From fbb39b21a676729643aee0bbc41d835b09ccd5ed Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Mon, 5 May 2025 13:46:43 +0100 Subject: [PATCH] Extend D3D12 Shader Debug Zoo GSM tests struct TestStruct { uint3 a; uint3 b; }; groupshared int gsmInt; groupshared TestStruct gsmStruct[8]; groupshared int gsmIntArray[128]; --- .../demos/d3d12/d3d12_shader_debug_zoo.cpp | 29 ++++++++++++++++--- .../tests/D3D12/D3D12_Shader_Debug_Zoo.py | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp b/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp index 69c014da3..467327967 100644 --- a/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp +++ b/util/test/demos/d3d12/d3d12_shader_debug_zoo.cpp @@ -1092,6 +1092,10 @@ float4 main(v2f IN, uint samp : SV_SampleIndex) : SV_Target0 std::string compute = R"EOSHADER( +// error X3556: integer divides may be much slower, try using uints if possible. +// we want to do this on purpose +#pragma warning( disable : 3556 ) + cbuffer consts : register(b0) { bool boolX; @@ -1103,13 +1107,27 @@ cbuffer consts : register(b0) RWStructuredBuffer bufIn : register(u0); RWStructuredBuffer bufOut : register(u1); -groupshared int gsmInt[128]; +struct TestStruct +{ + uint3 a; + uint3 b; +}; + +groupshared int gsmInt; +groupshared TestStruct gsmStruct[8]; +groupshared int gsmIntArray[128]; [numthreads(1,1,1)] void main(int3 inTestIndex : SV_GroupID) { + // Only want the workgroups (*,1,0) to output results + if ((inTestIndex.y != 1) || (inTestIndex.z != 0)) + return; + int testIndex = inTestIndex.x; int4 testResult = 123; + gsmInt = testIndex; + gsmStruct[gsmInt].a = inTestIndex; if (testIndex == 0) { testResult = bufOut[0]; @@ -1120,15 +1138,18 @@ void main(int3 inTestIndex : SV_GroupID) } else if (testIndex == 1) { - gsmInt[testIndex-1] = testIndex; - testResult.x = gsmInt[testIndex-1]; + gsmStruct[gsmInt*4].a = inTestIndex; + int idx = 128 - gsmInt - 1; + gsmIntArray[idx] = testIndex; + testResult.x = gsmIntArray[idx/2]; testResult.y = testIndex; + testResult.z = gsmStruct[gsmInt * 4].a.y; } else { testResult.x = inTestIndex.x; } - bufOut[testIndex] = testResult; + bufOut[gsmInt] = testResult; } )EOSHADER"; diff --git a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py index 555951976..c67651309 100644 --- a/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_Debug_Zoo.py @@ -245,7 +245,7 @@ class D3D12_Shader_Debug_Zoo(rdtest.TestCase): # Debug the shader for groupX in range(action.dispatchDimension[0]): - groupid = (groupX, 0, 0) + groupid = (groupX, 1, 0) threadid = (0, 0, 0) testIndex = groupX trace: rd.ShaderDebugTrace = self.controller.DebugThread(groupid, threadid)