Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r466 - trunk/Engine/ImageTraversers


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r466 - trunk/Engine/ImageTraversers
  • Date: Thu, 4 Aug 2005 21:03:37 -0600 (MDT)

Author: bigler
Date: Thu Aug  4 21:03:36 2005
New Revision: 466

Modified:
   trunk/Engine/ImageTraversers/DissolveImageTraverser.cc
Log:

DissolveImageTraverser.cc

  Make sure we hit the (0,0) pixel.  Try to make better guess as to
  the number of pixels to do per pass.  There's also some commented
  out code that colorizes the pixels based on the processor number (up
  to 4), so you can see how the work is distributed.


Modified: trunk/Engine/ImageTraversers/DissolveImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DissolveImageTraverser.cc      (original)
+++ trunk/Engine/ImageTraversers/DissolveImageTraverser.cc      Thu Aug  4 
21:03:36 2005
@@ -4,6 +4,7 @@
 #include <Core/Exceptions/InternalError.h>
 #include <Core/Util/Args.h>
 #include <Interface/Context.h>
+#include <Interface/FrameState.h>
 #include <Interface/Fragment.h>
 #include <Interface/Image.h>
 #include <Interface/LoadBalancer.h>
@@ -14,6 +15,9 @@
 using namespace Manta;
 using SCIRun::InternalError;
 
+// Defines how many iterations are required to finish a frame.
+#define ITERS_PER_FRAME 16
+
 // Use this mask to produce values from 1 to N (in the comments)
 unsigned int MaskValues[] = {
   /* 00 */       0x00,  //             0
@@ -58,7 +62,6 @@
 
 DissolveImageTraverser::DissolveImageTraverser(const vector<string>& args)
 {
-  pixels_per_pass = 4096;
   int argc = static_cast<int>(args.size());
   for(int i = 0; i<argc;i++){
     string arg = args[i];
@@ -96,6 +99,9 @@
   int xres, yres;
   context.getResolution(stereo, xres, yres);
 
+  // Try an educated guess for the pixels per sample
+  pixels_per_pass = (xres*yres)/context.numProcs/ITERS_PER_FRAME;
+
   // Compute the mask
   unsigned int num_x_bits = numBinaryDigits(xres-1);
   unsigned int num_y_bits = numBinaryDigits(yres-1);
@@ -143,12 +149,15 @@
 
   unsigned int next_pixel = 
per_thread_data[context.proc].next_pixel[context.channelIndex];
   ChannelContext& cdata = channel_data[context.channelIndex];
-  
+
   Fragment frag;
   frag.setFlags(Fragment::ConstantEye);
   unsigned int pixel = 0;
-  // Catch the first fragment
-  if (next_pixel == 1) {
+  // We need to render the (0,0) pixel every once in a while, so see
+  // if we are the last processor and if we've gone through so many
+  // frames.
+  if (context.proc == context.numProcs-1 &&
+      context.frameState->frameNumber%ITERS_PER_FRAME == 0) {
     frag.addElement(0,0,0);
     pixel++;
   }
@@ -163,16 +172,27 @@
       }
       if (frag.getSize() == Fragment::MaxFragmentSize) {
         context.pixelSampler->renderFragment(context, frag);
+#if 0
+        for(int f = 0; f < frag.getSize(); f++)
+          switch (context.proc) {
+          case 0: frag.setColor(f, Color(RGBColor(1,0,0))); break;
+          case 1: frag.setColor(f, Color(RGBColor(0,0,1))); break;
+          case 2: frag.setColor(f, Color(RGBColor(0,1,0))); break;
+          case 3: frag.setColor(f, Color(RGBColor(1,1,0))); break;
+          }
+#endif
         image->set(frag);
         // Reset the Fragment
         frag.resetSize();
       }
     }
-    // Generate the next pixel
+    // Generate the next pixel.  But we need to find the Nth good
+    // pixel, so only count pixels if we find them.
     for(int i = 0; i < context.numProcs;) {
       computeNextSample(next_pixel, cdata.mask);
       int x = next_pixel >> cdata.num_y_bits;
       int y = next_pixel &  cdata.y_bit_mask;
+      // Found a good pixel, so find the next one.
       if (x < xres && y < yres) i++;
     }
   }




  • [MANTA] r466 - trunk/Engine/ImageTraversers, bigler, 08/04/2005

Archive powered by MHonArc 2.6.16.

Top of page