Add ExecuteIndirect and Dispatch serialisation

This commit is contained in:
baldurk
2016-09-19 14:29:29 +02:00
parent 32ae271664
commit 278b2e41bc
3 changed files with 139 additions and 2 deletions
@@ -2214,11 +2214,72 @@ void WrappedID3D12GraphicsCommandList::DrawIndexedInstanced(UINT IndexCountPerIn
}
}
bool WrappedID3D12GraphicsCommandList::Serialise_Dispatch(UINT ThreadGroupCountX,
UINT ThreadGroupCountY,
UINT ThreadGroupCountZ)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(UINT, x, ThreadGroupCountX);
SERIALISE_ELEMENT(UINT, y, ThreadGroupCountY);
SERIALISE_ELEMENT(UINT, z, ThreadGroupCountZ);
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, true);
Unwrap(list)->Dispatch(x, y, z);
if(eventID && m_Cmd->m_DrawcallCallback->PostDraw(eventID, list))
{
Unwrap(list)->Dispatch(x, y, z);
m_Cmd->m_DrawcallCallback->PostRedraw(eventID, list);
}
}
}
else if(m_State == READING)
{
GetList(CommandList)->Dispatch(x, y, z);
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(DISPATCH, desc);
string name = "Dispatch(" + ToStr::Get(x) + ", " + ToStr::Get(y) + ", " + ToStr::Get(z) + ")";
FetchDrawcall draw;
draw.name = name;
draw.dispatchDimension[0] = x;
draw.dispatchDimension[1] = y;
draw.dispatchDimension[2] = z;
draw.flags |= eDraw_Dispatch;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY,
UINT ThreadGroupCountZ)
{
D3D12NOTIMP(__PRETTY_FUNCTION_SIGNATURE__);
m_pReal->Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(DISPATCH);
Serialise_Dispatch(ThreadGroupCountX, ThreadGroupCountY, ThreadGroupCountZ);
m_ListRecord->AddChunk(scope.Get());
}
}
void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList *pCommandList)
@@ -2227,6 +2288,63 @@ void WrappedID3D12GraphicsCommandList::ExecuteBundle(ID3D12GraphicsCommandList *
m_pReal->ExecuteBundle(Unwrap(pCommandList));
}
bool WrappedID3D12GraphicsCommandList::Serialise_ExecuteIndirect(
ID3D12CommandSignature *pCommandSignature, UINT MaxCommandCount, ID3D12Resource *pArgumentBuffer,
UINT64 ArgumentBufferOffset, ID3D12Resource *pCountBuffer, UINT64 CountBufferOffset)
{
SERIALISE_ELEMENT(ResourceId, CommandList, GetResourceID());
SERIALISE_ELEMENT(ResourceId, sig, GetResID(pCommandSignature));
SERIALISE_ELEMENT(UINT, maxCount, MaxCommandCount);
SERIALISE_ELEMENT(ResourceId, arg, GetResID(pArgumentBuffer));
SERIALISE_ELEMENT(UINT64, argOffs, ArgumentBufferOffset);
SERIALISE_ELEMENT(ResourceId, count, GetResID(pCountBuffer));
SERIALISE_ELEMENT(UINT64, countOffs, CountBufferOffset);
if(m_State < WRITING)
m_Cmd->m_LastCmdListID = CommandList;
D3D12NOTIMP("Serialise_DebugMessages");
if(m_State == EXECUTING)
{
pCommandSignature = GetResourceManager()->GetLiveAs<ID3D12CommandSignature>(sig);
pArgumentBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(arg);
pCountBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(count);
if(m_Cmd->ShouldRerecordCmd(CommandList) && m_Cmd->InRerecordRange(CommandList))
{
ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList);
Unwrap(list)->ExecuteIndirect(Unwrap(pCommandSignature), maxCount, Unwrap(pArgumentBuffer),
argOffs, Unwrap(pCountBuffer), countOffs);
}
}
else if(m_State == READING)
{
pCommandSignature = GetResourceManager()->GetLiveAs<ID3D12CommandSignature>(sig);
pArgumentBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(arg);
pCountBuffer = GetResourceManager()->GetLiveAs<ID3D12Resource>(count);
GetList(CommandList)
->ExecuteIndirect(Unwrap(pCommandSignature), maxCount, Unwrap(pArgumentBuffer), argOffs,
Unwrap(pCountBuffer), countOffs);
const string desc = m_pSerialiser->GetDebugStr();
m_Cmd->AddEvent(EXEC_INDIRECT, desc);
string name = "ExecuteIndirect(...)";
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_CmdList;
m_Cmd->AddDrawcall(draw, true);
}
return true;
}
void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *pCommandSignature,
UINT MaxCommandCount,
ID3D12Resource *pArgumentBuffer,
@@ -2234,10 +2352,23 @@ void WrappedID3D12GraphicsCommandList::ExecuteIndirect(ID3D12CommandSignature *p
ID3D12Resource *pCountBuffer,
UINT64 CountBufferOffset)
{
D3D12NOTIMP(__PRETTY_FUNCTION_SIGNATURE__);
m_pReal->ExecuteIndirect(Unwrap(pCommandSignature), MaxCommandCount, Unwrap(pArgumentBuffer),
ArgumentBufferOffset, Unwrap(pCountBuffer), CountBufferOffset);
if(m_State >= WRITING)
{
SCOPED_SERIALISE_CONTEXT(EXEC_INDIRECT);
Serialise_ExecuteIndirect(pCommandSignature, MaxCommandCount, pArgumentBuffer,
ArgumentBufferOffset, pCountBuffer, CountBufferOffset);
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCommandSignature), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pArgumentBuffer), eFrameRef_Read);
m_ListRecord->MarkResourceFrameReferenced(GetResID(pCountBuffer), eFrameRef_Read);
}
}
#pragma endregion Draws
#pragma region Clears
@@ -270,6 +270,9 @@ void WrappedID3D12CommandQueue::ProcessChunk(uint64_t offset, D3D12ChunkType chu
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 DISPATCH: m_ReplayList->Serialise_Dispatch(0, 0, 0); break;
case EXEC_INDIRECT: m_ReplayList->Serialise_ExecuteIndirect(NULL, 0, NULL, 0, NULL, 0); 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;
case COPY_RESOURCE: m_ReplayList->Serialise_CopyResource(NULL, NULL); break;
+3
View File
@@ -254,6 +254,9 @@ void Serialiser::Serialise(const char *name, D3D12Descriptor &el);
\
D3D12_CHUNK_MACRO(DRAW_INDEXED_INST, "ID3D12GraphicsCommandList::DrawIndexedInstanced") \
D3D12_CHUNK_MACRO(DRAW_INST, "ID3D12GraphicsCommandList::DrawInstanced") \
D3D12_CHUNK_MACRO(DISPATCH, "ID3D12GraphicsCommandList::Dispatch") \
D3D12_CHUNK_MACRO(EXEC_INDIRECT, "ID3D12GraphicsCommandList::ExecuteIndirect") \
\
D3D12_CHUNK_MACRO(COPY_BUFFER, "ID3D12GraphicsCommandList::CopyBufferRegion") \
D3D12_CHUNK_MACRO(COPY_TEXTURE, "ID3D12GraphicsCommandList::CopyTextureRegion") \
D3D12_CHUNK_MACRO(COPY_RESOURCE, "ID3D12GraphicsCommandList::CopyResource") \