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).
This commit is contained in:
baldurk
2017-04-24 12:52:15 +01:00
parent a4ae6c8db8
commit dafb3363ab
+13
View File
@@ -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);