Can I flush a memory range after unmap?
At first seems wrong, because the function is called vkFlushMappedMemoryRanges()
, but the documentation seems to imply the memory is ready to be flushed, even after being unmapped:
Unmapping non-coherent memory does not implicitly flush the mapped memory, and host writes that have not been flushed may not ever be visible to the device. However, implementations must ensure that writes that have not been flushed do not become visible to any other memory.
One of the valid usage rules of vkFlushMappedMemoryRanges()
is that all of the VkMappedMemoryRange
structures must be valid. And the validity rules for that structure say:
memory
must be currently mapped
So if you have unmapped the memory, you can't flush it.
However, flushing does say:
bytes in that range is flushed if any byte in that set has been written by the host since it was first mapped, or the last time it was flushed.
So apparently, if you unmap it and then map it again, you can flush it and still see the data. Personally, I wouldn't count on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With