Blender V4.5
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
24ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
25{
27
28 ccl_private float *stack_a = stack + a;
29 stack_a[0] = f.x;
30 stack_a[1] = f.y;
31 stack_a[2] = f.z;
32}
33
34ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
35{
37
38 return stack[a];
39}
40
42 const uint a,
43 const uint value)
44{
45 return (a == (uint)SVM_STACK_INVALID) ? __uint_as_float(value) : stack_load_float(stack, a);
46}
47
48ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
49{
51
52 stack[a] = f;
53}
54
55ccl_device_inline int stack_load_int(const ccl_private float *stack, const uint a)
56{
58
59 return __float_as_int(stack[a]);
60}
61
63 const uint a,
64 const uint value)
65{
66 return (a == (uint)SVM_STACK_INVALID) ? (int)value : stack_load_int(stack, a);
67}
68
69ccl_device_inline void stack_store_int(ccl_private float *stack, const uint a, const int i)
70{
72
73 stack[a] = __int_as_float(i);
74}
75
77{
78 return a != (uint)SVM_STACK_INVALID;
79}
80
81/* Reading Nodes */
82
84{
85 uint4 node = kernel_data_fetch(svm_nodes, *offset);
86 (*offset)++;
87 return node;
88}
89
91{
92 const uint4 node = kernel_data_fetch(svm_nodes, *offset);
93 const float4 f = make_float4(__uint_as_float(node.x),
94 __uint_as_float(node.y),
95 __uint_as_float(node.z),
96 __uint_as_float(node.w));
97 (*offset)++;
98 return f;
99}
100
102{
103 const uint4 node = kernel_data_fetch(svm_nodes, offset);
104 return make_float4(__uint_as_float(node.x),
105 __uint_as_float(node.y),
106 __uint_as_float(node.z),
107 __uint_as_float(node.w));
108}
109
113{
114 *x = (i & 0xFF);
115 *y = ((i >> 8) & 0xFF);
116}
117
122{
123 *x = (i & 0xFF);
124 *y = ((i >> 8) & 0xFF);
125 *z = ((i >> 16) & 0xFF);
126}
127
133{
134 *x = (i & 0xFF);
135 *y = ((i >> 8) & 0xFF);
136 *z = ((i >> 16) & 0xFF);
137 *w = ((i >> 24) & 0xFF);
138}
139
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 float4 read_node_float(KernelGlobals kg, ccl_private int *const offset)
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_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 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)
#define __int_as_float(x)
#define __float_as_int(x)
#define __uint_as_float(x)
VecBase< float, 4 > float4
float z
Definition sky_float3.h:27
float y
Definition sky_float3.h:27
float x
Definition sky_float3.h:27
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