Blender V5.0
types_int8.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#include "util/types_int4.h"
9
11
12struct vfloat8;
13
14#ifdef __KERNEL_GPU__
15struct vint8
16#else
17struct ccl_try_align(32) vint8
18#endif
19{
20#ifdef __KERNEL_AVX__
21 union {
22 __m256i m256;
23 struct {
24 int a, b, c, d, e, f, g, h;
25 };
26 };
27
28 __forceinline vint8() = default;
29 __forceinline vint8(const vint8 &a) = default;
30 __forceinline explicit vint8(const __m256i &a) : m256(a) {}
31
32 __forceinline operator const __m256i &() const
33 {
34 return m256;
35 }
36 __forceinline operator __m256i &()
37 {
38 return m256;
39 }
40
41 __forceinline vint8 &operator=(const vint8 &a)
42 {
43 m256 = a.m256;
44 return *this;
45 }
46#else /* __KERNEL_AVX__ */
47 int a, b, c, d, e, f, g, h;
48#endif /* __KERNEL_AVX__ */
49
50#ifndef __KERNEL_GPU__
51 __forceinline int operator[](int i) const
52 {
53 util_assert(i >= 0);
54 util_assert(i < 8);
55 return *(&a + i);
56 }
57 __forceinline int &operator[](int i)
58 {
59 util_assert(i >= 0);
60 util_assert(i < 8);
61 return *(&a + i);
62 }
63#endif
64};
65
67make_vint8(const int a, const int b, int c, const int d, int e, const int f, int g, const int h)
68{
69#ifdef __KERNEL_AVX__
70 return vint8(_mm256_set_epi32(h, g, f, e, d, c, b, a));
71#else
72 return {a, b, c, d, e, f, g, h};
73#endif
74}
75
77{
78#ifdef __KERNEL_AVX__
79 return vint8(_mm256_set1_epi32(i));
80#else
81 return make_vint8(i, i, i, i, i, i, i, i);
82#endif
83}
84
85ccl_device_inline vint8 make_vint8(const int4 a, const int4 b)
86{
87#ifdef __KERNEL_AVX__
88 return vint8(_mm256_insertf128_si256(_mm256_castsi128_si256(a.m128), b.m128, 1));
89#else
90 return make_vint8(a.x, a.y, a.z, a.w, b.x, b.y, b.z, b.w);
91#endif
92}
93
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
SIMD_FORCE_INLINE btVector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
#define util_assert(statement)
#define ccl_device_inline
#define ccl_try_align(...)
#define __forceinline
#define CCL_NAMESPACE_END
i
Definition text_draw.cc:230
ccl_device_inline vint8 make_vint8(const int a, const int b, int c, const int d, int e, const int f, int g, const int h)
Definition types_int8.h:67