Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_image_opencl.h
| Show All 14 Lines | |||||
| */ | */ | ||||
| /* For OpenCL all images are packed in a single array, and we do manual lookup | /* For OpenCL all images are packed in a single array, and we do manual lookup | ||||
| * and interpolation. */ | * and interpolation. */ | ||||
| ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset) | ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset) | ||||
| { | { | ||||
| const texture_type = kernel_tex_type(id); | |||||
| /* Float4 */ | /* Float4 */ | ||||
| if(id < TEX_START_BYTE4_OPENCL) { | if(texture_type == IMAGE_DATA_TYPE_FLOAT4) { | ||||
| return kernel_tex_fetch(__tex_image_float4_packed, offset); | return kernel_tex_fetch(__tex_image_float4_packed, offset); | ||||
| } | } | ||||
| /* Byte4 */ | /* Byte4 */ | ||||
| else if(id < TEX_START_FLOAT_OPENCL) { | else if(texture_type == IMAGE_DATA_TYPE_BYTE4) { | ||||
| uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset); | uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset); | ||||
| 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); | return make_float4(r.x*f, r.y*f, r.z*f, r.w*f); | ||||
| } | } | ||||
| /* Float */ | /* Float */ | ||||
| else if(id < TEX_START_BYTE_OPENCL) { | else if(texture_type == IMAGE_DATA_TYPE_FLOAT) { | ||||
| float f = kernel_tex_fetch(__tex_image_float_packed, offset); | float f = kernel_tex_fetch(__tex_image_float_packed, offset); | ||||
| return make_float4(f, f, f, 1.0f); | return make_float4(f, f, f, 1.0f); | ||||
| } | } | ||||
| /* Byte */ | /* Byte */ | ||||
| else { | else { | ||||
| uchar r = kernel_tex_fetch(__tex_image_byte_packed, offset); | uchar r = kernel_tex_fetch(__tex_image_byte_packed, offset); | ||||
| float f = r * (1.0f/255.0f); | float f = r * (1.0f/255.0f); | ||||
| return make_float4(f, f, f, 1.0f); | return make_float4(f, f, f, 1.0f); | ||||
| ▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines | |||||