From 724f9829b4b58459ee93c717f76ac20e3b0ce9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 4 May 2018 16:35:59 -0700 Subject: [PATCH] D3D12: Fixed initial state for MSAA render target. --- src/nvapi.cpp | 10 +++++++++- src/renderer_d3d12.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/nvapi.cpp b/src/nvapi.cpp index b26287b92..63a1f5cd3 100644 --- a/src/nvapi.cpp +++ b/src/nvapi.cpp @@ -252,13 +252,21 @@ namespace bgfx if (1 == result) { result = nvAftermathDx12CreateContextHandle(_commandList, &m_aftermathHandle); - BX_WARN(1 == result, "%x", result); + BX_WARN(1 == result, "NV Aftermath: nvAftermathDx12CreateContextHandle failed %x", result); if (1 == result) { return true; } } + else + { + switch (result) + { + case int32_t(0xbad0000a): BX_TRACE("NV Aftermath: Debug layer not compatible with Aftermath."); break; + default: BX_TRACE("NV Aftermath: Failed to initialize."); break; + } + } } shutdownAftermath(); diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index fc1622afa..02f731bfc 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -892,6 +892,31 @@ namespace bgfx { namespace d3d12 m_textVideoMem.resize(false, _init.resolution.width, _init.resolution.height); m_textVideoMem.clear(); } + + if (1 < m_scd.sampleDesc.Count) + { + D3D12_RESOURCE_DESC resourceDesc; + resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + resourceDesc.Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT; + resourceDesc.Width = m_scd.width; + resourceDesc.Height = m_scd.height; + resourceDesc.MipLevels = 1; + resourceDesc.Format = m_scd.format; + resourceDesc.SampleDesc = m_scd.sampleDesc; + resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; + resourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + resourceDesc.DepthOrArraySize = 1; + + D3D12_CLEAR_VALUE clearValue; + clearValue.Format = resourceDesc.Format; + clearValue.Color[0] = 0.0f; + clearValue.Color[1] = 0.0f; + clearValue.Color[2] = 0.0f; + clearValue.Color[3] = 0.0f; + + m_msaaRt = createCommittedResource(m_device, HeapProperty::Texture, &resourceDesc, &clearValue, true); + setDebugObjectName(m_msaaRt, "MSAA Backbuffer"); + } } m_presentElapsed = 0;