anv: fix alignments for uniform buffers
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 7 May 2020 09:25:50 +0000 (12:25 +0300)
committerMarge Bot <eric+marge@anholt.net>
Fri, 8 May 2020 08:59:02 +0000 (08:59 +0000)
We were not consistent with minimums reported in the physical device
properties.

Fixes a few CTS tests :
   dEQP-VK.memory.requirements.dedicated_allocation.buffer.regular
   dEQP-VK.memory.requirements.extended.buffer.regular
   dEQP-VK.memory.requirements.core.buffer.regular

v2: Use define for the limit

v3: Rename define

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: a0de2e0090535b ("anv: increase minUniformBufferOffsetAlignment to 64")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4940>

src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index 11d6a9cfa879f6787641cd0e582c73ab1de23743..d51721b22eab98270ef19de56aef57a9ca04d523 100644 (file)
@@ -1345,7 +1345,7 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
     */
    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);
+      bind_range = align_u64(bind_range, ANV_UBO_ALIGNMENT);
 
    if (type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
        type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
index 52ce55eeb84343fad81a1d29ce8a5ebb5e9c0b14..348ce8f2978e0499af517f522009af09c20f6823 100644 (file)
@@ -1505,10 +1505,7 @@ void anv_GetPhysicalDeviceProperties(
        * case of R32G32B32A32 which is 16 bytes.
        */
       .minTexelBufferOffsetAlignment            = 16,
-      /* We need 16 for UBO block reads to work and 32 for push UBOs.
-       *  However, we use 64 here to avoid cache issues.
-       */
-      .minUniformBufferOffsetAlignment          = 64,
+      .minUniformBufferOffsetAlignment          = ANV_UBO_ALIGNMENT,
       .minStorageBufferOffsetAlignment          = 4,
       .minTexelOffset                           = -8,
       .maxTexelOffset                           = 7,
@@ -1919,7 +1916,7 @@ void anv_GetPhysicalDeviceProperties2(
          properties->robustStorageBufferAccessSizeAlignment =
             ANV_SSBO_BOUNDS_CHECK_ALIGNMENT;
          properties->robustUniformBufferAccessSizeAlignment =
-            ANV_UBO_BOUNDS_CHECK_ALIGNMENT;
+            ANV_UBO_ALIGNMENT;
          break;
       }
 
@@ -3850,9 +3847,8 @@ void anv_GetBufferMemoryRequirements(
    /* Base alignment requirement of a cache line */
    uint32_t alignment = 16;
 
-   /* We need an alignment of 32 for pushing UBOs */
    if (buffer->usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)
-      alignment = MAX2(alignment, 32);
+      alignment = MAX2(alignment, ANV_UBO_ALIGNMENT);
 
    pMemoryRequirements->size = buffer->size;
    pMemoryRequirements->alignment = alignment;
index 522363b09f52ed518e0491bd0e915fd4e70fbde9..10938467ed1dba613b74194ec7cf805041cf79dd 100644 (file)
@@ -173,7 +173,12 @@ 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
+/* We need 16 for UBO block reads to work and 32 for push UBOs. However, we
+ * use 64 here to avoid cache issues. This could most likely bring it back to
+ * 32 if we had different virtual addresses for the different views on a given
+ * GEM object.
+ */
+#define ANV_UBO_ALIGNMENT 64
 #define ANV_SSBO_BOUNDS_CHECK_ALIGNMENT 4
 #define MAX_VIEWS_FOR_PRIMITIVE_REPLICATION 16
 
index 1ba6dc2b987e12f25a09f85bf95fa10fb00f8ec0..f1b102c9805966d71e71f49126fafdb0c0ef84c3 100644 (file)
@@ -2664,7 +2664,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
 
                /* Align the range for consistency */
                if (desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)
-                  range = align_u32(range, ANV_UBO_BOUNDS_CHECK_ALIGNMENT);
+                  range = align_u32(range, ANV_UBO_ALIGNMENT);
 
                struct anv_address address =
                   anv_address_add(desc->buffer->address, offset);
@@ -2993,7 +2993,7 @@ get_push_range_bound_size(struct anv_cmd_buffer *cmd_buffer,
          uint32_t bound_range = MIN2(desc->range, desc->buffer->size - offset);
 
          /* Align the range for consistency */
-         bound_range = align_u32(bound_range, ANV_UBO_BOUNDS_CHECK_ALIGNMENT);
+         bound_range = align_u32(bound_range, ANV_UBO_ALIGNMENT);
 
          return bound_range;
       }