Mesa (staging/20.1): anv: increase minUniformBufferOffsetAlignment to 64

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 8 16:32:52 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: c22388ed7ea29d5d9b386e21373f859de05457be
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c22388ed7ea29d5d9b386e21373f859de05457be

Author: Arcady Goldmints-Orlov <agoldmints at igalia.com>
Date:   Tue Apr 28 19:46:48 2020 -0500

anv: increase minUniformBufferOffsetAlignment to 64

Acked-by: Jason Ekstrand <jason at jlekstrand.net>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4904>
(cherry picked from commit a0de2e0090535bd49b70c52917e7bdab628d354a)

squashed with its fix:

anv: fix alignments for uniform buffers

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 at intel.com>
Fixes: a0de2e0090535b ("anv: increase minUniformBufferOffsetAlignment to 64")
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4940>
(cherry picked from commit 8bcfce2fcd02e9b04b7edda5c0d8a0e4b77be39c)

---

 .pick_status.json                     | 4 ++--
 src/intel/vulkan/anv_descriptor_set.c | 2 +-
 src/intel/vulkan/anv_device.c         | 8 +++-----
 src/intel/vulkan/anv_private.h        | 7 ++++++-
 src/intel/vulkan/genX_cmd_buffer.c    | 4 ++--
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6fd6cda8ab7..0e81e261fde 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -40,7 +40,7 @@
         "description": "anv: fix alignments for uniform buffers",
         "nominated": false,
         "nomination_type": 1,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "a0de2e0090535bd49b70c52917e7bdab628d354a"
     },
@@ -472,7 +472,7 @@
         "description": "anv: increase minUniformBufferOffsetAlignment to 64",
         "nominated": false,
         "nomination_type": null,
-        "resolution": 4,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 2e101fd1fdc..d4d6294ecf8 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -1328,7 +1328,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) {
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index b0a02b02a6d..f620c1791d0 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1503,8 +1503,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 */
-      .minUniformBufferOffsetAlignment          = 32,
+      .minUniformBufferOffsetAlignment          = ANV_UBO_ALIGNMENT,
       .minStorageBufferOffsetAlignment          = 4,
       .minTexelOffset                           = -8,
       .maxTexelOffset                           = 7,
@@ -1915,7 +1914,7 @@ void anv_GetPhysicalDeviceProperties2(
          properties->robustStorageBufferAccessSizeAlignment =
             ANV_SSBO_BOUNDS_CHECK_ALIGNMENT;
          properties->robustUniformBufferAccessSizeAlignment =
-            ANV_UBO_BOUNDS_CHECK_ALIGNMENT;
+            ANV_UBO_ALIGNMENT;
          break;
       }
 
@@ -3846,9 +3845,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;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ed851f5aacf..f73b5f053c0 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -172,7 +172,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
 
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 1ba6dc2b987..f1b102c9805 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -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;
       }



More information about the mesa-commit mailing list