mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
vulkan: call invalidate if mapping is incoherent
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <array>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user