Browse Source

Avoid overflow when calculating ptr address for 3D textures in RenderingDevice texture update

clayjohn 2 years ago
parent
commit
06042a23b6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/vulkan/rendering_device_vulkan.cpp

+ 1 - 1
drivers/vulkan/rendering_device_vulkan.cpp

@@ -2530,7 +2530,7 @@ Error RenderingDeviceVulkan::_texture_update(RID p_texture, uint32_t p_layer, co
 
 
 		for (uint32_t z = 0; z < depth; z++) { // For 3D textures, depth may be > 0.
 		for (uint32_t z = 0; z < depth; z++) { // For 3D textures, depth may be > 0.
 
 
-			const uint8_t *read_ptr = read_ptr_mipmap + image_size * z / depth;
+			const uint8_t *read_ptr = read_ptr_mipmap + (image_size / depth) * z;
 
 
 			for (uint32_t y = 0; y < height; y += region_size) {
 			for (uint32_t y = 0; y < height; y += region_size) {
 				for (uint32_t x = 0; x < width; x += region_size) {
 				for (uint32_t x = 0; x < width; x += region_size) {