31 globals->dPdx = dP.
dx;
32 globals->dPdy = dP.
dy;
34 globals->dIdx = dI.
dx;
35 globals->dIdy = dI.
dy;
39 globals->dudx = sd->du.dx;
40 globals->dudy = sd->du.dy;
42 globals->dvdx = sd->dv.dx;
43 globals->dvdy = sd->dv.dy;
44 globals->dPdu = sd->dPdu;
45 globals->dPdv = sd->dPdv;
46 globals->time = sd->time;
47 globals->dtime = 1.0f;
48 globals->surfacearea = 1.0f;
49 globals->raytype = path_flag;
50 globals->flipHandedness = 0;
54 globals->renderstate = sd;
55#if OSL_LIBRARY_VERSION_CODE >= 11304
56 globals->shadingStateUniform =
nullptr;
57 globals->thread_index = 0;
58 globals->shade_index = 0;
62 globals->shader2common = sd;
63 globals->object2common = sd;
66 globals->Ci =
nullptr;
78 int layer_stack_level = -1;
82 switch (closure->id) {
86 weight *=
mul->weight;
87 closure =
mul->closure;
91 if (stack_size >= 16) {
97 closure = add->closureA;
98 weight_stack[stack_size] = weight;
99 closure_stack[stack_size++] = add->closureB;
104 static_cast<ccl_private const OSLClosureComponent *
>(closure);
111 if (layer->top !=
nullptr) {
113 weight_stack[stack_size] = weight;
114 closure_stack[stack_size] = layer->base;
116 layer_stack_level = stack_size++;
119 closure = layer->top;
123 closure = layer->base;
127#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \
128 case OSL_CLOSURE_##Upper##_ID: { \
129 ccl_private const OSLClosureComponent *comp = \
130 static_cast<ccl_private const OSLClosureComponent *>(closure); \
131 float3 albedo = one_float3(); \
132 osl_closure_##lower##_setup(kg, \
135 weight * comp->weight, \
136 reinterpret_cast<ccl_private const Upper##Closure *>(comp + 1), \
137 (layer_stack_level >= 0) ? &albedo : NULL); \
138 if (layer_stack_level >= 0) { \
139 layer_albedo += albedo; \
150 if (stack_size == 0) {
154 weight = weight_stack[--stack_size];
155 closure = closure_stack[stack_size];
156 if (stack_size == layer_stack_level) {
160 layer_stack_level = -1;
167 }
while (closure ==
nullptr);
171#ifndef __KERNEL_GPU__
173template<ShaderType type>
181template<ShaderType type,
typename ConstIntegratorGenericState>
183 ConstIntegratorGenericState
state,
192# ifdef __KERNEL_OPTIX__
195 sd->osl_closure_pool = closure_pool;
197 unsigned int optix_dc_index = 2 +
199 optixDirectCall<void>(optix_dc_index + 0,
205 optixDirectCall<void>(optix_dc_index + 1,
213# if __cplusplus < 201703L
220 else if (globals.
Ci) {
ccl_device_inline Spectrum closure_layering_weight(const Spectrum layer_albedo, const Spectrum weight)
static void mul(btAlignedObjectArray< T > &items, const Q &value)
#define kernel_assert(cond)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
ccl_device void flatten_closure_tree(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, ccl_private const OSLClosure *closure)
CCL_NAMESPACE_BEGIN ccl_device_inline void shaderdata_to_shaderglobals(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, ccl_private ShaderGlobals *globals)
void osl_eval_nodes(const KernelGlobalsCPU *kg, const void *state, ShaderData *sd, uint32_t path_flag)
@ SHADER_TYPE_DISPLACEMENT
ccl_device_inline bool is_zero(const float2 a)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
ccl_private OSLClosure * Ci