diff --git a/util/test/demos/d3d12/d3d12_execute_indirect.cpp b/util/test/demos/d3d12/d3d12_execute_indirect.cpp index b92ac686e..bb4ff8bc7 100644 --- a/util/test/demos/d3d12/d3d12_execute_indirect.cpp +++ b/util/test/demos/d3d12/d3d12_execute_indirect.cpp @@ -382,6 +382,28 @@ void main(uint3 gid : SV_GroupID) ID3D12PipelineStatePtr patchpso2 = MakePSO().RootSig(patchsig).InputLayout(layout).VS(vsblob).PS(psblob); + struct PatchArgs3 + { + D3D12_DRAW_ARGUMENTS draw; + } patchargs3; + + patchargs3.draw.VertexCountPerInstance = 3; + patchargs3.draw.InstanceCount = 1024; + patchargs3.draw.StartInstanceLocation = 0; + patchargs3.draw.StartVertexLocation = 0; + + std::vector patchArgsData3; + patchArgsData3.resize(sizeof(PatchArgs3)); + + char *ptr3 = patchArgsData3.data(); + patchArgsData3.resize(sizeof(PatchArgs3)); + memcpy(ptr3, &patchargs3.draw, sizeof(D3D12_DRAW_ARGUMENTS)); + ID3D12ResourcePtr patchArgBuf3 = + MakeBuffer().Upload().Size((UINT)patchArgsData3.size()).Data(patchArgsData3.data()); + + ID3D12PipelineStatePtr patchpso3 = + MakePSO().RootSig(patchsig).InputLayout(layout).VS(vsblob).PS(psblob); + ID3D12CommandSignaturePtr compArgSig = MakeCommandSig(NULL, {dispatchArg()}); D3D12_DISPATCH_ARGUMENTS compargs; @@ -427,6 +449,10 @@ void main(uint3 gid : SV_GroupID) fullargsPtr += patchArgsDataSize; } + const uint32_t countDrawsInSingleDraw = 1; + ID3D12ResourcePtr singleDrawBuf = + MakeBuffer().Size(countDrawsInSingleDraw * sizeof(D3D12_INDIRECT_ARGUMENT_DESC)); + ID3D12ResourcePtr fullargsStateDrawBuf = MakeBuffer().Upload().Size((UINT)fullargsData.size()).Data(fullargsData.data()); @@ -631,6 +657,28 @@ void main(uint3 gid : SV_GroupID) } popMarker(cmd); + pushMarker(cmd, "Two Single Draws"); + { + cmd->SetPipelineState(patchpso3); + cmd->SetGraphicsRootSignature(patchsig); + cmd->SetDescriptorHeaps(1, &m_CBVUAVSRV.GetInterfacePtr()); + cmd->SetGraphicsRootDescriptorTable(5, m_CBVUAVSRV->GetGPUDescriptorHandleForHeapStart()); + cmd->SetGraphicsRootConstantBufferView(0, cbv->GetGPUVirtualAddress() + 256); + cmd->SetGraphicsRootShaderResourceView(1, srv->GetGPUVirtualAddress() + 256); + cmd->SetGraphicsRootUnorderedAccessView(2, uav->GetGPUVirtualAddress() + 256); + + RSSetViewport(cmd, {0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f}); + RSSetScissorRect(cmd, {0, 0, screenWidth, screenHeight}); + + OMSetRenderTargets(cmd, {rtv}, {}); + + cmd->SetGraphicsRoot32BitConstants(3, 4, baseConstData, 0); + + cmd->ExecuteIndirect(plainArgSig, 1, patchArgBuf3, 0, NULL, 0); + cmd->ExecuteIndirect(plainArgSig, 1, patchArgBuf3, 0, NULL, 0); + } + popMarker(cmd); + FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET); cmd->Close(); diff --git a/util/test/tests/D3D12/D3D12_Execute_Indirect.py b/util/test/tests/D3D12/D3D12_Execute_Indirect.py index 43a10c8af..9306a805d 100644 --- a/util/test/tests/D3D12/D3D12_Execute_Indirect.py +++ b/util/test/tests/D3D12/D3D12_Execute_Indirect.py @@ -249,3 +249,29 @@ class D3D12_Execute_Indirect(rdtest.TestCase): self.check_pixel_history_succeeds() action = action.next rdtest.log.success("Fully used argument buffer with multiple states + draws replayed") + + for drawNum in range(2): + action = self.find_action("Two Single Draws") + action = self.find_action("IndirectDraw", action.eventId) + if drawNum == 1: + action = self.find_action("IndirectDraw", action.eventId+1) + + self.controller.SetFrameEvent(action.eventId, False) + pipe = self.controller.GetPipelineState() + if len(pipe.GetOutputTargets()) != 1: + raise rdtest.TestFailureException( + f"With event {action.eventId} selected we should have one output target but there is {len(pipe.GetOutputTargets())}") + self.check_pixel_history_succeeds() + + overlay = rd.DebugOverlay.QuadOverdrawPass + tex = rd.TextureDisplay() + col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resource + tex.resourceId = col_tex + tex.overlay = overlay + tex.subresource.sample = 0 + + out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture) + out.SetTextureDisplay(tex) + out.Display() + out.Shutdown() + rdtest.log.success("Two Single Draws QuadOverdraw (Pass) replayed correctly"); \ No newline at end of file