Skip to content

Commit

Permalink
Fix a stall caused by faulty logic with index/vertex buffer update an…
Browse files Browse the repository at this point in the history
…d usage, causing uneven frame pacing.

Hopefully fixed GitHub linguistics stats this time...
  • Loading branch information
iftodebogdan committed Jul 20, 2021
1 parent dd4c636 commit 2068a18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
*.c linguist-language=C++
*.h linguist-language=C++
*.inl linguist-language=C++
GITechDemo/Tools/* linguist-vendored
GITechDemo/Tools/** linguist-vendored
10 changes: 4 additions & 6 deletions GITechDemo/Code/AppMain/GITechDemo/RenderScheme/UIPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,9 +1009,7 @@ void UIPass::RenderUI()
if (!RSMgr)
return;

const unsigned int nRenderBufferIdx = (m_nCurrBufferIdx + 1) % UI_BUFFER_COUNT;

if (!m_pImGuiVb[nRenderBufferIdx])
if (!m_pImGuiVb[m_nCurrBufferIdx])
return;

// Setup render states
Expand All @@ -1037,9 +1035,9 @@ void UIPass::RenderUI()

// Render geometry
UIShader.Enable();
for (unsigned int n = 0, vtxOffset = 0, idxOffset = 0; n < m_tDrawData[nRenderBufferIdx].CmdList.size(); n++)
for (unsigned int n = 0, vtxOffset = 0, idxOffset = 0; n < m_tDrawData[m_nCurrBufferIdx].CmdList.size(); n++)
{
const UIDrawData::UIDrawCommandList& cmdList = m_tDrawData[nRenderBufferIdx].CmdList[n];
const UIDrawData::UIDrawCommandList& cmdList = m_tDrawData[m_nCurrBufferIdx].CmdList[n];
for (unsigned int i = 0; i < cmdList.DrawCmd.size(); i++)
{
const UIDrawData::UIDrawCommandList::UIDrawCommand& cmd = cmdList.DrawCmd[i];
Expand Down Expand Up @@ -1080,7 +1078,7 @@ void UIPass::RenderUI()
if (invalidateShaderConstants)
UIShader.CommitShaderInputs();

RenderContext->DrawVertexBuffer(m_pImGuiVb[nRenderBufferIdx], vtxOffset, cmd.ElemCount / 3, cmdList.VtxBufferSize, idxOffset);
RenderContext->DrawVertexBuffer(m_pImGuiVb[m_nCurrBufferIdx], vtxOffset, cmd.ElemCount / 3, cmdList.VtxBufferSize, idxOffset);

idxOffset += cmd.ElemCount;
}
Expand Down
2 changes: 1 addition & 1 deletion GITechDemo/Code/AppMain/GITechDemo/RenderScheme/UIPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Synesthesia3D

namespace GITechDemoApp
{
#define UI_BUFFER_COUNT (2)
#define UI_BUFFER_COUNT (3)

class ArtistParameter;

Expand Down

0 comments on commit 2068a18

Please sign in to comment.