From ab9ada685a935290a0f226ff611c8afe864b237c Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 26 Oct 2016 21:59:49 +0200 Subject: [PATCH] Add basic serialisation of bundle execution, without stepping-in support --- .../driver/d3d12/d3d12_command_list_wrap.cpp | 81 ++++++++++++++++++- renderdoc/driver/d3d12/d3d12_commands.cpp | 1 + renderdoc/driver/d3d12/d3d12_common.h | 1 + 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 0d5dac5e7..8bc652ac9 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -2796,10 +2796,89 @@ void WrappedID3D12GraphicsCommandList::Dispatch(UINT ThreadGroupCountX, UINT Thr } } +bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteBundle(ID3D12GraphicsCommandList *pCommandList) +{ + SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID()); + + ResourceId Bundle; + + if(m_State >= WRITING) + { + D3D12ResourceRecord *record = GetRecord(pCommandList); + RDCASSERT(record->bakedCommands); + if(record->bakedCommands) + Bundle = record->bakedCommands->GetResourceID(); + } + + m_pSerialiser->Serialise("Bundle", Bundle); + + if(m_State < WRITING) + m_Cmd->m_LastCmdListID = CommandList; + + 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, true); + + ID3D12GraphicsCommandList *bundle = + GetResourceManager()->GetLiveAs(Bundle); + + Unwrap(list)->ExecuteBundle(Unwrap(bundle)); + + if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list)) + { + Unwrap(list)->ExecuteBundle(Unwrap(bundle)); + m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list); + } + } + } + else if(m_State == READING) + { + ID3D12GraphicsCommandList *bundle = + GetResourceManager()->GetLiveAs(Bundle); + + GetList(CommandList)->ExecuteBundle(Unwrap(bundle)); + GetCrackedList(CommandList)->ExecuteBundle(Unwrap(bundle)); + + const string desc = m_pSerialiser->GetDebugStr(); + + m_Cmd->AddEvent(desc); + string name = "ExecuteBundle(" + ToStr::Get(Bundle) + ")"; + + FetchDrawcall draw; + draw.name = name; + + draw.flags |= eDraw_CmdList; + + m_Cmd->AddDrawcall(draw, true); + } + + return true; +} + void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList *pCommandList) { - D3D12NOTIMP("Bundle execution"); m_pReal->ExecuteBundle(Unwrap(pCommandList)); + + if(m_State >= WRITING) + { + SCOPED_SERIALISE_CONTEXT(EXEC_BUNDLE); + Serialise_ExecuteBundle(pCommandList); + + m_ListRecord->AddChunk(scope.Get()); + + D3D12ResourceRecord *record = GetRecord(pCommandList); + + CmdListRecordingInfo *dst = m_ListRecord->cmdInfo; + CmdListRecordingInfo *src = record->bakedCommands->cmdInfo; + dst->boundDescs.insert(src->boundDescs.begin(), src->boundDescs.end()); + dst->dirtied.insert(src->dirtied.begin(), src->dirtied.end()); + + dst->bundles.push_back(record); + } } /* diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 4b76ef814..b120a635f 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -293,6 +293,7 @@ void WrappedID3D12CommandQueue::ProcessChunk(uint64_t offset, D3D12ChunkType chu case DRAW_INDEXED_INST: m_ReplayList->Serialise_DrawIndexedInstanced(0, 0, 0, 0, 0); break; case DISPATCH: m_ReplayList->Serialise_Dispatch(0, 0, 0); break; case EXEC_INDIRECT: m_ReplayList->Serialise_ExecuteIndirect(NULL, 0, NULL, 0, NULL, 0); break; + case EXEC_BUNDLE: m_ReplayList->Serialise_ExecuteBundle(NULL); break; case COPY_BUFFER: m_ReplayList->Serialise_CopyBufferRegion(NULL, 0, NULL, 0, 0); break; case COPY_TEXTURE: m_ReplayList->Serialise_CopyTextureRegion(NULL, 0, 0, 0, NULL, NULL); break; diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index fb21553ad..09270c4af 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -299,6 +299,7 @@ void Serialiser::Serialise(const char *name, D3D12Descriptor &el); D3D12_CHUNK_MACRO(DRAW_INST, "ID3D12GraphicsCommandList::DrawInstanced") \ D3D12_CHUNK_MACRO(DISPATCH, "ID3D12GraphicsCommandList::Dispatch") \ D3D12_CHUNK_MACRO(EXEC_INDIRECT, "ID3D12GraphicsCommandList::ExecuteIndirect") \ + D3D12_CHUNK_MACRO(EXEC_BUNDLE, "ID3D12GraphicsCommandList::ExecuteBundle") \ \ D3D12_CHUNK_MACRO(COPY_BUFFER, "ID3D12GraphicsCommandList::CopyBufferRegion") \ D3D12_CHUNK_MACRO(COPY_TEXTURE, "ID3D12GraphicsCommandList::CopyTextureRegion") \