Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1420 - in trunk: Engine/ImageTraversers Engine/PixelSamplers Image


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1420 - in trunk: Engine/ImageTraversers Engine/PixelSamplers Image
  • Date: Fri, 22 Jun 2007 05:21:51 -0600 (MDT)

Author: boulos
Date: Fri Jun 22 05:21:45 2007
New Revision: 1420

Modified:
   trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
   trunk/Engine/PixelSamplers/SingleSampler.cc
   trunk/Image/SimpleImage_special.cc
Log:
Bug fixes for deadline image traverser.


Modified: trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      (original)
+++ trunk/Engine/ImageTraversers/DeadlineImageTraverser.cc      Fri Jun 22 
05:21:45 2007
@@ -156,12 +156,20 @@
   int ntotal = 0;
   int x = xcoarsepixelsize;
   int y = ycoarsepixelsize;
-  while(x > 1 && y > 1){
+  // NOTE(boulos): This used to be > 1, but needs to be >= to account
+  // for (current) lowest level of a single tile of 1 pixel.  In the
+  // future this should get updated with something that accounts for
+  // super sampling too.
+  while(x >= 1 || y >= 1){
     ntotal += cur;
     cur *= xrefinementRatio * yrefinementRatio;
     x /= xrefinementRatio;
     y /= yrefinementRatio;
   }
+  // NOTE(boulos): But the "popTiles" code doesn't check for whether
+  // or not it'll actually be generating new children, so it needs on more
+  // level of available refinement space.  We account for that here.
+  ntotal += cur;
   if(total_tiles){
     delete[] tiles;
     delete[] queue;
@@ -195,6 +203,10 @@
     Tile* tile = &tiles[i];
 
     // Heap insert
+    if (qsize >= total_tiles) {
+      cerr << "Uh oh, ran out of queue space\n";
+      return;
+    }
     queue[qsize] = tile;
     int p = qsize++;
     while(p){
@@ -225,11 +237,18 @@
   // Create space for the children of this tile
   childtiles = &tiles[next_tile];
   next_tile += numtiles;
+  if (next_tile >= total_tiles) {
+    cerr << "Uh oh, ran out of tile space for kids\n";
+    return 0;
+  }
 
   // Get the next tile and update the queue
   Tile* tile = queue[0];
   tile->priority = -1;
 
+  // NOTE(boulos): This part looks for a new root node. So the part
+  // where you replace queue[p] with queue[c] is actually okay (since
+  // we're removing the root node).
   int p = 0;
   while((p<<1)+2 < qsize){
     int c1 = (p<<1)+1;
@@ -242,25 +261,22 @@
     queue[p] = queue[c];
     p = c;
   }
-  if((p<<1)+2 == qsize){
-    int c = (p<<1)+1;
-    queue[p] = queue[c];
-    p = c;
-  } else {
-    queue[p] = queue[qsize-1];
-    while(p){
-      int parent = (p-1)>>1;
-      if(queue[p]->priority > queue[parent]->priority){
-        // Swap
-        Tile* tmp = queue[p];
-        queue[p] = queue[parent];
-        queue[parent] = tmp;
-      } else {
-        break;
-      }
-      p = parent;
+
+  // NOTE(boulos): qsize >= 1, so this is legal and correct.
+  queue[p] = queue[qsize-1];
+  while(p){
+    int parent = (p-1)>>1;
+    if(queue[p]->priority > queue[parent]->priority){
+      // Swap
+      Tile* tmp = queue[p];
+      queue[p] = queue[parent];
+      queue[parent] = tmp;
+    } else {
+      break;
     }
+    p = parent;
   }
+
   qsize--;
   qlock.unlock();
   return tile;

Modified: trunk/Engine/PixelSamplers/SingleSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/SingleSampler.cc (original)
+++ trunk/Engine/PixelSamplers/SingleSampler.cc Fri Jun 22 05:21:45 2007
@@ -107,7 +107,18 @@
         px += ci.xscale;
       }
     }
+    else if (fragment.xPixelSize != 1 || fragment.yPixelSize != 1){
+      // Need to do centered setting of the pixels
+      Real x_splat_offset = .5 * fragment.xPixelSize;
+      Real y_splat_offset = .5 * fragment.yPixelSize;
 
+      for(int i=0;i<size;i++){
+        Real px = (fragment.getX(f+i)+x_splat_offset)*ci.xscale+ci.xoffset;
+        Real py = (fragment.getY(f+i)+y_splat_offset)*ci.yscale+ci.yoffset;
+
+        rays.setPixel(i, fragment.getWhichEye(f+i), px, py);
+      }
+    }
     // Otherwise, set each pixel individually.
     else {
 #if MANTA_SSE

Modified: trunk/Image/SimpleImage_special.cc
==============================================================================
--- trunk/Image/SimpleImage_special.cc  (original)
+++ trunk/Image/SimpleImage_special.cc  Fri Jun 22 05:21:45 2007
@@ -10,14 +10,24 @@
 void SimpleImage<ARGB8Pixel>::set(const Fragment& fragment)
 {
   if(fragment.xPixelSize != 1 || fragment.yPixelSize != 1){
+    // NOTE(boulos): This branch tries to copy fragments where a
+    // single sample splats onto several pixels
     for(int i=fragment.begin();i<fragment.end();i++){
       ARGB8Pixel pix;
       convertToPixel(pix, fragment.getColor(i).convertRGB());
 
+      // start splatting
+      int y_index = fragment.getY(i);
+      int last_x = std::min(xres - fragment.getX(i), fragment.xPixelSize);
       for(int y=0;y<fragment.yPixelSize;y++){
-        ARGB8Pixel* row = 
eyeStart[fragment.getWhichEye(i)][fragment.getY(i)+y] + fragment.getX(i);
-        for(int x=0;x<fragment.xPixelSize;x++)
-          row[x] = pix;
+
+        if (y_index >= yres) break;
+
+        ARGB8Pixel* row = eyeStart[fragment.getWhichEye(i)][y_index];
+        for(int x=0;x<last_x;x++)
+          row[fragment.getX(i) + x] = pix;
+
+        y_index++;
       }
     }
   } else if(fragment.getFlag(Fragment::ConsecutiveX|Fragment::ConstantEye)){




  • [MANTA] r1420 - in trunk: Engine/ImageTraversers Engine/PixelSamplers Image, boulos, 06/22/2007

Archive powered by MHonArc 2.6.16.

Top of page