Blender V4.3
types_int3.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#ifndef __UTIL_TYPES_H__
8# error "Do not include this file directly, include util/types.h instead."
9#endif
10
12
13#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
14struct ccl_try_align(16) int3
15{
16# ifdef __KERNEL_GPU__
17 /* Compact structure on the GPU. */
18 int x, y, z;
19# else
20 /* SIMD aligned structure for CPU. */
21# ifdef __KERNEL_SSE__
22 union {
23 __m128i m128;
24 struct {
25 int x, y, z, w;
26 };
27 };
28
30 __forceinline int3(const int3 &a);
31 __forceinline explicit int3(const __m128i &a);
32
33 __forceinline operator const __m128i &() const;
34 __forceinline operator __m128i &();
35
37# else /* __KERNEL_SSE__ */
38 int x, y, z, w;
39# endif /* __KERNEL_SSE__ */
40# endif
41
42# ifndef __KERNEL_GPU__
43 __forceinline int operator[](int i) const;
44 __forceinline int &operator[](int i);
45# endif
46};
47
48ccl_device_inline int3 make_int3(int x, int y, int z);
49#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
50
52ccl_device_inline void print_int3(ccl_private const char *label, const int3 a);
53
54#if defined(__KERNEL_METAL__)
55/* Metal has native packed_int3. */
56#elif defined(__KERNEL_CUDA__) || defined(__KERNEL_ONEAPI__)
57/* CUDA and oneAPI int3 are already packed. */
58typedef int3 packed_int3;
59#else
60/* HIP int3 is not packed (https://github.com/ROCm-Developer-Tools/HIP/issues/706). */
62 int x, y, z;
63
65
66 ccl_device_inline_method packed_int3(const int px, const int py, const int pz)
67 : x(px), y(py), z(pz){};
68
69 ccl_device_inline_method packed_int3(const int3 &a) : x(a.x), y(a.y), z(a.z) {}
70
72 {
73 return make_int3(x, y, z);
74 }
75
77 {
78 x = a.x;
79 y = a.y;
80 z = a.z;
81 return *this;
82 }
83
84# ifndef __KERNEL_GPU__
85 __forceinline int operator[](int i) const;
86 __forceinline int &operator[](int i);
87# endif
88};
89
90static_assert(sizeof(packed_int3) == 12, "packed_int3 expected to be exactly 12 bytes");
91#endif
92
blender::int3 packed_int3
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
SIMD_FORCE_INLINE btVector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
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
const char * label
#define ccl_private
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define ccl_device_inline_method
#define ccl_try_align(...)
#define __forceinline
ccl_device_inline_method packed_int3()
Definition types_int3.h:64
ccl_device_inline_method packed_int3 & operator=(const int3 &a)
Definition types_int3.h:76
ccl_device_inline_method packed_int3(const int3 &a)
Definition types_int3.h:69
ccl_device_inline_method packed_int3(const int px, const int py, const int pz)
Definition types_int3.h:66
__forceinline int operator[](int i) const
ccl_device_inline void print_int3(ccl_private const char *label, const int3 a)
ccl_device_inline int3 make_int3(int x, int y, int z)