From b0aa4ed434d9cbcb8b4bf1fce96e48914603d186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 17 Jan 2018 12:48:08 +0100 Subject: [PATCH] libs/vkd3d: Add simple format support restrictions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the long term, we may need more complex format support filtering. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/device.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 5cf2ecfe..d84c5796 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1230,6 +1230,30 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommandList(ID3D12Device *if &IID_ID3D12GraphicsCommandList, riid, command_list); } +/* Direct3D feature levels restrict which formats can be optionally supported. */ +static void vkd3d_restrict_format_support_for_feature_level( + D3D12_FEATURE_DATA_FORMAT_SUPPORT *format_support, const struct vkd3d_format *format) +{ + static const D3D12_FEATURE_DATA_FORMAT_SUPPORT blacklisted_format_features[] = + { + {DXGI_FORMAT_B8G8R8A8_TYPELESS, D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD | D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE}, + {DXGI_FORMAT_B8G8R8A8_UNORM, D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD | D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE}, + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(blacklisted_format_features); ++i) + { + if (blacklisted_format_features[i].Format == format->dxgi_format) + { + format_support->Support1 &= ~blacklisted_format_features[i].Support1; + format_support->Support2 &= ~blacklisted_format_features[i].Support2; + break; + } + } +} + static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device *iface, D3D12_FEATURE feature, void *feature_data, UINT feature_data_size) { @@ -1378,6 +1402,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CheckFeatureSupport(ID3D12Device * | D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX | D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX; + vkd3d_restrict_format_support_for_feature_level(data, format); + return S_OK; }