From 76c8fed7980242562b8e3cc065ce68a89ab665fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B3zef=20Kucia?= Date: Tue, 24 Oct 2017 12:38:29 +0200 Subject: [PATCH] core: Do not set D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS for unsupported formats. This is required because we have changed the swapchain format in 58da0077c9d848e5854d1337b4e4ef4e10172c06. --- Core/ColorBuffer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Core/ColorBuffer.cpp b/Core/ColorBuffer.cpp index 5aaf701..eddd2a8 100644 --- a/Core/ColorBuffer.cpp +++ b/Core/ColorBuffer.cpp @@ -111,11 +111,24 @@ void ColorBuffer::CreateFromSwapChain( const std::wstring& Name, ID3D12Resource* Graphics::g_Device->CreateRenderTargetView(m_pResource.Get(), nullptr, m_RTVHandle); } +static bool is_uav_supported(ID3D12Device *device, DXGI_FORMAT format) +{ + D3D12_FEATURE_DATA_FORMAT_SUPPORT data; + data.Format = format; + if (FAILED((device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &data, sizeof(data))))) + return false; + return data.Support1 & D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW; +} + void ColorBuffer::Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips, DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMem) { NumMips = (NumMips == 0 ? ComputeNumMips(Width, Height) : NumMips); D3D12_RESOURCE_FLAGS Flags = CombineResourceFlags(); + + if ((Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) && !is_uav_supported(Graphics::g_Device, Format)) + Flags &= ~D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D(Width, Height, 1, NumMips, Format, Flags); ResourceDesc.SampleDesc.Count = m_FragmentCount; -- 2.11.4.GIT