Blender V4.3
types_float4_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#ifndef __KERNEL_NATIVE_VECTOR_TYPES__
14# ifdef __KERNEL_SSE__
15__forceinline float4::float4() {}
16
17__forceinline float4::float4(const __m128 &a) : m128(a) {}
18
19__forceinline float4::operator const __m128 &() const
20{
21 return m128;
22}
23
24__forceinline float4::operator __m128 &()
25{
26 return m128;
27}
28
29__forceinline float4 &float4::operator=(const float4 &a)
30{
31 m128 = a.m128;
32 return *this;
33}
34# endif /* __KERNEL_SSE__ */
35
36# ifndef __KERNEL_GPU__
37__forceinline float float4::operator[](int i) const
38{
39 util_assert(i >= 0);
40 util_assert(i < 4);
41 return *(&x + i);
42}
43
44__forceinline float &float4::operator[](int i)
45{
46 util_assert(i >= 0);
47 util_assert(i < 4);
48 return *(&x + i);
49}
50# endif
51
52ccl_device_inline float4 make_float4(float x, float y, float z, float w)
53{
54# ifdef __KERNEL_SSE__
55 return float4(_mm_set_ps(w, z, y, x));
56# else
57 return {x, y, z, w};
58# endif
59}
60
61#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
62
64{
65#ifdef __KERNEL_SSE__
66 return float4(_mm_set1_ps(f));
67#else
68 return make_float4(f, f, f, f);
69#endif
70}
71
73{
74#ifdef __KERNEL_SSE__
75 return float4(_mm_cvtepi32_ps(i.m128));
76#else
77 return make_float4((float)i.x, (float)i.y, (float)i.z, (float)i.w);
78#endif
79}
80
81ccl_device_inline void print_float4(ccl_private const char *label, const float4 a)
82{
83#ifdef __KERNEL_PRINTF__
84 printf("%s: %.8f %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z, (double)a.w);
85#endif
86}
87
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 printf
#define util_assert(statement)
Definition defines.h:98
const char * label
#define ccl_private
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define __forceinline
VecBase< float, 4 > float4
ccl_device_inline void print_float4(ccl_private const char *label, const float4 a)
ccl_device_inline float4 make_float4(float x, float y, float z, float w)