Browse Source

vulkan: readd local streambuffer frame index

niki 2 years ago
parent
commit
c924d943d6

+ 3 - 2
src/modules/graphics/vulkan/StreamBuffer.cpp

@@ -95,13 +95,13 @@ love::graphics::StreamBuffer::MapInfo StreamBuffer::map(size_t /*minsize*/)
 
 	MapInfo info;
 	info.size = bufferSize - frameGPUReadOffset;
-	info.data = (uint8*)allocInfo.pMappedData + (vgfx->getFrameIndex() * bufferSize) + frameGPUReadOffset;
+	info.data = (uint8*)allocInfo.pMappedData + (frameIndex * bufferSize) + frameGPUReadOffset;
 	return info;
 }
 
 size_t StreamBuffer::unmap(size_t /*usedSize*/)
 {
-	size_t offset = (vgfx->getFrameIndex() * bufferSize) + frameGPUReadOffset;
+	size_t offset = (frameIndex * bufferSize) + frameGPUReadOffset;
 	return offset;
 }
 
@@ -112,6 +112,7 @@ void StreamBuffer::markUsed(size_t usedSize)
 
 void StreamBuffer::nextFrame()
 {
+	frameIndex = (frameIndex + 1) % MAX_FRAMES_IN_FLIGHT;
 	frameGPUReadOffset = 0;
 }
 

+ 1 - 0
src/modules/graphics/vulkan/StreamBuffer.h

@@ -61,6 +61,7 @@ private:
 	VmaAllocation allocation;
 	VmaAllocationInfo allocInfo;
 	VkBuffer buffer = VK_NULL_HANDLE;
+	int frameIndex = 0;
 
 };