Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r885 - in trunk: . Core/Util fox/disco_demo/Engine/ImageTraversers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r885 - in trunk: . Core/Util fox/disco_demo/Engine/ImageTraversers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface
  • Date: Fri, 3 Feb 2006 14:50:48 -0700 (MST)

Author: bigler
Date: Fri Feb  3 14:50:45 2006
New Revision: 885

Modified:
   trunk/CMakeLists.txt
   trunk/Core/Util/ThreadStorage.h
   trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
   trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
   trunk/fox/disco_demo/Engine/Shaders/AOShader.h
   trunk/fox/disco_demo/Interface/DiscoTile.cc
   trunk/fox/disco_demo/Interface/DiscoTile.h
   trunk/fox/disco_demo/Interface/NeighborhoodShader.h
   trunk/fox/disco_demo/Interface/TilePacket.h
Log:

CMakeLists.txt

  Place MantaTypes in binary directory instead of source directory.
  This allows you to configure differently if you have more than one
  build pointing to the same source.  Note:  There are still some
  other template code being dumped in the source directory.  I haven't
  gotten to them yet.

  Add the binary directory to the include path for compilation.

Core/Util/ThreadStorage.h

  Make sure the token fits under the requested amount of memory
  available.

fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc

  The DiscoTile class is now on the stack, but the memory for the
  TilePackets is still on the heap.

fox/disco_demo/Engine/Shaders/AOShader.cc
fox/disco_demo/Engine/Shaders/AOShader.h
fox/disco_demo/Interface/NeighborhoodShader.h

  shade() now takes a DiscoTile& instead of DiscoTile*.

fox/disco_demo/Interface/DiscoTile.cc
fox/disco_demo/Interface/DiscoTile.h

  DiscoTile is now pulls only the memory for the TilePackets from the
  ThreadStorage rather than the whole structure.

fox/disco_demo/Interface/TilePacket.h

  Added resetFlags() that assigns 0 to all the flags.


Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt        (original)
+++ trunk/CMakeLists.txt        Fri Feb  3 14:50:45 2006
@@ -137,6 +137,9 @@
 
   # For now force sproc on IRIX systems.
   #  MESSAGE("Forcing Irix Threads")
+#   SET(CMAKE_USE_SPROC_INIT 1)
+#   SET(CMAKE_USE_PTHREADS_INIT 0)
+#   SET(CMAKE_THREAD_LIBS_INIT -lfetchop)
   SET(CMAKE_USE_SPROC_INIT 0)
   SET(CMAKE_USE_PTHREADS_INIT 1)
   SET(CMAKE_THREAD_LIBS_INIT -lpthread -lfetchop)
@@ -176,8 +179,12 @@
 
 CONFIGURE_FILE(
   ${CMAKE_SOURCE_DIR}/MantaTypes.h.CMakeTemplate
-  ${CMAKE_SOURCE_DIR}/MantaTypes.h
+  ${CMAKE_BINARY_DIR}/MantaTypes.h
   )
+
+##################################################################
+#Add the build path to the include search path
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
 
 IF (OPENGL_INCLUDE_PATH)
   INCLUDE_DIRECTORIES (${OPENGL_INCLUDE_PATH})

Modified: trunk/Core/Util/ThreadStorage.h
==============================================================================
--- trunk/Core/Util/ThreadStorage.h     (original)
+++ trunk/Core/Util/ThreadStorage.h     Fri Feb  3 14:50:45 2006
@@ -129,7 +129,7 @@
       ASSERT(storage[proc]);
       if (storage[proc]) {
 
-        ASSERT(token.offset < requested);
+        ASSERT(token.offset+token.size <= requested)
         return storage[proc]+token.offset;
       }
     }

Modified: trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc  
(original)
+++ trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc  Fri 
Feb  3 14:50:45 2006
@@ -118,20 +118,19 @@
   context.renderer->setupFrame( context );
 }
 
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 // Render Image Method
 //
-////////////////////////////////////////////////////////////////////////////////
-void DiscoImageTraverser::renderImage(const RenderContext& context, Image* 
image)
+///////////////////////////////////////////////////////////////////////////////
+void DiscoImageTraverser::renderImage(const RenderContext& context,
+                                      Image* image)
 {
 
   // Obtain a pointer to persistant storage and initialize it.
-  DiscoTile *disco_tile = new ( ThreadStorage::Allocator( context, 
storage_token),
-                                xtilesize,
-                                ytilesize,
-                                overlap ) DiscoTile;
-    
+  DiscoTile disco_tile( ThreadStorage::Allocator( context, storage_token),
+                        xtilesize, ytilesize, overlap );
+
   // Determine resolution
   bool stereo;
   int xres, yres;
@@ -140,7 +139,7 @@
   
/////////////////////////////////////////////////////////////////////////////
   // Call the load balancer to get work assignments.
   int kernel_width = overlap*2+1;
-  
+
   int s,e;
   while(context.loadBalancer->getNextAssignment(context, s, e)){
 
@@ -150,7 +149,7 @@
       // Place pixels in the tile.
 
       // The following are bounds of the actual tile--ignoring overlap.
-      
+
       // Determine which tile.
       int xtile = assignment/ytiles;
       int ytile = assignment%ytiles;
@@ -171,7 +170,7 @@
 
       RayPacketData ray_data;
       RayPacket     ray_packet( ray_data, 0, 0, 0, flags );
-      
+
       // Total number of rays in packet.
       int packet_size = 0;
 
@@ -181,18 +180,19 @@
       // Iterate across the tile.
       for (int y=-overlap;y<ytile_end+overlap;++y) {
         for (int x=-overlap;x<xtile_end+overlap;++x) {

-          TilePacket::Element &t = disco_tile->get( x, y );
-          
+
+          TilePacket::Element &t = disco_tile.get( x, y );
+
           
/////////////////////////////////////////////////////////////////////
           // Initialize the tile.
-          
+
           t.tilex = x;
           t.tiley = y;
-          t.flags =
-            ((x<0 || x>=xtilesize) ||
-             (y<0 || y>=ytilesize)) << 1;
-                      
+          // We need to flag the Element as being an "overlap" tile.
+          // As it turns out the value of this is 0x02.
+          t.flags = ((x<0 || x>=xtilesize) ||
+                     (y<0 || y>=ytilesize)) << 1;
+
           
/////////////////////////////////////////////////////////////////////
           // Initialize the ray packet element
           Real px = (xstart + x) * xscale + xoffset;
@@ -200,15 +200,15 @@
 
           // Set image space pixel coordinates.
           ray_packet.setPixel( packet_size++, 0, px, py );
-          
+
           // Check to see if a whole ray packet was filled.
           if (packet_size==RayPacket::MaxSize) {
 
             // Create a tile packet.
-            TilePacket tile_packet( disco_tile->getTilePacketData( 
packet_sent++ ),
+            TilePacket tile_packet( disco_tile.getTilePacketData( 
packet_sent++ ),
                                     RayPacket::MaxSize );
             ray_packet.resize( RayPacket::MaxSize );
-            
+
             // Render the packet.
             disco_renderer->traceEyeRays( context, ray_packet, tile_packet );
 
@@ -223,8 +223,8 @@
       // Check to see if there are any left over rays.
       if (packet_size != 0) {
         // Create a tile packet with the remaining rays.
-        TilePacket tile_packet( disco_tile->getTilePacketData( packet_sent++ 
),
-                           packet_size );
+        TilePacket tile_packet( disco_tile.getTilePacketData( packet_sent++ 
),
+                                packet_size );
         
         // Render the packet.
         ray_packet.resize( packet_size );
@@ -241,8 +241,8 @@
         // called on all of the samples, including overlap.
 
         // Create a tile packet.
-        TilePacket tile_packet( disco_tile->getTilePacketData( i ),
-                                disco_tile->getPacketSize( i ) );
+        TilePacket tile_packet( disco_tile.getTilePacketData( i ),
+                                disco_tile.getPacketSize( i ) );
         
         
///////////////////////////////////////////////////////////////////////
         // Shade the packet

Modified: trunk/fox/disco_demo/Engine/Shaders/AOShader.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/Shaders/AOShader.cc     (original)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.cc     Fri Feb  3 14:50:45 
2006
@@ -294,7 +294,7 @@
 
     TilePacket::Element &p = tile_packet.get( i - ray_packet.begin());
     
-    p.illuminance = (Real)1.0 -( (Real)total_hits[i] / (Real)task_size );
+    p.illuminance = 1 - ( total_hits[i] / task_size );
     
     // Copy over the material color and normal
     p.color  = ray_packet.getColor( i ); // Color(RGB(1,1,1));
@@ -322,9 +322,9 @@
 
 /////////////////////////////////////////////////////////////////////////////
 // Shader method
-void AONeighborhoodShader::shade( const RenderContext &context,
-                                  DiscoTile *disco_tile,
-                                  TilePacket &tile_packet ) {
+void AONeighborhoodShader::shade( const RenderContext& context,
+                                  DiscoTile& disco_tile,
+                                  TilePacket& tile_packet ) {
 
   
   
@@ -355,24 +355,22 @@
         for (int x_offset=-half_width;x_offset<=half_width;++x_offset) {
           
           TilePacket::Element &neighbor =
-            disco_tile->get( x+x_offset,y+y_offset );
+            disco_tile.get( x+x_offset,y+y_offset );
           
           if (neighbor.wasHit()) {
 
             Real d = SCIRun::Abs( (p.point-neighbor.point).length2() );
-            Real n = SCIRun::Max((Real)0.0,Dot( normal, neighbor.normal ));
-            Real pixel_dist = SCIRun::Sqrt( x_offset*x_offset + 
y_offset*y_offset ) * p.t;
+            Real n = SCIRun::Max((Real)0,Dot( normal, neighbor.normal ));
+            Real pixel_dist = SCIRun::Sqrt( x_offset*x_offset +
+                                            y_offset*y_offset ) * p.t;
             
-            if ((n > 0) && (d <= 0.009*pixel_dist)) {
+            if ((n > 0) && (d <= (Real)0.009*pixel_dist)) {
 
 
-              Real weight = (Real)1.0 / SCIRun::Sqrt( ((Real)1.0 - n) + 
(Real)0.001 );
+              Real weight = 1 / SCIRun::Sqrt( (1 - n) + (Real)0.001 );
               
               // Look up the neighbor value.
-              Real hit_ratio = weight * 
-                disco_tile->
-                get( x+x_offset,
-                     y+y_offset ).illuminance;
+              Real hit_ratio = weight * neighbor.illuminance;
               
               // Sum up all of the neighbors.
               sum += hit_ratio;

Modified: trunk/fox/disco_demo/Engine/Shaders/AOShader.h
==============================================================================
--- trunk/fox/disco_demo/Engine/Shaders/AOShader.h      (original)
+++ trunk/fox/disco_demo/Engine/Shaders/AOShader.h      Fri Feb  3 14:50:45 
2006
@@ -91,9 +91,9 @@
       virtual void setupDisplayChannel(SetupContext& context);
       virtual void setupFrame(const RenderContext& context);
 
-      virtual void shade( const RenderContext &context,
-                          DiscoTile *disco_tile,
-                          TilePacket &tile_packet );
+      virtual void shade( const RenderContext& context,
+                          DiscoTile& disco_tile,
+                          TilePacket& tile_packet );
     private:
       int kernel_width;
     };

Modified: trunk/fox/disco_demo/Interface/DiscoTile.cc
==============================================================================
--- trunk/fox/disco_demo/Interface/DiscoTile.cc (original)
+++ trunk/fox/disco_demo/Interface/DiscoTile.cc Fri Feb  3 14:50:45 2006
@@ -36,18 +36,10 @@
   // Total number of pixels.
   size_t total_pixels = (xtilesize+2*overlap) * (ytilesize+2*overlap);
   
-  // Determine amount of space for ray packet elements and
-  // tile packet elements.
+  // Determine amount of space for the tile packet elements.
   size_t tilepacket_bytes = total_pixels * sizeof(TilePacket::Element);
 
-  // Determine how much continous space for the whole structure
-  // including arrays. With buffer space for aligning the arrays to cache.
-  size_t total_bytes =
-    sizeof(DiscoTile) +
-    tilepacket_bytes +
-    128*3;
-
-  return total_bytes;
+  return tilepacket_bytes;
 }
 
 
@@ -63,30 +55,19 @@
 }
 
 // Initialize DiscoTile of a given size in thread local storage.
-void *DiscoTile::operator new( size_t bytes,
-                               const ThreadStorage::Allocator &allocator,
-                               int xtilesize,
-                               int ytilesize,
-                               int overlap ) {
-  
-  // Obtain a pointer to the tile
-  DiscoTile *disco_tile = (DiscoTile *)(*allocator);
-
-  // Initialize.
-  disco_tile->width   = xtilesize+2*overlap;
-  disco_tile->height  = ytilesize+2*overlap;
-  disco_tile->overlap = overlap;
-  disco_tile->total   = disco_tile->width * disco_tile->height;
-
-  
/////////////////////////////////////////////////////////////////////////////
-  // Compute offsets into the memory for each array.
-  size_t allocated = sizeof(DiscoTile);
-  size_t tilepacket_offset = ((allocated/128)+1)*128;
-
-  // Point arrays to allocated memory.
-  disco_tile->tilepacket_data = (TilePacket::Element *)((char *)disco_tile + 
tilepacket_offset);
-
-  return disco_tile;
+DiscoTile::DiscoTile(const ThreadStorage::Allocator &allocator,
+                     int xtilesize, int ytilesize, int overlap):
+  width(xtilesize+2*overlap),
+  height(ytilesize+2*overlap),
+  overlap(overlap),
+  total(width * height)
+{
+#if SCI_ASSERTION_LEVEL >= 2
+  size_t total_bytes = total * sizeof(TilePacket::Element);
+  tilepacket_data = (TilePacket::Element*)(allocator.check_fit(total_bytes));
+#else
+  tilepacket_data = (TilePacket::Element*)(*allocator);
+#endif
 }
 
 

Modified: trunk/fox/disco_demo/Interface/DiscoTile.h
==============================================================================
--- trunk/fox/disco_demo/Interface/DiscoTile.h  (original)
+++ trunk/fox/disco_demo/Interface/DiscoTile.h  Fri Feb  3 14:50:45 2006
@@ -56,11 +56,8 @@
                                                 int overlap = 1 );
     
     // Initialize DiscoTile of a given size in thread local storage.
-    void *DiscoTile::operator new( size_t bytes,
-                                   const ThreadStorage::Allocator &allocator,
-                                   int xtilesize,
-                                   int ytilesize,
-                                   int overlap = 1);
+    DiscoTile( const ThreadStorage::Allocator &allocator,
+               int xtilesize, int ytilesize, int overlap = 1);
 
     DiscoTile() { }; // Use thread local storage methods.
     
@@ -79,8 +76,8 @@
     // TilePacket Accessors, caller is responsible for determining size.
     TilePacketData &getTilePacketData( int i ) {
       size_t index = i*RayPacket::MaxSize;
-      ASSERT(index < total);      
-      return *((TilePacketData *)&tilepacket_data[i*RayPacket::MaxSize]);
+      ASSERT(index < total);
+      return *((TilePacketData *)&tilepacket_data[index]);
     };
 
     int getPacketSize( int i ) {
@@ -98,6 +95,7 @@
     // Array indexing.
     int get_offset( int x, int y ) { return y*(width) + x; }
 
+    // This tells up how much data to allocate for the tilepacket_data.
     static size_t compute_size( int xtilesize, int ytilesize, int overlap );
     
     
///////////////////////////////////////////////////////////////////////////

Modified: trunk/fox/disco_demo/Interface/NeighborhoodShader.h
==============================================================================
--- trunk/fox/disco_demo/Interface/NeighborhoodShader.h (original)
+++ trunk/fox/disco_demo/Interface/NeighborhoodShader.h Fri Feb  3 14:50:45 
2006
@@ -55,9 +55,9 @@
     virtual void setupFrame(const RenderContext& context) = 0;
 
     // Shader method.
-    virtual void shade( const RenderContext &context,
-                        DiscoTile *disco_tile,
-                        TilePacket &tile_packet ) = 0;
+    virtual void shade( const RenderContext& context,
+                        DiscoTile& disco_tile,
+                        TilePacket& tile_packet ) = 0;
   private:
     NeighborhoodShader(const NeighborhoodShader&);
     NeighborhoodShader& operator=(const NeighborhoodShader&);

Modified: trunk/fox/disco_demo/Interface/TilePacket.h
==============================================================================
--- trunk/fox/disco_demo/Interface/TilePacket.h (original)
+++ trunk/fox/disco_demo/Interface/TilePacket.h Fri Feb  3 14:50:45 2006
@@ -93,7 +93,12 @@
 
     bool wasHit( int i )     { return  data[i].wasHit(); }
     bool isOverlap( int i )  { return  data[i].isOverlap(); }
-    
+
+    void resetFlags() {
+      for(int i = 0; i < size; ++i ) {
+        data[i].flags = 0;
+      }
+    }
   private:
     // Size member of the ray packet is used.
     int size;




  • [MANTA] r885 - in trunk: . Core/Util fox/disco_demo/Engine/ImageTraversers fox/disco_demo/Engine/Shaders fox/disco_demo/Interface, bigler, 02/03/2006

Archive powered by MHonArc 2.6.16.

Top of page