Revision: 45498
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45498&view=rev
Author:   kunigami
Date:     2011-07-15 01:23:43 +0000 (Fri, 15 Jul 2011)

Log Message:
-----------
changing OSLRender methods to static. I think this will be necessary to 
increase parallelism

Modified Paths:
--------------
    brlcad/trunk/src/liboptical/liboslrend.cpp
    brlcad/trunk/src/liboptical/liboslrend.h
    brlcad/trunk/src/liboptical/sh_osl.cpp

Modified: brlcad/trunk/src/liboptical/liboslrend.cpp
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.cpp  2011-07-15 00:59:17 UTC (rev 
45497)
+++ brlcad/trunk/src/liboptical/liboslrend.cpp  2011-07-15 01:23:43 UTC (rev 
45498)
@@ -33,12 +33,10 @@
     ssi = (ShadingSystemImpl *)shadingsys;
     
     handle = ssi->create_thread_info();
-    ctx = ssi->get_context(handle);
 }
 
 OSLRenderer::~OSLRenderer(){
 
-    ssi->release_context(ctx, handle);
     ssi->destroy_thread_info(handle);
     ShadingSystem::destroy(shadingsys);
 }
@@ -111,13 +109,17 @@
 
     fastf_t y = info->screen_y;
 
+    unsigned short Xi[3];                /* seed for RNG */
     Xi[0] = rand();
     Xi[1] = rand();
     Xi[2] = rand();
 
+    /* Thread specifics */
+    info->thread_info = handle;
+
     // execute shader
     ShaderGlobals globals;
-    const ClosureColor *closure = ExecuteShaders(globals, info);
+    const ClosureColor *closure = ExecuteShaders(globals, info, ssi);
 
     Color3 weight = Color3(0.0f);
     // sample primitive from closure tree
@@ -163,7 +165,7 @@
  * ----------------------------------------------- */
 
 const ClosureColor * OSLRenderer::
-ExecuteShaders(ShaderGlobals &globals, RenderInfo *info){
+ExecuteShaders(ShaderGlobals &globals, RenderInfo *info, ShadingSystemImpl 
*ssi){
 
     memset(&globals, 0, sizeof(globals));
 
@@ -189,9 +191,11 @@
     globals.Ci = NULL;
 
     // execute shader
+    ShadingContext* ctx = ssi->get_context(info->thread_info);
     ctx->execute(ShadUseSurface, *(info->shader_ref),
                 globals);
-
+    ssi->release_context(ctx, info->thread_info);
+    
     return globals.Ci;
 }
 

Modified: brlcad/trunk/src/liboptical/liboslrend.h
===================================================================
--- brlcad/trunk/src/liboptical/liboslrend.h    2011-07-15 00:59:17 UTC (rev 
45497)
+++ brlcad/trunk/src/liboptical/liboslrend.h    2011-07-15 01:23:43 UTC (rev 
45498)
@@ -53,6 +53,7 @@
 struct RenderInfo {
 
     /* -- input -- */
+    void *thread_info;
     fastf_t screen_x;       /* Coordinates of the screen (if applicable) */
     fastf_t screen_y;
     point_t P;              /* Query point */
@@ -96,18 +97,13 @@
    These information are hidden from the calling C code */
 class OSLRenderer {
 
-    const char *shadername;              /* name of the shader */
     ErrorHandler errhandler;
-    ShaderGlobals globals;
-
+    
     ShadingSystem *shadingsys;
     ShadingSystemImpl *ssi;
     SimpleRenderer rend;
-    ShadingContext *ctx;
     void *handle;
 
-    unsigned short Xi[3];                /* seed for RNG */
-
     /* Information about each shader of the renderer */
 #if 0
     struct OSLShader{
@@ -117,8 +113,8 @@
     std::vector<OSLShader> shaders;
 #endif
 
-    const ClosureColor
-       *ExecuteShaders(ShaderGlobals &globals, RenderInfo *info);
+    static const ClosureColor
+       *ExecuteShaders(ShaderGlobals &globals, RenderInfo *info, 
ShadingSystemImpl *ssi);
 
     /* Sample a primitive from the shaders group */
     const ClosurePrimitive* SamplePrimitive(Color3& weight,

Modified: brlcad/trunk/src/liboptical/sh_osl.cpp
===================================================================
--- brlcad/trunk/src/liboptical/sh_osl.cpp      2011-07-15 00:59:17 UTC (rev 
45497)
+++ brlcad/trunk/src/liboptical/sh_osl.cpp      2011-07-15 01:23:43 UTC (rev 
45498)
@@ -538,7 +538,7 @@
        struct application new_ap;
        RT_APPLICATION_INIT(&new_ap);
        
-       new_ap = *ap;
+       new_ap = *ap;                     /* struct copy */
        new_ap.a_onehit = 1;
        new_ap.a_hit = default_a_hit;
        new_ap.a_level = info.depth + 1;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to