diff --git a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp index a7b1c3c1b..225f48257 100644 --- a/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp @@ -183,6 +183,21 @@ bool WrappedOpenGL::Serialise_glShaderSource(GLuint shader, GLsizei count, m_Real.glShaderSource(GetResourceManager()->GetLiveResource(id).name, Count, strings, NULL); + // if we've already disassembled this shader, undo all that. + // Note this means we don't support compiling the same shader multiple times + // attached to different programs, but that is *utterly crazy* and anyone + // who tries to actually do that should be ashamed. + // Doing this means we support the case of recompiling a shader different ways + // and relinking a program before use, which is still moderately crazy and + // so people who do that should be moderately ashamed. + if(m_Shaders[liveId].prog) + { + m_Real.glDeleteProgram(m_Shaders[liveId].prog); + m_Shaders[liveId].prog = 0; + m_Shaders[liveId].spirv = SPVModule(); + m_Shaders[liveId].reflection = ShaderReflection(); + } + delete[] strings; }