From 53bf231104fea1636f16f83e06815d722414398a Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Mon, 3 Jul 2023 11:54:49 +0100 Subject: [PATCH] Extend D3D12 Execute Indirect test Change it to do 8 indirect draws with a clear in between. Check the pixel and mesh data for each draw is correct (simple triangle) --- .../demos/d3d12/d3d12_execute_indirect.cpp | 21 ++++++----- .../tests/D3D12/D3D12_Execute_Indirect.py | 36 ++++++++++++++++--- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/util/test/demos/d3d12/d3d12_execute_indirect.cpp b/util/test/demos/d3d12/d3d12_execute_indirect.cpp index 199278e35..b2b6face6 100644 --- a/util/test/demos/d3d12/d3d12_execute_indirect.cpp +++ b/util/test/demos/d3d12/d3d12_execute_indirect.cpp @@ -81,20 +81,23 @@ RD_TEST(D3D12_Execute_Indirect, D3D12GraphicsTest) D3D12_CPU_DESCRIPTOR_HANDLE rtv = MakeRTV(bb).Format(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB).CreateCPU(0); - ClearRenderTargetView(cmd, rtv, {1.0f, 0.0f, 0.0f, 1.0f}); + for(int i = 0; i < 8; ++i) + { + ClearRenderTargetView(cmd, rtv, {1.0f, 0.0f, 0.0f, 1.0f}); - cmd->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + cmd->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - IASetVertexBuffer(cmd, vb, sizeof(DefaultA2V), 0); - cmd->SetPipelineState(pso); - cmd->SetGraphicsRootSignature(sig); + IASetVertexBuffer(cmd, vb, sizeof(DefaultA2V), 0); + cmd->SetPipelineState(pso); + cmd->SetGraphicsRootSignature(sig); - RSSetViewport(cmd, {0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f}); - RSSetScissorRect(cmd, {0, 0, screenWidth, screenHeight}); + RSSetViewport(cmd, {0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f}); + RSSetScissorRect(cmd, {0, 0, screenWidth, screenHeight}); - OMSetRenderTargets(cmd, {rtv}, {}); + OMSetRenderTargets(cmd, {rtv}, {}); - cmd->ExecuteIndirect(cmdsig, 1, argBuf, 0, NULL, 0); + cmd->ExecuteIndirect(cmdsig, 1, argBuf, 0, NULL, 0); + } FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET); diff --git a/util/test/tests/D3D12/D3D12_Execute_Indirect.py b/util/test/tests/D3D12/D3D12_Execute_Indirect.py index 57f60332a..a56b44107 100644 --- a/util/test/tests/D3D12/D3D12_Execute_Indirect.py +++ b/util/test/tests/D3D12/D3D12_Execute_Indirect.py @@ -6,9 +6,37 @@ class D3D12_Execute_Indirect(rdtest.TestCase): demos_test_name = 'D3D12_Execute_Indirect' def check_capture(self): - action = self.find_action("IndirectDraw") + from_eid = 0 + for i in range(8): + action = self.find_action("IndirectDraw", from_eid) + self.controller.SetFrameEvent(action.eventId, False) + # Should be a green triangle in the centre of the screen on a red background + self.check_triangle(back=[1.0, 0.0, 0.0, 1.0]) + postvs_data = self.get_postvs(action, rd.MeshDataStage.VSOut, 0, action.numIndices) - self.controller.SetFrameEvent(action.eventId, False) + postvs_ref = { + 0: { + 'vtx': 0, + 'idx': 0, + 'SV_POSITION': [-0.5, -0.5, 0.0, 1.0], + 'COLOR': [0.0, 1.0, 0.0, 1.0], + 'TEXCOORD': [0.0, 0.0], + }, + 1: { + 'vtx': 1, + 'idx': 1, + 'SV_POSITION': [0.0, 0.5, 0.0, 1.0], + 'COLOR': [0.0, 1.0, 0.0, 1.0], + 'TEXCOORD': [0.0, 1.0], + }, + 2: { + 'vtx': 2, + 'idx': 2, + 'SV_POSITION': [0.5, -0.5, 0.0, 1.0], + 'COLOR': [0.0, 1.0, 0.0, 1.0], + 'TEXCOORD': [1.0, 0.0], + }, + } - # Should be a green triangle in the centre of the screen on a red background - self.check_triangle(back=[1.0, 0.0, 0.0, 1.0]) \ No newline at end of file + self.check_mesh_data(postvs_ref, postvs_data) + from_eid = action.eventId + 1 \ No newline at end of file