Only unwrap command lists at the level we need

* This prevents us from accidentally unwrapping at List2 level when List2 might
  not be available, and we only need List.
* If we need higher list levels we can unwrap explicitly, and it's clearer that
  it needs an availability check.
This commit is contained in:
baldurk
2018-08-10 10:24:59 +01:00
parent c51e6f0e79
commit b52a4ae553
4 changed files with 70 additions and 43 deletions
+8 -5
View File
@@ -135,7 +135,9 @@ public:
WrappedID3D12Device *GetWrappedDevice() { return m_pDevice; }
D3D12ResourceRecord *GetResourceRecord() { return m_ListRecord; }
D3D12ResourceRecord *GetCreationRecord() { return m_CreationRecord; }
ID3D12GraphicsCommandList2 *GetCrackedList();
ID3D12GraphicsCommandList *GetCrackedList();
ID3D12GraphicsCommandList1 *GetCrackedList1();
ID3D12GraphicsCommandList2 *GetCrackedList2();
ID3D12GraphicsCommandList2 *GetWrappedCrackedList();
void SetAMDMarkerInterface(IAmdExtD3DCommandListMarker *marker) { m_AMDMarkers = marker; }
@@ -449,10 +451,11 @@ ResourceId GetResID(ID3D12GraphicsCommandList1 *obj);
template <>
ResourceId GetResID(ID3D12GraphicsCommandList2 *obj);
template <>
ID3D12GraphicsCommandList1 *Unwrap(ID3D12GraphicsCommandList1 *obj);
template <>
ID3D12GraphicsCommandList2 *Unwrap(ID3D12GraphicsCommandList2 *obj);
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList1 *obj);
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList2 *obj);
ID3D12GraphicsCommandList1 *Unwrap1(ID3D12GraphicsCommandList1 *obj);
ID3D12GraphicsCommandList2 *Unwrap2(ID3D12GraphicsCommandList2 *obj);
WrappedID3D12GraphicsCommandList2 *GetWrapped(ID3D12GraphicsCommandList1 *obj);
WrappedID3D12GraphicsCommandList2 *GetWrapped(ID3D12GraphicsCommandList2 *obj);
@@ -65,9 +65,9 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_AtomicCopyBufferUINT(
deps[i] = Unwrap(ppDependentResources[i]);
ID3D12GraphicsCommandList1 *list = m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID);
Unwrap(list)->AtomicCopyBufferUINT(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
Unwrap1(list)->AtomicCopyBufferUINT(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
}
}
else
@@ -77,12 +77,12 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_AtomicCopyBufferUINT(
for(size_t i = 0; i < deps.size(); i++)
deps[i] = Unwrap(ppDependentResources[i]);
Unwrap(pCommandList)
Unwrap1(pCommandList)
->AtomicCopyBufferUINT(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer), SrcOffset,
Dependencies, deps.data(), pDependentSubresourceRanges);
GetCrackedList()->AtomicCopyBufferUINT(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
GetCrackedList1()->AtomicCopyBufferUINT(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
{
m_Cmd->AddEvent();
@@ -183,9 +183,9 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_AtomicCopyBufferUINT64(
deps[i] = Unwrap(ppDependentResources[i]);
ID3D12GraphicsCommandList1 *list = m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID);
Unwrap(list)->AtomicCopyBufferUINT64(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
Unwrap1(list)->AtomicCopyBufferUINT64(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
}
}
else
@@ -195,12 +195,12 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_AtomicCopyBufferUINT64(
for(size_t i = 0; i < deps.size(); i++)
deps[i] = Unwrap(ppDependentResources[i]);
Unwrap(pCommandList)
Unwrap1(pCommandList)
->AtomicCopyBufferUINT64(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer), SrcOffset,
Dependencies, deps.data(), pDependentSubresourceRanges);
GetCrackedList()->AtomicCopyBufferUINT64(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
GetCrackedList1()->AtomicCopyBufferUINT64(Unwrap(pDstBuffer), DstOffset, Unwrap(pSrcBuffer),
SrcOffset, Dependencies, deps.data(),
pDependentSubresourceRanges);
{
m_Cmd->AddEvent();
@@ -288,7 +288,7 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_OMSetDepthBounds(SerialiserTyp
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->OMSetDepthBounds(Min, Max);
Unwrap1(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->OMSetDepthBounds(Min, Max);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
{
@@ -299,8 +299,8 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_OMSetDepthBounds(SerialiserTyp
}
else
{
Unwrap(pCommandList)->OMSetDepthBounds(Min, Max);
GetCrackedList()->OMSetDepthBounds(Min, Max);
Unwrap1(pCommandList)->OMSetDepthBounds(Min, Max);
GetCrackedList1()->OMSetDepthBounds(Min, Max);
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state.depthBoundsMin = Min;
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state.depthBoundsMax = Max;
@@ -351,7 +351,7 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_SetSamplePositions(
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
Unwrap1(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
@@ -369,8 +369,8 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_SetSamplePositions(
}
else
{
Unwrap(pCommandList)->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
GetCrackedList()->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
Unwrap1(pCommandList)->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
GetCrackedList1()->SetSamplePositions(NumSamplesPerPixel, NumPixels, pSamplePositions);
{
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
@@ -438,20 +438,20 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_ResolveSubresourceRegion(
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
ID3D12GraphicsCommandList1 *list = m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID);
Unwrap(list)->ResolveSubresourceRegion(Unwrap(pDstResource), DstSubresource, DstX, DstY,
Unwrap(pSrcResource), SrcSubresource, pSrcRect,
Format, ResolveMode);
Unwrap1(list)->ResolveSubresourceRegion(Unwrap(pDstResource), DstSubresource, DstX, DstY,
Unwrap(pSrcResource), SrcSubresource, pSrcRect,
Format, ResolveMode);
}
}
else
{
Unwrap(pCommandList)
Unwrap1(pCommandList)
->ResolveSubresourceRegion(Unwrap(pDstResource), DstSubresource, DstX, DstY,
Unwrap(pSrcResource), SrcSubresource, pSrcRect, Format,
ResolveMode);
GetCrackedList()->ResolveSubresourceRegion(Unwrap(pDstResource), DstSubresource, DstX, DstY,
Unwrap(pSrcResource), SrcSubresource, pSrcRect,
Format, ResolveMode);
GetCrackedList1()->ResolveSubresourceRegion(Unwrap(pDstResource), DstSubresource, DstX, DstY,
Unwrap(pSrcResource), SrcSubresource, pSrcRect,
Format, ResolveMode);
{
m_Cmd->AddEvent();
@@ -534,7 +534,7 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_SetViewInstanceMask(Serialiser
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->SetViewInstanceMask(Mask);
Unwrap1(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->SetViewInstanceMask(Mask);
if(m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
m_Cmd->m_RenderState.viewInstMask = Mask;
@@ -542,8 +542,8 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_SetViewInstanceMask(Serialiser
}
else
{
Unwrap(pCommandList)->SetViewInstanceMask(Mask);
GetCrackedList()->SetViewInstanceMask(Mask);
Unwrap1(pCommandList)->SetViewInstanceMask(Mask);
GetCrackedList1()->SetViewInstanceMask(Mask);
m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state.viewInstMask = Mask;
}
@@ -596,14 +596,14 @@ bool WrappedID3D12GraphicsCommandList2::Serialise_WriteBufferImmediate(
{
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
{
Unwrap(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
Unwrap2(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))
->WriteBufferImmediate(Count, pParams, pModes);
}
}
else
{
Unwrap(pCommandList)->WriteBufferImmediate(Count, pParams, pModes);
GetCrackedList()->WriteBufferImmediate(Count, pParams, pModes);
Unwrap2(pCommandList)->WriteBufferImmediate(Count, pParams, pModes);
GetCrackedList2()->WriteBufferImmediate(Count, pParams, pModes);
}
}
@@ -28,11 +28,21 @@
#include "d3d12_command_queue.h"
#include "d3d12_debug.h"
ID3D12GraphicsCommandList2 *WrappedID3D12GraphicsCommandList2::GetCrackedList()
ID3D12GraphicsCommandList *WrappedID3D12GraphicsCommandList2::GetCrackedList()
{
return Unwrap(m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].crackedLists.back());
}
ID3D12GraphicsCommandList1 *WrappedID3D12GraphicsCommandList2::GetCrackedList1()
{
return Unwrap1(m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].crackedLists.back());
}
ID3D12GraphicsCommandList2 *WrappedID3D12GraphicsCommandList2::GetCrackedList2()
{
return Unwrap2(m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].crackedLists.back());
}
ID3D12GraphicsCommandList2 *WrappedID3D12GraphicsCommandList2::GetWrappedCrackedList()
{
return m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].crackedLists.back();
+18 -4
View File
@@ -40,8 +40,23 @@ ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList *obj)
return ((WrappedID3D12GraphicsCommandList2 *)obj)->GetReal();
}
template <>
ID3D12GraphicsCommandList1 *Unwrap(ID3D12GraphicsCommandList1 *obj)
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList1 *obj)
{
if(obj == NULL)
return NULL;
return ((WrappedID3D12GraphicsCommandList2 *)obj)->GetReal();
}
ID3D12GraphicsCommandList *Unwrap(ID3D12GraphicsCommandList2 *obj)
{
if(obj == NULL)
return NULL;
return ((WrappedID3D12GraphicsCommandList2 *)obj)->GetReal();
}
ID3D12GraphicsCommandList1 *Unwrap1(ID3D12GraphicsCommandList1 *obj)
{
if(obj == NULL)
return NULL;
@@ -49,8 +64,7 @@ ID3D12GraphicsCommandList1 *Unwrap(ID3D12GraphicsCommandList1 *obj)
return ((WrappedID3D12GraphicsCommandList2 *)obj)->GetReal1();
}
template <>
ID3D12GraphicsCommandList2 *Unwrap(ID3D12GraphicsCommandList2 *obj)
ID3D12GraphicsCommandList2 *Unwrap2(ID3D12GraphicsCommandList2 *obj)
{
if(obj == NULL)
return NULL;