pan/layout: Use uint64_t types for offsets and sizes
As things are now, the pan_image_slice_layout::{offset,size}_B calculation
can exceed UINT32_MAX, and we silently droppin the upper 32-bit on the
floor. Same goes for the crc offset. Let's use a uint64_t to make sure
that doesn't happen.
While at it, move the two 64-bit field next to each other to avoid
padding, and document what size_B encodes.
It's hard to find the commit that introduced the problem with all the
code motion that happened this this struct was introduced, so I'll
just flag for backport.
Backport-to: 25.1
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Eric R. Smith <eric.smith@collabora.com>
Tested-by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35555>
This commit is contained in:
@@ -120,7 +120,7 @@ pan_image_renderblock_size_el(uint64_t modifier, enum pipe_format format,
|
||||
|
||||
static void
|
||||
init_slice_crc_info(unsigned arch, struct pan_image_slice_layout *slice,
|
||||
unsigned width_px, unsigned height_px, unsigned offset_B)
|
||||
unsigned width_px, unsigned height_px, uint64_t offset_B)
|
||||
{
|
||||
unsigned checksum_region_size_px = pan_meta_tile_size(arch);
|
||||
unsigned checksum_x_tile_per_region =
|
||||
|
||||
@@ -32,7 +32,10 @@ struct pan_image_slice_layout {
|
||||
* - report image subres layout and memory requirement
|
||||
* - bind image memory
|
||||
*/
|
||||
unsigned offset_B;
|
||||
uint64_t offset_B;
|
||||
|
||||
/* Size of the MIP level in bytes. */
|
||||
uint64_t size_B;
|
||||
|
||||
/* For AFBC images, the number of bytes between two rows of AFBC
|
||||
* headers.
|
||||
@@ -71,12 +74,10 @@ struct pan_image_slice_layout {
|
||||
/* If checksumming is enabled following the slice, what
|
||||
* is its offset/stride? */
|
||||
struct {
|
||||
unsigned offset_B;
|
||||
uint64_t offset_B;
|
||||
unsigned stride_B;
|
||||
unsigned size_B;
|
||||
} crc;
|
||||
|
||||
unsigned size_B;
|
||||
};
|
||||
|
||||
struct pan_image_extent {
|
||||
@@ -113,7 +114,7 @@ struct pan_image_layout_constraints {
|
||||
* To be noted, this offset might be adjusted to choose an optimal alignment,
|
||||
* unless the layout constraints are explicit (wsi_row_patch_B != 0).
|
||||
*/
|
||||
unsigned offset_B;
|
||||
uint64_t offset_B;
|
||||
|
||||
/* Row pitch in bytes. Non-zero if layout is explicit. */
|
||||
unsigned wsi_row_pitch_B;
|
||||
@@ -176,7 +177,7 @@ bool pan_image_layout_init(
|
||||
const struct pan_image_layout_constraints *layout_constraints,
|
||||
struct pan_image_layout *layout);
|
||||
|
||||
static inline unsigned
|
||||
static inline uint64_t
|
||||
pan_image_get_wsi_offset(const struct pan_image_layout *layout, unsigned level)
|
||||
{
|
||||
return layout->slices[level].offset_B;
|
||||
|
||||
Reference in New Issue
Block a user