Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r953 - in trunk/fox/grid_demo: Model/Groups scenes
- Date: Thu, 23 Feb 2006 00:43:46 -0700 (MST)
Author: abe
Date: Thu Feb 23 00:43:45 2006
New Revision: 953
Modified:
trunk/fox/grid_demo/Model/Groups/DyGridLoader.cc
trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.cc
trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.h
trunk/fox/grid_demo/Model/Groups/DyGridSingle.cc
trunk/fox/grid_demo/scenes/dygrid.cc
Log:
There is still a problem with the grid traversal. As well as a problem with
how parallel animation callbacks are deleted in RTRT.cc.
M fox/grid_demo/Model/Groups/DyGridSingle.cc
M fox/grid_demo/Model/Groups/DyGridParallelBuilder.cc
M fox/grid_demo/Model/Groups/DyGridParallelBuilder.h
M fox/grid_demo/Model/Groups/DyGridLoader.cc
M fox/grid_demo/scenes/dygrid.cc
Modified: trunk/fox/grid_demo/Model/Groups/DyGridLoader.cc
==============================================================================
--- trunk/fox/grid_demo/Model/Groups/DyGridLoader.cc (original)
+++ trunk/fox/grid_demo/Model/Groups/DyGridLoader.cc Thu Feb 23 00:43:45
2006
@@ -84,7 +84,7 @@
// Compute edges.
triangle.edge1 = raw_triangles[i].vertex[1] - raw_triangles[i].vertex[0];
- triangle.edge1 = raw_triangles[i].vertex[2] - raw_triangles[i].vertex[0];
+ triangle.edge2 = raw_triangles[i].vertex[2] - raw_triangles[i].vertex[0];
// Compute face normal if necessary.
TriangleNormal &normals = (*data->normal_array)[i];
Modified: trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.cc
==============================================================================
--- trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.cc (original)
+++ trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.cc Thu Feb 23
00:43:45 2006
@@ -30,15 +30,20 @@
#include <Model/Groups/DyGridData.h>
-
#include <SCIRun/Core/Thread/Barrier.h>
+#include <iostream>
+
using namespace Manta;
using namespace Manta::Dygrid;
using namespace SCIRun;
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// Single thread setup callback.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
void DyGridParallelBuilder::setupGridOneShot( int proc, int numProcs ) {
// This callback should only be invoked by one thread.
@@ -99,6 +104,8 @@
index_t total_cells = grid->N[0] * grid->N[1] * grid->N[2];
// index_t total_macro_cells = grid->N_mc[0] * grid->N_mc[1] *
grid->N_mc[2];
+
+ std::cerr << "Total grid cells: " << total_cells << "\n";
/////////////////////////////////////////////////////////////////////////////
// Resize the grid if necessary.
@@ -122,15 +129,53 @@
/////////////////////////////////////////////////////////////////////////////
// Request per thread storage.
+ size_t old_size = builder_cells.size();
+ if (old_size < numProcs) {
+
+ // Resize the array.
+ builder_cells.resize( numProcs );
+
+ // Initialize the pointers to zero.
+ for (int i=old_size;i<numProcs;++i) {
+ builder_cells[i] = 0;
+ }
+
+ }
+ else if (old_size > numProcs) {
+
+ // Free the extra cell arrays.
+ for (int i=numProcs-1;i<old_size;++i) {
+ delete builder_cells[i];
+ }
+
+ builder_cells.resize( numProcs );
+ }
}
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
// Parallel build callback.
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
void DyGridParallelBuilder::buildGridOneShot( int proc, int numProcs ) {
+ // Wait for all threads (including the one which performed setup)
+ build_barrier.wait( numProcs );
+
+
/////////////////////////////////////////////////////////////////////////////
// Obtain a pointer to the per-thread-grid cells for this thread.
- Array1<Cell> *thread_cells = 0;
+ Array1<Cell> *thread_cells = builder_cells[proc];
+
+ // Check to see if thread cell array must be initialized.
+ if (thread_cells == 0) {
+ builder_cells[proc] = new DyGridData::CellArray();
+ thread_cells = builder_cells[proc];
+
+ // Resize the thread cells.
+ index_t total_cells = grid->N[0] * grid->N[1] * grid->N[2];
+ thread_cells->resize( total_cells );
+ }
- // THE ABOVE LINE CAUSES THE BUILD TO BREAK.
/////////////////////////////////////////////////////////////////////////////
// Determine which portion of the triangles to add to this thread's grid.
@@ -181,7 +226,7 @@
/////////////////////////////////////////////////////////////////////////////
// Merge Stage
const int startZ = (grid->N[2] * proc)/numProcs;
- const int endZ = (grid->N[2] * proc)/numProcs;
+ const int endZ = (grid->N[2] * (proc+1))/numProcs;
for (int z=startZ; z<endZ; ++z) {
for (int y=0;y<grid->N[1];++y) {
Modified: trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.h
==============================================================================
--- trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.h (original)
+++ trunk/fox/grid_demo/Model/Groups/DyGridParallelBuilder.h Thu Feb 23
00:43:45 2006
@@ -78,7 +78,7 @@
// Array of pointers to cell arrays, allocated by each builder thread.
Array1< Array1<Cell> * > builder_cells;
-
+
DyGridParallelBuilder( const DyGridParallelBuilder & );
DyGridParallelBuilder &operator= ( const DyGridParallelBuilder & );
};
Modified: trunk/fox/grid_demo/Model/Groups/DyGridSingle.cc
==============================================================================
--- trunk/fox/grid_demo/Model/Groups/DyGridSingle.cc (original)
+++ trunk/fox/grid_demo/Model/Groups/DyGridSingle.cc Thu Feb 23 00:43:45
2006
@@ -48,7 +48,9 @@
///////////////////////////////////////////////////////////////////////////////
void DyGridSingle::intersect(const RenderContext& context, RayPacket& rays)
const {
+ rays.normalizeDirections();
rays.computeInverseDirections();
+ rays.computeSigns();
// Intersect rays individually.
for (int i=rays.begin();i<rays.end();++i) {
@@ -65,7 +67,7 @@
void DyGridSingle::intersect_ray( const RenderContext& context, RayPacket&
rays,
const int which ) const {
- Real t_near, t_far, t_exit, t0, t1;
+ Real t_near, t_far, t_exit;
Vector dt; // Delta in t.
Vector di; // Delta in index.
@@ -87,15 +89,13 @@
t_near, t_far,
rays.getRay( which ),
rays.getSigns( which ),
- inv_direction,
- T_EPSILON,
- rays.getMinT( which ))) {
+ inv_direction )) {
return;
}
// Determine the actual minimum distance.
- // t_near = SCIRun::Max( t_near, T_EPSILON );
- // t_far = SCIRun::Min( t_far, rays.getMinT(i) );
+ t_near = SCIRun::Max( t_near, T_EPSILON );
+ t_far = SCIRun::Min( t_far, rays.getMinT(which) );
// Check to see if a hit is possible.
if (t_near > t_far)
Modified: trunk/fox/grid_demo/scenes/dygrid.cc
==============================================================================
--- trunk/fox/grid_demo/scenes/dygrid.cc (original)
+++ trunk/fox/grid_demo/scenes/dygrid.cc Thu Feb 23 00:43:45 2006
@@ -119,7 +119,7 @@
Dygrid::load( grid_data, file_name.c_str() );
// Create a single ray traversal grid.
- DyGridSingle *grid = new DyGridSingle( grid_data, new Flat( new
NormalTexture ) );
+ DyGridSingle *grid = new DyGridSingle( grid_data, new Lambertian( new
RaySignTexture ) );
scene->setObject( grid );
// Create a loose parallel builder.
- [MANTA] r953 - in trunk/fox/grid_demo: Model/Groups scenes, abe, 02/23/2006
Archive powered by MHonArc 2.6.16.