|
@@ -58,7 +58,6 @@ DirectX12::DirectX12()
|
|
|
swapChain(0),
|
|
swapChain(0),
|
|
|
backBufferIndex(0),
|
|
backBufferIndex(0),
|
|
|
tearing(0),
|
|
tearing(0),
|
|
|
- signature(0),
|
|
|
|
|
uiTexture(0),
|
|
uiTexture(0),
|
|
|
texturRegister(new TextureList()),
|
|
texturRegister(new TextureList()),
|
|
|
blasModels(0),
|
|
blasModels(0),
|
|
@@ -74,7 +73,6 @@ DirectX12::DirectX12()
|
|
|
pfnD3D12SerializeRootSignature(0),
|
|
pfnD3D12SerializeRootSignature(0),
|
|
|
pipeline(0),
|
|
pipeline(0),
|
|
|
globalDescriptorHeap(0),
|
|
globalDescriptorHeap(0),
|
|
|
- textureDescriptorHeap(0),
|
|
|
|
|
samplerDescriptorHeap(0),
|
|
samplerDescriptorHeap(0),
|
|
|
defaultHitGroup(0),
|
|
defaultHitGroup(0),
|
|
|
defaultRayGenerationShaderFunction(0),
|
|
defaultRayGenerationShaderFunction(0),
|
|
@@ -82,7 +80,10 @@ DirectX12::DirectX12()
|
|
|
sbtTextureIdBufferOffset(0),
|
|
sbtTextureIdBufferOffset(0),
|
|
|
sbtIndexBufferOffset(0),
|
|
sbtIndexBufferOffset(0),
|
|
|
sbtVertexDataBufferOffset(0),
|
|
sbtVertexDataBufferOffset(0),
|
|
|
- sbtPolygonSizeBufferOffset(0)
|
|
|
|
|
|
|
+ sbtPolygonSizeBufferOffset(0),
|
|
|
|
|
+ firstTextureHeapIndex(0),
|
|
|
|
|
+ globalRayGenerationSettingsOffset(0),
|
|
|
|
|
+ globalTLASoffset(0)
|
|
|
{
|
|
{
|
|
|
for (int i = 0; i < 2; i++)
|
|
for (int i = 0; i < 2; i++)
|
|
|
backBuffer[i] = 0;
|
|
backBuffer[i] = 0;
|
|
@@ -119,10 +120,6 @@ DirectX12::~DirectX12()
|
|
|
{
|
|
{
|
|
|
globalDescriptorHeap->release();
|
|
globalDescriptorHeap->release();
|
|
|
}
|
|
}
|
|
|
- if (textureDescriptorHeap)
|
|
|
|
|
- {
|
|
|
|
|
- textureDescriptorHeap->release();
|
|
|
|
|
- }
|
|
|
|
|
if (samplerDescriptorHeap)
|
|
if (samplerDescriptorHeap)
|
|
|
{
|
|
{
|
|
|
samplerDescriptorHeap->release();
|
|
samplerDescriptorHeap->release();
|
|
@@ -148,7 +145,6 @@ DirectX12::~DirectX12()
|
|
|
if (uiTexture) uiTexture->release();
|
|
if (uiTexture) uiTexture->release();
|
|
|
if (defaultKamera) defaultKamera->release();
|
|
if (defaultKamera) defaultKamera->release();
|
|
|
if (defaultRenderTarget) defaultRenderTarget->release();
|
|
if (defaultRenderTarget) defaultRenderTarget->release();
|
|
|
- if (signature) signature->Release();
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
for (int i = 0; i < 2; i++)
|
|
|
{
|
|
{
|
|
|
if (backBuffer[i]) backBuffer[i]->Release();
|
|
if (backBuffer[i]) backBuffer[i]->Release();
|
|
@@ -205,7 +201,8 @@ void Framework::DirectX12::renderKamera(
|
|
|
{
|
|
{
|
|
|
if (texture->hasBufferChanged())
|
|
if (texture->hasBufferChanged())
|
|
|
{
|
|
{
|
|
|
- textureDescriptorHeap->updateTextureInput(texture->getId(),
|
|
|
|
|
|
|
+ globalDescriptorHeap->updateTextureInput(
|
|
|
|
|
+ texture->getId() + firstTextureHeapIndex,
|
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE,
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE,
|
|
|
(DX12Texture*)texture);
|
|
(DX12Texture*)texture);
|
|
|
texture->setBufferChanged(0);
|
|
texture->setBufferChanged(0);
|
|
@@ -250,11 +247,15 @@ void Framework::DirectX12::renderKamera(
|
|
|
// descriptor heaps must be set before filling the shader binding table with
|
|
// descriptor heaps must be set before filling the shader binding table with
|
|
|
// hit groups
|
|
// hit groups
|
|
|
sbt->setGlobalDescriptorHeap(globalDescriptorHeap);
|
|
sbt->setGlobalDescriptorHeap(globalDescriptorHeap);
|
|
|
- sbt->setTextureDescriptorHeap(textureDescriptorHeap);
|
|
|
|
|
sbt->setSamplerDescriptorHeap(samplerDescriptorHeap);
|
|
sbt->setSamplerDescriptorHeap(samplerDescriptorHeap);
|
|
|
int objectIndex = 0;
|
|
int objectIndex = 0;
|
|
|
renderWorld(w, tlas, sbt, objectIndex);
|
|
renderWorld(w, tlas, sbt, objectIndex);
|
|
|
tlas->endUpdate();
|
|
tlas->endUpdate();
|
|
|
|
|
+ // add additional default hit group if no other hit group exists
|
|
|
|
|
+ if (!sbt->getHitGoupCount() && defaultHitGroup)
|
|
|
|
|
+ {
|
|
|
|
|
+ sbt->addHitGroup(defaultHitGroup);
|
|
|
|
|
+ }
|
|
|
settings.inverseProjection = zKamera->getInverseProjectionMatrix();
|
|
settings.inverseProjection = zKamera->getInverseProjectionMatrix();
|
|
|
settings.inverseView = zKamera->getInverseViewMatrix();
|
|
settings.inverseView = zKamera->getInverseViewMatrix();
|
|
|
settings.minDistance = zKamera->getMinDistance();
|
|
settings.minDistance = zKamera->getMinDistance();
|
|
@@ -263,13 +264,6 @@ void Framework::DirectX12::renderKamera(
|
|
|
settings.renderGui = (int)guiVisible;
|
|
settings.renderGui = (int)guiVisible;
|
|
|
rayGenSettingsBuffer->setData(&settings, 1);
|
|
rayGenSettingsBuffer->setData(&settings, 1);
|
|
|
rayGenSettingsBuffer->copyToGPU(sizeof(settings));
|
|
rayGenSettingsBuffer->copyToGPU(sizeof(settings));
|
|
|
- if (defaultRayGenerationShaderFunction)
|
|
|
|
|
- {
|
|
|
|
|
- globalDescriptorHeap->updateTextureInput(
|
|
|
|
|
- 0, DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, zTarget);
|
|
|
|
|
- globalDescriptorHeap->updateTLASInput(
|
|
|
|
|
- 3, DX12_SHADER_REGISTER_T_SHADER_RESOURCE, tlas);
|
|
|
|
|
- }
|
|
|
|
|
sbt->endUpdate(device, directCommandQueue);
|
|
sbt->endUpdate(device, directCommandQueue);
|
|
|
|
|
|
|
|
D3D12_DISPATCH_RAYS_DESC desc;
|
|
D3D12_DISPATCH_RAYS_DESC desc;
|
|
@@ -278,7 +272,7 @@ void Framework::DirectX12::renderKamera(
|
|
|
desc.Height = zTarget->zImage()->getHeight();
|
|
desc.Height = zTarget->zImage()->getHeight();
|
|
|
desc.Depth = 1;
|
|
desc.Depth = 1;
|
|
|
// order of definition in DX12DescriptorHeapType must be matched
|
|
// order of definition in DX12DescriptorHeapType must be matched
|
|
|
- fillGlobalShaderParams(zKamera, tlas);
|
|
|
|
|
|
|
+ fillGlobalShaderParams(zKamera, tlas, zTarget);
|
|
|
directCommandQueue->zCommandList()->SetPipelineState1(
|
|
directCommandQueue->zCommandList()->SetPipelineState1(
|
|
|
pipeline->zPipelineState());
|
|
pipeline->zPipelineState());
|
|
|
directCommandQueue->zCommandList()->DispatchRays(&desc);
|
|
directCommandQueue->zCommandList()->DispatchRays(&desc);
|
|
@@ -366,25 +360,29 @@ void Framework::DirectX12::initializePipeline()
|
|
|
{ // add default shaders
|
|
{ // add default shaders
|
|
|
pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(
|
|
pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
0, DX12_SHADER_REGISTER_S_SAMPLER, 0, 0, SAMPLER_DESCRIPTOR_HEAP);
|
|
0, DX12_SHADER_REGISTER_S_SAMPLER, 0, 0, SAMPLER_DESCRIPTOR_HEAP);
|
|
|
- pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(0,
|
|
|
|
|
|
|
+ pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
+ firstTextureHeapIndex,
|
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE,
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE,
|
|
|
0,
|
|
0,
|
|
|
1,
|
|
1,
|
|
|
- TEXTURE_DESCRIPTOR_HEAP,
|
|
|
|
|
|
|
+ GLOBAL_DESCRIPTOR_HEAP,
|
|
|
1);
|
|
1);
|
|
|
|
|
+ pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
+ 0, DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, 0);
|
|
|
|
|
+ pipeline->zGlobalSignature()->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
+ 1, DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, 1);
|
|
|
|
|
+ globalRayGenerationSettingsOffset
|
|
|
|
|
+ = pipeline->zGlobalSignature()
|
|
|
|
|
+ ->addRegisterUsageLinkedToShaderBindingTable(
|
|
|
|
|
+ DX12_SHADER_REGISTER_B_CONST_BUFFER, 0);
|
|
|
|
|
+ globalTLASoffset = pipeline->zGlobalSignature()
|
|
|
|
|
+ ->addRegisterUsageLinkedToShaderBindingTable(
|
|
|
|
|
+ DX12_SHADER_REGISTER_T_SHADER_RESOURCE, 0);
|
|
|
|
|
|
|
|
DX12Shader* rayGenShader = new DX12Shader(
|
|
DX12Shader* rayGenShader = new DX12Shader(
|
|
|
DX12DefaultRayGenShaderBytes, sizeof(DX12DefaultRayGenShaderBytes));
|
|
DX12DefaultRayGenShaderBytes, sizeof(DX12DefaultRayGenShaderBytes));
|
|
|
// RayGen from RayGen.hlsl
|
|
// RayGen from RayGen.hlsl
|
|
|
DX12ShaderSignature* rayGenSignature = new DX12ShaderSignature();
|
|
DX12ShaderSignature* rayGenSignature = new DX12ShaderSignature();
|
|
|
- rayGenSignature->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
- 0, DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, 0);
|
|
|
|
|
- rayGenSignature->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
- 1, DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, 1);
|
|
|
|
|
- rayGenSignature->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
- 2, DX12_SHADER_REGISTER_B_CONST_BUFFER, 0);
|
|
|
|
|
- rayGenSignature->addRegisterUsageLinkedToDescriptorHeap(
|
|
|
|
|
- 3, DX12_SHADER_REGISTER_T_SHADER_RESOURCE, 0);
|
|
|
|
|
defaultRayGenerationShaderFunction = new DX12ShaderFunction(
|
|
defaultRayGenerationShaderFunction = new DX12ShaderFunction(
|
|
|
"RayGen", rayGenSignature, DX12_SHADER_FUNCTION_TYPE_RAY_GEN);
|
|
"RayGen", rayGenSignature, DX12_SHADER_FUNCTION_TYPE_RAY_GEN);
|
|
|
rayGenShader->addFunction(defaultRayGenerationShaderFunction);
|
|
rayGenShader->addFunction(defaultRayGenerationShaderFunction);
|
|
@@ -446,24 +444,14 @@ void Framework::DirectX12::initializeGlobalDescriptorHeap()
|
|
|
DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, defaultRenderTarget);
|
|
DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, defaultRenderTarget);
|
|
|
globalDescriptorHeap->addTextureInput(
|
|
globalDescriptorHeap->addTextureInput(
|
|
|
DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, uiTexture);
|
|
DX12_SHADER_REGISTER_U_UNORDERED_ACCESS, uiTexture);
|
|
|
- globalDescriptorHeap->addBufferInput(
|
|
|
|
|
- DX12_SHADER_REGISTER_B_CONST_BUFFER, rayGenSettingsBuffer);
|
|
|
|
|
- globalDescriptorHeap->addTLASInput(
|
|
|
|
|
- DX12_SHADER_REGISTER_T_SHADER_RESOURCE, 0);
|
|
|
|
|
-
|
|
|
|
|
- globalDescriptorHeap->updateDescriptorHeap(device);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void Framework::DirectX12::initializeTextureDescriptorHeap()
|
|
|
|
|
-{
|
|
|
|
|
|
|
+ firstTextureHeapIndex = globalDescriptorHeap->getRegisterInputCount();
|
|
|
for (Texture* tex : *texturRegister->zTextures())
|
|
for (Texture* tex : *texturRegister->zTextures())
|
|
|
{
|
|
{
|
|
|
- textureDescriptorHeap->addTextureInput(
|
|
|
|
|
|
|
+ globalDescriptorHeap->addTextureInput(
|
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE, tex);
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE, tex);
|
|
|
tex->setBufferChanged(0);
|
|
tex->setBufferChanged(0);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- textureDescriptorHeap->updateDescriptorHeap(device);
|
|
|
|
|
|
|
+ globalDescriptorHeap->updateDescriptorHeap(device);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void Framework::DirectX12::initializeSamplerDescriptorHeap()
|
|
void Framework::DirectX12::initializeSamplerDescriptorHeap()
|
|
@@ -526,13 +514,10 @@ void Framework::DirectX12::fillShaderBindingTable(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int Framework::DirectX12::fillGlobalShaderParams(
|
|
int Framework::DirectX12::fillGlobalShaderParams(
|
|
|
- Cam3D* zKam, DX12TLAS* zTLAS, int startIndex)
|
|
|
|
|
|
|
+ Cam3D* zKam, DX12TLAS* zTLAS, DX12Texture* zTarget, int startIndex)
|
|
|
{
|
|
{
|
|
|
- ID3D12DescriptorHeap* heaps[]
|
|
|
|
|
- = {pipeline->zGlobalSignature()->doesUseTextureDescriptorHeap()
|
|
|
|
|
- ? textureDescriptorHeap->zDescriptorHeap()
|
|
|
|
|
- : globalDescriptorHeap->zDescriptorHeap(),
|
|
|
|
|
- samplerDescriptorHeap->zDescriptorHeap()};
|
|
|
|
|
|
|
+ ID3D12DescriptorHeap* heaps[] = {globalDescriptorHeap->zDescriptorHeap(),
|
|
|
|
|
+ samplerDescriptorHeap->zDescriptorHeap()};
|
|
|
directCommandQueue->zCommandList()->SetDescriptorHeaps(2, heaps);
|
|
directCommandQueue->zCommandList()->SetDescriptorHeaps(2, heaps);
|
|
|
if (pipeline->zGlobalSignature()->gerShaderBindingTableParamCount()
|
|
if (pipeline->zGlobalSignature()->gerShaderBindingTableParamCount()
|
|
|
+ pipeline->zGlobalSignature()
|
|
+ pipeline->zGlobalSignature()
|
|
@@ -552,13 +537,6 @@ int Framework::DirectX12::fillGlobalShaderParams(
|
|
|
globalDescriptorHeap->zDescriptorHeap()
|
|
globalDescriptorHeap->zDescriptorHeap()
|
|
|
->GetGPUDescriptorHandleForHeapStart());
|
|
->GetGPUDescriptorHandleForHeapStart());
|
|
|
}
|
|
}
|
|
|
- if (pipeline->zGlobalSignature()->doesUseTextureDescriptorHeap())
|
|
|
|
|
- {
|
|
|
|
|
- directCommandQueue->zCommandList()->SetComputeRootDescriptorTable(
|
|
|
|
|
- startIndex++,
|
|
|
|
|
- textureDescriptorHeap->zDescriptorHeap()
|
|
|
|
|
- ->GetGPUDescriptorHandleForHeapStart());
|
|
|
|
|
- }
|
|
|
|
|
if (pipeline->zGlobalSignature()->doesUseSamplerDescriptorHeap())
|
|
if (pipeline->zGlobalSignature()->doesUseSamplerDescriptorHeap())
|
|
|
{
|
|
{
|
|
|
directCommandQueue->zCommandList()->SetComputeRootDescriptorTable(
|
|
directCommandQueue->zCommandList()->SetComputeRootDescriptorTable(
|
|
@@ -567,6 +545,18 @@ int Framework::DirectX12::fillGlobalShaderParams(
|
|
|
->GetGPUDescriptorHandleForHeapStart());
|
|
->GetGPUDescriptorHandleForHeapStart());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (globalRayGenerationSettingsOffset)
|
|
|
|
|
+ {
|
|
|
|
|
+ directCommandQueue->zCommandList()->SetComputeRootConstantBufferView(
|
|
|
|
|
+ *globalRayGenerationSettingsOffset,
|
|
|
|
|
+ rayGenSettingsBuffer->zBuffer()->GetGPUVirtualAddress());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (globalTLASoffset)
|
|
|
|
|
+ {
|
|
|
|
|
+ directCommandQueue->zCommandList()->SetComputeRootShaderResourceView(
|
|
|
|
|
+ *globalTLASoffset,
|
|
|
|
|
+ zTLAS->zResultBuffer()->zBuffer()->GetGPUVirtualAddress());
|
|
|
|
|
+ }
|
|
|
return startIndex;
|
|
return startIndex;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -588,9 +578,10 @@ void DirectX12::initialize(
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
if (debugDX)
|
|
if (debugDX)
|
|
|
{
|
|
{
|
|
|
- HINSTANCE pixDebugger = getDLLRegister()->loadDLL(
|
|
|
|
|
- "WinPixGpuCapturer.dll",
|
|
|
|
|
- "C:\\Program Files\\Microsoft PIX\\2603.25\\WinPixGpuCapturer.dll");
|
|
|
|
|
|
|
+ HINSTANCE pixDebugger
|
|
|
|
|
+ = getDLLRegister()->loadDLL("WinPixGpuCapturer.dll",
|
|
|
|
|
+ "C:\\Program Files\\Microsoft PIX "
|
|
|
|
|
+ "Preview\\2606.18-preview\\WinPixGpuCapturer.dll");
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -659,32 +650,68 @@ void DirectX12::initialize(
|
|
|
MB_ICONERROR);
|
|
MB_ICONERROR);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- // D3D12SerializeVersionedRootSignature
|
|
|
|
|
- PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE d3d12svrsf
|
|
|
|
|
- = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)GetProcAddress(
|
|
|
|
|
- d3d12DLL, "D3D12SerializeVersionedRootSignature");
|
|
|
|
|
- // D3D12SerializeRootSignature
|
|
|
|
|
- PFN_D3D12_SERIALIZE_ROOT_SIGNATURE d3d12srsf
|
|
|
|
|
- = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(
|
|
|
|
|
- d3d12DLL, "D3D12SerializeRootSignature");
|
|
|
|
|
bool debugDXGI = 0;
|
|
bool debugDXGI = 0;
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
- IDXGIInfoQueue* dxgiInfoQueue;
|
|
|
|
|
|
|
+ IDXGIInfoQueue* dxgiInfoQueue = 0;
|
|
|
if (debugDX)
|
|
if (debugDX)
|
|
|
{
|
|
{
|
|
|
// D3D12GetDebugInterface
|
|
// D3D12GetDebugInterface
|
|
|
D3D12GetDebugInterfaceFunction getDebugInterface
|
|
D3D12GetDebugInterfaceFunction getDebugInterface
|
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
|
- if (SUCCEEDED(getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug)))
|
|
|
|
|
- debug->EnableDebugLayer();
|
|
|
|
|
|
|
+ if (getDebugInterface)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (SUCCEEDED(
|
|
|
|
|
+ getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug)))
|
|
|
|
|
+ {
|
|
|
|
|
+ debug->EnableDebugLayer();
|
|
|
|
|
+
|
|
|
|
|
+ ID3D12Debug1* debug1 = 0;
|
|
|
|
|
+ if (SUCCEEDED(debug->QueryInterface(
|
|
|
|
|
+ __uuidof(ID3D12Debug1), (void**)&debug1)))
|
|
|
|
|
+ {
|
|
|
|
|
+ debug1->SetEnableGPUBasedValidation(TRUE);
|
|
|
|
|
+ debug1->SetEnableSynchronizedCommandQueueValidation(TRUE);
|
|
|
|
|
+ debug1->Release();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ID3D12DeviceRemovedExtendedDataSettings* dredSettings = 0;
|
|
|
|
|
+ if (SUCCEEDED(getDebugInterface(
|
|
|
|
|
+ __uuidof(ID3D12DeviceRemovedExtendedDataSettings),
|
|
|
|
|
+ (void**)&dredSettings)))
|
|
|
|
|
+ {
|
|
|
|
|
+ dredSettings->SetAutoBreadcrumbsEnablement(
|
|
|
|
|
+ D3D12_DRED_ENABLEMENT_FORCED_ON);
|
|
|
|
|
+ dredSettings->SetPageFaultEnablement(
|
|
|
|
|
+ D3D12_DRED_ENABLEMENT_FORCED_ON);
|
|
|
|
|
+ dredSettings->Release();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// DXGIGetDebugInterface1
|
|
// DXGIGetDebugInterface1
|
|
|
DXGIGetDebugInterface1Function dxgiDebugInterface
|
|
DXGIGetDebugInterface1Function dxgiDebugInterface
|
|
|
= (DXGIGetDebugInterface1Function)GetProcAddress(
|
|
= (DXGIGetDebugInterface1Function)GetProcAddress(
|
|
|
dxgiDLL, "DXGIGetDebugInterface1");
|
|
dxgiDLL, "DXGIGetDebugInterface1");
|
|
|
- if (SUCCEEDED(dxgiDebugInterface(
|
|
|
|
|
|
|
+ if (dxgiDebugInterface
|
|
|
|
|
+ && SUCCEEDED(dxgiDebugInterface(
|
|
|
0, __uuidof(IDXGIInfoQueue), (void**)&dxgiInfoQueue)))
|
|
0, __uuidof(IDXGIInfoQueue), (void**)&dxgiInfoQueue)))
|
|
|
|
|
+ {
|
|
|
debugDXGI = 1;
|
|
debugDXGI = 1;
|
|
|
|
|
+ static const DXGI_DEBUG_ID DXGI_DEBUG_ALL_LOCAL = {
|
|
|
|
|
+ 0xe48ae283,
|
|
|
|
|
+ 0xda80,
|
|
|
|
|
+ 0x490b,
|
|
|
|
|
+ {0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x08}
|
|
|
|
|
+ };
|
|
|
|
|
+ dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL_LOCAL,
|
|
|
|
|
+ DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR,
|
|
|
|
|
+ TRUE);
|
|
|
|
|
+ dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL_LOCAL,
|
|
|
|
|
+ DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION,
|
|
|
|
|
+ TRUE);
|
|
|
|
|
+ dxgiInfoQueue->Release();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
IDXGIFactory6* factory;
|
|
IDXGIFactory6* factory;
|
|
@@ -929,106 +956,8 @@ void DirectX12::initialize(
|
|
|
Image* renderB = new Image(1);
|
|
Image* renderB = new Image(1);
|
|
|
renderB->setAlpha3D(1);
|
|
renderB->setAlpha3D(1);
|
|
|
renderB->newImage(this->backBufferSize.x, this->backBufferSize.y, 0);
|
|
renderB->newImage(this->backBufferSize.x, this->backBufferSize.y, 0);
|
|
|
- uiTexture = createOrGetTexture("_f_Render_Image", renderB, RAM_TO_GPU);
|
|
|
|
|
-
|
|
|
|
|
- D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {};
|
|
|
|
|
- featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1;
|
|
|
|
|
- if (FAILED(device->CheckFeatureSupport(
|
|
|
|
|
- D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData))))
|
|
|
|
|
- featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0;
|
|
|
|
|
-
|
|
|
|
|
- D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags
|
|
|
|
|
- = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT
|
|
|
|
|
- | D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS
|
|
|
|
|
- | D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS
|
|
|
|
|
- | D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS;
|
|
|
|
|
-
|
|
|
|
|
- D3D12_DESCRIPTOR_RANGE1 range[2];
|
|
|
|
|
- range[0].NumDescriptors = 5;
|
|
|
|
|
- range[0].BaseShaderRegister = 0;
|
|
|
|
|
- range[0].RegisterSpace = 0;
|
|
|
|
|
- range[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_CBV;
|
|
|
|
|
- range[0].OffsetInDescriptorsFromTableStart
|
|
|
|
|
- = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
|
|
|
|
|
- range[0].Flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE;
|
|
|
|
|
- range[1].NumDescriptors = 1;
|
|
|
|
|
- range[1].BaseShaderRegister = 0;
|
|
|
|
|
- range[1].RegisterSpace = 0;
|
|
|
|
|
- range[1].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
|
|
|
|
|
- range[1].OffsetInDescriptorsFromTableStart
|
|
|
|
|
- = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
|
|
|
|
|
- range[1].Flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE;
|
|
|
|
|
-
|
|
|
|
|
- D3D12_ROOT_PARAMETER1 rootParameters[1];
|
|
|
|
|
- rootParameters[0].ParameterType
|
|
|
|
|
- = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
|
|
|
|
|
- rootParameters[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
|
|
|
|
|
- rootParameters[0].DescriptorTable.NumDescriptorRanges = 2;
|
|
|
|
|
- rootParameters[0].DescriptorTable.pDescriptorRanges = range;
|
|
|
|
|
-
|
|
|
|
|
- D3D12_STATIC_SAMPLER_DESC sampler = {};
|
|
|
|
|
- sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT;
|
|
|
|
|
- sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
|
|
|
|
- sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
|
|
|
|
- sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_BORDER;
|
|
|
|
|
- sampler.MipLODBias = 0;
|
|
|
|
|
- sampler.MaxAnisotropy = 0;
|
|
|
|
|
- sampler.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER;
|
|
|
|
|
- sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK;
|
|
|
|
|
- sampler.MinLOD = 0.0f;
|
|
|
|
|
- sampler.MaxLOD = D3D12_FLOAT32_MAX;
|
|
|
|
|
- sampler.ShaderRegister = 0;
|
|
|
|
|
- sampler.RegisterSpace = 0;
|
|
|
|
|
- sampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
|
|
|
|
-
|
|
|
|
|
- D3D12_VERSIONED_ROOT_SIGNATURE_DESC rootSignatureDescription;
|
|
|
|
|
- rootSignatureDescription.Version = D3D_ROOT_SIGNATURE_VERSION_1_1;
|
|
|
|
|
- rootSignatureDescription.Desc_1_1.NumParameters = 1;
|
|
|
|
|
- rootSignatureDescription.Desc_1_1.pParameters = rootParameters;
|
|
|
|
|
- rootSignatureDescription.Desc_1_1.NumStaticSamplers = 1;
|
|
|
|
|
- rootSignatureDescription.Desc_1_1.pStaticSamplers = &sampler;
|
|
|
|
|
- rootSignatureDescription.Desc_1_1.Flags = rootSignatureFlags;
|
|
|
|
|
-
|
|
|
|
|
- ID3DBlob* rootSignature;
|
|
|
|
|
- ID3DBlob* error;
|
|
|
|
|
- res = D3DX12SerializeVersionedRootSignature(&rootSignatureDescription,
|
|
|
|
|
- featureData.HighestVersion,
|
|
|
|
|
- &rootSignature,
|
|
|
|
|
- &error,
|
|
|
|
|
- d3d12svrsf,
|
|
|
|
|
- d3d12srsf);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- factory->Release();
|
|
|
|
|
- Logging::error()
|
|
|
|
|
- << "ERROR: D3DX12SerializeVersionedRootSignature returned " << res
|
|
|
|
|
- << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text(
|
|
|
|
|
- "D3DX12SerializeVersionedRootSignature ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- if (error) error->Release();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- res = device->CreateRootSignature(0,
|
|
|
|
|
- rootSignature->GetBufferPointer(),
|
|
|
|
|
- rootSignature->GetBufferSize(),
|
|
|
|
|
- __uuidof(ID3D12RootSignature),
|
|
|
|
|
- (void**)&signature);
|
|
|
|
|
- if (FAILED(res))
|
|
|
|
|
- {
|
|
|
|
|
- factory->Release();
|
|
|
|
|
- Logging::error() << "ERROR: CreateRootSignature returned " << res
|
|
|
|
|
- << "\n";
|
|
|
|
|
- WMessageBox(fenster->getWindowHandle(),
|
|
|
|
|
- new Text("Fehler"),
|
|
|
|
|
- new Text("CreateRootSignature ist Fehlgeschlagen."),
|
|
|
|
|
- MB_ICONERROR);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- rootSignature->Release();
|
|
|
|
|
|
|
+ uiTexture = dynamic_cast<DX12Texture*>(
|
|
|
|
|
+ createOrGetTexture("_f_Render_Image", renderB, RAM_TO_GPU));
|
|
|
|
|
|
|
|
D3D12_RASTERIZER_DESC rdesc;
|
|
D3D12_RASTERIZER_DESC rdesc;
|
|
|
rdesc.FillMode = D3D12_FILL_MODE_SOLID;
|
|
rdesc.FillMode = D3D12_FILL_MODE_SOLID;
|
|
@@ -1126,10 +1055,10 @@ void DirectX12::presentFrame()
|
|
|
|
|
|
|
|
directCommandQueue->execute();
|
|
directCommandQueue->execute();
|
|
|
|
|
|
|
|
- swapChain->Present(0, DXGI_PRESENT_ALLOW_TEARING);
|
|
|
|
|
|
|
+ UINT presentFlags = tearing ? DXGI_PRESENT_ALLOW_TEARING : 0;
|
|
|
|
|
+ swapChain->Present(0, presentFlags);
|
|
|
|
|
|
|
|
globalDescriptorHeap->setHeapChanged(0);
|
|
globalDescriptorHeap->setHeapChanged(0);
|
|
|
- textureDescriptorHeap->setHeapChanged(0);
|
|
|
|
|
samplerDescriptorHeap->setHeapChanged(0);
|
|
samplerDescriptorHeap->setHeapChanged(0);
|
|
|
|
|
|
|
|
backBufferIndex = swapChain->GetCurrentBackBufferIndex();
|
|
backBufferIndex = swapChain->GetCurrentBackBufferIndex();
|
|
@@ -1156,11 +1085,11 @@ Texture* DirectX12::createOrGetTexture(
|
|
|
if (b) ret->setImageZ(b);
|
|
if (b) ret->setImageZ(b);
|
|
|
texturRegister->addTexture(dynamic_cast<Texture*>(ret->getThis()), name);
|
|
texturRegister->addTexture(dynamic_cast<Texture*>(ret->getThis()), name);
|
|
|
ret->updateTextur();
|
|
ret->updateTextur();
|
|
|
- if (textureDescriptorHeap)
|
|
|
|
|
|
|
+ if (globalDescriptorHeap)
|
|
|
{
|
|
{
|
|
|
- textureDescriptorHeap->addTextureInput(
|
|
|
|
|
|
|
+ globalDescriptorHeap->addTextureInput(
|
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE, ret);
|
|
DX12_SHADER_REGISTER_T_SHADER_RESOURCE, ret);
|
|
|
- textureDescriptorHeap->updateDescriptorHeap(device);
|
|
|
|
|
|
|
+ globalDescriptorHeap->updateDescriptorHeap(device);
|
|
|
ret->setBufferChanged(0);
|
|
ret->setBufferChanged(0);
|
|
|
}
|
|
}
|
|
|
// directCommandQueue->execute();
|
|
// directCommandQueue->execute();
|
|
@@ -1213,7 +1142,6 @@ void Framework::DirectX12::setPipeline(DX12Pipeline* pipeline)
|
|
|
this->pipeline = pipeline;
|
|
this->pipeline = pipeline;
|
|
|
if (pipeline)
|
|
if (pipeline)
|
|
|
{
|
|
{
|
|
|
- initializePipeline();
|
|
|
|
|
if (!globalDescriptorHeap
|
|
if (!globalDescriptorHeap
|
|
|
|| globalDescriptorHeap->zPipeline() != pipeline)
|
|
|| globalDescriptorHeap->zPipeline() != pipeline)
|
|
|
{
|
|
{
|
|
@@ -1225,17 +1153,6 @@ void Framework::DirectX12::setPipeline(DX12Pipeline* pipeline)
|
|
|
= pipeline->createGlobalDescriptorHeap(GLOBAL_DESCRIPTOR_HEAP);
|
|
= pipeline->createGlobalDescriptorHeap(GLOBAL_DESCRIPTOR_HEAP);
|
|
|
initializeGlobalDescriptorHeap();
|
|
initializeGlobalDescriptorHeap();
|
|
|
}
|
|
}
|
|
|
- if (!textureDescriptorHeap
|
|
|
|
|
- || textureDescriptorHeap->zPipeline() != pipeline)
|
|
|
|
|
- {
|
|
|
|
|
- if (textureDescriptorHeap)
|
|
|
|
|
- {
|
|
|
|
|
- textureDescriptorHeap->release();
|
|
|
|
|
- }
|
|
|
|
|
- textureDescriptorHeap
|
|
|
|
|
- = pipeline->createGlobalDescriptorHeap(TEXTURE_DESCRIPTOR_HEAP);
|
|
|
|
|
- initializeTextureDescriptorHeap();
|
|
|
|
|
- }
|
|
|
|
|
if (!samplerDescriptorHeap
|
|
if (!samplerDescriptorHeap
|
|
|
|| samplerDescriptorHeap->zPipeline() != pipeline)
|
|
|| samplerDescriptorHeap->zPipeline() != pipeline)
|
|
|
{
|
|
{
|
|
@@ -1247,6 +1164,7 @@ void Framework::DirectX12::setPipeline(DX12Pipeline* pipeline)
|
|
|
= pipeline->createGlobalDescriptorHeap(SAMPLER_DESCRIPTOR_HEAP);
|
|
= pipeline->createGlobalDescriptorHeap(SAMPLER_DESCRIPTOR_HEAP);
|
|
|
initializeSamplerDescriptorHeap();
|
|
initializeSamplerDescriptorHeap();
|
|
|
}
|
|
}
|
|
|
|
|
+ initializePipeline();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1283,8 +1201,10 @@ bool DirectX12::isAvailable()
|
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
= (D3D12GetDebugInterfaceFunction)GetProcAddress(
|
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
d3d12DLL, "D3D12GetDebugInterface");
|
|
|
ID3D12Debug* debug = 0;
|
|
ID3D12Debug* debug = 0;
|
|
|
- getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug);
|
|
|
|
|
- debug->EnableDebugLayer();
|
|
|
|
|
|
|
+ if (getDebugInterface
|
|
|
|
|
+ && SUCCEEDED(getDebugInterface(__uuidof(ID3D12Debug), (void**)&debug))
|
|
|
|
|
+ && debug)
|
|
|
|
|
+ debug->EnableDebugLayer();
|
|
|
#endif
|
|
#endif
|
|
|
IDXGIFactory4* factory;
|
|
IDXGIFactory4* factory;
|
|
|
UINT createFactoryFlags = 0;
|
|
UINT createFactoryFlags = 0;
|
|
@@ -1319,7 +1239,7 @@ bool DirectX12::isAvailable()
|
|
|
current->Release();
|
|
current->Release();
|
|
|
factory->Release();
|
|
factory->Release();
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
- debug->Release();
|
|
|
|
|
|
|
+ if (debug) debug->Release();
|
|
|
#endif
|
|
#endif
|
|
|
getDLLRegister()->releaseDLL("dxgi.dll");
|
|
getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
getDLLRegister()->releaseDLL("d3d12.dll");
|
|
getDLLRegister()->releaseDLL("d3d12.dll");
|
|
@@ -1329,6 +1249,9 @@ bool DirectX12::isAvailable()
|
|
|
}
|
|
}
|
|
|
} while (res != DXGI_ERROR_NOT_FOUND);
|
|
} while (res != DXGI_ERROR_NOT_FOUND);
|
|
|
factory->Release();
|
|
factory->Release();
|
|
|
|
|
+#ifdef _DEBUG
|
|
|
|
|
+ if (debug) debug->Release();
|
|
|
|
|
+#endif
|
|
|
getDLLRegister()->releaseDLL("dxgi.dll");
|
|
getDLLRegister()->releaseDLL("dxgi.dll");
|
|
|
getDLLRegister()->releaseDLL("d3d12.dll");
|
|
getDLLRegister()->releaseDLL("d3d12.dll");
|
|
|
return 0;
|
|
return 0;
|