Blender V4.5
types_int4.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__
12
13struct ccl_try_align(16) int4
14{
15# ifdef __KERNEL_SSE__
16 union {
17 __m128i m128;
18 struct {
19 int x, y, z, w;
20 };
21 };
22
23 __forceinline int4() = default;
24 __forceinline int4(const int4 &a) = default;
25 __forceinline explicit int4(const __m128i &a) : m128(a) {}
26
27 __forceinline operator const __m128i &() const
28 {
29 return m128;
30 }
31 __forceinline operator __m128i &()
32 {
33 return m128;
34 }
35
37 {
38 m128 = a.m128;
39 return *this;
40 }
41# else /* __KERNEL_SSE__ */
42 int x, y, z, w;
43# endif /* __KERNEL_SSE__ */
44
45# ifndef __KERNEL_GPU__
46 __forceinline int operator[](int i) const
47 {
48 util_assert(i >= 0);
49 util_assert(i < 4);
50 return *(&x + i);
51 }
52 __forceinline int &operator[](int i)
53 {
54 util_assert(i >= 0);
55 util_assert(i < 4);
56 return *(&x + i);
57 }
58# endif
59};
60
61ccl_device_inline int4 make_int4(const int x, const int y, int z, const int w)
62{
63# ifdef __KERNEL_SSE__
64 return int4(_mm_set_epi32(w, z, y, x));
65# else
66 return {x, y, z, w};
67# endif
68}
69#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
70
72{
73#ifdef __KERNEL_SSE__
74 return int4(_mm_set1_epi32(i));
75#else
76 return make_int4(i, i, i, i);
77#endif
78}
79
81{
82 return make_int4(0);
83}
84
85ccl_device_inline void print_int4(const ccl_private char *label, const int4 a)
86{
87#ifdef __KERNEL_PRINTF__
88 printf("%s: %d %d %d %d\n", label, a.x, a.y, a.z, a.w);
89#endif
90}
91
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
#define util_assert(statement)
#define ccl_private
#define ccl_device_inline
#define ccl_try_align(...)
#define __forceinline
#define CCL_NAMESPACE_END
VecBase< int, 4 > int4
#define printf(...)
i
Definition text_draw.cc:230
ccl_device_inline void print_int4(const ccl_private char *label, const int4 a)
Definition types_int4.h:85
ccl_device_inline int4 zero_int4()
Definition types_int4.h:80
ccl_device_inline int4 make_int4(const int x, const int y, int z, const int w)
Definition types_int4.h:61