For now, persistent maps are ones that have been going for many frames

This commit is contained in:
baldurk
2015-10-11 14:28:24 +02:00
parent ac0f1c6540
commit 307052b467
3 changed files with 9 additions and 3 deletions
+2 -1
View File
@@ -658,12 +658,13 @@ struct VkResourceRecord : public ResourceRecord
struct MemState
{
MemState()
: device(VK_NULL_HANDLE), mapOffset(0), mapSize(0), size(0), mapFlags(0), mappedPtr(NULL), mapFlushed(false), refData(NULL)
: device(VK_NULL_HANDLE), mapOffset(0), mapSize(0), size(0), mapFlags(0), mapFrame(0), mappedPtr(NULL), mapFlushed(false), refData(NULL)
{ }
VkDevice device;
VkDeviceSize mapOffset, mapSize;
VkDeviceSize size;
VkMemoryMapFlags mapFlags;
uint32_t mapFrame;
bool mapFlushed;
void *mappedPtr;
byte *refData;
@@ -399,7 +399,11 @@ VkResult WrappedVulkan::vkQueueSubmit(
for(auto it = m_MemoryInfo.begin(); it != m_MemoryInfo.end(); ++it)
{
// potential persistent map, force a full flush
if(it->second.mappedPtr)
// VKTODOHIGH need better detection than just 'has not been flushed and has
// been mapped for many frames'. Once we are duplicating coherent memory types
// to offer a non-coherent version, we'll have to treat all maps into coherent
// memory the same.
if(it->second.mappedPtr && !it->second.mapFlushed && it->second.mapFrame + 4 < m_FrameCounter)
{
size_t diffStart = 0, diffEnd = 0;
bool found = true;
@@ -414,7 +418,7 @@ VkResult WrappedVulkan::vkQueueSubmit(
if(found)
{
{
RDCLOG("Persistent map flush forced for %llu (%llu -> %llu)", it->first, (uint64_t)diffStart, (uint64_t)diffEnd);
RDCLOG("Persistent map flush forced for %llu (%llu -> %llu) [mapped in %u, flushed %u]", it->first, (uint64_t)diffStart, (uint64_t)diffEnd, it->second.mapFrame, it->second.mapFlushed);
VkMappedMemoryRange range = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, NULL, GetResourceManager()->GetCurrentHandle<VkDeviceMemory>(it->first), it->second.mapOffset+diffStart, diffEnd-diffStart };
vkFlushMappedMemoryRanges(it->second.device, 1, &range);
}
@@ -159,6 +159,7 @@ VkResult WrappedVulkan::vkMapMemory(
it->second.mappedPtr = *ppData;
it->second.mapOffset = offset;
it->second.mapSize = size == 0 ? it->second.size : size;
it->second.mapFrame = m_FrameCounter;
it->second.mapFlags = flags;
it->second.mapFlushed = false;
it->second.refData = NULL;