anv: don't silently convert view ranges from u64 to u32 then u64

Both anv_buffer_view->vk.range and VkDescriptorAddressInfoEXT->range
are VkDeviceSize, which is uint64_t. In Anv, we pass this to
align_down_npot_u32(), anv_fill_buffer_surface_state() and
anv_fill_buffer_view_surface_state(), all which convert it down to
uint32_t. Then we call isl_buffer_fill_state(), converting the value
back to uin64_t as size_B.

Remove the intermediate u32 truncation everywhere. If some place does
not accept values bigger than UINT_MAX, it is that place that should
have a check. We shouldn't silently convert a u64 value to u32 and
then back to u64.

I'm not aware or any workloads that are affected by this bug today.

Reviewed-by: Dylan Baker <dylan.c.baker@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41251>
This commit is contained in:
Paulo Zanoni 2026-04-27 16:16:02 -07:00 committed by Marge Bot
parent 4167b7d51f
commit 8ced368644
4 changed files with 9 additions and 9 deletions

View file

@ -343,7 +343,7 @@ anv_fill_buffer_surface_state(struct anv_device *device,
struct isl_swizzle swizzle,
isl_surf_usage_flags_t usage,
struct anv_address address,
uint32_t range, uint32_t stride)
uint64_t range, uint32_t stride)
{
if (address.bo && address.bo->alloc_flags & ANV_BO_ALLOC_PROTECTED)
usage |= ISL_SURF_USAGE_PROTECTED_BIT;

View file

@ -11,7 +11,7 @@ anv_fill_buffer_view_surface_state(struct anv_device *device,
struct isl_swizzle swizzle,
isl_surf_usage_flags_t usage,
struct anv_address address,
uint32_t range, uint32_t stride)
uint64_t range, uint32_t stride)
{
anv_fill_buffer_surface_state(device,
state->state_data.data,
@ -49,8 +49,8 @@ anv_CreateBufferView(VkDevice _device,
view->format = format.isl_format;
const uint32_t format_bs = isl_format_get_layout(format.isl_format)->bpb / 8;
const uint32_t align_range =
align_down_npot_u32(view->vk.range, format_bs);
const uint64_t align_range =
align_down_npot_u64(view->vk.range, format_bs);
view->address = anv_address_add(buffer->address, pCreateInfo->offset);

View file

@ -2834,7 +2834,7 @@ void anv_GetDescriptorEXT(
format.isl_format, format.swizzle,
ISL_SURF_USAGE_TEXTURE_BIT,
anv_address_from_u64(addr_info->address),
align_down_npot_u32(addr_info->range, format_bs),
align_down_npot_u64(addr_info->range, format_bs),
format_bs);
} else {
memcpy(pDescriptor, device->host_null_surface_state,
@ -2859,7 +2859,7 @@ void anv_GetDescriptorEXT(
format.isl_format, format.swizzle,
ISL_SURF_USAGE_STORAGE_BIT,
anv_address_from_u64(addr_info->address),
align_down_npot_u32(addr_info->range, format_bs),
align_down_npot_u64(addr_info->range, format_bs),
format_bs);
} else {
memcpy(pDescriptor, device->host_null_surface_state,

View file

@ -293,8 +293,8 @@ get_max_vbs(const struct intel_device_info *devinfo) {
*/
#define ANV_COLOR_OUTPUT_UNUSED (0xfe)
static inline uint32_t
align_down_npot_u32(uint32_t v, uint32_t a)
static inline uint64_t
align_down_npot_u64(uint64_t v, uint64_t a)
{
return v - (v % a);
}
@ -6629,7 +6629,7 @@ void anv_fill_buffer_surface_state(struct anv_device *device,
struct isl_swizzle swizzle,
isl_surf_usage_flags_t usage,
struct anv_address address,
uint32_t range, uint32_t stride);
uint64_t range, uint32_t stride);
struct gfx8_border_color {