Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r848 - in trunk/fox/disco_demo: . Engine/ImageTraversers Engine/Renderers Engine/Shaders Interface
- Date: Wed, 18 Jan 2006 15:01:46 -0700 (MST)
Author: abe
Date: Wed Jan 18 15:01:45 2006
New Revision: 848
Removed:
trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.cc
trunk/fox/disco_demo/Engine/Shaders/DepthMapShader.h
Modified:
trunk/fox/disco_demo/CMakeLists.txt
trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
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/PerSampleShader.h
trunk/fox/disco_demo/Interface/TilePacket.h
Log:
Reduced footprint of persistant tile data by placing ray packets on stack
instead of in thread local storage.
M fox/disco_demo/Interface/DiscoTile.cc
M fox/disco_demo/Interface/NeighborhoodShader.h
M fox/disco_demo/Interface/DiscoTile.h
M fox/disco_demo/Interface/PerSampleShader.h
M fox/disco_demo/Interface/TilePacket.h
M fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.cc
M fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
M fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
M fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
D fox/disco_demo/Engine/Shaders/DepthMapShader.h
M fox/disco_demo/Engine/Shaders/AOShader.cc
M fox/disco_demo/Engine/Shaders/AOShader.h
D fox/disco_demo/Engine/Shaders/DepthMapShader.cc
M fox/disco_demo/CMakeLists.txt
Modified: trunk/fox/disco_demo/CMakeLists.txt
==============================================================================
--- trunk/fox/disco_demo/CMakeLists.txt (original)
+++ trunk/fox/disco_demo/CMakeLists.txt Wed Jan 18 15:01:45 2006
@@ -12,8 +12,6 @@
Engine/ImageTraversers/DiscoImageTraverser.h
Engine/Renderers/DiscoRayTracer.cc
Engine/Renderers/DiscoRayTracer.h
- Engine/Shaders/DepthMapShader.cc
- Engine/Shaders/DepthMapShader.h
Engine/Shaders/AOShader.cc
Engine/Shaders/AOShader.h
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 Wed
Jan 18 15:01:45 2006
@@ -118,6 +118,11 @@
context.renderer->setupFrame( context );
}
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// Render Image Method
+//
+////////////////////////////////////////////////////////////////////////////////
void DiscoImageTraverser::renderImage(const RenderContext& context, Image*
image)
{
@@ -157,69 +162,85 @@
int xtile_end = (xend > xres) ? xres-xstart : xtilesize;
int ytile_end = (yend > yres) ? yres-ystart : ytilesize;
-
+
/////////////////////////////////////////////////////////////////////////
- // Initialize ray packet elements.
- int total_elements = 0;
+ // Create ray packet on the stack.
+ int flags = RayPacket::HaveImageCoordinates | RayPacket::ConstantEye;
+
+ RayPacketData ray_data;
+ RayPacket ray_packet( ray_data, 0, 0, flags );
+
+ // Total number of rays in packet.
+ int packet_size = 0;
+
+ // Total number of packets
+ int packet_sent = 0;
+
+ // Iterate across the tile.
for (int y=-1;y<=ytile_end;++y) {
for (int x=-1;x<=xtile_end;++x) {
+
+ TilePacket::Element &t = disco_tile->get( x, y );
- RayPacket::Element &r = disco_tile->getRayPacketElement( x, y );
- TilePacket::Element &t = disco_tile->getTilePacketElement( x, y );
-
/////////////////////////////////////////////////////////////////////
// Initialize the tile.
+
t.tilex = x;
t.tiley = y;
- t.overlap =
- (x<0 || x>=xtilesize) ||
- (y<0 || y>=ytilesize) ;
-
- // t.task = (total_elements++)%kernel_width;
-
+ t.flags =
+ ((x<0 || x>=xtilesize) ||
+ (y<0 || y>=ytilesize)) << 1;
+
/////////////////////////////////////////////////////////////////////
// Initialize the ray packet element
- r.imageX = (xstart + x) * xscale + xoffset;
- r.imageY = (ystart + y) * yscale + yoffset;
- r.whichEye = 0;
- }
- }
-
-
/////////////////////////////////////////////////////////////////////////
- // Create ray packets from disco tile and render.
- int flags = RayPacket::HaveImageCoordinates | RayPacket::ConstantEye;
+ Real px = (xstart + x) * xscale + xoffset;
+ Real py = (ystart + y) * yscale + yoffset;
- int total_packets = (disco_tile->getTotalElements() /
RayPacket::MaxSize) +
- ((disco_tile->getTotalElements() % RayPacket::MaxSize) != 0);
+ // 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) {
- for (int i=0;i<total_packets; ++i) {
+ // Create a tile packet.
+ 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 );
- // Create a tile packet.
- TilePacket packet( disco_tile->getRayPacketData( i ),
- disco_tile->getTilePacketData( i ),
- disco_tile->getPacketSize( i ),
- 0,
- flags );
+ ray_packet.setAllFlags( flags );
+ packet_size = 0;
+ }
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////////
+ // 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 );
+
// Render the packet.
- disco_renderer->traceEyeRays( context, packet );
+ ray_packet.resize( packet_size );
+ disco_renderer->traceEyeRays( context, ray_packet, tile_packet );
}
/////////////////////////////////////////////////////////////////////////
// Call the neighborhood shader and write image results.
Fragment fragment;
-
- for (int i=0;i<total_packets; ++i) {
+ for (int i=0;i<packet_sent; ++i) {
// Since we don't where the overlap is in the packets, the shader is
// called on all of the samples, including overlap.
+
// Create a tile packet.
- TilePacket tile_packet( disco_tile->getRayPacketData( i ),
- disco_tile->getTilePacketData( i ),
- disco_tile->getPacketSize( i ),
- 0,
- flags );
+ TilePacket tile_packet( disco_tile->getTilePacketData( i ),
+ disco_tile->getPacketSize( i ) );
///////////////////////////////////////////////////////////////////////
// Shade the packet
@@ -227,18 +248,15 @@
// Find the first hit.
int start = 0;
- // This is necessary since calling raypacket.computeNormals assumes
- // that all of the rays in the packet hit something and have a valid
- // primitive pointer.
for (;start<tile_packet.getSize();++start) {
while ((start<tile_packet.getSize()) &&
- !tile_packet.hitInfo(start).wasHit())
+ !tile_packet.wasHit(start))
++start;
// Find a run of elements that generated hits.
int end = start;
- while (end < tile_packet.getSize() &&
tile_packet.hitInfo(end).wasHit())
+ while (end < tile_packet.getSize() && tile_packet.wasHit(end))
++end;
// Create a sub packet of elements which generated hits.
@@ -255,11 +273,10 @@
for (int j=0;j<tile_packet.getSize();++j) {
// Make sure the element isn't part of the overlap.
- TilePacket::Element &t = tile_packet.getTilePacketElement( j );
- if (!t.overlap) {
+ if (!tile_packet.isOverlap(j)) {
Fragment::Element &f = fragment.get( fragment_size++ );
- RayPacket::Element &r = tile_packet.getRayPacketElement( j );
+ TilePacket::Element &t = tile_packet.get( j );
// Pixel coordinates.
f.which_eye = 0;
@@ -267,12 +284,11 @@
f.y = t.tiley + ystart;
// Result
- f.color = r.color;
+ f.color = t.color;
}
}
fragment.setSize( fragment_size );
-
// Set image values.
image->set( fragment );
Modified: trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
==============================================================================
--- trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h
(original)
+++ trunk/fox/disco_demo/Engine/ImageTraversers/DiscoImageTraverser.h Wed
Jan 18 15:01:45 2006
@@ -58,7 +58,7 @@
///////////////////////////////////////////////////////////////////////////
// Constructors
DiscoImageTraverser( int xtilesize_, int ytilesize_, int overlap_,
- DiscoRayTracer *disco_renderer_,
+ DiscoRayTracer *disco_renderer_,
NeighborhoodShader *neighborhood_shader_ );
virtual ~DiscoImageTraverser();
Modified: trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc
==============================================================================
--- trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc (original)
+++ trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.cc Wed Jan 18
15:01:45 2006
@@ -98,37 +98,44 @@
///////////////////////////////////////////////////////////////////////////////
// Disco Renderer Methods.
-void DiscoRayTracer::traceEyeRays(const RenderContext& context, TilePacket&
tile_packet)
+void DiscoRayTracer::traceEyeRays(const RenderContext& context, RayPacket
&ray_packet, TilePacket& tile_packet)
{
- ASSERT(tile_packet.getFlag(RayPacket::HaveImageCoordinates));
+ ASSERT(ray_packet.getFlag(RayPacket::HaveImageCoordinates));
// Compute ray origin & direction using the camera.
- context.camera->makeRays( tile_packet );
- tile_packet.initializeImportance();
+ context.camera->makeRays( ray_packet );
+ ray_packet.initializeImportance();
- traceRays(context, tile_packet);
+ traceRays(context, ray_packet, tile_packet );
}
-void DiscoRayTracer::traceRays(const RenderContext& context, TilePacket&
tile_packet)
+void DiscoRayTracer::traceRays(const RenderContext& context, RayPacket
&ray_packet, TilePacket& tile_packet)
{
// Intersect the ray packet with the scene.
- tile_packet.resetHit();
- context.scene->getObject()->intersect(context, tile_packet);
+ ray_packet.resetHit();
+ context.scene->getObject()->intersect(context, ray_packet);
// Send hit rays to the per sample shader and missed rays to
// the background shader.
- for(int i = 0;i<tile_packet.getSize();){
+ for(int i = 0;i<ray_packet.getSize();){
// Call the per-sample shader.
- if(tile_packet.hitInfo(i).wasHit()){
+ if(ray_packet.hitInfo(i).wasHit()){
int end = i+1;
- while(end < tile_packet.getSize() && tile_packet.hitInfo(end).wasHit())
- end++;
- TilePacket sub_packet(tile_packet, i, end);
- per_sample_shader->shade( context, sub_packet );
+ // Set the tile packet hit flag.
+ tile_packet.get(i).flags |= TilePacket::WAS_HIT;
+
+ while(end < ray_packet.getSize() && ray_packet.hitInfo(end).wasHit()) {
+ tile_packet.get(end++).flags |= TilePacket::WAS_HIT;
+ }
+
+ RayPacket sub_ray_packet (ray_packet, i, end);
+ TilePacket sub_tile_packet(tile_packet, i, end);
+
+ per_sample_shader->shade( context, sub_ray_packet, sub_tile_packet );
i=end;
@@ -137,11 +144,16 @@
// Call the background shader.
else {
int end = i+1;
- while(end < tile_packet.getSize() &&
!tile_packet.hitInfo(end).wasHit())
+ while(end < ray_packet.getSize() && !ray_packet.hitInfo(end).wasHit())
end++;
- TilePacket subPacket(tile_packet, i, end);
+ RayPacket subPacket(ray_packet, i, end);
context.scene->getBackground()->shade(context, subPacket);
+
+ // Copy the background color over to the tile packet.
+ for (int j=i;j<end;++j) {
+ tile_packet.get(j).color = ray_packet.get(j).color;
+ }
i=end;
}
Modified: trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h
==============================================================================
--- trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h (original)
+++ trunk/fox/disco_demo/Engine/Renderers/DiscoRayTracer.h Wed Jan 18
15:01:45 2006
@@ -55,13 +55,13 @@
virtual void setupDisplayChannel(SetupContext&);
virtual void setupFrame(const RenderContext& context);
- // These functions should not be called.
+ // These functions should not be called for image generation.
virtual void traceEyeRays(const RenderContext&, RayPacket& rays);
virtual void traceRays(const RenderContext&, RayPacket& rays);
// These methods should be used instead.
- virtual void traceEyeRays(const RenderContext& context, TilePacket&
tile_packet);
- virtual void traceRays(const RenderContext& context, TilePacket&
tile_packet);
+ virtual void traceEyeRays(const RenderContext& context, RayPacket
&ray_packet, TilePacket& tile_packet);
+ virtual void traceRays(const RenderContext& context, RayPacket
&ray_packet, TilePacket& tile_packet);
// Accessors.
PerSampleShader *getPerSampleShader() { return per_sample_shader; };
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 Wed Jan 18 15:01:45
2006
@@ -135,13 +135,10 @@
/////////////////////////////////////////////////////////////////////////
// Generate cosine weighted directions
- // MT_RNG rng;
HaltonSequence<Real,2> sequence( context.proc*100 );
PointT<Real,2> p;
for ( int i = 0; i < total_directions; i++ ) {
- // Real r1 = rng.genRealRand<Real>();
- // Real r2 = rng.genRealRand<Real>();
sequence.next( p );
@@ -160,7 +157,7 @@
/////////////////////////////////////////////////////////////////////////////
// Shader Method
-void AOSampleShader::shade( const RenderContext &context, TilePacket &packet
) {
+void AOSampleShader::shade( const RenderContext &context, RayPacket
&ray_packet, TilePacket &tile_packet ) {
// Obtain a pointer to the array.
Vector *directions = (Vector *)context.storage_allocator->get(
context.proc, storage_token );
@@ -171,11 +168,11 @@
///////////////////////////////////////////////////////////////////////////
// Compute normals and hit positions.
- packet.computeNormals(context);
- packet.computeHitPositions();
+ ray_packet.computeNormals(context);
+ ray_packet.computeHitPositions();
// Set ray packet colors.
- shade_materials( context, packet );
+ // shade_materials( context, ray_packet );
///////////////////////////////////////////////////////////////////////////
// Compute local coordinate system for each hit position.
@@ -184,12 +181,12 @@
Vector W[RayPacket::MaxSize];
int kernel_size = kernel_width*kernel_width;
- int overlap = (kernel_width-1)/2;
- int task_size = total_directions / kernel_size;
+ int overlap = (kernel_width-1)/2;
+ int task_size = total_directions / kernel_size;
- for (int i=0;i<packet.getSize();++i) {
+ for (int i=0;i<ray_packet.getSize();++i) {
- RayPacket::Element &e = packet.get(i);
+ RayPacket::Element &e = ray_packet.get(i);
W[i] = e.normal;
W[i].normalize();
@@ -215,9 +212,10 @@
///////////////////////////////////////////////////////////////////////////
// Decide which directions to shoot based on TilePacket element task id.
- for (int i=0;i<packet.getSize();++i) {
- TilePacket::Element &p = packet.getTilePacketElement( i );
- RayPacket::Element &e = packet.getRayPacketElement ( i );
+ for (int i=0;i<ray_packet.getSize();++i) {
+
+ TilePacket::Element &p = tile_packet.get( i );
+ RayPacket::Element &e = ray_packet.get ( i );
int task =
((p.tilex+overlap)%kernel_width) +
@@ -285,8 +283,11 @@
////////////////////////////////////////////////////////////////////////
// Determine hit ratio.
- p.scratch_pad<DiscoInfo>().hit_ratio = ( total_hit / total_sent );
+ p.illuminance = ( total_hit / total_sent );
+ // Copy over the material color and normal
+ p.color = Color(RGB(1,1,1));
+ p.normal = e.normal;
}
}
@@ -310,77 +311,60 @@
// Shader method
void AONeighborhoodShader::shade( const RenderContext &context,
DiscoTile *disco_tile,
- TilePacket &packet ) {
+ TilePacket &tile_packet ) {
- // Compute normals.
- packet.computeNormals( context );
-
/////////////////////////////////////////////////////////////////////////////
// Filter the hit ratios from neighboring pixels.
- for (int i=0;i<packet.getSize();++i) {
+ for (int i=0;i<tile_packet.getSize();++i) {
- TilePacket::Element &p = packet.getTilePacketElement( i );
+ TilePacket::Element &p = tile_packet.get( i );
// Check to see if the element is part of the tile.
- if (!p.overlap) {
- RayPacket::Element &e = packet.get( i );
-
- // Make sure the element generated a hit.
- // if (e.hitInfo.wasHit()) {
+ if (!p.isOverlap()) {
- // Determine the location of this element.
- int x = p.tilex;
- int y = p.tiley;
-
- // Find normal.
- Vector &normal = e.normal;
-
- Real sum = 0.0;
- Real total = 0.0;
-
-
///////////////////////////////////////////////////////////////////////
- // Convolve.
- int half_width = (kernel_width-1)/2;
-
- // Use an averaging filter.
- // Real filter_value = 1.0/(Real)(kernel_width*kernel_width);
-
- for (int y_offset=-half_width;y_offset<=half_width;++y_offset) {
- for (int x_offset=-half_width;x_offset<=half_width;++x_offset) {
-
- RayPacket::Element &neighbor_ray =
- disco_tile->getRayPacketElement( x+x_offset,y+y_offset );
+ // Determine the location of this element.
+ int x = p.tilex;
+ int y = p.tiley;
+
+ // Find normal.
+ Vector &normal = p.normal;
+
+ Real sum = 0.0;
+ Real total = 0.0;
+
+ ///////////////////////////////////////////////////////////////////////
+ // Convolve.
+ int half_width = (kernel_width-1)/2;
- if (neighbor_ray.hitInfo.wasHit()) {
-
- // Check dot product.
- Real d = SCIRun::Max((Real)0.0,Dot( normal,
neighbor_ray.normal ));
-
- // Look up the neighbor value.
- Real hit_ratio = d *
- disco_tile->
- getTilePacketElement( x+x_offset,
- y+y_offset
).scratch_pad<DiscoInfo>().hit_ratio;
-
- // Sum up all of the neighbors.
- sum += hit_ratio;
- total += d;
- }
-
+ for (int y_offset=-half_width;y_offset<=half_width;++y_offset) {
+ for (int x_offset=-half_width;x_offset<=half_width;++x_offset) {
+
+ TilePacket::Element &neighbor =
+ disco_tile->get( x+x_offset,y+y_offset );
+
+ if (neighbor.wasHit()) {
+
+ // Check dot product.
+ Real d = SCIRun::Max((Real)0.0,Dot( normal, neighbor.normal ));
+
+ // Look up the neighbor value.
+ Real hit_ratio = d *
+ disco_tile->
+ get( x+x_offset,
+ y+y_offset ).illuminance;
+ // Sum up all of the neighbors.
+ sum += hit_ratio;
+ total += d;
}
+
}
-
- // Color the pixel
- sum = 1.0 - (sum/total);
- e.color = e.color * Color(RGB(sum,sum,sum));
- // }
- // else {
- // Background color.
- // e.color = Color(RGB(0.4,0.4,0.2));
- // }
+ }
+
+ // Color the pixel
+ sum = 1.0 - (sum/total);
+ p.color = p.color * Color(RGB(sum,sum,sum));
}
- }
-
+ }
}
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 Wed Jan 18 15:01:45
2006
@@ -69,7 +69,7 @@
virtual void setupDisplayChannel(SetupContext& context);
virtual void setupFrame(const RenderContext& context);
- virtual void shade( const RenderContext &context, TilePacket &packet );
+ virtual void shade( const RenderContext &context, RayPacket
&ray_packet, TilePacket &tile_packet );
private:
// Members.
@@ -93,7 +93,7 @@
virtual void shade( const RenderContext &context,
DiscoTile *disco_tile,
- TilePacket &packet );
+ 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 Wed Jan 18 15:01:45 2006
@@ -31,21 +31,19 @@
using namespace Manta;
using namespace disco;
-size_t compute_size( int xtilesize, int ytilesize, int overlap ) {
+size_t DiscoTile::compute_size( int xtilesize, int ytilesize, int overlap ) {
// 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.
- size_t raypacket_bytes = total_pixels * sizeof(RayPacket::Element);
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) +
- raypacket_bytes +
tilepacket_bytes +
128*3;
@@ -54,9 +52,9 @@
ThreadStorage::Token DiscoTile::requestStorage( ThreadStorage &storage,
- int xtilesize,
- int ytilesize,
- int overlap )
+ int xtilesize,
+ int ytilesize,
+ int overlap )
{
size_t total_bytes = compute_size( xtilesize, ytilesize, overlap );
@@ -83,26 +81,11 @@
/////////////////////////////////////////////////////////////////////////////
// Compute offsets into the memory for each array.
size_t allocated = sizeof(DiscoTile);
- size_t raypacket_offset = ((allocated/128)+1)*128;
-
- allocated = raypacket_offset + (disco_tile->total *
sizeof(RayPacket::Element));
size_t tilepacket_offset = ((allocated/128)+1)*128;
// Point arrays to allocated memory.
- disco_tile->raypacket_data = (RayPacket::Element *)((char *)disco_tile +
raypacket_offset);
disco_tile->tilepacket_data = (TilePacket::Element *)((char *)disco_tile +
tilepacket_offset);
- // Sanity check.
- size_t total_pixels = (xtilesize+2*overlap) * (ytilesize+2*overlap);
- size_t tilepacket_bytes = total_pixels * sizeof(TilePacket::Element);
-
- size_t requested_size = compute_size( xtilesize, ytilesize, overlap );
- size_t actual_size = (size_t) ((char *)disco_tile->tilepacket_data +
tilepacket_bytes);
-
- actual_size = actual_size - (size_t)disco_tile;
-
- ASSERT(actual_size < requested_size);
-
return disco_tile;
}
Modified: trunk/fox/disco_demo/Interface/DiscoTile.h
==============================================================================
--- trunk/fox/disco_demo/Interface/DiscoTile.h (original)
+++ trunk/fox/disco_demo/Interface/DiscoTile.h Wed Jan 18 15:01:45 2006
@@ -67,15 +67,7 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Tile coordinate Accessors
- RayPacket::Element &DiscoTile::getRayPacketElement( int x, int y ) {
-
- // Shift so that overlap requires negative coordinates.
- int offset = get_offset( x+overlap, y+overlap );
- ASSERT(offset < total);
- return raypacket_data[offset];
- }
-
- TilePacket::Element &DiscoTile::getTilePacketElement( int x, int y ) {
+ TilePacket::Element &DiscoTile::get( int x, int y ) {
// Shift so that overlap requires negative coordinates.
int offset = get_offset( x+overlap, y+overlap );
@@ -85,12 +77,6 @@
/////////////////////////////////////////////////////////////////////////..
// TilePacket Accessors, caller is responsible for determining size.
- RayPacketData &getRayPacketData( int i ) {
- size_t index = i*RayPacket::MaxSize;
- ASSERT(index < total);
- return *((RayPacketData *)&raypacket_data[i*RayPacket::MaxSize]);
- };
-
TilePacketData &getTilePacketData( int i ) {
size_t index = i*RayPacket::MaxSize;
ASSERT(index < total);
@@ -112,6 +98,8 @@
// Array indexing.
int get_offset( int x, int y ) { return y*(width) + x; }
+ static size_t compute_size( int xtilesize, int ytilesize, int overlap );
+
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Actual Dimensions (including overlap)
@@ -122,7 +110,6 @@
int total;
// Arrays
- RayPacket::Element *raypacket_data;
TilePacket::Element *tilepacket_data;
};
};
Modified: trunk/fox/disco_demo/Interface/NeighborhoodShader.h
==============================================================================
--- trunk/fox/disco_demo/Interface/NeighborhoodShader.h (original)
+++ trunk/fox/disco_demo/Interface/NeighborhoodShader.h Wed Jan 18 15:01:45
2006
@@ -57,7 +57,7 @@
// Shader method.
virtual void shade( const RenderContext &context,
DiscoTile *disco_tile,
- TilePacket &packet ) = 0;
+ TilePacket &tile_packet ) = 0;
private:
NeighborhoodShader(const NeighborhoodShader&);
NeighborhoodShader& operator=(const NeighborhoodShader&);
Modified: trunk/fox/disco_demo/Interface/PerSampleShader.h
==============================================================================
--- trunk/fox/disco_demo/Interface/PerSampleShader.h (original)
+++ trunk/fox/disco_demo/Interface/PerSampleShader.h Wed Jan 18 15:01:45
2006
@@ -53,7 +53,7 @@
virtual void setupFrame(const RenderContext& context) = 0;
// Shader method.
- virtual void shade( const RenderContext &context, TilePacket &packet ) =
0;
+ virtual void shade( const RenderContext &context, RayPacket &ray_packet,
TilePacket &tile_packet ) = 0;
protected:
// Helper method which performs the usual raypacket material shading.
Modified: trunk/fox/disco_demo/Interface/TilePacket.h
==============================================================================
--- trunk/fox/disco_demo/Interface/TilePacket.h (original)
+++ trunk/fox/disco_demo/Interface/TilePacket.h Wed Jan 18 15:01:45 2006
@@ -44,40 +44,58 @@
///////////////////////////////////////////////////////////////////////////
// TilePacket data structure for accessing neighboring samples and storing
// per sample results
- class TilePacket : public RayPacket {
+ class TilePacket {
public:
- enum { MaxScratchpadSize = HitInfo::MaxScratchpadSize };
-
+ enum { MaxScratchpadSize = (HitInfo::MaxScratchpadSize-16) };
+ enum { WAS_HIT = 0x01,
+ OVERLAP = 0x02 };
+
+
///////////////////////////////////////////////////////////////////////////
// Tile Element
class Element {
- public:
+ public:
+ // Initialized values
int tilex, tiley;
- int overlap;
+ int flags;
int task;
- private:
- char scratch_pad_data[MaxScratchpadSize];
-
- public:
- // Scratch pad accessor.
- template< typename T >
- T &scratch_pad() { return *(T*)scratch_pad_data; };
+ // Computed by per sampler shader.
+ Real illuminance;
+ Vector normal;
+
+ // Result
+ Color color;
+
+ // Accessors.
+ bool wasHit() { return flags & WAS_HIT; }
+ bool isOverlap() { return flags & OVERLAP; }
};
+
///////////////////////////////////////////////////////////////////////////
// Constructor.
- TilePacket( RayPacketData &raypacket_data, TilePacketData
&tilepacket_data,
- int size_, int depth_ = 0, int flags_ = 0 );
+ TilePacket( TilePacketData &tilepacket_data,
+ int size_ );
// Sub packet constructor.
TilePacket( const TilePacket &packet, int start, int end )
- : RayPacket( (RayPacket &)packet, start, end ), data(
&packet.data[start] ) { }
+ : size(end-start), data( &packet.data[start] ) { }
+
+ // Element Accessors.
+ void setElement( int i, int tilex_, int tiley_, bool overlap_ ) {
+ data[i].tilex = tilex_;
+ data[i].tiley = tiley_;
+ data[i].flags = (overlap_ << 1); }
+ Element &get( int i ) { return data[i]; }
+
+ // Accessors
+ int getSize() { return size; }
+
+ bool wasHit( int i ) { return data[i].wasHit(); }
+ bool isOverlap( int i ) { return data[i].isOverlap(); }
- // Element accessors.
- RayPacket::Element &getRayPacketElement ( int i ) { return
RayPacket::get( i );};
- Element &getTilePacketElement( int i ) { return data[i]; };
-
private:
- // Size member of the ray packet is used.
+ // Size member of the ray packet is used.
+ int size;
Element *data;
};
@@ -88,11 +106,8 @@
};
// Constructor.
- inline TilePacket::TilePacket( RayPacketData &raypacket_data,
TilePacketData &tilepacket_data,
- int size_, int depth_, int flags_ )
-
- : RayPacket( raypacket_data, size_, depth_, flags_ ),
- data( &tilepacket_data.data[0] ) { }
+ inline TilePacket::TilePacket( TilePacketData &tilepacket_data, int size_ )
+ : size( size_ ), data( &tilepacket_data.data[0] ) { }
};
- [MANTA] r848 - in trunk/fox/disco_demo: . Engine/ImageTraversers Engine/Renderers Engine/Shaders Interface, abe, 01/18/2006
Archive powered by MHonArc 2.6.16.