Track root signature and its contents for matching against root sets

This commit is contained in:
baldurk
2016-07-31 15:56:22 +07:00
parent 699dde6563
commit 7095c663a2
8 changed files with 88 additions and 2 deletions
+5 -1
View File
@@ -89,6 +89,8 @@ class WrappedID3D12GraphicsCommandList : public RefCounter12<ID3D12GraphicsComma
// command recording/replay data shared between queues and lists
D3D12CommandData *m_Cmd;
WrappedID3D12RootSignature *m_CurRootSig;
ResourceId m_ResourceID;
D3D12ResourceRecord *m_ListRecord;
@@ -107,7 +109,9 @@ class WrappedID3D12GraphicsCommandList : public RefCounter12<ID3D12GraphicsComma
const char *GetChunkName(uint32_t idx) { return m_pDevice->GetChunkName(idx); }
D3D12ResourceManager *GetResourceManager() { return m_pDevice->GetResourceManager(); }
public:
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12GraphicsCommandList);
static const int AllocPoolCount = 8192;
static const int AllocMaxByteSize = 2 * 1024 * 1024;
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12GraphicsCommandList, AllocPoolCount, AllocMaxByteSize);
WrappedID3D12GraphicsCommandList(ID3D12GraphicsCommandList *real, WrappedID3D12Device *device,
Serialiser *serialiser, LogState &state);
@@ -955,6 +955,9 @@ void WrappedID3D12GraphicsCommandList::SetGraphicsRootSignature(ID3D12RootSignat
m_ListRecord->AddChunk(scope.Get());
m_ListRecord->MarkResourceFrameReferenced(GetResID(pRootSignature), eFrameRef_Read);
// store this so we can look up how many descriptors a given slot references, etc
m_CurRootSig = GetWrapped(pRootSignature);
}
}
@@ -505,6 +505,8 @@ WrappedID3D12GraphicsCommandList::WrappedID3D12GraphicsCommandList(ID3D12Graphic
m_ListRecord = NULL;
m_Cmd = NULL;
m_CurRootSig = NULL;
if(!RenderDoc::Inst().IsReplayApp())
{
m_ListRecord = m_pDevice->GetResourceManager()->AddResourceRecord(m_ResourceID);
+31
View File
@@ -120,6 +120,37 @@ public:
}
};
struct D3D12RootSignatureParameter : D3D12_ROOT_PARAMETER
{
void MakeFrom(const D3D12_ROOT_PARAMETER &param)
{
ParameterType = param.ParameterType;
ShaderVisibility = param.ShaderVisibility;
// copy the POD ones first
Descriptor = param.Descriptor;
Constants = param.Constants;
if(ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
{
ranges.resize(param.DescriptorTable.NumDescriptorRanges);
for(size_t i = 0; i < ranges.size(); i++)
ranges[i] = param.DescriptorTable.pDescriptorRanges[i];
DescriptorTable.NumDescriptorRanges = (UINT)ranges.size();
DescriptorTable.pDescriptorRanges = &ranges[0];
}
}
vector<D3D12_DESCRIPTOR_RANGE> ranges;
};
struct D3D12RootSignature
{
vector<D3D12RootSignatureParameter> params;
vector<D3D12_STATIC_SAMPLER_DESC> samplers;
};
#define IMPLEMENT_IUNKNOWN_WITH_REFCOUNTER_CUSTOMQUERY \
ULONG STDMETHODCALLTYPE AddRef() { return RefCounter12::AddRef(); } \
ULONG STDMETHODCALLTYPE Release() { return RefCounter12::Release(); }
+40
View File
@@ -712,6 +712,46 @@ string D3D12DebugManager::GetShaderBlob(const char *source, const char *entry,
return errors;
}
D3D12RootSignature D3D12DebugManager::GetRootSig(const void *data, size_t dataSize)
{
PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER deserializeRootSig =
(PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER)GetProcAddress(
GetModuleHandleA("d3d12.dll"), "D3D12CreateRootSignatureDeserializer");
if(deserializeRootSig == NULL)
{
RDCERR("Can't get D3D12CreateRootSignatureDeserializer");
return D3D12RootSignature();
}
ID3D12RootSignatureDeserializer *deser = NULL;
HRESULT hr =
deserializeRootSig(data, dataSize, __uuidof(ID3D12RootSignatureDeserializer), (void **)&deser);
if(FAILED(hr))
{
SAFE_RELEASE(deser);
RDCERR("Can't get deserializer");
return D3D12RootSignature();
}
D3D12RootSignature ret;
const D3D12_ROOT_SIGNATURE_DESC *desc = deser->GetRootSignatureDesc();
ret.params.resize(desc->NumParameters);
for(size_t i = 0; i < ret.params.size(); i++)
ret.params[i].MakeFrom(desc->pParameters[i]);
if(desc->NumStaticSamplers > 0)
ret.samplers.assign(desc->pStaticSamplers, desc->pStaticSamplers + desc->NumStaticSamplers);
SAFE_RELEASE(deser);
return ret;
}
ID3DBlob *D3D12DebugManager::MakeRootSig(const vector<D3D12_ROOT_PARAMETER> &rootSig)
{
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE serializeRootSig =
+3 -1
View File
@@ -71,6 +71,8 @@ public:
D3D12_CPU_DESCRIPTOR_HANDLE AllocRTV();
void FreeRTV(D3D12_CPU_DESCRIPTOR_HANDLE handle);
static D3D12RootSignature GetRootSig(const void *data, size_t dataSize);
private:
struct OutputWindow
{
@@ -168,7 +170,7 @@ private:
string GetShaderBlob(const char *source, const char *entry, const uint32_t compileFlags,
const char *profile, ID3DBlob **srcblob);
ID3DBlob *MakeRootSig(const vector<D3D12_ROOT_PARAMETER> &rootSig);
static ID3DBlob *MakeRootSig(const vector<D3D12_ROOT_PARAMETER> &rootSig);
int m_width, m_height;
@@ -544,6 +544,8 @@ HRESULT WrappedID3D12Device::CreateRootSignature(UINT nodeMask, const void *pBlo
record->Length = 0;
wrapped->SetResourceRecord(record);
wrapped->sig = D3D12DebugManager::GetRootSig(pBlobWithRootSignature, blobLengthInBytes);
record->AddChunk(scope.Get());
}
else
+2
View File
@@ -582,6 +582,8 @@ class WrappedID3D12RootSignature : public WrappedDeviceChild12<ID3D12RootSignatu
public:
ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12RootSignature);
D3D12RootSignature sig;
enum
{
TypeEnum = Resource_RootSignature,