Cycles: Quick (real) fix for broken textures on OpenCL
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 28 Apr 2017 12:56:22 +0000 (14:56 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 28 Apr 2017 12:56:22 +0000 (14:56 +0200)
Previous fix did not work for mixed textures. This one will over-allocate
information array, but it's better than not being able to render at all.

Some more cleanup and improvement is coming.

intern/cycles/render/image.cpp

index 5ce3b75a2261bb887a30da777b4206cd4d4960d6..22fe14d1dd22e91bd795f9d089e7eede7b780ff0 100644 (file)
@@ -1045,8 +1045,17 @@ void ImageManager::device_pack_images(Device *device,
        size_t size = 0, offset = 0;
        ImageDataType type;
 
-       int info_size = tex_num_images[IMAGE_DATA_TYPE_FLOAT4] + tex_num_images[IMAGE_DATA_TYPE_BYTE4]
-                       + tex_num_images[IMAGE_DATA_TYPE_FLOAT] + tex_num_images[IMAGE_DATA_TYPE_BYTE];
+       /* TODO(sergey): This will over-allocate a bit, but this is constant memory
+        * so should be fine for a short term.
+        */
+       size_t info_size = max4(type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_FLOAT4],
+                                                            IMAGE_DATA_TYPE_FLOAT4),
+                               type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_BYTE4],
+                                                            IMAGE_DATA_TYPE_BYTE4),
+                               type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_FLOAT],
+                                                            IMAGE_DATA_TYPE_FLOAT),
+                               type_index_to_flattened_slot(tex_num_images[IMAGE_DATA_TYPE_BYTE],
+                                                            IMAGE_DATA_TYPE_BYTE));
        uint4 *info = dscene->tex_image_packed_info.resize(info_size*2);
 
        /* Byte4 Textures*/