Make shader binary alignment handling simpler and more robust

Bonus:
Also simplified the rounding to block size in image size calculations.
This commit is contained in:
Pedro J. Estébanez 2024-03-06 11:06:17 +01:00
parent 7d2ca2d8ac
commit f77b4d155b
3 changed files with 37 additions and 67 deletions

View file

@ -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;