mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-07 15:20:58 +00:00
Track resource event usage
This commit is contained in:
@@ -389,6 +389,8 @@ enum ResourceUsage
|
||||
eUsage_PS_Constants,
|
||||
eUsage_CS_Constants,
|
||||
|
||||
eUsage_All_Constants,
|
||||
|
||||
eUsage_SO,
|
||||
|
||||
eUsage_VS_Resource,
|
||||
@@ -398,6 +400,8 @@ enum ResourceUsage
|
||||
eUsage_PS_Resource,
|
||||
eUsage_CS_Resource,
|
||||
|
||||
eUsage_All_Resource,
|
||||
|
||||
eUsage_VS_RWResource,
|
||||
eUsage_HS_RWResource,
|
||||
eUsage_DS_RWResource,
|
||||
@@ -405,6 +409,8 @@ enum ResourceUsage
|
||||
eUsage_PS_RWResource,
|
||||
eUsage_CS_RWResource,
|
||||
|
||||
eUsage_All_RWResource,
|
||||
|
||||
eUsage_InputTarget,
|
||||
eUsage_ColourTarget,
|
||||
eUsage_DepthStencilTarget,
|
||||
|
||||
@@ -786,6 +786,8 @@ bool WrappedID3D12GraphicsCommandList::Serialise_IASetIndexBuffer(const D3D12_IN
|
||||
{
|
||||
list->IASetIndexBuffer(&view);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.ibuffer =
|
||||
WrappedID3D12Resource::GetResIDFromAddr(view.BufferLocation);
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.idxWidth =
|
||||
(view.Format == DXGI_FORMAT_R32_UINT ? 4 : 2);
|
||||
}
|
||||
@@ -793,6 +795,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_IASetIndexBuffer(const D3D12_IN
|
||||
{
|
||||
list->IASetIndexBuffer(NULL);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.ibuffer = ResourceId();
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.idxWidth = 2;
|
||||
}
|
||||
}
|
||||
@@ -850,6 +853,13 @@ bool WrappedID3D12GraphicsCommandList::Serialise_IASetVertexBuffers(
|
||||
else if(m_State == READING)
|
||||
{
|
||||
GetList(CommandList)->IASetVertexBuffers(start, num, views);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.vbuffers.size() < start + num)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.vbuffers.resize(start + num);
|
||||
|
||||
for(UINT i = 0; i < num; i++)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.vbuffers[start + i] =
|
||||
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferLocation);
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(views);
|
||||
@@ -910,6 +920,17 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SOSetTargets(
|
||||
else if(m_State == READING)
|
||||
{
|
||||
GetList(CommandList)->SOSetTargets(start, num, views);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.sotargets.size() < start + num)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.sotargets.resize(start + num);
|
||||
|
||||
for(UINT i = 0; i < num; i++)
|
||||
{
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.sotargets[start + i] =
|
||||
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferLocation);
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.socounters[start + i] =
|
||||
WrappedID3D12Resource::GetResIDFromAddr(views[i].BufferFilledSizeLocation);
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(views);
|
||||
@@ -1050,10 +1071,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets(
|
||||
|
||||
if(singlehandle)
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(rts[0].heap);
|
||||
|
||||
const D3D12Descriptor *descs = heap->GetDescriptors() + rts[0].index;
|
||||
const D3D12Descriptor *descs = DescriptorFromPortableHandle(GetResourceManager(), rts[0]);
|
||||
|
||||
for(UINT i = 0; i < num; i++)
|
||||
{
|
||||
@@ -1077,14 +1095,11 @@ bool WrappedID3D12GraphicsCommandList::Serialise_OMSetRenderTargets(
|
||||
|
||||
if(dsv.heap != ResourceId())
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(dsv.heap);
|
||||
const D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv);
|
||||
|
||||
const D3D12Descriptor &desc = heap->GetDescriptors()[dsv.index];
|
||||
RDCASSERT(desc->GetType() == D3D12Descriptor::TypeDSV);
|
||||
|
||||
RDCASSERT(desc.GetType() == D3D12Descriptor::TypeDSV);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.dsv = GetResID(desc.nonsamp.resource);
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.dsv = GetResID(desc->nonsamp.resource);
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(rtHandles);
|
||||
@@ -1169,6 +1184,10 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootSignature(
|
||||
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
|
||||
|
||||
GetList(CommandList)->SetComputeRootSignature(Unwrap(pRootSignature));
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.rootsig != GetResID(pRootSignature))
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.clear();
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.rootsig = GetResID(pRootSignature);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1224,6 +1243,15 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootDescriptorTable(
|
||||
GetList(CommandList)
|
||||
->SetComputeRootDescriptorTable(
|
||||
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.resize(idx + 1);
|
||||
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1415,6 +1443,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootConstantBufferVie
|
||||
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
|
||||
|
||||
GetList(CommandList)->SetComputeRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1477,6 +1511,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootShaderResourceVie
|
||||
WrappedID3D12Resource *pRes = GetResourceManager()->GetLiveAs<WrappedID3D12Resource>(buffer);
|
||||
|
||||
GetList(CommandList)->SetComputeRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1540,6 +1580,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetComputeRootUnorderedAccessVi
|
||||
|
||||
GetList(CommandList)
|
||||
->SetComputeRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1601,6 +1647,10 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootSignature(
|
||||
pRootSignature = GetResourceManager()->GetLiveAs<ID3D12RootSignature>(sig);
|
||||
|
||||
GetList(CommandList)->SetGraphicsRootSignature(Unwrap(pRootSignature));
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.rootsig != GetResID(pRootSignature))
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.sigelems.clear();
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.compute.rootsig = GetResID(pRootSignature);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1656,6 +1706,15 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootDescriptorTable(
|
||||
GetList(CommandList)
|
||||
->SetGraphicsRootDescriptorTable(
|
||||
idx, GPUHandleFromPortableHandle(GetResourceManager(), Descriptor));
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.resize(idx + 1);
|
||||
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(Descriptor.heap);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootTable, GetResID(heap), (UINT64)Descriptor.index);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1848,6 +1907,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootConstantBufferVi
|
||||
|
||||
GetList(CommandList)
|
||||
->SetGraphicsRootConstantBufferView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootCBV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1911,6 +1976,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootShaderResourceVi
|
||||
|
||||
GetList(CommandList)
|
||||
->SetGraphicsRootShaderResourceView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootSRV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1974,6 +2045,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetGraphicsRootUnorderedAccessV
|
||||
|
||||
GetList(CommandList)
|
||||
->SetGraphicsRootUnorderedAccessView(idx, pRes->GetGPUVirtualAddress() + byteOffset);
|
||||
|
||||
if(m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.size() < idx + 1)
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems.resize(idx + 1);
|
||||
|
||||
m_Cmd->m_BakedCmdListInfo[CommandList].state.graphics.sigelems[idx] =
|
||||
D3D12RenderState::SignatureElement(eRootUAV, GetResID(pRes), byteOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2545,12 +2622,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearDepthStencilView(
|
||||
|
||||
m_Cmd->AddDrawcall(draw, true);
|
||||
|
||||
D3D12NOTIMP("Getting image for DSV to mark usage");
|
||||
D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv);
|
||||
|
||||
// D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
|
||||
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
|
||||
|
||||
// drawNode.resourceUsage.push_back(
|
||||
// std::make_pair(GetResID(image), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
|
||||
drawNode.resourceUsage.push_back(std::make_pair(
|
||||
GetResID(desc->nonsamp.resource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2630,12 +2707,12 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearRenderTargetView(
|
||||
|
||||
m_Cmd->AddDrawcall(draw, true);
|
||||
|
||||
D3D12NOTIMP("Getting image for RTV to mark usage");
|
||||
D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), rtv);
|
||||
|
||||
// D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
|
||||
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
|
||||
|
||||
// drawNode.resourceUsage.push_back(
|
||||
// std::make_pair(GetResID(image), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
|
||||
drawNode.resourceUsage.push_back(std::make_pair(
|
||||
GetResID(desc->nonsamp.resource), EventUsage(drawNode.draw.eventID, eUsage_Clear)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
void ReplayLog(LogState readType, uint32_t startEventID, uint32_t endEventID, bool partial);
|
||||
|
||||
D3D12CommandData *GetCommandData() { return &m_Cmd; }
|
||||
vector<EventUsage> GetUsage(ResourceId id) { return m_Cmd.m_ResourceUses[id]; }
|
||||
const vector<EventUsage> &GetUsage(ResourceId id) { return m_Cmd.m_ResourceUses[id]; }
|
||||
// interface for DXGI
|
||||
virtual IUnknown *GetRealIUnknown() { return GetReal(); }
|
||||
virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); }
|
||||
|
||||
@@ -818,6 +818,175 @@ void D3D12CommandData::AddEvent(D3D12ChunkType type, string description)
|
||||
m_EventMessages.clear();
|
||||
}
|
||||
|
||||
void D3D12CommandData::AddUsage(D3D12DrawcallTreeNode &drawNode, ResourceId id, uint32_t EID,
|
||||
ResourceUsage usage)
|
||||
{
|
||||
if(id == ResourceId())
|
||||
return;
|
||||
|
||||
drawNode.resourceUsage.push_back(std::make_pair(id, EventUsage(EID, usage)));
|
||||
}
|
||||
|
||||
void D3D12CommandData::AddUsage(D3D12DrawcallTreeNode &drawNode)
|
||||
{
|
||||
FetchDrawcall &d = drawNode.draw;
|
||||
|
||||
const BakedCmdListInfo::CmdListState &state = m_BakedCmdListInfo[m_LastCmdListID].state;
|
||||
uint32_t e = d.eventID;
|
||||
|
||||
if((d.flags & (eDraw_Drawcall | eDraw_Dispatch)) == 0)
|
||||
return;
|
||||
|
||||
const BakedCmdListInfo::CmdListState::RootSignature *rootdata = NULL;
|
||||
|
||||
if((d.flags & eDraw_Dispatch) && state.compute.rootsig != ResourceId())
|
||||
{
|
||||
rootdata = &state.compute;
|
||||
}
|
||||
else if(state.graphics.rootsig != ResourceId())
|
||||
{
|
||||
rootdata = &state.graphics;
|
||||
|
||||
if(d.flags & eDraw_UseIBuffer && state.ibuffer != ResourceId())
|
||||
drawNode.resourceUsage.push_back(
|
||||
std::make_pair(state.ibuffer, EventUsage(e, eUsage_IndexBuffer)));
|
||||
|
||||
for(size_t i = 0; i < state.vbuffers.size(); i++)
|
||||
{
|
||||
if(state.vbuffers[i] != ResourceId())
|
||||
drawNode.resourceUsage.push_back(
|
||||
std::make_pair(state.vbuffers[i], EventUsage(e, eUsage_VertexBuffer)));
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < state.sotargets.size(); i++)
|
||||
{
|
||||
if(state.sotargets[i] != ResourceId())
|
||||
drawNode.resourceUsage.push_back(std::make_pair(state.sotargets[i], EventUsage(e, eUsage_SO)));
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < state.socounters.size(); i++)
|
||||
{
|
||||
if(state.socounters[i] != ResourceId())
|
||||
drawNode.resourceUsage.push_back(
|
||||
std::make_pair(state.socounters[i], EventUsage(e, eUsage_SO)));
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < ARRAY_COUNT(state.rts); i++)
|
||||
{
|
||||
if(state.rts[i] != ResourceId())
|
||||
drawNode.resourceUsage.push_back(
|
||||
std::make_pair(state.rts[i], EventUsage(e, eUsage_ColourTarget)));
|
||||
}
|
||||
|
||||
if(state.dsv != ResourceId())
|
||||
drawNode.resourceUsage.push_back(
|
||||
std::make_pair(state.dsv, EventUsage(e, eUsage_DepthStencilTarget)));
|
||||
}
|
||||
|
||||
if(rootdata)
|
||||
{
|
||||
WrappedID3D12RootSignature *sig =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12RootSignature>(rootdata->rootsig);
|
||||
|
||||
for(size_t rootEl = 0; rootEl < sig->sig.params.size(); rootEl++)
|
||||
{
|
||||
if(rootEl >= rootdata->sigelems.size())
|
||||
break;
|
||||
|
||||
const D3D12RootSignatureParameter &p = sig->sig.params[rootEl];
|
||||
const D3D12RenderState::SignatureElement &el = rootdata->sigelems[rootEl];
|
||||
|
||||
ResourceUsage cb = eUsage_CS_Constants;
|
||||
ResourceUsage ro = eUsage_CS_Resource;
|
||||
ResourceUsage rw = eUsage_CS_RWResource;
|
||||
|
||||
if(rootdata == &state.graphics)
|
||||
{
|
||||
if(p.ShaderVisibility == D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
cb = eUsage_All_Constants;
|
||||
ro = eUsage_All_Resource;
|
||||
rw = eUsage_All_RWResource;
|
||||
}
|
||||
else
|
||||
{
|
||||
cb = ResourceUsage(eUsage_VS_Constants + p.ShaderVisibility -
|
||||
D3D12_SHADER_VISIBILITY_VERTEX);
|
||||
ro = ResourceUsage(eUsage_VS_Resource + p.ShaderVisibility - D3D12_SHADER_VISIBILITY_VERTEX);
|
||||
rw = ResourceUsage(eUsage_VS_RWResource + p.ShaderVisibility -
|
||||
D3D12_SHADER_VISIBILITY_VERTEX);
|
||||
}
|
||||
}
|
||||
|
||||
if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV && el.type == eRootCBV)
|
||||
{
|
||||
AddUsage(drawNode, el.id, e, cb);
|
||||
}
|
||||
else if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV && el.type == eRootSRV)
|
||||
{
|
||||
AddUsage(drawNode, el.id, e, ro);
|
||||
}
|
||||
else if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV && el.type == eRootUAV)
|
||||
{
|
||||
AddUsage(drawNode, el.id, e, rw);
|
||||
}
|
||||
else if(p.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE && el.type == eRootTable)
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12DescriptorHeap>(el.id);
|
||||
|
||||
if(heap == NULL)
|
||||
continue;
|
||||
|
||||
UINT prevTableOffset = 0;
|
||||
|
||||
for(size_t r = 0; r < p.ranges.size(); r++)
|
||||
{
|
||||
const D3D12_DESCRIPTOR_RANGE &range = p.ranges[r];
|
||||
|
||||
UINT offset = range.OffsetInDescriptorsFromTableStart;
|
||||
|
||||
if(range.OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
|
||||
offset = prevTableOffset;
|
||||
|
||||
D3D12Descriptor *desc = (D3D12Descriptor *)heap->GetCPUDescriptorHandleForHeapStart().ptr;
|
||||
desc += el.offset;
|
||||
desc += offset;
|
||||
|
||||
prevTableOffset = offset + range.NumDescriptors;
|
||||
|
||||
if(range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_CBV)
|
||||
{
|
||||
EventUsage usage(e, cb);
|
||||
|
||||
for(UINT i = 0; i < range.NumDescriptors; i++)
|
||||
{
|
||||
ResourceId id =
|
||||
WrappedID3D12Resource::GetResIDFromAddr(desc->nonsamp.cbv.BufferLocation);
|
||||
|
||||
AddUsage(drawNode, id, e, cb);
|
||||
|
||||
desc++;
|
||||
}
|
||||
}
|
||||
else if(range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV ||
|
||||
range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_UAV)
|
||||
{
|
||||
ResourceUsage usage = range.RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SRV ? ro : rw;
|
||||
|
||||
for(UINT i = 0; i < range.NumDescriptors; i++)
|
||||
{
|
||||
AddUsage(drawNode, GetResID(desc->nonsamp.resource), e, usage);
|
||||
|
||||
desc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12CommandData::AddDrawcall(const FetchDrawcall &d, bool hasEvents)
|
||||
{
|
||||
m_AddedDrawcall = true;
|
||||
@@ -868,7 +1037,8 @@ void D3D12CommandData::AddDrawcall(const FetchDrawcall &d, bool hasEvents)
|
||||
|
||||
node.resourceUsage.swap(m_BakedCmdListInfo[m_LastCmdListID].resourceUsage);
|
||||
|
||||
D3D12NOTIMP("event usage");
|
||||
if(m_LastCmdListID != ResourceId())
|
||||
AddUsage(node);
|
||||
|
||||
node.children.insert(node.children.begin(), draw.children.elems,
|
||||
draw.children.elems + draw.children.count);
|
||||
@@ -885,7 +1055,6 @@ void D3D12CommandData::InsertDrawsAndRefreshIDs(vector<D3D12DrawcallTreeNode> &c
|
||||
{
|
||||
if(cmdBufNodes[i].draw.flags & eDraw_PopMarker)
|
||||
{
|
||||
RDCASSERT(GetDrawcallStack().size() > 1);
|
||||
if(GetDrawcallStack().size() > 1)
|
||||
GetDrawcallStack().pop_back();
|
||||
|
||||
|
||||
@@ -152,6 +152,17 @@ struct BakedCmdListInfo
|
||||
D3D12_PRIMITIVE_TOPOLOGY topo;
|
||||
|
||||
uint32_t idxWidth;
|
||||
ResourceId ibuffer;
|
||||
vector<ResourceId> vbuffers;
|
||||
|
||||
vector<ResourceId> sotargets, socounters;
|
||||
|
||||
struct RootSignature
|
||||
{
|
||||
ResourceId rootsig;
|
||||
|
||||
vector<D3D12RenderState::SignatureElement> sigelems;
|
||||
} compute, graphics;
|
||||
|
||||
ResourceId rts[8];
|
||||
ResourceId dsv;
|
||||
@@ -304,4 +315,6 @@ struct D3D12CommandData
|
||||
|
||||
void AddDrawcall(const FetchDrawcall &d, bool hasEvents);
|
||||
void AddEvent(D3D12ChunkType type, string description);
|
||||
void AddUsage(D3D12DrawcallTreeNode &drawNode);
|
||||
void AddUsage(D3D12DrawcallTreeNode &drawNode, ResourceId id, uint32_t EID, ResourceUsage usage);
|
||||
};
|
||||
|
||||
@@ -579,19 +579,14 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorWrite(Serialiser *localSeri
|
||||
|
||||
if(m_State <= EXECUTING)
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(dst.heap);
|
||||
D3D12Descriptor *handle = DescriptorFromPortableHandle(GetResourceManager(), dst);
|
||||
|
||||
if(heap)
|
||||
if(handle)
|
||||
{
|
||||
// get the wrapped handle
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle = heap->GetCPUDescriptorHandleForHeapStart();
|
||||
handle.ptr += dst.index * sizeof(D3D12Descriptor);
|
||||
|
||||
// safe to pass an invalid heap type to Create() as these descriptors will by definition not
|
||||
// be undefined
|
||||
RDCASSERT(desc.GetType() != D3D12Descriptor::TypeUndefined);
|
||||
desc.Create(D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, this, handle);
|
||||
desc.Create(D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, this, *handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1399,17 +1394,8 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorCopies(
|
||||
if(m_State <= EXECUTING)
|
||||
{
|
||||
// do a wrapped copy so that internal tracking is also updated
|
||||
WrappedID3D12DescriptorHeap *srcHeap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(src.heap);
|
||||
WrappedID3D12DescriptorHeap *dstHeap =
|
||||
GetResourceManager()->GetLiveAs<WrappedID3D12DescriptorHeap>(dst.heap);
|
||||
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE srchandle = srcHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
srchandle.ptr += src.index * sizeof(D3D12Descriptor);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE dsthandle = dstHeap->GetCPUDescriptorHandleForHeapStart();
|
||||
dsthandle.ptr += dst.index * sizeof(D3D12Descriptor);
|
||||
|
||||
CopyDescriptorsSimple(1, dsthandle, srchandle, type);
|
||||
CopyDescriptorsSimple(1, *DescriptorFromPortableHandle(GetResourceManager(), dst),
|
||||
*DescriptorFromPortableHandle(GetResourceManager(), src), type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,6 +339,19 @@ D3D12_GPU_DESCRIPTOR_HANDLE GPUHandleFromPortableHandle(D3D12ResourceManager *ma
|
||||
return D3D12_GPU_DESCRIPTOR_HANDLE();
|
||||
}
|
||||
|
||||
D3D12Descriptor *DescriptorFromPortableHandle(D3D12ResourceManager *manager, PortableHandle handle)
|
||||
{
|
||||
if(handle.heap == ResourceId())
|
||||
return NULL;
|
||||
|
||||
WrappedID3D12DescriptorHeap *heap = manager->GetLiveAs<WrappedID3D12DescriptorHeap>(handle.heap);
|
||||
|
||||
if(heap)
|
||||
return heap->GetDescriptors() + handle.index;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// debugging logging for barriers
|
||||
#if 1
|
||||
#define BARRIER_DBG RDCLOG
|
||||
|
||||
@@ -140,6 +140,20 @@ struct D3D12Descriptor
|
||||
return nonsamp.type;
|
||||
}
|
||||
|
||||
operator D3D12_CPU_DESCRIPTOR_HANDLE() const
|
||||
{
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle;
|
||||
handle.ptr = (SIZE_T) this;
|
||||
return handle;
|
||||
}
|
||||
|
||||
operator D3D12_GPU_DESCRIPTOR_HANDLE() const
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE handle;
|
||||
handle.ptr = (SIZE_T) this;
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Init(const D3D12_SAMPLER_DESC *pDesc);
|
||||
void Init(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc);
|
||||
void Init(ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc);
|
||||
@@ -225,6 +239,7 @@ D3D12_CPU_DESCRIPTOR_HANDLE CPUHandleFromPortableHandle(D3D12ResourceManager *ma
|
||||
PortableHandle handle);
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GPUHandleFromPortableHandle(D3D12ResourceManager *manager,
|
||||
PortableHandle handle);
|
||||
D3D12Descriptor *DescriptorFromPortableHandle(D3D12ResourceManager *manager, PortableHandle handle);
|
||||
|
||||
struct DynamicDescriptorWrite
|
||||
{
|
||||
|
||||
@@ -1033,9 +1033,7 @@ void D3D12Replay::MakePipelineState()
|
||||
|
||||
if(h.heap != ResourceId())
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap = rm->GetLiveAs<WrappedID3D12DescriptorHeap>(h.heap);
|
||||
D3D12Descriptor *desc =
|
||||
(D3D12Descriptor *)heap->GetCPUDescriptorHandleForHeapStart().ptr + h.index;
|
||||
D3D12Descriptor *desc = DescriptorFromPortableHandle(rm, h);
|
||||
|
||||
if(rs.rtSingle)
|
||||
desc += i;
|
||||
@@ -1052,9 +1050,7 @@ void D3D12Replay::MakePipelineState()
|
||||
|
||||
if(rs.dsv.heap != ResourceId())
|
||||
{
|
||||
WrappedID3D12DescriptorHeap *heap = rm->GetLiveAs<WrappedID3D12DescriptorHeap>(rs.dsv.heap);
|
||||
D3D12Descriptor *desc =
|
||||
(D3D12Descriptor *)heap->GetCPUDescriptorHandleForHeapStart().ptr + rs.dsv.index;
|
||||
D3D12Descriptor *desc = DescriptorFromPortableHandle(rm, rs.dsv);
|
||||
|
||||
view.RootElement = 0;
|
||||
view.Immediate = false;
|
||||
|
||||
@@ -334,7 +334,7 @@ public:
|
||||
const D3D12_DESCRIPTOR_HEAP_DESC &desc);
|
||||
virtual ~WrappedID3D12DescriptorHeap();
|
||||
|
||||
const D3D12Descriptor *GetDescriptors() { return descriptors; }
|
||||
D3D12Descriptor *GetDescriptors() { return descriptors; }
|
||||
UINT GetNumDescriptors() { return numDescriptors; }
|
||||
bool Resident() { return resident != 0; }
|
||||
void SetResident(bool r) { resident = r ? 1 : 0; }
|
||||
@@ -661,6 +661,9 @@ public:
|
||||
id = ResourceId();
|
||||
offs = 0;
|
||||
|
||||
if(addr == 0)
|
||||
return;
|
||||
|
||||
if(m_Addresses.empty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -400,6 +400,7 @@ namespace renderdoc
|
||||
GS_Constants,
|
||||
PS_Constants,
|
||||
CS_Constants,
|
||||
All_Constants,
|
||||
|
||||
SO,
|
||||
|
||||
@@ -409,6 +410,7 @@ namespace renderdoc
|
||||
GS_Resource,
|
||||
PS_Resource,
|
||||
CS_Resource,
|
||||
All_Resource,
|
||||
|
||||
VS_RWResource,
|
||||
HS_RWResource,
|
||||
@@ -416,6 +418,7 @@ namespace renderdoc
|
||||
GS_RWResource,
|
||||
PS_RWResource,
|
||||
CS_RWResource,
|
||||
All_RWResource,
|
||||
|
||||
InputTarget,
|
||||
ColourTarget,
|
||||
@@ -711,6 +714,7 @@ namespace renderdoc
|
||||
case ResourceUsage.DS_Constants: return "DS - Constant Buffer";
|
||||
case ResourceUsage.CS_Constants: return "CS - Constant Buffer";
|
||||
case ResourceUsage.PS_Constants: return "PS - Constant Buffer";
|
||||
case ResourceUsage.All_Constants: return "All - Constant Buffer";
|
||||
|
||||
case ResourceUsage.SO: return "Stream Out";
|
||||
|
||||
@@ -720,6 +724,7 @@ namespace renderdoc
|
||||
case ResourceUsage.DS_Resource: return "DS - Resource";
|
||||
case ResourceUsage.CS_Resource: return "CS - Resource";
|
||||
case ResourceUsage.PS_Resource: return "PS - Resource";
|
||||
case ResourceUsage.All_Resource: return "All - Resource";
|
||||
|
||||
case ResourceUsage.VS_RWResource: return "VS - UAV";
|
||||
case ResourceUsage.HS_RWResource: return "HS - UAV";
|
||||
@@ -727,6 +732,7 @@ namespace renderdoc
|
||||
case ResourceUsage.GS_RWResource: return "GS - UAV";
|
||||
case ResourceUsage.PS_RWResource: return "PS - UAV";
|
||||
case ResourceUsage.CS_RWResource: return "CS - UAV";
|
||||
case ResourceUsage.All_RWResource: return "All - UAV";
|
||||
|
||||
case ResourceUsage.InputTarget: return "Colour Input";
|
||||
case ResourceUsage.ColourTarget: return "Rendertarget";
|
||||
@@ -760,6 +766,7 @@ namespace renderdoc
|
||||
case ResourceUsage.DS_Constants: return "DS - Uniform Buffer";
|
||||
case ResourceUsage.CS_Constants: return "CS - Uniform Buffer";
|
||||
case ResourceUsage.PS_Constants: return "PS - Uniform Buffer";
|
||||
case ResourceUsage.All_Constants: return "All - Uniform Buffer";
|
||||
|
||||
case ResourceUsage.SO: return "Transform Feedback";
|
||||
|
||||
@@ -769,6 +776,7 @@ namespace renderdoc
|
||||
case ResourceUsage.DS_Resource: return "DS - Texture";
|
||||
case ResourceUsage.CS_Resource: return "CS - Texture";
|
||||
case ResourceUsage.PS_Resource: return "PS - Texture";
|
||||
case ResourceUsage.All_Resource: return "All - Texture";
|
||||
|
||||
case ResourceUsage.VS_RWResource: return "VS - Image/SSBO";
|
||||
case ResourceUsage.HS_RWResource: return "HS - Image/SSBO";
|
||||
@@ -776,6 +784,7 @@ namespace renderdoc
|
||||
case ResourceUsage.GS_RWResource: return "GS - Image/SSBO";
|
||||
case ResourceUsage.PS_RWResource: return "PS - Image/SSBO";
|
||||
case ResourceUsage.CS_RWResource: return "CS - Image/SSBO";
|
||||
case ResourceUsage.All_RWResource: return "All - Image/SSBO";
|
||||
|
||||
case ResourceUsage.InputTarget: return "FBO Input";
|
||||
case ResourceUsage.ColourTarget: return "FBO Colour";
|
||||
|
||||
@@ -661,7 +661,7 @@ namespace renderdocui.Windows
|
||||
// read/write
|
||||
if (
|
||||
((int)u.usage >= (int)ResourceUsage.VS_RWResource &&
|
||||
(int)u.usage <= (int)ResourceUsage.CS_RWResource) ||
|
||||
(int)u.usage <= (int)ResourceUsage.All_RWResource) ||
|
||||
u.usage == ResourceUsage.GenMips ||
|
||||
u.usage == ResourceUsage.Copy ||
|
||||
u.usage == ResourceUsage.Resolve)
|
||||
|
||||
Reference in New Issue
Block a user