Blender V5.0
types_uint3.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 "util/types_base.h"
8
10
11#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
12struct uint3 {
13 uint x, y, z;
14
15# ifndef __KERNEL_GPU__
17 {
18 util_assert(i < 3);
19 return *(&x + i);
20 }
21
23 {
24 util_assert(i < 3);
25 return *(&x + i);
26 }
27# endif
28};
29
31{
32 uint3 a = {x, y, z};
33 return a;
34}
35#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
36
37#if defined(__KERNEL_METAL__)
38/* Metal has native packed_float3. */
39#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_ONEAPI__)
40/* CUDA/oneAPI uint3 is already packed. */
41using packed_uint3 = uint3;
42#else
43/* HIP uint3 is not packed (https://github.com/ROCm-Developer-Tools/HIP/issues/706). */
45 uint x, y, z;
46
48
49 ccl_device_inline_method packed_uint3(const uint px, const uint py, const uint pz)
50 : x(px), y(py), z(pz) {};
51
52 ccl_device_inline_method packed_uint3(const uint3 &a) : x(a.x), y(a.y), z(a.z) {}
53
55 {
56 return make_uint3(x, y, z);
57 }
58
60 {
61 x = a.x;
62 y = a.y;
63 z = a.z;
64 return *this;
65 }
66
67# ifndef __KERNEL_GPU__
69 {
70 util_assert(i < 3);
71 return *(&x + i);
72 }
73
75 {
76 util_assert(i < 3);
77 return *(&x + i);
78 }
79# endif
80};
81#endif
82
83static_assert(sizeof(packed_uint3) == 12, "packed_uint3 expected to be exactly 12 bytes");
84
86{
87 packed_uint3 a = {x, y, z};
88 return a;
89}
90
unsigned int uint
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#define util_assert(statement)
#define ccl_device_inline
#define ccl_device_inline_method
#define __forceinline
#define CCL_NAMESPACE_END
VecBase< uint, 3 > uint3
__forceinline uint operator[](uint i) const
Definition types_uint3.h:68
ccl_device_inline_method packed_uint3()=default
__forceinline uint & operator[](uint i)
Definition types_uint3.h:74
ccl_device_inline_method packed_uint3(const uint3 &a)
Definition types_uint3.h:52
ccl_device_inline_method packed_uint3(const uint px, const uint py, const uint pz)
Definition types_uint3.h:49
ccl_device_inline_method packed_uint3 & operator=(const uint3 &a)
Definition types_uint3.h:59
uint y
Definition types_uint3.h:13
uint z
Definition types_uint3.h:13
uint x
Definition types_uint3.h:13
__forceinline uint & operator[](uint i)
Definition types_uint3.h:22
__forceinline uint operator[](uint i) const
Definition types_uint3.h:16
i
Definition text_draw.cc:230
ccl_device_inline uint3 make_uint3(const uint x, const uint y, uint z)
Definition types_uint3.h:30
ccl_device_inline packed_uint3 make_packed_uint3(const uint x, const uint y, uint z)
Definition types_uint3.h:85