mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-20 22:41:36 +00:00
Add builtin to SourceVariableMapping
This commit is contained in:
@@ -2142,6 +2142,9 @@ void ShaderViewer::updateDebugState()
|
||||
{
|
||||
const SourceVariableMapping &sourceVar = m_Trace->sourceVars[globalVarIdx];
|
||||
|
||||
if(!sourceVar.variables.empty() && sourceVar.variables[0].type == DebugVariableType::Variable)
|
||||
continue;
|
||||
|
||||
for(const DebugVariableReference &r : sourceVar.variables)
|
||||
varsMapped.insert(r.name);
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ struct SourceVariableMapping
|
||||
bool operator==(const SourceVariableMapping &o) const
|
||||
{
|
||||
return name == o.name && type == o.type && rows == o.rows && columns == o.columns &&
|
||||
variables == o.variables;
|
||||
offset == o.offset && builtin == o.builtin && variables == o.variables;
|
||||
}
|
||||
bool operator<(const SourceVariableMapping &o) const
|
||||
{
|
||||
@@ -398,6 +398,10 @@ struct SourceVariableMapping
|
||||
return rows < o.rows;
|
||||
if(!(columns == o.columns))
|
||||
return columns < o.columns;
|
||||
if(!(offset == o.offset))
|
||||
return offset < o.offset;
|
||||
if(!(builtin == o.builtin))
|
||||
return builtin < o.builtin;
|
||||
if(!(variables == o.variables))
|
||||
return variables < o.variables;
|
||||
return false;
|
||||
@@ -410,14 +414,20 @@ struct SourceVariableMapping
|
||||
VarType type = VarType::Unknown;
|
||||
|
||||
DOCUMENT("The number of rows in this variable - 1 for vectors, >1 for matrices.");
|
||||
uint32_t rows;
|
||||
uint32_t rows = 0;
|
||||
|
||||
DOCUMENT("The number of columns in this variable.");
|
||||
uint32_t columns;
|
||||
uint32_t columns = 0;
|
||||
|
||||
DOCUMENT("The offset in the parent source variable, for struct members. Useful for sorting.");
|
||||
DOCUMENT(R"(The offset in the parent source variable, for struct members. Useful for sorting.
|
||||
|
||||
For builtin variables this can also indicate the index of the builtin (e.g. multiple color outputs).
|
||||
)");
|
||||
uint32_t offset;
|
||||
|
||||
DOCUMENT("The :class:`ShaderBuiltin` that this variable corresponds to.");
|
||||
ShaderBuiltin builtin = ShaderBuiltin::Undefined;
|
||||
|
||||
DOCUMENT(R"(The debug variables that the components of this high level variable map to. Multiple
|
||||
ranges could refer to the same variable if a contiguous range is mapped to - the mapping is
|
||||
component-by-component to greatly simplify algorithms at the expense of a small amount of storage
|
||||
|
||||
@@ -4756,8 +4756,6 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC
|
||||
|
||||
ThreadState &state = activeLane();
|
||||
|
||||
bool hasSourceMapping = dxbc->GetDebugInfo() && dxbc->GetDebugInfo()->HasSourceMapping();
|
||||
|
||||
int32_t maxReg = -1;
|
||||
for(const SigParameter &sig : dxbc->GetReflection()->InputSig)
|
||||
{
|
||||
@@ -4810,6 +4808,9 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = sig.compCount;
|
||||
sourcemap.variables.reserve(sig.compCount);
|
||||
sourcemap.builtin = sig.systemValue;
|
||||
if(sig.systemValue != ShaderBuiltin::Undefined)
|
||||
sourcemap.offset = sig.regIndex;
|
||||
|
||||
for(uint16_t c = 0; c < 4; c++)
|
||||
{
|
||||
@@ -4841,6 +4842,7 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC
|
||||
sourcemap.type = VarType::UInt;
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = 1;
|
||||
sourcemap.builtin = ShaderBuiltin::MSAACoverage;
|
||||
DebugVariableReference ref;
|
||||
ref.type = DebugVariableType::Input;
|
||||
ref.name = state.inputs.back().name;
|
||||
@@ -4906,75 +4908,74 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC
|
||||
else
|
||||
dst.columns = RDCMAX(dst.columns, v.columns);
|
||||
|
||||
// if we don't have any debug info we can at least map to the semantic to give a better name
|
||||
// than the raw register from the reflection info, at least for normal outputs
|
||||
if(!hasSourceMapping)
|
||||
if(type == DXBCBytecode::TYPE_OUTPUT)
|
||||
{
|
||||
if(type == DXBCBytecode::TYPE_OUTPUT)
|
||||
SourceVariableMapping sourcemap;
|
||||
sourcemap.name = sig.semanticIdxName;
|
||||
if(sourcemap.name.empty() && sig.systemValue != ShaderBuiltin::Undefined)
|
||||
sourcemap.name = ToStr(sig.systemValue);
|
||||
sourcemap.type = v.type;
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = sig.compCount;
|
||||
sourcemap.builtin = sig.systemValue;
|
||||
if(sig.systemValue != ShaderBuiltin::Undefined)
|
||||
sourcemap.offset = sig.regIndex;
|
||||
sourcemap.variables.reserve(sig.compCount);
|
||||
|
||||
for(uint16_t c = 0; c < 4; c++)
|
||||
{
|
||||
SourceVariableMapping sourcemap;
|
||||
sourcemap.name = sig.semanticIdxName;
|
||||
if(sourcemap.name.empty() && sig.systemValue != ShaderBuiltin::Undefined)
|
||||
sourcemap.name = ToStr(sig.systemValue);
|
||||
sourcemap.type = v.type;
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = sig.compCount;
|
||||
sourcemap.variables.reserve(sig.compCount);
|
||||
|
||||
for(uint16_t c = 0; c < 4; c++)
|
||||
if(sig.regChannelMask & (1 << c))
|
||||
{
|
||||
if(sig.regChannelMask & (1 << c))
|
||||
{
|
||||
DebugVariableReference ref;
|
||||
ref.type = DebugVariableType::Variable;
|
||||
ref.name = v.name;
|
||||
ref.component = c;
|
||||
sourcemap.variables.push_back(ref);
|
||||
}
|
||||
DebugVariableReference ref;
|
||||
ref.type = DebugVariableType::Variable;
|
||||
ref.name = v.name;
|
||||
ref.component = c;
|
||||
sourcemap.variables.push_back(ref);
|
||||
}
|
||||
|
||||
ret->sourceVars.push_back(sourcemap);
|
||||
}
|
||||
else
|
||||
|
||||
ret->sourceVars.push_back(sourcemap);
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceVariableMapping sourcemap;
|
||||
|
||||
if(sig.systemValue == ShaderBuiltin::DepthOutput)
|
||||
{
|
||||
SourceVariableMapping sourcemap;
|
||||
|
||||
if(sig.systemValue == ShaderBuiltin::DepthOutput)
|
||||
{
|
||||
sourcemap.name = "SV_Depth";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::DepthOutputLessEqual)
|
||||
{
|
||||
sourcemap.name = "SV_DepthLessEqual";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::DepthOutputGreaterEqual)
|
||||
{
|
||||
sourcemap.name = "SV_DepthGreaterEqual";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::MSAACoverage)
|
||||
{
|
||||
sourcemap.name = "SV_Coverage";
|
||||
sourcemap.type = VarType::UInt;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::StencilReference)
|
||||
{
|
||||
sourcemap.name = "SV_StencilRef";
|
||||
sourcemap.type = VarType::UInt;
|
||||
}
|
||||
|
||||
// all these variables are 1 scalar component
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = 1;
|
||||
DebugVariableReference ref;
|
||||
ref.type = DebugVariableType::Variable;
|
||||
ref.name = v.name;
|
||||
sourcemap.variables.push_back(ref);
|
||||
|
||||
ret->sourceVars.push_back(sourcemap);
|
||||
sourcemap.name = "SV_Depth";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::DepthOutputLessEqual)
|
||||
{
|
||||
sourcemap.name = "SV_DepthLessEqual";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::DepthOutputGreaterEqual)
|
||||
{
|
||||
sourcemap.name = "SV_DepthGreaterEqual";
|
||||
sourcemap.type = VarType::Float;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::MSAACoverage)
|
||||
{
|
||||
sourcemap.name = "SV_Coverage";
|
||||
sourcemap.type = VarType::UInt;
|
||||
}
|
||||
else if(sig.systemValue == ShaderBuiltin::StencilReference)
|
||||
{
|
||||
sourcemap.name = "SV_StencilRef";
|
||||
sourcemap.type = VarType::UInt;
|
||||
}
|
||||
|
||||
// all these variables are 1 scalar component
|
||||
sourcemap.rows = 1;
|
||||
sourcemap.columns = 1;
|
||||
sourcemap.builtin = sig.systemValue;
|
||||
DebugVariableReference ref;
|
||||
ref.type = DebugVariableType::Variable;
|
||||
ref.name = v.name;
|
||||
sourcemap.variables.push_back(ref);
|
||||
|
||||
ret->sourceVars.push_back(sourcemap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -357,9 +357,10 @@ void DoSerialise(SerialiserType &ser, SourceVariableMapping &el)
|
||||
SERIALISE_MEMBER(rows);
|
||||
SERIALISE_MEMBER(columns);
|
||||
SERIALISE_MEMBER(offset);
|
||||
SERIALISE_MEMBER(builtin);
|
||||
SERIALISE_MEMBER(variables);
|
||||
|
||||
SIZE_CHECK(64);
|
||||
SIZE_CHECK(72);
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
|
||||
Reference in New Issue
Block a user