Blender V4.3
types_float3_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__
16
17__forceinline float3::float3(const float3 &a) : m128(a.m128) {}
18
19__forceinline float3::float3(const __m128 &a) : m128(a) {}
20
21__forceinline float3::operator const __m128 &() const
22{
23 return m128;
24}
25
26__forceinline float3::operator __m128 &()
27{
28 return m128;
29}
30
31__forceinline float3 &float3::operator=(const float3 &a)
32{
33 m128 = a.m128;
34 return *this;
35}
36# endif /* __KERNEL_SSE__ */
37
38# ifndef __KERNEL_GPU__
39__forceinline float float3::operator[](int i) const
40{
41 util_assert(i >= 0);
42 util_assert(i < 3);
43 return *(&x + i);
44}
45
46__forceinline float &float3::operator[](int i)
47{
48 util_assert(i >= 0);
49 util_assert(i < 3);
50 return *(&x + i);
51}
52# endif
53
54ccl_device_inline float3 make_float3(float x, float y, float z)
55{
56# if defined(__KERNEL_GPU__)
57 return {x, y, z};
58# elif defined(__KERNEL_SSE__)
59 return float3(_mm_set_ps(0.0f, z, y, x));
60# else
61 return {x, y, z, 0.0f};
62# endif
63}
64
65#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */
66
68{
69#if defined(__KERNEL_GPU__)
70 return make_float3(f, f, f);
71#elif defined(__KERNEL_SSE__)
72 return float3(_mm_set1_ps(f));
73#else
74 return {f, f, f, f};
75#endif
76}
77
79{
80#ifdef __KERNEL_PRINTF__
81 printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z);
82#endif
83}
84
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#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
float3()=default
ccl_device_inline void print_float3(ccl_private const char *label, const float3 a)
ccl_device_inline float3 make_float3(float x, float y, float z)