diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-12 13:34:09 +0100 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-12 13:34:09 +0100 |
| commit | b8b0eea1f828bc82f73d9977a4b6e0ca1ea76bf3 (patch) | |
| tree | e334b8e25b4d7c378a5bfbf1920ed5c7aa96b441 | |
| parent | 687f840354a82dd23d55e12cec5a49ffe1aa3290 (diff) | |
| parent | 6807cd86738022a5b30a41927126d7adfabc4041 (diff) | |
| download | redot-engine-b8b0eea1f828bc82f73d9977a4b6e0ca1ea76bf3.tar.gz | |
Merge pull request #87570 from RandomShaper/d3d12_defensive
Direct3D 12: Make format feature check more defensive
| -rw-r--r-- | drivers/d3d12/rendering_device_driver_d3d12.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index f1900023aa..23b697c8ed 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -1579,15 +1579,19 @@ void RenderingDeviceDriverD3D12::texture_unmap(TextureID p_texture) { BitField<RDD::TextureUsageBits> RenderingDeviceDriverD3D12::texture_get_usages_supported_by_format(DataFormat p_format, bool p_cpu_readable) { D3D12_FEATURE_DATA_FORMAT_SUPPORT srv_rtv_support = {}; srv_rtv_support.Format = RD_TO_D3D12_FORMAT[p_format].general_format; - HRESULT res = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &srv_rtv_support, sizeof(srv_rtv_support)); - ERR_FAIL_COND_V_MSG(!SUCCEEDED(res), false, "CheckFeatureSupport failed with error " + vformat("0x%08ux", (uint64_t)res) + "."); + if (srv_rtv_support.Format != DXGI_FORMAT_UNKNOWN) { // Some implementations (i.e., vkd3d-proton) error out instead of returning empty. + HRESULT res = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &srv_rtv_support, sizeof(srv_rtv_support)); + ERR_FAIL_COND_V_MSG(!SUCCEEDED(res), false, "CheckFeatureSupport failed with error " + vformat("0x%08ux", (uint64_t)res) + "."); + } D3D12_FEATURE_DATA_FORMAT_SUPPORT &uav_support = srv_rtv_support; // Fine for now. D3D12_FEATURE_DATA_FORMAT_SUPPORT dsv_support = {}; dsv_support.Format = RD_TO_D3D12_FORMAT[p_format].dsv_format; - res = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dsv_support, sizeof(dsv_support)); - ERR_FAIL_COND_V_MSG(!SUCCEEDED(res), false, "CheckFeatureSupport failed with error " + vformat("0x%08ux", (uint64_t)res) + "."); + if (dsv_support.Format != DXGI_FORMAT_UNKNOWN) { // See above. + HRESULT res = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dsv_support, sizeof(dsv_support)); + ERR_FAIL_COND_V_MSG(!SUCCEEDED(res), false, "CheckFeatureSupport failed with error " + vformat("0x%08ux", (uint64_t)res) + "."); + } // Everything supported by default makes an all-or-nothing check easier for the caller. BitField<RDD::TextureUsageBits> supported = INT64_MAX; |
