From 9e79ba3416896cebc63b578ed3548475bba89685 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 20 Nov 2023 18:17:51 +0000 Subject: [PATCH] Fix DXIL patching for quad overdraw * Also tweak the test output to be more organised --- renderdoc/driver/d3d12/d3d12_overlay.cpp | 47 ++++++++++++++++++++---- util/test/rdtest/shared/Overlay_Test.py | 23 +++++++++--- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_overlay.cpp b/renderdoc/driver/d3d12/d3d12_overlay.cpp index c74356019..08c3ed64b 100644 --- a/renderdoc/driver/d3d12/d3d12_overlay.cpp +++ b/renderdoc/driver/d3d12/d3d12_overlay.cpp @@ -459,22 +459,44 @@ void D3D12Replay::PatchQuadWritePS(D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC &pi RDCASSERT(quadPSsigs->children.size() > 0); - // just repoint input signature list to rast out sig - quadPSsigs->children[0] = (Metadata *)rastOutSig; + // create new input signature list + Metadata *newInSig = quadPSsigs->children[0] = editor.CreateMetadata(); uint32_t posID = ~0U; // process signature to get string table & index table for semantics for(size_t i = 0; i < rastOutSig->children.size(); i++) { - const Metadata *sigEl = rastOutSig->children[i]; + const Metadata *inSigEl = rastOutSig->children[i]; + + Metadata *outSigEl = editor.CreateMetadata(); + newInSig->children.push_back(outSigEl); + + outSigEl->children = { + editor.CreateConstantMetadata(cast(inSigEl->children[0]->value)->getU32()), + editor.CreateConstantMetadata(inSigEl->children[1]->str), + editor.CreateConstantMetadata( + (uint8_t)cast(inSigEl->children[2]->value)->getU32()), + editor.CreateConstantMetadata( + (uint8_t)cast(inSigEl->children[3]->value)->getU32()), + editor.CreateMetadata(), + editor.CreateConstantMetadata( + (uint8_t)cast(inSigEl->children[5]->value)->getU32()), + editor.CreateConstantMetadata(cast(inSigEl->children[6]->value)->getU32()), + editor.CreateConstantMetadata( + (uint8_t)cast(inSigEl->children[7]->value)->getU32()), + editor.CreateConstantMetadata(cast(inSigEl->children[8]->value)->getU32()), + editor.CreateConstantMetadata( + (uint8_t)cast(inSigEl->children[9]->value)->getU32()), + editor.CreateMetadata(), + }; // only append non-system values to the string table - uint32_t systemValue = cast(sigEl->children[3]->value)->getU32(); + uint32_t systemValue = cast(inSigEl->children[3]->value)->getU32(); if(systemValue == 0) { stringTableOffsets.push_back((uint32_t)stringTable.size()); - stringTable.append(sigEl->children[1]->str); + stringTable.append(inSigEl->children[1]->str); stringTable.push_back('\0'); } else @@ -483,17 +505,28 @@ void D3D12Replay::PatchQuadWritePS(D3D12_EXPANDED_PIPELINE_STATE_STREAM_DESC &pi // SV_Position is 3 if(systemValue == 3) - posID = cast(sigEl->children[0]->value)->getU32(); + posID = cast(inSigEl->children[0]->value)->getU32(); } rdcarray semIndexValues; // semantic indices - if(const Metadata *semIdxs = sigEl->children[4]) + if(const Metadata *semIdxs = inSigEl->children[4]) { // the semantic index node is a list of constants for(size_t sidx = 0; sidx < semIdxs->children.size(); sidx++) + { semIndexValues.push_back(cast(semIdxs->children[sidx]->value)->getU32()); + outSigEl->children[4]->children.push_back( + editor.CreateConstantMetadata(semIndexValues.back())); + } + } + + if(const Metadata *props = inSigEl->children[10]) + { + for(size_t sidx = 0; sidx < props->children.size(); sidx++) + outSigEl->children[10]->children.push_back(editor.CreateConstantMetadata( + cast(props->children[sidx]->value)->getU32())); } size_t tableOffset = ~0U; diff --git a/util/test/rdtest/shared/Overlay_Test.py b/util/test/rdtest/shared/Overlay_Test.py index 96e33f23f..875dd0cb3 100644 --- a/util/test/rdtest/shared/Overlay_Test.py +++ b/util/test/rdtest/shared/Overlay_Test.py @@ -7,6 +7,9 @@ class Overlay_Test(rdtest.TestCase): internal = True def check_capture(self, base_event=0): + if base_event != 0: + rdtest.log.print("Checking overlays from base event {}".format(base_event)) + out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture) self.check(out is not None) @@ -17,23 +20,25 @@ class Overlay_Test(rdtest.TestCase): # Check the actual output is as expected first. for fmt in fmts: - marker_name = "Normal Test " + fmt; + marker_name = "Normal Test " + fmt test_marker: rd.ActionDescription = self.find_action(marker_name, base_event) if test_marker == None: rdtest.log.print("Skipping format {} marker {} not found".format(fmt, marker_name)) - continue; - rdtest.log.print("Checking format {}".format(fmt)) + continue + rdtest.log.begin_section("Checking format {}".format(fmt)) has_stencil = fmt.endswith("_S8") for is_msaa in [False, True]: if is_msaa: - marker_name = "MSAA Test "; + marker_name = "MSAA Test " else: - marker_name = "Normal Test "; - marker_name += fmt; + marker_name = "Normal Test " + marker_name += fmt test_marker: rd.ActionDescription = self.find_action(marker_name, base_event) self.controller.SetFrameEvent(test_marker.next.eventId, True) + rdtest.log.print("Checking overlays at event {}: {}".format(test_marker.next.eventId, marker_name)) + pipe: rd.PipeState = self.controller.GetPipelineState() col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId @@ -688,6 +693,10 @@ class Overlay_Test(rdtest.TestCase): rdtest.log.success("All overlays as expected for main action Format {}".format(fmt)) + rdtest.log.end_section("Checking format {}".format(fmt)) + + rdtest.log.begin_section("Checking mip/slice rendering") + # Now test overlays on a render-to-slice/mip case for mip in [2, 3]: sub_marker: rd.ActionDescription = self.find_action("Subresources mip {}".format(mip), base_event) @@ -805,4 +814,6 @@ class Overlay_Test(rdtest.TestCase): rdtest.log.success("Picked values are correct for mip {} overlay {}".format(sub.mip, str(overlay))) + rdtest.log.end_section("Checking mip/slice rendering") + out.Shutdown()