@@ -14,27 +14,18 @@ extern __device__ char* s_color_system;
1414}
1515OSL_NAMESPACE_END
1616
17- // Taken from the SimplePool class
18- __device__ static inline size_t
19- alignment_offset_calc (void * ptr, size_t alignment)
20- {
21- uintptr_t ptrbits = reinterpret_cast <uintptr_t >(ptr);
22- uintptr_t offset = ((ptrbits + alignment - 1 ) & -alignment) - ptrbits;
23- return offset;
24- }
25-
2617// These functions are declared extern to prevent name mangling.
2718extern " C" {
2819
2920
30- __device__ void *
21+ __device__ const void *
3122osl_add_closure_closure (void * sg_, const void * a_, const void * b_)
3223{
33- a_ = __builtin_assume_aligned (a_, alignof (float ));
34- b_ = __builtin_assume_aligned (b_, alignof (float ));
35- ShaderGlobals* sg = (ShaderGlobals*)sg_;
36- const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
37- const OSL ::ClosureColor* b = (const OSL ::ClosureColor*)b_;
24+ a_ = __builtin_assume_aligned (a_, alignof (float ));
25+ b_ = __builtin_assume_aligned (b_, alignof (float ));
26+ OSL_CUDA :: ShaderGlobals* sg = (OSL_CUDA :: ShaderGlobals*)sg_;
27+ const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
28+ const OSL ::ClosureColor* b = (const OSL ::ClosureColor*)b_;
3829 if (a == NULL )
3930 return b;
4031 if (b == NULL )
@@ -51,15 +42,15 @@ osl_add_closure_closure(void* sg_, const void* a_, const void* b_)
5142 return add;
5243}
5344
54- __device__ void *
45+ __device__ const void *
5546osl_mul_closure_color (void * sg_, const void * a_, const void * w_)
5647{
5748 a_ = __builtin_assume_aligned (a_, alignof (float ));
5849 w_ = __builtin_assume_aligned (w_, alignof (float ));
5950
60- ShaderGlobals* sg = (ShaderGlobals*)sg_;
61- const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
62- const OSL ::Color3* w = (const OSL ::Color3*)w_;
51+ OSL_CUDA :: ShaderGlobals* sg = (OSL_CUDA :: ShaderGlobals*)sg_;
52+ const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
53+ const OSL ::Color3* w = (const OSL ::Color3*)w_;
6354 if (a == NULL )
6455 return NULL ;
6556 if (w->x == 0 .0f && w->y == 0 .0f && w->z == 0 .0f )
@@ -78,13 +69,13 @@ osl_mul_closure_color(void* sg_, const void* a_, const void* w_)
7869 return mul;
7970}
8071
81- __device__ void *
72+ __device__ const void *
8273osl_mul_closure_float (void * sg_, const void * a_, float w)
8374{
8475 a_ = __builtin_assume_aligned (a_, alignof (float ));
8576
86- ShaderGlobals* sg = (ShaderGlobals*)sg_;
87- const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
77+ OSL_CUDA :: ShaderGlobals* sg = (OSL_CUDA :: ShaderGlobals*)sg_;
78+ const OSL ::ClosureColor* a = (const OSL ::ClosureColor*)a_;
8879 if (a == NULL )
8980 return NULL ;
9081 if (w == 0 .0f )
@@ -106,8 +97,8 @@ osl_mul_closure_float(void* sg_, const void* a_, float w)
10697__device__ void *
10798osl_allocate_closure_component (void * sg_, int id, int size)
10899{
109- ShaderGlobals* sg = (ShaderGlobals*)sg_;
110- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
100+ OSL_CUDA :: ShaderGlobals* sg = (OSL_CUDA :: ShaderGlobals*)sg_;
101+ auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
111102 // Allocate the component and the mul back to back
112103 const size_t needed = sizeof (OSL ::ClosureComponent) + size;
113104 OSL ::ClosureComponent* comp
@@ -126,8 +117,8 @@ osl_allocate_weighted_closure_component(void* sg_, int id, int size,
126117{
127118 w_ = __builtin_assume_aligned (w_, alignof (float ));
128119
129- ShaderGlobals* sg = (ShaderGlobals*)sg_;
130- const OSL ::Color3* w = (const OSL ::Color3*)w_;
120+ OSL_CUDA :: ShaderGlobals* sg = (OSL_CUDA :: ShaderGlobals*)sg_;
121+ const OSL ::Color3* w = (const OSL ::Color3*)w_;
131122 if (w->x == 0 .0f && w->y == 0 .0f && w->z == 0 .0f )
132123 return NULL ;
133124 auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
0 commit comments