|
@@ -8,11 +8,12 @@
|
|
|
|
|
|
|
|
using namespace Framework;
|
|
using namespace Framework;
|
|
|
|
|
|
|
|
-Framework::DX12ShaderSignature::DX12ShaderSignature()
|
|
|
|
|
|
|
+Framework::DX12ShaderSignature::DX12ShaderSignature(bool global)
|
|
|
: ReferenceCounter(),
|
|
: ReferenceCounter(),
|
|
|
signature(0),
|
|
signature(0),
|
|
|
changed(1),
|
|
changed(1),
|
|
|
- shaderBindingTableParamCount(0)
|
|
|
|
|
|
|
+ shaderBindingTableParamCount(0),
|
|
|
|
|
+ global(global)
|
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
Framework::DX12ShaderSignature::~DX12ShaderSignature()
|
|
Framework::DX12ShaderSignature::~DX12ShaderSignature()
|
|
@@ -312,7 +313,8 @@ void Framework::DX12ShaderSignature::createSignature(ID3D12Device5* zDevice,
|
|
|
D3D12_ROOT_SIGNATURE_DESC rootDesc = {};
|
|
D3D12_ROOT_SIGNATURE_DESC rootDesc = {};
|
|
|
rootDesc.NumParameters = shaderBindingTableParamCount;
|
|
rootDesc.NumParameters = shaderBindingTableParamCount;
|
|
|
rootDesc.pParameters = descriptorTable;
|
|
rootDesc.pParameters = descriptorTable;
|
|
|
- rootDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE;
|
|
|
|
|
|
|
+ rootDesc.Flags = global ? D3D12_ROOT_SIGNATURE_FLAG_NONE
|
|
|
|
|
+ : D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE;
|
|
|
ID3DBlob* pSigBlob = 0;
|
|
ID3DBlob* pSigBlob = 0;
|
|
|
ID3DBlob* pErrorBlob = 0;
|
|
ID3DBlob* pErrorBlob = 0;
|
|
|
HRESULT hr = pfnD3D12SerializeRootSignature(
|
|
HRESULT hr = pfnD3D12SerializeRootSignature(
|
|
@@ -740,21 +742,16 @@ DX12ShaderSignature* Framework::DX12ShaderHitGroup::zSignature() const
|
|
|
|
|
|
|
|
Framework::DX12Pipeline::DX12Pipeline()
|
|
Framework::DX12Pipeline::DX12Pipeline()
|
|
|
: ReferenceCounter(),
|
|
: ReferenceCounter(),
|
|
|
- emptyGlobalRootSignature(0),
|
|
|
|
|
- emptyLocalRootSignature(0),
|
|
|
|
|
|
|
+ globalSignature(new DX12ShaderSignature(true)),
|
|
|
pipelineState(0),
|
|
pipelineState(0),
|
|
|
maxRecursionDepth(0)
|
|
maxRecursionDepth(0)
|
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
Framework::DX12Pipeline::~DX12Pipeline()
|
|
Framework::DX12Pipeline::~DX12Pipeline()
|
|
|
{
|
|
{
|
|
|
- if (emptyGlobalRootSignature)
|
|
|
|
|
|
|
+ if (globalSignature)
|
|
|
{
|
|
{
|
|
|
- emptyGlobalRootSignature->Release();
|
|
|
|
|
- }
|
|
|
|
|
- if (emptyLocalRootSignature)
|
|
|
|
|
- {
|
|
|
|
|
- emptyLocalRootSignature->Release();
|
|
|
|
|
|
|
+ globalSignature->release();
|
|
|
}
|
|
}
|
|
|
if (pipelineState)
|
|
if (pipelineState)
|
|
|
{
|
|
{
|
|
@@ -780,66 +777,9 @@ void Framework::DX12Pipeline::setMaxRecursionDepth(int maxRecursionDepth)
|
|
|
void Framework::DX12Pipeline::createPipelineState(ID3D12Device5* zDevice,
|
|
void Framework::DX12Pipeline::createPipelineState(ID3D12Device5* zDevice,
|
|
|
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE pfnD3D12SerializeRootSignature)
|
|
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE pfnD3D12SerializeRootSignature)
|
|
|
{
|
|
{
|
|
|
- if (!emptyGlobalRootSignature)
|
|
|
|
|
- {
|
|
|
|
|
- D3D12_ROOT_SIGNATURE_DESC rootDesc = {};
|
|
|
|
|
- rootDesc.NumParameters = 0;
|
|
|
|
|
- rootDesc.pParameters = 0;
|
|
|
|
|
- rootDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;
|
|
|
|
|
- ID3DBlob* pSigBlob = 0;
|
|
|
|
|
- ID3DBlob* pErrorBlob = 0;
|
|
|
|
|
- HRESULT hr = pfnD3D12SerializeRootSignature(
|
|
|
|
|
- &rootDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &pSigBlob, &pErrorBlob);
|
|
|
|
|
- if (pSigBlob)
|
|
|
|
|
- {
|
|
|
|
|
- zDevice->CreateRootSignature(0,
|
|
|
|
|
- pSigBlob->GetBufferPointer(),
|
|
|
|
|
- pSigBlob->GetBufferSize(),
|
|
|
|
|
- __uuidof(ID3D12RootSignature),
|
|
|
|
|
- (void**)&emptyGlobalRootSignature);
|
|
|
|
|
- pSigBlob->Release();
|
|
|
|
|
- }
|
|
|
|
|
- if (pErrorBlob)
|
|
|
|
|
- {
|
|
|
|
|
- std::string errorMessage(
|
|
|
|
|
- static_cast<const char*>(pErrorBlob->GetBufferPointer()),
|
|
|
|
|
- pErrorBlob->GetBufferSize());
|
|
|
|
|
- Logging::error()
|
|
|
|
|
- << "Failed to serialize empty root signature: " << errorMessage;
|
|
|
|
|
- pErrorBlob->Release();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!emptyLocalRootSignature)
|
|
|
|
|
- {
|
|
|
|
|
- D3D12_ROOT_SIGNATURE_DESC rootDesc = {};
|
|
|
|
|
- rootDesc.NumParameters = 0;
|
|
|
|
|
- rootDesc.pParameters = 0;
|
|
|
|
|
- rootDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE;
|
|
|
|
|
- ID3DBlob* pSigBlob = 0;
|
|
|
|
|
- ID3DBlob* pErrorBlob = 0;
|
|
|
|
|
- HRESULT hr = pfnD3D12SerializeRootSignature(
|
|
|
|
|
- &rootDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &pSigBlob, &pErrorBlob);
|
|
|
|
|
- if (pSigBlob)
|
|
|
|
|
- {
|
|
|
|
|
- zDevice->CreateRootSignature(0,
|
|
|
|
|
- pSigBlob->GetBufferPointer(),
|
|
|
|
|
- pSigBlob->GetBufferSize(),
|
|
|
|
|
- __uuidof(ID3D12RootSignature),
|
|
|
|
|
- (void**)&emptyLocalRootSignature);
|
|
|
|
|
- pSigBlob->Release();
|
|
|
|
|
- }
|
|
|
|
|
- if (pErrorBlob)
|
|
|
|
|
- {
|
|
|
|
|
- std::string errorMessage(
|
|
|
|
|
- static_cast<const char*>(pErrorBlob->GetBufferPointer()),
|
|
|
|
|
- pErrorBlob->GetBufferSize());
|
|
|
|
|
- Logging::error()
|
|
|
|
|
- << "Failed to serialize empty root signature: " << errorMessage;
|
|
|
|
|
- pErrorBlob->Release();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ globalSignature->createSignature(zDevice, pfnD3D12SerializeRootSignature);
|
|
|
unsigned int subobjectCount
|
|
unsigned int subobjectCount
|
|
|
- = shaders.getEntryCount() + hitGroups.getEntryCount() + 5;
|
|
|
|
|
|
|
+ = shaders.getEntryCount() + hitGroups.getEntryCount() + 4;
|
|
|
Array<DX12ShaderSignature*> distinctSignatures;
|
|
Array<DX12ShaderSignature*> distinctSignatures;
|
|
|
for (const DX12Shader* shader : shaders)
|
|
for (const DX12Shader* shader : shaders)
|
|
|
{
|
|
{
|
|
@@ -1034,12 +974,10 @@ void Framework::DX12Pipeline::createPipelineState(ID3D12Device5* zDevice,
|
|
|
rootSignatureIndex++;
|
|
rootSignatureIndex++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ D3D12_GLOBAL_ROOT_SIGNATURE globalRootSignature = {};
|
|
|
|
|
+ globalRootSignature.pGlobalRootSignature = globalSignature->zSignature();
|
|
|
subobjects[index].Type = D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE;
|
|
subobjects[index].Type = D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE;
|
|
|
- subobjects[index].pDesc = &emptyGlobalRootSignature;
|
|
|
|
|
- index++;
|
|
|
|
|
-
|
|
|
|
|
- subobjects[index].Type = D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE;
|
|
|
|
|
- subobjects[index].pDesc = &emptyLocalRootSignature;
|
|
|
|
|
|
|
+ subobjects[index].pDesc = &globalRootSignature;
|
|
|
index++;
|
|
index++;
|
|
|
|
|
|
|
|
D3D12_RAYTRACING_PIPELINE_CONFIG pipelineConfig = {};
|
|
D3D12_RAYTRACING_PIPELINE_CONFIG pipelineConfig = {};
|
|
@@ -1063,14 +1001,14 @@ void Framework::DX12Pipeline::createPipelineState(ID3D12Device5* zDevice,
|
|
|
throw std::logic_error("Could not create the raytracing state object");
|
|
throw std::logic_error("Could not create the raytracing state object");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* delete[] functionAndHitGroupNames;
|
|
|
|
|
|
|
+ delete[] functionAndHitGroupNames;
|
|
|
delete[] localRootSignatures;
|
|
delete[] localRootSignatures;
|
|
|
for (int i = 0; i < distinctSignatures.getEntryCount(); i++)
|
|
for (int i = 0; i < distinctSignatures.getEntryCount(); i++)
|
|
|
{
|
|
{
|
|
|
delete[] rootSignatureExports[i];
|
|
delete[] rootSignatureExports[i];
|
|
|
}
|
|
}
|
|
|
delete[] rootSignatureExports;
|
|
delete[] rootSignatureExports;
|
|
|
- delete[] localRootAssociations;*/
|
|
|
|
|
|
|
+ delete[] localRootAssociations;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ID3D12StateObject* Framework::DX12Pipeline::zPipelineState() const
|
|
ID3D12StateObject* Framework::DX12Pipeline::zPipelineState() const
|
|
@@ -1106,6 +1044,11 @@ const RCArray<DX12ShaderHitGroup>& Framework::DX12Pipeline::getHitGroups() const
|
|
|
return hitGroups;
|
|
return hitGroups;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+DX12ShaderSignature* Framework::DX12Pipeline::zGlobalSignature() const
|
|
|
|
|
+{
|
|
|
|
|
+ return globalSignature;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
Framework::DX12GlobalDescriptorHeap::DX12GlobalDescriptorHeap(
|
|
Framework::DX12GlobalDescriptorHeap::DX12GlobalDescriptorHeap(
|
|
|
DX12Pipeline* pipeline, DX12DescriptorHeapType type)
|
|
DX12Pipeline* pipeline, DX12DescriptorHeapType type)
|
|
|
: ReferenceCounter(),
|
|
: ReferenceCounter(),
|