mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- minor code cleanup
This commit is contained in:
parent
779cb42578
commit
a8e7f38150
2 changed files with 17 additions and 17 deletions
|
@ -87,6 +87,9 @@ VulkanFrameBuffer::VulkanFrameBuffer(void *hMonitor, bool fullscreen, VulkanDevi
|
||||||
for (auto &fence : mSubmitFence)
|
for (auto &fence : mSubmitFence)
|
||||||
fence.reset(new VulkanFence(device));
|
fence.reset(new VulkanFence(device));
|
||||||
|
|
||||||
|
for (int i = 0; i < maxConcurrentSubmitCount; i++)
|
||||||
|
mSubmitWaitFences[i] = mSubmitFence[i]->fence;
|
||||||
|
|
||||||
InitPalette();
|
InitPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +195,9 @@ void VulkanFrameBuffer::DeleteFrameObjects()
|
||||||
|
|
||||||
void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish)
|
void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t count, bool finish)
|
||||||
{
|
{
|
||||||
int currentIndex = nextSubmitQueue % submitQueueSize;
|
int currentIndex = mNextSubmit % maxConcurrentSubmitCount;
|
||||||
|
|
||||||
if (nextSubmitQueue >= submitQueueSize)
|
if (mNextSubmit >= maxConcurrentSubmitCount)
|
||||||
{
|
{
|
||||||
vkWaitForFences(device->device, 1, &mSubmitFence[currentIndex]->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
|
vkWaitForFences(device->device, 1, &mSubmitFence[currentIndex]->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
|
||||||
vkResetFences(device->device, 1, &mSubmitFence[currentIndex]->fence);
|
vkResetFences(device->device, 1, &mSubmitFence[currentIndex]->fence);
|
||||||
|
@ -205,8 +208,8 @@ void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t cou
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
submit.addCommandBuffer(commands[i]);
|
submit.addCommandBuffer(commands[i]);
|
||||||
|
|
||||||
if (nextSubmitQueue > 0)
|
if (mNextSubmit > 0)
|
||||||
submit.addWait(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, mSubmitSemaphore[(nextSubmitQueue - 1) % submitQueueSize].get());
|
submit.addWait(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, mSubmitSemaphore[(mNextSubmit - 1) % maxConcurrentSubmitCount].get());
|
||||||
|
|
||||||
if (finish && presentImageIndex != 0xffffffff)
|
if (finish && presentImageIndex != 0xffffffff)
|
||||||
{
|
{
|
||||||
|
@ -216,7 +219,7 @@ void VulkanFrameBuffer::FlushCommands(VulkanCommandBuffer **commands, size_t cou
|
||||||
|
|
||||||
submit.addSignal(mSubmitSemaphore[currentIndex].get());
|
submit.addSignal(mSubmitSemaphore[currentIndex].get());
|
||||||
submit.execute(device, device->graphicsQueue, mSubmitFence[currentIndex].get());
|
submit.execute(device, device->graphicsQueue, mSubmitFence[currentIndex].get());
|
||||||
nextSubmitQueue++;
|
mNextSubmit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::FlushCommands(bool finish)
|
void VulkanFrameBuffer::FlushCommands(bool finish)
|
||||||
|
@ -268,16 +271,12 @@ void VulkanFrameBuffer::WaitForCommands(bool finish)
|
||||||
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());
|
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFence waitFences[submitQueueSize];
|
int numWaitFences = MIN(mNextSubmit, (int)maxConcurrentSubmitCount);
|
||||||
for (int i = 0; i < submitQueueSize; i++)
|
vkWaitForFences(device->device, numWaitFences, mSubmitWaitFences, VK_TRUE, std::numeric_limits<uint64_t>::max());
|
||||||
waitFences[i] = mSubmitFence[i]->fence;
|
vkResetFences(device->device, numWaitFences, mSubmitWaitFences);
|
||||||
|
|
||||||
int numWaitFences = MIN(nextSubmitQueue, (int)submitQueueSize);
|
|
||||||
vkWaitForFences(device->device, numWaitFences, waitFences, VK_TRUE, std::numeric_limits<uint64_t>::max());
|
|
||||||
vkResetFences(device->device, numWaitFences, waitFences);
|
|
||||||
|
|
||||||
DeleteFrameObjects();
|
DeleteFrameObjects();
|
||||||
nextSubmitQueue = 0;
|
mNextSubmit = 0;
|
||||||
|
|
||||||
if (finish)
|
if (finish)
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,10 +125,11 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<VulkanCommandBuffer> mDrawCommands;
|
std::unique_ptr<VulkanCommandBuffer> mDrawCommands;
|
||||||
|
|
||||||
enum { submitQueueSize = 8};
|
enum { maxConcurrentSubmitCount = 8};
|
||||||
std::unique_ptr<VulkanSemaphore> mSubmitSemaphore[submitQueueSize];
|
std::unique_ptr<VulkanSemaphore> mSubmitSemaphore[maxConcurrentSubmitCount];
|
||||||
std::unique_ptr<VulkanFence> mSubmitFence[submitQueueSize];
|
std::unique_ptr<VulkanFence> mSubmitFence[maxConcurrentSubmitCount];
|
||||||
int nextSubmitQueue = 0;
|
VkFence mSubmitWaitFences[maxConcurrentSubmitCount];
|
||||||
|
int mNextSubmit = 0;
|
||||||
|
|
||||||
std::unique_ptr<VulkanSemaphore> mSwapChainImageAvailableSemaphore;
|
std::unique_ptr<VulkanSemaphore> mSwapChainImageAvailableSemaphore;
|
||||||
std::unique_ptr<VulkanSemaphore> mRenderFinishedSemaphore;
|
std::unique_ptr<VulkanSemaphore> mRenderFinishedSemaphore;
|
||||||
|
|
Loading…
Reference in a new issue