Commit: ae177e799c121f4135d2f32aa0c23cf36992afaf Author: Geraldine Chua Date: Tue Jun 5 21:32:24 2018 +0800 Branches: soc-2018-cycles-volumes https://developer.blender.org/rBae177e799c121f4135d2f32aa0c23cf36992afaf
Created init functions for uchar4 and half4. =================================================================== M intern/cycles/util/util_half.h M intern/cycles/util/util_types_uchar4.h M intern/cycles/util/util_types_uchar4_impl.h =================================================================== diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index 612228dd1c1..b21c773a773 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -32,12 +32,12 @@ CCL_NAMESPACE_BEGIN #define float4_store_half(h, f, scale) vstore_half4(f * (scale), 0, h); -#else +#else /* __KERNEL_OPENCL__ */ /* CUDA has its own half data type, no need to define then */ #ifndef __KERNEL_CUDA__ typedef unsigned short half; -#endif +#endif /* __KERNEL_CUDA__ */ struct half4 { half x, y, z, w; }; @@ -51,7 +51,7 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale) h[3] = __float2half(f.w * scale); } -#else +#else /* __KERNEL_CUDA__ */ ccl_device_inline void float4_store_half(half *h, float4 f, float scale) { @@ -71,23 +71,23 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale) h[i] = (rshift & 0x7FFF); } -#else +#else /*__KERNEL_SSE2__ */ /* same as above with SSE */ ssef fscale = load4f(f) * scale; ssef x = min(max(fscale, 0.0f), 65504.0f); #ifdef __KERNEL_AVX2__ ssei rpack = _mm_cvtps_ph(x, 0); -#else +#else /* __KERNEL_AVX2__ */ ssei absolute = cast(x) & 0x7FFFFFFF; ssei Z = absolute + 0xC8000000; ssei result = andnot(absolute < 0x38800000, Z); ssei rshift = (result >> 13) & 0x7FFF; ssei rpack = _mm_packs_epi32(rshift, rshift); -#endif +#endif /* __KERNEL_AVX2__ */ _mm_storel_pi((__m64*)h, _mm_castsi128_ps(rpack)); -#endif +#endif /*__KERNEL_SSE2__ */ } ccl_device_inline float half_to_float(half h) @@ -133,11 +133,22 @@ ccl_device_inline half float_to_half(float f) return (value_bits | sign_bit); } -#endif +ccl_device_inline half4 make_half4(half h) +{ + half4 a = {h, h, h, h}; + return a; +} -#endif +ccl_device_inline half4 make_half4(half x, half y, half z, half w) +{ + half4 a = {x, y, z, w}; + return a; +} + +#endif /* __KERNEL_CUDA__ */ + +#endif /* __KERNEL_OPENCL__ */ CCL_NAMESPACE_END #endif /* __UTIL_HALF_H__ */ - diff --git a/intern/cycles/util/util_types_uchar4.h b/intern/cycles/util/util_types_uchar4.h index 3802cebbfb9..d9d7cc6f35e 100644 --- a/intern/cycles/util/util_types_uchar4.h +++ b/intern/cycles/util/util_types_uchar4.h @@ -31,6 +31,7 @@ struct uchar4 { __forceinline uchar& operator[](int i); }; +ccl_device_inline uchar4 make_uchar4(uchar u); ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w); #endif /* __KERNEL_GPU__ */ diff --git a/intern/cycles/util/util_types_uchar4_impl.h b/intern/cycles/util/util_types_uchar4_impl.h index 03039f60c54..0594ca4fc43 100644 --- a/intern/cycles/util/util_types_uchar4_impl.h +++ b/intern/cycles/util/util_types_uchar4_impl.h @@ -38,6 +38,12 @@ uchar& uchar4::operator[](int i) return *(&x + i); } +ccl_device_inline uchar4 make_uchar4(uchar u) +{ + uchar4 a = {u, u, u, u}; + return a; +} + ccl_device_inline uchar4 make_uchar4(uchar x, uchar y, uchar z, uchar w) { uchar4 a = {x, y, z, w}; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs