From dafb3363aba56067f62729d31657b9b18a730cb3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 24 Apr 2017 12:52:15 +0100 Subject: [PATCH] Fix a shader editing issue - when copying fragdata bindings ignore dupes * I'm not clear on if this is safe or sensible - somehow the source program can report multiple outputs bound to the same index (e.g. 0) but that's illegal to set explicitly ourselves. So we just ignore the subsequent variables and hope the first one we find is the valid one. * The other alternative is to set the subsequent variables to some bind higher than all of the rest, or fill in holes (e.g. if we see 0, 0, 1 then bind the second 0 to 2). --- renderdoc/driver/gl/gl_common.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/renderdoc/driver/gl/gl_common.cpp b/renderdoc/driver/gl/gl_common.cpp index 6e149812a..e6bc67f4f 100644 --- a/renderdoc/driver/gl/gl_common.cpp +++ b/renderdoc/driver/gl/gl_common.cpp @@ -2365,6 +2365,8 @@ void CopyProgramAttribBindings(const GLHookSet &gl, GLuint progsrc, GLuint progd void CopyProgramFragDataBindings(const GLHookSet &gl, GLuint progsrc, GLuint progdst, ShaderReflection *refl) { + uint64_t used = 0; + // copy over fragdata bindings for(int32_t i = 0; i < refl->OutputSig.count; i++) { @@ -2375,6 +2377,17 @@ void CopyProgramFragDataBindings(const GLHookSet &gl, GLuint progsrc, GLuint pro GLint idx = gl.glGetFragDataLocation(progsrc, refl->OutputSig[i].varName.elems); if(idx >= 0) { + uint64_t mask = 1ULL << idx; + + if(used & mask) + { + RDCWARN("Multiple signatures bound to output %d, ignoring %s", i, + refl->OutputSig[i].varName.elems); + continue; + } + + used |= mask; + if(gl.glBindFragDataLocation) { gl.glBindFragDataLocation(progdst, (GLuint)idx, refl->OutputSig[i].varName.elems);