Blender V5.3
services.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5/* TODO(sergey): There is a bit of headers dependency hell going on
6 * here, so for now we just put here. In the future it might be better
7 * to have dedicated file for such tweaks.
8 */
9#if (defined(__GNUC__) && !defined(__clang__)) && defined(NDEBUG)
10# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
11# pragma GCC diagnostic ignored "-Wuninitialized"
12#endif
13
14#include "util/log.h"
15#include "util/string.h"
16#include "util/types_image.h"
17
19
20#include "kernel/bvh/bvh.h"
21
22#include "kernel/osl/globals.h"
23#include "kernel/osl/services.h"
25#include "kernel/osl/strings.h"
26#include "kernel/osl/types.h"
27
29
30/* RenderServices implementation */
31
33 /* Dummy texture system pointer so OSL doesn't create its own. Such an opaque texture system
34 * pointer is supported and normally would be done with the OSL_NO_DEFAULT_TEXTURESYSTEM
35 * build option, but we want to work with OSL builds that don't have it. */
36 : OSL::RendererServices(reinterpret_cast<OSL::TextureSystem *>(1)), device_type_(device_type)
37{
38}
39
41
42int OSLRenderServices::supports(string_view feature) const
43{
44#ifdef WITH_OPTIX
45 if (feature == "OptiX") {
46 return device_type_ == DEVICE_OPTIX;
47 }
48#else
49 (void)feature;
50#endif
51
52 return false;
53}
54
55bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
56 OSL::Matrix44 &result,
57 OSL::TransformationPtr /*xform*/,
58 const float time)
59{
60 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
61 if (globals == nullptr || globals->sd == nullptr) {
62 return false;
63 }
65 globals->kg, globals->sd, reinterpret_cast<float *>(&result), time);
66}
67
68bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
69 OSL::Matrix44 &result,
70 OSL::TransformationPtr /*xform*/,
71 const float time)
72{
73 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
74 if (globals == nullptr || globals->sd == nullptr) {
75 return false;
76 }
78 globals->kg, globals->sd, reinterpret_cast<float *>(&result), time);
79}
80
81bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
82 OSL::Matrix44 &result,
83 OSLUStringHash from,
84 const float /*time*/)
85{
86 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
87 return osl_shared_get_named_matrix(globals->kg, from, reinterpret_cast<float *>(&result));
88}
89
90bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
91 OSL::Matrix44 &result,
93 const float /*time*/)
94{
95 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
96 return osl_shared_get_named_inverse_matrix(globals->kg, to, reinterpret_cast<float *>(&result));
97}
98
99bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
100 OSL::Matrix44 &result,
101 OSL::TransformationPtr /*xform*/)
102{
103 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
104 if (globals == nullptr || globals->sd == nullptr) {
105 return false;
106 }
108 globals->kg, globals->sd, reinterpret_cast<float *>(&result));
109}
110
111bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
112 OSL::Matrix44 &result,
113 OSL::TransformationPtr /*xform*/)
114{
115 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
116 if (globals == nullptr || globals->sd == nullptr) {
117 return false;
118 }
120 globals->kg, globals->sd, reinterpret_cast<float *>(&result));
121}
122
123bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg,
124 OSL::Matrix44 &result,
125 OSLUStringHash from)
126{
127 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
128 return osl_shared_get_named_matrix(globals->kg, from, reinterpret_cast<float *>(&result));
129}
130
131bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg,
132 OSL::Matrix44 &result,
134{
135 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
136 return osl_shared_get_named_inverse_matrix(globals->kg, to, reinterpret_cast<float *>(&result));
137}
138
139bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals * /*sg*/,
140 bool /*derivatives*/,
141 OSLUStringHash /*object*/,
142 const TypeDesc /*type*/,
143 OSLUStringHash /*name*/,
144 const int /*index*/,
145 void * /*val*/)
146{
147 return false;
148}
149
151 ShaderData *sd,
152 OSLUStringHash name,
153 const TypeDesc type,
154 bool derivatives,
155 void *val)
156{
158 globals->kg, globals, sd, name, type, derivatives, val);
159}
160
162 ShaderData *sd,
163 OSLUStringHash name,
164 const TypeDesc type,
165 bool derivatives,
166 void *val)
167{
169 globals->kg, globals, sd, name, type, derivatives, val);
170}
171
173 ShaderGlobals *globals, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
174{
175 return osl_shared_get_camera_attribute(globals->kg, globals, name, type, derivatives, val);
176}
177
178bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg,
179 bool derivatives,
180 OSLUStringHash object_name,
181 const TypeDesc type,
182 OSLUStringHash name,
183 void *val)
184{
185 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
186 if (globals == nullptr) {
187 return false;
188 }
189
190 return get_attribute(globals, globals->sd, derivatives, object_name, type, name, val);
191}
192
194 ShaderData *sd,
195 bool derivatives,
196 OSLUStringHash object_name,
197 const TypeDesc type,
198 OSLUStringHash name,
199 void *val)
200{
201
202 if (globals == nullptr) {
203 return false;
204 }
205
206 const ThreadKernelGlobalsCPU *kg = globals->kg;
207 if (sd->shader == SHADER_NONE) {
208 /* Camera shader. */
209 return osl_shared_get_camera_attribute(kg, globals, name, type, derivatives, val);
210 }
211
212 /* lookup of attribute on another object */
213 int object;
214 if (object_name != DeviceStrings::u_empty) {
215 const OSLGlobals::ObjectNameMap::iterator it = kg->osl.globals->object_name_map.find(
216 object_name);
217
218 if (it == kg->osl.globals->object_name_map.end()) {
219 return false;
220 }
221
222 object = it->second;
223 }
224 else {
225 object = sd->object;
226 }
227
228 /* find attribute on object */
229 const AttributeDescriptor desc = find_attribute(kg, object, sd->prim, name.hash());
230 if (is_attribute_found(desc)) {
231 return osl_shared_get_object_attribute(kg, sd, desc, type, derivatives, val);
232 }
233
234 /* not found in attribute, check standard object info */
235 return osl_shared_get_object_standard_attribute(kg, globals, sd, name, type, derivatives, val);
236}
237
238bool OSLRenderServices::get_userdata(bool /*derivatives*/,
239 OSLUStringHash /*name*/,
240 const TypeDesc /*type*/,
241 OSL::ShaderGlobals * /*sg*/,
242 void * /*val*/)
243{
244 return false; /* disabled by lockgeom */
245}
246
247OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(
248 OSLUStringHash filename, OSL::ShadingContext *context, const OSL::TextureOpt *opt)
249{
250 return get_texture_handle(to_ustring(filename), context, opt);
251}
252
253void OSLRenderServices::image_manager_add(const OSL::ShadingContext *context,
254 ImageManager *image_manager)
255{
256 const thread_scoped_lock lock(image_managers_mutex_);
257 image_managers_[context] = image_manager;
258}
259
260void OSLRenderServices::image_manager_remove(const OSL::ShadingContext *context)
261{
262 const thread_scoped_lock lock(image_managers_mutex_);
263 image_managers_.erase(context);
264}
265
266ImageManager *OSLRenderServices::image_manager_find(const OSL::ShadingContext *context)
267{
268 const thread_scoped_lock lock(image_managers_mutex_);
269 auto it = image_managers_.find(context);
270 return (it != image_managers_.end()) ? it->second : nullptr;
271}
272
273OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(
274 OSL::ustring filename, OSL::ShadingContext *context, const OSL::TextureOpt * /*options*/)
275{
276 ImageManager *image_manager = image_manager_find(context);
277 if (image_manager == nullptr) {
278 LOG_WARNING << "Open Shading Language texture call can not resolve " << filename.c_str()
279 << ", filename must be a compile-time constant";
280 return nullptr;
281 }
282
283 /* Note the mutex lock in find_or_insert() is not so bad for performance because
284 * this function only gets called once per texture handle to create it, not for
285 * every texture access. */
286 auto [it, inserted] = textures.find_or_insert({filename, image_manager},
288
289 if (inserted) {
290 /* Add new texture to image manager. */
291 const ImageHandle handle = image_manager->add_image(filename.string(), ImageParams());
292 OSLTextureHandle *texture_handle = const_cast<OSLTextureHandle *>(&it->second);
293 *texture_handle = OSLTextureHandle(handle);
294 }
295
296 /* Construct texture handle. We encode this as a packed integer cast to a pointer,
297 * which is also what we use on the GPU. OSL does not dereference these.
298 *
299 * Note that we must keep the OSLTextureHandle in the map alive, as it holds
300 * the ImageHandle that keeps the image loaded in the manager. */
301 return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(
302 OSL_TEXTURE_HANDLE_ENCODE(it->second.type, it->second.id));
303}
304
305bool OSLRenderServices::good(OSL::TextureSystem::TextureHandle *texture_handle)
306{
307 return OSL_TEXTURE_HANDLE_TYPE(texture_handle) != OSLTextureHandleType::IMAGE ||
308 OSL_TEXTURE_HANDLE_ID(texture_handle) != KERNEL_IMAGE_NONE;
309}
310
311bool OSLRenderServices::is_udim(OSL::TextureSystem::TextureHandle *texture_handle)
312{
313 return OSL_TEXTURE_HANDLE_TYPE(texture_handle) == OSLTextureHandleType::IMAGE &&
314 OSL_TEXTURE_HANDLE_ID(texture_handle) <= -1;
315}
316
318 TextureHandle *texture_handle,
319 TexturePerthread * /*texture_thread_info*/,
320 OSL::TextureOpt &options,
321 OSL::ShaderGlobals *sg,
322 float s,
323 float t,
324 const float dsdx,
325 const float dtdx,
326 const float dsdy,
327 const float dtdy,
328 const int nchannels,
329 float *result,
330 float * /*dresultds*/,
331 float * /*dresultdt*/,
332 OSLUStringHash * /*errormessage*/)
333{
334 if (texture_handle == nullptr) {
335 if (texture_filenames_seen_.insert(filename).second) {
336 LOG_WARNING << "Open Shading Language texture call can not resolve " << filename.c_str()
337 << ", filename must be a compile-time constant";
338 }
339 return false;
340 }
341
342 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
343
344 return osl_shared_texture(globals->kg,
345 globals,
346 texture_handle,
347 reinterpret_cast<OSLTextureOptions *>(&options),
348 s,
349 t,
350 dsdx,
351 dtdx,
352 dsdy,
353 dtdy,
354 nchannels,
355 result);
356}
357
359 TextureHandle *texture_handle,
360 TexturePerthread * /*texture_thread_info*/,
361 OSL::TextureOpt & /*options*/,
362 OSL::ShaderGlobals *sg,
363 const OSL::Vec3 &P,
364 const OSL::Vec3 &dPdx,
365 const OSL::Vec3 &dPdy,
366 const OSL::Vec3 &dPdz,
367 const int nchannels,
368 float *result,
369 float * /*dresultds*/,
370 float * /*dresultdt*/,
371 float * /*dresultdr*/,
372 OSLUStringHash * /*errormessage*/)
373{
374 if (texture_handle == nullptr) {
375 if (texture_filenames_seen_.insert(filename).second) {
376 LOG_WARNING << "Open Shading Language texture3d call can not resolve " << filename.c_str()
377 << ", filename must be a constant";
378 }
379 return false;
380 }
381
382 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
383
384 return osl_shared_texture3d(globals->kg,
385 globals,
386 texture_handle,
387 make_float3(P.x, P.y, P.z),
390 make_float3(dPdz.x, dPdz.y, dPdz.z),
391 nchannels,
392 result);
393}
394
396 TextureHandle *texture_handle,
397 TexturePerthread * /*thread_info*/,
398 OSL::TextureOpt &options,
399 OSL::ShaderGlobals *sg,
400 const OSL::Vec3 &R,
401 const OSL::Vec3 &dRdx,
402 const OSL::Vec3 &dRdy,
403 const int nchannels,
404 float *result,
405 float * /*dresultds*/,
406 float * /*dresultdt*/,
407 OSLUStringHash * /*errormessage*/)
408{
409 if (texture_handle == nullptr) {
410 if (texture_filenames_seen_.insert(filename).second) {
411 LOG_WARNING << "Open Shading Language environment call can not resolve " << filename.c_str()
412 << ", filename must be a constant string after optimization";
413 }
414 return false;
415 }
416
417 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
418
419 return osl_shared_environment(globals->kg,
420 globals,
421 texture_handle,
422 reinterpret_cast<OSLTextureOptions *>(&options),
423 make_float3(R.x, R.y, R.z),
424 make_float3(dRdx.x, dRdx.y, dRdx.z),
425 make_float3(dRdy.x, dRdy.y, dRdy.z),
426 nchannels,
427 result);
428}
429
431 TextureHandle *texture_handle,
432 TexturePerthread * /*texture_thread_info*/,
433 OSL::ShaderGlobals *sg,
434 const int /*subimage*/,
435 OSLUStringHash dataname,
436 const TypeDesc datatype,
437 void *data,
438 OSLUStringHash * /*errormessage*/)
439{
440 if (texture_handle == nullptr) {
441 if (texture_filenames_seen_.insert(filename).second) {
442 LOG_WARNING << "Open Shading Language gettextureinfo call can not resolve "
443 << filename.c_str() << ", filename must be a constant";
444 }
445 return false;
446 }
447
448 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
449 const ThreadKernelGlobalsCPU *kg = globals->kg;
450
452 kg, texture_handle, make_float2(0.0f, 0.0f), false, dataname, datatype, data);
453}
454
456 TextureHandle *texture_handle,
457 float s,
458 float t,
459 TexturePerthread * /*texture_thread_info*/,
460 OSL::ShaderGlobals *sg,
461 const int /*subimage*/,
462 OSLUStringHash dataname,
463 const TypeDesc datatype,
464 void *data,
465 OSLUStringHash * /*errormessage*/)
466{
467 if (texture_handle == nullptr) {
468 if (texture_filenames_seen_.insert(filename).second) {
469 LOG_WARNING << "Open Shading Language gettextureinfo call can not resolve "
470 << filename.c_str() << ", filename must be a constant";
471 }
472 return false;
473 }
474
475 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
476 const ThreadKernelGlobalsCPU *kg = globals->kg;
477
479 kg, texture_handle, make_float2(s, t), true, dataname, datatype, data);
480}
481
482int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals * /*sg*/,
483 OSLUStringHash /*filename*/,
484 const OSL::Vec3 & /*center*/,
485 const float /*radius*/,
486 const int /*max_points*/,
487 bool /*sort*/,
488#if OSL_LIBRARY_VERSION_CODE >= 11400
489 int * /*indices*/,
490#else
491 size_t * /*out_indices*/,
492#endif
493 float * /*out_distances*/,
494 const int /*derivs_offset*/)
495{
496 return 0;
497}
498
499int OSLRenderServices::pointcloud_get(OSL::ShaderGlobals * /*sg*/
500 ,
501 OSLUStringHash /*filename*/,
502#if OSL_LIBRARY_VERSION_CODE >= 11400
503 const int * /*indices*/,
504#else
505 size_t * /*indices*/,
506#endif
507 const int /*count*/,
508 OSLUStringHash /*attr_name*/,
509 const TypeDesc /*attr_type*/,
510 void * /*out_data*/)
511{
512 return 0;
513}
514
515bool OSLRenderServices::pointcloud_write(OSL::ShaderGlobals * /*sg*/,
516 OSLUStringHash /*filename*/,
517 const OSL::Vec3 & /*pos*/,
518 const int /*nattribs*/,
519 const OSLUStringRep * /*names*/,
520 const TypeDesc * /*types*/,
521 const void ** /*data*/)
522{
523 return false;
524}
525
527 OSL::ShaderGlobals *sg,
528 const OSL::Vec3 &P,
529 const OSL::Vec3 &dPdx,
530 const OSL::Vec3 &dPdy,
531 const OSL::Vec3 &R,
532 const OSL::Vec3 &dRdx,
533 const OSL::Vec3 &dRdy)
534{
535 /* todo: options.shader support, maybe options.traceset */
536 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
537 ShaderData *sd = globals->sd;
538 const ThreadKernelGlobalsCPU *kg = globals->kg;
539
540 if (sd == nullptr) {
541 return false;
542 }
543
544 /* setup ray */
545 Ray ray;
546
547 ray.P = make_float3(P.x, P.y, P.z);
548 ray.D = make_float3(R.x, R.y, R.z);
549 ray.tmin = options.mindist;
550 ray.tmax = (options.maxdist == 1.0e30f) ? FLT_MAX : options.maxdist;
551 ray.time = sd->time;
552 ray.self.object = OBJECT_NONE;
553 ray.self.prim = PRIM_NONE;
556
557 if (ray.tmin == 0.0f) {
558 /* avoid self-intersections */
559 if (ray.P == sd->P) {
560 ray.self.object = sd->object;
561 ray.self.prim = sd->prim;
562 }
563 }
564
565 /* ray differentials */
566 differential3 dP;
567 dP.dx = make_float3(dPdx.x, dPdx.y, dPdx.z);
568 dP.dy = make_float3(dPdy.x, dPdy.y, dPdy.z);
569 ray.dP = differential_make_compact(dP);
570 differential3 dD;
571 dD.dx = make_float3(dRdx.x, dRdx.y, dRdx.z);
572 dD.dy = make_float3(dRdy.x, dRdy.y, dRdy.z);
573 ray.dD = differential_make_compact(dD);
574
575 /* allocate trace data */
576 OSLTraceData *tracedata = globals->tracedata;
577 tracedata->ray = ray;
578 tracedata->setup = false;
579 tracedata->init = true;
580 tracedata->hit = false;
581 tracedata->self_hit = false;
582
583 /* Can't ray-trace from shaders like displacement, before BVH exists. */
584 if (kernel_data.bvh.bvh_layout == BVH_LAYOUT_NONE) {
585 return false;
586 }
587
588 if (options.traceset == DeviceStrings::u_traceset_only_local) {
589 LocalIntersection local_isect;
590 scene_intersect_local(kg, &ray, &local_isect, sd->object, nullptr, 1);
591 if (local_isect.num_hits > 0) {
592 tracedata->isect = local_isect.hits[0];
593 tracedata->hit = true;
594 tracedata->self_hit = true;
595 }
596 }
597 else {
598 /* Ray-trace, leaving out shadow opaque to avoid early exit. */
600 if (options.traceset == DeviceStrings::u_traceset_raycast) {
601 visibility = PATH_RAY_VISIBILITY_RAYCAST;
602 }
603 tracedata->hit = scene_intersect(kg, &ray, visibility, &tracedata->isect);
604 if (tracedata->hit) {
605 tracedata->self_hit = tracedata->isect.object == sd->object;
606 }
607 }
608 return tracedata->hit;
609}
610
611bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg,
612 OSLUStringHash source,
613 OSLUStringHash name,
614 const TypeDesc type,
615 void *val,
616 bool derivatives)
617{
618 ShaderGlobals *globals = reinterpret_cast<ShaderGlobals *>(sg);
619 const ThreadKernelGlobalsCPU *kg = globals->kg;
620 OSLTraceData *tracedata = globals->tracedata;
621
622 if (source == DeviceStrings::u_trace && tracedata->init) {
623 if (name == DeviceStrings::u_hit) {
624 return set_attribute<int>(tracedata->hit, type, derivatives, val);
625 }
626 if (tracedata->hit) {
627 if (name == DeviceStrings::u_hitdist) {
628 return set_attribute(tracedata->isect.t, type, derivatives, val);
629 }
630
631 ShaderData *sd = &tracedata->sd;
632
633 if (!tracedata->setup) {
634 /* lazy shader data setup */
635 shader_setup_from_ray(kg, sd, &tracedata->ray, &tracedata->isect);
636 tracedata->setup = true;
637 }
638
639 if (name == DeviceStrings::u_hitself) {
640 return set_attribute(float(tracedata->self_hit), type, derivatives, val);
641 }
642 if (name == DeviceStrings::u_N) {
643 return set_attribute(sd->N, type, derivatives, val);
644 }
645 if (name == DeviceStrings::u_Ng) {
646 return set_attribute(sd->Ng, type, derivatives, val);
647 }
648 if (name == DeviceStrings::u_P) {
649 const differential3 dP = differential_from_compact(sd->Ng, sd->dP);
650 return set_attribute(dual3(sd->P, dP.dx, dP.dy), type, derivatives, val);
651 }
652 if (name == DeviceStrings::u_I) {
653 const differential3 dI = differential_from_compact(sd->wi, sd->dI);
654 return set_attribute(dual3(sd->wi, dI.dx, dI.dy), type, derivatives, val);
655 }
656 if (name == DeviceStrings::u_u) {
657 return set_attribute(dual1(sd->u, sd->du.dx, sd->du.dy), type, derivatives, val);
658 }
659 if (name == DeviceStrings::u_v) {
660 return set_attribute(dual1(sd->v, sd->dv.dx, sd->dv.dy), type, derivatives, val);
661 }
662
663 return get_attribute(globals, sd, derivatives, DeviceStrings::u_empty, type, name, val);
664 }
665 }
666
667 return false;
668}
669
volatile int lock
ImageHandle add_image(const string &filename, const ImageParams &params)
static bool get_background_attribute(ShaderGlobals *globals, ShaderData *sd, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
Definition services.cpp:161
bool get_texture_info(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::ShaderGlobals *sg, const int subimage, OSLUStringHash dataname, const TypeDesc datatype, void *data, OSLUStringHash *errormessage) override
Definition services.cpp:430
bool is_udim(OSL::TextureSystem::TextureHandle *texture_handle) override
Definition services.cpp:311
bool texture(OSLUStringHash filename, OSL::TextureSystem::TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const float s, const float t, const float dsdx, const float dtdx, const float dsdy, const float dtdy, const int nchannels, float *result, float *dresultds, float *dresultdt, OSLUStringHash *errormessage) override
Definition services.cpp:317
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override
Definition services.cpp:68
int pointcloud_search(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 &center, const float radius, const int max_points, bool sort, size_t *out_indices, float *out_distances, int derivs_offset) override
Definition services.cpp:482
~OSLRenderServices() override
int supports(string_view feature) const override
Definition services.cpp:42
static bool get_object_standard_attribute(ShaderGlobals *globals, ShaderData *sd, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
Definition services.cpp:150
static bool get_camera_attribute(ShaderGlobals *globals, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
Definition services.cpp:172
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override
Definition services.cpp:55
OSLRenderServices(const int device_type)
Definition services.cpp:32
int pointcloud_get(OSL::ShaderGlobals *sg, OSLUStringHash filename, size_t *indices, const int count, OSLUStringHash attr_name, const TypeDesc attr_type, void *out_data) override
Definition services.cpp:499
OSLTextureHandleMap textures
Definition services.h:304
bool pointcloud_write(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 &pos, const int nattribs, const OSLUStringRep *names, const TypeDesc *types, const void **data) override
Definition services.cpp:515
bool environment(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const OSL::Vec3 &R, const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, const int nchannels, float *result, float *dresultds, float *dresultdt, OSLUStringHash *errormessage) override
Definition services.cpp:395
bool get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object, const TypeDesc type, OSLUStringHash name, const int index, void *val) override
Definition services.cpp:139
bool get_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object, const TypeDesc type, OSLUStringHash name, void *val) override
Definition services.cpp:178
bool get_userdata(bool derivatives, OSLUStringHash name, const TypeDesc type, OSL::ShaderGlobals *sg, void *val) override
Definition services.cpp:238
bool trace(TraceOpt &options, OSL::ShaderGlobals *sg, const OSL::Vec3 &P, const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy, const OSL::Vec3 &R, const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy) override
Definition services.cpp:526
bool texture3d(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const OSL::Vec3 &P, const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy, const OSL::Vec3 &dPdz, const int nchannels, float *result, float *dresultds, float *dresultdt, float *dresultdr, OSLUStringHash *errormessage) override
Definition services.cpp:358
void image_manager_remove(const OSL::ShadingContext *context)
Definition services.cpp:260
bool getmessage(OSL::ShaderGlobals *sg, OSLUStringHash source, OSLUStringHash name, const TypeDesc type, void *val, bool derivatives) override
Definition services.cpp:611
void image_manager_add(const OSL::ShadingContext *context, ImageManager *image_manager)
Definition services.cpp:253
OSL::TextureSystem::TextureHandle * get_texture_handle(OSL::ustring filename, OSL::ShadingContext *context, const OSL::TextureOpt *options) override
Definition services.cpp:273
bool good(OSL::TextureSystem::TextureHandle *texture_handle) override
Definition services.cpp:305
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
CCL_NAMESPACE_BEGIN struct Options options
#define kernel_data
#define SHADER_NONE
#define PRIM_NONE
#define OBJECT_NONE
#define CCL_NAMESPACE_END
@ DEVICE_OPTIX
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline float differential_make_compact(const float dD)
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
#define FLT_MAX
ccl_device_intersect bool scene_intersect(KernelGlobals kg, const ccl_private Ray *ray, const uint visibility, ccl_private Intersection *isect)
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)
#define OSL_TEXTURE_HANDLE_ENCODE(type, id)
#define OSL_TEXTURE_HANDLE_TYPE(handle)
#define OSL_TEXTURE_HANDLE_ID(handle)
uint32_t PathRayVisibility
@ PATH_RAY_VISIBILITY_ALL
@ PATH_RAY_VISIBILITY_RAYCAST
@ PATH_RAY_VISIBILITY_SHADOW_OPAQUE
@ BVH_LAYOUT_NONE
#define LOG_WARNING
Definition log.h:103
#define R
#define KERNEL_IMAGE_NONE
OSL::ustringhash OSLUStringHash
Definition osl/compat.h:11
OSL::ustringrep OSLUStringRep
Definition osl/compat.h:15
#define make_float2
ccl_device_inline bool osl_shared_get_object_standard_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private ShaderData *sd, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool osl_shared_get_object_inverse_matrix_motion(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res, float time)
ccl_device_inline bool osl_shared_get_named_matrix(KernelGlobals kg, DeviceString from, ccl_private float *res)
ccl_device_inline bool osl_shared_get_object_matrix_motion(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res, float time)
ccl_device bool osl_shared_environment(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, ccl_private OSLTextureOptions *opt, float3 R, float3 dRdx, float3 dRdy, int nchannels, float *result)
ccl_device bool osl_shared_get_texture_info(KernelGlobals kg, ccl_private void *texture_handle, const float2 uv, const bool use_uv, DeviceString dataname, const TypeDesc datatype, void *data)
ccl_device_inline bool osl_shared_get_camera_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool set_attribute(const dual< T > v, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool osl_shared_get_background_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private ShaderData *sd, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool osl_shared_get_object_matrix(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res)
ccl_device bool osl_shared_texture3d(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, float3 P, float3, float3, float3, int nchannels, float *result)
ccl_device_inline bool osl_shared_get_object_attribute(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device bool osl_shared_texture(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, ccl_private OSLTextureOptions *opt, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy, int nchannels, float *result)
ccl_device_inline bool osl_shared_get_named_inverse_matrix(KernelGlobals kg, DeviceString to, ccl_private float *res)
ccl_device_inline bool osl_shared_get_object_inverse_matrix(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res)
ccl_device_inline void shader_setup_from_ray(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, const ccl_private Ray *ccl_restrict ray, const ccl_private Intersection *ccl_restrict isect)
Definition shader_data.h:48
Intersection hits[LOCAL_MAX_HITS]
OSLTextureHandle(const OSLTextureHandleType type, const int id=-1)
Definition services.h:53
float tmax
float tmin
float3 P
float time
RaySelfPrimitives self
float3 D
ccl_private ShaderData * sd
const ThreadKernelGlobalsCPU * kg
ccl_private OSLTraceData * tracedata
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
std::unique_lock< std::mutex > thread_scoped_lock
Definition thread.h:28
dual< float3 > dual3
Definition types_dual.h:106
dual< float > dual1
Definition types_dual.h:104