From 249c76e27b092bf0571a6ca35b61ca588eaaf7f5 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 22 Jun 2023 12:50:43 +0300 Subject: [PATCH] anv: align buffers to a cache line Signed-off-by: Lionel Landwerlin Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9217 Reviewed-by: Yiwei Zhang Part-of: (cherry picked from commit 8509ebb68a022bd1b0629c3362638d217ad0c477) --- .pick_status.json | 2 +- src/intel/vulkan/anv_device.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index fa50aaa8c67..5943448698c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1219,7 +1219,7 @@ "description": "anv: align buffers to a cache line", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index b8bb5a85b6c..867b76425d3 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4303,11 +4303,11 @@ anv_get_buffer_memory_requirements(struct anv_device *device, */ uint32_t memory_types = (1ull << device->physical->memory.type_count) - 1; - /* Base alignment requirement of a cache line */ - uint32_t alignment = 16; - - if (usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) - alignment = MAX2(alignment, ANV_UBO_ALIGNMENT); + /* The GPU appears to write back to main memory in cachelines. Writes to a + * buffers should not clobber with writes to another buffers so make sure + * those are in different cachelines. + */ + uint32_t alignment = 64; pMemoryRequirements->memoryRequirements.size = size; pMemoryRequirements->memoryRequirements.alignment = alignment;