27 const uint32_t path_flag,
35 globals->dPdx = dP.
dx;
36 globals->dPdy = dP.
dy;
38 globals->dIdx = dI.
dx;
39 globals->dIdy = dI.
dy;
43 globals->dudx = sd->du.dx;
44 globals->dudy = sd->du.dy;
46 globals->dvdx = sd->dv.dx;
47 globals->dvdy = sd->dv.dy;
48 globals->dPdu = sd->dPdu;
49 globals->dPdv = sd->dPdv;
50 globals->time = sd->time;
51 globals->dtime = 1.0f;
52 globals->surfacearea = 1.0f;
53 globals->raytype = path_flag;
54 globals->flipHandedness = 0;
59 globals->shadingStateUniform =
nullptr;
60 globals->thread_index = 0;
61 globals->shade_index = 0;
64 globals->shader2common = sd;
65 globals->object2common = sd;
68 globals->Ci =
nullptr;
73 const uint32_t path_flag,
80 int layer_stack_level = -1;
84 switch (closure->id) {
88 weight *=
mul->weight;
89 closure =
mul->closure;
93 if (stack_size >= 16) {
99 closure =
add->closureA;
100 weight_stack[stack_size] = weight;
101 closure_stack[stack_size++] =
add->closureB;
104 case OSL_CLOSURE_LAYER_ID: {
106 static_cast<const ccl_private OSLClosureComponent *
>(closure);
113 if (layer->top !=
nullptr) {
115 weight_stack[stack_size] = weight;
116 closure_stack[stack_size] = layer->base;
118 layer_stack_level = stack_size++;
121 closure = layer->top;
125 closure = layer->base;
129#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \
130 case OSL_CLOSURE_##Upper##_ID: { \
131 ccl_private const OSLClosureComponent *comp = \
132 static_cast<ccl_private const OSLClosureComponent *>(closure); \
133 float3 albedo = one_float3(); \
134 osl_closure_##lower##_setup(kg, \
137 weight * comp->weight, \
138 reinterpret_cast<ccl_private const Upper##Closure *>(comp + 1), \
139 (layer_stack_level >= 0) ? &albedo : nullptr); \
140 if (layer_stack_level >= 0) { \
141 layer_albedo += albedo; \
152 if (stack_size == 0) {
156 weight = weight_stack[--stack_size];
157 closure = closure_stack[stack_size];
158 if (stack_size == layer_stack_level) {
162 layer_stack_level = -1;
169 }
while (closure ==
nullptr);
173#ifndef __KERNEL_GPU__
175template<ShaderType type>
183template<ShaderType type,
typename ConstIntegratorGenericState>
185 ConstIntegratorGenericState
state,
187 const uint32_t path_flag)
194# ifdef __KERNEL_OPTIX__
195 uint8_t closure_pool[1024];
196 globals.closure_pool = closure_pool;
206# if __cplusplus < 201703L
215 const float dP = sd->dP;
239 unsigned int optix_dc_index = 2 + 1 +
241 optixDirectCall<void>(optix_dc_index,
262 unsigned int optix_dc_index = 2 + 1 +
264 optixDirectCall<void>(optix_dc_index,
273# if __cplusplus < 201703L
280 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 ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_forceinline float differential_make_compact(const float dD)
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
ccl_device_inline void object_dir_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private float3 *D)
ccl_device_inline void object_position_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private float3 *P)
ccl_device void flatten_closure_tree(KernelGlobals kg, ccl_private ShaderData *sd, const uint32_t path_flag, const ccl_private OSLClosure *closure)
CCL_NAMESPACE_BEGIN ccl_device_inline void shaderdata_to_shaderglobals(KernelGlobals kg, ccl_private ShaderData *sd, const uint32_t path_flag, ccl_private ShaderGlobals *globals)
void osl_eval_nodes(const ThreadKernelGlobalsCPU *kg, const void *state, ShaderData *sd, uint32_t path_flag)
@ SHADER_TYPE_DISPLACEMENT
@ ATTR_STD_POSITION_UNDISPLACED
ccl_device_inline bool is_zero(const float2 a)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
CCL_NAMESPACE_BEGIN ccl_device_forceinline T primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc, ccl_private T *dfdx, ccl_private T *dfdy)
static bool find_attribute(const std::string &attributes, const char *search_attribute)
ccl_private OSLClosure * Ci