Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1144 - in trunk: . Engine/Control Interface Model/Primitives StandAlone SwigInterface scenes


Chronological Thread 
  • From: cgribble@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1144 - in trunk: . Engine/Control Interface Model/Primitives StandAlone SwigInterface scenes
  • Date: Tue, 18 Jul 2006 15:52:31 -0600 (MDT)

Author: cgribble
Date: Tue Jul 18 15:52:28 2006
New Revision: 1144

Modified:
   trunk/CMakeLists.txt
   trunk/Engine/Control/DynPLTWorker.cc
   trunk/Engine/Control/DynPLTWorker.h
   trunk/Engine/Control/RTRT.cc
   trunk/Engine/Control/RTRT.h
   trunk/Interface/Callback.h
   trunk/Interface/CallbackHelpers.h
   trunk/Interface/MantaInterface.h
   trunk/Model/Primitives/DynPLTGridSpheres.h
   trunk/StandAlone/CMakeLists.txt
   trunk/SwigInterface/wxManta.py
   trunk/scenes/dynplt.cc
   trunk/scenes/pnrrd.cc
Log:
scenes/pnrrd.cc
  Changed default light source, added some useful bookmarks

scenes/dynplt.cc
  Added code for static vs. dynamic texture generation threads
  Dynamic scheduling is now the default (all threads, 1/30th of a second)

StandAlone/CMakeLists.txt
  Added missing library to link libraries

SwigInterface/wxManta.py
  Set redirect for MantaApp class to false by default

Model/Primitives/DynPLTGridSpheres.h
  Added several accessors and made public mutable members private

Interface/MantaInterface.h
Interface/Callback.h
Interface/CallbackHelpers.h
  Added interfaces for registering pre-render callbacks
  Added create(...) for Callback_Static_2Data_0Arg callbacks
  Added code for Callback_Static_2Data_0Arg callbacks

Engine/Control/RTRT.h
Engine/Control/RTRT.cc
  Added interfaces for registering pre-render callbacks
  Added code to register pre-render callbacks
  Transactions now post *before* callbacks are invoked; needed to avoid
    situations in which one shot parallel callbacks were being deleted before
    running on all threads; now fits the model described in the Manta paper, 
and
    thus hopefully fits what Steve was thinking
  Switched order of execution of pre-render callbacks to (Serial, Parallel) to
    match order of animation callbacks and avoid situations in which serial
    pre-render callbacks modify state being used by parallel pre-render 
callbacks
    (serial first --> state is consistent)

Engine/Control/DynPLTWorker.h
Engine/Control/DynPLTWorker.cc
  Added code to support dynamic thread scheduling:  texture generation 
callback
    allows rendering threads to generate textures until the user-specified 
timer
    fires
  Some code restructuring to support static/dynamic texture generation threads
  Make use of new DynPLTGridSpheres accessors by using 
const_cast<...>(msg.grid)
    to de-const-ify the pointer (nice trick, really cleans up the interface,
    etc.)

CMakeLists.txt
  Comment out stuff depending on APPLE_MACHINE (fails to work with Cmake
    2.2-patch 3 on PPC Macs)


Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt        (original)
+++ trunk/CMakeLists.txt        Tue Jul 18 15:52:28 2006
@@ -169,19 +169,19 @@
   EXEC_PROGRAM("/usr/bin/machine" OUTPUT_VARIABLE APPLE_MACHINE)
 
   # G4 Powerbook.
-  IF (${APPLE_MACHINE} MATCHES "ppc7450")
-     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock 
-falign-loops=16 -falign-jumps=16 -falign-functions=16 
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math 
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G4 -mcpu=G4 
-faltivec -mabi=altivec -mpowerpc-gfxopt" STRING "G4 Optimized Flags")
-  ENDIF (${APPLE_MACHINE} MATCHES "ppc7450")
+#  IF (${APPLE_MACHINE} MATCHES "ppc7450")
+#     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock 
-falign-loops=16 -falign-jumps=16 -falign-functions=16 
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math 
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G4 -mcpu=G4 
-faltivec -mabi=altivec -mpowerpc-gfxopt" STRING "G4 Optimized Flags")
+#  ENDIF (${APPLE_MACHINE} MATCHES "ppc7450")
 
   # G5 Workstation.
-  IF (${APPLE_MACHINE} STREQUAL "ppc970")
-     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock 
-falign-loops=16 -falign-jumps=16 -falign-functions=16 
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math 
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G5 -mcpu=G5 
-mpowerpc64 -faltivec -mabi=altivec -mpowerpc-gfxopt" STRING "G5 Optimized 
Flags")
-  ENDIF(${APPLE_MACHINE} STREQUAL "ppc970")
+#  IF (${APPLE_MACHINE} STREQUAL "ppc970")
+#     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock 
-falign-loops=16 -falign-jumps=16 -falign-functions=16 
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math 
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G5 -mcpu=G5 
-mpowerpc64 -faltivec -mabi=altivec -mpowerpc-gfxopt" STRING "G5 Optimized 
Flags")
+#  ENDIF(${APPLE_MACHINE} STREQUAL "ppc970")
 
   # Core Duo.  
-  IF (${APPLE_MACHINE} STREQUAL "i486") # ???
-     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock -ffast-math 
-freorder-blocks -fpermissive -march=prescott -mtune=prescott -msse -msse2 
-msse3 -mfpmath=sse" STRING "Core Duo Optimized Flags")
-  ENDIF (${APPLE_MACHINE} STREQUAL "i486")
+#  IF (${APPLE_MACHINE} STREQUAL "i486") # ???
+#     FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock -ffast-math 
-freorder-blocks -fpermissive -march=prescott -mtune=prescott -msse -msse2 
-msse3 -mfpmath=sse" STRING "Core Duo Optimized Flags")
+#  ENDIF (${APPLE_MACHINE} STREQUAL "i486")
 
 ENDIF (APPLE)
 

Modified: trunk/Engine/Control/DynPLTWorker.cc
==============================================================================
--- trunk/Engine/Control/DynPLTWorker.cc        (original)
+++ trunk/Engine/Control/DynPLTWorker.cc        Tue Jul 18 15:52:28 2006
@@ -9,6 +9,7 @@
 #include <Model/Primitives/Sphere.h>
 #include <SCIRun/Core/Math/MiscMath.h>
 #include <SCIRun/Core/Thread/Semaphore.h>
+#include <SCIRun/Core/Thread/Time.h>
 
 #include <string>
 
@@ -21,13 +22,17 @@
 // XXX:  the exit strategy only works occasionally (no segfault) when the 
queue
 //       isn't empty, and never when it is empty
 
-DynPLTContext::DynPLTContext(SCIRun::Mailbox<DynPLTMessage>* queue,
+DynPLTContext::DynPLTContext(MantaInterface* manta_interface,
+                             SCIRun::Mailbox<DynPLTMessage>* queue,
                              Scene* scene, unsigned int ngroups,
                              unsigned int nsamples, unsigned int max_depth,
-                             bool dilate, Background* background, Real Kd,
-                             Real Ka) :
+                             bool dilate, Background* background, double 
runtime,
+                             unsigned int minproc, unsigned int maxproc,
+                             Real Kd, Real Ka) :
+  manta_interface(manta_interface),
   queue(queue), scene(scene), ngroups(ngroups), nsamples(nsamples),
-  max_depth(max_depth), dilate(dilate), background(background), Kd(Kd), 
Ka(Ka)
+  max_depth(max_depth), dilate(dilate), background(background), 
runtime(runtime),
+  minproc(minproc), maxproc(maxproc), Kd(Kd), Ka(Ka)
 {
   // Ensure that the number of samples is a perfect square
   
nsamples_root=static_cast<int>(SCIRun::Ceil(SCIRun::Sqrt(static_cast<Real>(nsamples))));
@@ -97,51 +102,83 @@
 
   DynPLTMessage msg=context->queue->receive();
   while (msg.particle>=0) {
-    // Grab message data
-    int particle=msg.particle;
-    const DynPLTGridSpheres* grid=msg.grid;
-
-    // Skip valid textures
-    if (grid->valid[particle])
-      continue;
-
-    // Allocate new texture, if necessary
-    if (!grid->allocated[particle]) {
-      grid->plts[particle]=new DynPLT();
-      grid->allocated[particle]=true;
-    }
+    // Generate texture
+    innerLoop(rctx, msg);
 
-    bool dilateTexture=false;
+    // Receive next message
+    msg=context->queue->receive();
+  }
 
-    // Render the texture
-    switch (grid->getTextureMode()) {
-    case DynPLTGridSpheres::AmbientOcclusion:
-      dilateTexture=renderAmbient(context, rctx, grid, particle);
-      break;
-    case DynPLTGridSpheres::GlobalIllumination:
-    default:
-      dilateTexture=renderGlobal(context, rctx, grid, particle);
+  if (exitSem)
+    exitSem->up();
+}
+
+void DynPLTWorker::timedRun(int proc, int numProcs)
+{
+  // Only specified range of threads should be generating textures
+  if (proc < context->minproc || proc > context->maxproc)
+    return;
+
+  // Create a render context for computing ray intersections
+  vector<string> args;
+  HardShadows shadows(args);
+  // RenderContext(MantaInterface*, int, int, int, const FrameState*,
+  //               LoadBalancer*, PixelSampler*, Renderer*, ShadowAlgorithm*,
+  //               const Camera*, const Scene*, ThreadStorage*);
+  RenderContext rctx(0, 0, 0, 0, 0, 0, 0, 0, &shadows, 0, context->scene, 0);
+
+  double start=SCIRun::Time::currentSeconds();
+  DynPLTMessage msg;
+  while (SCIRun::Time::currentSeconds() - start < context->runtime) {
+    if (context->queue->tryReceive(msg)) {
+      // Generate texture
+      innerLoop(rctx, msg);
+    } else {
+      // No texture requests available, continue with rendering immediately
       break;
     }
+  }
+}
 
-    if (context->dilate && dilateTexture)
-      grid->plts[particle]->dilate(context);
-  
-    // XXX:  maybe use a transaction to mark the texture as valid and prevent
-    //       tearing in the middle of a frame
-    grid->valid[particle]=true;
+void DynPLTWorker::innerLoop(const RenderContext& rctx, const DynPLTMessage& 
msg)
+{
+  // Grab message data
+  int particle=msg.particle;
+  DynPLTGridSpheres* grid=const_cast<DynPLTGridSpheres*>(msg.grid);
+
+  // Skip valid textures
+  if (grid->isValid(particle))
+    return;
+
+  // Allocate new texture, if necessary
+  if (!grid->isAllocated(particle))
+    grid->allocate(particle);
 
-    // Receive next message
-    msg=context->queue->receive();
+  bool dilateTexture=false;
+
+  // Render the texture
+  switch (grid->getTextureMode()) {
+  case DynPLTGridSpheres::AmbientOcclusion:
+    dilateTexture=renderAmbient(context, rctx, grid, particle);
+    break;
+  case DynPLTGridSpheres::GlobalIllumination:
+  default:
+    dilateTexture=renderGlobal(context, rctx, grid, particle);
+    break;
   }
 
-  if (exitSem)
-    exitSem->up();
+  // Dilate texture, if necessary
+  if (context->dilate && dilateTexture)
+    grid->dilate(context, particle);
+  
+  // Mark the texture as valid
+  context->manta_interface->addTransaction("Texture valid",
+                                           Callback::create(grid, 
&DynPLTGridSpheres::setValid, particle));
 }
 
 bool DynPLTWorker::renderAmbient(const DynPLTContext* context,
                                  const RenderContext& rctx,
-                                 const DynPLTGridSpheres* grid,
+                                 DynPLTGridSpheres* grid,
                                  unsigned int particle)
 {
   // Grab useful information from the DynPLT context
@@ -151,7 +188,7 @@
   Real inv_nsamples=1/static_cast<Real>(nsamples);
 
   // Determine texture resolution
-  DynPLT* dynplt=grid->plts[particle];
+  DynPLT* dynplt=grid->getTexture(particle);
   unsigned int xres=dynplt->getXRes();
   unsigned int yres=dynplt->getYRes();
   // Real inv_width=1/static_cast<Real>(xres - 1);
@@ -303,7 +340,7 @@
 
 bool DynPLTWorker::renderGlobal(const DynPLTContext* context,
                                 const RenderContext& rctx,
-                                const DynPLTGridSpheres* grid,
+                                DynPLTGridSpheres* grid,
                                 unsigned int particle)
 {
   // Grab useful information from the DynPLT context
@@ -313,7 +350,7 @@
   Real inv_nsamples=1/static_cast<Real>(nsamples);
 
   // Determine texture resolution
-  DynPLT* dynplt=grid->plts[particle];
+  DynPLT* dynplt=grid->getTexture(particle);
   unsigned int xres=dynplt->getXRes();
   unsigned int yres=dynplt->getYRes();
   // Real inv_width=1/static_cast<Real>(xres - 1);

Modified: trunk/Engine/Control/DynPLTWorker.h
==============================================================================
--- trunk/Engine/Control/DynPLTWorker.h (original)
+++ trunk/Engine/Control/DynPLTWorker.h Tue Jul 18 15:52:28 2006
@@ -4,12 +4,15 @@
 
 #include <Core/Math/MT_RNG.h>
 #include <Core/Math/vector2d.h>
+#include <Interface/MantaInterface.h>
 #include <Model/Primitives/DynPLTGridSpheres.h>
 #include <SCIRun/Core/Containers/Array1.h>
 #include <SCIRun/Core/Containers/Array2.h>
 #include <SCIRun/Core/Thread/Mailbox.h>
 #include <SCIRun/Core/Thread/Runnable.h>
 
+#include <float.h>
+
 namespace Manta
 {
   class Background;
@@ -22,12 +25,18 @@
   class DynPLTContext
   {
   public:
-    DynPLTContext(SCIRun::Mailbox<DynPLTMessage>* queue, Scene* scene,
+    DynPLTContext(MantaInterface* manta_interface,
+                  SCIRun::Mailbox<DynPLTMessage>* queue, Scene* scene,
                   unsigned int ngroups, unsigned int nsamples,
                   unsigned int max_depth, bool dilate,
-                  Background* background, Real Kd=0.6, Real Ka=0.4);
+                  Background* background, double runtime=DBL_MAX,
+                  unsigned int minproc=0, unsigned int maxproc=INT_MAX,
+                  Real Kd=0.6, Real Ka=0.4);
     ~DynPLTContext(void) { }
 
+    // Manta interface
+    MantaInterface* manta_interface;
+
     // DynPLT work queue
     SCIRun::Mailbox<DynPLTMessage>* queue;
 
@@ -40,6 +49,9 @@
     unsigned int nsamples;
     unsigned int nsamples_root;
     unsigned int max_depth;
+    double runtime;
+    unsigned int minproc;
+    unsigned int maxproc;
     Real Ka;
     Real Kd;
 
@@ -55,16 +67,22 @@
   public:
     DynPLTWorker(const DynPLTContext* context, unsigned int id);
     virtual ~DynPLTWorker(void);
-    
+
+    // Thread run function for static thread scheduling
     virtual void run(void);
 
+    // Termination call back for static thread scheduling
     void terminate(MantaInterface*);
 
+    // Parallel pre-render callback for dynamic thread scheduling
+    void timedRun(int proc, int numProcs);
+
   private:
     bool renderAmbient(const DynPLTContext* context, const RenderContext& 
rctx,
-                       const DynPLTGridSpheres* grid, unsigned int particle);
+                       DynPLTGridSpheres* grid, unsigned int particle);
     bool renderGlobal(const DynPLTContext* context, const RenderContext& 
rctx,
-                      const DynPLTGridSpheres* grid, unsigned int particle);
+                      DynPLTGridSpheres* grid, unsigned int particle);
+    void innerLoop(const RenderContext& rctx, const DynPLTMessage& msg);
 
     const DynPLTContext* context;
     unsigned int id;

Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc        (original)
+++ trunk/Engine/Control/RTRT.cc        Tue Jul 18 15:52:28 2006
@@ -181,6 +181,20 @@
   callbackLock.writeUnlock();
 }
 
+void RTRT::registerSerialPreRenderCallback(CallbackBase_2Data<int, int>* cb)
+{
+  callbackLock.writeLock();
+  serialPreRenderCallbacks.push_back(cb);
+  callbackLock.writeUnlock();
+}
+
+void RTRT::registerParallelPreRenderCallback(CallbackBase_2Data<int, int>* 
cb)
+{
+  callbackLock.writeLock();
+  parallelPreRenderCallbacks.push_back(cb);
+  callbackLock.writeUnlock();
+}
+
 void RTRT::registerTerminationCallback( CallbackBase_1Data< MantaInterface 
*> *cb ) {
   callbackLock.writeLock();
   terminationCallbacks.push_back(cb);
@@ -313,12 +327,12 @@
     changed=false;
     //callbackLock.readLock();
 
-    doSerialAnimationCallbacks(changed, proc, workersAnimAndImage);
-    doParallelAnimationCallbacks(changed, proc, workersAnimAndImage);
-
     if(proc == 0)
       postTransactions(changed);
 
+    doSerialAnimationCallbacks(changed, proc, workersAnimAndImage);
+    doParallelAnimationCallbacks(changed, proc, workersAnimAndImage);
+
     if(!firstFrame){
       for(int index = 0;index < static_cast<int>(channels.size());index++){
         Channel* channel = channels[index];
@@ -461,8 +475,8 @@
   skipToRendering:
     // Pre-render callbacks
     //callbackLock.readLock();
-    doParallelPreRenderCallbacks(proc, workersRendering);
     doSerialPreRenderCallbacks(proc, workersRendering);
+    doParallelPreRenderCallbacks(proc, workersRendering);
     //callbackLock.readUnlock();
 
     if(workersChanged){
@@ -533,7 +547,9 @@
   }
 }
 
-void RTRT::deleteParallelOneShot( RTRT::ParallelOneShotMapType::iterator 
iter ) {
+void RTRT::deleteParallelOneShot( RTRT::ParallelOneShotMapType::iterator 
iter )
+{
+  cerr<<"deleting parallelOneShot\n";
 
   // Delete the callback
   delete iter->second;

Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Tue Jul 18 15:52:28 2006
@@ -120,6 +120,8 @@
     virtual void registerSetupCallback(SetupCallback*);
     virtual void registerSerialAnimationCallback(CallbackBase_3Data<int, 
int, bool&>*);
     virtual void registerParallelAnimationCallback(CallbackBase_3Data<int, 
int, bool&>*);
+    virtual void registerSerialPreRenderCallback(CallbackBase_2Data<int, 
int>*);
+    virtual void registerParallelPreRenderCallback(CallbackBase_2Data<int, 
int>*);
     virtual void registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *);
 
     // Control of time/animation

Modified: trunk/Interface/Callback.h
==============================================================================
--- trunk/Interface/Callback.h  (original)
+++ trunk/Interface/Callback.h  Tue Jul 18 15:52:28 2006
@@ -52,6 +52,12 @@
       return new Callback_Static_2Data_2Arg<Data1, Data2, Arg1, Arg2>(pmf, 
arg1, arg2);
     }
 
+    template<typename Data1, typename Data2> static
+    CallbackBase_2Data<Data1, Data2>*
+    create(void (*pmf)(Data1, Data2)) {
+      return new Callback_Static_2Data_0Arg<Data1, Data2>(pmf);
+    }
+
     template<typename Data1, typename Data2, typename Data3,
              typename Arg1, typename Arg2> static
     CallbackBase_3Data<Data1, Data2, Data3>*
@@ -111,7 +117,7 @@
       return new Callback_0Data_3Arg<T, Arg1, Arg2, Arg3>(ptr, pmf, arg1, 
arg2, arg3);
     }
 
-               template<class T, typename Arg1, typename Arg2, typename 
Arg3, typename Arg4> static
+    template<class T, typename Arg1, typename Arg2, typename Arg3, typename 
Arg4> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4), Arg1 arg1, Arg2 
arg2, Arg3 arg3, Arg4 arg4) {
       return new Callback_0Data_4Arg<T, Arg1, Arg2, Arg3, Arg4>(ptr, pmf, 
arg1, arg2, arg3, arg4);

Modified: trunk/Interface/CallbackHelpers.h
==============================================================================
--- trunk/Interface/CallbackHelpers.h   (original)
+++ trunk/Interface/CallbackHelpers.h   Tue Jul 18 15:52:28 2006
@@ -188,6 +188,24 @@
   };
   
   // 2 Data
+  template<typename Data1, typename Data2>
+  class Callback_Static_2Data_0Arg : public CallbackBase_2Data<Data1, Data2> 
{
+  public:
+    Callback_Static_2Data_0Arg(void (*pmf)(Data1, Data2))
+      : pmf(pmf)
+    {
+    }
+    virtual ~Callback_Static_2Data_0Arg()
+    {
+    }
+    virtual void call(Data1 data1, Data2 data2)
+    {
+      pmf(data1, data2);
+    }
+  private:
+    void (*pmf)(Data1, Data2);
+  };
+
   template<typename Data1, typename Data2,
            typename Arg1, typename Arg2>
   class Callback_Static_2Data_2Arg : public CallbackBase_2Data<Data1, Data2> 
{

Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h    (original)
+++ trunk/Interface/MantaInterface.h    Tue Jul 18 15:52:28 2006
@@ -133,6 +133,8 @@
     virtual void registerSetupCallback(SetupCallback*) = 0;
     virtual void registerSerialAnimationCallback(CallbackBase_3Data<int, 
int, bool&>*) = 0;
     virtual void registerParallelAnimationCallback(CallbackBase_3Data<int, 
int, bool&>*) = 0;
+    virtual void registerSerialPreRenderCallback(CallbackBase_2Data<int, 
int>*) = 0;
+    virtual void registerParallelPreRenderCallback(CallbackBase_2Data<int, 
int>*) = 0;
     virtual void registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *) = 0;
     
     // Settings

Modified: trunk/Model/Primitives/DynPLTGridSpheres.h
==============================================================================
--- trunk/Model/Primitives/DynPLTGridSpheres.h  (original)
+++ trunk/Model/Primitives/DynPLTGridSpheres.h  Tue Jul 18 15:52:28 2006
@@ -92,9 +92,30 @@
       return radius;
     }
 
-    mutable vector<DynPLT*> plts;
-    mutable vector<bool> allocated;
-    mutable vector<bool> valid;
+    bool isValid(int idx) {
+      return valid[idx];
+    }
+
+    bool isAllocated(int idx) {
+      return allocated[idx];
+    }
+
+    void setValid(int idx) {
+      valid[idx]=true;
+    }
+
+    void allocate(int idx) {
+      plts[idx]=new DynPLT();
+      allocated[idx]=true;
+    }
+
+    void dilate(const DynPLTContext* context, int idx) {
+      plts[idx]->dilate(context);
+    }
+
+    DynPLT* getTexture(int idx) {
+      return plts[idx];
+    }
 
   private:
     void shadeAmbient(const RenderContext& context, RayPacket& rays) const;
@@ -112,6 +133,9 @@
 
     SCIRun::Mailbox<DynPLTMessage>* queue;
     mutable vector<bool> requested;
+    vector<bool> allocated;
+    vector<bool> valid;
+    vector<DynPLT*> plts;
 
     unsigned int textureMode;
   };

Modified: trunk/StandAlone/CMakeLists.txt
==============================================================================
--- trunk/StandAlone/CMakeLists.txt     (original)
+++ trunk/StandAlone/CMakeLists.txt     Tue Jul 18 15:52:28 2006
@@ -13,7 +13,7 @@
                                   ${CMAKE_THREAD_LIBS_INIT})
 
 ADD_EXECUTABLE(octvol_build octvol_build.cc)
-TARGET_LINK_LIBRARIES(octvol_build SCIRun_Core Manta_Model
+TARGET_LINK_LIBRARIES(octvol_build SCIRun_Core Manta_Model Manta_Engine
                                    ${CMAKE_THREAD_LIBS_INIT} -lm)
 
 #ADD_EXECUTABLE(frust-test frust-test.cc)

Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py      (original)
+++ trunk/SwigInterface/wxManta.py      Tue Jul 18 15:52:28 2006
@@ -529,6 +529,8 @@
 
 
 class MantaApp(wx.App) :
+    def __init__(self, redirect=False, filename=None):
+        wx.App.__init__(self, redirect, filename)
 
     
###########################################################################
     ## OnInit
@@ -541,5 +543,3 @@
 
 app = MantaApp()
 app.MainLoop()
-
-

Modified: trunk/scenes/dynplt.cc
==============================================================================
--- trunk/scenes/dynplt.cc      (original)
+++ trunk/scenes/dynplt.cc      Tue Jul 18 15:52:28 2006
@@ -23,6 +23,8 @@
 #include <iostream>
 #include <sgi_stl_warnings_on.h>
 
+#include <float.h>
+
 #define WORKER_THREAD_STACKSIZE 8*1024*1024
 
 using namespace Manta;
@@ -44,11 +46,13 @@
   int ngroups=100;
   int nsamples=32;
   int nthreads=1;
-  int qsize=10;  // XXX:  what's a good default value?  should be based (very
-                 //       roughly) on the number of textures/sec a typical 
thread
-                 //       can process
+  int qsize=16;
   double radius=1.;
   int ridx=-1;
+  bool static_threads=false;
+  double runtime=1./30.;
+  int minproc=0;
+  int maxproc=INT_MAX;
 
   int argc=static_cast<int>(args.size());
   for(int i=0; i<argc; ++i) {
@@ -101,6 +105,7 @@
       if (!getIntArg(i, args, nsamples))
         throw IllegalArgument("scene dynplt -nsamples", i, args);
     } else if (arg=="-nthreads") {
+      static_threads=true;
       if (!getIntArg(i, args, nthreads))
         throw IllegalArgument("scene dynplt -nthreads", i, args);
     } else if (arg=="-radius") {
@@ -112,22 +117,35 @@
     } else if (arg=="-qsize") {
       if (!getIntArg(i, args, qsize))
         throw IllegalArgument("scene dynplt -qsize", i, args);
+    } else if (arg=="-timed") {
+      string s;
+      if (getStringArg(i, args, s)) {
+        if (s[0] != '-') {
+          runtime=atof(s.c_str());
+          if (getStringArg(i, args, s)) {
+            minproc=atoi(s.c_str());
+            if (!getIntArg(i, args, maxproc))
+              throw IllegalArgument("scene dynplt -nthreads", i, args);
+          }
+        }
+      }
     } else {
       cerr<<"Valid options for scene dynplt:\n";
-      // cerr<<"  -bv <string>           bounding volume {bvh|grid|group}\n";
-      cerr<<"  -cidx <int>             data value index for color mapping\n";
-      cerr<<"  -depth <int>            grid depth\n";
-      cerr<<"  -dilate                 dilate textures during generation\n";
-      cerr<<"  -envmap [bg] <string>   environment map filename\n";
-      cerr<<"  -i <string>             particle data filename\n";
-      cerr<<"  -nbounces <int>         number of indirect nbounces\n";
-      cerr<<"  -ncells <int>           grid resolution\n";
-      cerr<<"  -ngroups <int>          number of sample groups\n";
-      cerr<<"  -nsamples <int>         number of samples/texel\n";
-      cerr<<"  -nthreads <int>         number of dynplt workers\n";
-      cerr<<"  -qsize <int>            maximum queue qsize\n";
-      cerr<<"  -radius <float>         particle radius\n";
-      cerr<<"  -ridx <int>             radius index\n";
+      // cerr<<"  -bv <string>                     bounding volume 
{bvh|grid|group}\n";
+      cerr<<"  -cidx <int>                       data value index for color 
mapping\n";
+      cerr<<"  -depth <int>                      grid depth\n";
+      cerr<<"  -dilate                           dilate textures during 
generation\n";
+      cerr<<"  -envmap [bg] <string>             environment map filename\n";
+      cerr<<"  -i <string>                       particle data filename\n";
+      cerr<<"  -nbounces <int>                   number of indirect 
nbounces\n";
+      cerr<<"  -ncells <int>                     grid resolution\n";
+      cerr<<"  -ngroups <int>                    number of sample groups\n";
+      cerr<<"  -nsamples <int>                   number of samples/texel\n";
+      cerr<<"  -nthreads <int>                   number of static dynplt 
workers\n";
+      cerr<<"  -qsize <int>                      maximum queue qsize\n";
+      cerr<<"  -radius <float>                   particle radius\n";
+      cerr<<"  -ridx <int>                       radius index\n";
+      cerr<<"  -timed [<double> [<int> <int>]]   texgen thread range and 
runtime (in seconds)\n";
       throw IllegalArgument("scene dynplt", i, args);
     }
   }
@@ -142,28 +160,40 @@
   Mailbox<DynPLTMessage>* queue=new Mailbox<DynPLTMessage>("DynPLT Work 
Queue",
                                                            nthreads*qsize);
   
-  // Create DynPLTContext
   Background* bg=0;
   if (env_fname != "")
     bg=new EnvMapBackground(env_fname);
   else
     bg=new ConstantBackground(Color(RGB(0, 0, 0)));
-  DynPLTContext* dpltctx=new DynPLTContext(queue, scene, ngroups, nsamples,
-                                           max_depth, dilate, bg /*, kd, 
ka*/);
 
-  // Create DynPLTWorker threads
-  for (unsigned int i=0; i<nthreads; ++i) {
-    ostringstream name;
-    name<<"DynPLT Worker "<<i;
-    DynPLTWorker* worker=new DynPLTWorker(dpltctx, i);
-    Thread* thread=new Thread(worker, name.str().c_str(), 0,
-                              Thread::NotActivated);
-    thread->setStackSize(WORKER_THREAD_STACKSIZE);
-    thread->activate(false);
-    
-    // Register termination callback
-    
context.manta_interface->registerTerminationCallback(Callback::create(worker,
- &DynPLTWorker::terminate));
+  if (static_threads) {
+    // Static thread scheduling --> create DynPLTWorker threads
+    DynPLTContext* dpltctx=new DynPLTContext(context.manta_interface,
+                                             queue, scene, ngroups, nsamples,
+                                             max_depth, dilate, bg /*, 
runtime,
+                                             minproc, maxproc, kd, ka */);
+
+    for (unsigned int i=0; i<nthreads; ++i) {
+      ostringstream name;
+      name<<"DynPLT Worker "<<i;
+      DynPLTWorker* worker=new DynPLTWorker(dpltctx, i);
+      Thread* thread=new Thread(worker, name.str().c_str(), 0,
+                                Thread::NotActivated);
+      thread->setStackSize(WORKER_THREAD_STACKSIZE);
+      thread->activate(false);
+      
+      // Register termination callback
+      
context.manta_interface->registerTerminationCallback(Callback::create(worker, 
&DynPLTWorker::terminate));
+    }
+  } else {
+    // Dynamic thread scheduling --> register timed texgen function
+    DynPLTContext* dpltctx=new DynPLTContext(context.manta_interface,
+                                             queue, scene, ngroups, nsamples,
+                                             max_depth, dilate, bg, runtime,
+                                             minproc, maxproc /*, kd, ka */);
+
+    DynPLTWorker* worker=new DynPLTWorker(dpltctx, 0);
+    
context.manta_interface->registerParallelPreRenderCallback(Callback::create(worker,
 &DynPLTWorker::timedRun));
   }
 
   // Create color map

Modified: trunk/scenes/pnrrd.cc
==============================================================================
--- trunk/scenes/pnrrd.cc       (original)
+++ trunk/scenes/pnrrd.cc       Tue Jul 18 15:52:28 2006
@@ -101,9 +101,20 @@
   scene->setObject(tsteps);
 
   LightSet* lights=new LightSet();
-  lights->add(new PointLight(Vector(1, 1, 1), Color(RGB(1, 1, 1))));
+  lights->add(new PointLight(Vector(1, 0, -1), Color(RGB(1, 1, 1))));
+  //  lights->add(new PointLight(Vector(0, 0, 0), Color(RGB(1, 1, 1))));
   lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
   scene->setLights(lights);
+
+  scene->addBookmark("foam 0", Vector(0.835869, -0.122922, 0.286287),
+                     Vector(0.277762, 0.280163, 0.165134),
+                     Vector(-0.156483, 0.0792408, 0.984497), 58.4373);
+  scene->addBookmark("foam 1", Vector(-0.340352, -0.145661, 0.236622),
+                     Vector(0.225205, 0.260603, 0.175516),
+                     Vector(0.0811998, 0.0367719, 0.996019), 6.8504);
+  scene->addBookmark("bullet",  Vector(-0.0119308, -0.0248974, -0.0167165),
+                     Vector(0.00851935, -0.0205668, 0.00802854),
+                     Vector(-0.562437, 0.757121, 0.332312), 32.6482);
 
   /*
   scene->addBookmark("envmap debug", Vector(0.155849, 0.427053, 0.207308),




  • [MANTA] r1144 - in trunk: . Engine/Control Interface Model/Primitives StandAlone SwigInterface scenes, cgribble, 07/18/2006

Archive powered by MHonArc 2.6.16.

Top of page