From 582bf4d9f72f35bb56f06386ab3fb6b5384a4593 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 23 Sep 2022 22:21:10 +0300 Subject: [PATCH] anv: flag BO for write combine when CPU visible and potentially in lmem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should fix a performance regression with the internal kernel branch which does not support the upstream I915_MMAP_OFFSET_FIXED. With I915_MMAP_OFFSET_FIXED we defer the mapping flags to the kernel since it knows better where buffers are going to end up (lmem or smem). The internal kernel doesn´t have that and there we should use write combined for anything that can be in lmem. Signed-off-by: Lionel Landwerlin Reviewed-by: Kenneth Graunke Part-of: --- src/intel/vulkan/anv_device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index aa7a5a78ac6..a6fe4c3b0f8 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3923,6 +3923,13 @@ VkResult anv_AllocateMemory( if (!(mem_type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) alloc_flags |= ANV_BO_ALLOC_NO_LOCAL_MEM; + /* If the allocated buffer might end up in local memory and it's host + * visible, make CPU writes are combined, it should be faster. + */ + if (!(alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) && + (mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + alloc_flags |= ANV_BO_ALLOC_WRITE_COMBINE; + if (vk_flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) alloc_flags |= ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS;