Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backends: DX12: let the user specifies the DepthStencilView format. #8217

Closed
wants to merge 1 commit into from

Conversation

bmarques1995
Copy link
Contributor

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.

This is particullarly important for those who use RenderPasses
ocornut pushed a commit that referenced this pull request Dec 9, 2024
…8217)

This is particullarly important for those who use RenderPasses.
@ocornut
Copy link
Owner

ocornut commented Dec 9, 2024

Thank you Bruno for the PR and explanation.
I have merged this as 53dd755 with minor changes (added an explicit init_info.DSVFormat = DXGI_FORMAT_UNKNOWN; in the main.cpp for discoverability + changelog entries).

@ocornut ocornut closed this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants