diff options
| author | Ewann <207907827+dev-ewann@users.noreply.github.com> | 2026-11-22 22:37:10 +0100 |
|---|---|---|
| committer | Ewann <207907827+dev-ewann@users.noreply.github.com> | 2026-11-22 22:37:10 +0100 |
| commit | dac96d2d65b49f4b707e89511f6980ce3097b433 (patch) | |
| tree | af23563cdf78c495cdb7e6a3d60085595d52fee0 /runtime/shims/dxgi_com.cpp | |
| parent | e62744353bb61eefa06c14322fbdc965754ebe67 (diff) | |
DXGI: CreateSwapChainForHwnd checks MSAA, buffer count and format before the size, like the host
A description with width 16385 and MSAA 4, one buffer or a bad format is
DXGI_ERROR_INVALID_CALL on the host runtime's DXGI, not E_INVALIDARG
(found by Kam471 in the review of #3531). Five multi-fault cases added
to the side-by-side comparison.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/dxgi_com.cpp')
| -rw-r--r-- | runtime/shims/dxgi_com.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp index 42558e621..e4d6f6b93 100644 --- a/runtime/shims/dxgi_com.cpp +++ b/runtime/shims/dxgi_com.cpp | |||
| @@ -845,8 +845,9 @@ public: | |||
| 845 | // RTX 5070 / 621.14): a null queue, window, description or output, an ID3D12Device in place of the queue, the | 845 | // RTX 5070 / 621.14): a null queue, window, description or output, an ID3D12Device in place of the queue, the |
| 846 | // bitblt effects, a scaling or alpha mode a window can't present, a flag outside the ones a D3D12 window swap chain | 846 | // bitblt effects, a scaling or alpha mode a window can't present, a flag outside the ones a D3D12 window swap chain |
| 847 | // takes (MODE_SWITCH, DISPLAY_ONLY, FRAME_LATENCY_WAITABLE_OBJECT, ALLOW_TEARING, the holographic restriction and | 847 | // takes (MODE_SWITCH, DISPLAY_ONLY, FRAME_LATENCY_WAITABLE_OBJECT, ALLOW_TEARING, the holographic restriction and |
| 848 | // 0x2000), and a shared, read-only, discard-on-present or unordered-access buffer usage are | 848 | // 0x2000), a shared, read-only, discard-on-present or unordered-access buffer usage, MSAA, a buffer count outside |
| 849 | // DXGI_ERROR_INVALID_CALL; a side above 16384 is E_INVALIDARG. | 849 | // 2..16 and a format the swap chain can't take are DXGI_ERROR_INVALID_CALL; a side above 16384 is E_INVALIDARG, |
| 850 | // only when nothing else is wrong. | ||
| 850 | static HRESULT check_hwnd_swap_chain(IUnknown* device, HWND hwnd, const DXGI_SWAP_CHAIN_DESC1* desc, | 851 | static HRESULT check_hwnd_swap_chain(IUnknown* device, HWND hwnd, const DXGI_SWAP_CHAIN_DESC1* desc, |
| 851 | IDXGISwapChain1** out) { | 852 | IDXGISwapChain1** out) { |
| 852 | if (!device || !hwnd || !desc || !out) return DXGI_ERROR_INVALID_CALL; | 853 | if (!device || !hwnd || !desc || !out) return DXGI_ERROR_INVALID_CALL; |
| @@ -865,6 +866,10 @@ public: | |||
| 865 | constexpr DXGI_USAGE kRefusedUsage = | 866 | constexpr DXGI_USAGE kRefusedUsage = |
| 866 | DXGI_USAGE_SHARED | DXGI_USAGE_READ_ONLY | DXGI_USAGE_DISCARD_ON_PRESENT | DXGI_USAGE_UNORDERED_ACCESS; | 867 | DXGI_USAGE_SHARED | DXGI_USAGE_READ_ONLY | DXGI_USAGE_DISCARD_ON_PRESENT | DXGI_USAGE_UNORDERED_ACCESS; |
| 867 | if (desc->BufferUsage & kRefusedUsage) return DXGI_ERROR_INVALID_CALL; | 868 | if (desc->BufferUsage & kRefusedUsage) return DXGI_ERROR_INVALID_CALL; |
| 869 | // The host checks these before the size: MSAA 4 or one buffer at width 16385 is still INVALID_CALL. | ||
| 870 | if (desc->SampleDesc.Count != 1 || desc->SampleDesc.Quality != 0) return DXGI_ERROR_INVALID_CALL; | ||
| 871 | if (!valid_flip_buffer_count(desc->BufferCount)) return DXGI_ERROR_INVALID_CALL; | ||
| 872 | if (dxgi_to_vk_format(desc->Format) == VK_FORMAT_UNDEFINED) return DXGI_ERROR_INVALID_CALL; | ||
| 868 | if (desc->Width > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION || desc->Height > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION) | 873 | if (desc->Width > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION || desc->Height > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION) |
| 869 | return E_INVALIDARG; | 874 | return E_INVALIDARG; |
| 870 | return S_OK; | 875 | return S_OK; |