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 <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18841>
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;