panfrost: use 64-bits for layout calculations

On modern Mali GPUs, we can have 16 bits for the X and Y sizes, already
overflowing 32-bit barrier even with a single layer of byte-sized
formats.

So let's make sure we have enough bits to avoid overflows here.

Fixes: d5ed77800e ("panvk: Fix GetPhysicalDeviceProperties2() to report accurate info")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32221>
(cherry picked from commit 00b25ec769)
This commit is contained in:
Erik Faye-Lund 2024-11-19 15:18:07 +01:00 committed by Dylan Baker
parent 9f2e62e2d7
commit 2b742dd9c8
3 changed files with 6 additions and 6 deletions

View file

@ -1154,7 +1154,7 @@
"description": "panfrost: use 64-bits for layout calculations",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "d5ed77800e04fee670dbc1091d98490e4fa470ce",
"notes": null

View file

@ -485,7 +485,7 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout,
bool linear = layout->modifier == DRM_FORMAT_MOD_LINEAR;
bool is_3d = layout->dim == MALI_TEXTURE_DIMENSION_3D;
unsigned offset = explicit_layout ? explicit_layout->offset : 0;
uint64_t offset = explicit_layout ? explicit_layout->offset : 0;
struct pan_block_size block_size =
panfrost_block_size(layout->modifier, layout->format);
@ -543,8 +543,8 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout,
row_stride = ALIGN_POT(row_stride, 64);
}
unsigned slice_one_size =
row_stride * (effective_height / block_size.height);
uint64_t slice_one_size =
(uint64_t)row_stride * (effective_height / block_size.height);
/* Compute AFBC sizes if necessary */
if (afbc) {
@ -583,7 +583,7 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout,
slice->row_stride = row_stride;
}
unsigned slice_full_size = slice_one_size * depth * layout->nr_samples;
uint64_t slice_full_size = slice_one_size * depth * layout->nr_samples;
slice->surface_stride = slice_one_size;

View file

@ -112,7 +112,7 @@ struct pan_image_layout {
struct pan_image_slice_layout slices[MAX_MIP_LEVELS];
uint64_t data_size;
unsigned array_stride;
uint64_t array_stride;
};
struct pan_image_mem {