Update D3D12 command list wrapping code to new serialisation

This commit is contained in:
baldurk
2017-10-30 17:47:46 +00:00
parent 5452940739
commit 3aa8398ec2
8 changed files with 2435 additions and 2485 deletions
+5 -6
View File
@@ -123,10 +123,8 @@ public:
ID3D12GraphicsCommandList *GetReal() { return m_pReal; }
WrappedID3D12Device *GetWrappedDevice() { return m_pDevice; }
D3D12ResourceRecord *GetResourceRecord() { return m_ListRecord; }
ID3D12GraphicsCommandList *GetList(ResourceId id);
ID3D12GraphicsCommandList *GetWrappedList(ResourceId id);
ID3D12GraphicsCommandList *GetCrackedList(ResourceId id);
ID3D12GraphicsCommandList *GetWrappedCrackedList(ResourceId id);
ID3D12GraphicsCommandList *GetCrackedList();
ID3D12GraphicsCommandList *GetWrappedCrackedList();
void SetAMDMarkerInterface(IAmdExtD3DCommandListMarker *marker) { m_AMDMarkers = marker; }
void SetCommandData(D3D12CommandData *cmd) { m_Cmd = cmd; }
@@ -137,7 +135,7 @@ public:
m_Init.type = type;
}
bool ValidateRootGPUVA(ResourceId buffer);
bool ValidateRootGPUVA(D3D12_GPU_VIRTUAL_ADDRESS buffer);
//////////////////////////////
// implement IUnknown
@@ -376,7 +374,8 @@ public:
IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, EndEvent, );
void ReserveExecuteIndirect(ID3D12GraphicsCommandList *list, ResourceId sig, UINT maxCount);
void ReserveExecuteIndirect(ID3D12GraphicsCommandList *list,
WrappedID3D12CommandSignature *comSig, UINT maxCount);
void PatchExecuteIndirect(BakedCmdListInfo &info, uint32_t executeIndex);
void ReplayExecuteIndirect(ID3D12GraphicsCommandList *list, BakedCmdListInfo &info);
File diff suppressed because it is too large Load Diff
+7 -15
View File
@@ -556,8 +556,7 @@ void WrappedID3D12CommandQueue::ReplayLog(CaptureState readType, uint32_t startE
if(it != m_Cmd.m_DrawcallUses.end())
{
BakedCmdListInfo &cmdInfo =
m_Cmd.m_BakedCmdListInfo[m_Cmd.m_BakedCmdListInfo[it->cmdList].parentList];
BakedCmdListInfo &cmdInfo = m_Cmd.m_BakedCmdListInfo[it->cmdList];
cmdInfo.curEventID = it->relativeEID;
}
}
@@ -719,24 +718,17 @@ WrappedID3D12GraphicsCommandList::~WrappedID3D12GraphicsCommandList()
SAFE_RELEASE(m_pReal);
}
bool WrappedID3D12GraphicsCommandList::ValidateRootGPUVA(ResourceId buffer)
bool WrappedID3D12GraphicsCommandList::ValidateRootGPUVA(D3D12_GPU_VIRTUAL_ADDRESS buffer)
{
if(!GetResourceManager()->HasLiveResource(buffer))
if(buffer == 0)
{
// abort, we don't have this buffer. Print errors while reading
if(IsLoading(m_State))
{
if(buffer != ResourceId())
{
RDCERR("Don't have live buffer for %llu", buffer);
}
else
{
m_pDevice->AddDebugMessage(MessageCategory::Resource_Manipulation, MessageSeverity::Medium,
MessageSource::IncorrectAPIUse,
"Binding 0 as a GPU Virtual Address in a root constant is "
"invalid. This call will be dropped during replay.");
}
m_pDevice->AddDebugMessage(MessageCategory::Resource_Manipulation, MessageSeverity::Medium,
MessageSource::IncorrectAPIUse,
"Binding 0 as a GPU Virtual Address in a root constant is "
"invalid. This call will be dropped during replay.");
}
return true;
+12 -45
View File
@@ -121,57 +121,24 @@ struct D3D12DrawcallCallback
virtual void AliasEvent(uint32_t primary, uint32_t alias) = 0;
};
class WrappedID3D12CommandSignature;
struct BakedCmdListInfo
{
void BakeFrom(ResourceId parentID, BakedCmdListInfo &parent)
{
draw = parent.draw;
curEvents = parent.curEvents;
debugMessages = parent.debugMessages;
eventCount = parent.curEventID;
drawCount = parent.drawCount;
crackedLists.swap(parent.crackedLists);
executeEvents.swap(parent.executeEvents);
parentList = parentID;
curEventID = 0;
parent.draw = NULL;
parent.curEventID = 0;
parent.eventCount = 0;
parent.drawCount = 0;
parent.curEvents.clear();
parent.debugMessages.clear();
}
void ShiftForRemoved(uint32_t shiftDrawID, uint32_t shiftEID, size_t idx);
struct ExecuteData
{
ExecuteData()
: baseEvent(0),
lastEvent(0),
patched(false),
argBuf(NULL),
countBuf(NULL),
argOffs(0),
countOffs(0),
maxCount(0),
realCount(0)
{
}
uint32_t baseEvent;
uint32_t lastEvent;
bool patched;
ID3D12Resource *argBuf;
ID3D12Resource *countBuf;
uint64_t argOffs;
uint64_t countOffs;
ResourceId sig;
UINT maxCount;
UINT realCount;
uint32_t baseEvent = 0;
uint32_t lastEvent = 0;
bool patched = false;
ID3D12Resource *argBuf = NULL;
ID3D12Resource *countBuf = NULL;
uint64_t argOffs = 0;
uint64_t countOffs = 0;
WrappedID3D12CommandSignature *sig = NULL;
UINT maxCount = 0;
UINT realCount = 0;
};
vector<ID3D12GraphicsCommandList *> crackedLists;
+17 -27
View File
@@ -33,6 +33,7 @@
#include "maths/vec.h"
#include "stb/stb_truetype.h"
#include "strings/string_utils.h"
#include "d3d12_command_list.h"
#include "d3d12_command_queue.h"
#include "d3d12_device.h"
@@ -6955,8 +6956,7 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
ID3D12Resource *renderDepth = NULL;
D3D12Descriptor *dsView =
DescriptorFromPortableHandle(m_WrappedDevice->GetResourceManager(), rs.dsv);
D3D12Descriptor *dsView = GetWrapped(rs.dsv);
D3D12_RESOURCE_DESC depthTexDesc = {};
D3D12_DEPTH_STENCIL_VIEW_DESC dsViewDesc = {};
@@ -7141,8 +7141,8 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
rs.pipe = GetResID(pso);
rs.rtSingle = true;
rs.rts.resize(1);
rs.rts[0] = ToPortableHandle(rtv);
rs.dsv = PortableHandle();
rs.rts[0] = rtv;
rs.dsv = D3D12_CPU_DESCRIPTOR_HANDLE();
m_WrappedDevice->ReplayLog(0, eventID, eReplay_OnlyDraw);
@@ -7233,8 +7233,8 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
rs.pipe = GetResID(redPSO);
rs.rtSingle = true;
rs.rts.resize(1);
rs.rts[0] = ToPortableHandle(rtv);
rs.dsv = PortableHandle();
rs.rts[0] = rtv;
rs.dsv = D3D12_CPU_DESCRIPTOR_HANDLE();
m_WrappedDevice->ReplayLog(0, eventID, eReplay_OnlyDraw);
@@ -7312,8 +7312,8 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
rs.pipe = GetResID(pso);
rs.rtSingle = true;
rs.rts.resize(1);
rs.rts[0] = ToPortableHandle(rtv);
rs.dsv = ToPortableHandle(dsv);
rs.rts[0] = rtv;
rs.dsv = dsv;
m_WrappedDevice->ReplayLog(0, eventID, eReplay_OnlyDraw);
@@ -7341,7 +7341,7 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
list = NULL;
bool rtSingle = rs.rtSingle;
vector<PortableHandle> rts = rs.rts;
std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> rts = rs.rts;
if(overlay == DebugOverlay::ClearBeforePass)
m_WrappedDevice->ReplayLog(0, events[0], eReplay_WithoutDraw);
@@ -7350,20 +7350,14 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
for(size_t i = 0; i < rts.size(); i++)
{
PortableHandle ph = rtSingle ? rts[0] : rts[i];
D3D12Descriptor *desc = rtSingle ? GetWrapped(rts[0]) : GetWrapped(rts[i]);
WrappedID3D12DescriptorHeap *heap =
m_WrappedDevice->GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(ph.heap);
if(heap)
if(desc)
{
D3D12_CPU_DESCRIPTOR_HANDLE clearrtv = heap->GetCPUDescriptorHandleForHeapStart();
clearrtv.ptr += ph.index * sizeof(D3D12Descriptor);
if(rtSingle)
clearrtv.ptr += i * sizeof(D3D12Descriptor);
desc += i;
list->ClearRenderTargetView(clearrtv, black, 0, NULL);
Unwrap(list)->ClearRenderTargetView(UnwrapCPU(desc), black, 0, NULL);
}
}
@@ -7519,13 +7513,9 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
Vec4f viewport(rs.views[0].Width, rs.views[0].Height);
if(rs.dsv.heap != ResourceId())
if(rs.dsv.ptr)
{
WrappedID3D12DescriptorHeap *realDSVHeap =
m_WrappedDevice->GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(rs.dsv.heap);
D3D12_CPU_DESCRIPTOR_HANDLE realDSV = realDSVHeap->GetCPUDescriptorHandleForHeapStart();
realDSV.ptr += sizeof(D3D12Descriptor) * rs.dsv.index;
D3D12_CPU_DESCRIPTOR_HANDLE realDSV = Unwrap(rs.dsv);
list->OMSetRenderTargets(1, &rtv, TRUE, &realDSV);
}
@@ -7856,8 +7846,8 @@ ResourceId D3D12DebugManager::RenderOverlay(ResourceId texid, CompType typeHint,
rs.pipe = GetResID(redPSO);
rs.rtSingle = true;
rs.rts.resize(1);
rs.rts[0] = ToPortableHandle(rtv);
rs.dsv = ToPortableHandle(dsv);
rs.rts[0] = rtv;
rs.dsv = dsv;
m_WrappedDevice->ReplayLog(0, eventID, eReplay_OnlyDraw);
+8 -12
View File
@@ -1099,12 +1099,10 @@ void D3D12Replay::SavePipelineState()
{
D3D12Pipe::View &view = state.m_OM.RenderTargets[i];
PortableHandle h = rs.rtSingle ? rs.rts[0] : rs.rts[i];
D3D12Descriptor *desc = rs.rtSingle ? GetWrapped(rs.rts[0]) : GetWrapped(rs.rts[i]);
if(h.heap != ResourceId())
if(desc)
{
D3D12Descriptor *desc = DescriptorFromPortableHandle(rm, h);
if(rs.rtSingle)
desc += i;
@@ -1118,9 +1116,9 @@ void D3D12Replay::SavePipelineState()
{
D3D12Pipe::View &view = state.m_OM.DepthTarget;
if(rs.dsv.heap != ResourceId())
if(rs.dsv.ptr)
{
D3D12Descriptor *desc = DescriptorFromPortableHandle(rm, rs.dsv);
D3D12Descriptor *desc = GetWrapped(rs.dsv);
view.RootElement = 0;
view.Immediate = false;
@@ -1255,12 +1253,10 @@ bool D3D12Replay::IsRenderOutput(ResourceId id)
for(size_t i = 0; i < rs.rts.size(); i++)
{
PortableHandle h = rs.rtSingle ? rs.rts[0] : rs.rts[i];
D3D12Descriptor *desc = rs.rtSingle ? GetWrapped(rs.rts[0]) : GetWrapped(rs.rts[i]);
if(h.heap != ResourceId())
if(desc)
{
D3D12Descriptor *desc = DescriptorFromPortableHandle(m_pDevice->GetResourceManager(), h);
if(rs.rtSingle)
desc += i;
@@ -1269,9 +1265,9 @@ bool D3D12Replay::IsRenderOutput(ResourceId id)
}
}
if(rs.dsv.heap != ResourceId())
if(rs.dsv.ptr)
{
D3D12Descriptor *desc = DescriptorFromPortableHandle(m_pDevice->GetResourceManager(), rs.dsv);
D3D12Descriptor *desc = GetWrapped(rs.dsv);
if(id == GetResID(desc->nonsamp.resource))
return true;
+11 -14
View File
@@ -34,7 +34,7 @@ D3D12RenderState::D3D12RenderState()
rts.clear();
rtSingle = false;
dsv = PortableHandle();
dsv = D3D12_CPU_DESCRIPTOR_HANDLE();
m_ResourceManager = NULL;
@@ -89,7 +89,7 @@ vector<ResourceId> D3D12RenderState::GetRTVIDs() const
{
if(!rts.empty())
{
const D3D12Descriptor *descs = DescriptorFromPortableHandle(GetResourceManager(), rts[0]);
const D3D12Descriptor *descs = GetWrapped(rts[0]);
for(UINT i = 0; i < rts.size(); i++)
{
@@ -102,13 +102,10 @@ vector<ResourceId> D3D12RenderState::GetRTVIDs() const
{
for(UINT i = 0; i < rts.size(); i++)
{
WrappedID3D12DescriptorHeap *heap =
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(rts[0].heap);
const D3D12Descriptor *desc = GetWrapped(rts[i]);
const D3D12Descriptor &desc = heap->GetDescriptors()[rts[i].index];
RDCASSERT(desc.GetType() == D3D12DescriptorType::RTV);
ret.push_back(GetResID(desc.nonsamp.resource));
RDCASSERT(desc->GetType() == D3D12DescriptorType::RTV);
ret.push_back(GetResID(desc->nonsamp.resource));
}
}
@@ -117,9 +114,9 @@ vector<ResourceId> D3D12RenderState::GetRTVIDs() const
ResourceId D3D12RenderState::GetDSVID() const
{
if(dsv.heap != ResourceId())
if(dsv.ptr)
{
const D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv);
const D3D12Descriptor *desc = GetWrapped(dsv);
RDCASSERT(desc->GetType() == D3D12DescriptorType::DSV);
@@ -186,20 +183,20 @@ void D3D12RenderState::ApplyState(ID3D12GraphicsCommandList *cmd) const
}
}
if(!rts.empty() || dsv.heap != ResourceId())
if(!rts.empty() || dsv.ptr)
{
D3D12_CPU_DESCRIPTOR_HANDLE rtHandles[8];
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = CPUHandleFromPortableHandle(GetResourceManager(), dsv);
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = Unwrap(dsv);
UINT rtCount = (UINT)rts.size();
UINT numActualHandles = rtSingle ? RDCMIN(1U, rtCount) : rtCount;
for(UINT i = 0; i < numActualHandles; i++)
rtHandles[i] = CPUHandleFromPortableHandle(GetResourceManager(), rts[i]);
rtHandles[i] = Unwrap(rts[i]);
// need to unwrap here, as FromPortableHandle unwraps too.
Unwrap(cmd)->OMSetRenderTargets((UINT)rts.size(), rtHandles, rtSingle ? TRUE : FALSE,
dsv.heap != ResourceId() ? &dsvHandle : NULL);
dsv.ptr ? &dsvHandle : NULL);
}
}
+2 -2
View File
@@ -52,9 +52,9 @@ struct D3D12RenderState
vector<D3D12_VIEWPORT> views;
vector<D3D12_RECT> scissors;
vector<PortableHandle> rts;
vector<D3D12_CPU_DESCRIPTOR_HANDLE> rts;
bool rtSingle;
PortableHandle dsv;
D3D12_CPU_DESCRIPTOR_HANDLE dsv;
vector<ResourceId> GetRTVIDs() const;
ResourceId GetDSVID() const;