mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 15:11:46 +00:00
- submit the upload commands
This commit is contained in:
parent
e875198b37
commit
854526dee4
2 changed files with 46 additions and 14 deletions
|
@ -66,6 +66,7 @@ VulkanFrameBuffer::~VulkanFrameBuffer()
|
|||
|
||||
void VulkanFrameBuffer::InitializeState()
|
||||
{
|
||||
mUploadSemaphore.reset(new VulkanSemaphore(device));
|
||||
mGraphicsCommandPool.reset(new VulkanCommandPool(device, device->graphicsFamily));
|
||||
|
||||
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
|
||||
|
@ -109,21 +110,51 @@ void VulkanFrameBuffer::Update()
|
|||
|
||||
mPresentCommands->end();
|
||||
|
||||
VkSemaphore waitSemaphores[] = { device->imageAvailableSemaphore->semaphore };
|
||||
VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
|
||||
if (mUploadCommands)
|
||||
{
|
||||
// Submit upload commands immediately
|
||||
VkSubmitInfo submitInfo = {};
|
||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &mUploadCommands->buffer;
|
||||
submitInfo.signalSemaphoreCount = 1;
|
||||
submitInfo.pSignalSemaphores = &mUploadSemaphore->semaphore;
|
||||
VkResult result = vkQueueSubmit(device->graphicsQueue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||
if (result != VK_SUCCESS)
|
||||
I_FatalError("Failed to submit command buffer!\n");
|
||||
|
||||
VkSubmitInfo submitInfo = {};
|
||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
submitInfo.waitSemaphoreCount = 1;
|
||||
submitInfo.pWaitSemaphores = waitSemaphores;
|
||||
submitInfo.pWaitDstStageMask = waitStages;
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &mPresentCommands->buffer;
|
||||
submitInfo.signalSemaphoreCount = 1;
|
||||
submitInfo.pSignalSemaphores = &device->renderFinishedSemaphore->semaphore;
|
||||
VkResult result = vkQueueSubmit(device->graphicsQueue, 1, &submitInfo, device->renderFinishedFence->fence);
|
||||
if (result != VK_SUCCESS)
|
||||
I_FatalError("Failed to submit command buffer!\n");
|
||||
// Wait for upload commands to finish, then submit render commands
|
||||
VkSemaphore waitSemaphores[] = { mUploadSemaphore->semaphore, device->imageAvailableSemaphore->semaphore };
|
||||
VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
|
||||
submitInfo.waitSemaphoreCount = 2;
|
||||
submitInfo.pWaitSemaphores = waitSemaphores;
|
||||
submitInfo.pWaitDstStageMask = waitStages;
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &mPresentCommands->buffer;
|
||||
submitInfo.signalSemaphoreCount = 1;
|
||||
submitInfo.pSignalSemaphores = &device->renderFinishedSemaphore->semaphore;
|
||||
result = vkQueueSubmit(device->graphicsQueue, 1, &submitInfo, device->renderFinishedFence->fence);
|
||||
if (result != VK_SUCCESS)
|
||||
I_FatalError("Failed to submit command buffer!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
VkSemaphore waitSemaphores[] = { device->imageAvailableSemaphore->semaphore };
|
||||
VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
|
||||
|
||||
VkSubmitInfo submitInfo = {};
|
||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
submitInfo.waitSemaphoreCount = 1;
|
||||
submitInfo.pWaitSemaphores = waitSemaphores;
|
||||
submitInfo.pWaitDstStageMask = waitStages;
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &mPresentCommands->buffer;
|
||||
submitInfo.signalSemaphoreCount = 1;
|
||||
submitInfo.pSignalSemaphores = &device->renderFinishedSemaphore->semaphore;
|
||||
VkResult result = vkQueueSubmit(device->graphicsQueue, 1, &submitInfo, device->renderFinishedFence->fence);
|
||||
if (result != VK_SUCCESS)
|
||||
I_FatalError("Failed to submit command buffer!\n");
|
||||
}
|
||||
|
||||
Flush3D.Unclock();
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
std::unique_ptr<VulkanCommandPool> mGraphicsCommandPool;
|
||||
std::unique_ptr<VulkanCommandBuffer> mUploadCommands;
|
||||
std::unique_ptr<VulkanCommandBuffer> mPresentCommands;
|
||||
std::unique_ptr<VulkanSemaphore> mUploadSemaphore;
|
||||
std::unique_ptr<VkRenderState> mRenderState;
|
||||
|
||||
int camtexcount = 0;
|
||||
|
|
Loading…
Reference in a new issue