diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-14 13:13:43 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-14 13:24:15 +0300 |
commit | b50cf33d917b3e0fe7152cff96996e5a850c68d4 (patch) | |
tree | 775a7e8a6129e634d8a4982671fa0999a76444e7 /intern/cycles/kernel/osl/osl_shader.cpp | |
parent | 9fecac32d9e9f3e6dd69f89fe4ceaddcecaf1277 (diff) |
Fix T64515, T60434: crash in OSL and preview render after recent changes
The refactoring of texture handles did not take into account that render
services are shared between multiple render session. Now the texture
to handle map is also shared between render sessions.
Diffstat (limited to 'intern/cycles/kernel/osl/osl_shader.cpp')
-rw-r--r-- | intern/cycles/kernel/osl/osl_shader.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index 69599825bc0..db5ad06d3fc 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -49,7 +49,6 @@ void OSLShader::thread_init(KernelGlobals *kg, /* per thread kernel data init*/ kg->osl = osl_globals; - kg->osl->services->thread_init(kernel_globals, osl_globals, osl_globals->ts); OSL::ShadingSystem *ss = kg->osl->ss; OSLThreadData *tdata = new OSLThreadData(); @@ -129,13 +128,13 @@ static void shaderdata_to_shaderglobals( tdata->tracedata.init = false; /* used by renderservices */ + sd->osl_globals = kg; sd->osl_path_state = state; } /* Surface */ -static void flatten_surface_closure_tree(KernelGlobals *kg, - ShaderData *sd, +static void flatten_surface_closure_tree(ShaderData *sd, int path_flag, const OSL::ClosureColor *closure, float3 weight = make_float3(1.0f, 1.0f, 1.0f)) @@ -146,14 +145,13 @@ static void flatten_surface_closure_tree(KernelGlobals *kg, switch (closure->id) { case OSL::ClosureColor::MUL: { OSL::ClosureMul *mul = (OSL::ClosureMul *)closure; - flatten_surface_closure_tree( - kg, sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight); + flatten_surface_closure_tree(sd, path_flag, mul->closure, TO_FLOAT3(mul->weight) * weight); break; } case OSL::ClosureColor::ADD: { OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure; - flatten_surface_closure_tree(kg, sd, path_flag, add->closureA, weight); - flatten_surface_closure_tree(kg, sd, path_flag, add->closureB, weight); + flatten_surface_closure_tree(sd, path_flag, add->closureA, weight); + flatten_surface_closure_tree(sd, path_flag, add->closureB, weight); break; } default: { @@ -164,7 +162,7 @@ static void flatten_surface_closure_tree(KernelGlobals *kg, #ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS weight = weight * TO_FLOAT3(comp->w); #endif - prim->setup(kg, sd, path_flag, weight); + prim->setup(sd, path_flag, weight); } break; } @@ -235,13 +233,12 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state /* flatten closure tree */ if (globals->Ci) - flatten_surface_closure_tree(kg, sd, path_flag, globals->Ci); + flatten_surface_closure_tree(sd, path_flag, globals->Ci); } /* Background */ -static void flatten_background_closure_tree(KernelGlobals *kg, - ShaderData *sd, +static void flatten_background_closure_tree(ShaderData *sd, const OSL::ClosureColor *closure, float3 weight = make_float3(1.0f, 1.0f, 1.0f)) { @@ -252,14 +249,14 @@ static void flatten_background_closure_tree(KernelGlobals *kg, switch (closure->id) { case OSL::ClosureColor::MUL: { OSL::ClosureMul *mul = (OSL::ClosureMul *)closure; - flatten_background_closure_tree(kg, sd, mul->closure, weight * TO_FLOAT3(mul->weight)); + flatten_background_closure_tree(sd, mul->closure, weight * TO_FLOAT3(mul->weight)); break; } case OSL::ClosureColor::ADD: { OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure; - flatten_background_closure_tree(kg, sd, add->closureA, weight); - flatten_background_closure_tree(kg, sd, add->closureB, weight); + flatten_background_closure_tree(sd, add->closureA, weight); + flatten_background_closure_tree(sd, add->closureB, weight); break; } default: { @@ -270,7 +267,7 @@ static void flatten_background_closure_tree(KernelGlobals *kg, #ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS weight = weight * TO_FLOAT3(comp->w); #endif - prim->setup(kg, sd, 0, weight); + prim->setup(sd, 0, weight); } break; } @@ -294,13 +291,12 @@ void OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, PathState *st /* return background color immediately */ if (globals->Ci) - flatten_background_closure_tree(kg, sd, globals->Ci); + flatten_background_closure_tree(sd, globals->Ci); } /* Volume */ -static void flatten_volume_closure_tree(KernelGlobals *kg, - ShaderData *sd, +static void flatten_volume_closure_tree(ShaderData *sd, const OSL::ClosureColor *closure, float3 weight = make_float3(1.0f, 1.0f, 1.0f)) { @@ -310,13 +306,13 @@ static void flatten_volume_closure_tree(KernelGlobals *kg, switch (closure->id) { case OSL::ClosureColor::MUL: { OSL::ClosureMul *mul = (OSL::ClosureMul *)closure; - flatten_volume_closure_tree(kg, sd, mul->closure, TO_FLOAT3(mul->weight) * weight); + flatten_volume_closure_tree(sd, mul->closure, TO_FLOAT3(mul->weight) * weight); break; } case OSL::ClosureColor::ADD: { OSL::ClosureAdd *add = (OSL::ClosureAdd *)closure; - flatten_volume_closure_tree(kg, sd, add->closureA, weight); - flatten_volume_closure_tree(kg, sd, add->closureB, weight); + flatten_volume_closure_tree(sd, add->closureA, weight); + flatten_volume_closure_tree(sd, add->closureB, weight); break; } default: { @@ -327,7 +323,7 @@ static void flatten_volume_closure_tree(KernelGlobals *kg, #ifdef OSL_SUPPORTS_WEIGHTED_CLOSURE_COMPONENTS weight = weight * TO_FLOAT3(comp->w); #endif - prim->setup(kg, sd, 0, weight); + prim->setup(sd, 0, weight); } } } @@ -351,7 +347,7 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, /* flatten closure tree */ if (globals->Ci) - flatten_volume_closure_tree(kg, sd, globals->Ci); + flatten_volume_closure_tree(sd, globals->Ci); } /* Displacement */ |