vulkan: call invalidate if mapping is incoherent

This commit is contained in:
niki
2022-10-13 23:58:31 +02:00
parent 425480af0a
commit 940ac05137
2 changed files with 17 additions and 3 deletions
+17 -2
View File
@@ -148,8 +148,25 @@ ptrdiff_t Buffer::getTexelBufferHandle() const
void *Buffer::map(MapType map, size_t offset, size_t size)
{
if (size == 0)
return nullptr;
if (map == MAP_WRITE_INVALIDATE && (isImmutable() || dataUsage == BUFFERDATAUSAGE_READBACK))
return nullptr;
if (map == MAP_READ_ONLY && dataUsage != BUFFERDATAUSAGE_READBACK)
return nullptr;
mappedRange = Range(offset, size);
if (!Range(0, getSize()).contains(mappedRange))
return nullptr;
if (dataUsage == BUFFERDATAUSAGE_READBACK)
{
if (!coherent)
vmaInvalidateAllocation(allocator, allocation, offset, size);
char *data = (char*)allocInfo.pMappedData;
return (void*) (data + offset);
}
@@ -167,8 +184,6 @@ void *Buffer::map(MapType map, size_t offset, size_t size)
if (vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &stagingBuffer, &stagingAllocation, &stagingAllocInfo) != VK_SUCCESS)
throw love::Exception("failed to create staging buffer");
mappedRange = Range(offset, size);
return stagingAllocInfo.pMappedData;
}
}
-1
View File
@@ -34,7 +34,6 @@
#include <vector>
#include <cstring>
#include <set>
#include <fstream>
#include <sstream>
#include <array>