anv: Fix ANV_BO_ALLOC_NO_LOCAL_MEM flag

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: fbd32a04da ("anv: add a third memory type for LLC configuration") added a new heap
Fixes: 582bf4d9f7 ("anv: flag BO for write combine when CPU visible and potentially in lmem")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22483>
(cherry picked from commit a6c5746b37)
This commit is contained in:
José Roberto de Souza 2023-04-27 09:35:38 -07:00 committed by Eric Engestrom
parent 433e4e8fb8
commit 1b4720b305
3 changed files with 5 additions and 3 deletions

View file

@ -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"
},

View file

@ -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;

View file

@ -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;