From 466a563e61330078ca4b0559308b42f9468b9da3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 18 Nov 2019 08:31:03 -0800 Subject: D3D12 backend: fixed issue with the format of the swap chain's back buffer texture --- Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 9517c93f..0d24c669 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -76,7 +76,6 @@ void SwapChainD3D12Impl::InitBuffersAndViews() VERIFY_EXPR(SUCCEEDED(hr)); TextureDesc BackBufferDesc; - BackBufferDesc.Format = m_SwapChainDesc.ColorBufferFormat; String Name = "Main back buffer "; Name += std::to_string(backbuff); BackBufferDesc.Name = Name.c_str(); @@ -85,6 +84,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() m_pRenderDevice.RawPtr()->CreateTexture(BackBufferDesc, pBackBuffer, RESOURCE_STATE_UNDEFINED, &pBackBufferTex); TextureViewDesc RTVDesc; RTVDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; + RTVDesc.Format = m_SwapChainDesc.ColorBufferFormat; RefCntAutoPtr pRTV; pBackBufferTex->CreateView(RTVDesc, &pRTV); m_pBackBufferRTV[backbuff] = RefCntAutoPtr(pRTV, IID_TextureViewD3D12); diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 945e4428..61cdc181 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -339,9 +339,13 @@ static TextureDesc InitTexDescFromD3D12Resource(ID3D12Resource* pTexture, const TextureDesc TexDesc = SrcTexDesc; if (TexDesc.Format == TEX_FORMAT_UNKNOWN) TexDesc.Format = DXGI_FormatToTexFormat(ResourceDesc.Format); - auto RefDXGIFormat = TexFormatToDXGI_Format(TexDesc.Format); - if( RefDXGIFormat != TexDesc.Format) - LOG_ERROR_AND_THROW("Incorrect texture format (", GetTextureFormatAttribs(TexDesc.Format).Name, ")"); + else + { + auto RefFormat = DXGI_FormatToTexFormat(ResourceDesc.Format); + DEV_CHECK_ERR(RefFormat == TexDesc.Format, "The format specified by texture description (", GetTextureFormatAttribs(TexDesc.Format).Name, ")" + " does not match the D3D12 resource format (", GetTextureFormatAttribs(RefFormat).Name, ")"); + (void)RefFormat; + } TexDesc.Width = static_cast( ResourceDesc.Width ); TexDesc.Height = Uint32{ ResourceDesc.Height }; -- cgit v1.2.3