diff options
author | Thomas Dinges <blender@dingto.org> | 2016-05-09 18:06:22 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2016-05-10 03:53:50 +0300 |
commit | 76481eaeff77e46555f8a0458d860911a9a57a9c (patch) | |
tree | aa3e872c967d4744ad7504a5e54f1003da441984 /intern/cycles/kernel/svm/svm_image.h | |
parent | dc82c2cd4817c6c84a4dd7e313eb2659a8830d59 (diff) |
Cycles: Add support for float4 textures on OpenCL.
Title says it all, this adds OpenCL float4 texture support.
There is a bug in the code still, I get a "Out of ressources error" on nvidia hardware here, not sure whats wrong yet.
Will investigate further, but maybe someone else has an idea. :)
Reviewers: #cycles, brecht
Subscribers: brecht, candreacchio
Differential Revision: https://developer.blender.org/D1983
Diffstat (limited to 'intern/cycles/kernel/svm/svm_image.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_image.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 1f5ea8cc0ee..faff4ce3e6d 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -30,11 +30,16 @@ CCL_NAMESPACE_BEGIN /* For OpenCL all images are packed in a single array, and we do manual lookup * and interpolation. */ -ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int offset) +ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset) { - uchar4 r = kernel_tex_fetch(__tex_image_packed, offset); - float f = 1.0f/255.0f; - return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); + if(id >= TEX_NUM_FLOAT4_IMAGES) { + uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset); + float f = 1.0f/255.0f; + return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); + } + else { + return kernel_tex_fetch(__tex_image_float4_packed, offset); + } } ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width) @@ -81,7 +86,7 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, iy = svm_image_texture_wrap_clamp(iy, height); } - r = svm_image_texture_read(kg, offset + ix + iy*width); + r = svm_image_texture_read(kg, id, offset + ix + iy*width); } else { /* We default to linear interpolation if it is not closest */ float tx = svm_image_texture_frac(x*width, &ix); @@ -103,10 +108,10 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, } - r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + iy*width); - r += (1.0f - ty)*tx*svm_image_texture_read(kg, offset + nix + iy*width); - r += ty*(1.0f - tx)*svm_image_texture_read(kg, offset + ix + niy*width); - r += ty*tx*svm_image_texture_read(kg, offset + nix + niy*width); + r = (1.0f - ty)*(1.0f - tx)*svm_image_texture_read(kg, id, offset + ix + iy*width); + r += (1.0f - ty)*tx*svm_image_texture_read(kg, id, offset + nix + iy*width); + r += ty*(1.0f - tx)*svm_image_texture_read(kg, id, offset + ix + niy*width); + r += ty*tx*svm_image_texture_read(kg, id, offset + nix + niy*width); } if(use_alpha && r.w != 1.0f && r.w != 0.0f) { |