From 61ac8cf08381f7df05b477cfc6854b3b4b88f03f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 11 Feb 2020 10:12:06 -0600 Subject: [PATCH] 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: --- src/intel/vulkan/anv_descriptor_set.c | 7 +++++++ src/intel/vulkan/anv_private.h | 2 ++ src/intel/vulkan/genX_cmd_buffer.c | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index 585ff89..b9d7eea 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 288d6ec..cdfbcb8 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 5ee82b1..5e4c4d1 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); -- 2.7.4