Blender V4.3
types_int8_impl.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#ifdef __KERNEL_AVX__
14__forceinline vint8::vint8() {}
15
16__forceinline vint8::vint8(const vint8 &a) : m256(a.m256) {}
17
18__forceinline vint8::vint8(const __m256i &a) : m256(a) {}
19
20__forceinline vint8::operator const __m256i &() const
21{
22 return m256;
23}
24
25__forceinline vint8::operator __m256i &()
26{
27 return m256;
28}
29
30__forceinline vint8 &vint8::operator=(const vint8 &a)
31{
32 m256 = a.m256;
33 return *this;
34}
35#endif /* __KERNEL_AVX__ */
36
37#ifndef __KERNEL_GPU__
38__forceinline int vint8::operator[](int i) const
39{
40 util_assert(i >= 0);
41 util_assert(i < 8);
42 return *(&a + i);
43}
44
45__forceinline int &vint8::operator[](int i)
46{
47 util_assert(i >= 0);
48 util_assert(i < 8);
49 return *(&a + i);
50}
51#endif
52
53ccl_device_inline vint8 make_vint8(int a, int b, int c, int d, int e, int f, int g, int h)
54{
55#ifdef __KERNEL_AVX__
56 return vint8(_mm256_set_epi32(h, g, f, e, d, c, b, a));
57#else
58 return {a, b, c, d, e, f, g, h};
59#endif
60}
61
63{
64#ifdef __KERNEL_AVX__
65 return vint8(_mm256_set1_epi32(i));
66#else
67 return make_vint8(i, i, i, i, i, i, i, i);
68#endif
69}
70
71ccl_device_inline vint8 make_vint8(const vfloat8 f)
72{
73#ifdef __KERNEL_AVX__
74 return vint8(_mm256_cvtps_epi32(f.m256));
75#else
76 return make_vint8(
77 (int)f.a, (int)f.b, (int)f.c, (int)f.d, (int)f.e, (int)f.f, (int)f.g, (int)f.h);
78#endif
79}
80
81ccl_device_inline vint8 make_vint8(const int4 a, const int4 b)
82{
83#ifdef __KERNEL_AVX__
84 return vint8(_mm256_insertf128_si256(_mm256_castsi128_si256(a.m128), b.m128, 1));
85#else
86 return make_vint8(a.x, a.y, a.z, a.w, b.x, b.y, b.z, b.w);
87#endif
88}
89
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
local_group_size(16, 16) .push_constant(Type b
#define util_assert(statement)
Definition defines.h:98
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define __forceinline
ccl_device_inline vint8 make_vint8(int a, int b, int c, int d, int e, int f, int g, int h)