From c86ebb34dfeb43b51a12dc17618e5c1addb4368f Mon Sep 17 00:00:00 2001 From: BeaR Date: Tue, 13 Nov 2012 15:39:23 +0100 Subject: [PATCH] Bug: Losing render-commands if commandbuffer is full(gfx) Problem: If there is a new draw call, it is checked if there is enough free memory for the vertices in the databuffer but not if we have enough free space in the commandbuffer to add the command So we lose some commands during a frame cuz the commandbuffer is full This fixes the 2nd part of issue 1004 --- src/engine/client/graphics_threaded.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index b19e8a836..b5d87f8bd 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -81,7 +81,19 @@ void CGraphics_Threaded::FlushVertices() } mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts); - m_pCommandBuffer->AddCommand(Cmd); + + // check if we have enough free memory in the commandbuffer + if(!m_pCommandBuffer->AddCommand(Cmd)) + { + // kick command buffer and try again + KickCommandBuffer(); + + if(!m_pCommandBuffer->AddCommand(Cmd)) + { + dbg_msg("graphics", "failed to allocate memory for render command"); + return; + } + } } void CGraphics_Threaded::AddVertices(int Count)