Skip to content

Commit 6cc829b

Browse files
committed
Use stack closure pool for test shade cpu bitcode
Signed-off-by: Curtis Black <curtis.w.black@gmail.com>
1 parent dd091ca commit 6cc829b

5 files changed

Lines changed: 10 additions & 19 deletions

File tree

src/liboslexec/shadeimage.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ shade_image(ShadingSystem& shadingsys, ShaderGroup& group,
116116
// That also implies that our normal points to (0,0,1)
117117
sg.N = Vec3(0, 0, 1);
118118
sg.Ng = Vec3(0, 0, 1);
119-
// In our SimpleRenderer, the "renderstate" itself just a pointer to
120-
// the ShaderGlobals.
121-
// sg.renderstate = &sg;
122119
}
123120

124121
// Loop over all pixels in the image (in x and y)...

src/osltoy/osltoyrenderer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ OSLToyRenderer::OSLToyRenderer()
115115
// That also implies that our normal points to (0,0,1)
116116
sg.N = Vec3(0, 0, 1);
117117
sg.Ng = Vec3(0, 0, 1);
118-
// In our SimpleRenderer, the "renderstate" itself just a pointer to
119-
// the ShaderGlobals.
120-
// sg.renderstate = &sg;
121118
}
122119

123120

src/testrender/simpleraytracer.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,6 @@ SimpleRaytracer::globals_from_hit(ShaderGlobalsType& sg, const Ray& r,
921921
}
922922
sg.raytype = r.raytype;
923923
sg.flipHandedness = sg.dPdx.cross(sg.dPdy).dot(sg.N) < 0;
924-
925-
#ifndef __CUDACC__
926-
// In our SimpleRaytracer, the "renderstate" itself just a pointer to
927-
// the ShaderGlobals.
928-
sg.renderstate = &sg;
929-
#endif
930924
}
931925

932926

@@ -1349,7 +1343,6 @@ SimpleRaytracer::prepare_geometry()
13491343
sg.v = uv[i].y;
13501344
sg.I = (p[i] - camera.eye).normalize();
13511345
sg.surfacearea = area;
1352-
sg.renderstate = &sg;
13531346

13541347
shadingsys->execute(*ctx, *m_shaders[shaderID].disp, sg);
13551348

src/testshade/rs_simplerend.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,12 @@ rs_trace_get(OSL::OpaqueExecContextPtr ec, OSL::ustringhash name,
368368
#endif
369369
}
370370

371-
#ifdef __CUDA_ARCH__ // Host side uses rs_fallback implementation.
372371
OSL_RSOP OSL_HOSTDEVICE void*
373372
rs_allocate_closure(OSL::OpaqueExecContextPtr ec, size_t size, size_t alignment)
374373
{
375374
auto rs = OSL::get_rs<RenderState>(ec);
376375
return rs->closure_pool->allocate(size, alignment);
377376
}
378-
#endif
379377

380378
OSL_RSOP OSL_HOSTDEVICE bool
381379
rs_get_attribute_constant_string(OSL::ustringhash value, void* result)

src/testshade/testshade.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,16 +952,19 @@ static RenderContext theRenderContext;
952952
// Set up the ShaderGlobals fields for pixel (x,y).
953953
static void
954954
setup_shaderglobals(ShaderGlobals& sg, ShadingSystem* shadingsys,
955-
RenderState& renderState, int x, int y)
955+
RenderState& renderState, StackClosurePool* closure_pool,
956+
int x, int y)
956957
{
957958
// Just zero the whole thing out to start
958959
memset((char*)&sg, 0, sizeof(ShaderGlobals));
959960

960961
// Any state data needed by SimpleRenderer or its free function equivalent
961962
// will need to be passed here the ShaderGlobals.
962963
renderState.context = &theRenderContext;
963-
renderState.closure_pool = nullptr; // Use inbuilt closure pool.
964+
renderState.closure_pool = closure_pool;
964965
sg.renderstate = &renderState;
966+
if (closure_pool)
967+
closure_pool->reset();
965968

966969
// Set "shader" space to be Mshad. In a real renderer, this may be
967970
// different for each shader group.
@@ -1185,7 +1188,8 @@ setup_output_images(SimpleRenderer* rend, ShadingSystem* shadingsys,
11851188
raytype_bit = shadingsys->raytype_bit(ustring(raytype_name));
11861189
ShaderGlobals sg;
11871190
RenderState renderState;
1188-
setup_shaderglobals(sg, shadingsys, renderState, 0, 0);
1191+
StackClosurePool closure_pool;
1192+
setup_shaderglobals(sg, shadingsys, renderState, &closure_pool, 0, 0);
11891193

11901194
#if OSL_USE_BATCHED
11911195
if (batched) {
@@ -1590,6 +1594,7 @@ shade_region(SimpleRenderer* rend, ShaderGroup* shadergroup, OIIO::ROI roi,
15901594
// Set up shader globals and a little test grid of points to shade.
15911595
ShaderGlobals shaderglobals;
15921596
RenderState renderState;
1597+
StackClosurePool closure_pool;
15931598

15941599
raytype_bit = shadingsys->raytype_bit(ustring(raytype_name));
15951600

@@ -1610,7 +1615,8 @@ shade_region(SimpleRenderer* rend, ShaderGroup* shadergroup, OIIO::ROI roi,
16101615
// set it up rigged to look like we're rendering a single
16111616
// quadrilateral that exactly fills the viewport, and that
16121617
// setup is done in the following function call:
1613-
setup_shaderglobals(shaderglobals, shadingsys, renderState, x, y);
1618+
setup_shaderglobals(shaderglobals, shadingsys, renderState,
1619+
&closure_pool, x, y);
16141620

16151621
if (this_threads_index == uninitialized_thread_index) {
16161622
this_threads_index = next_thread_index.fetch_add(1u);

0 commit comments

Comments
 (0)