Handle SPIR-V GL shaders with no location on texture binds. Closes #3405

* Since GL doesn't have sets, use the fixedBindSetOrSpace to namespace bindings
  with locations (that need to be queried) from bindings without locations
  (which have a fixed bind). Prior to the descriptor refactor this was indiated
  with negative binds.
This commit is contained in:
baldurk
2024-08-12 12:42:23 +01:00
parent 9607410b94
commit 808a14dede
2 changed files with 24 additions and 5 deletions
+20 -4
View File
@@ -2485,11 +2485,25 @@ void GetCurrentBinding(GLuint curProg, ShaderReflection *refl, const ShaderResou
if(refl->encoding == ShaderEncoding::OpenGLSPIRV)
{
if(resource.isTexture && resource.fixedBindNumber != ~0U)
slot = 0;
if(resource.isTexture)
{
GL.glGetUniformiv(curProg, resource.fixedBindNumber, dummyReadback);
slot = dummyReadback[0];
used = true;
if(resource.fixedBindNumber == ~0U)
{
slot = 0;
}
// the fixedBindSetOrSpace is set to 1 if a location is provided (whether or not there's a fixed binding)
else if(resource.fixedBindSetOrSpace == 0)
{
slot = resource.fixedBindNumber;
used = true;
}
else
{
GL.glGetUniformiv(curProg, resource.fixedBindNumber, dummyReadback);
slot = dummyReadback[0];
used = true;
}
}
}
else if(resource.isReadOnly)
@@ -2669,6 +2683,8 @@ void GetCurrentBinding(GLuint curProg, ShaderReflection *refl, const ConstantBlo
{
// It's fuzzy on whether UBOs can be remapped with glUniformBlockBinding so for now we hope that
// anyone using UBOs and SPIR-V will at least specify immutable bindings in the SPIR-V.
slot = cblock.fixedBindNumber;
used = true;
return;
}
@@ -1386,9 +1386,12 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
Decorations::Flags flags = Decorations::Flags(
decorations[global.id].flags & (Decorations::HasLocation | Decorations::HasBinding));
bindset = 0;
if(flags == Decorations::HasLocation)
{
bind = decorations[global.id].location;
bindset = 1;
}
else if(flags == Decorations::NoFlags)
{
@@ -1422,7 +1425,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
res.variableType.baseType = VarType::UInt;
res.variableType.name = varType->name;
res.fixedBindSetOrSpace = 0;
res.fixedBindSetOrSpace = bindset;
res.fixedBindNumber = GetBinding(decorations[global.id].binding);
res.bindArraySize = arraySize;