Add fixed bindpoint information to shader reflection data

* Previously this was provided by the ShaderBindpointMapping, but since we plan
  to remove that we add the information here. These will be purely for
  informational purposes and will not be used to look up bound resources etc.
  They exist for display only, or for API-specific interpretation if e.g. the
  bindpoint is known ahead of time it can be identified here without having to
  jump through hoops to get which descriptor a given bind accesses and get the
  register number for that descriptor.
* On OpenGL this information will not be present because bindings are mutable
  (even if they are declared in the shader). The only way to identify a
  particular binding by register will be with those hoops
This commit is contained in:
baldurk
2024-04-10 18:58:50 +01:00
parent d88aad8fc2
commit bbbfb5f3d2
4 changed files with 179 additions and 8 deletions
@@ -252,6 +252,10 @@ static void MakeResourceList(bool srv, DXBC::DXBCContainer *dxbc,
res.bindPoint = (int32_t)i;
res.fixedBindNumber = r.reg;
res.fixedBindSetOrSpace = r.space;
res.bindArraySize = r.bindCount == 0 ? ~0U : r.bindCount;
Bindpoint map;
map.arraySize = r.bindCount == 0 ? ~0U : r.bindCount;
map.bindset = r.space;
@@ -398,6 +402,10 @@ void MakeShaderReflection(DXBC::DXBCContainer *dxbc, ShaderReflection *refl,
cb.byteSize = dxbcRefl->CBuffers[i].descriptor.byteSize;
cb.bindPoint = (int32_t)i;
cb.fixedBindNumber = dxbcRefl->CBuffers[i].reg;
cb.fixedBindSetOrSpace = dxbcRefl->CBuffers[i].space;
cb.bindArraySize = dxbcRefl->CBuffers[i].bindCount;
Bindpoint map;
map.arraySize = dxbcRefl->CBuffers[i].bindCount;
map.bindset = dxbcRefl->CBuffers[i].space;
@@ -424,6 +432,10 @@ void MakeShaderReflection(DXBC::DXBCContainer *dxbc, ShaderReflection *refl,
s.name = dxbcRefl->Samplers[i].name;
s.bindPoint = (int32_t)i;
s.fixedBindNumber = dxbcRefl->Samplers[i].reg;
s.fixedBindSetOrSpace = dxbcRefl->Samplers[i].space;
s.bindArraySize = dxbcRefl->Samplers[i].bindCount;
Bindpoint map;
map.arraySize = 1;
map.bindset = dxbcRefl->Samplers[i].space;
@@ -1407,6 +1407,10 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
bindmap.bindset = 0;
bindmap.bind = GetBinding(decorations[global.id].binding);
res.fixedBindSetOrSpace = 0;
res.fixedBindNumber = GetBinding(decorations[global.id].binding);
res.bindArraySize = isArray ? arraySize : 1;
rwresources.push_back(shaderrespair(bindmap, res));
}
else if(varType->IsOpaqueType())
@@ -1424,6 +1428,10 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
if(res.name.empty())
res.name = StringFormat::Fmt("res%u", global.id.value());
res.fixedBindSetOrSpace = bindmap.bindset;
res.fixedBindNumber = bindmap.bind;
res.bindArraySize = isArray ? arraySize : 1;
if(varType->type == DataType::SamplerType)
{
res.resType = TextureType::Unknown;
@@ -1544,6 +1552,10 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
res.name = StringFormat::Fmt("ssbo%u", global.id.value());
res.resType = TextureType::Buffer;
res.fixedBindNumber = bindmap.bind;
res.fixedBindSetOrSpace = bindmap.bindset;
res.bindArraySize = isArray ? arraySize : 1;
res.variableType.columns = 0;
res.variableType.rows = 0;
res.variableType.baseType = VarType::Float;
@@ -1564,6 +1576,10 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
cblock.bufferBacked = !pushConst;
cblock.inlineDataBytes = pushConst;
cblock.fixedBindNumber = bindmap.bind;
cblock.fixedBindSetOrSpace = bindmap.bindset;
cblock.bindArraySize = isArray ? arraySize : 1;
MakeConstantBlockVariables(effectiveStorage, *varType, 0, 0, cblock.variables,
pointerTypes, specInfo);
@@ -1616,6 +1632,8 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
specblock.inlineDataBytes = true;
specblock.compileConstants = true;
specblock.byteSize = 0;
// set the binding number to some huge value to try to sort it to the end
specblock.fixedBindNumber = 0x8000000;
Bindpoint bindmap;
@@ -1636,6 +1654,8 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
globalsblock.inlineDataBytes = false;
globalsblock.byteSize = (uint32_t)globalsblock.variables.size();
globalsblock.bindPoint = (int)cblocks.size();
// set the binding number to some huge value to try to sort it to the end
globalsblock.fixedBindNumber = 0x8000001;
Bindpoint bindmap;
bindmap.bindset = 0;