From b91971c240d3b8391f2105337579a0e14116769c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sun, 12 Jun 2022 22:18:45 +0300 Subject: [PATCH] anv: use the right helper to invalidate memory Signed-off-by: Lionel Landwerlin Reviewed-by: Caio Oliveira Cc: mesa-stable Part-of: --- src/intel/vulkan/anv_device.c | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 5f361d35906..18d6296636b 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4164,25 +4164,6 @@ void anv_UnmapMemory( mem->map_delta = 0; } -static void -clflush_mapped_ranges(struct anv_device *device, - uint32_t count, - const VkMappedMemoryRange *ranges) -{ - for (uint32_t i = 0; i < count; i++) { - ANV_FROM_HANDLE(anv_device_memory, mem, ranges[i].memory); - uint64_t map_offset = ranges[i].offset + mem->map_delta; - if (map_offset >= mem->map_size) - continue; - - if (mem->type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) - continue; - - intel_clflush_range(mem->map + map_offset, - MIN2(ranges[i].size, mem->map_size - map_offset)); - } -} - VkResult anv_FlushMappedMemoryRanges( VkDevice _device, uint32_t memoryRangeCount, @@ -4196,7 +4177,19 @@ VkResult anv_FlushMappedMemoryRanges( /* Make sure the writes we're flushing have landed. */ __builtin_ia32_mfence(); - clflush_mapped_ranges(device, memoryRangeCount, pMemoryRanges); + for (uint32_t i = 0; i < memoryRangeCount; i++) { + ANV_FROM_HANDLE(anv_device_memory, mem, pMemoryRanges[i].memory); + uint64_t map_offset = pMemoryRanges[i].offset + mem->map_delta; + if (map_offset >= mem->map_size) + continue; + + if (mem->type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) + continue; + + intel_clflush_range(mem->map + map_offset, + MIN2(pMemoryRanges[i].size, + mem->map_size - map_offset)); + } return VK_SUCCESS; } @@ -4211,7 +4204,19 @@ VkResult anv_InvalidateMappedMemoryRanges( if (!device->physical->memory.need_clflush) return VK_SUCCESS; - clflush_mapped_ranges(device, memoryRangeCount, pMemoryRanges); + for (uint32_t i = 0; i < memoryRangeCount; i++) { + ANV_FROM_HANDLE(anv_device_memory, mem, pMemoryRanges[i].memory); + uint64_t map_offset = pMemoryRanges[i].offset + mem->map_delta; + if (map_offset >= mem->map_size) + continue; + + if (mem->type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) + continue; + + intel_invalidate_range(mem->map + map_offset, + MIN2(pMemoryRanges[i].size, + mem->map_size - map_offset)); + } /* Make sure no reads get moved up above the invalidate. */ __builtin_ia32_mfence();