Repository navigation
DXGI swapchain: Present checks its arguments, ResizeBuffers refuses held buffers, 0 means the client area - #1128
Merged
Conversation
…eld buffers, 0 means the client area Measured on the host DXGI (RTX 5070 and WARP): Present(n > 4) is DXGI_ERROR_INVALID_CALL and DXGI_PRESENT_TEST doesn't present; ResizeBuffers while the app holds a back buffer is DXGI_ERROR_INVALID_CALL and keeps the size; a zero width or height at creation or in ResizeBuffers takes the window's client area. The shim presented on TEST, destroyed held buffers, and used 256x256 / the old size.
Contributor
|
Tested a8b83d8 on NVIDIA GeForce RTX 5070, driver 621.24 (32.0.16.2124), Windows 11 26H2 (26300), MSVC 14.52 (VS Build Tools 18), RelWithDebInfo + Ninja: pass.
|
Contributor
|
Tested a8b83d8 on NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 Home 25H2 (26200.9974), VS 2022 Build Tools, Vulkan SDK 1.4.363.1: pass.
AI-assisted. No game files. |
Contributor
|
Tested a8b83d8: pass on both GPUs. Windows 11 26200, MSVC 19.44, Vulkan SDK 1.4.363,
No game files. AI-assisted (Claude Code). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three places where
runtime/shims/dxgi_com.cppdiffers from DXGI on the host, all measured with a probe on Windows 11 (RTX 5070 and WARP give the same answers). They also match Microsoft's docs.Presentignored its arguments.DXGI_PRESENT_TESTpresented a frame and advanced the back buffer, and a sync interval above 4 was accepted. Nowsync > 4isDXGI_ERROR_INVALID_CALLandDXGI_PRESENT_TESTreturnsS_OKwithout presenting.Present1forwards here, so it gets both.ResizeBufferswhile the app holds a back buffer removed it from the VulkanContext and destroyed its image. DXGI refuses withDXGI_ERROR_INVALID_CALLand keeps the old size.BackBufferResource::held_by_app()(refs_ > 1) makes that check. Nothing inside the shim AddRefs a back buffer: the presenter and replay only hold itsresource_id. So the check refuses only real app references.ResizeBuffers(the usualResizeBuffers(0, 0, 0, ...)afterWM_SIZE). If either is 0, both come fromGetClientRect, as on the host. The shim used 256x256 at creation and kept the old size on resize. When the client area is also 0, it falls back to those old values.mainPresent(0, DXGI_PRESENT_TEST):S_OK, back buffer index stays 0S_OK, index stays 0Present(5, 0):DXGI_ERROR_INVALID_CALLS_OKDXGI_ERROR_INVALID_CALLResizeBufferswithGetBuffer(0)held:DXGI_ERROR_INVALID_CALL, old sizeS_OK, image destroyedDXGI_ERROR_INVALID_CALL, old sizeResizeBuffers(0, 0)and(0, 100)on a 400x300 client: 400x300Test:
runtime/test/dxgi_swapchain_test.cppgets checks for all of these. Withmain'sdxgi_com.cppit exits 1 at the first one (FAIL: Present(0, DXGI_PRESENT_TEST) presented a frame). With this change:PASS (...; 0 validation errors). Fullcteston Windows 11, RTX 5070 (621.24), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, withLEONIDA_VK_VALIDATION=1andLEONIDA_D3D12=vulkan: 54/54. Only the knownVUID-...-01387that #1027 fixes shows up. Not changed here: hostGetBufferpast the last buffer andResizeBuffers(R32_UINT)return different codes from the shim (DXGI_ERROR_INVALID_CALLvsE_INVALIDARG,E_INVALIDARGvsDXGI_ERROR_UNSUPPORTED); the existing test asserts the latter. #1038 adds a block to the same test, and I'll rebase on whichever lands first.AI-assisted.