From fa1520bc13c8ec1feaf21fdc5ff770b949067e04 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 2 Dec 2015 20:40:42 +0100 Subject: [PATCH] Follow the spec strictly - only coherent memory is 'implicitly flushed' * Technically coherent memory isn't implicitly flushed either, but this is handling is required if memory is mapped, written to, and unmapped without ever hitting a QueueSubmit where we will check any current coherent map, and treat it as persistent to flush it out. --- .../driver/vulkan/wrappers/vk_resource_funcs.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index 13533595e..ae11bee59 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -417,7 +417,13 @@ void WrappedVulkan::vkUnmapMemory( if(capframe) { - if(!state.mapFlushed) + // coherent maps must always serialise all data on unmap, even if a flush was seen, because + // unflushed data is *also* visible. This is a bit redundant since data is serialised here + // and in any flushes, but that's the app's fault - the spec calls out flushing coherent maps + // as inefficient + // if the memory is not coherent, we must have a flush for every region written while it is + // mapped, there is no implicit flush on unmap, so we follow the spec strictly on this. + if(state.mapCoherent) { CACHE_THREAD_SERIALISER(); @@ -436,11 +442,6 @@ void WrappedVulkan::vkUnmapMemory( GetResourceManager()->MarkResourceFrameReferenced(id, eFrameRef_Write); } } - else - { - // VKTODOLOW for now assuming flushes cover all writes. Technically - // this is true for all non-coherent memory types. - } } state.mappedPtr = NULL;