From aa412ddf89a0f430be50facadf5081dd2b7526cb Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 19 Sep 2022 16:43:05 +0100 Subject: [PATCH] Don't hard-fail on results of undefined tests in shader debug zoo --- .../demos/d3d11/d3d11_shader_debug_zoo.cpp | 23 ++++++++++++++++--- .../demos/d3d12/d3d12_shader_debug_zoo.cpp | 22 +++++++++++++++--- .../tests/D3D11/D3D11_Shader_Debug_Zoo.py | 9 ++++++-- .../tests/D3D12/D3D12_Shader_Debug_Zoo.py | 9 ++++++-- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp b/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp index 22d3c9443..0df58c2e6 100644 --- a/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp +++ b/util/test/demos/d3d11/d3d11_shader_debug_zoo.cpp @@ -244,7 +244,7 @@ float4 main(v2f IN) : SV_Target0 // test reading/writing byte address data // mis-aligned loads - if(IN.tri == 35) + if(IN.tri == 35) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -290,7 +290,7 @@ float4 main(v2f IN) : SV_Target0 } // mis-aligned store - if(IN.tri == 40) + if(IN.tri == 40) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -302,7 +302,7 @@ float4 main(v2f IN) : SV_Target0 return asfloat(byterwtest.Load(z2+0).x); } // mis-aligned loads - if(IN.tri == 41) + if(IN.tri == 41) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -901,6 +901,21 @@ float4 main(v2f IN, uint samp : SV_SampleIndex) : SV_Target0 const uint32_t numTests = atoi(pixel.c_str() + lastTest) + 1; + std::string undefined_tests = "Undefined tests:"; + + size_t undef = pixel.find("undefined-test"); + while(undef != std::string::npos) + { + size_t testNumStart = pixel.rfind("IN.tri == ", undef); + testNumStart += sizeof("IN.tri == ") - 1; + size_t testNumEnd = pixel.find_first_not_of("0123456789", testNumStart); + + undefined_tests += " "; + undefined_tests += pixel.substr(testNumStart, testNumEnd - testNumStart); + + undef = pixel.find("undefined-test", undef + 1); + } + if(opts2.TypedUAVLoadAdditionalFormats) common += "\n#define TYPED_UAV_EXT 1\n"; @@ -1054,6 +1069,8 @@ float4 main(v2f IN, uint samp : SV_SampleIndex) : SV_Target0 ctx->OMSetRenderTargetsAndUnorderedAccessViews(1, &fltRT.GetInterfacePtr(), NULL, 1, 3, uavs, NULL); + setMarker(undefined_tests); + setMarker("Main Test"); ctx->DrawInstanced(3, numTests, 0, 0); diff --git a/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp b/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp index 3c58f5db9..4431e7dc4 100644 --- a/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp +++ b/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp @@ -294,7 +294,7 @@ float4 main(v2f IN) : SV_Target0 // test reading/writing byte address data // mis-aligned loads - if(IN.tri == 35) + if(IN.tri == 35) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -340,7 +340,7 @@ float4 main(v2f IN) : SV_Target0 } // mis-aligned store - if(IN.tri == 40) + if(IN.tri == 40) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -352,7 +352,7 @@ float4 main(v2f IN) : SV_Target0 return asfloat(byterwtest.Load(z2+0).x); } // mis-aligned loads - if(IN.tri == 41) + if(IN.tri == 41) // undefined-test { // use this to ensure the compiler doesn't know we're using fixed locations uint z = intval - IN.tri - 7; @@ -753,6 +753,20 @@ float4 main(v2f IN, uint samp : SV_SampleIndex) : SV_Target0 const uint32_t numTests = atoi(pixel.c_str() + lastTest) + 1; + std::string undefined_tests = "Undefined tests:"; + + size_t undef = pixel.find("undefined-test"); + while(undef != std::string::npos) + { + size_t testNumStart = pixel.rfind("IN.tri == ", undef); + testNumStart += sizeof("IN.tri == ") - 1; + size_t testNumEnd = pixel.find_first_not_of("0123456789", testNumStart); + + undefined_tests += " "; + undefined_tests += pixel.substr(testNumStart, testNumEnd - testNumStart); + + undef = pixel.find("undefined-test", undef + 1); + } ID3DBlobPtr vsblob = Compile(common + vertex, "main", "vs_5_0"); ID3DBlobPtr psblob = Compile(common + pixel, "main", "ps_5_0"); @@ -1080,6 +1094,8 @@ float4 main(v2f IN, uint samp : SV_SampleIndex) : SV_Target0 MakeRTV(bb).Format(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB).CreateCPU(2); ClearRenderTargetView(cmd, rtv, {0.2f, 0.2f, 0.2f, 1.0f}); + setMarker(cmd, undefined_tests); + ID3D12PipelineStatePtr psos[2] = {pso_5_0, pso_5_1}; float blitOffsets[2] = {0.0f, 4.0f}; D3D12_RECT scissors[2] = {{0, 0, (int)texDim, 4}, {0, 4, (int)texDim, 8}}; diff --git a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py index 1597257e1..bc03f16c2 100644 --- a/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D11/D3D11_Shader_Debug_Zoo.py @@ -10,6 +10,8 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): # Jump to the action action = self.find_action("Main Test").next + undefined_tests = [int(test) for test in self.find_action("Undefined tests: ").customName.split(" ")[2:]] + self.controller.SetFrameEvent(action.eventId, False) pipe: rd.PipeState = self.controller.GetPipelineState() @@ -32,8 +34,11 @@ class D3D11_Shader_Debug_Zoo(rdtest.TestCase): try: self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: - failed = True - rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) + if test in undefined_tests: + rdtest.log.comment("Undefined test {} did not match. {}".format(test, str(ex))) + else: + rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) + failed = True continue finally: self.controller.FreeTrace(trace) diff --git a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py index a9d7b9795..b4011ab00 100644 --- a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py @@ -11,6 +11,8 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): rdtest.log.success("Shader debugging not enabled, skipping test") return + undefined_tests = [int(test) for test in self.find_action("Undefined tests: ").customName.split(" ")[2:]] + failed = False shaderModels = ["sm_5_0", "sm_5_1"] @@ -43,8 +45,11 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): try: self.check_pixel_value(pipe.GetOutputTargets()[0].resourceId, 4 * test, 0, debugged.value.f32v[0:4]) except rdtest.TestFailureException as ex: - failed = True - rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) + if test in undefined_tests: + rdtest.log.comment("Undefined test {} did not match. {}".format(test, str(ex))) + else: + rdtest.log.error("Test {} did not match. {}".format(test, str(ex))) + failed = True continue finally: self.controller.FreeTrace(trace)