Blender V5.0
cycles/kernel/svm/util.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/globals.h"
8#include "kernel/types.h"
9
10#include "kernel/svm/types.h"
11
13
14/* Stack */
15
17{
19
20 const ccl_private float *stack_a = stack + a;
21 return make_float3(stack_a[0], stack_a[1], stack_a[2]);
22}
23
25 const uint a,
26 const float3 value)
27{
28 return (a == (uint)SVM_STACK_INVALID) ? value : stack_load_float3(stack, a);
29}
30
31ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
32{
34 copy_v3_v3(stack + a, f);
35}
36
37ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
38{
40
41 return stack[a];
42}
43
45 const uint a,
46 const uint value)
47{
48 return (a == (uint)SVM_STACK_INVALID) ? __uint_as_float(value) : stack_load_float(stack, a);
49}
50
52 const uint a,
53 const float value)
54{
55 return (a == (uint)SVM_STACK_INVALID) ? value : stack_load_float(stack, a);
56}
57
58ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
59{
61
62 stack[a] = f;
63}
64
65ccl_device_inline int stack_load_int(const ccl_private float *stack, const uint a)
66{
68
69 return __float_as_int(stack[a]);
70}
71
73 const uint a,
74 const uint value)
75{
76 return (a == (uint)SVM_STACK_INVALID) ? (int)value : stack_load_int(stack, a);
77}
78
79ccl_device_inline void stack_store_int(ccl_private float *stack, const uint a, const int i)
80{
82
83 stack[a] = __int_as_float(i);
84}
85
87{
88 return a != (uint)SVM_STACK_INVALID;
89}
90
91/* Reading Nodes */
92
94{
95 uint4 node = kernel_data_fetch(svm_nodes, *offset);
96 (*offset)++;
97 return node;
98}
99
101{
102 const uint4 node = kernel_data_fetch(svm_nodes, *offset);
103 const float4 f = make_float4(__uint_as_float(node.x),
104 __uint_as_float(node.y),
105 __uint_as_float(node.z),
106 __uint_as_float(node.w));
107 (*offset)++;
108 return f;
109}
110
112{
113 const uint4 node = kernel_data_fetch(svm_nodes, offset);
114 return make_float4(__uint_as_float(node.x),
115 __uint_as_float(node.y),
116 __uint_as_float(node.z),
117 __uint_as_float(node.w));
118}
119
123{
124 *x = (i & 0xFF);
125 *y = ((i >> 8) & 0xFF);
126}
127
132{
133 *x = (i & 0xFF);
134 *y = ((i >> 8) & 0xFF);
135 *z = ((i >> 16) & 0xFF);
136}
137
143{
144 *x = (i & 0xFF);
145 *y = ((i >> 8) & 0xFF);
146 *z = ((i >> 16) & 0xFF);
147 *w = ((i >> 24) & 0xFF);
148}
149
151{
152 return sd->dPdu * sd->du.dx + sd->dPdv * sd->dv.dx;
153}
154
156{
157 return sd->dPdu * sd->du.dy + sd->dPdv * sd->dv.dy;
158}
159
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
ccl_device_inline float4 fetch_node_float(KernelGlobals kg, const int offset)
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline float3 stack_load_float3_default(const ccl_private float *stack, const uint a, const float3 value)
ccl_device_inline float4 read_node_float(KernelGlobals kg, ccl_private int *const offset)
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline int stack_load_int(const ccl_private float *stack, const uint a)
ccl_device_inline uint4 read_node(KernelGlobals kg, ccl_private int *const offset)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline void stack_store_int(ccl_private float *stack, const uint a, const int i)
ccl_device_inline float stack_load_float_default(const ccl_private float *stack, const uint a, const uint value)
ccl_device_forceinline void svm_unpack_node_uchar2(const uint i, ccl_private uint *x, ccl_private uint *y)
ccl_device_forceinline void svm_unpack_node_uchar3(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_forceinline void svm_unpack_node_uchar4(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z, ccl_private uint *w)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
ccl_device_inline bool stack_valid(const uint a)
ccl_device_inline int stack_load_int_default(ccl_private float *stack, const uint a, const uint value)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
#define kernel_assert(cond)
#define SVM_STACK_SIZE
#define ccl_device_forceinline
#define kernel_data_fetch(name, index)
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define SVM_STACK_INVALID
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
#define __int_as_float(x)
#define __float_as_int(x)
#define __uint_as_float(x)
#define make_float4
uint x
Definition types_uint4.h:13
uint y
Definition types_uint4.h:13
uint z
Definition types_uint4.h:13
uint w
Definition types_uint4.h:13
i
Definition text_draw.cc:230