Blender V4.5
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"
20
21#include "util/hash.h"
22#include "util/transform.h"
23
24#include "kernel/osl/osl.h"
26
27namespace DeviceStrings {
28
29/* "" */
31/* "common" */
32ccl_device_constant DeviceString u_common = 14645198576927606093ull;
33/* "world" */
34ccl_device_constant DeviceString u_world = 16436542438370751598ull;
35/* "shader" */
37/* "object" */
39/* "NDC" */
40ccl_device_constant DeviceString u_ndc = 5148305047403260775ull;
41/* "screen" */
42ccl_device_constant DeviceString u_screen = 14159088609039777114ull;
43/* "camera" */
44ccl_device_constant DeviceString u_camera = 2159505832145726196ull;
45/* "raster" */
46ccl_device_constant DeviceString u_raster = 7759263238610201778ull;
47/* "colorsystem" */
49/* "object:location" */
51/* "object:color" */
53/* "object:alpha" */
55/* "object:index" */
57/* "object:is_light" */
59/* "geom:bump_map_normal" */
61/* "geom:dupli_generated" */
63/* "geom:dupli_uv" */
65/* "material:index" */
67/* "object:random" */
69/* "particle:index" */
71/* "particle:random" */
73/* "particle:age" */
75/* "particle:lifetime" */
77/* "particle:location" */
79/* "particle:rotation" */
81/* "particle:size" */
83/* "particle:velocity" */
85/* "particle:angular_velocity" */
87/* "geom:numpolyvertices" */
89/* "geom:trianglevertices" */
91/* "geom:polyvertices" */
93/* "geom:name" */
95/* "geom:undisplaced" */
97/* "geom:is_smooth" */
99/* "geom:is_curve" */
101/* "geom:curve_thickness" */
103/* "geom:curve_length" */
105/* "geom:curve_tangent_normal" */
107/* "geom:curve_random" */
109/* "geom:is_point" */
111/* "geom:point_radius" */
113/* "geom:point_position" */
115/* "geom:point_random" */
117/* "geom:normal_map_normal" */
119/* "path:ray_length" */
121/* "path:ray_depth" */
123/* "path:diffuse_depth" */
125/* "path:glossy_depth" */
127/* "path:transparent_depth" */
129/* "path:transmission_depth" */
131/* "cam:sensor_size" */
133/* "cam:image_resolution" */
135/* "cam:aperture_aspect_ratio" */
137/* "cam:aperture_size" */
139/* "cam:aperture_position" */
141/* "cam:focal_distance" */
143
144} // namespace DeviceStrings
145
146/* Closure */
147
150 const ccl_private float3 *weight)
151{
152 if (*weight == zero_float3() || !a) {
153 return nullptr;
154 }
155 else if (*weight == one_float3()) {
156 return a;
157 }
158
159 ccl_private uint8_t *closure_pool = sg->closure_pool;
160 /* Align pointer to closure struct requirement */
161 closure_pool = reinterpret_cast<uint8_t *>(
162 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureMul) - 1) &
163 (-alignof(OSLClosureMul)));
164 sg->closure_pool = closure_pool + sizeof(OSLClosureMul);
165
166 ccl_private OSLClosureMul *const closure = reinterpret_cast<ccl_private OSLClosureMul *>(
167 closure_pool);
168 closure->id = OSL_CLOSURE_MUL_ID;
169 closure->weight = *weight;
170 closure->closure = a;
171
172 return closure;
173}
174
177 const float weight)
178{
179 if (weight == 0.0f || !a) {
180 return nullptr;
181 }
182 else if (weight == 1.0f) {
183 return a;
184 }
185
186 ccl_private uint8_t *closure_pool = sg->closure_pool;
187 /* Align pointer to closure struct requirement */
188 closure_pool = reinterpret_cast<uint8_t *>(
189 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureMul) - 1) &
190 (-alignof(OSLClosureMul)));
191 sg->closure_pool = closure_pool + sizeof(OSLClosureMul);
192
193 ccl_private OSLClosureMul *const closure = reinterpret_cast<ccl_private OSLClosureMul *>(
194 closure_pool);
195 closure->id = OSL_CLOSURE_MUL_ID;
196 closure->weight = make_float3(weight, weight, weight);
197 closure->closure = a;
198
199 return closure;
200}
201
205{
206 if (!a) {
207 return b;
208 }
209 if (!b) {
210 return a;
211 }
212
213 ccl_private uint8_t *closure_pool = sg->closure_pool;
214 /* Align pointer to closure struct requirement */
215 closure_pool = reinterpret_cast<uint8_t *>(
216 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureAdd) - 1) &
217 (-alignof(OSLClosureAdd)));
218 sg->closure_pool = closure_pool + sizeof(OSLClosureAdd);
219
220 ccl_private OSLClosureAdd *const closure = reinterpret_cast<ccl_private OSLClosureAdd *>(
221 closure_pool);
222 closure->id = OSL_CLOSURE_ADD_ID;
223 closure->closureA = a;
224 closure->closureB = b;
225
226 return closure;
227}
228
230 ccl_private ShaderGlobals *sg, const int id, const int size)
231{
232 ccl_private uint8_t *closure_pool = sg->closure_pool;
233 /* Align pointer to closure struct requirement */
234 closure_pool = reinterpret_cast<uint8_t *>(
235 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureComponent) - 1) &
236 (-alignof(OSLClosureComponent)));
237 sg->closure_pool = closure_pool + sizeof(OSLClosureComponent) + size;
238
239 ccl_private OSLClosureComponent *const closure =
240 reinterpret_cast<ccl_private OSLClosureComponent *>(closure_pool);
241 closure->id = static_cast<OSLClosureType>(id);
242 closure->weight = one_float3();
243
244 return closure;
245}
246
248 ccl_private ShaderGlobals *sg, const int id, const int size, const ccl_private float3 *weight)
249{
250 ccl_private uint8_t *closure_pool = sg->closure_pool;
251 /* Align pointer to closure struct requirement */
252 closure_pool = reinterpret_cast<uint8_t *>(
253 (reinterpret_cast<size_t>(closure_pool) + alignof(OSLClosureComponent) - 1) &
254 (-alignof(OSLClosureComponent)));
255 sg->closure_pool = closure_pool + sizeof(OSLClosureComponent) + size;
256
257 ccl_private OSLClosureComponent *const closure =
258 reinterpret_cast<ccl_private OSLClosureComponent *>(closure_pool);
259 closure->id = static_cast<OSLClosureType>(id);
260 closure->weight = *weight;
261
262 return closure;
263}
264
265/* Utilities */
266
268
272
276
278 DeviceString filename,
280 void *args)
281{
282}
283
285 const int length,
286 DeviceString symname,
288 DeviceString sourcefile,
289 const int sourceline,
290 DeviceString groupname,
291 const int layer,
292 DeviceString layername,
293 DeviceString shadername)
294{
295 const int result = indexvalue < 0 ? 0 : indexvalue >= length ? length - 1 : indexvalue;
296#if 0
297 if (result != indexvalue) {
298 printf("Index [%d] out of range\n", indexvalue);
299 }
300#endif
301 return result;
302}
303
304/* Matrix Utilities */
305
307{
308 res[0] = tfm.x.x;
309 res[1] = tfm.y.x;
310 res[2] = tfm.z.x;
311 res[3] = 0.0f;
312 res[4] = tfm.x.y;
313 res[5] = tfm.y.y;
314 res[6] = tfm.z.y;
315 res[7] = 0.0f;
316 res[8] = tfm.x.z;
317 res[9] = tfm.y.z;
318 res[10] = tfm.z.z;
319 res[11] = 0.0f;
320 res[12] = tfm.x.w;
321 res[13] = tfm.y.w;
322 res[14] = tfm.z.w;
323 res[15] = 1.0f;
324}
326{
327 res[0] = tfm.x.x;
328 res[1] = tfm.y.x;
329 res[2] = tfm.z.x;
330 res[3] = tfm.w.x;
331 res[4] = tfm.x.y;
332 res[5] = tfm.y.y;
333 res[6] = tfm.z.y;
334 res[7] = tfm.w.y;
335 res[8] = tfm.x.z;
336 res[9] = tfm.y.z;
337 res[10] = tfm.z.z;
338 res[11] = tfm.w.z;
339 res[12] = tfm.x.w;
340 res[13] = tfm.y.w;
341 res[14] = tfm.z.w;
342 res[15] = tfm.w.w;
343}
344
346 ccl_private float *res,
347 DeviceString from)
348{
349 if (from == DeviceStrings::u_common || from == DeviceStrings::u_world) {
351 return true;
352 }
353 if (from == DeviceStrings::u_shader || from == DeviceStrings::u_object) {
354 KernelGlobals kg = nullptr;
355 ccl_private ShaderData *const sd = sg->sd;
356 int object = sd->object;
357
358 if (object != OBJECT_NONE) {
359 const Transform tfm = object_get_transform(kg, sd);
360 copy_matrix(res, tfm);
361 return true;
362 }
363 }
364 else if (from == DeviceStrings::u_ndc) {
365 copy_matrix(res, kernel_data.cam.ndctoworld);
366 return true;
367 }
368 else if (from == DeviceStrings::u_raster) {
369 copy_matrix(res, kernel_data.cam.rastertoworld);
370 return true;
371 }
372 else if (from == DeviceStrings::u_screen) {
373 copy_matrix(res, kernel_data.cam.screentoworld);
374 return true;
375 }
376 else if (from == DeviceStrings::u_camera) {
377 copy_matrix(res, kernel_data.cam.cameratoworld);
378 return true;
379 }
380
381 return false;
382}
383
385 ccl_private float *res,
386 DeviceString to)
387{
390 return true;
391 }
393 KernelGlobals kg = nullptr;
394 ccl_private ShaderData *const sd = sg->sd;
395 int object = sd->object;
396
397 if (object != OBJECT_NONE) {
398 const Transform itfm = object_get_inverse_transform(kg, sd);
399 copy_matrix(res, itfm);
400 return true;
401 }
402 }
403 else if (to == DeviceStrings::u_ndc) {
404 copy_matrix(res, kernel_data.cam.worldtondc);
405 return true;
406 }
407 else if (to == DeviceStrings::u_raster) {
408 copy_matrix(res, kernel_data.cam.worldtoraster);
409 return true;
410 }
411 else if (to == DeviceStrings::u_screen) {
412 copy_matrix(res, kernel_data.cam.worldtoscreen);
413 return true;
414 }
415 else if (to == DeviceStrings::u_camera) {
416 copy_matrix(res, kernel_data.cam.worldtocamera);
417 return true;
418 }
419
420 return false;
421}
422
423/* Attributes */
424
425typedef long long TypeDesc;
426
427template<typename T>
429 const T dx,
430 const T dy,
431 const TypeDesc type,
432 bool derivatives,
433 ccl_private void *val);
434
436 const float v, const float dx, const float dy, bool derivatives, ccl_private void *val)
437{
438 ccl_private float *fval = static_cast<ccl_private float *>(val);
439 fval[0] = v;
440 if (derivatives) {
441 fval[1] = dx;
442 fval[2] = dy;
443 }
444}
445
447 const float3 v, const float3 dx, const float3 dy, bool derivatives, ccl_private void *val)
448{
449 ccl_private float *fval = static_cast<ccl_private float *>(val);
450 fval[0] = v.x;
451 fval[1] = v.y;
452 fval[2] = v.z;
453 if (derivatives) {
454 fval[3] = dx.x;
455 fval[4] = dx.y;
456 fval[5] = dx.z;
457 fval[6] = dy.x;
458 fval[7] = dy.y;
459 fval[8] = dy.z;
460 }
461}
462
464 const float4 v, const float4 dx, const float4 dy, bool derivatives, ccl_private void *val)
465{
466 ccl_private float *fval = static_cast<ccl_private float *>(val);
467 fval[0] = v.x;
468 fval[1] = v.y;
469 fval[2] = v.z;
470 fval[3] = v.w;
471 if (derivatives) {
472 fval[4] = dx.x;
473 fval[5] = dx.y;
474 fval[6] = dx.z;
475 fval[7] = dx.w;
476 fval[8] = dy.x;
477 fval[9] = dy.y;
478 fval[10] = dy.z;
479 fval[11] = dy.w;
480 }
481}
482
484 const float dx,
485 const float dy,
486 const TypeDesc type,
487 bool derivatives,
488 ccl_private void *val)
489{
490 const unsigned char type_basetype = type & 0xFF;
491 const unsigned char type_aggregate = (type >> 8) & 0xFF;
492 const int type_arraylen = type >> 32;
493
494 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
495 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
496 {
497 set_data_float3(make_float3(v), make_float3(dx), make_float3(dy), derivatives, val);
498 return true;
499 }
500 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
501 {
503 make_float4(dx, dx, dx, 0.0f),
504 make_float4(dy, dy, dy, 0.0f),
505 derivatives,
506 val);
507 return true;
508 }
509 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
510 set_data_float(v, dx, dy, derivatives, val);
511 return true;
512 }
513 }
514
515 return false;
516}
518 const float2 dx,
519 const float2 dy,
520 const TypeDesc type,
521 bool derivatives,
522 ccl_private void *val)
523{
524 const unsigned char type_basetype = type & 0xFF;
525 const unsigned char type_aggregate = (type >> 8) & 0xFF;
526 const int type_arraylen = type >> 32;
527
528 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
529 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
530 {
531 set_data_float3(make_float3(v), make_float3(dx), make_float3(dy), derivatives, val);
532 return true;
533 }
534 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
535 {
536 set_data_float4(make_float4(v.x, v.y, 0.0f, 1.0f),
537 make_float4(dx.x, dx.y, 0.0f, 0.0f),
538 make_float4(dy.x, dy.y, 0.0f, 0.0f),
539 derivatives,
540 val);
541 }
542 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
543 set_data_float(average(v), average(dx), average(dy), derivatives, val);
544 return true;
545 }
546 }
547
548 return false;
549}
551 const float3 dx,
552 const float3 dy,
553 const TypeDesc type,
554 bool derivatives,
555 ccl_private void *val)
556{
557 const unsigned char type_basetype = type & 0xFF;
558 const unsigned char type_aggregate = (type >> 8) & 0xFF;
559 const int type_arraylen = type >> 32;
560
561 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
562 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
563 {
564 set_data_float3(v, dx, dy, derivatives, val);
565 return true;
566 }
567 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
568 {
570 make_float4(v, 1.0f), make_float4(dx, 0.0f), make_float4(dy, 0.0f), derivatives, val);
571 return true;
572 }
573 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
574 set_data_float(average(v), average(dx), average(dy), derivatives, val);
575 return true;
576 }
577 }
578
579 return false;
580}
582 const float4 dx,
583 const float4 dy,
584 const TypeDesc type,
585 bool derivatives,
586 ccl_private void *val)
587{
588 const unsigned char type_basetype = type & 0xFF;
589 const unsigned char type_aggregate = (type >> 8) & 0xFF;
590 const int type_arraylen = type >> 32;
591
592 if (type_basetype == 11 /* TypeDesc::FLOAT */) {
593 if ((type_aggregate == 3 /* TypeDesc::VEC3 */) || (type_aggregate == 1 && type_arraylen == 3))
594 {
595 set_data_float3(make_float3(v), make_float3(dx), make_float3(dy), derivatives, val);
596 return true;
597 }
598 if ((type_aggregate == 4 /* TypeDesc::VEC4 */) || (type_aggregate == 1 && type_arraylen == 4))
599 {
600 set_data_float4(v, dx, dy, derivatives, val);
601 return true;
602 }
603 if ((type_aggregate == 1 /* TypeDesc::SCALAR */)) {
605 average(make_float3(dx)),
606 average(make_float3(dy)),
607 derivatives,
608 val);
609 return true;
610 }
611 }
612
613 return false;
614}
615
616template<typename T>
618 const TypeDesc type,
619 bool derivatives,
620 ccl_private void *val)
621{
622 return set_attribute(f, make_zero<T>(), make_zero<T>(), type, derivatives, val);
623}
624
626 const TypeDesc type,
627 ccl_private void *val)
628{
629 const unsigned char type_basetype = type & 0xFF;
630 const unsigned char type_aggregate = (type >> 8) & 0xFF;
631
632 if (type_basetype == 11 /* TypeDesc::FLOAT */ && type_aggregate == 16 /* TypeDesc::MATRIX44 */) {
633 copy_matrix(static_cast<ccl_private float *>(val), tfm);
634 return true;
635 }
636
637 return false;
638}
639
641 const TypeDesc type,
642 bool derivatives,
643 ccl_private void *val)
644{
645 ccl_private int *ival = static_cast<ccl_private int *>(val);
646
647 const unsigned char type_basetype = type & 0xFF;
648 const unsigned char type_aggregate = (type >> 8) & 0xFF;
649 const int type_arraylen = type >> 32;
650
651 if ((type_basetype == 7 /* TypeDesc::INT */) && (type_aggregate == 1 /* TypeDesc::SCALAR */) &&
652 type_arraylen == 0)
653 {
654 ival[0] = i;
655
656 if (derivatives) {
657 ival[1] = 0;
658 ival[2] = 0;
659 }
660
661 return true;
662 }
663
664 return false;
665}
666
669 ccl_private ShaderData *sd,
670 DeviceString name,
671 const TypeDesc type,
672 bool derivatives,
673 ccl_private void *val)
674{
675 ConstIntegratorState state = (sg->shade_index > 0) ? (sg->shade_index - 1) : -1;
676 ConstIntegratorShadowState shadow_state = (sg->shade_index < 0) ? (-sg->shade_index - 1) : -1;
678 /* Ray Length */
679 float f = sd->ray_length;
680 return set_attribute(f, type, derivatives, val);
681 }
682
683#define READ_PATH_STATE(elem) \
684 ((state != -1) ? INTEGRATOR_STATE(state, path, elem) : \
685 (shadow_state != -1) ? INTEGRATOR_STATE(shadow_state, shadow_path, elem) : \
686 0)
687
689 /* Ray Depth */
690 int f = READ_PATH_STATE(bounce);
691
692 /* Read bounce from different locations depending on if this is a shadow path. For background,
693 * light emission and shadow evaluation from a surface or volume we are effectively one bounce
694 * further. */
695 if (sg->raytype & (PATH_RAY_SHADOW | PATH_RAY_EMISSION)) {
696 f += 1;
697 }
698
699 return set_attribute(f, type, derivatives, val);
700 }
702 /* Diffuse Ray Depth */
703 const int f = READ_PATH_STATE(diffuse_bounce);
704 return set_attribute(f, type, derivatives, val);
705 }
707 /* Glossy Ray Depth */
708 const int f = READ_PATH_STATE(glossy_bounce);
709 return set_attribute(f, type, derivatives, val);
710 }
712 /* Transmission Ray Depth */
713 const int f = READ_PATH_STATE(transmission_bounce);
714 return set_attribute(f, type, derivatives, val);
715 }
717 /* Transparent Ray Depth */
718 const int f = READ_PATH_STATE(transparent_bounce);
719 return set_attribute(f, type, derivatives, val);
720 }
721#undef READ_PATH_STATE
722
723 else if (name == DeviceStrings::u_ndc) {
724 /* NDC coordinates with special exception for orthographic projection. */
725 float3 ndc[3];
726
727 if ((sg->raytype & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE &&
729 {
730 ndc[0] = camera_world_to_ndc(kg, sd, sd->ray_P);
731
732 if (derivatives) {
733 ndc[1] = zero_float3();
734 ndc[2] = zero_float3();
735 }
736 }
737 else {
738 ndc[0] = camera_world_to_ndc(kg, sd, sd->P);
739
740 if (derivatives) {
741 const differential3 dP = differential_from_compact(sd->Ng, sd->dP);
742 ndc[1] = camera_world_to_ndc(kg, sd, sd->P + dP.dx) - ndc[0];
743 ndc[2] = camera_world_to_ndc(kg, sd, sd->P + dP.dy) - ndc[0];
744 }
745 }
746
747 return set_attribute(ndc[0], ndc[1], ndc[2], type, derivatives, val);
748 }
749
750 return false;
751}
752
753template<typename T>
755 ccl_private ShaderData *sd,
756 const AttributeDescriptor &desc,
757 const TypeDesc type,
758 bool derivatives,
759 ccl_private void *val)
760{
761 T v;
762 T dx = make_zero<T>();
763 T dy = make_zero<T>();
764#ifdef __VOLUME__
765 if (primitive_is_volume_attribute(sd, desc)) {
766 v = primitive_volume_attribute<T>(kg, sd, desc);
767 }
768 else
769#endif
770 {
772 kg, sd, desc, derivatives ? &dx : nullptr, derivatives ? &dy : nullptr);
773 }
774 return set_attribute(v, dx, dy, type, derivatives, val);
775}
776
778 ccl_private ShaderData *sd,
779 const AttributeDescriptor &desc,
780 const TypeDesc type,
781 bool derivatives,
782 ccl_private void *val)
783{
784 if (desc.type == NODE_ATTR_FLOAT) {
785 return get_object_attribute_impl<float>(kg, sd, desc, type, derivatives, val);
786 }
787 else if (desc.type == NODE_ATTR_FLOAT2) {
788 return get_object_attribute_impl<float2>(kg, sd, desc, type, derivatives, val);
789 }
790 else if (desc.type == NODE_ATTR_FLOAT3) {
791 return get_object_attribute_impl<float3>(kg, sd, desc, type, derivatives, val);
792 }
793 else if (desc.type == NODE_ATTR_FLOAT4 || desc.type == NODE_ATTR_RGBA) {
794 return get_object_attribute_impl<float4>(kg, sd, desc, type, derivatives, val);
795 }
796 else if (desc.type == NODE_ATTR_MATRIX) {
798 return set_attribute_matrix(tfm, type, val);
799 }
800
801 return false;
802}
803
806 ccl_private ShaderData *sd,
807 DeviceString name,
808 const TypeDesc type,
809 bool derivatives,
810 ccl_private void *val)
811{
812 /* Object attributes */
814 float3 f = object_location(kg, sd);
815 return set_attribute(f, type, derivatives, val);
816 }
817 else if (name == DeviceStrings::u_object_color) {
818 float3 f = object_color(kg, sd->object);
819 return set_attribute(f, type, derivatives, val);
820 }
821 else if (name == DeviceStrings::u_object_alpha) {
822 float f = object_alpha(kg, sd->object);
823 return set_attribute(f, type, derivatives, val);
824 }
825 else if (name == DeviceStrings::u_object_index) {
826 float f = object_pass_id(kg, sd->object);
827 return set_attribute(f, type, derivatives, val);
828 }
829 else if (name == DeviceStrings::u_object_is_light) {
830 float f = ((sd->type & PRIMITIVE_LAMP) != 0);
831 return set_attribute(f, type, derivatives, val);
832 }
833 else if (name == DeviceStrings::u_geom_dupli_generated) {
834 float3 f = object_dupli_generated(kg, sd->object);
835 return set_attribute(f, type, derivatives, val);
836 }
837 else if (name == DeviceStrings::u_geom_dupli_uv) {
838 float3 f = object_dupli_uv(kg, sd->object);
839 return set_attribute(f, type, derivatives, val);
840 }
841 else if (name == DeviceStrings::u_material_index) {
842 float f = shader_pass_id(kg, sd);
843 return set_attribute(f, type, derivatives, val);
844 }
845 else if (name == DeviceStrings::u_object_random) {
846 const float f = object_random_number(kg, sd->object);
847
848 return set_attribute(f, type, derivatives, val);
849 }
850
851 /* Particle attributes */
852 else if (name == DeviceStrings::u_particle_index) {
853 int particle_id = object_particle_id(kg, sd->object);
854 float f = particle_index(kg, particle_id);
855 return set_attribute(f, type, derivatives, val);
856 }
857 else if (name == DeviceStrings::u_particle_random) {
858 int particle_id = object_particle_id(kg, sd->object);
859 float f = hash_uint2_to_float(particle_index(kg, particle_id), 0);
860 return set_attribute(f, type, derivatives, val);
861 }
862
863 else if (name == DeviceStrings::u_particle_age) {
864 int particle_id = object_particle_id(kg, sd->object);
865 float f = particle_age(kg, particle_id);
866 return set_attribute(f, type, derivatives, val);
867 }
868 else if (name == DeviceStrings::u_particle_lifetime) {
869 int particle_id = object_particle_id(kg, sd->object);
870 float f = particle_lifetime(kg, particle_id);
871 return set_attribute(f, type, derivatives, val);
872 }
873 else if (name == DeviceStrings::u_particle_location) {
874 int particle_id = object_particle_id(kg, sd->object);
875 float3 f = particle_location(kg, particle_id);
876 return set_attribute(f, type, derivatives, val);
877 }
878#if 0 /* unsupported */
879 else if (name == DeviceStrings::u_particle_rotation) {
880 int particle_id = object_particle_id(kg, sd->object);
881 float4 f = particle_rotation(kg, particle_id);
882 return set_attribute4(f, type, derivatives, val);
883 }
884#endif
885 else if (name == DeviceStrings::u_particle_size) {
886 int particle_id = object_particle_id(kg, sd->object);
887 float f = particle_size(kg, particle_id);
888 return set_attribute(f, type, derivatives, val);
889 }
890 else if (name == DeviceStrings::u_particle_velocity) {
891 int particle_id = object_particle_id(kg, sd->object);
892 float3 f = particle_velocity(kg, particle_id);
893 return set_attribute(f, type, derivatives, val);
894 }
896 int particle_id = object_particle_id(kg, sd->object);
897 float3 f = particle_angular_velocity(kg, particle_id);
898 return set_attribute(f, type, derivatives, val);
899 }
900
901 /* Geometry attributes */
902#if 0 /* TODO */
903 else if (name == DeviceStrings::u_geom_numpolyvertices) {
904 return false;
905 }
908 return false;
909 }
910 else if (name == DeviceStrings::u_geom_name) {
911 return false;
912 }
913#endif
914 else if (name == DeviceStrings::u_is_smooth) {
915 float f = ((sd->shader & SHADER_SMOOTH_NORMAL) != 0);
916 return set_attribute(f, type, derivatives, val);
917 }
918
919#ifdef __HAIR__
920 /* Hair attributes */
921 else if (name == DeviceStrings::u_is_curve) {
922 float f = (sd->type & PRIMITIVE_CURVE) != 0;
923 return set_attribute(f, type, derivatives, val);
924 }
925 else if (name == DeviceStrings::u_curve_thickness) {
926 float f = curve_thickness(kg, sd);
927 return set_attribute(f, type, derivatives, val);
928 }
929 else if (name == DeviceStrings::u_curve_tangent_normal) {
930 float3 f = curve_tangent_normal(kg, sd);
931 return set_attribute(f, type, derivatives, val);
932 }
933 else if (name == DeviceStrings::u_curve_random) {
934 float f = curve_random(kg, sd);
935 return set_attribute(f, type, derivatives, val);
936 }
937#endif
938
939#ifdef __POINTCLOUD__
940 /* Point attributes */
941 else if (name == DeviceStrings::u_is_point) {
942 float f = (sd->type & PRIMITIVE_POINT) != 0;
943 return set_attribute(f, type, derivatives, val);
944 }
945 else if (name == DeviceStrings::u_point_radius) {
946 float f = point_radius(kg, sd);
947 return set_attribute(f, type, derivatives, val);
948 }
949 else if (name == DeviceStrings::u_point_position) {
950 float3 f = point_position(kg, sd);
951 return set_attribute(f, type, derivatives, val);
952 }
953 else if (name == DeviceStrings::u_point_random) {
954 float f = point_random(kg, sd);
955 return set_attribute(f, type, derivatives, val);
956 }
957#endif
958
959 else if (name == DeviceStrings::u_normal_map_normal) {
960 if (sd->type & PRIMITIVE_TRIANGLE) {
961 float3 f = triangle_smooth_normal_unnormalized(kg, sd, sd->Ng, sd->prim, sd->u, sd->v);
962 return set_attribute(f, type, derivatives, val);
963 }
964 else {
965 return false;
966 }
967 }
969 float3 f[3];
970 if (!attribute_bump_map_normal(kg, sd, f)) {
971 return false;
972 }
973 return set_attribute(f[0], f[1], f[2], type, derivatives, val);
974 }
975
976 return get_background_attribute(kg, sg, sd, name, type, derivatives, val);
977}
978
980 KernelGlobals kg,
981 DeviceString name,
982 TypeDesc type,
983 bool derivatives,
984 ccl_private void *val)
985{
986 if (name == DeviceStrings::u_sensor_size) {
987 const float2 sensor = make_float2(kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight);
988 return set_attribute(sensor, type, derivatives, val);
989 }
990 else if (name == DeviceStrings::u_image_resolution) {
991 const float2 image = make_float2(kernel_data.cam.width, kernel_data.cam.height);
992 return set_attribute(image, type, derivatives, val);
993 }
995 return set_attribute(1.0f / kernel_data.cam.inv_aperture_ratio, type, derivatives, val);
996 }
997 else if (name == DeviceStrings::u_aperture_size) {
998 return set_attribute(kernel_data.cam.aperturesize, type, derivatives, val);
999 }
1000 else if (name == DeviceStrings::u_aperture_position) {
1001 /* The random numbers for aperture sampling are packed into N. */
1002 const float2 rand_lens = make_float2(sg->N.x, sg->N.y);
1003 const float2 pos = camera_sample_aperture(&kernel_data.cam, rand_lens);
1004 return set_attribute(pos * kernel_data.cam.aperturesize, type, derivatives, val);
1005 }
1006 else if (name == DeviceStrings::u_focal_distance) {
1007 return set_attribute(kernel_data.cam.focaldistance, type, derivatives, val);
1008 }
1009 return false;
1010}
1011
1013 const int derivatives,
1014 DeviceString object_name,
1015 DeviceString name,
1016 const int array_lookup,
1017 const int index,
1018 const TypeDesc type,
1019 ccl_private void *res)
1020{
1021 KernelGlobals kg = nullptr;
1022 ccl_private ShaderData *const sd = sg->sd;
1023 int object;
1024
1025 if (sd == nullptr) {
1026 /* Camera shader. */
1027 return get_camera_attribute(sg, kg, name, type, derivatives, res);
1028 }
1029
1030 if (object_name != DeviceStrings::_emptystring_) {
1031 /* TODO: Get object index from name */
1032 return false;
1033 }
1034 else {
1035 object = sd->object;
1036 }
1037
1038 const AttributeDescriptor desc = find_attribute(kg, object, sd->prim, name);
1039 if (desc.offset != ATTR_STD_NOT_FOUND) {
1040 return get_object_attribute(kg, sd, desc, type, derivatives, res);
1041 }
1042 else {
1043 return get_object_standard_attribute(kg, sg, sd, name, type, derivatives, res);
1044 }
1045}
1046
1047/* Renderer services */
1048
1049/* The ABI for these callbacks is different, so DeviceString and TypeDesc don't work here. */
1053
1055 unsigned char basetype;
1056 unsigned char aggregate;
1057 unsigned char vecsemantics;
1058 unsigned char reserved;
1060};
1061
1063 RSDeviceString name, ccl_private void *data, int data_size, const RSTypeDesc &type, int index)
1064{
1065 if (type.basetype == 14 /* TypeDesc::PTR */) {
1066 kernel_assert(data_size == sizeof(void *));
1067 ccl_private void **ptr_data = (ccl_private void **)data;
1068
1069#ifdef __KERNEL_OPTIX__
1070 if (name.val == DeviceStrings::u_colorsystem) {
1071 *ptr_data = kernel_params.osl_colorsystem;
1072 return true;
1073 }
1074#endif
1075 }
1076 return false;
1077}
1078
1080 RSDeviceString filename,
1081 ccl_private void *texture_handle,
1082 ccl_private void *texture_thread_info,
1084 const float s,
1085 const float t,
1086 const float dsdx,
1087 const float dtdx,
1088 const float dsdy,
1089 const float dtdy,
1090 const int nchannels,
1091 ccl_private float *result,
1092 ccl_private float *dresultds,
1093 ccl_private float *dresultdt,
1094 ccl_private void *errormessage)
1095{
1096 const unsigned int type = OSL_TEXTURE_HANDLE_TYPE(texture_handle);
1097 const unsigned int slot = OSL_TEXTURE_HANDLE_SLOT(texture_handle);
1098
1099 switch (type) {
1101 const float4 rgba = kernel_tex_image_interp(nullptr, slot, s, 1.0f - t);
1102 if (nchannels > 0) {
1103 result[0] = rgba.x;
1104 }
1105 if (nchannels > 1) {
1106 result[1] = rgba.y;
1107 }
1108 if (nchannels > 2) {
1109 result[2] = rgba.z;
1110 }
1111 if (nchannels > 3) {
1112 result[3] = rgba.w;
1113 }
1114 return true;
1115 }
1117 if (nchannels > 0) {
1118 result[0] = kernel_ies_interp(nullptr, slot, s, t);
1119 }
1120 return true;
1121 }
1122 default: {
1123 return false;
1124 }
1125 }
1126}
1127
1129 RSDeviceString filename,
1130 ccl_private void *texture_handle,
1131 ccl_private void *texture_thread_info,
1133 const ccl_private float3 *P,
1134 const ccl_private float3 *dPdx,
1135 const ccl_private float3 *dPdy,
1136 const ccl_private float3 *dPdz,
1137 const int nchannels,
1138 ccl_private float *result,
1139 ccl_private float *dresultds,
1140 ccl_private float *dresultdt,
1141 ccl_private float *dresultdr,
1142 ccl_private void *errormessage)
1143{
1144 const unsigned int type = OSL_TEXTURE_HANDLE_TYPE(texture_handle);
1145 const unsigned int slot = OSL_TEXTURE_HANDLE_SLOT(texture_handle);
1146
1147 switch (type) {
1149 const float4 rgba = kernel_tex_image_interp_3d(nullptr, slot, *P, INTERPOLATION_NONE);
1150 if (nchannels > 0) {
1151 result[0] = rgba.x;
1152 }
1153 if (nchannels > 1) {
1154 result[1] = rgba.y;
1155 }
1156 if (nchannels > 2) {
1157 result[2] = rgba.z;
1158 }
1159 if (nchannels > 3) {
1160 result[3] = rgba.w;
1161 }
1162 return true;
1163 }
1164 default: {
1165 return false;
1166 }
1167 }
1168}
1169
1171 RSDeviceString filename,
1172 ccl_private void *texture_handle,
1173 ccl_private void *texture_thread_info,
1175 const ccl_private float3 *R,
1176 const ccl_private float3 *dRdx,
1177 const ccl_private float3 *dRdy,
1178 const int nchannels,
1179 ccl_private float *result,
1180 ccl_private float *dresultds,
1181 ccl_private float *dresultdt,
1182 ccl_private void *errormessage)
1183{
1184 if (nchannels > 0) {
1185 result[0] = 1.0f;
1186 }
1187 if (nchannels > 1) {
1188 result[1] = 0.0f;
1189 }
1190 if (nchannels > 2) {
1191 result[2] = 1.0f;
1192 }
1193 if (nchannels > 3) {
1194 result[3] = 1.0f;
1195 }
1196
1197 return false;
1198}
1199
1201 RSDeviceString filename,
1202 ccl_private void *texture_handle,
1203 ccl_private void *texture_thread_info,
1204 int subimage,
1205 RSDeviceString dataname,
1206 RSTypeDesc datatype,
1207 ccl_private void *data,
1208 ccl_private void *errormessage)
1209{
1210 return 0;
1211}
1212
1214 RSDeviceString filename,
1215 ccl_private void *texture_handle,
1216 const float s,
1217 const float t,
1218 ccl_private void *texture_thread_info,
1219 int subimage,
1220 RSDeviceString dataname,
1221 RSTypeDesc datatype,
1222 ccl_private void *data,
1223 ccl_private void *errormessage)
1224{
1225 return 0;
1226}
1227
1229 RSDeviceString filename,
1230 const ccl_private float3 *center,
1231 float radius,
1232 int max_points,
1233 bool sort,
1234 ccl_private int *out_indices,
1235 ccl_private float *out_distances,
1236 int derivs_offset)
1237{
1238 return 0;
1239}
1240
1242 RSDeviceString filename,
1243 const ccl_private int *indices,
1244 int count,
1245 RSDeviceString attr_name,
1246 RSTypeDesc attr_type,
1247 ccl_private void *out_data)
1248{
1249 return 0;
1250}
1251
1253 RSDeviceString filename,
1254 const ccl_private float3 *pos,
1255 int nattribs,
1256 const ccl_private DeviceString *names,
1258 const ccl_private void **data)
1259{
1260 return false;
1261}
1262
1264 ccl_private void *options,
1265 const ccl_private float3 *P,
1266 const ccl_private float3 *dPdx,
1267 const ccl_private float3 *dPdy,
1268 const ccl_private float3 *R,
1269 const ccl_private float3 *dRdx,
1270 const ccl_private float3 *dRdy)
1271{
1272 return false;
1273}
1274
1276 RSDeviceString name,
1277 RSTypeDesc type,
1278 ccl_private void *data,
1279 bool derivatives)
1280{
1281 return false;
1282}
1283
1284/* These osl_ functions are supposed to be implemented by OSL itself, but they are not yet.
1285 * See: https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1951
1286 * So we have to keep them around for now.
1287 *
1288 * The 1.14.4 based beta used for Blender 4.5 does not need them though, so we check the
1289 * version for that. */
1290#if (OSL_LIBRARY_VERSION_CODE >= 11405) || (OSL_LIBRARY_VERSION_CODE < 11403)
1292 const int firstchannel)
1293{
1294}
1295
1297{
1298 return 0;
1299}
1300
1305
1310
1315
1320
1324
1328
1332
1336
1338 const float width)
1339{
1340}
1341
1343 const float width)
1344{
1345}
1346
1348 const float width)
1349{
1350}
1351
1353 const float width)
1354{
1355}
1356
1360
1364
1369
1371 const int subimage)
1372{
1373}
1374
1379
1384
1386 const int nchannels,
1387 const float alpha)
1388{
1389}
1390
1392
1394
1396
1398
1400#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_3d(KernelGlobals kg, const int id, float3 P, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y)
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 float4 make_float4(const float x, const float y, const float z, const float w)
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline float2 make_float2(const float x, const float y)
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
VecBase< float, 4 > float4
#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:148
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
@ 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 T make_zero()
ccl_device_inline float average(const float2 a)
ccl_device_inline float3 one_float3()
Definition math_float3.h:24
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:15
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 _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
CCL_NAMESPACE_BEGIN ccl_device_forceinline T primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc, ccl_private T *dfdx, ccl_private T *dfdy)
Definition primitive.h:32
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_inline bool set_attribute(const T v, const T dx, const T dy, const TypeDesc type, bool derivatives, ccl_private void *val)
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)
long long TypeDesc
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_inline void set_data_float4(const float4 v, const float4 dx, const float4 dy, bool derivatives, ccl_private void *val)
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 void set_data_float3(const float3 v, const float3 dx, const float3 dy, bool derivatives, ccl_private void *val)
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_inline void set_data_float(const float v, const float dx, const float dy, bool derivatives, ccl_private void *val)
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_NAMESPACE_BEGIN ccl_device bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, float3 f[3])
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 x
float y
float z
Definition sky_float3.h:27
float y
Definition sky_float3.h:27
float x
Definition sky_float3.h:27
i
Definition text_draw.cc:230
@ INTERPOLATION_NONE