diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2018-07-06 12:42:34 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2018-07-06 12:42:34 +0300 |
commit | df30b50f2f5ee66e055fc795fea91c0f7f4954d5 (patch) | |
tree | 4fe16bd326c1592c9637d168b4055e546fe12c18 /intern/cycles/kernel | |
parent | d20d2bcb7fe76a5a8241eefb2f2f3374e4d101bd (diff) |
Cycles: Enabled half precision textures for OpenCL devices that support the cl_khr_fp16 extension.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/kernel_compat_opencl.h | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 438c819eec6..d1ae10a0384 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -150,6 +150,11 @@ /* define NULL */ #define NULL 0 +/* enable extensions */ +#ifdef __KERNEL_CL_KHR_FP16__ +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + #include "util/util_half.h" #include "util/util_types.h" diff --git a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h index 011623130eb..dd9d683e030 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h +++ b/intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h @@ -72,6 +72,17 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, const ccl_glo return make_float4(f, f, f, 1.0f); } /* Byte */ +#ifdef cl_khr_fp16 + /* half and half4 are optional in OpenCL */ + else if(texture_type == IMAGE_DATA_TYPE_HALF) { + float f = tex_fetch(half, info, offset); + return make_float4(f, f, f, 1.0f); + } + else if(texture_type == IMAGE_DATA_TYPE_HALF4) { + half4 r = tex_fetch(half4, info, offset); + return make_float4(r.x, r.y, r.z, r.w); + } +#endif else { uchar r = tex_fetch(uchar, info, offset); float f = r * (1.0f/255.0f); |