mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-11-09 09:35:43 +00:00
Don't present BGFX_FRAME_FLUSH frames. Fixed D3D12/VK flush sync. (#3771)
This commit is contained in:
+3
-1
@@ -2778,7 +2778,7 @@ namespace bgfx
|
||||
|
||||
if (!m_flipAfterRender)
|
||||
{
|
||||
if (!m_render->m_flush)
|
||||
if (!m_flushPrevFrame)
|
||||
{
|
||||
BGFX_PROFILER_SCOPE("bgfx/flip", kColorSubmit);
|
||||
flip();
|
||||
@@ -2825,6 +2825,8 @@ namespace bgfx
|
||||
flip();
|
||||
}
|
||||
}
|
||||
|
||||
m_flushPrevFrame = m_render->m_flush;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3928,6 +3928,7 @@ namespace bgfx
|
||||
, m_exit(false)
|
||||
, m_flipAfterRender(false)
|
||||
, m_singleThreaded(false)
|
||||
, m_flushPrevFrame(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6209,6 +6210,7 @@ namespace bgfx
|
||||
bool m_flipAfterRender;
|
||||
bool m_singleThreaded;
|
||||
bool m_flipped;
|
||||
bool m_flushPrevFrame;
|
||||
|
||||
typedef UpdateBatchT<256> TextureUpdateBatch;
|
||||
BX_ALIGN_DECL_CACHE_LINE(TextureUpdateBatch m_textureUpdateBatch);
|
||||
|
||||
@@ -7248,6 +7248,7 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle;
|
||||
ScratchBufferD3D12& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
|
||||
m_cmd.finish(m_backBufferColorFence[m_backBufferColorIdx]);
|
||||
scratchBuffer.reset(gpuHandle);
|
||||
|
||||
m_uniformScratchBuffer.begin();
|
||||
|
||||
+13
-5
@@ -8384,6 +8384,9 @@ VK_DESTROY
|
||||
m_lastImageRenderedSemaphore = m_renderDoneSemaphore[m_backBufferColorIdx];
|
||||
|
||||
m_needPresent = true;
|
||||
|
||||
s_renderVK->m_cmd.addWaitSemaphore(m_lastImageAcquiredSemaphore, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
m_lastImageAcquiredSemaphore = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -8903,15 +8906,20 @@ VK_DESTROY
|
||||
return result;
|
||||
}
|
||||
|
||||
void CommandQueueVK::addWaitSemaphore(VkSemaphore _semaphore, VkPipelineStageFlags _waitStage)
|
||||
{
|
||||
BX_ASSERT(m_numWaitSemaphores < BX_COUNTOF(m_waitSemaphores), "Too many wait semaphores.");
|
||||
|
||||
m_waitSemaphores[m_numWaitSemaphores] = _semaphore;
|
||||
m_waitSemaphoreStages[m_numWaitSemaphores] = _waitStage;
|
||||
m_numWaitSemaphores++;
|
||||
}
|
||||
|
||||
void CommandQueueVK::addSwapChain(SwapChainVK& _swapChain)
|
||||
{
|
||||
if (VK_NULL_HANDLE != _swapChain.m_lastImageAcquiredSemaphore)
|
||||
{
|
||||
BX_ASSERT(m_numWaitSemaphores < BX_COUNTOF(m_waitSemaphores), "Too many wait semaphores.");
|
||||
|
||||
m_waitSemaphores[m_numWaitSemaphores] = _swapChain.m_lastImageAcquiredSemaphore;
|
||||
m_waitSemaphoreStages[m_numWaitSemaphores] = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||
m_numWaitSemaphores++;
|
||||
addWaitSemaphore(_swapChain.m_lastImageAcquiredSemaphore, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
|
||||
_swapChain.m_lastImageAcquiredSemaphore = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
@@ -912,6 +912,7 @@ VK_DESTROY_FUNC(DescriptorSet);
|
||||
void shutdown();
|
||||
|
||||
VkResult alloc(VkCommandBuffer* _outCommandBuffer);
|
||||
void addWaitSemaphore(VkSemaphore _semaphore, VkPipelineStageFlags _waitStage);
|
||||
void addSwapChain(SwapChainVK& _swapChain);
|
||||
void kick(bool _wait = false);
|
||||
void finish(bool _finishAll = false);
|
||||
|
||||
Reference in New Issue
Block a user