diff --git a/renderdoc/driver/shaders/dxbc/dxbc_bytecode.h b/renderdoc/driver/shaders/dxbc/dxbc_bytecode.h index d3ef0651c..e5fe0ebd1 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_bytecode.h +++ b/renderdoc/driver/shaders/dxbc/dxbc_bytecode.h @@ -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; /////////////////////////////////////// diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index e3f86b6af..59e5760a2 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -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]; diff --git a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp index 9f1b9910f..13dbf2b58 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp @@ -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())