diff --git a/renderdoc/api/replay/shader_types.h b/renderdoc/api/replay/shader_types.h index 0508fe81c..e277bb25c 100644 --- a/renderdoc/api/replay/shader_types.h +++ b/renderdoc/api/replay/shader_types.h @@ -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 && - offset == o.offset && builtin == o.builtin && variables == o.variables; + offset == o.offset && signatureIndex == o.signatureIndex && variables == o.variables; } bool operator<(const SourceVariableMapping &o) const { @@ -400,8 +400,8 @@ struct SourceVariableMapping return columns < o.columns; if(!(offset == o.offset)) return offset < o.offset; - if(!(builtin == o.builtin)) - return builtin < o.builtin; + if(!(signatureIndex == o.signatureIndex)) + return signatureIndex < o.signatureIndex; if(!(variables == o.variables)) return variables < o.variables; return false; @@ -419,14 +419,17 @@ struct SourceVariableMapping DOCUMENT("The number of columns in this variable."); uint32_t columns = 0; - 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). -)"); + DOCUMENT("The offset in the parent source variable, for struct members. Useful for sorting."); uint32_t offset; - DOCUMENT("The :class:`ShaderBuiltin` that this variable corresponds to."); - ShaderBuiltin builtin = ShaderBuiltin::Undefined; + DOCUMENT(R"(The index in the input or output signature of the shader that this variable represents. + +The type of signature can be disambiguated by the debug variables referenced - inputs are stored +separately. + +This will be set to -1 if the variable is not part of either signature. +)"); + int32_t signatureIndex = -1; 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 @@ -634,6 +637,9 @@ struct ShaderDebugTrace ShaderDebugTrace(const ShaderDebugTrace &) = default; ShaderDebugTrace &operator=(const ShaderDebugTrace &) = default; + DOCUMENT("The shader stage being debugged in this trace"); + ShaderStage stage; + DOCUMENT("The input variables for this shader as a list of :class:`ShaderVariable`."); rdcarray inputs; diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 86bd11a1b..0f1a01d89 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -4809,6 +4809,7 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC { ShaderDebugTrace *ret = new ShaderDebugTrace; ret->debugger = this; + ret->stage = refl.stage; this->dxbc = dxbcContainer; this->activeLaneIndex = activeIndex; @@ -4835,8 +4836,10 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC if(maxReg >= 0 || inputCoverage) { state.inputs.resize(maxReg + 1 + (inputCoverage ? 1 : 0)); - for(const SigParameter &sig : dxbc->GetReflection()->InputSig) + for(int32_t sigIdx = 0; sigIdx < dxbc->GetReflection()->InputSig.size(); sigIdx++) { + const SigParameter &sig = dxbc->GetReflection()->InputSig[sigIdx]; + ShaderVariable v; v.name = dxbc->GetDXBCByteCode()->GetRegisterName(DXBCBytecode::TYPE_INPUT, sig.regIndex); @@ -4874,9 +4877,7 @@ 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; + sourcemap.signatureIndex = sigIdx; for(uint16_t c = 0; c < 4; c++) { @@ -4908,7 +4909,8 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC sourcemap.type = VarType::UInt; sourcemap.rows = 1; sourcemap.columns = 1; - sourcemap.builtin = ShaderBuiltin::MSAACoverage; + // no corresponding signature element for this - maybe we should generate one? + sourcemap.signatureIndex = -1; DebugVariableReference ref; ref.type = DebugVariableType::Input; ref.name = state.inputs.back().name; @@ -4920,8 +4922,10 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC } // Set up outputs in the shader state - for(const SigParameter &sig : dxbc->GetReflection()->OutputSig) + for(int32_t sigIdx = 0; sigIdx < dxbc->GetReflection()->OutputSig.size(); sigIdx++) { + const SigParameter &sig = dxbc->GetReflection()->OutputSig[sigIdx]; + DXBCBytecode::OperandType type = DXBCBytecode::TYPE_OUTPUT; if(sig.systemValue == ShaderBuiltin::DepthOutput) @@ -4983,9 +4987,7 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC 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.signatureIndex = sigIdx; sourcemap.variables.reserve(sig.compCount); for(uint16_t c = 0; c < 4; c++) @@ -5035,7 +5037,7 @@ ShaderDebugTrace *InterpretDebugger::BeginDebug(const DXBC::DXBCContainer *dxbcC // all these variables are 1 scalar component sourcemap.rows = 1; sourcemap.columns = 1; - sourcemap.builtin = sig.systemValue; + sourcemap.signatureIndex = sigIdx; DebugVariableReference ref; ref.type = DebugVariableType::Variable; ref.name = v.name; diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 473b4470e..a4f252b8a 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -28,6 +28,9 @@ #include "spirv_common.h" #include "spirv_processor.h" +struct SPIRVInterfaceAccess; +struct SPIRVPatchData; + namespace rdcspv { class DebugAPIWrapper @@ -134,7 +137,7 @@ public: ShaderDebugTrace *BeginDebug(DebugAPIWrapper *apiWrapper, const ShaderStage stage, const rdcstr &entryPoint, const rdcarray &specInfo, const std::map &instructionLines, - uint32_t activeIndex); + const SPIRVPatchData &patchData, uint32_t activeIndex); rdcarray ContinueDebug(); @@ -171,6 +174,7 @@ private: const DataType &inType, ShaderVariable &outVar); void AddSourceVars(rdcarray &sourceVars, const DataType &inType, const rdcstr &sourceName, const rdcstr &varName, uint32_t &offset); + void MakeSignatureNames(const rdcarray &sigList, rdcarray &sigNames); ///////////////////////////////////////////////////////// // debug data diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index 1936cf073..917a41692 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -25,6 +25,7 @@ #include "spirv_debug.h" #include "common/formatting.h" #include "spirv_op_helpers.h" +#include "spirv_reflect.h" static uint32_t VarByteSize(const ShaderVariable &var) { @@ -85,11 +86,46 @@ const rdcspv::DataType &Debugger::GetType(Id typeId) return dataTypes[typeId]; } +void Debugger::MakeSignatureNames(const rdcarray &sigList, + rdcarray &sigNames) +{ + for(const SPIRVInterfaceAccess &sig : sigList) + { + rdcstr name = GetRawName(sig.ID); + + const DataType *type = &dataTypes[idTypes[sig.ID]]; + + RDCASSERT(type->type == DataType::PointerType); + type = &dataTypes[type->InnerType()]; + + for(uint32_t chain : sig.accessChain) + { + if(type->type == DataType::ArrayType) + { + name += StringFormat::Fmt("[%u]", chain); + type = &dataTypes[type->InnerType()]; + } + else if(type->type == DataType::StructType) + { + name += StringFormat::Fmt("._child%u", chain); + type = &dataTypes[type->children[chain].type]; + } + else + { + RDCERR("Got access chain with non-aggregate type in interface."); + break; + } + } + + sigNames.push_back(name); + } +} + ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const ShaderStage stage, const rdcstr &entryPoint, const rdcarray &specInfo, const std::map &instructionLines, - uint32_t activeIndex) + const SPIRVPatchData &patchData, uint32_t activeIndex) { Id entryId = entryLookup[entryPoint]; @@ -179,6 +215,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader ShaderDebugTrace *ret = new ShaderDebugTrace; ret->debugger = this; + ret->stage = stage; this->activeLaneIndex = activeIndex; this->stage = stage; this->apiWrapper = apiWrapper; @@ -197,6 +234,11 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader for(auto it = constants.begin(); it != constants.end(); it++) active.ids[it->first] = EvaluateConstant(it->first, specInfo); + rdcarray inputSigNames, outputSigNames; + + MakeSignatureNames(patchData.inputs, inputSigNames); + MakeSignatureNames(patchData.outputs, outputSigNames); + rdcarray inputIDs, outputIDs, cbufferIDs; // allocate storage for globals with opaque storage classes, and prepare to set up pointers to @@ -226,8 +268,13 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader // I/O variable structs don't have offsets, so give them fake offsets to ensure they sort as // we want. Since FillVariable is depth-first the source vars are already in order. + // We also add the signature index for(size_t i = oldSize; i < globalSourceVars.size(); i++) + { globalSourceVars[i].offset = uint32_t(i - oldSize); + globalSourceVars[i].signatureIndex = + (isInput ? inputSigNames : outputSigNames).indexOf(globalSourceVars[i].variables[0].name); + } if(isInput) { @@ -904,15 +951,16 @@ void Debugger::AllocateVariable(const Decorations &varDecorations, const Decorat for(uint32_t x = 0; x < uint32_t(outVar.rows) * outVar.columns; x++) sourceVar.variables.push_back(DebugVariableReference(sourceVarType, outVar.name, x)); + ShaderBuiltin builtin = ShaderBuiltin::Undefined; if(curDecorations.flags & Decorations::HasBuiltIn) - sourceVar.builtin = MakeShaderBuiltin(stage, curDecorations.builtIn); + builtin = MakeShaderBuiltin(stage, curDecorations.builtIn); globalSourceVars.push_back(sourceVar); if(sourceVarType == DebugVariableType::Input) { apiWrapper->FillInputValue( - outVar, sourceVar.builtin, + outVar, builtin, (curDecorations.flags & Decorations::HasLocation) ? curDecorations.location : 0, (curDecorations.flags & Decorations::HasOffset) ? curDecorations.offset : 0); } diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp index 9f126f013..65df27aa2 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.cpp @@ -62,7 +62,7 @@ void AddXFBAnnotations(const ShaderReflection &refl, const SPIRVPatchData &patch editor.Prepare(); rdcarray outsig = refl.outputSignature; - rdcarray outpatch = patchData.outputs; + rdcarray outpatch = patchData.outputs; rdcspv::Id entryid; for(const rdcspv::EntryPoint &entry : editor.GetEntries()) @@ -815,7 +815,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st else childname += StringFormat::Fmt(".child%zu", i); - SPIRVPatchData::InterfaceAccess patch; + SPIRVInterfaceAccess patch; patch.accessChain = {i}; uint32_t dummy = 0; @@ -1180,7 +1180,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st for(size_t i = 0; i < inputs.size(); i++) reflection.inputSignature.push_back(inputs[indices[i]]); - rdcarray inPatch = patchData.inputs; + rdcarray inPatch = patchData.inputs; for(size_t i = 0; i < inputs.size(); i++) patchData.inputs[i] = inPatch[indices[i]]; } @@ -1196,7 +1196,7 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st for(size_t i = 0; i < outputs.size(); i++) reflection.outputSignature.push_back(outputs[indices[i]]); - rdcarray outPatch = patchData.outputs; + rdcarray outPatch = patchData.outputs; for(size_t i = 0; i < outputs.size(); i++) patchData.outputs[i] = outPatch[indices[i]]; } @@ -1452,9 +1452,8 @@ void Reflector::MakeConstantBlockVariable(ShaderConstant &outConst, void Reflector::AddSignatureParameter(const bool isInput, const ShaderStage stage, const Id globalID, const Id parentStructID, uint32_t ®Index, - const SPIRVPatchData::InterfaceAccess &parentPatch, - const rdcstr &varName, const DataType &type, - const Decorations &varDecorations, + const SPIRVInterfaceAccess &parentPatch, const rdcstr &varName, + const DataType &type, const Decorations &varDecorations, rdcarray &sigarray, SPIRVPatchData &patchData, const rdcarray &specInfo) const { @@ -1462,7 +1461,7 @@ void Reflector::AddSignatureParameter(const bool isInput, const ShaderStage stag sig.needSemanticIndex = false; - SPIRVPatchData::InterfaceAccess patch; + SPIRVInterfaceAccess patch; patch.accessChain = parentPatch.accessChain; patch.ID = globalID; patch.structID = parentStructID; diff --git a/renderdoc/driver/shaders/spirv/spirv_reflect.h b/renderdoc/driver/shaders/spirv/spirv_reflect.h index 91325b344..910fa6228 100644 --- a/renderdoc/driver/shaders/spirv/spirv_reflect.h +++ b/renderdoc/driver/shaders/spirv/spirv_reflect.h @@ -34,34 +34,34 @@ enum class ShaderBuiltin : uint32_t; struct ShaderReflection; struct ShaderBindpointMapping; +struct SPIRVInterfaceAccess +{ + // ID of the base variable + rdcspv::Id ID; + + // ID of the struct parent of this variable + rdcspv::Id structID; + + // member in the parent struct of this variable (for MemberDecorate) + uint32_t structMemberIndex = 0; + + // the access chain of indices + rdcarray accessChain; + + // this is an element of an array that's been exploded after [0]. + // i.e. this is false for non-arrays, and false for element [0] in an array, then true for + // elements [1], [2], [3], etc.. + bool isArraySubsequentElement = false; +}; + // extra information that goes along with a ShaderReflection that has extra information for SPIR-V // patching struct SPIRVPatchData { - struct InterfaceAccess - { - // ID of the base variable - rdcspv::Id ID; - - // ID of the struct parent of this variable - rdcspv::Id structID; - - // member in the parent struct of this variable (for MemberDecorate) - uint32_t structMemberIndex = 0; - - // the access chain of indices - rdcarray accessChain; - - // this is an element of an array that's been exploded after [0]. - // i.e. this is false for non-arrays, and false for element [0] in an array, then true for - // elements [1], [2], [3], etc.. - bool isArraySubsequentElement = false; - }; - // matches the input/output signature array, with details of where to fetch the output from in the // SPIR-V. - rdcarray inputs; - rdcarray outputs; + rdcarray inputs; + rdcarray outputs; // the output topology for tessellation and geometry shaders Topology outTopo = Topology::Unknown; @@ -109,10 +109,10 @@ private: const rdcarray &specInfo) const; void AddSignatureParameter(const bool isInput, const ShaderStage stage, const Id id, const Id structID, uint32_t ®Index, - const SPIRVPatchData::InterfaceAccess &parentPatch, - const rdcstr &varName, const DataType &type, - const Decorations &decorations, rdcarray &sigarray, - SPIRVPatchData &patchData, const rdcarray &specInfo) const; + const SPIRVInterfaceAccess &parentPatch, const rdcstr &varName, + const DataType &type, const Decorations &decorations, + rdcarray &sigarray, SPIRVPatchData &patchData, + const rdcarray &specInfo) const; rdcstr cmdline; DenseIdMap strings; diff --git a/renderdoc/driver/vulkan/vk_shaderdebug.cpp b/renderdoc/driver/vulkan/vk_shaderdebug.cpp index 7d5f97dbc..c4c18d43e 100644 --- a/renderdoc/driver/vulkan/vk_shaderdebug.cpp +++ b/renderdoc/driver/vulkan/vk_shaderdebug.cpp @@ -255,7 +255,7 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u rdcspv::Debugger *debugger = new rdcspv::Debugger; debugger->Parse(shader.spirv.GetSPIRV()); ShaderDebugTrace *ret = debugger->BeginDebug(apiWrapper, ShaderStage::Vertex, entryPoint, spec, - shadRefl.instructionLines, 0); + shadRefl.instructionLines, shadRefl.patchData, 0); return ret; } diff --git a/renderdoc/replay/renderdoc_serialise.inl b/renderdoc/replay/renderdoc_serialise.inl index c5808dcc3..1d0a60744 100644 --- a/renderdoc/replay/renderdoc_serialise.inl +++ b/renderdoc/replay/renderdoc_serialise.inl @@ -357,7 +357,7 @@ void DoSerialise(SerialiserType &ser, SourceVariableMapping &el) SERIALISE_MEMBER(rows); SERIALISE_MEMBER(columns); SERIALISE_MEMBER(offset); - SERIALISE_MEMBER(builtin); + SERIALISE_MEMBER(signatureIndex); SERIALISE_MEMBER(variables); SIZE_CHECK(72); @@ -401,6 +401,7 @@ void DoSerialise(SerialiserType &ser, ShaderDebugState &el) template void DoSerialise(SerialiserType &ser, ShaderDebugTrace &el) { + SERIALISE_MEMBER(stage); SERIALISE_MEMBER(inputs); SERIALISE_MEMBER(constantBlocks); SERIALISE_MEMBER(readOnlyResources); @@ -416,7 +417,7 @@ void DoSerialise(SerialiserType &ser, ShaderDebugTrace &el) if(ser.IsReading()) el.debugger = (ShaderDebugger *)debugger; - SIZE_CHECK(152); + SIZE_CHECK(160); } template diff --git a/util/test/rdtest/testcase.py b/util/test/rdtest/testcase.py index c6bdde628..9fe263632 100644 --- a/util/test/rdtest/testcase.py +++ b/util/test/rdtest/testcase.py @@ -458,6 +458,40 @@ class TestCase: return cycles, variables + def get_sig_index(self, signature, builtin: rd.ShaderBuiltin, reg_index: int = -1): + search = (builtin, reg_index) + signature_mapped = [(sig.systemValue, sig.regIndex) for sig in signature] + + if reg_index == -1: + search = builtin + signature_mapped = [x[0] for x in signature_mapped] + + if search in signature_mapped: + return signature_mapped.index(search) + return -1 + + def find_source_var(self, sourceVars, signatureIndex, varType): + vars = [x for x in sourceVars if x.signatureIndex == signatureIndex and x.variables[0].type == varType] + + if len(vars) == 0: + return None + + return vars[0] + + def find_input_source_var(self, trace: rd.ShaderDebugTrace, builtin: rd.ShaderBuiltin, reg_index: int = -1): + refl: rd.ShaderReflection = self.controller.GetPipelineState().GetShaderReflection(trace.stage) + + sig_index = self.get_sig_index(refl.inputSignature, builtin, reg_index) + + return self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Input) + + def find_output_source_var(self, trace: rd.ShaderDebugTrace, builtin: rd.ShaderBuiltin, reg_index: int = -1): + refl: rd.ShaderReflection = self.controller.GetPipelineState().GetShaderReflection(trace.stage) + + sig_index = self.get_sig_index(refl.outputSignature, builtin, reg_index) + + return self.find_source_var(trace.sourceVars, sig_index, rd.DebugVariableType.Variable) + def evalute_source_var(self, sourceVar: rd.SourceVariableMapping, debugVars): debugged = rd.ShaderVariable() debugged.name = sourceVar.name diff --git a/util/test/tests/D3D11/D3D11_PrimitiveID.py b/util/test/tests/D3D11/D3D11_PrimitiveID.py index 6f4980db7..0413ed03a 100644 --- a/util/test/tests/D3D11/D3D11_PrimitiveID.py +++ b/util/test/tests/D3D11/D3D11_PrimitiveID.py @@ -16,8 +16,8 @@ class D3D11_PrimitiveID(rdtest.TestCase): cycles, variables = self.process_trace(trace) # Find the SV_PrimitiveID variable - primInput = [var for var in sourceVars if var.builtin == rd.ShaderBuiltin.PrimitiveIndex] - if primInput == []: + primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex) + if primInput is None: # If we didn't find it, then we should be expecting a 0 if len(expected_prim) > 1 or expected_prim[0] is not 0: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( @@ -26,7 +26,7 @@ class D3D11_PrimitiveID(rdtest.TestCase): else: # Look up the matching register in the inputs, and see if the expected value matches inputs: List[rd.ShaderVariable] = list(trace.inputs) - primValue = [var for var in inputs if var.name == primInput[0].variables[0].name][0] + primValue = [var for var in inputs if var.name == primInput.variables[0].name][0] if primValue.value.uv[0] not in expected_prim: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( str(expected_prim), x, y, primValue.value.uv[0])) @@ -35,7 +35,7 @@ class D3D11_PrimitiveID(rdtest.TestCase): # Compare shader debug output against an expected value instead of the RT's output, # since we're testing overlapping primitives in a single draw if expected_output is not None: - output = [var for var in sourceVars if var.builtin == rd.ShaderBuiltin.ColorOutput and var.offset == 0][0] + output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evalute_source_var(output, variables) if debugged.value.fv[0:4] != expected_output: rdtest.log.error("Expected value {} at {},{} did not match actual {}.".format( diff --git a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py index 89eaa5a39..9d8042773 100644 --- a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py @@ -22,11 +22,9 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): trace: rd.ShaderDebugTrace = self.controller.DebugPixel(4 * test, 0, rd.ReplayController.NoPreference, rd.ReplayController.NoPreference) - sourceVars: List[rd.SourceVariableMapping] = list(trace.sourceVars) - cycles, variables = self.process_trace(trace) - output = [x for x in sourceVars if x.builtin == rd.ShaderBuiltin.ColorOutput and x.offset == 0][0] + output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evalute_source_var(output, variables) diff --git a/util/test/tests/D3D12/D3D12_PrimitiveID.py b/util/test/tests/D3D12/D3D12_PrimitiveID.py index 1720d4d98..4f30d9f31 100644 --- a/util/test/tests/D3D12/D3D12_PrimitiveID.py +++ b/util/test/tests/D3D12/D3D12_PrimitiveID.py @@ -15,12 +15,11 @@ class D3D12_PrimitiveID(rdtest.TestCase): trace: rd.ShaderDebugTrace = self.controller.DebugPixel(x, y, rd.ReplayController.NoPreference, prim) - sourceVars: List[rd.SourceVariableMapping] = list(trace.sourceVars) cycles, variables = self.process_trace(trace) # Find the SV_PrimitiveID variable - primInput = [var for var in sourceVars if var.builtin == rd.ShaderBuiltin.PrimitiveIndex] - if primInput == []: + primInput = self.find_input_source_var(trace, rd.ShaderBuiltin.PrimitiveIndex) + if primInput is None: # If we didn't find it, then we should be expecting a 0 if len(expected_prim) > 1 or expected_prim[0] is not 0: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( @@ -29,7 +28,7 @@ class D3D12_PrimitiveID(rdtest.TestCase): else: # Look up the matching register in the inputs, and see if the expected value matches inputs: List[rd.ShaderVariable] = list(trace.inputs) - primValue = [var for var in inputs if var.name == primInput[0].variables[0].name][0] + primValue = [var for var in inputs if var.name == primInput.variables[0].name][0] if primValue.value.uv[0] not in expected_prim: rdtest.log.error("Expected prim {} at {},{} did not match actual prim {}.".format( str(expected_prim), x, y, primValue.value.uv[0])) @@ -38,7 +37,7 @@ class D3D12_PrimitiveID(rdtest.TestCase): # Compare shader debug output against an expected value instead of the RT's output, # since we're testing overlapping primitives in a single draw if expected_output is not None: - output = [var for var in sourceVars if var.builtin == rd.ShaderBuiltin.ColorOutput and var.offset == 0][0] + output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evalute_source_var(output, variables) if debugged.value.fv[0:4] != expected_output: rdtest.log.error("Expected value {} at {},{} did not match actual {}.".format( diff --git a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py index 96d6389b6..af82ddf5d 100644 --- a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py @@ -31,11 +31,9 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): trace: rd.ShaderDebugTrace = self.controller.DebugPixel(4 * test, 0, rd.ReplayController.NoPreference, rd.ReplayController.NoPreference) - sourceVars: List[rd.SourceVariableMapping] = list(trace.sourceVars) - cycles, variables = self.process_trace(trace) - output = [x for x in sourceVars if x.builtin == rd.ShaderBuiltin.ColorOutput and x.offset == 0][0] + output = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, 0) debugged = self.evalute_source_var(output, variables) diff --git a/util/test/tests/Iter_Test.py b/util/test/tests/Iter_Test.py index dfbe13d41..c1b7c2597 100644 --- a/util/test/tests/Iter_Test.py +++ b/util/test/tests/Iter_Test.py @@ -196,8 +196,6 @@ class Iter_Test(rdtest.TestCase): rdtest.log.print("No debug result") return - sourceVars: List[rd.SourceVariableMapping] = list(trace.sourceVars) - cycles, variables = self.process_trace(trace) output_index = [o.resourceId for o in pipe.GetOutputTargets()].index(target) @@ -214,11 +212,10 @@ class Iter_Test(rdtest.TestCase): else: rdtest.log.print("At event {} the target is index {}".format(lastmod.eventId, output_index)) - output_list = \ - [x for x in sourceVars if x.builtin == rd.ShaderBuiltin.ColorOutput and x.offset == output_index] + output_sourcevar = self.find_output_source_var(trace, rd.ShaderBuiltin.ColorOutput, output_index) - if len(output_list) > 0: - debugged = self.evalute_source_var(output_list[0], variables) + if output_sourcevar is not None: + debugged = self.evalute_source_var(output_sourcevar, variables) self.controller.FreeTrace(trace)