diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-07-29 15:40:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-08-09 17:07:23 +0300 |
commit | 1988665c3c310cbfb66b4e499408fa48c522545c (patch) | |
tree | 5e5771dd13165d9d7ab67fe8837ac088de522eec /intern/cycles/util/types_float3_impl.h | |
parent | 9990792e87238386375c97f431f648c1334bd587 (diff) |
Cleanup: make vector types make/print functions consistent between CPU and GPU
Now all the same ones are available on CPU and GPU, which was previously not
possible due to lack of operator overloadng in OpenCL. Print functions are
no-ops on some GPUs.
Ref D15535
Diffstat (limited to 'intern/cycles/util/types_float3_impl.h')
-rw-r--r-- | intern/cycles/util/types_float3_impl.h | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/intern/cycles/util/types_float3_impl.h b/intern/cycles/util/types_float3_impl.h index cbd3f76dae4..da76ab2ab2a 100644 --- a/intern/cycles/util/types_float3_impl.h +++ b/intern/cycles/util/types_float3_impl.h @@ -56,38 +56,35 @@ __forceinline float &float3::operator[](int i) } # endif -ccl_device_inline float3 make_float3(float f) +ccl_device_inline float3 make_float3(float x, float y, float z) { -# ifdef __KERNEL_GPU__ - float3 a = {f, f, f}; +# if defined(__KERNEL_GPU__) + return {x, y, z}; +# elif defined(__KERNEL_SSE__) + return float3(_mm_set_ps(0.0f, z, y, x)); # else -# ifdef __KERNEL_SSE__ - float3 a(_mm_set1_ps(f)); -# else - float3 a = {f, f, f, f}; -# endif + return {x, y, z, 0.0f}; # endif - return a; } -ccl_device_inline float3 make_float3(float x, float y, float z) +#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ + +ccl_device_inline float3 make_float3(float f) { -# ifdef __KERNEL_GPU__ - float3 a = {x, y, z}; -# else -# ifdef __KERNEL_SSE__ - float3 a(_mm_set_ps(0.0f, z, y, x)); -# else - float3 a = {x, y, z, 0.0f}; -# endif -# endif - return a; +#if defined(__KERNEL_GPU__) + return make_float3(f, f, f); +#elif defined(__KERNEL_SSE__) + return float3(_mm_set1_ps(f)); +#else + return {f, f, f, f}; +#endif } -ccl_device_inline void print_float3(const char *label, const float3 &a) +ccl_device_inline void print_float3(ccl_private const char *label, const float3 a) { +#ifdef __KERNEL_PRINTF__ printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z); +#endif } -#endif /* __KERNEL_NATIVE_VECTOR_TYPES__ */ CCL_NAMESPACE_END |