diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 906ca2658..186b27b76 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -304,12 +304,79 @@ void WrappedID3D12GraphicsCommandList::ClearState(ID3D12PipelineState *pPipeline m_pReal->ClearState(Unwrap(pPipelineState)); } +bool WrappedID3D12GraphicsCommandList::Serialise_DrawInstanced(UINT VertexCountPerInstance, + UINT InstanceCount, + UINT StartVertexLocation, + UINT StartInstanceLocation) +{ + SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID()); + SERIALISE_ELEMENT(UINT, vtxCount, VertexCountPerInstance); + SERIALISE_ELEMENT(UINT, instCount, InstanceCount); + SERIALISE_ELEMENT(UINT, startVtx, StartVertexLocation); + SERIALISE_ELEMENT(UINT, startInst, StartInstanceLocation); + + if(m_State < WRITING) + m_Cmd->m_LastCmdListID = CommandList; + + D3D12NOTIMP("Serialise_DebugMessages"); + + if(m_State == EXECUTING) + { + if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList)) + { + ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList); + + uint32_t eventID = m_Cmd->HandlePreCallback(list); + + Unwrap(list)->DrawInstanced(vtxCount, instCount, startVtx, startInst); + + if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list)) + { + Unwrap(list)->DrawInstanced(vtxCount, instCount, startVtx, startInst); + m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list); + } + } + } + else if(m_State == READING) + { + GetList(CommandList)->DrawInstanced(vtxCount, instCount, startVtx, startInst); + + const string desc = m_pSerialiser->GetDebugStr(); + + m_Cmd->AddEvent(DRAW_INST, desc); + string name = "DrawInstanced(" + ToStr::Get(vtxCount) + ", " + ToStr::Get(instCount) + ")"; + + FetchDrawcall draw; + draw.name = name; + draw.numIndices = vtxCount; + draw.numInstances = instCount; + draw.indexOffset = 0; + draw.baseVertex = startVtx; + draw.instanceOffset = startInst; + + draw.flags |= eDraw_Drawcall | eDraw_Instanced; + + m_Cmd->AddDrawcall(draw, true); + } + + return true; +} + void WrappedID3D12GraphicsCommandList::DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation) { m_pReal->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); + + if(m_State >= WRITING) + { + SCOPED_SERIALISE_CONTEXT(DRAW_INST); + Serialise_DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, + StartInstanceLocation); + + m_ListRecord->AddChunk(scope.Get()); + } } bool WrappedID3D12GraphicsCommandList::Serialise_DrawIndexedInstanced(UINT IndexCountPerInstance, diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 32920cc82..4ddf2ee39 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -264,6 +264,7 @@ void WrappedID3D12CommandQueue::ProcessChunk(uint64_t offset, D3D12ChunkType chu case RESOURCE_BARRIER: m_ReplayList->Serialise_ResourceBarrier(0, NULL); break; + case DRAW_INST: m_ReplayList->Serialise_DrawInstanced(0, 0, 0, 0); break; case DRAW_INDEXED_INST: m_ReplayList->Serialise_DrawIndexedInstanced(0, 0, 0, 0, 0); break; case COPY_BUFFER: m_ReplayList->Serialise_CopyBufferRegion(NULL, 0, NULL, 0, 0); break; diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 994aabc61..ea5f61738 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -237,6 +237,7 @@ void Serialiser::Serialise(const char *name, D3D12Descriptor &el); D3D12_CHUNK_MACRO(RESOURCE_BARRIER, "ID3D12GraphicsCommandList::ResourceBarrier") \ \ D3D12_CHUNK_MACRO(DRAW_INDEXED_INST, "ID3D12GraphicsCommandList::DrawIndexedInstanced") \ + D3D12_CHUNK_MACRO(DRAW_INST, "ID3D12GraphicsCommandList::DrawInstanced") \ D3D12_CHUNK_MACRO(COPY_BUFFER, "ID3D12GraphicsCommandList::CopyBufferRegion") \ \ D3D12_CHUNK_MACRO(CLEAR_RTV, "ID3D12GraphicsCommandList::ClearRenderTargetView") \