From: Jason Ekstrand Date: Tue, 11 Feb 2020 16:12:06 +0000 (-0600) Subject: anv: Align UBO sizes to 32B X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61ac8cf08381f7df05b477cfc6854b3b4b88f03f;p=mesa.git anv: Align UBO sizes to 32B This makes all of our bounds checking consistent with the block loads we do for constant offset UBO accesses. Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index 585ff89306a..b9d7eea86eb 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -1304,6 +1304,13 @@ anv_descriptor_set_write_buffer(struct anv_device *device, struct anv_address bind_addr = anv_address_add(buffer->address, offset); uint64_t bind_range = anv_buffer_get_range(buffer, offset, range); + /* We report a bounds checking alignment of 32B for the sake of block + * messages which read an entire register worth at a time. + */ + if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || + type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) + bind_range = align_u64(bind_range, ANV_UBO_BOUNDS_CHECK_ALIGNMENT); + if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC || type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) { *desc = (struct anv_descriptor) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 288d6ece12e..cdfbcb87535 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -172,6 +172,8 @@ struct gen_perf_config; #define MAX_PUSH_DESCRIPTORS 32 /* Minimum requirement */ #define MAX_INLINE_UNIFORM_BLOCK_SIZE 4096 #define MAX_INLINE_UNIFORM_BLOCK_DESCRIPTORS 32 +#define ANV_UBO_BOUNDS_CHECK_ALIGNMENT 32 +#define ANV_SSBO_BOUNDS_CHECK_ALIGNMENT 4 /* From the Skylake PRM Vol. 7 "Binding Table Surface State Model": * diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 5ee82b1df6e..5e4c4d1c408 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -2701,6 +2701,10 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer, /* Clamp the range to the buffer size */ uint32_t range = MIN2(desc->range, desc->buffer->size - offset); + /* Align the range for consistency */ + if (desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) + range = align_u32(range, ANV_UBO_BOUNDS_CHECK_ALIGNMENT); + struct anv_address address = anv_address_add(desc->buffer->address, offset);