radv: align buffer descriptor sizes to dword
This is needed to prevent bounds checking issues when load 8/16-bit values with dword loads. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4639>
This commit is contained in:
parent
62ff2ff808
commit
51363bd475
|
@ -81,8 +81,10 @@
|
|||
*/
|
||||
#define RADV_MAX_PER_SET_DESCRIPTORS ((1ull << 31 ) / 96)
|
||||
|
||||
/* Our buffer size fields allow only this much */
|
||||
#define RADV_MAX_MEMORY_ALLOCATION_SIZE 0xFFFFFFFFull
|
||||
/* Our buffer size fields allow only 2**32 - 1. We round that down to a multiple
|
||||
* of 4 bytes so we can align buffer sizes up.
|
||||
*/
|
||||
#define RADV_MAX_MEMORY_ALLOCATION_SIZE 0xFFFFFFFCull
|
||||
|
||||
/* Number of invocations in each subgroup. */
|
||||
#define RADV_SUBGROUP_SIZE 64
|
||||
|
|
|
@ -851,6 +851,12 @@ static void write_buffer_descriptor(struct radv_device *device,
|
|||
if (buffer_info->range == VK_WHOLE_SIZE)
|
||||
range = buffer->size - buffer_info->offset;
|
||||
|
||||
/* robustBufferAccess is relaxed enough to allow this (in combination
|
||||
* with the alignment/size we return from vkGetBufferMemoryRequirements)
|
||||
* and this allows the shader compiler to create more efficient 8/16-bit
|
||||
* buffer accesses. */
|
||||
range = align(range, 4);
|
||||
|
||||
va += buffer_info->offset + buffer->offset;
|
||||
dst[0] = va;
|
||||
dst[1] = S_008F04_BASE_ADDRESS_HI(va >> 32);
|
||||
|
@ -898,6 +904,12 @@ static void write_dynamic_buffer_descriptor(struct radv_device *device,
|
|||
if (buffer_info->range == VK_WHOLE_SIZE)
|
||||
size = buffer->size - buffer_info->offset;
|
||||
|
||||
/* robustBufferAccess is relaxed enough to allow this (in combination
|
||||
* with the alignment/size we return from vkGetBufferMemoryRequirements)
|
||||
* and this allows the shader compiler to create more efficient 8/16-bit
|
||||
* buffer accesses. */
|
||||
size = align(size, 4);
|
||||
|
||||
va += buffer_info->offset + buffer->offset;
|
||||
range->va = va;
|
||||
range->size = size;
|
||||
|
|
Loading…
Reference in New Issue