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