Add helper function to compare resource/sampler operands by identifier

This commit is contained in:
baldurk
2020-02-18 19:18:22 +00:00
parent 83d77ea543
commit b377d70b1d
3 changed files with 22 additions and 6 deletions
@@ -663,6 +663,10 @@ struct Operand
bool operator==(const Operand &o) const;
// helper function that compares operands by their type and first index (for resources the logical
// identifier - excluding register range on SM5.1)
bool sameResource(const Operand &o) const;
rdcstr toString(const DXBC::Reflection *reflection, ToString flags) const;
///////////////////////////////////////
+4 -6
View File
@@ -3690,14 +3690,13 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper,
const Declaration &decl = program->GetDeclaration(i);
if(decl.declaration == OPCODE_DCL_SAMPLER && op.operands.size() > 3 &&
op.operands[3].indices[0] == decl.operand.indices[0])
decl.operand.sameResource(op.operands[3]))
{
samplerMode = decl.samplerMode;
samplerBinding = GetBindingSlotForDeclaration(*program, decl);
}
if(decl.dim == RESOURCE_DIMENSION_BUFFER && op.operation == OPCODE_LD &&
decl.declaration == OPCODE_DCL_RESOURCE && decl.operand.type == TYPE_RESOURCE &&
decl.operand.indices.size() > 0 && decl.operand.indices[0] == op.operands[2].indices[0])
if(op.operation == OPCODE_LD && decl.dim == RESOURCE_DIMENSION_BUFFER &&
decl.declaration == OPCODE_DCL_RESOURCE && decl.operand.sameResource(op.operands[2]))
{
resourceDim = decl.dim;
@@ -3753,8 +3752,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper,
return;
}
if(decl.declaration == OPCODE_DCL_RESOURCE && decl.operand.type == TYPE_RESOURCE &&
decl.operand.indices.size() > 0 && decl.operand.indices[0] == op.operands[2].indices[0])
if(decl.declaration == OPCODE_DCL_RESOURCE && decl.operand.sameResource(op.operands[2]))
{
resourceDim = decl.dim;
resourceRetType = decl.resType[0];
@@ -276,6 +276,20 @@ bool Operand::operator==(const Operand &o) const
return true;
}
bool Operand::sameResource(const Operand &o) const
{
if(type != o.type)
return false;
if(indices.size() == o.indices.size() && indices.empty())
return true;
if(indices.size() < 1 || o.indices.size() < 1)
return false;
return indices[0] == indices[1];
}
void Program::FetchTypeVersion()
{
if(m_HexDump.empty())