From 446f0ee4a6f70d948d7e326c18befb298d369251 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 25 Oct 2015 13:11:48 +0100 Subject: [PATCH] Record glUseProgramStages 'live' if it happens mid-frame. Refs #160 --- .../driver/gl/wrappers/gl_shader_funcs.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index 4e61549e5..ac9af5923 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -929,7 +929,35 @@ void WrappedOpenGL::glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuin GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramPipeRes(GetCtx(), pipeline)); RDCASSERT(record); - record->AddChunk(scope.Get()); + + if(m_State == WRITING_CAPFRAME) + { + m_ContextRecord->AddChunk(scope.Get()); + } + else + { + // USE_PROGRAMSTAGES is one of the few kinds of chunk that are + // recorded to pipeline records, so we can probably find previous + // uses (if it's been constantly rebound instead of once at init + // time) that can be popped as redundant + record->LockChunks(); + while(true) + { + Chunk *end = record->GetLastChunk(); + + if(end->GetChunkType() == USE_PROGRAMSTAGES) + { + SAFE_DELETE(end); + record->PopChunk(); + continue; + } + + break; + } + record->UnlockChunks(); + + record->AddChunk(scope.Get()); + } if(program) {