diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-07-05 23:46:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-07-05 23:46:04 +0300 |
commit | 8dff53898965b5ea07a99245071098207d3f197e (patch) | |
tree | 6d15750b7009796ac7176bb3063145e2dc12b66b /intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h | |
parent | 45fdf41be87fb0b2fbf85778a714537ed1f5eca3 (diff) | |
parent | 0e2915b2929aa312a03bc4d3a606bb8073fcead0 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h')
-rw-r--r-- | intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h index 7bf833eadbc..b77b7350d86 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h +++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h @@ -35,13 +35,13 @@ template<typename T> struct TextureInterpolator { static ccl_always_inline float4 read(uchar4 r) { - float f = 1.0f/255.0f; + float f = 1.0f / 255.0f; return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); } static ccl_always_inline float4 read(uchar r) { - float f = r*(1.0f/255.0f); + float f = r * (1.0f / 255.0f); return make_float4(f, f, f, 1.0f); } @@ -63,6 +63,18 @@ template<typename T> struct TextureInterpolator { return make_float4(f, f, f, 1.0f); } + static ccl_always_inline float4 read(uint16_t r) + { + float f = r*(1.0f/65535.0f); + return make_float4(f, f, f, 1.0f); + } + + static ccl_always_inline float4 read(ushort4 r) + { + float f = 1.0f/65535.0f; + return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); + } + static ccl_always_inline float4 read(const T *data, int x, int y, int width, int height) @@ -481,15 +493,21 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl return TextureInterpolator<half>::interp(info, x, y); case IMAGE_DATA_TYPE_BYTE: return TextureInterpolator<uchar>::interp(info, x, y); + case IMAGE_DATA_TYPE_USHORT: + return TextureInterpolator<uint16_t>::interp(info, x, y); case IMAGE_DATA_TYPE_FLOAT: return TextureInterpolator<float>::interp(info, x, y); case IMAGE_DATA_TYPE_HALF4: return TextureInterpolator<half4>::interp(info, x, y); case IMAGE_DATA_TYPE_BYTE4: return TextureInterpolator<uchar4>::interp(info, x, y); + case IMAGE_DATA_TYPE_USHORT4: + return TextureInterpolator<ushort4>::interp(info, x, y); case IMAGE_DATA_TYPE_FLOAT4: - default: return TextureInterpolator<float4>::interp(info, x, y); + default: + assert(0); + return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); } } @@ -502,15 +520,21 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, return TextureInterpolator<half>::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_BYTE: return TextureInterpolator<uchar>::interp_3d(info, x, y, z, interp); + case IMAGE_DATA_TYPE_USHORT: + return TextureInterpolator<uint16_t>::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_FLOAT: return TextureInterpolator<float>::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_HALF4: return TextureInterpolator<half4>::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_BYTE4: return TextureInterpolator<uchar4>::interp_3d(info, x, y, z, interp); + case IMAGE_DATA_TYPE_USHORT4: + return TextureInterpolator<ushort4>::interp_3d(info, x, y, z, interp); case IMAGE_DATA_TYPE_FLOAT4: - default: return TextureInterpolator<float4>::interp_3d(info, x, y, z, interp); + default: + assert(0); + return make_float4(TEX_IMAGE_MISSING_R, TEX_IMAGE_MISSING_G, TEX_IMAGE_MISSING_B, TEX_IMAGE_MISSING_A); } } |