Cycles: fix crash rendering textured objects in OpenCL
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 5 Nov 2012 08:05:24 +0000 (08:05 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 5 Nov 2012 08:05:24 +0000 (08:05 +0000)
Issue was caused by changed order of texture slots -- float textures
have got lower slots indices than byte textures. OpenCL was still assuming
byte textures goes before float.

intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm_image.h
intern/cycles/render/image.h

index 930fffa3f409551a564ae96ea1e253115f346e9f..98d998351a761cbe6df6b6bde810fe36dc4c1f06 100644 (file)
@@ -36,6 +36,8 @@ CCL_NAMESPACE_BEGIN
 #define PARTICLE_SIZE          5
 #define TIME_INVALID           FLT_MAX
 
+#define TEX_NUM_FLOAT_IMAGES   5
+
 /* device capabilities */
 #ifdef __KERNEL_CPU__
 #define __KERNEL_SHADING__
index 9877856fec2a9b9b04e84ca6ea69b80f34464ee1..0894c9c8290fdc9373166af04e178cfe50e9013e 100644 (file)
@@ -52,6 +52,12 @@ __device_inline float svm_image_texture_frac(float x, int *ix)
 
 __device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb)
 {
+       /* first slots are used by float textures, which are not supported here */
+       if(id < TEX_NUM_FLOAT_IMAGES)
+               return make_float4(1.0f, 0.0f, 1.0f, 1.0f);
+
+       id -= TEX_NUM_FLOAT_IMAGES;
+
        uint4 info = kernel_tex_fetch(__tex_image_packed_info, id);
        uint width = info.x;
        uint height = info.y;
index 8fb229282dce605d7260fb8ef98964dff15b9cd6..485bfc5cbf5a580451d68115f953eb7292efc1b2 100644 (file)
 #include "util_thread.h"
 #include "util_vector.h"
 
+#include "kernel_types.h"  /* for TEX_NUM_FLOAT_IMAGES */
+
 CCL_NAMESPACE_BEGIN
 
-#define TEX_NUM_FLOAT_IMAGES   5
 #define TEX_NUM_IMAGES                 95
 #define TEX_IMAGE_BYTE_START   TEX_NUM_FLOAT_IMAGES