Blender V5.0
services_gpu.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
2 * SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Adapted code from Open Shading Language. */
7
9
11#include "kernel/geom/curve.h"
13#include "kernel/geom/object.h"
14#include "kernel/geom/point.h"
17
19#include "kernel/util/ies.h"
21
22#include "util/hash.h"
23#include "util/transform.h"
24
25#include "kernel/osl/osl.h"
27
28namespace DeviceStrings {
29
30/* "" */
32/* "common" */
33ccl_device_constant DeviceString u_common = 14645198576927606093ull;
34/* "world" */
35ccl_device_constant DeviceString u_world = 16436542438370751598ull;
36/* "shader" */
38/* "object" */
40/* "NDC" */
41ccl_device_constant DeviceString u_ndc = 5148305047403260775ull;
42/* "screen" */
43ccl_device_constant DeviceString u_screen = 14159088609039777114ull;
44/* "camera" */
45ccl_device_constant DeviceString u_camera = 2159505832145726196ull;
46/* "raster" */
47ccl_device_constant DeviceString u_raster = 7759263238610201778ull;
48/* "colorsystem" */
50/* "object:location" */
52/* "object:color" */
54/* "object:alpha" */
56/* "object:index" */
58/* "object:is_light" */
60/* "geom:bump_map_normal" */
62/* "geom:dupli_generated" */
64/* "geom:dupli_uv" */
66/* "material:index" */
68/* "object:random" */
70/* "particle:index" */
72/* "particle:random" */
74/* "particle:age" */
76/* "particle:lifetime" */
78/* "particle:location" */
80/* "particle:rotation" */
82/* "particle:size" */
84/* "particle:velocity" */
86/* "particle:angular_velocity" */
88/* "geom:numpolyvertices" */
90/* "geom:trianglevertices" */
92/* "geom:polyvertices" */
94/* "geom:name" */
96/* "geom:undisplaced" */
98/* "geom:is_smooth" */
100/* "geom:is_curve" */
102/* "geom:curve_thickness" */
104/* "geom:curve_length" */
106/* "geom:curve_tangent_normal" */
108/* "geom:curve_random" */
110/* "geom:is_point" */
112/* "geom:point_radius" */
114/* "geom:point_position" */
116/* "geom:point_random" */
118/* "geom:normal_map_normal" */
120/* "path:ray_length" */
122/* "path:ray_depth" */
124/* "path:diffuse_depth" */
126/* "path:glossy_depth" */
128/* "path:transparent_depth" */
130/* "path:transmission_depth" */
132/* "path:portal_depth" */
134/* "cam:sensor_size" */
136/* "cam:image_resolution" */
138/* "cam:aperture_aspect_ratio" */
140/* "cam:aperture_size" */
142/* "cam:aperture_position" */
144/* "cam:focal_distance" */
146
147} // namespace DeviceStrings
148
149/* Closure */
150
153 const ccl_private float3 *weight)
154{
155 if (*weight == zero_float3() || !a) {
156 return nullptr;
157 }
158 else if (*weight == one_float3()) {
159 return a;
160 }
161
162 ccl_private uint8_t *closure_pool = sg->closure_pool;
163 /* Align pointer to closure struct requirement */
164 closure_pool = reinterpret_cast<uint8_t *>(
165 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureMul) - 1) &
166 (-alignof(OSLClosureMul)));
167 sg->closure_pool = closure_pool + sizeof(OSLClosureMul);
168
169 ccl_private OSLClosureMul *const closure = reinterpret_cast<ccl_private OSLClosureMul *>(
170 closure_pool);
171 closure->id = OSL_CLOSURE_MUL_ID;
172 closure->weight = *weight;
173 closure->closure = a;
174
175 return closure;
176}
177
180 const float weight)
181{
182 if (weight == 0.0f || !a) {
183 return nullptr;
184 }
185 else if (weight == 1.0f) {
186 return a;
187 }
188
189 ccl_private uint8_t *closure_pool = sg->closure_pool;
190 /* Align pointer to closure struct requirement */
191 closure_pool = reinterpret_cast<uint8_t *>(
192 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureMul) - 1) &
193 (-alignof(OSLClosureMul)));
194 sg->closure_pool = closure_pool + sizeof(OSLClosureMul);
195
196 ccl_private OSLClosureMul *const closure = reinterpret_cast<ccl_private OSLClosureMul *>(
197 closure_pool);
198 closure->id = OSL_CLOSURE_MUL_ID;
199 closure->weight = make_float3(weight, weight, weight);
200 closure->closure = a;
201
202 return closure;
203}
204
208{
209 if (!a) {
210 return b;
211 }
212 if (!b) {
213 return a;
214 }
215
216 ccl_private uint8_t *closure_pool = sg->closure_pool;
217 /* Align pointer to closure struct requirement */
218 closure_pool = reinterpret_cast<uint8_t *>(
219 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureAdd) - 1) &
220 (-alignof(OSLClosureAdd)));
221 sg->closure_pool = closure_pool + sizeof(OSLClosureAdd);
222
223 ccl_private OSLClosureAdd *const closure = reinterpret_cast<ccl_private OSLClosureAdd *>(
224 closure_pool);
225 closure->id = OSL_CLOSURE_ADD_ID;
226 closure->closureA = a;
227 closure->closureB = b;
228
229 return closure;
230}
231
233 ccl_private ShaderGlobals *sg, const int id, const int size)
234{
235 ccl_private uint8_t *closure_pool = sg->closure_pool;
236 /* Align pointer to closure struct requirement */
237 closure_pool = reinterpret_cast<uint8_t *>(
238 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureComponent) - 1) &
239 (-alignof(OSLClosureComponent)));
240 sg->closure_pool = closure_pool + sizeof(OSLClosureComponent) + size;
241
242 ccl_private OSLClosureComponent *const closure =
243 reinterpret_cast<ccl_private OSLClosureComponent *>(closure_pool);
244 closure->id = static_cast<OSLClosureType>(id);
245 closure->weight = one_float3();
246
247 return closure;
248}
249
251 ccl_private ShaderGlobals *sg, const int id, const int size, const ccl_private float3 *weight)
252{
253 ccl_private uint8_t *closure_pool = sg->closure_pool;
254 /* Align pointer to closure struct requirement */
255 closure_pool = reinterpret_cast<uint8_t *>(
256 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureComponent) - 1) &
257 (-alignof(OSLClosureComponent)));
258 sg->closure_pool = closure_pool + sizeof(OSLClosureComponent) + size;
259
260 ccl_private OSLClosureComponent *const closure =
261 reinterpret_cast<ccl_private OSLClosureComponent *>(closure_pool);
262 closure->id = static_cast<OSLClosureType>(id);
263 closure->weight = *weight;
264
265 return closure;
266}
267
268/* Utilities */
269
271
275
279
281 DeviceString filename,
283 void *args)
284{
285}
286
288 const int length,
289 DeviceString symname,
291 DeviceString sourcefile,
292 const int sourceline,
293 DeviceString groupname,
294 const int layer,
295 DeviceString layername,
296 DeviceString shadername)
297{
298 const int result = indexvalue < 0 ? 0 : indexvalue >= length ? length - 1 : indexvalue;
299#if 0
300 if (result != indexvalue) {
301 printf("Index [%d] out of range\n", indexvalue);
302 }
303#endif
304 return result;
305}
306
307/* Matrix Utilities */
308
310{
311 res[0] = tfm.x.x;
312 res[1] = tfm.y.x;
313 res[2] = tfm.z.x;
314 res[3] = 0.0f;
315 res[4] = tfm.x.y;
316 res[5] = tfm.y.y;
317 res[6] = tfm.z.y;
318 res[7] = 0.0f;
319 res[8] = tfm.x.z;
320 res[9] = tfm.y.z;
321 res[10] = tfm.z.z;
322 res[11] = 0.0f;
323 res[12] = tfm.x.w;
324 res[13] = tfm.y.w;
325 res[14] = tfm.z.w;
326 res[15] = 1.0f;
327}
329{
330 res[0] = tfm.x.x;
331 res[1] = tfm.y.x;
332 res[2] = tfm.z.x;
333 res[3] = tfm.w.x;
334 res[4] = tfm.x.y;
335 res[5] = tfm.y.y;
336 res[6] = tfm.z.y;
337 res[7] = tfm.w.y;
338 res[8] = tfm.x.z;
339 res[9] = tfm.y.z;
340 res[10] = tfm.z.z;
341 res[11] = tfm.w.z;
342 res[12] = tfm.x.w;
343 res[13] = tfm.y.w;
344 res[14] = tfm.z.w;
345 res[15] = tfm.w.w;
346}
347
349 ccl_private float *res,
350 DeviceString from)
351{
352 if (from == DeviceStrings::u_common || from == DeviceStrings::u_world) {
354 return true;
355 }
356 if (from == DeviceStrings::u_shader || from == DeviceStrings::u_object) {
357 KernelGlobals kg = nullptr;
358 ccl_private ShaderData *const sd = sg->sd;
359 int object = sd->object;
360
361 if (object != OBJECT_NONE) {
362 const Transform tfm = object_get_transform(kg, sd);
363 copy_matrix(res, tfm);
364 return true;
365 }
366 }
367 else if (from == DeviceStrings::u_ndc) {
368 copy_matrix(res, kernel_data.cam.ndctoworld);
369 return true;
370 }
371 else if (from == DeviceStrings::u_raster) {
372 copy_matrix(res, kernel_data.cam.rastertoworld);
373 return true;
374 }
375 else if (from == DeviceStrings::u_screen) {
376 copy_matrix(res, kernel_data.cam.screentoworld);
377 return true;
378 }
379 else if (from == DeviceStrings::u_camera) {
380 copy_matrix(res, kernel_data.cam.cameratoworld);
381 return true;
382 }
383
384 return false;
385}
386
388 ccl_private float *res,
389 DeviceString to)
390{
393 return true;
394 }
396 KernelGlobals kg = nullptr;
397 ccl_private ShaderData *const sd = sg->sd;
398 int object = sd->object;
399
400 if (object != OBJECT_NONE) {
401 const Transform itfm = object_get_inverse_transform(kg, sd);
402 copy_matrix(res, itfm);
403 return true;
404 }
405 }
406 else if (to == DeviceStrings::u_ndc) {
407 copy_matrix(res, kernel_data.cam.worldtondc);
408 return true;
409 }
410 else if (to == DeviceStrings::u_raster) {
411 copy_matrix(res, kernel_data.cam.worldtoraster);
412 return true;
413 }
414 else if (to == DeviceStrings::u_screen) {
415 copy_matrix(res, kernel_data.cam.worldtoscreen);
416 return true;
417 }
418 else if (to == DeviceStrings::u_camera) {
419 copy_matrix(res, kernel_data.cam.worldtocamera);
420 return true;
421 }
422
423 return false;
424}
425
426/* Attributes */
427
429 const TypeDesc type,
430 bool derivatives,
431 ccl_private void *val)
432{
433 const unsigned char type_basetype = type & 0xFF;
434 const unsigned char type_aggregate = (type >> 8) & 0xFF;
435 const int type_arraylen = type >> 32;
436
437 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
438 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
439 {
440 set_data_float3(make_float3(v), derivatives, val);
441 return true;
442 }
443 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
444 {
445 set_data_float4(make_float4(make_float3(v)), derivatives, val);
446 return true;
447 }
448 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
449 set_data_float(v, derivatives, val);
450 return true;
451 }
452 }
453
454 return false;
455}
457 const TypeDesc type,
458 bool derivatives,
459 ccl_private void *val)
460{
461 const unsigned char type_basetype = type & 0xFF;
462 const unsigned char type_aggregate = (type >> 8) & 0xFF;
463 const int type_arraylen = type >> 32;
464
465 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
466 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
467 {
468 set_data_float3(make_float3(v), derivatives, val);
469 return true;
470 }
471 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
472 {
473 set_data_float4(make_float4(make_float3(v)), derivatives, val);
474 }
475 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
476 set_data_float(average(v), derivatives, val);
477 return true;
478 }
479 }
480
481 return false;
482}
484 const TypeDesc type,
485 bool derivatives,
486 ccl_private void *val)
487{
488 const unsigned char type_basetype = type & 0xFF;
489 const unsigned char type_aggregate = (type >> 8) & 0xFF;
490 const int type_arraylen = type >> 32;
491
492 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
493 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
494 {
495 set_data_float3(v, derivatives, val);
496 return true;
497 }
498 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
499 {
500 set_data_float4(make_float4(v), derivatives, val);
501 return true;
502 }
503 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
504 set_data_float(average(v), derivatives, val);
505 return true;
506 }
507 }
508
509 return false;
510}
512 const TypeDesc type,
513 bool derivatives,
514 ccl_private void *val)
515{
516 const unsigned char type_basetype = type & 0xFF;
517 const unsigned char type_aggregate = (type >> 8) & 0xFF;
518 const int type_arraylen = type >> 32;
519
520 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
521 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
522 {
523 set_data_float3(make_float3(v), derivatives, val);
524 return true;
525 }
526 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
527 {
528 set_data_float4(v, derivatives, val);
529 return true;
530 }
531 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
532 set_data_float(average(make_float3(v)), derivatives, val);
533 return true;
534 }
535 }
536
537 return false;
538}
539
540template<typename T>
542 const TypeDesc type,
543 bool derivatives,
544 ccl_private void *val)
545{
546 return set_attribute(dual<T>(f), type, derivatives, val);
547}
548
550 const TypeDesc type,
551 ccl_private void *val)
552{
553 const unsigned char type_basetype = type & 0xFF;
554 const unsigned char type_aggregate = (type >> 8) & 0xFF;
555
556 if (type_basetype == 11 /* TypeDesc::FLOAT */ && type_aggregate == 16 /* TypeDesc::MATRIX44 */) {
557 copy_matrix(static_cast<ccl_private float *>(val), tfm);
558 return true;
559 }
560
561 return false;
562}
563
565 const TypeDesc type,
566 bool derivatives,
567 ccl_private void *val)
568{
569 ccl_private int *ival = static_cast<ccl_private int *>(val);
570
571 const unsigned char type_basetype = type & 0xFF;
572 const unsigned char type_aggregate = (type >> 8) & 0xFF;
573 const int type_arraylen = type >> 32;
574
575 if ((type_basetype == 7 /* TypeDesc::INT */) && (type_aggregate == 1 /* TypeDesc::SCALAR */) &&
576 type_arraylen == 0)
577 {
578 ival[0] = i;
579
580 if (derivatives) {
581 ival[1] = 0;
582 ival[2] = 0;
583 }
584
585 return true;
586 }
587
588 return false;
589}
590
593 ccl_private ShaderData *sd,
595 const TypeDesc type,
596 bool derivatives,
597 ccl_private void *val)
598{
599 ConstIntegratorState state = (sg->shade_index > 0) ? (sg->shade_index - 1) : -1;
600 ConstIntegratorShadowState shadow_state = (sg->shade_index < 0) ? (-sg->shade_index - 1) : -1;
602 /* Ray Length */
603 float f = sd->ray_length;
604 return set_attribute(f, type, derivatives, val);
605 }
606
607#define READ_PATH_STATE(elem) \
608 ((state != -1) ? INTEGRATOR_STATE(state, path, elem) : \
609 (shadow_state != -1) ? INTEGRATOR_STATE(shadow_state, shadow_path, elem) : \
610 0)
611
613 /* Ray Depth */
614 int f = READ_PATH_STATE(bounce);
615
616 /* Read bounce from different locations depending on if this is a shadow path. For background,
617 * light emission and shadow evaluation from a surface or volume we are effectively one bounce
618 * further. */
619 if (sg->raytype & (PATH_RAY_SHADOW | PATH_RAY_EMISSION)) {
620 f += 1;
621 }
622
623 return set_attribute(f, type, derivatives, val);
624 }
626 /* Diffuse Ray Depth */
627 const int f = READ_PATH_STATE(diffuse_bounce);
628 return set_attribute(f, type, derivatives, val);
629 }
631 /* Glossy Ray Depth */
632 const int f = READ_PATH_STATE(glossy_bounce);
633 return set_attribute(f, type, derivatives, val);
634 }
636 /* Transmission Ray Depth */
637 const int f = READ_PATH_STATE(transmission_bounce);
638 return set_attribute(f, type, derivatives, val);
639 }
641 /* Transparent Ray Depth */
642 const int f = READ_PATH_STATE(transparent_bounce);
643 return set_attribute(f, type, derivatives, val);
644 }
646 /* Portal Ray Depth */
647 const int f = READ_PATH_STATE(portal_bounce);
648 return set_attribute(f, type, derivatives, val);
649 }
650#undef READ_PATH_STATE
651
652 else if (name == DeviceStrings::u_ndc) {
653 /* NDC coordinates with special exception for orthographic projection. */
654 dual3 ndc;
655
656 if ((sg->raytype & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE &&
658 {
659 ndc.val = camera_world_to_ndc(kg, sd, sd->ray_P);
660 }
661 else {
662 ndc.val = camera_world_to_ndc(kg, sd, sd->P);
663
664 if (derivatives) {
665 const differential3 dP = differential_from_compact(sd->Ng, sd->dP);
666 ndc.dx = camera_world_to_ndc(kg, sd, sd->P + dP.dx) - ndc.val;
667 ndc.dy = camera_world_to_ndc(kg, sd, sd->P + dP.dy) - ndc.val;
668 }
669 }
670
671 return set_attribute(ndc, type, derivatives, val);
672 }
673
674 return false;
675}
676
677template<typename T>
679 ccl_private ShaderData *sd,
680 const AttributeDescriptor &desc,
681 const TypeDesc type,
682 bool derivatives,
683 ccl_private void *val)
684{
686#ifdef __VOLUME__
687 if (primitive_is_volume_attribute(sd)) {
688 data.val = primitive_volume_attribute<T>(kg, sd, desc, true);
689 }
690 else
691#endif
692 {
693 data = primitive_surface_attribute<T>(kg, sd, desc, derivatives, derivatives);
694 }
695 return set_attribute(data, type, derivatives, val);
696}
697
699 ccl_private ShaderData *sd,
700 const AttributeDescriptor &desc,
701 const TypeDesc type,
702 bool derivatives,
703 ccl_private void *val)
704{
705 if (desc.type == NODE_ATTR_FLOAT) {
706 return get_object_attribute_impl<float>(kg, sd, desc, type, derivatives, val);
707 }
708 else if (desc.type == NODE_ATTR_FLOAT2) {
709 return get_object_attribute_impl<float2>(kg, sd, desc, type, derivatives, val);
710 }
711 else if (desc.type == NODE_ATTR_FLOAT3) {
712 return get_object_attribute_impl<float3>(kg, sd, desc, type, derivatives, val);
713 }
714 else if (desc.type == NODE_ATTR_FLOAT4 || desc.type == NODE_ATTR_RGBA) {
715 return get_object_attribute_impl<float4>(kg, sd, desc, type, derivatives, val);
716 }
717 else if (desc.type == NODE_ATTR_MATRIX) {
719 return set_attribute_matrix(tfm, type, val);
720 }
721
722 return false;
723}
724
727 ccl_private ShaderData *sd,
729 const TypeDesc type,
730 bool derivatives,
731 ccl_private void *val)
732{
733 /* Object attributes */
735 float3 f = object_location(kg, sd);
736 return set_attribute(f, type, derivatives, val);
737 }
739 float3 f = object_color(kg, sd->object);
740 return set_attribute(f, type, derivatives, val);
741 }
743 float f = object_alpha(kg, sd->object);
744 return set_attribute(f, type, derivatives, val);
745 }
747 float f = object_pass_id(kg, sd->object);
748 return set_attribute(f, type, derivatives, val);
749 }
751 float f = ((sd->type & PRIMITIVE_LAMP) != 0);
752 return set_attribute(f, type, derivatives, val);
753 }
755 float3 f = object_dupli_generated(kg, sd->object);
756 return set_attribute(f, type, derivatives, val);
757 }
759 float3 f = object_dupli_uv(kg, sd->object);
760 return set_attribute(f, type, derivatives, val);
761 }
763 float f = shader_pass_id(kg, sd);
764 return set_attribute(f, type, derivatives, val);
765 }
767 const float f = object_random_number(kg, sd->object);
768
769 return set_attribute(f, type, derivatives, val);
770 }
771
772 /* Particle attributes */
774 int particle_id = object_particle_id(kg, sd->object);
775 float f = particle_index(kg, particle_id);
776 return set_attribute(f, type, derivatives, val);
777 }
779 int particle_id = object_particle_id(kg, sd->object);
780 float f = hash_uint2_to_float(particle_index(kg, particle_id), 0);
781 return set_attribute(f, type, derivatives, val);
782 }
783
785 int particle_id = object_particle_id(kg, sd->object);
786 float f = particle_age(kg, particle_id);
787 return set_attribute(f, type, derivatives, val);
788 }
790 int particle_id = object_particle_id(kg, sd->object);
791 float f = particle_lifetime(kg, particle_id);
792 return set_attribute(f, type, derivatives, val);
793 }
795 int particle_id = object_particle_id(kg, sd->object);
796 float3 f = particle_location(kg, particle_id);
797 return set_attribute(f, type, derivatives, val);
798 }
799#if 0 /* unsupported */
801 int particle_id = object_particle_id(kg, sd->object);
802 float4 f = particle_rotation(kg, particle_id);
803 return set_attribute4(f, type, derivatives, val);
804 }
805#endif
807 int particle_id = object_particle_id(kg, sd->object);
808 float f = particle_size(kg, particle_id);
809 return set_attribute(f, type, derivatives, val);
810 }
812 int particle_id = object_particle_id(kg, sd->object);
813 float3 f = particle_velocity(kg, particle_id);
814 return set_attribute(f, type, derivatives, val);
815 }
817 int particle_id = object_particle_id(kg, sd->object);
818 float3 f = particle_angular_velocity(kg, particle_id);
819 return set_attribute(f, type, derivatives, val);
820 }
821
822 /* Geometry attributes */
823#if 0 /* TODO */
825 return false;
826 }
829 return false;
830 }
831 else if (name == DeviceStrings::u_geom_name) {
832 return false;
833 }
834#endif
835 else if (name == DeviceStrings::u_is_smooth) {
836 float f = ((sd->shader & SHADER_SMOOTH_NORMAL) != 0);
837 return set_attribute(f, type, derivatives, val);
838 }
839
840#ifdef __HAIR__
841 /* Hair attributes */
842 else if (name == DeviceStrings::u_is_curve) {
843 float f = (sd->type & PRIMITIVE_CURVE) != 0;
844 return set_attribute(f, type, derivatives, val);
845 }
847 float f = curve_thickness(kg, sd);
848 return set_attribute(f, type, derivatives, val);
849 }
851 float3 f = curve_tangent_normal(sd);
852 return set_attribute(f, type, derivatives, val);
853 }
855 float f = curve_random(kg, sd);
856 return set_attribute(f, type, derivatives, val);
857 }
858#endif
859
860#ifdef __POINTCLOUD__
861 /* Point attributes */
862 else if (name == DeviceStrings::u_is_point) {
863 float f = (sd->type & PRIMITIVE_POINT) != 0;
864 return set_attribute(f, type, derivatives, val);
865 }
867 float f = point_radius(kg, sd);
868 return set_attribute(f, type, derivatives, val);
869 }
871 float3 f = point_position(kg, sd);
872 return set_attribute(f, type, derivatives, val);
873 }
875 float f = point_random(kg, sd);
876 return set_attribute(f, type, derivatives, val);
877 }
878#endif
879
881 if (sd->type & PRIMITIVE_TRIANGLE) {
883 kg, sd->object, sd->prim, ATTR_STD_NORMAL_UNDISPLACED);
884 if (desc.offset != ATTR_STD_NOT_FOUND) {
885 return get_object_attribute(kg, sd, desc, type, derivatives, val);
886 }
887 float3 f = triangle_smooth_normal_unnormalized(kg, sd, sd->Ng, sd->prim, sd->u, sd->v);
888 return set_attribute(f, type, derivatives, val);
889 }
890 else {
891 return false;
892 }
893 }
895 dual3 f;
896 if (!attribute_bump_map_normal(kg, sd, f)) {
897 return false;
898 }
899 return set_attribute(f, type, derivatives, val);
900 }
901
902 return get_background_attribute(kg, sg, sd, name, type, derivatives, val);
903}
904
906 KernelGlobals kg,
908 TypeDesc type,
909 bool derivatives,
910 ccl_private void *val)
911{
913 const float2 sensor = make_float2(kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight);
914 return set_attribute(sensor, type, derivatives, val);
915 }
917 const float2 image = make_float2(kernel_data.cam.width, kernel_data.cam.height);
918 return set_attribute(image, type, derivatives, val);
919 }
921 return set_attribute(1.0f / kernel_data.cam.inv_aperture_ratio, type, derivatives, val);
922 }
924 return set_attribute(kernel_data.cam.aperturesize, type, derivatives, val);
925 }
927 /* The random numbers for aperture sampling are packed into N. */
928 const float2 rand_lens = make_float2(sg->N.x, sg->N.y);
929 const float2 pos = camera_sample_aperture(&kernel_data.cam, rand_lens);
930 return set_attribute(pos * kernel_data.cam.aperturesize, type, derivatives, val);
931 }
933 return set_attribute(kernel_data.cam.focaldistance, type, derivatives, val);
934 }
935 return false;
936}
937
939 const int derivatives,
940 DeviceString object_name,
942 const int array_lookup,
943 const int index,
944 const TypeDesc type,
945 ccl_private void *res)
946{
947 KernelGlobals kg = nullptr;
948 ccl_private ShaderData *const sd = sg->sd;
949 int object;
950
951 if (sd == nullptr) {
952 /* Camera shader. */
953 return get_camera_attribute(sg, kg, name, type, derivatives, res);
954 }
955
956 if (object_name != DeviceStrings::_emptystring_) {
957 /* TODO: Get object index from name */
958 return false;
959 }
960 else {
961 object = sd->object;
962 }
963
964 const AttributeDescriptor desc = find_attribute(kg, object, sd->prim, name);
965 if (desc.offset != ATTR_STD_NOT_FOUND) {
966 return get_object_attribute(kg, sd, desc, type, derivatives, res);
967 }
968 else {
969 return get_object_standard_attribute(kg, sg, sd, name, type, derivatives, res);
970 }
971}
972
973/* Renderer services */
974
975/* The ABI for these callbacks is different, so DeviceString and TypeDesc don't work here. */
979
981 unsigned char basetype;
982 unsigned char aggregate;
983 unsigned char vecsemantics;
984 unsigned char reserved;
986};
987
989 RSDeviceString name, ccl_private void *data, int data_size, const RSTypeDesc &type, int index)
990{
991 if (type.basetype == 14 /* TypeDesc::PTR */) {
992 kernel_assert(data_size == sizeof(void *));
993 ccl_private void **ptr_data = (ccl_private void **)data;
994
995#ifdef __KERNEL_OPTIX__
997 *ptr_data = kernel_params.osl_colorsystem;
998 return true;
999 }
1000#endif
1001 }
1002 return false;
1003}
1004
1006 RSDeviceString filename,
1007 ccl_private void *texture_handle,
1008 ccl_private void *texture_thread_info,
1010 const float s,
1011 const float t,
1012 const float dsdx,
1013 const float dtdx,
1014 const float dsdy,
1015 const float dtdy,
1016 const int nchannels,
1017 ccl_private float *result,
1018 ccl_private float *dresultds,
1019 ccl_private float *dresultdt,
1020 ccl_private void *errormessage)
1021{
1022 const unsigned int type = OSL_TEXTURE_HANDLE_TYPE(texture_handle);
1023 const unsigned int slot = OSL_TEXTURE_HANDLE_SLOT(texture_handle);
1024
1025 switch (type) {
1027 const float4 rgba = kernel_tex_image_interp(nullptr, slot, s, 1.0f - t);
1028 if (nchannels > 0) {
1029 result[0] = rgba.x;
1030 }
1031 if (nchannels > 1) {
1032 result[1] = rgba.y;
1033 }
1034 if (nchannels > 2) {
1035 result[2] = rgba.z;
1036 }
1037 if (nchannels > 3) {
1038 result[3] = rgba.w;
1039 }
1040 return true;
1041 }
1043 if (nchannels > 0) {
1044 result[0] = kernel_ies_interp(nullptr, slot, s, t);
1045 }
1046 return true;
1047 }
1048 default: {
1049 return false;
1050 }
1051 }
1052}
1053
1055 RSDeviceString filename,
1056 ccl_private void *texture_handle,
1057 ccl_private void *texture_thread_info,
1059 const ccl_private float3 *P,
1060 const ccl_private float3 *dPdx,
1061 const ccl_private float3 *dPdy,
1062 const ccl_private float3 *dPdz,
1063 const int nchannels,
1064 ccl_private float *result,
1065 ccl_private float *dresultds,
1066 ccl_private float *dresultdt,
1067 ccl_private float *dresultdr,
1068 ccl_private void *errormessage)
1069{
1070 const unsigned int type = OSL_TEXTURE_HANDLE_TYPE(texture_handle);
1071 const unsigned int slot = OSL_TEXTURE_HANDLE_SLOT(texture_handle);
1072
1073 switch (type) {
1075 const float4 rgba = kernel_tex_image_interp_3d(
1076 nullptr, sg->sd, slot, *P, INTERPOLATION_NONE, false);
1077 if (nchannels > 0) {
1078 result[0] = rgba.x;
1079 }
1080 if (nchannels > 1) {
1081 result[1] = rgba.y;
1082 }
1083 if (nchannels > 2) {
1084 result[2] = rgba.z;
1085 }
1086 if (nchannels > 3) {
1087 result[3] = rgba.w;
1088 }
1089 return true;
1090 }
1091 default: {
1092 return false;
1093 }
1094 }
1095}
1096
1098 RSDeviceString filename,
1099 ccl_private void *texture_handle,
1100 ccl_private void *texture_thread_info,
1102 const ccl_private float3 *R,
1103 const ccl_private float3 *dRdx,
1104 const ccl_private float3 *dRdy,
1105 const int nchannels,
1106 ccl_private float *result,
1107 ccl_private float *dresultds,
1108 ccl_private float *dresultdt,
1109 ccl_private void *errormessage)
1110{
1111 if (nchannels > 0) {
1112 result[0] = 1.0f;
1113 }
1114 if (nchannels > 1) {
1115 result[1] = 0.0f;
1116 }
1117 if (nchannels > 2) {
1118 result[2] = 1.0f;
1119 }
1120 if (nchannels > 3) {
1121 result[3] = 1.0f;
1122 }
1123
1124 return false;
1125}
1126
1128 RSDeviceString filename,
1129 ccl_private void *texture_handle,
1130 ccl_private void *texture_thread_info,
1131 int subimage,
1132 RSDeviceString dataname,
1133 RSTypeDesc datatype,
1134 ccl_private void *data,
1135 ccl_private void *errormessage)
1136{
1137 return 0;
1138}
1139
1141 RSDeviceString filename,
1142 ccl_private void *texture_handle,
1143 const float s,
1144 const float t,
1145 ccl_private void *texture_thread_info,
1146 int subimage,
1147 RSDeviceString dataname,
1148 RSTypeDesc datatype,
1149 ccl_private void *data,
1150 ccl_private void *errormessage)
1151{
1152 return 0;
1153}
1154
1156 RSDeviceString filename,
1157 const ccl_private float3 *center,
1158 float radius,
1159 int max_points,
1160 bool sort,
1161 ccl_private int *out_indices,
1162 ccl_private float *out_distances,
1163 int derivs_offset)
1164{
1165 return 0;
1166}
1167
1169 RSDeviceString filename,
1170 const ccl_private int *indices,
1171 int count,
1172 RSDeviceString attr_name,
1173 RSTypeDesc attr_type,
1174 ccl_private void *out_data)
1175{
1176 return 0;
1177}
1178
1180 RSDeviceString filename,
1181 const ccl_private float3 *pos,
1182 int nattribs,
1183 const ccl_private DeviceString *names,
1185 const ccl_private void **data)
1186{
1187 return false;
1188}
1189
1191 ccl_private void *options,
1192 const ccl_private float3 *P,
1193 const ccl_private float3 *dPdx,
1194 const ccl_private float3 *dPdy,
1195 const ccl_private float3 *R,
1196 const ccl_private float3 *dRdx,
1197 const ccl_private float3 *dRdy)
1198{
1199 return false;
1200}
1201
1204 RSTypeDesc type,
1205 ccl_private void *data,
1206 bool derivatives)
1207{
1208 return false;
1209}
1210
1211/* These osl_ functions are supposed to be implemented by OSL itself, but they are not yet.
1212 * See: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1951
1213 * So we have to keep them around for now.
1214 *
1215 * The 1.14.4 based beta used for Blender 4.5 does not need them though, so we check the
1216 * version for that. */
1217#if (OSL_LIBRARY_VERSION_CODE >= 11405) || (OSL_LIBRARY_VERSION_CODE < 11403)
1219 const int firstchannel)
1220{
1221}
1222
1224{
1225 return 0;
1226}
1227
1232
1237
1242
1247
1251
1255
1259
1263
1265 const float width)
1266{
1267}
1268
1270 const float width)
1271{
1272}
1273
1275 const float width)
1276{
1277}
1278
1280 const float width)
1281{
1282}
1283
1287
1291
1296
1298 const int subimage)
1299{
1300}
1301
1306
1311
1313 const int nchannels,
1314 const float alpha)
1315{
1316}
1317
1319
1321
1323
1325
1327#endif
unsigned int uint
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static DBVT_INLINE btDbvtNode * sort(btDbvtNode *n, btDbvtNode *&r)
Definition btDbvt.cpp:418
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y)
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
ccl_device_inline ProjectionTransform projection_identity()
CCL_NAMESPACE_BEGIN struct Options options
#define kernel_assert(cond)
#define kernel_data
#define ccl_device_forceinline
#define OBJECT_NONE
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define ccl_device_extern
#define ccl_device_template_spec
#define ccl_device_constant
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
ccl_device_inline float3 triangle_smooth_normal_unnormalized(KernelGlobals kg, const ccl_private ShaderData *sd, const float3 Ng, const int prim, const float u, float v)
static ushort indices[]
uint pos
#define printf(...)
float length(VecOp< float, D >) RET
ccl_device_inline float hash_uint2_to_float(const uint kx, const uint ky)
Definition hash.h:197
int count
CCL_NAMESPACE_BEGIN ccl_device float2 camera_sample_aperture(ccl_constant KernelCamera *cam, const float2 rand)
ccl_device_inline float3 camera_world_to_ndc(KernelGlobals kg, ccl_private ShaderData *sd, float3 P)
ccl_device Transform primitive_attribute_matrix(KernelGlobals kg, const AttributeDescriptor desc)
ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, const int object)
ccl_device_inline int object_particle_id(KernelGlobals kg, const int object)
ccl_device int shader_pass_id(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline Transform object_get_inverse_transform(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device float4 particle_rotation(KernelGlobals kg, const int particle)
ccl_device float3 particle_location(KernelGlobals kg, const int particle)
ccl_device float particle_lifetime(KernelGlobals kg, const int particle)
ccl_device float particle_age(KernelGlobals kg, const int particle)
ccl_device_inline uint particle_index(KernelGlobals kg, const int particle)
ccl_device_inline float3 object_color(KernelGlobals kg, const int object)
ccl_device_inline Transform object_get_transform(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device float3 particle_velocity(KernelGlobals kg, const int particle)
ccl_device_inline float object_alpha(KernelGlobals kg, const int object)
ccl_device float3 particle_angular_velocity(KernelGlobals kg, const int particle)
ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, const int object)
ccl_device_inline float object_pass_id(KernelGlobals kg, const int object)
ccl_device float particle_size(KernelGlobals kg, const int particle)
ccl_device_inline float3 object_location(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline float object_random_number(KernelGlobals kg, const int object)
#define OSL_TEXTURE_HANDLE_SLOT(handle)
#define OSL_TEXTURE_HANDLE_TYPE(handle)
#define OSL_TEXTURE_HANDLE_TYPE_SVM
#define OSL_TEXTURE_HANDLE_TYPE_IES
OSLClosureType
@ OSL_CLOSURE_MUL_ID
@ OSL_CLOSURE_ADD_ID
const char * DeviceString
@ NODE_ATTR_FLOAT
@ NODE_ATTR_FLOAT3
@ NODE_ATTR_RGBA
@ NODE_ATTR_FLOAT2
@ NODE_ATTR_FLOAT4
@ NODE_ATTR_MATRIX
@ PRIMITIVE_LAMP
@ PRIMITIVE_CURVE
@ PRIMITIVE_TRIANGLE
@ PRIMITIVE_POINT
@ ATTR_STD_NOT_FOUND
@ ATTR_STD_NORMAL_UNDISPLACED
@ PATH_RAY_SHADOW
@ PATH_RAY_EMISSION
@ PATH_RAY_CAMERA
@ SHADER_SMOOTH_NORMAL
@ CAMERA_ORTHOGRAPHIC
ccl_device_inline float kernel_ies_interp(KernelGlobals kg, const int slot, const float h_angle, const float v_angle)
format
static char ** types
Definition makesdna.cc:71
ccl_device_inline float3 one_float3()
Definition math_float3.h:26
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
static ulong state[N]
#define T
#define R
ccl_device_constant DeviceString u_particle_rotation
ccl_device_constant DeviceString u_point_position
ccl_device_constant DeviceString u_path_transparent_depth
ccl_device_constant DeviceString u_object_color
ccl_device_constant DeviceString u_is_point
ccl_device_constant DeviceString u_particle_lifetime
ccl_device_constant DeviceString u_geom_numpolyvertices
ccl_device_constant DeviceString u_sensor_size
ccl_device_constant DeviceString u_is_curve
ccl_device_constant DeviceString u_material_index
ccl_device_constant DeviceString u_aperture_size
ccl_device_constant DeviceString u_point_radius
ccl_device_constant DeviceString u_aperture_position
ccl_device_constant DeviceString u_particle_location
ccl_device_constant DeviceString u_object_is_light
ccl_device_constant DeviceString u_path_ray_length
ccl_device_constant DeviceString u_path_diffuse_depth
ccl_device_constant DeviceString u_path_transmission_depth
ccl_device_constant DeviceString u_geom_dupli_uv
ccl_device_constant DeviceString u_colorsystem
ccl_device_constant DeviceString u_aperture_aspect_ratio
ccl_device_constant DeviceString u_object_location
ccl_device_constant DeviceString u_focal_distance
ccl_device_constant DeviceString u_particle_age
ccl_device_constant DeviceString u_screen
ccl_device_constant DeviceString u_path_portal_depth
ccl_device_constant DeviceString _emptystring_
ccl_device_constant DeviceString u_is_smooth
ccl_device_constant DeviceString u_normal_map_normal
ccl_device_constant DeviceString u_path_ray_depth
ccl_device_constant DeviceString u_path_glossy_depth
ccl_device_constant DeviceString u_world
ccl_device_constant DeviceString u_object_alpha
ccl_device_constant DeviceString u_object
ccl_device_constant DeviceString u_particle_velocity
ccl_device_constant DeviceString u_raster
ccl_device_constant DeviceString u_image_resolution
ccl_device_constant DeviceString u_common
ccl_device_constant DeviceString u_camera
ccl_device_constant DeviceString u_curve_length
ccl_device_constant DeviceString u_particle_index
ccl_device_constant DeviceString u_particle_size
ccl_device_constant DeviceString u_bump_map_normal
ccl_device_constant DeviceString u_point_random
ccl_device_constant DeviceString u_geom_dupli_generated
ccl_device_constant DeviceString u_particle_angular_velocity
ccl_device_constant DeviceString u_shader
ccl_device_constant DeviceString u_object_random
ccl_device_constant DeviceString u_ndc
ccl_device_constant DeviceString u_object_index
ccl_device_constant DeviceString u_curve_tangent_normal
ccl_device_constant DeviceString u_geom_polyvertices
ccl_device_constant DeviceString u_geom_name
ccl_device_constant DeviceString u_curve_thickness
ccl_device_constant DeviceString u_particle_random
ccl_device_constant DeviceString u_geom_undisplaced
ccl_device_constant DeviceString u_curve_random
ccl_device_constant DeviceString u_geom_trianglevertices
float average(point a)
Definition node_math.h:144
CCL_NAMESPACE_BEGIN ccl_device_forceinline dual< T > primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc, const bool dx=false, const bool dy=false)
Definition primitive.h:32
const char * name
#define make_float2
#define make_float4
ccl_device_extern bool osl_get_attribute(ccl_private ShaderGlobals *sg, const int derivatives, DeviceString object_name, DeviceString name, const int array_lookup, const int index, const TypeDesc type, ccl_private void *res)
ccl_device_forceinline void copy_matrix(ccl_private float *res, const Transform &tfm)
ccl_device_extern bool rs_environment(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const ccl_private float3 *R, const ccl_private float3 *dRdx, const ccl_private float3 *dRdy, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private void *errormessage)
ccl_device_extern int rs_pointcloud_get(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private int *indices, int count, RSDeviceString attr_name, RSTypeDesc attr_type, ccl_private void *out_data)
ccl_device_extern void osl_trace_set_shade(ccl_private void *opt, int x)
ccl_device_extern ccl_private OSLClosure * osl_allocate_closure_component(ccl_private ShaderGlobals *sg, const int id, const int size)
ccl_device_extern void osl_texture_set_sblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern ccl_private OSLClosure * osl_add_closure_closure(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, ccl_private OSLClosure *b)
ccl_device_extern void osl_texture_set_time(ccl_private OSLTextureOptions *opt, const float time)
ccl_device_extern void osl_texture_set_stblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern int rs_pointcloud_search(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private float3 *center, float radius, int max_points, bool sort, ccl_private int *out_indices, ccl_private float *out_distances, int derivs_offset)
ccl_device_extern void osl_texture_set_fill(ccl_private OSLTextureOptions *opt, const float fill)
ccl_device_extern bool rs_trace(ccl_private ShaderGlobals *sg, ccl_private void *options, const ccl_private float3 *P, const ccl_private float3 *dPdx, const ccl_private float3 *dPdy, const ccl_private float3 *R, const ccl_private float3 *dRdx, const ccl_private float3 *dRdy)
ccl_device_extern void osl_fprintf(ccl_private ShaderGlobals *sg, DeviceString filename, DeviceString format, void *args)
ccl_device_inline bool get_object_attribute_impl(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern bool rs_texture3d(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const ccl_private float3 *P, const ccl_private float3 *dPdx, const ccl_private float3 *dPdy, const ccl_private float3 *dPdz, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private float *dresultdr, ccl_private void *errormessage)
ccl_device_extern bool rs_texture(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const float s, const float t, const float dsdx, const float dtdx, const float dsdy, const float dtdy, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private void *errormessage)
ccl_device_extern void osl_texture_set_swidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_extern void osl_trace_set_maxdist(ccl_private void *opt, float x)
ccl_device_extern void osl_texture_set_interp_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern bool rs_trace_get(ccl_private ShaderGlobals *sg, RSDeviceString name, RSTypeDesc type, ccl_private void *data, bool derivatives)
ccl_device_extern void osl_texture_set_twidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_template_spec bool set_attribute(const dual1 v, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool 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_extern void osl_texture_set_rwrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern bool rs_pointcloud_write(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private float3 *pos, int nattribs, const ccl_private DeviceString *names, const ccl_private RSTypeDesc *types, const ccl_private void **data)
ccl_device_extern bool osl_get_inverse_matrix(ccl_private ShaderGlobals *sg, ccl_private float *res, DeviceString to)
ccl_device_extern void osl_texture_set_subimagename(ccl_private OSLTextureOptions *opt, DeviceString subimagename_)
ccl_device_extern void osl_warning(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_swrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_inline bool get_object_attribute(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern void osl_init_trace_options(ccl_private void *oec, ccl_private void *opt)
ccl_device_extern void osl_texture_set_stwrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern void osl_trace_set_mindist(ccl_private void *opt, float x)
ccl_device_inline bool set_attribute_matrix(const ccl_private Transform &tfm, const TypeDesc type, ccl_private void *val)
ccl_device_extern uint osl_range_check_err(const int indexvalue, const int length, DeviceString symname, ccl_private ShaderGlobals *sg, DeviceString sourcefile, const int sourceline, DeviceString groupname, const int layer, DeviceString layername, DeviceString shadername)
ccl_device_inline bool get_camera_attribute(ccl_private ShaderGlobals *sg, KernelGlobals kg, DeviceString name, TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern void osl_texture_set_missingcolor_arena(ccl_private OSLTextureOptions *opt, ccl_private float3 *color)
ccl_device_extern void osl_trace_set_traceset(ccl_private void *opt, const DeviceString x)
ccl_device_extern void osl_texture_set_twrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern void osl_texture_set_tblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern ccl_private OSLClosure * osl_allocate_weighted_closure_component(ccl_private ShaderGlobals *sg, const int id, const int size, const ccl_private float3 *weight)
ccl_device_extern ccl_private OSLClosure * osl_mul_closure_float(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, const float weight)
ccl_device_extern void osl_texture_set_firstchannel(ccl_private OSLTextureOptions *opt, const int firstchannel)
ccl_device_extern void osl_texture_set_stwidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_inline bool 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)
#define READ_PATH_STATE(elem)
ccl_device_extern void osl_printf(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_missingcolor_alpha(ccl_private OSLTextureOptions *opt, const int nchannels, const float alpha)
ccl_device_extern bool rs_get_texture_info(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, int subimage, RSDeviceString dataname, RSTypeDesc datatype, ccl_private void *data, ccl_private void *errormessage)
ccl_device_extern int osl_texture_decode_wrapmode(DeviceString name_)
ccl_device_extern void osl_texture_set_rwidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_extern ccl_private OSLClosure * osl_mul_closure_color(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, const ccl_private float3 *weight)
ccl_device_extern void osl_texture_set_rblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern bool osl_get_matrix(ccl_private ShaderGlobals *sg, ccl_private float *res, DeviceString from)
ccl_device_extern void osl_error(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_subimage(ccl_private OSLTextureOptions *opt, const int subimage)
ccl_device_extern bool rend_get_userdata(RSDeviceString name, ccl_private void *data, int data_size, const RSTypeDesc &type, int index)
ccl_device_extern bool rs_get_texture_info_st(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, const float s, const float t, ccl_private void *texture_thread_info, int subimage, RSDeviceString dataname, RSTypeDesc datatype, ccl_private void *data, ccl_private void *errormessage)
ccl_device_inline void set_data_float3(const dual3 data, bool derivatives, ccl_private void *val)
ccl_device bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private dual3 &f)
ccl_device_inline void set_data_float4(const dual4 data, bool derivatives, ccl_private void *val)
ccl_device_inline void set_data_float(const dual1 data, bool derivatives, ccl_private void *val)
const IntegratorShadowStateCPU * ConstIntegratorShadowState
Definition state.h:231
const IntegratorStateCPU * ConstIntegratorState
Definition state.h:229
static bool find_attribute(const std::string &attributes, const char *search_attribute)
NodeAttributeType type
DeviceString val
unsigned char reserved
unsigned char aggregate
unsigned char vecsemantics
unsigned char basetype
float4 y
Definition transform.h:23
float4 x
Definition transform.h:23
float4 z
Definition transform.h:23
float y
Definition sky_math.h:225
float z
Definition sky_math.h:225
float x
Definition sky_math.h:225
float w
Definition sky_math.h:225
i
Definition text_draw.cc:230
@ INTERPOLATION_NONE
Definition texture.h:23
dual< float4 > dual4
Definition types_dual.h:59
dual< float3 > dual3
Definition types_dual.h:58
dual< float2 > dual2
Definition types_dual.h:57
dual< float > dual1
Definition types_dual.h:56