From 1b4720b30599e24492b18480be531dcd5ccd48bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Thu, 27 Apr 2023 09:35:38 -0700 Subject: [PATCH] anv: Fix ANV_BO_ALLOC_NO_LOCAL_MEM flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT is also set in all memory types of integrated GPUs. This flag means that memory will be allocated in the most efficient place for the GPU to access, which is true in integrated GPUs. However, this was causing ANV_BO_ALLOC_WRITE_COMBINE to be set in integrated GPUs in the block right below when allocating in the non-cached memory type. But the comment only talks about lmem, so to still keep the write combine behavior for iGPUs it was used VkMemoryPropertyFlags in mmap_calc_flags(). Additionally, this was causing anv_bo.has_implicit_ccs to always be set, which could change the expected behavior of anv_BindImageMemory2() in MTL. Fixes: fbd32a04daf8 ("anv: add a third memory type for LLC configuration") added a new heap Fixes: 582bf4d9f72f ("anv: flag BO for write combine when CPU visible and potentially in lmem") Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: (cherry picked from commit a6c5746b3778320c433c5ba7e0f1fa2fde8c5e75) --- .pick_status.json | 2 +- src/intel/vulkan/anv_device.c | 4 ++-- src/intel/vulkan/i915/anv_kmd_backend.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2aacf9a8938..cb0eeb0b35a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -193,7 +193,7 @@ "description": "anv: Fix ANV_BO_ALLOC_NO_LOCAL_MEM flag", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "fbd32a04daf84f7ed931a4a2510f2181083753cf" }, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 53007130001..01844610dcf 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3754,13 +3754,13 @@ VkResult anv_AllocateMemory( (mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) alloc_flags |= ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE; - if (!(mem_type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + if (!mem_heap->is_local_mem) alloc_flags |= ANV_BO_ALLOC_NO_LOCAL_MEM; /* If the allocated buffer might end up in local memory and it's host * visible and uncached, enable CPU write-combining. It should be faster. */ - if (!(alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) && + if (mem_heap->is_local_mem && (mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) == 0 && (mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) alloc_flags |= ANV_BO_ALLOC_WRITE_COMBINE; diff --git a/src/intel/vulkan/i915/anv_kmd_backend.c b/src/intel/vulkan/i915/anv_kmd_backend.c index 82917a88f4b..a3c26dede4a 100644 --- a/src/intel/vulkan/i915/anv_kmd_backend.c +++ b/src/intel/vulkan/i915/anv_kmd_backend.c @@ -136,6 +136,8 @@ mmap_calc_flags(struct anv_device *device, struct anv_bo *bo, flags |= I915_MMAP_WC; if (bo->map_wc) flags |= I915_MMAP_WC; + if (!(property_flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT)) + flags |= I915_MMAP_WC; if (likely(device->physical->info.has_mmap_offset)) flags = (flags & I915_MMAP_WC) ? I915_MMAP_OFFSET_WC : I915_MMAP_OFFSET_WB;