Repository navigation
vk: vkCmdBlitImage and the device procs SDL_GPU resolves (MARVEL Cosmic Invasion) - #2598
Open
bensaadmucret wants to merge 1 commit into
Open
bensaadmucret wants to merge 1 commit into
bensaadmucret wants to merge 1 commit into
Conversation
…ic Invasion) SDL_GPU resolves every Vulkan entry point through vkGetDeviceProcAddr and calls some of them unchecked: lookups the host did not implement returned null and the game crashed on a blr to 0 right after 'Setting backbuffer'. The lookup now finds the calls SDL_GPU uses: vkCmdSetBlendConstants, vkCmdSetDepthBias, vkCmdSetDepthBounds, vkCmdClearAttachments, vkCmdResolveImage, vkCmdDispatch, vkCmdDispatchIndirect, vkCmdDrawIndirect, vkCmdDrawIndexedIndirect, vkCreateComputePipelines and the VK_EXT_debug_utils entry points — no-ops that keep the call landing somewhere real until each gets its Metal implementation. vkCmdBlitImage is real: an unscaled same-format region goes through the blit encoder like vkCmdCopyImage, and what a copy cannot do — a blit between different formats, scaled or flipped — is drawn with the draw_tex builtin, which samples the source through a fullscreen triangle whose linear mapping takes a flip into account on its own. This was the black screen: SDL_GPU renders its frame to an R8G8B8A8 texture and blits it into the B8G8R8A8 swapchain image, which no Metal copy can do. Checked: dmhost builds; MARVEL Cosmic Invasion plays its intro video in a window at 60 FPS with audio (was a black screen before).
bensaadmucret
force-pushed
the
pr-vk-blit-swapchain
branch
from
November 14, 2026 13:59
94f3b2c to
a01bccf
Compare
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.
What and why
SDL_GPU resolves every Vulkan entry point through
vkGetInstanceProcAddr/vkGetDeviceProcAddrand calls some of them unchecked: lookups the layer did not implement returned null, and the game crashed on ablrto 0 right after "Setting backbuffer" (FNA's SDL_GPU backend, MARVEL Cosmic Invasion010059D020C26000v0, buildD6A37DEAFF3F5AEA).Two parts:
vkCmdSetBlendConstants,vkCmdSetDepthBias,vkCmdSetDepthBounds,vkCmdClearAttachments,vkCmdResolveImage,vkCmdDispatch,vkCmdDispatchIndirect,vkCmdDrawIndirect,vkCmdDrawIndexedIndirect,vkCreateComputePipelinesand theVK_EXT_debug_utilslabel calls are listed so the lookup answers something real — no-ops, logged, until each gets its Metal implementation (the unimplemented ones already warn, e.g.dynamic state 4 not implemented).vkCmdBlitImageis real (C_BLIT). An unscaled same-format region replays through the blit encoder, asvkCmdCopyImagedoes; what a copy cannot do — a blit between different formats, scaled or flipped — is drawn with thedraw_texbuiltin: a fullscreen triangle samples the source, and the linear mapping carries a flip on its own. This was the black window: SDL_GPU renders its frame into anR8G8B8A8_UNORMimage and blits it into theB8G8R8A8_UNORMswap chain image, which no Metal texture copy can do. A blit inside a render pass splits the encoder and the pass resumes, as copies do; the occlusion slot counting includesC_BLIT.Adds the findings to docs/reference/rendering.md (Vulkan layer: device procs a Vulkan library calls without checking;
vkCmdBlitImageto the swap chain).Checked
python3 -m unittest dm.tools.tests.test_docs(6 tests);make -C dm/host GAME=010099C022B96000builds clean on this base010059D020C26000v0: before, the run reached 60 fps with real draws but the window stayed black; after, the intro video plays at 60 fps with audio (~870 draws/frame, presents at every display-link tick)regress.py check --gameswas not run:regress.py impactreachesapi:vulkanfor the change, but every added path was unreachable before — a game that had calledvkCmdBlitImageor one of these procs would have crashed on the null lookup, so no profiled game's behavior changes. Open:vkCmdSetBlendConstantsstill warns as unimplemented; the render-encoder split for mid-pass blits is exercised only by the game this was found on.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change