Skip to content

Fix an issue that SwapChainDesc.DepthBufferFormat = TEX_FORMAT_R24G8_TYPELESS causing D3D12 invalid param error#691

Merged
TheMostDiligent merged 12 commits intoDiligentGraphics:masterfrom
hzqst:d3d12_r24g8
Aug 3, 2025
Merged

Fix an issue that SwapChainDesc.DepthBufferFormat = TEX_FORMAT_R24G8_TYPELESS causing D3D12 invalid param error#691
TheMostDiligent merged 12 commits intoDiligentGraphics:masterfrom
hzqst:d3d12_r24g8

Conversation

@hzqst
Copy link
Copy Markdown
Contributor

@hzqst hzqst commented Aug 2, 2025

An invalid param error D3D12_CLEAR_VALUE::Format cannot be a typeless format. A fully qualified format must be supplied. Format = R24G8_TYPELESS. was thrown when ClearValue.Format set to DXGI_FORMAT_R24G8_TYPELESS.

We just leave the Desc.ClearValue.Format empty and GetClearFormat wil return a proper format for us.

//TextureD3D12Impl.cpp~L169
if (d3d12TexDesc.Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL))
    {
        if (m_Desc.ClearValue.Format != TEX_FORMAT_UNKNOWN)
            ClearValue.Format = TexFormatToDXGI_Format(m_Desc.ClearValue.Format);
        else
        {
            DXGI_FORMAT Format = TexFormatToDXGI_Format(m_Desc.Format, m_Desc.BindFlags);
            ClearValue.Format  = GetClearFormat(Format, d3d12TexDesc.Flags);
        }

@hzqst hzqst requested a review from TheMostDiligent as a code owner August 2, 2025 10:58
Comment thread Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp Outdated
hzqst and others added 2 commits August 3, 2025 11:09
@TheMostDiligent TheMostDiligent merged commit f3e5352 into DiligentGraphics:master Aug 3, 2025
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants