From 057e36aefa653fe23353e069abb8ce5a9e1af0bb Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 2 Jan 2017 11:28:06 +0000 Subject: [PATCH] Reset disassembly/reflection of shaders when recompiled. Refs #470 * In GL various really really stupid options for changing shaders and recompiling and relinking is possible. * We don't support the whole giant trash fire, but we can at least handle re-compiling a shader within the same program (so the original source isn't used anywhere and can be safely rewritten). --- renderdoc/driver/gl/wrappers/gl_shader_funcs.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; }