Backends: DX12: let the user specifies the DepthStencilView format. #8217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is particullarly important for those who use RenderPasses
Let me explain the problem:
with this snippet:
`
m_CurrentBufferIndex = m_SwapChain->GetCurrentBackBufferIndex();
auto backBuffer = m_RenderTargets[m_CurrentBufferIndex];
auto rtvHandle = m_RTVHandles[m_CurrentBufferIndex];
auto dsvHandle = m_DSVHandle;
D3D12_RESOURCE_BARRIER rtSetupBarrier{};
rtSetupBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
rtSetupBarrier.Transition.pResource = backBuffer.Get();
rtSetupBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
rtSetupBarrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
rtSetupBarrier.Transition.Subresource = 0;
rtSetupBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
m_CommandLists[m_CurrentBufferIndex]->ResourceBarrier(1, &rtSetupBarrier);
D3D12_RENDER_PASS_RENDER_TARGET_DESC renderTargetDesc = {};
renderTargetDesc.cpuDescriptor = rtvHandle;
renderTargetDesc.BeginningAccess.Type = D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR;
renderTargetDesc.BeginningAccess.Clear.ClearValue = m_ClearColor;
renderTargetDesc.EndingAccess.Type = D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE;
//D24_S8 dsv
D3D12_RENDER_PASS_DEPTH_STENCIL_DESC depthStencilDesc = {};
depthStencilDesc.cpuDescriptor = m_DSVHandle;
depthStencilDesc.DepthBeginningAccess.Type = D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR;
depthStencilDesc.DepthBeginningAccess.Clear.ClearValue.DepthStencil.Depth = 1.0f;
depthStencilDesc.DepthBeginningAccess.Clear.ClearValue.DepthStencil.Stencil = 0;
depthStencilDesc.DepthEndingAccess.Type = D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE;
m_CommandLists[m_CurrentBufferIndex]->BeginRenderPass(1, &renderTargetDesc, &depthStencilDesc, D3D12_RENDER_PASS_FLAG_NONE);
`
and the previous version, the render was throwing:
D3D12 ERROR: ID3D12CommandList::DrawIndexedInstanced: The PSO indicates a format of DXGI_FORMAT_UNKNOWN to be bound to the rasterizer, but the render pass depth stencil descriptor indicates an incompatible format (DXGI_FORMAT_D24_UNORM_S8_UINT). [ EXECUTION ERROR #1170: RENDER_PASS_ERROR]
This snippet is to the use set also the DSV format to the Imgui PSO.