Explorar o código

When updating command buffer states, make sure to do so for all active command buffers, not just the latest one on the queue

BearishSun %!s(int64=9) %!d(string=hai) anos
pai
achega
d2447d1e49

+ 2 - 1
Source/BansheeVulkanRenderAPI/Include/BsVulkanCommandBufferManager.h

@@ -120,7 +120,8 @@ namespace bs
 		/** Contains command buffers specific to one device. */
 		struct PerDeviceData
 		{
-			VulkanCmdBuffer* activeBuffers[BS_MAX_UNIQUE_QUEUES];
+			List<VulkanCmdBuffer*> activeBuffers;
+			VulkanCmdBuffer* lastActiveBuffer[BS_MAX_UNIQUE_QUEUES];
 			VulkanTransferBuffer transferBuffers[GQT_COUNT][BS_MAX_QUEUES_PER_TYPE];
 		};
 

+ 2 - 0
Source/BansheeVulkanRenderAPI/Source/BsVulkanCommandBuffer.cpp

@@ -499,6 +499,8 @@ namespace bs
 
 			queue->submit(cmdBuffer, mSemaphoresTemp, numSemaphores);
 			numSemaphores = 0; // Semaphores are only needed the first time, since we're adding the buffers on the same queue
+
+			// TODO - Cmd buffer not marked as submitted, and doesn't set active buffer in CBM (probably among other things)
 		}
 
 		queue->submit(this, mSemaphoresTemp, numSemaphores);

+ 21 - 10
Source/BansheeVulkanRenderAPI/Source/BsVulkanCommandBufferManager.cpp

@@ -111,7 +111,7 @@ namespace bs
 		{
 			SPtr<VulkanDevice> device = rapi._getDevice(i);
 
-			bs_zero_out(mDeviceData[i].activeBuffers);
+			bs_zero_out(mDeviceData[i].lastActiveBuffer);
 
 			for (UINT32 j = 0; j < GQT_COUNT; j++)
 			{
@@ -155,7 +155,8 @@ namespace bs
 		assert(buffer->isSubmitted());
 
 		UINT32 idx = CommandSyncMask::getGlobalQueueIdx(type, queueIdx);
-		mDeviceData[deviceIdx].activeBuffers[idx] = buffer;
+		mDeviceData[deviceIdx].lastActiveBuffer[idx] = buffer;
+		mDeviceData[deviceIdx].activeBuffers.push_back(buffer);
 	}
 
 	void VulkanCommandBufferManager::getSyncSemaphores(UINT32 deviceIdx, UINT32 syncMask, VkSemaphore* semaphores, 
@@ -167,14 +168,14 @@ namespace bs
 		UINT32 semaphoreIdx = 0;
 		for (UINT32 i = 0; i < BS_MAX_UNIQUE_QUEUES; i++)
 		{
-			if (deviceData.activeBuffers[i] == nullptr)
+			if (deviceData.lastActiveBuffer[i] == nullptr)
 				continue;
 
 			if ((syncMask & (1 << i)) == 0) // We don't care about the command buffer
 				continue;
 
-			assert(deviceData.activeBuffers[i]->isSubmitted()); // It shouldn't be here if it wasn't submitted
-			semaphores[semaphoreIdx++] = deviceData.activeBuffers[i]->getSemaphore();
+			assert(deviceData.lastActiveBuffer[i]->isSubmitted()); // It shouldn't be here if it wasn't submitted
+			semaphores[semaphoreIdx++] = deviceData.lastActiveBuffer[i]->getSemaphore();
 		}
 
 		count = semaphoreIdx;
@@ -185,16 +186,26 @@ namespace bs
 		assert(deviceIdx < mNumDevices);
 		PerDeviceData& deviceData = mDeviceData[deviceIdx];
 
-		UINT32 semaphoreIdx = 0;
+		auto iter = deviceData.activeBuffers.begin();
+		while(iter != deviceData.activeBuffers.end())
+		{
+			VulkanCmdBuffer* cmdBuffer = *iter;
+
+			cmdBuffer->refreshFenceStatus();
+			if (!cmdBuffer->isSubmitted())
+				iter = deviceData.activeBuffers.erase(iter);
+			else
+				++iter;
+		}
+
 		for (UINT32 i = 0; i < BS_MAX_UNIQUE_QUEUES; i++)
 		{
-			if (deviceData.activeBuffers[i] == nullptr)
+			if (deviceData.lastActiveBuffer[i] == nullptr)
 				continue;
 
-			VulkanCmdBuffer* cmdBuffer = deviceData.activeBuffers[i];
-			cmdBuffer->refreshFenceStatus();
+			VulkanCmdBuffer* cmdBuffer = deviceData.lastActiveBuffer[i];
 			if (!cmdBuffer->isSubmitted())
-				deviceData.activeBuffers[i] = nullptr;
+				deviceData.lastActiveBuffer[i] = nullptr;
 		}
 	}