Skip to content

Commit 802f3aa

Browse files
committed
Re-remove device decoration from some osl_ functions (#1951)
Recent PR 1852 (Free functions for texturing, point clouds, and trace) added host/device decorations to certain `osl_` functions that previously were replicated in OptiX-based renderers. This means that now the ones in those renderers will be seen as duplicate symbols. The more clear intent that we'd like to work towards is that all the `osl_` functions are meant to be "internal" to the liboslexec or the bitcode it provides, and the `rs_` functions are the customization points that the renderer is expected to supply. Except... a bunch of the `osl_` functions that set parameters for subsequent texture and trace calls do not yet have `rs_` customization points. So we're actually not quite ready to change things. To unbreak, then, this PR removes the `__device__` decorations (so they are again safe/expected for GPU renderers to override them). To keep testshade/testrender working, we add copies of them to testshade/testrender specifically. Like I said, eventually we'll add `rs_` customization points, and at that point, we'll truly expect the `osl_` functions to be only supplied by oslexec itself and not the renderers. Signed-off-by: Larry Gritz <[email protected]>
1 parent 8d1c9d6 commit 802f3aa

File tree

2 files changed

+314
-33
lines changed

2 files changed

+314
-33
lines changed

src/liboslexec/optexture.cpp

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ osl_init_texture_options(OpaqueExecContextPtr oec, void* opt)
6666
}
6767

6868

69-
OSL_SHADEOP OSL_HOSTDEVICE void
69+
#define OSL_TEXTURE_SET_HOSTDEVICE /* just host */
70+
71+
72+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
7073
osl_texture_set_firstchannel(void* opt, int x)
7174
{
7275
((TextureOpt*)opt)->firstchannel = x;
7376
}
7477

75-
OSL_HOSTDEVICE inline TextureOpt::Wrap
78+
OSL_TEXTURE_SET_HOSTDEVICE inline TextureOpt::Wrap
7679
decode_wrapmode(ustringhash_pod name_)
7780
{
7881
// TODO: Enable when decode_wrapmode has __device__ marker.
@@ -89,134 +92,134 @@ decode_wrapmode(ustringhash_pod name_)
8992
#endif
9093
}
9194

92-
OSL_SHADEOP OSL_HOSTDEVICE int
95+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE int
9396
osl_texture_decode_wrapmode(ustringhash_pod name_)
9497
{
9598
return (int)decode_wrapmode(name_);
9699
}
97100

98-
OSL_SHADEOP OSL_HOSTDEVICE void
101+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
99102
osl_texture_set_swrap(void* opt, ustringhash_pod x_)
100103
{
101104
((TextureOpt*)opt)->swrap = decode_wrapmode(x_);
102105
}
103106

104-
OSL_SHADEOP OSL_HOSTDEVICE void
107+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
105108
osl_texture_set_twrap(void* opt, ustringhash_pod x_)
106109
{
107110
((TextureOpt*)opt)->twrap = decode_wrapmode(x_);
108111
}
109112

110-
OSL_SHADEOP OSL_HOSTDEVICE void
113+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
111114
osl_texture_set_rwrap(void* opt, ustringhash_pod x_)
112115
{
113116
((TextureOpt*)opt)->rwrap = decode_wrapmode(x_);
114117
}
115118

116-
OSL_SHADEOP OSL_HOSTDEVICE void
119+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
117120
osl_texture_set_stwrap(void* opt, ustringhash_pod x_)
118121
{
119122
TextureOpt::Wrap code = decode_wrapmode(x_);
120123
((TextureOpt*)opt)->swrap = code;
121124
((TextureOpt*)opt)->twrap = code;
122125
}
123126

124-
OSL_SHADEOP OSL_HOSTDEVICE void
127+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
125128
osl_texture_set_swrap_code(void* opt, int mode)
126129
{
127130
((TextureOpt*)opt)->swrap = (TextureOpt::Wrap)mode;
128131
}
129132

130-
OSL_SHADEOP OSL_HOSTDEVICE void
133+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
131134
osl_texture_set_twrap_code(void* opt, int mode)
132135
{
133136
((TextureOpt*)opt)->twrap = (TextureOpt::Wrap)mode;
134137
}
135138

136-
OSL_SHADEOP OSL_HOSTDEVICE void
139+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
137140
osl_texture_set_rwrap_code(void* opt, int mode)
138141
{
139142
((TextureOpt*)opt)->rwrap = (TextureOpt::Wrap)mode;
140143
}
141144

142-
OSL_SHADEOP OSL_HOSTDEVICE void
145+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
143146
osl_texture_set_stwrap_code(void* opt, int mode)
144147
{
145148
((TextureOpt*)opt)->swrap = (TextureOpt::Wrap)mode;
146149
((TextureOpt*)opt)->twrap = (TextureOpt::Wrap)mode;
147150
}
148151

149-
OSL_SHADEOP OSL_HOSTDEVICE void
152+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
150153
osl_texture_set_sblur(void* opt, float x)
151154
{
152155
((TextureOpt*)opt)->sblur = x;
153156
}
154157

155-
OSL_SHADEOP OSL_HOSTDEVICE void
158+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
156159
osl_texture_set_tblur(void* opt, float x)
157160
{
158161
((TextureOpt*)opt)->tblur = x;
159162
}
160163

161-
OSL_SHADEOP OSL_HOSTDEVICE void
164+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
162165
osl_texture_set_rblur(void* opt, float x)
163166
{
164167
((TextureOpt*)opt)->rblur = x;
165168
}
166169

167-
OSL_SHADEOP OSL_HOSTDEVICE void
170+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
168171
osl_texture_set_stblur(void* opt, float x)
169172
{
170173
((TextureOpt*)opt)->sblur = x;
171174
((TextureOpt*)opt)->tblur = x;
172175
}
173176

174-
OSL_SHADEOP OSL_HOSTDEVICE void
177+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
175178
osl_texture_set_swidth(void* opt, float x)
176179
{
177180
((TextureOpt*)opt)->swidth = x;
178181
}
179182

180-
OSL_SHADEOP OSL_HOSTDEVICE void
183+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
181184
osl_texture_set_twidth(void* opt, float x)
182185
{
183186
((TextureOpt*)opt)->twidth = x;
184187
}
185188

186-
OSL_SHADEOP OSL_HOSTDEVICE void
189+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
187190
osl_texture_set_rwidth(void* opt, float x)
188191
{
189192
((TextureOpt*)opt)->rwidth = x;
190193
}
191194

192-
OSL_SHADEOP OSL_HOSTDEVICE void
195+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
193196
osl_texture_set_stwidth(void* opt, float x)
194197
{
195198
((TextureOpt*)opt)->swidth = x;
196199
((TextureOpt*)opt)->twidth = x;
197200
}
198201

199-
OSL_SHADEOP OSL_HOSTDEVICE void
202+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
200203
osl_texture_set_fill(void* opt, float x)
201204
{
202205
((TextureOpt*)opt)->fill = x;
203206
}
204207

205-
OSL_SHADEOP OSL_HOSTDEVICE void
208+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
206209
osl_texture_set_time(void* opt, float x)
207210
{
208211
// Not used by the texture system
209212
// ((TextureOpt*)opt)->time = x;
210213
}
211214

212-
OSL_SHADEOP OSL_HOSTDEVICE int
215+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE int
213216
osl_texture_decode_interpmode(ustringhash_pod name_)
214217
{
215218
ustringhash name_hash = ustringhash_from(name_);
216219
return tex_interp_to_code(name_hash);
217220
}
218221

219-
OSL_SHADEOP OSL_HOSTDEVICE void
222+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
220223
osl_texture_set_interp(void* opt, ustringhash_pod modename_)
221224
{
222225
ustringhash modename_hash = ustringhash_from(modename_);
@@ -225,20 +228,21 @@ osl_texture_set_interp(void* opt, ustringhash_pod modename_)
225228
((TextureOpt*)opt)->interpmode = (TextureOpt::InterpMode)mode;
226229
}
227230

228-
OSL_SHADEOP OSL_HOSTDEVICE void
231+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
229232
osl_texture_set_interp_code(void* opt, int mode)
230233
{
234+
// rs_texture_set_interp_code((*(TextureOpt*)opt), mode);
231235
((TextureOpt*)opt)->interpmode = (TextureOpt::InterpMode)mode;
232236
}
233237

234-
OSL_SHADEOP OSL_HOSTDEVICE void
238+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
235239
osl_texture_set_subimage(void* opt, int subimage)
236240
{
237241
((TextureOpt*)opt)->subimage = subimage;
238242
}
239243

240244

241-
OSL_SHADEOP OSL_HOSTDEVICE void
245+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
242246
osl_texture_set_subimagename(void* opt, ustringhash_pod subimagename_)
243247
{
244248
ustringhash subimagename_hash = ustringhash_from(subimagename_);
@@ -255,13 +259,13 @@ osl_texture_set_subimagename(void* opt, ustringhash_pod subimagename_)
255259
#endif
256260
}
257261

258-
OSL_SHADEOP OSL_HOSTDEVICE void
262+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
259263
osl_texture_set_missingcolor_arena(void* opt, const void* missing)
260264
{
261265
((TextureOpt*)opt)->missingcolor = (const float*)missing;
262266
}
263267

264-
OSL_SHADEOP OSL_HOSTDEVICE void
268+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
265269
osl_texture_set_missingcolor_alpha(void* opt, int alphaindex,
266270
float missingalpha)
267271
{
@@ -576,32 +580,32 @@ osl_get_textureinfo_st(OpaqueExecContextPtr oec, ustringhash_pod name_,
576580

577581
// Trace
578582

579-
OSL_SHADEOP OSL_HOSTDEVICE void
583+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
580584
osl_init_trace_options(OpaqueExecContextPtr oec, void* opt)
581585
{
582586
new (opt) TraceOpt;
583587
}
584588

585-
OSL_SHADEOP OSL_HOSTDEVICE void
589+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
586590
osl_trace_set_mindist(void* opt, float x)
587591
{
588592
((TraceOpt*)opt)->mindist = x;
589593
}
590594

591-
OSL_SHADEOP OSL_HOSTDEVICE void
595+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
592596
osl_trace_set_maxdist(void* opt, float x)
593597
{
594598
((TraceOpt*)opt)->maxdist = x;
595599
}
596600

597-
OSL_SHADEOP OSL_HOSTDEVICE void
601+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
598602
osl_trace_set_shade(void* opt, int x)
599603
{
600604
((TraceOpt*)opt)->shade = x;
601605
}
602606

603607

604-
OSL_SHADEOP OSL_HOSTDEVICE void
608+
OSL_SHADEOP OSL_TEXTURE_SET_HOSTDEVICE void
605609
osl_trace_set_traceset(void* opt, const ustringhash_pod x)
606610
{
607611
((TraceOpt*)opt)->traceset = ustringhash_from(x);

0 commit comments

Comments
 (0)