Cycles: Fix image textures were completely broken since recent unlimited textures commit
The indexing was totally wrong in both image packing code and image sampling in kernel. Fixes T51341: Cycles OpenCL corruption in todays buildbot
This commit is contained in:
parent
e3fc945fe2
commit
8f4166ee49
Notes:
blender-bot
2023-02-14 07:01:31 +01:00
Referenced by commit 1ec59c8e06
, Revert "Cycles: Fix image textures were completely broken since recent unlimited textures commit"
Referenced by issue #51341, cycles OpenCL corruption in todays buildbot (wasn't there 2 days ago)
|
@ -66,7 +66,8 @@ ccl_device_inline float svm_image_texture_frac(float x, int *ix)
|
|||
|
||||
ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, float y)
|
||||
{
|
||||
uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2);
|
||||
const int texture_id = kernel_tex_index(id);
|
||||
uint4 info = kernel_tex_fetch(__tex_image_packed_info, texture_id*2);
|
||||
uint width = info.x;
|
||||
uint height = info.y;
|
||||
uint offset = info.z;
|
||||
|
@ -140,11 +141,12 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
|
|||
|
||||
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x, float y, float z)
|
||||
{
|
||||
uint4 info = kernel_tex_fetch(__tex_image_packed_info, id*2);
|
||||
const int texture_id = kernel_tex_index(id);
|
||||
uint4 info = kernel_tex_fetch(__tex_image_packed_info, texture_id*2);
|
||||
uint width = info.x;
|
||||
uint height = info.y;
|
||||
uint offset = info.z;
|
||||
uint depth = kernel_tex_fetch(__tex_image_packed_info, id*2+1).x;
|
||||
uint depth = kernel_tex_fetch(__tex_image_packed_info, texture_id*2+1).x;
|
||||
|
||||
/* Image Options */
|
||||
uint interpolation = (info.w & (1 << 0)) ? INTERPOLATION_CLOSEST : INTERPOLATION_LINEAR;
|
||||
|
|
|
@ -1049,6 +1049,8 @@ void ImageManager::device_pack_images(Device *device,
|
|||
+ tex_num_images[IMAGE_DATA_TYPE_FLOAT] + tex_num_images[IMAGE_DATA_TYPE_BYTE];
|
||||
uint4 *info = dscene->tex_image_packed_info.resize(info_size*2);
|
||||
|
||||
size_t index = 0;
|
||||
|
||||
/* Byte4 Textures*/
|
||||
type = IMAGE_DATA_TYPE_BYTE4;
|
||||
|
||||
|
@ -1070,9 +1072,8 @@ void ImageManager::device_pack_images(Device *device,
|
|||
|
||||
uint8_t options = pack_image_options(type, slot);
|
||||
|
||||
int index = type_index_to_flattened_slot(slot, type) * 2;
|
||||
info[index] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
info[index++] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index++] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
|
||||
memcpy(pixels_byte4+offset, (void*)tex_img.data_pointer, tex_img.memory_size());
|
||||
offset += tex_img.size();
|
||||
|
@ -1102,9 +1103,8 @@ void ImageManager::device_pack_images(Device *device,
|
|||
|
||||
uint8_t options = pack_image_options(type, slot);
|
||||
|
||||
int index = type_index_to_flattened_slot(slot, type) * 2;
|
||||
info[index] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
info[index++] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index++] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
|
||||
memcpy(pixels_float4+offset, (void*)tex_img.data_pointer, tex_img.memory_size());
|
||||
offset += tex_img.size();
|
||||
|
@ -1132,9 +1132,8 @@ void ImageManager::device_pack_images(Device *device,
|
|||
|
||||
uint8_t options = pack_image_options(type, slot);
|
||||
|
||||
int index = type_index_to_flattened_slot(slot, type) * 2;
|
||||
info[index] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
info[index++] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index++] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
|
||||
memcpy(pixels_byte+offset, (void*)tex_img.data_pointer, tex_img.memory_size());
|
||||
offset += tex_img.size();
|
||||
|
@ -1164,9 +1163,8 @@ void ImageManager::device_pack_images(Device *device,
|
|||
|
||||
uint8_t options = pack_image_options(type, slot);
|
||||
|
||||
int index = type_index_to_flattened_slot(slot, type) * 2;
|
||||
info[index] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index+1] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
info[index++] = make_uint4(tex_img.data_width, tex_img.data_height, offset, options);
|
||||
info[index++] = make_uint4(tex_img.data_depth, 0, 0, 0);
|
||||
|
||||
memcpy(pixels_float+offset, (void*)tex_img.data_pointer, tex_img.memory_size());
|
||||
offset += tex_img.size();
|
||||
|
|
Loading…
Reference in New Issue