Skip to content

Instantly share code, notes, and snippets.

@attilaz
Created July 24, 2021 21:52
Show Gist options
  • Save attilaz/72c243d178406654cdefddcfab2fcf03 to your computer and use it in GitHub Desktop.
Save attilaz/72c243d178406654cdefddcfab2fcf03 to your computer and use it in GitHub Desktop.
bgfx metal flip
void flip() override
{
if (NULL == m_commandBuffer)
{
return;
}
//for (uint32_t ii = 0, num = m_numWindows; ii < num; ++ii)
if (m_numWindows > 0)
{
FrameBufferMtl& frameBuffer = m_mainFrameBuffer;
if (NULL != frameBuffer.m_swapChain
&& frameBuffer.m_swapChain->m_drawableTexture)
{
MTL_RELEASE(frameBuffer.m_swapChain->m_drawableTexture);
if (NULL != frameBuffer.m_swapChain->m_drawable)
{
m_commandBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
}
}
}
m_cmd.kick(true);
m_commandBuffer = 0;
for (uint32_t ii = 1, num = m_numWindows; ii < num; ++ii)
{
FrameBufferMtl& frameBuffer = m_frameBuffers[m_windows[ii].idx];
if (NULL != frameBuffer.m_swapChain
&& frameBuffer.m_swapChain->m_drawableTexture)
{
MTL_RELEASE(frameBuffer.m_swapChain->m_drawableTexture);
if (NULL != frameBuffer.m_swapChain->m_drawable)
{
CommandBuffer cmdBuffer = m_cmd.m_commandQueue.commandBuffer();
cmdBuffer.presentDrawable(frameBuffer.m_swapChain->m_drawable);
MTL_RELEASE(frameBuffer.m_swapChain->m_drawable);
cmdBuffer.commit();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment