@@ -17,124 +17,6 @@ OSL_NAMESPACE_END
1717// These functions are declared extern to prevent name mangling.
1818extern " C" {
1919
20-
21- __device__ const void *
22- osl_add_closure_closure (void * sg_, const void * a_, const void * b_)
23- {
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_;
29- if (a == NULL )
30- return b;
31- if (b == NULL )
32- return a;
33- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
34- OSL::ClosureAdd* add
35- = (OSL::ClosureAdd*)closure_pool->allocate (sizeof (OSL::ClosureAdd),
36- alignof (OSL::ClosureAdd));
37- if (add) {
38- add->id = OSL::ClosureColor::ADD;
39- add->closureA = a;
40- add->closureB = b;
41- }
42- return add;
43- }
44-
45- __device__ const void *
46- osl_mul_closure_color (void * sg_, const void * a_, const void * w_)
47- {
48- a_ = __builtin_assume_aligned (a_, alignof (float ));
49- w_ = __builtin_assume_aligned (w_, alignof (float ));
50-
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_;
54- if (a == NULL )
55- return NULL ;
56- if (w->x == 0 .0f && w->y == 0 .0f && w->z == 0 .0f )
57- return NULL ;
58- if (w->x == 1 .0f && w->y == 1 .0f && w->z == 1 .0f )
59- return a;
60- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
61- OSL::ClosureMul* mul
62- = (OSL::ClosureMul*)closure_pool->allocate (sizeof (OSL::ClosureMul),
63- alignof (OSL::ClosureMul));
64- if (mul) {
65- mul->id = OSL::ClosureColor::MUL;
66- mul->weight = *w;
67- mul->closure = a;
68- }
69- return mul;
70- }
71-
72- __device__ const void *
73- osl_mul_closure_float (void * sg_, const void * a_, float w)
74- {
75- a_ = __builtin_assume_aligned (a_, alignof (float ));
76-
77- OSL_CUDA::ShaderGlobals* sg = (OSL_CUDA::ShaderGlobals*)sg_;
78- const OSL::ClosureColor* a = (const OSL::ClosureColor*)a_;
79- if (a == NULL )
80- return NULL ;
81- if (w == 0 .0f )
82- return NULL ;
83- if (w == 1 .0f )
84- return a;
85- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
86- OSL::ClosureMul* mul
87- = (OSL::ClosureMul*)closure_pool->allocate (sizeof (OSL::ClosureMul),
88- alignof (OSL::ClosureMul));
89- if (mul) {
90- mul->id = OSL::ClosureColor::MUL;
91- mul->weight = OSL::Color3 (w);
92- mul->closure = a;
93- }
94- return mul;
95- }
96-
97- __device__ void *
98- osl_allocate_closure_component (void * sg_, int id, int size)
99- {
100- OSL_CUDA::ShaderGlobals* sg = (OSL_CUDA::ShaderGlobals*)sg_;
101- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
102- // Allocate the component and the mul back to back
103- const size_t needed = sizeof (OSL::ClosureComponent) + size;
104- OSL::ClosureComponent* comp
105- = (OSL::ClosureComponent*)
106- closure_pool->allocate (needed, alignof (OSL::ClosureComponent));
107- if (comp) {
108- comp->id = id;
109- comp->w = OSL::Color3 (1 .0f );
110- }
111- return comp;
112- }
113-
114- __device__ void *
115- osl_allocate_weighted_closure_component (void * sg_, int id, int size,
116- const void * w_)
117- {
118- w_ = __builtin_assume_aligned (w_, alignof (float ));
119-
120- OSL_CUDA::ShaderGlobals* sg = (OSL_CUDA::ShaderGlobals*)sg_;
121- const OSL::Color3* w = (const OSL::Color3*)w_;
122- if (w->x == 0 .0f && w->y == 0 .0f && w->z == 0 .0f )
123- return NULL ;
124- auto * closure_pool = ((RenderState*)sg->renderstate )->closure_pool ;
125- // Allocate the component and the mul back to back
126- const size_t needed = sizeof (OSL::ClosureComponent) + size;
127- OSL::ClosureComponent* comp
128- = (OSL::ClosureComponent*)
129- closure_pool->allocate (needed, alignof (OSL::ClosureComponent));
130- if (comp) {
131- comp->id = id;
132- comp->w = *w;
133- }
134- return comp;
135- }
136-
137-
13820#define IS_STRING (type ) (type.basetype == OSL::TypeDesc::STRING)
13921#define IS_PTR (type ) (type.basetype == OSL::TypeDesc::PTR)
14022#define IS_COLOR (type ) (type.vecsemantics == OSL::TypeDesc::COLOR)
0 commit comments