mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-25 10:28:11 +02:00
anv: use the right helper to invalidate memory
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17001>
(cherry picked from commit b91971c240)
This commit is contained in:
parent
122e31b5ea
commit
562c1d93b3
2 changed files with 27 additions and 22 deletions
|
|
@ -400,7 +400,7 @@
|
|||
"description": "anv: use the right helper to invalidate memory",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4167,25 +4167,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,
|
||||
|
|
@ -4199,7 +4180,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;
|
||||
}
|
||||
|
|
@ -4214,7 +4207,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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue