mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-21 06:51:35 +00:00
Switch to use manual encoding/decoding of root signatures
* This removes the dependency on the serialisers/deserialisers provided by D3D12.dll or the D3D12Core.dlls * It also allows us to easily decode root signatures that don't have DXBC containers, such as those in embedded subobjects.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "d3d12_command_queue.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
#include "data/hlsl/hlsl_cbuffers.h"
|
||||
@@ -248,46 +249,40 @@ D3D12DebugManager::D3D12DebugManager(WrappedID3D12Device *wrapper)
|
||||
shaderCache->SetCaching(true);
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
// cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
// normal SRVs (2x, 4x, 8x, 16x, 32x)
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1, 5),
|
||||
// stencil SRVs (2x, 4x, 8x, 16x, 32x)
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 11, 5),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
m_pDevice->RootSigVersion(),
|
||||
{
|
||||
// cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
// normal SRVs (2x, 4x, 8x, 16x, 32x)
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1, 5),
|
||||
// stencil SRVs (2x, 4x, 8x, 16x, 32x)
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 11, 5),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&m_ArrayMSAARootSig);
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_ArrayMSAARootSig);
|
||||
m_pDevice->InternalRef();
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
rm->SetInternalResource(m_ArrayMSAARootSig);
|
||||
}
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig(
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_GEOMETRY, 0, 0),
|
||||
// 'push constant' CBV
|
||||
constParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0, 4),
|
||||
// meshlet sizes SRV
|
||||
srvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
},
|
||||
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_GEOMETRY, 0, 0),
|
||||
// 'push constant' CBV
|
||||
constParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0, 4),
|
||||
// meshlet sizes SRV
|
||||
srvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
},
|
||||
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&m_MeshRootSig);
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_MeshRootSig);
|
||||
m_pDevice->InternalRef();
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
rm->SetInternalResource(m_MeshRootSig);
|
||||
}
|
||||
|
||||
@@ -376,21 +371,18 @@ D3D12DebugManager::D3D12DebugManager(WrappedID3D12Device *wrapper)
|
||||
}
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 5),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 10),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
m_pDevice->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 5),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 10),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature),
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_PixelHistoryCopySig);
|
||||
m_pDevice->InternalRef();
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
rm->SetInternalResource(m_PixelHistoryCopySig);
|
||||
|
||||
rdcstr hlsl = GetEmbeddedResource(d3d12_pixelhistory_hlsl);
|
||||
@@ -509,18 +501,15 @@ D3D12DebugManager::D3D12DebugManager(WrappedID3D12Device *wrapper)
|
||||
m_pDevice->InternalRef();
|
||||
FillBuffer(m_DiscardConstantsUndefined, 0, pattern.data(), pattern.size());
|
||||
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
constParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 1, 1),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
constParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 1, 1),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&m_DiscardRootSig);
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_DiscardRootSig);
|
||||
m_pDevice->InternalRef();
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,19 +651,17 @@ bool D3D12DebugManager::CreateShaderDebugResources()
|
||||
sampParam.ranges.push_back(range);
|
||||
rootSig.Parameters.push_back(sampParam);
|
||||
|
||||
ID3DBlob *root = m_pDevice->GetShaderCache()->MakeRootSig(rootSig);
|
||||
if(root == NULL)
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(), rootSig);
|
||||
if(root.empty())
|
||||
{
|
||||
RDCERR("Failed to create root signature for shader debugging");
|
||||
SAFE_RELEASE(csBlob);
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr =
|
||||
m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&m_ShaderDebugRootSig);
|
||||
HRESULT hr = m_pDevice->CreateRootSignature(
|
||||
0, root.data(), root.size(), __uuidof(ID3D12RootSignature), (void **)&m_ShaderDebugRootSig);
|
||||
m_pDevice->InternalRef();
|
||||
SAFE_RELEASE(root);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Failed to create root signature for shader debugging HRESULT: %s", ToStr(hr).c_str());
|
||||
@@ -1988,25 +1975,22 @@ void D3D12DebugManager::PrepareExecuteIndirectPatching(const GPUAddressRangeTrac
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 1),
|
||||
constParam(D3D12_SHADER_VISIBILITY_ALL, 0, 2, 1),
|
||||
srvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
uavParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 1),
|
||||
constParam(D3D12_SHADER_VISIBILITY_ALL, 0, 2, 1),
|
||||
srvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
uavParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&m_EIPatchRootSig);
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_EIPatchRootSig);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Couldn't create execute indirect patching RootSig! HRESULT: %s", ToStr(hr).c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2284,16 +2268,13 @@ void D3D12Replay::GeneralMisc::Init(WrappedID3D12Device *device, D3D12DebugManag
|
||||
}
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
});
|
||||
bytebuf root =
|
||||
EncodeRootSig(device->RootSigVersion(), {
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&CheckerboardRootSig);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&CheckerboardRootSig);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2403,30 +2384,28 @@ void D3D12Replay::TextureRendering::Init(WrappedID3D12Device *device, D3D12Debug
|
||||
shaderCache->SetCaching(true);
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
// VS cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
// normal FS cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
// heatmap cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 1),
|
||||
// display SRVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 32),
|
||||
// samplers
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 0, 2),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
device->RootSigVersion(),
|
||||
{
|
||||
// VS cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_VERTEX, 0, 0),
|
||||
// normal FS cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 0),
|
||||
// heatmap cbuffer
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_PIXEL, 0, 1),
|
||||
// display SRVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 32),
|
||||
// samplers
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 0, 2),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&RootSig);
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&RootSig);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Couldn't create tex display RootSig! HRESULT: %s", ToStr(hr).c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2635,17 +2614,15 @@ void D3D12Replay::OverlayRendering::Init(WrappedID3D12Device *device, D3D12Debug
|
||||
}
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
// quad overdraw results SRV
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 1),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
device->RootSigVersion(),
|
||||
{
|
||||
// quad overdraw results SRV
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 1),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&QuadResolveRootSig);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&QuadResolveRootSig);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2711,16 +2688,15 @@ void D3D12Replay::OverlayRendering::Init(WrappedID3D12Device *device, D3D12Debug
|
||||
}
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
// depth copy SRV
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 1),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
device->RootSigVersion(),
|
||||
{
|
||||
// depth copy SRV
|
||||
tableParam(D3D12_SHADER_VISIBILITY_PIXEL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 1),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature),
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&DepthCopyResolveRootSig);
|
||||
SAFE_RELEASE(root);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2921,18 +2897,16 @@ void D3D12Replay::VertexPicking::Init(WrappedID3D12Device *device, D3D12DebugMan
|
||||
VBSize = 0;
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 2),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 1),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
device->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 2),
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 1),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&RootSig);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&RootSig);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -3160,22 +3134,20 @@ void D3D12Replay::HistogramMinMax::Init(WrappedID3D12Device *device, D3D12DebugM
|
||||
shaderCache->SetCaching(true);
|
||||
|
||||
{
|
||||
ID3DBlob *root = shaderCache->MakeRootSig({
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
// texture SRVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 32),
|
||||
// samplers
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 0, 2),
|
||||
// UAVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 3),
|
||||
});
|
||||
bytebuf root = EncodeRootSig(
|
||||
device->RootSigVersion(),
|
||||
{
|
||||
cbvParam(D3D12_SHADER_VISIBILITY_ALL, 0, 0),
|
||||
// texture SRVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 0, 32),
|
||||
// samplers
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 0, 2),
|
||||
// UAVs
|
||||
tableParam(D3D12_SHADER_VISIBILITY_ALL, D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 0, 3),
|
||||
});
|
||||
|
||||
RDCASSERT(root);
|
||||
|
||||
hr = device->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&HistogramRootSig);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
hr = device->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&HistogramRootSig);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -591,6 +591,16 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
{
|
||||
D3D12_FEATURE_DATA_ROOT_SIGNATURE rootSigVer;
|
||||
hr = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &rootSigVer,
|
||||
sizeof(rootSigVer));
|
||||
if(hr != S_OK)
|
||||
rootSigVer.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0;
|
||||
|
||||
m_RootSigVersion = rootSigVer.HighestVersion;
|
||||
}
|
||||
|
||||
hr = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_D3D12Opts,
|
||||
sizeof(m_D3D12Opts));
|
||||
if(hr != S_OK)
|
||||
@@ -4174,9 +4184,6 @@ void WrappedID3D12Device::CreateInternalResources()
|
||||
|
||||
m_GPUSyncCounter = 0;
|
||||
|
||||
if(IsReplayMode(m_State))
|
||||
GetShaderCache()->SetDevConfiguration(m_Replay->GetDevConfiguration());
|
||||
|
||||
if(m_TextRenderer == NULL)
|
||||
m_TextRenderer = new D3D12TextRenderer(this);
|
||||
|
||||
|
||||
@@ -686,6 +686,8 @@ private:
|
||||
WrappedID3D12DebugDevice m_WrappedDebug;
|
||||
WrappedID3D12SharingContract m_SharingContract;
|
||||
|
||||
D3D_ROOT_SIGNATURE_VERSION m_RootSigVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
|
||||
|
||||
D3D12Replay *m_Replay;
|
||||
D3D12ShaderCache *m_ShaderCache = NULL;
|
||||
D3D12TextRenderer *m_TextRenderer = NULL;
|
||||
@@ -844,6 +846,7 @@ public:
|
||||
return m_DescriptorIncrements[type];
|
||||
}
|
||||
|
||||
D3D_ROOT_SIGNATURE_VERSION RootSigVersion() const { return m_RootSigVersion; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS &GetOpts() { return m_D3D12Opts; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS1 &GetOpts1() { return m_D3D12Opts1; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS2 &GetOpts2() { return m_D3D12Opts2; }
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "d3d12_command_queue.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_resources.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
RDOC_DEBUG_CONFIG(bool, D3D12_Experimental_EnableRTSupport, false,
|
||||
@@ -1097,7 +1098,7 @@ bool WrappedID3D12Device::Serialise_CreateRootSignature(SerialiserType &ser, UIN
|
||||
|
||||
WrappedID3D12RootSignature *wrapped = (WrappedID3D12RootSignature *)ret;
|
||||
|
||||
wrapped->sig = GetShaderCache()->GetRootSig(pBlobWithRootSignature, (size_t)blobLengthInBytes);
|
||||
wrapped->sig = DecodeRootSig(pBlobWithRootSignature, (size_t)blobLengthInBytes);
|
||||
|
||||
if(wrapped->sig.Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE)
|
||||
wrapped->localRootSigIdx =
|
||||
@@ -1167,7 +1168,7 @@ HRESULT WrappedID3D12Device::CreateRootSignature(UINT nodeMask, const void *pBlo
|
||||
record->Length = 0;
|
||||
wrapped->SetResourceRecord(record);
|
||||
|
||||
wrapped->sig = GetShaderCache()->GetRootSig(pBlobWithRootSignature, blobLengthInBytes);
|
||||
wrapped->sig = DecodeRootSig(pBlobWithRootSignature, blobLengthInBytes);
|
||||
|
||||
if(wrapped->sig.Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE)
|
||||
wrapped->localRootSigIdx =
|
||||
@@ -1216,7 +1217,7 @@ HRESULT WrappedID3D12Device::CreateRootSignature(UINT nodeMask, const void *pBlo
|
||||
}
|
||||
else
|
||||
{
|
||||
wrapped->sig = GetShaderCache()->GetRootSig(pBlobWithRootSignature, blobLengthInBytes);
|
||||
wrapped->sig = DecodeRootSig(pBlobWithRootSignature, blobLengthInBytes);
|
||||
}
|
||||
|
||||
*ppvRootSignature = (ID3D12RootSignature *)wrapped;
|
||||
|
||||
@@ -161,7 +161,7 @@ bool WrappedID3D12Device::Serialise_CreateStateObject(SerialiserType &ser,
|
||||
|
||||
wrapped->exports = new D3D12ShaderExportDatabase(
|
||||
pStateObject, GetResourceManager()->GetRaytracingResourceAndUtilHandler(),
|
||||
GetShaderCache(), wrapped->GetProperties());
|
||||
wrapped->GetProperties());
|
||||
|
||||
wrapped->exports->PopulateDatabase(Descriptor.NumSubobjects, subs);
|
||||
|
||||
@@ -229,7 +229,7 @@ WrappedID3D12Device::CreateStateObject(const D3D12_STATE_OBJECT_DESC *pDesc, REF
|
||||
|
||||
wrapped->exports = new D3D12ShaderExportDatabase(
|
||||
wrapped->GetResourceID(), GetResourceManager()->GetRaytracingResourceAndUtilHandler(),
|
||||
GetShaderCache(), wrapped->GetProperties());
|
||||
wrapped->GetProperties());
|
||||
|
||||
wrapped->exports->PopulateDatabase(pDesc->NumSubobjects, pDesc->pSubobjects);
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ bool WrappedID3D12Device::Serialise_AddToStateObject(SerialiserType &ser,
|
||||
|
||||
wrapped->exports = new D3D12ShaderExportDatabase(
|
||||
pNewStateObject, GetResourceManager()->GetRaytracingResourceAndUtilHandler(),
|
||||
GetShaderCache(), wrapped->GetProperties());
|
||||
wrapped->GetProperties());
|
||||
|
||||
wrapped->exports->GrowFrom(((WrappedID3D12StateObject *)pStateObjectToGrowFrom)->exports);
|
||||
wrapped->exports->PopulateDatabase(Addition.NumSubobjects, subs);
|
||||
@@ -189,7 +189,7 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12Device::AddToStateObject(
|
||||
|
||||
wrapped->exports = new D3D12ShaderExportDatabase(
|
||||
wrapped->GetResourceID(), GetResourceManager()->GetRaytracingResourceAndUtilHandler(),
|
||||
GetShaderCache(), wrapped->GetProperties());
|
||||
wrapped->GetProperties());
|
||||
|
||||
wrapped->exports->GrowFrom(((WrappedID3D12StateObject *)pStateObjectToGrowFrom)->exports);
|
||||
wrapped->exports->PopulateDatabase(pAddition->NumSubobjects, pAddition->pSubobjects);
|
||||
|
||||
@@ -752,7 +752,6 @@ private:
|
||||
{
|
||||
D3D12DevConfiguration *cfg = new D3D12DevConfiguration(*devConfig);
|
||||
wrap->GetReplay()->SetDevConfiguration(cfg);
|
||||
wrap->GetShaderCache()->SetDevConfiguration(cfg);
|
||||
}
|
||||
|
||||
RDCDEBUG("created wrapped device.");
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "d3d12_command_queue.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_resources.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
#include "data/hlsl/hlsl_cbuffers.h"
|
||||
@@ -1369,12 +1370,13 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
|
||||
|
||||
RDCASSERT(rootParameters.size() == uint32_t(D3D12PatchRayDispatchParam::Count));
|
||||
|
||||
ID3DBlob *rootSig = shaderCache->MakeRootSig(rootParameters, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
bytebuf rootSig = EncodeRootSig(m_wrappedDevice->RootSigVersion(), rootParameters,
|
||||
D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
|
||||
if(rootSig)
|
||||
if(!rootSig.empty())
|
||||
{
|
||||
HRESULT result = m_wrappedDevice->GetReal()->CreateRootSignature(
|
||||
0, rootSig->GetBufferPointer(), rootSig->GetBufferSize(), __uuidof(ID3D12RootSignature),
|
||||
0, rootSig.data(), rootSig.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_RayPatchingData.descPatchRootSig);
|
||||
|
||||
if(!SUCCEEDED(result))
|
||||
@@ -1405,8 +1407,6 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
|
||||
{
|
||||
RDCERR("Failed to get shader for dispatch patching");
|
||||
}
|
||||
|
||||
SAFE_RELEASE(rootSig);
|
||||
}
|
||||
|
||||
// need 5x 2-DWORD root buffers, the rest we can have for constants.
|
||||
@@ -1481,12 +1481,13 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
|
||||
|
||||
RDCASSERT(rootParameters.size() == uint32_t(D3D12IndirectPrepParam::Count));
|
||||
|
||||
rootSig = shaderCache->MakeRootSig(rootParameters, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
rootSig = EncodeRootSig(m_wrappedDevice->RootSigVersion(), rootParameters,
|
||||
D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
|
||||
if(rootSig)
|
||||
if(!rootSig.empty())
|
||||
{
|
||||
HRESULT result = m_wrappedDevice->GetReal()->CreateRootSignature(
|
||||
0, rootSig->GetBufferPointer(), rootSig->GetBufferSize(), __uuidof(ID3D12RootSignature),
|
||||
0, rootSig.data(), rootSig.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_RayPatchingData.indirectPrepRootSig);
|
||||
|
||||
if(!SUCCEEDED(result))
|
||||
@@ -1517,8 +1518,6 @@ void D3D12RaytracingResourceAndUtilHandler::InitRayDispatchPatchingResources()
|
||||
{
|
||||
RDCERR("Failed to get shader for indirect execute patching");
|
||||
}
|
||||
|
||||
SAFE_RELEASE(rootSig);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1601,12 +1600,13 @@ void D3D12RaytracingResourceAndUtilHandler::InitReplayBlasPatchingResources()
|
||||
|
||||
if(shaderCache != NULL)
|
||||
{
|
||||
ID3DBlob *rootSig = shaderCache->MakeRootSig(rootParameters, D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
bytebuf rootSig = EncodeRootSig(m_wrappedDevice->RootSigVersion(), rootParameters,
|
||||
D3D12_ROOT_SIGNATURE_FLAG_NONE);
|
||||
|
||||
if(rootSig)
|
||||
if(!rootSig.empty())
|
||||
{
|
||||
HRESULT result = m_wrappedDevice->GetReal()->CreateRootSignature(
|
||||
0, rootSig->GetBufferPointer(), rootSig->GetBufferSize(), __uuidof(ID3D12RootSignature),
|
||||
0, rootSig.data(), rootSig.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&m_accStructPatchInfo.m_rootSignature);
|
||||
|
||||
if(!SUCCEEDED(result))
|
||||
@@ -1633,8 +1633,6 @@ void D3D12RaytracingResourceAndUtilHandler::InitReplayBlasPatchingResources()
|
||||
if(!SUCCEEDED(result))
|
||||
RDCERR("Unable to create pipeline for patching the BLAS");
|
||||
}
|
||||
|
||||
SAFE_RELEASE(rootSig);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "d3d12_debug.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
#include "data/hlsl/hlsl_cbuffers.h"
|
||||
@@ -116,14 +117,12 @@ struct D3D12QuadOverdrawCallback : public D3D12ActionCallback
|
||||
|
||||
cache.sigElem = uint32_t(modsig.Parameters.size() - 1);
|
||||
|
||||
ID3DBlob *root = m_pDevice->GetShaderCache()->MakeRootSig(modsig);
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(), modsig);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&cache.sig);
|
||||
RDCASSERTEQUAL(hr, S_OK);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
WrappedID3D12PipelineState *origPSO =
|
||||
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12PipelineState>(rs.pipe);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "d3d12_debug.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
RDOC_CONFIG(rdcstr, D3D12_Debug_PostVSDumpDirPath, "",
|
||||
@@ -2231,12 +2232,9 @@ void D3D12Replay::InitPostMSBuffers(uint32_t eventId)
|
||||
ID3D12RootSignature *annotatedSig = NULL;
|
||||
|
||||
{
|
||||
ID3DBlob *blob = m_pDevice->GetShaderCache()->MakeRootSig(modsig);
|
||||
HRESULT hr =
|
||||
m_pDevice->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&annotatedSig);
|
||||
|
||||
SAFE_RELEASE(blob);
|
||||
bytebuf blob = EncodeRootSig(m_pDevice->RootSigVersion(), modsig);
|
||||
HRESULT hr = m_pDevice->CreateRootSignature(
|
||||
0, blob.data(), blob.size(), __uuidof(ID3D12RootSignature), (void **)&annotatedSig);
|
||||
|
||||
if(annotatedSig == NULL || FAILED(hr))
|
||||
{
|
||||
@@ -2955,9 +2953,9 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId)
|
||||
{
|
||||
rootsig.Flags |= D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT;
|
||||
|
||||
ID3DBlob *blob = m_pDevice->GetShaderCache()->MakeRootSig(rootsig);
|
||||
bytebuf blob = EncodeRootSig(m_pDevice->RootSigVersion(), rootsig);
|
||||
|
||||
hr = m_pDevice->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(),
|
||||
hr = m_pDevice->CreateRootSignature(0, blob.data(), blob.size(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&soSig);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
@@ -2966,8 +2964,6 @@ void D3D12Replay::InitPostVSBuffers(uint32_t eventId)
|
||||
RDCERR("%s", ret.vsout.status.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(blob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "strings/string_utils.h"
|
||||
#include "d3d12_command_list.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
#include "data/hlsl/hlsl_cbuffers.h"
|
||||
@@ -363,12 +364,13 @@ D3D12TextRenderer::D3D12TextRenderer(WrappedID3D12Device *wrapper)
|
||||
},
|
||||
};
|
||||
|
||||
ID3DBlob *root = shaderCache->MakeRootSig(rootSig, D3D12_ROOT_SIGNATURE_FLAG_NONE, 2, samplers);
|
||||
bytebuf root =
|
||||
EncodeRootSig(wrapper->RootSigVersion(), rootSig, D3D12_ROOT_SIGNATURE_FLAG_NONE, 2, samplers);
|
||||
|
||||
RDCASSERT(root);
|
||||
RDCASSERT(!root.empty());
|
||||
|
||||
hr = wrapper->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&RootSig);
|
||||
hr = wrapper->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&RootSig);
|
||||
wrapper->InternalRef();
|
||||
|
||||
if(FAILED(hr))
|
||||
@@ -376,8 +378,6 @@ D3D12TextRenderer::D3D12TextRenderer(WrappedID3D12Device *wrapper)
|
||||
|
||||
rm->SetInternalResource(RootSig);
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
rdcstr hlsl = GetEmbeddedResource(text_hlsl);
|
||||
|
||||
ID3DBlob *TextVS = NULL;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "driver/shaders/dxil/dxil_metadata.h"
|
||||
#include "d3d12_command_list.h"
|
||||
#include "d3d12_command_queue.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
GPUAddressRangeTracker WrappedID3D12Resource::m_Addresses;
|
||||
@@ -688,7 +689,7 @@ void WrappedID3D12PipelineState::FetchRootSig(D3D12ShaderCache *shaderCache)
|
||||
D3D12_SHADER_BYTECODE desc = CS()->GetDesc();
|
||||
if(DXBC::DXBCContainer::CheckForRootSig(desc.pShaderBytecode, desc.BytecodeLength))
|
||||
{
|
||||
usedSig = shaderCache->GetRootSig(desc.pShaderBytecode, desc.BytecodeLength);
|
||||
usedSig = DecodeRootSig(desc.pShaderBytecode, desc.BytecodeLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -713,7 +714,7 @@ void WrappedID3D12PipelineState::FetchRootSig(D3D12ShaderCache *shaderCache)
|
||||
|
||||
if(DXBC::DXBCContainer::CheckForRootSig(desc.pShaderBytecode, desc.BytecodeLength))
|
||||
{
|
||||
usedSig = shaderCache->GetRootSig(desc.pShaderBytecode, desc.BytecodeLength);
|
||||
usedSig = DecodeRootSig(desc.pShaderBytecode, desc.BytecodeLength);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -840,13 +841,8 @@ void WrappedID3D12PipelineState::ProcessDescriptorAccess()
|
||||
|
||||
D3D12ShaderExportDatabase::D3D12ShaderExportDatabase(ResourceId id,
|
||||
D3D12RaytracingResourceAndUtilHandler *rayManager,
|
||||
D3D12ShaderCache *cache,
|
||||
ID3D12StateObjectProperties *obj)
|
||||
: RefCounter12(NULL),
|
||||
objectOriginalId(id),
|
||||
m_RayManager(rayManager),
|
||||
m_ShaderCache(cache),
|
||||
m_StateObjectProps(obj)
|
||||
: RefCounter12(NULL), objectOriginalId(id), m_RayManager(rayManager), m_StateObjectProps(obj)
|
||||
{
|
||||
m_RayManager->RegisterExportDatabase(this);
|
||||
}
|
||||
@@ -946,7 +942,7 @@ void D3D12ShaderExportDatabase::PopulateDatabase(size_t NumSubobjects,
|
||||
{
|
||||
localRSs.push_back(sub.name);
|
||||
dxilLocalRootSigs[sub.name] = m_RayManager->RegisterLocalRootSig(
|
||||
m_ShaderCache->GetRootSig(sub.rs.data.data(), sub.rs.data.size()));
|
||||
DecodeRootSig(sub.rs.data.data(), sub.rs.data.size(), false));
|
||||
|
||||
// ignore these if an explicit default association has been made
|
||||
if(!explicitDXILDefault)
|
||||
|
||||
@@ -1025,7 +1025,7 @@ struct D3D12ShaderExportDatabase : public RefCounter12<IUnknown>
|
||||
{
|
||||
public:
|
||||
D3D12ShaderExportDatabase(ResourceId id, D3D12RaytracingResourceAndUtilHandler *rayManager,
|
||||
D3D12ShaderCache *cache, ID3D12StateObjectProperties *obj);
|
||||
ID3D12StateObjectProperties *obj);
|
||||
~D3D12ShaderExportDatabase();
|
||||
|
||||
ResourceId GetResourceId() { return objectOriginalId; }
|
||||
@@ -1073,7 +1073,6 @@ private:
|
||||
|
||||
ID3D12StateObjectProperties *m_StateObjectProps = NULL;
|
||||
D3D12RaytracingResourceAndUtilHandler *m_RayManager = NULL;
|
||||
D3D12ShaderCache *m_ShaderCache = NULL;
|
||||
|
||||
struct ExportLookup
|
||||
{
|
||||
|
||||
@@ -695,346 +695,6 @@ rdcstr D3D12ShaderCache::GetShaderBlob(const char *source, const char *entry, ui
|
||||
includeDirs, profile, srcblob);
|
||||
}
|
||||
|
||||
D3D12RootSignature D3D12ShaderCache::GetRootSig(const void *data, size_t dataSize)
|
||||
{
|
||||
PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER deserializeRootSig =
|
||||
(PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER)GetProcAddress(
|
||||
GetModuleHandleA("d3d12.dll"), "D3D12CreateVersionedRootSignatureDeserializer");
|
||||
|
||||
PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER deserializeRootSigOld =
|
||||
(PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER)GetProcAddress(
|
||||
GetModuleHandleA("d3d12.dll"), "D3D12CreateRootSignatureDeserializer");
|
||||
|
||||
if(deserializeRootSig == NULL)
|
||||
{
|
||||
RDCWARN("Can't get D3D12CreateVersionedRootSignatureDeserializer - old version of windows?");
|
||||
|
||||
if(deserializeRootSigOld == NULL)
|
||||
{
|
||||
RDCERR("Can't get D3D12CreateRootSignatureDeserializer!");
|
||||
return D3D12RootSignature();
|
||||
}
|
||||
|
||||
ID3D12RootSignatureDeserializer *deser = NULL;
|
||||
HRESULT hr = deserializeRootSigOld(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();
|
||||
if(FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(deser);
|
||||
RDCERR("Can't get descriptor");
|
||||
return D3D12RootSignature();
|
||||
}
|
||||
|
||||
ret.Flags = desc->Flags;
|
||||
|
||||
ret.Parameters.resize(desc->NumParameters);
|
||||
|
||||
ret.dwordLength = 0;
|
||||
|
||||
for(size_t i = 0; i < ret.Parameters.size(); i++)
|
||||
{
|
||||
ret.Parameters[i].MakeFrom(desc->pParameters[i], ret.maxSpaceIndex);
|
||||
|
||||
// Descriptor tables cost 1 DWORD each.
|
||||
// Root constants cost 1 DWORD each, since they are 32-bit values.
|
||||
// Root descriptors (64-bit GPU virtual addresses) cost 2 DWORDs each.
|
||||
if(desc->pParameters[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
|
||||
ret.dwordLength++;
|
||||
else if(desc->pParameters[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
|
||||
ret.dwordLength += desc->pParameters[i].Constants.Num32BitValues;
|
||||
else
|
||||
ret.dwordLength += 2;
|
||||
}
|
||||
|
||||
if(desc->NumStaticSamplers > 0)
|
||||
{
|
||||
ret.StaticSamplers.resize(desc->NumStaticSamplers);
|
||||
|
||||
for(size_t i = 0; i < ret.StaticSamplers.size(); i++)
|
||||
{
|
||||
ret.StaticSamplers[i] = Upconvert(desc->pStaticSamplers[i]);
|
||||
ret.maxSpaceIndex = RDCMAX(ret.maxSpaceIndex, ret.StaticSamplers[i].RegisterSpace + 1);
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_RELEASE(deser);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ID3D12VersionedRootSignatureDeserializer *deser = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
if(m_DevConfig)
|
||||
hr = m_DevConfig->devconfig->CreateVersionedRootSignatureDeserializer(
|
||||
data, dataSize, __uuidof(ID3D12VersionedRootSignatureDeserializer), (void **)&deser);
|
||||
else
|
||||
hr = deserializeRootSig(data, dataSize, __uuidof(ID3D12VersionedRootSignatureDeserializer),
|
||||
(void **)&deser);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(deser);
|
||||
RDCERR("Can't get deserializer");
|
||||
return D3D12RootSignature();
|
||||
}
|
||||
|
||||
D3D12RootSignature ret;
|
||||
|
||||
uint32_t version = 12;
|
||||
const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *verdesc = NULL;
|
||||
hr = deser->GetRootSignatureDescAtVersion(D3D_ROOT_SIGNATURE_VERSION_1_2, &verdesc);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
version = 11;
|
||||
hr = deser->GetRootSignatureDescAtVersion(D3D_ROOT_SIGNATURE_VERSION_1_1, &verdesc);
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(deser);
|
||||
RDCERR("Can't get descriptor");
|
||||
return D3D12RootSignature();
|
||||
}
|
||||
|
||||
const D3D12_ROOT_SIGNATURE_DESC1 *desc = &verdesc->Desc_1_1;
|
||||
|
||||
ret.Flags = desc->Flags;
|
||||
|
||||
ret.Parameters.resize(desc->NumParameters);
|
||||
|
||||
ret.dwordLength = 0;
|
||||
|
||||
for(size_t i = 0; i < ret.Parameters.size(); i++)
|
||||
{
|
||||
ret.Parameters[i].MakeFrom(desc->pParameters[i], ret.maxSpaceIndex);
|
||||
|
||||
// Descriptor tables cost 1 DWORD each.
|
||||
// Root constants cost 1 DWORD each, since they are 32-bit values.
|
||||
// Root descriptors (64-bit GPU virtual addresses) cost 2 DWORDs each.
|
||||
if(desc->pParameters[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
|
||||
ret.dwordLength++;
|
||||
else if(desc->pParameters[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
|
||||
ret.dwordLength += desc->pParameters[i].Constants.Num32BitValues;
|
||||
else
|
||||
ret.dwordLength += 2;
|
||||
}
|
||||
|
||||
if(desc->NumStaticSamplers > 0)
|
||||
{
|
||||
if(version >= 12)
|
||||
{
|
||||
ret.StaticSamplers.assign(verdesc->Desc_1_2.pStaticSamplers,
|
||||
verdesc->Desc_1_2.NumStaticSamplers);
|
||||
|
||||
for(size_t i = 0; i < ret.StaticSamplers.size(); i++)
|
||||
ret.maxSpaceIndex = RDCMAX(ret.maxSpaceIndex, ret.StaticSamplers[i].RegisterSpace + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.StaticSamplers.resize(desc->NumStaticSamplers);
|
||||
|
||||
for(size_t i = 0; i < ret.StaticSamplers.size(); i++)
|
||||
{
|
||||
ret.StaticSamplers[i] = Upconvert(desc->pStaticSamplers[i]);
|
||||
ret.maxSpaceIndex = RDCMAX(ret.maxSpaceIndex, ret.StaticSamplers[i].RegisterSpace + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_RELEASE(deser);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ID3DBlob *D3D12ShaderCache::MakeRootSig(const rdcarray<D3D12_ROOT_PARAMETER1> ¶ms,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS Flags, UINT NumStaticSamplers,
|
||||
const D3D12_STATIC_SAMPLER_DESC1 *StaticSamplers)
|
||||
{
|
||||
PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE serializeRootSig =
|
||||
(PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)GetProcAddress(
|
||||
GetModuleHandleA("d3d12.dll"), "D3D12SerializeVersionedRootSignature");
|
||||
|
||||
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE serializeRootSigOld =
|
||||
(PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(GetModuleHandleA("d3d12.dll"),
|
||||
"D3D12SerializeRootSignature");
|
||||
|
||||
if(serializeRootSig == NULL)
|
||||
{
|
||||
RDCWARN("Can't get D3D12SerializeVersionedRootSignature - old version of windows?");
|
||||
|
||||
if(serializeRootSigOld == NULL)
|
||||
{
|
||||
RDCERR("Can't get D3D12SerializeRootSignature!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rdcarray<D3D12_STATIC_SAMPLER_DESC> oldSamplers;
|
||||
oldSamplers.resize(NumStaticSamplers);
|
||||
for(size_t i = 0; i < oldSamplers.size(); i++)
|
||||
oldSamplers[i] = Downconvert(StaticSamplers[i]);
|
||||
|
||||
D3D12_ROOT_SIGNATURE_DESC desc;
|
||||
desc.Flags = Flags;
|
||||
desc.NumStaticSamplers = NumStaticSamplers;
|
||||
desc.pStaticSamplers = oldSamplers.data();
|
||||
desc.NumParameters = (UINT)params.size();
|
||||
|
||||
rdcarray<D3D12_ROOT_PARAMETER> params_1_0;
|
||||
params_1_0.resize(params.size());
|
||||
for(size_t i = 0; i < params.size(); i++)
|
||||
{
|
||||
params_1_0[i].ShaderVisibility = params[i].ShaderVisibility;
|
||||
params_1_0[i].ParameterType = params[i].ParameterType;
|
||||
|
||||
if(params[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS)
|
||||
{
|
||||
params_1_0[i].Constants = params[i].Constants;
|
||||
}
|
||||
else if(params[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
|
||||
{
|
||||
params_1_0[i].DescriptorTable.NumDescriptorRanges =
|
||||
params[i].DescriptorTable.NumDescriptorRanges;
|
||||
|
||||
D3D12_DESCRIPTOR_RANGE *dst =
|
||||
new D3D12_DESCRIPTOR_RANGE[params[i].DescriptorTable.NumDescriptorRanges];
|
||||
params_1_0[i].DescriptorTable.pDescriptorRanges = dst;
|
||||
|
||||
for(UINT r = 0; r < params[i].DescriptorTable.NumDescriptorRanges; r++)
|
||||
{
|
||||
dst[r].BaseShaderRegister =
|
||||
params[i].DescriptorTable.pDescriptorRanges[r].BaseShaderRegister;
|
||||
dst[r].NumDescriptors = params[i].DescriptorTable.pDescriptorRanges[r].NumDescriptors;
|
||||
dst[r].OffsetInDescriptorsFromTableStart =
|
||||
params[i].DescriptorTable.pDescriptorRanges[r].OffsetInDescriptorsFromTableStart;
|
||||
dst[r].RangeType = params[i].DescriptorTable.pDescriptorRanges[r].RangeType;
|
||||
dst[r].RegisterSpace = params[i].DescriptorTable.pDescriptorRanges[r].RegisterSpace;
|
||||
|
||||
if(params[i].DescriptorTable.pDescriptorRanges[r].Flags !=
|
||||
(D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE |
|
||||
D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE))
|
||||
RDCWARN("Losing information when reducing down to 1.0 root signature");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
params_1_0[i].Descriptor.RegisterSpace = params[i].Descriptor.RegisterSpace;
|
||||
params_1_0[i].Descriptor.ShaderRegister = params[i].Descriptor.ShaderRegister;
|
||||
|
||||
if(params[i].Descriptor.Flags != D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE)
|
||||
RDCWARN("Losing information when reducing down to 1.0 root signature");
|
||||
}
|
||||
}
|
||||
|
||||
desc.pParameters = ¶ms_1_0[0];
|
||||
|
||||
ID3DBlob *ret = NULL;
|
||||
ID3DBlob *errBlob = NULL;
|
||||
HRESULT hr = serializeRootSigOld(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &ret, &errBlob);
|
||||
|
||||
for(size_t i = 0; i < params_1_0.size(); i++)
|
||||
if(params_1_0[i].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
|
||||
delete[] params_1_0[i].DescriptorTable.pDescriptorRanges;
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
rdcstr errors = (char *)errBlob->GetBufferPointer();
|
||||
|
||||
rdcstr logerror = errors;
|
||||
if(logerror.length() > 1024)
|
||||
logerror = logerror.substr(0, 1024) + "...";
|
||||
|
||||
RDCERR("Root signature serialize error:\n%s", logerror.c_str());
|
||||
|
||||
SAFE_RELEASE(errBlob);
|
||||
SAFE_RELEASE(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(errBlob);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
D3D12_VERSIONED_ROOT_SIGNATURE_DESC verdesc;
|
||||
verdesc.Version = D3D_ROOT_SIGNATURE_VERSION_1_2;
|
||||
|
||||
D3D12_ROOT_SIGNATURE_DESC2 &desc12 = verdesc.Desc_1_2;
|
||||
desc12.Flags = Flags;
|
||||
desc12.NumStaticSamplers = NumStaticSamplers;
|
||||
desc12.pStaticSamplers = StaticSamplers;
|
||||
desc12.NumParameters = (UINT)params.size();
|
||||
desc12.pParameters = ¶ms[0];
|
||||
|
||||
ID3DBlob *ret = NULL;
|
||||
ID3DBlob *errBlob = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
if(m_DevConfig && m_DevConfig->devconfig)
|
||||
hr = m_DevConfig->devconfig->SerializeVersionedRootSignature(&verdesc, &ret, &errBlob);
|
||||
else
|
||||
hr = serializeRootSig(&verdesc, &ret, &errBlob);
|
||||
SAFE_RELEASE(errBlob);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
return ret;
|
||||
|
||||
// if it failed, try again at version 1.1
|
||||
verdesc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1;
|
||||
D3D12_ROOT_SIGNATURE_DESC1 &desc11 = verdesc.Desc_1_1;
|
||||
rdcarray<D3D12_STATIC_SAMPLER_DESC> oldSamplers;
|
||||
oldSamplers.resize(NumStaticSamplers);
|
||||
for(size_t i = 0; i < oldSamplers.size(); i++)
|
||||
oldSamplers[i] = Downconvert(StaticSamplers[i]);
|
||||
desc11.pStaticSamplers = oldSamplers.data();
|
||||
|
||||
if(m_DevConfig && m_DevConfig->devconfig)
|
||||
hr = m_DevConfig->devconfig->SerializeVersionedRootSignature(&verdesc, &ret, &errBlob);
|
||||
else
|
||||
hr = serializeRootSig(&verdesc, &ret, &errBlob);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
rdcstr errors = (char *)errBlob->GetBufferPointer();
|
||||
|
||||
rdcstr logerror = errors;
|
||||
if(logerror.length() > 1024)
|
||||
logerror = logerror.substr(0, 1024) + "...";
|
||||
|
||||
RDCERR("Root signature serialize error:\n%s", logerror.c_str());
|
||||
|
||||
SAFE_RELEASE(errBlob);
|
||||
SAFE_RELEASE(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(errBlob);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ID3DBlob *D3D12ShaderCache::MakeRootSig(const D3D12RootSignature &rootsig)
|
||||
{
|
||||
rdcarray<D3D12_ROOT_PARAMETER1> params;
|
||||
params.resize(rootsig.Parameters.size());
|
||||
for(size_t i = 0; i < params.size(); i++)
|
||||
params[i] = rootsig.Parameters[i];
|
||||
|
||||
return MakeRootSig(params, rootsig.Flags, (UINT)rootsig.StaticSamplers.size(),
|
||||
rootsig.StaticSamplers.empty() ? NULL : &rootsig.StaticSamplers[0]);
|
||||
}
|
||||
|
||||
ID3DBlob *D3D12ShaderCache::MakeFixedColShader(FixedColVariant variant, bool dxil)
|
||||
{
|
||||
ID3DBlob *ret = NULL;
|
||||
@@ -1109,24 +769,3 @@ void D3D12ShaderCache::LoadDXC()
|
||||
{
|
||||
GetDXC();
|
||||
}
|
||||
|
||||
D3D12_STATIC_SAMPLER_DESC1 D3D12ShaderCache::Upconvert(const D3D12_STATIC_SAMPLER_DESC &StaticSampler)
|
||||
{
|
||||
D3D12_STATIC_SAMPLER_DESC1 ret;
|
||||
memcpy(&ret, &StaticSampler, sizeof(StaticSampler));
|
||||
ret.Flags = D3D12_SAMPLER_FLAG_NONE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
D3D12_STATIC_SAMPLER_DESC D3D12ShaderCache::Downconvert(const D3D12_STATIC_SAMPLER_DESC1 &StaticSampler)
|
||||
{
|
||||
D3D12_STATIC_SAMPLER_DESC ret;
|
||||
memcpy(&ret, &StaticSampler, sizeof(ret));
|
||||
if(StaticSampler.Flags != 0)
|
||||
RDCWARN("Downconverting sampler with advanced features set");
|
||||
if(ret.BorderColor == D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK_UINT)
|
||||
ret.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK_UINT;
|
||||
else if(ret.BorderColor == D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE_UINT)
|
||||
ret.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE_UINT;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -41,13 +41,6 @@ public:
|
||||
rdcstr GetShaderBlob(const char *source, const char *entry, const ShaderCompileFlags &compileFlags,
|
||||
const rdcarray<rdcstr> &includeDirs, const char *profile, ID3DBlob **srcblob);
|
||||
|
||||
D3D12RootSignature GetRootSig(const void *data, size_t dataSize);
|
||||
ID3DBlob *MakeRootSig(const rdcarray<D3D12_ROOT_PARAMETER1> ¶ms,
|
||||
D3D12_ROOT_SIGNATURE_FLAGS Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE,
|
||||
UINT NumStaticSamplers = 0,
|
||||
const D3D12_STATIC_SAMPLER_DESC1 *StaticSamplers = NULL);
|
||||
ID3DBlob *MakeRootSig(const D3D12RootSignature &rootsig);
|
||||
|
||||
// must match the values in fixedcol.hlsl
|
||||
enum FixedColVariant
|
||||
{
|
||||
@@ -63,7 +56,6 @@ public:
|
||||
|
||||
void LoadDXC();
|
||||
|
||||
void SetDevConfiguration(D3D12DevConfiguration *config) { m_DevConfig = config; }
|
||||
void SetCaching(bool enabled) { m_CacheShaders = enabled; }
|
||||
private:
|
||||
static const uint32_t m_ShaderCacheMagic = 0xf000baba;
|
||||
@@ -73,9 +65,4 @@ private:
|
||||
|
||||
bool m_ShaderCacheDirty = false, m_CacheShaders = false;
|
||||
std::map<uint32_t, ID3DBlob *> m_ShaderCache;
|
||||
|
||||
D3D12DevConfiguration *m_DevConfig = NULL;
|
||||
|
||||
D3D12_STATIC_SAMPLER_DESC1 Upconvert(const D3D12_STATIC_SAMPLER_DESC &StaticSampler);
|
||||
D3D12_STATIC_SAMPLER_DESC Downconvert(const D3D12_STATIC_SAMPLER_DESC1 &StaticSampler);
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_resources.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
RDOC_CONFIG(rdcstr, D3D12_Debug_FeedbackDumpDirPath, "",
|
||||
@@ -1430,19 +1431,15 @@ bool D3D12Replay::FetchShaderFeedback(uint32_t eventId)
|
||||
ID3D12RootSignature *annotatedSig = NULL;
|
||||
|
||||
{
|
||||
ID3DBlob *root = m_pDevice->GetShaderCache()->MakeRootSig(modsig);
|
||||
HRESULT hr =
|
||||
m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&annotatedSig);
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(), modsig);
|
||||
HRESULT hr = m_pDevice->CreateRootSignature(
|
||||
0, root.data(), root.size(), __uuidof(ID3D12RootSignature), (void **)&annotatedSig);
|
||||
|
||||
if(annotatedSig == NULL || FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(root);
|
||||
RDCERR("Couldn't create feedback modified root signature: %s", ToStr(hr).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(root);
|
||||
}
|
||||
|
||||
ID3D12PipelineState *annotatedPipe = NULL;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "d3d12_debug.h"
|
||||
#include "d3d12_replay.h"
|
||||
#include "d3d12_resources.h"
|
||||
#include "d3d12_rootsig.h"
|
||||
#include "d3d12_shader_cache.h"
|
||||
|
||||
#include "data/hlsl/hlsl_cbuffers.h"
|
||||
@@ -2439,21 +2440,19 @@ void ExtractInputsPS(PSInput IN,
|
||||
modsig.Flags &= ~D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS;
|
||||
|
||||
// Create the root signature for gathering initial pixel shader values
|
||||
ID3DBlob *root = m_pDevice->GetShaderCache()->MakeRootSig(modsig);
|
||||
bytebuf root = EncodeRootSig(m_pDevice->RootSigVersion(), modsig);
|
||||
ID3D12RootSignature *pRootSignature = NULL;
|
||||
hr = m_pDevice->CreateRootSignature(0, root->GetBufferPointer(), root->GetBufferSize(),
|
||||
__uuidof(ID3D12RootSignature), (void **)&pRootSignature);
|
||||
hr = m_pDevice->CreateRootSignature(0, root.data(), root.size(), __uuidof(ID3D12RootSignature),
|
||||
(void **)&pRootSignature);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Failed to create root signature for pixel shader debugging HRESULT: %s",
|
||||
ToStr(hr).c_str());
|
||||
SAFE_RELEASE(root);
|
||||
SAFE_RELEASE(psBlob);
|
||||
SAFE_RELEASE(pInitialValuesBuffer);
|
||||
SAFE_RELEASE(pMsaaEvalBuffer);
|
||||
return new ShaderDebugTrace;
|
||||
}
|
||||
SAFE_RELEASE(root);
|
||||
|
||||
// All PSO state is the same as the event's, except for the pixel shader and root signature
|
||||
pipeDesc.PS.BytecodeLength = psBlob->GetBufferSize();
|
||||
|
||||
Reference in New Issue
Block a user