15#ifdef __KERNEL_OPTIX__
29 const uint32_t path_flag,
37 globals->dPdx = dP.
dx;
38 globals->dPdy = dP.
dy;
40 globals->dIdx = dI.
dx;
41 globals->dIdy = dI.
dy;
45 globals->dudx = sd->du.dx;
46 globals->dudy = sd->du.dy;
48 globals->dvdx = sd->dv.dx;
49 globals->dvdy = sd->dv.dy;
50 globals->dPdu = sd->dPdu;
51 globals->dPdv = sd->dPdv;
52 globals->time = sd->time;
53 globals->dtime = 1.0f;
54 globals->surfacearea = 1.0f;
56 globals->flipHandedness = 0;
61 globals->shadingStateUniform =
nullptr;
62 globals->thread_index = 0;
63 globals->shade_index = 0;
66 globals->shader2common = sd;
67 globals->object2common = sd;
70 globals->Ci =
nullptr;
76 const uint32_t path_flag,
83 int layer_stack_level = -1;
87 switch (closure->id) {
91 weight *=
mul->weight;
92 closure =
mul->closure;
96 if (stack_size >= 16) {
102 closure =
add->closureA;
103 weight_stack[stack_size] = weight;
104 closure_stack[stack_size++] =
add->closureB;
107 case OSL_CLOSURE_LAYER_ID: {
109 static_cast<const ccl_private OSLClosureComponent *
>(closure);
116 if (
layer->top !=
nullptr) {
118 weight_stack[stack_size] = weight;
119 closure_stack[stack_size] =
layer->base;
121 layer_stack_level = stack_size++;
124 closure =
layer->top;
128 closure =
layer->base;
132#define OSL_CLOSURE_STRUCT_BEGIN(Upper, lower) \
133 case OSL_CLOSURE_##Upper##_ID: { \
134 ccl_private const OSLClosureComponent *comp = \
135 static_cast<ccl_private const OSLClosureComponent *>(closure); \
136 float3 albedo = one_float3(); \
137 osl_closure_##lower##_setup(kg, \
141 weight * comp->weight, \
142 reinterpret_cast<ccl_private const Upper##Closure *>(comp + 1), \
143 (layer_stack_level >= 0) ? &albedo : nullptr); \
144 if (layer_stack_level >= 0) { \
145 layer_albedo += albedo; \
157 if (stack_size == 0) {
161 weight = weight_stack[--stack_size];
162 closure = closure_stack[stack_size];
163 if (stack_size == layer_stack_level) {
167 layer_stack_level = -1;
174 }
while (closure ==
nullptr);
178#ifndef __KERNEL_GPU__
180template<ShaderType type,
typename ConstIntegratorGenericState>
182 ConstIntegratorGenericState
state,
189template<ShaderType type,
typename ConstIntegratorGenericState>
191 ConstIntegratorGenericState
state,
194 const uint32_t path_flag)
201# ifdef __KERNEL_OPTIX__
202 uint8_t closure_pool[1024];
203 globals.closure_pool = closure_pool;
204 globals.closure_pool_end = closure_pool +
sizeof(closure_pool);
205 if constexpr (std::is_same_v<ConstIntegratorGenericState, ConstIntegratorBakeState>) {
208 else if constexpr (std::is_same_v<ConstIntegratorGenericState, ConstIntegratorShadowState>) {
221 const float dP = sd->dP;
247 unsigned int optix_dc_index = 2 + 1 +
249 optixDirectCall<void>(optix_dc_index,
270 unsigned int optix_dc_index = 2 + 1 +
272 optixDirectCall<void>(optix_dc_index,
284 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)
static void add(btAlignedObjectArray< T > &items, const Q &value)
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
#define kernel_assert(cond)
#define ccl_device_inline
#define OSL_RAYTYPE_PACK(visibility, path_flag)
#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_NAMESPACE_BEGIN ccl_device_forceinline bool is_attribute_found(const ccl_private AttributeDescriptor &desc)
ccl_device_inline AttributeDescriptor find_attribute(const ccl_global AttributeMap *attributes_map, uint attr_offset, const int prim, const uint64_t id)
ccl_device_inline void object_position_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private T *P)
CCL_NAMESPACE_BEGIN ccl_device_inline void shaderdata_to_shaderglobals(ccl_private ShaderData *sd, const PathRayVisibility path_visibility, const uint32_t path_flag, ccl_private ShaderGlobals *globals)
void osl_eval_nodes(const ThreadKernelGlobalsCPU *kg, ConstIntegratorGenericState state, ShaderData *sd, PathRayVisibility path_visibility, uint32_t path_flag)
ccl_device void flatten_closure_tree(KernelGlobals kg, ccl_private ShaderData *sd, const PathRayVisibility ray_visibility, const uint32_t path_flag, const ccl_private OSLClosure *closure)
@ SHADER_TYPE_DISPLACEMENT
uint32_t PathRayVisibility
@ SD_HAS_BUMP_FROM_DISPLACEMENT
@ ATTR_STD_POSITION_UNDISPLACED
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
ccl_device void primitive_normal_set_undisplaced(KernelGlobals kg, ccl_private ShaderData *sd, const int position_undisplaced_offset)
CCL_NAMESPACE_BEGIN ccl_device_forceinline T primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc)
ccl_private OSLClosure * Ci