Blender
V5.0
intern
cycles
util
types_float8.h
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2017 Intel Corporation
2
* SPDX-FileCopyrightText: 2018-2022 Blender Foundation
3
*
4
* SPDX-License-Identifier: BSD-3-Clause
5
*
6
* Originally by Intel Corporation, modified by the Blender Foundation. */
7
8
#pragma once
9
10
#include "
util/types_base.h
"
11
#include "
util/types_float4.h
"
12
#include "
util/types_int8.h
"
13
14
CCL_NAMESPACE_BEGIN
15
16
/* float8 is a reserved type in Metal that has not been implemented. For
17
* that reason this is named vfloat8 and not using native vector types. */
18
19
#ifdef __KERNEL_GPU__
20
struct
vfloat8
21
#else
22
struct
ccl_try_align
(32) vfloat8
23
#endif
24
{
25
#ifdef __KERNEL_AVX__
26
union
{
27
__m256 m256;
28
struct
{
29
float
a,
b
, c, d,
e
, f, g, h;
30
};
31
};
32
33
__forceinline
vfloat8() =
default
;
34
__forceinline
vfloat8(
const
vfloat8 &a) =
default
;
35
__forceinline
explicit
vfloat8(
const
__m256 &a) : m256(a) {}
36
37
__forceinline
operator
const
__m256 &()
const
38
{
39
return
m256;
40
}
41
__forceinline
operator
__m256 &()
42
{
43
return
m256;
44
}
45
46
__forceinline
vfloat8 &
operator=
(
const
vfloat8 &a)
47
{
48
m256 = a.m256;
49
return
*
this
;
50
}
51
52
#else
/* __KERNEL_AVX__ */
53
float
a,
b
, c, d,
e
, f, g, h;
54
#endif
/* __KERNEL_AVX__ */
55
56
#ifndef __KERNEL_GPU__
57
__forceinline
float
operator[]
(
int
i
)
const
58
{
59
util_assert
(
i
>= 0);
60
util_assert
(
i
< 8);
61
return
*(&a +
i
);
62
}
63
__forceinline
float
&
operator[]
(
int
i
)
64
{
65
util_assert
(
i
>= 0);
66
util_assert
(
i
< 8);
67
return
*(&a +
i
);
68
}
69
#endif
70
};
71
72
ccl_device_inline
vfloat8
make_vfloat8
(
const
float
f)
73
{
74
#ifdef __KERNEL_AVX__
75
vfloat8 r(_mm256_set1_ps(f));
76
#else
77
vfloat8 r = {f, f, f, f, f, f, f, f};
78
#endif
79
return
r;
80
}
81
82
ccl_device_inline
vfloat8
make_vfloat8
(
const
float
a,
83
const
float
b
,
84
float
c,
85
const
float
d,
86
float
e
,
87
const
float
f,
88
float
g,
89
const
float
h)
90
{
91
#ifdef __KERNEL_AVX__
92
vfloat8 r(_mm256_setr_ps(a,
b
, c, d,
e
, f, g, h));
93
#else
94
vfloat8 r = {a,
b
, c, d,
e
, f, g, h};
95
#endif
96
return
r;
97
}
98
99
ccl_device_inline
vfloat8
make_vfloat8
(
const
float4
a,
const
float4
b
)
100
{
101
#ifdef __KERNEL_AVX__
102
return
vfloat8(_mm256_insertf128_ps(_mm256_castps128_ps256(a),
b
, 1));
103
#else
104
return
make_vfloat8
(a.
x
, a.
y
, a.
z
, a.
w
,
b
.x,
b
.y,
b
.z,
b
.w);
105
#endif
106
}
107
108
ccl_device_inline
void
print_vfloat8
(
const
ccl_private
char
*label,
const
vfloat8 a)
109
{
110
#ifdef __KERNEL_PRINTF__
111
printf
(
"%s: %.8f %.8f %.8f %.8f %.8f %.8f %.8f %.8f\n"
,
112
label,
113
(
double
)a.a,
114
(
double
)a.b,
115
(
double
)a.c,
116
(
double
)a.d,
117
(
double
)a.e,
118
(
double
)a.f,
119
(
double
)a.g,
120
(
double
)a.h);
121
#endif
122
}
123
124
ccl_device_inline
vint8
make_vint8
(
const
vfloat8 f)
125
{
126
#ifdef __KERNEL_AVX__
127
return
vint8(_mm256_cvtps_epi32(f.m256));
128
#else
129
return
make_vint8
(
130
(
int
)f.a, (
int
)f.b, (
int
)f.c, (
int
)f.d, (
int
)f.e, (
int
)f.f, (
int
)f.g, (
int
)f.h);
131
#endif
132
}
133
134
CCL_NAMESPACE_END
e
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
Definition
bmesh_query_inline.hh:42
operator=
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
Definition
btGeneric6DofConstraint.h:314
operator[]
SIMD_FORCE_INLINE btVector3 & operator[](int i)
Get a mutable reference to a row of the matrix as a vector.
Definition
btMatrix3x3.h:157
b
b
Definition
compositor_morphological_distance_infos.hh:24
util_assert
#define util_assert(statement)
ccl_private
#define ccl_private
ccl_device_inline
#define ccl_device_inline
ccl_try_align
#define ccl_try_align(...)
__forceinline
#define __forceinline
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
printf
#define printf(...)
Definition
gpu_shader_compat_cxx.hh:37
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
float4
Definition
sky_math.h:224
float4::y
float y
Definition
sky_math.h:225
float4::z
float z
Definition
sky_math.h:225
float4::x
float x
Definition
sky_math.h:225
float4::w
float w
Definition
sky_math.h:225
i
i
Definition
text_draw.cc:230
types_base.h
types_float4.h
make_vfloat8
ccl_device_inline vfloat8 make_vfloat8(const float f)
Definition
types_float8.h:72
print_vfloat8
ccl_device_inline void print_vfloat8(const ccl_private char *label, const vfloat8 a)
Definition
types_float8.h:108
make_vint8
ccl_device_inline vint8 make_vint8(const vfloat8 f)
Definition
types_float8.h:124
types_int8.h
Generated on
for Blender by
doxygen
1.16.1