diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2012-01-03 22:01:37 +0100 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2012-01-03 22:01:37 +0100 |
| commit | 2991f4071e50cca641044376dc2196d9dcfff80d (patch) | |
| tree | b578297bed74be8d4221f8608d83747c548e7601 /src/engine/client | |
| parent | 50d872531aae6640f57da98e8dcf6dbae1f9cd82 (diff) | |
| download | zcatch-2991f4071e50cca641044376dc2196d9dcfff80d.tar.gz zcatch-2991f4071e50cca641044376dc2196d9dcfff80d.zip | |
fixed kicking of command buffer if it's full when rendering. fixed compile error on windows
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.cpp | 6 | ||||
| -rw-r--r-- | src/engine/client/graphics_threaded.cpp | 20 | ||||
| -rw-r--r-- | src/engine/client/graphics_threaded.h | 32 |
3 files changed, 39 insertions, 19 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 5067f8b2..f126a09c 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -49,6 +49,10 @@ #include <windows.h> #endif +#include "SDL.h" +#ifdef main +#undef main +#endif void CGraph::Init(float Min, float Max) { @@ -1690,8 +1694,6 @@ void CClient::InitInterfaces() m_Friends.Init(); } -#include "SDL.h" - void CClient::Run() { m_LocalStartTime = time_get(); diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index d1d09d38..33670f7b 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -67,7 +67,17 @@ void CGraphics_Threaded::FlushVertices() Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts); if(Cmd.m_pVertices == 0x0) - return; + { + // kick command buffer and try again + KickCommandBuffer(); + + Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts); + if(Cmd.m_pVertices == 0x0) + { + dbg_msg("graphics", "failed to allocate data for vertices"); + return; + } + } mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts); m_pCommandBuffer->AddCommand(Cmd); @@ -757,8 +767,8 @@ int CGraphics_Threaded::Init() m_ScreenHeight = g_Config.m_GfxScreenHeight; // create command buffers - m_apCommandBuffers[0] = new CCommandBuffer(1024*512, 1024*1024); - m_apCommandBuffers[1] = new CCommandBuffer(1024*512, 1024*1024); + for(int i = 0; i < NUM_CMDBUFFERS; i++) + m_apCommandBuffers[i] = new CCommandBuffer(128*1024, 2*1024*1024); m_pCommandBuffer = m_apCommandBuffers[0]; // create null texture, will get id=0 @@ -779,6 +789,10 @@ void CGraphics_Threaded::Shutdown() m_pBackend->Shutdown(); delete m_pBackend; m_pBackend = 0x0; + + // delete the command buffers + for(int i = 0; i < NUM_CMDBUFFERS; i++) + delete m_apCommandBuffers[i]; } void CGraphics_Threaded::Minimize() diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 9f5f442d..51148f0f 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -46,9 +46,10 @@ class CCommandBuffer unsigned DataUsed() { return m_Used; } }; +public: CBuffer m_CmdBuffer; CBuffer m_DataBuffer; -public: + enum { MAX_TEXTURES=1024*4, @@ -251,7 +252,7 @@ public: } template<class T> - void AddCommand(const T &Command) + bool AddCommand(const T &Command) { // make sure that we don't do something stupid like ->AddCommand(&Cmd); (void)static_cast<const SCommand *>(&Command); @@ -259,9 +260,10 @@ public: // allocate and copy the command into the buffer SCommand *pCmd = (SCommand *)m_CmdBuffer.Alloc(sizeof(Command)); if(!pCmd) - return; + return false; mem_copy(pCmd, &Command, sizeof(Command)); pCmd->m_Size = sizeof(Command); + return true; } SCommand *GetCommand(unsigned *pIndex) @@ -278,7 +280,7 @@ public: { m_CmdBuffer.Reset(); m_DataBuffer.Reset(); - } + } }; // interface for the graphics backend @@ -308,10 +310,21 @@ public: class CGraphics_Threaded : public IEngineGraphics { + enum + { + NUM_CMDBUFFERS = 2, + + MAX_VERTICES = 32*1024, + MAX_TEXTURES = 1024*4, + + DRAWING_QUADS=1, + DRAWING_LINES=2 + }; + CCommandBuffer::SState m_State; IGraphicsBackend *m_pBackend; - CCommandBuffer *m_apCommandBuffers[2]; + CCommandBuffer *m_apCommandBuffers[NUM_CMDBUFFERS]; CCommandBuffer *m_pCommandBuffer; unsigned m_CurrentCommandBuffer; @@ -319,15 +332,6 @@ class CGraphics_Threaded : public IEngineGraphics class IStorage *m_pStorage; class IConsole *m_pConsole; - enum - { - MAX_VERTICES = 32*1024, - MAX_TEXTURES = 1024*4, - - DRAWING_QUADS=1, - DRAWING_LINES=2 - }; - CCommandBuffer::SVertex m_aVertices[MAX_VERTICES]; int m_NumVertices; |