Repository navigation
dxgi_swapchain: retired swapchain, stale buffer count, unsupported surface, blit filter and composite alpha (RT-SWAPCHAIN-MOCK-FINDINGS) - #2493
Open
Tyrannys wants to merge 1 commit into
Conversation
…rface, blit filter and composite alpha Four VulkanSwapchain bugs from a mock-driver review (kevincommits, ubiquitarianism#1608): - A failed vkCreateSwapchainKHR still retires its oldSwapchain (VUID-VkSwapchainCreateInfoKHR-oldSwapchain-01933). The retired swapchain was kept, acquired from, and passed as oldSwapchain again. It is now destroyed with its buffers, as the host's swap chain has no buffers after a failed ResizeBuffers. - When the off-screen back buffers could not be made, exposed_count_ kept the old BufferCount while there was no ring, so image() and resource_binding() indexed the native images out of bounds. Nothing is exposed until the new buffers exist. ResizeBuffers with count 0 still keeps the last built BufferCount. - A surface the queue family cannot present to was kept, and the next create() skipped the support check. It is destroyed. - The present blit always used VK_FILTER_LINEAR. It is NEAREST for a 1:1 blit, and LINEAR only when the format allows linear filtering (VUID-vkCmdBlitImage-filter-02001). The composite alpha is the first one the surface offers, opaque first. dxgi_swapchain_count_test gains one case per finding, following the repros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Claimed in the coordination issue as: RT-SWAPCHAIN-MOCK-FINDINGS (#1608 (comment)). This is item 2 (a-d) of @kevincommits' finding (#1608 (comment)). Thanks for the mock-driver repros; the tests follow them.
Depends on: none. No other open PR touches
runtime/shims/dxgi_swapchain.h.What and why
VulkanSwapchain(runtime/shims/dxgi_swapchain.h, the DXGI shim's Vulkan swapchain):vkCreateSwapchainKHR.oldSwapchainis retired even when the call fails (VUID-VkSwapchainCreateInfoKHR-oldSwapchain-01933). The shim kept the handle inswapchain_, kept acquiring from it, and passed it asoldSwapchainagain on the next resize. It is now destroyed together with its buffers. This matches the host, where a failedResizeBuffersleaves the swap chain with no buffers (dxgi_swapchain_testalready compares that part with the host).destroy_offscreen()ran first. Whencreate_offscreen_backbuffers()then failed,exposed_count_still held the oldBufferCountbut there was no ring.image(i)andresource_binding(i)then indexed the native images out of bounds (4 exposed over 2 native images in the repro), andpresent()skipped the blit. Nothing is exposed now until the new buffers exist.ResizeBufferswith count 0 still keeps the swap chain's count: a newbuffer_count_holds the last count that was built, whereexposed_count_was used before.create()skipped the support check.VK_FILTER_LINEARunconditionally. It now uses NEAREST for a 1:1 blit. A scaling blit uses LINEAR only when the format hasSAMPLED_IMAGE_FILTER_LINEARwith optimal tiling (VUID-vkCmdBlitImage-filter-02001), asvulkan_present.halready does.vkGetPhysicalDeviceFormatPropertiesis loaded as an optional function; without it the blit is NEAREST.compositeAlphais now the first mode the surface offers, opaque first, instead of alwaysOPAQUE.Tested
dxgi_swapchain_count_test(mock driver, no GPU) gains one case per finding:oldSwapchain, and a later resize recovers and presents.image(i)/resource_binding(i)for 0..3, and a refused present. A later resize recovers.create()checks support again.INHERIToffered, and with opaque and inherit both offered.Each case runs even when an earlier one fails. On
main(43a9d562d, header reverted), all four fail:With the change, the test passes, including the existing failed-resize cases.
ctest -R "dxgi|swapchain|present": 16/17 pass, includingdxgi_swapchain,dxgi_host_parity,dxgi_host_answers,dxgi_waitable_latencyandd3d12_present. The failure isxbox_present, which also fails onmainon this machine.No game files.
GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)🤖 Generated with Claude Code