Merge pull request #90911 from clayjohn/RD-tex-copy
Ensure minimum block size is respected when doing GPU to CPU copies of compressed textures
This commit is contained in:
commit
258be6d762
1 changed files with 7 additions and 6 deletions
|
@ -1350,6 +1350,9 @@ Vector<uint8_t> RenderingDevice::texture_get_data(RID p_texture, uint32_t p_laye
|
|||
thread_local LocalVector<RDD::BufferTextureCopyRegion> command_buffer_texture_copy_regions_vector;
|
||||
command_buffer_texture_copy_regions_vector.clear();
|
||||
|
||||
uint32_t block_w = 0, block_h = 0;
|
||||
get_compressed_image_format_block_dimensions(tex->format, block_w, block_h);
|
||||
|
||||
uint32_t w = tex->width;
|
||||
uint32_t h = tex->height;
|
||||
uint32_t d = tex->depth;
|
||||
|
@ -1365,8 +1368,8 @@ Vector<uint8_t> RenderingDevice::texture_get_data(RID p_texture, uint32_t p_laye
|
|||
copy_region.texture_region_size.z = d;
|
||||
command_buffer_texture_copy_regions_vector.push_back(copy_region);
|
||||
|
||||
w = MAX(1u, w >> 1);
|
||||
h = MAX(1u, h >> 1);
|
||||
w = MAX(block_w, w >> 1);
|
||||
h = MAX(block_h, h >> 1);
|
||||
d = MAX(1u, d >> 1);
|
||||
}
|
||||
|
||||
|
@ -1395,8 +1398,6 @@ Vector<uint8_t> RenderingDevice::texture_get_data(RID p_texture, uint32_t p_laye
|
|||
for (uint32_t i = 0; i < tex->mipmaps; i++) {
|
||||
uint32_t width = 0, height = 0, depth = 0;
|
||||
uint32_t tight_mip_size = get_image_format_required_size(tex->format, w, h, d, 1, &width, &height, &depth);
|
||||
uint32_t block_w = 0, block_h = 0;
|
||||
get_compressed_image_format_block_dimensions(tex->format, block_w, block_h);
|
||||
uint32_t tight_row_pitch = tight_mip_size / ((height / block_h) * depth);
|
||||
|
||||
// Copy row-by-row to erase padding due to alignments.
|
||||
|
@ -1408,8 +1409,8 @@ Vector<uint8_t> RenderingDevice::texture_get_data(RID p_texture, uint32_t p_laye
|
|||
wp += tight_row_pitch;
|
||||
}
|
||||
|
||||
w = MAX(1u, w >> 1);
|
||||
h = MAX(1u, h >> 1);
|
||||
w = MAX(block_w, w >> 1);
|
||||
h = MAX(block_h, h >> 1);
|
||||
d = MAX(1u, d >> 1);
|
||||
read_ptr += mip_layouts[i].size;
|
||||
write_ptr += tight_mip_size;
|
||||
|
|
Loading…
Reference in a new issue