From f77b4d155b5900f6b10bdb14cd7f56aa20e27e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 6 Mar 2024 11:06:17 +0100 Subject: Make shader binary alignment handling simpler and more robust Bonus: Also simplified the rounding to block size in image size calculations. --- servers/rendering/rendering_device_commons.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'servers/rendering/rendering_device_commons.cpp') diff --git a/servers/rendering/rendering_device_commons.cpp b/servers/rendering/rendering_device_commons.cpp index c8b7980633..4dbd0e3964 100644 --- a/servers/rendering/rendering_device_commons.cpp +++ b/servers/rendering/rendering_device_commons.cpp @@ -711,12 +711,13 @@ uint32_t RenderingDeviceCommons::get_image_format_required_size(DataFormat p_for uint32_t pixel_size = get_image_format_pixel_size(p_format); uint32_t pixel_rshift = get_compressed_image_format_pixel_rshift(p_format); - uint32_t blockw, blockh; + uint32_t blockw = 0; + uint32_t blockh = 0; get_compressed_image_format_block_dimensions(p_format, blockw, blockh); for (uint32_t i = 0; i < p_mipmaps; i++) { - uint32_t bw = w % blockw != 0 ? w + (blockw - w % blockw) : w; - uint32_t bh = h % blockh != 0 ? h + (blockh - h % blockh) : h; + uint32_t bw = STEPIFY(w, blockw); + uint32_t bh = STEPIFY(h, blockh); uint32_t s = bw * bh; -- cgit v1.2.3