Repository navigation
vk: blend constants as dynamic command-buffer state (MARVEL Cosmic Invasion) - #2667
Open
bensaadmucret wants to merge 2 commits into
Open
bensaadmucret wants to merge 2 commits into
bensaadmucret wants to merge 2 commits into
Conversation
This was referenced Nov 14, 2026
…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).
…vasion) Symptom: sprites drawn with CONSTANT_COLOR/CONSTANT_ALPHA blend factors were invisible (the player's characters and enemies in MARVEL's stages); the run log showed "[RED] dynamic state 4 not implemented". Cause: VK_DYNAMIC_STATE_BLEND_CONSTANTS makes the blend colour a command-buffer value set by vkCmdSetBlendConstants, which the layer listed as a no-op; the encoder kept its zero default, so the factor multiplied the source to nothing. Fix: the command is recorded (C_BLEND) and replayed into the encoder's blend colour; a pipeline declaring the dynamic state takes the command buffer's value, others keep their own. Checked: MARVEL's sprites draw; the log has no [RED] left. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
bensaadmucret
force-pushed
the
pr-vk-blend-constants
branch
from
November 14, 2026 13:59
1275166 to
9040620
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
vkCmdSetBlendConstantsrecorded into the command buffer (C_BLEND) and replayed into the Metal encoder's blend colour.VK_DYNAMIC_STATE_BLEND_CONSTANTSon a pipeline marks it to take the command buffer's value; other pipelines keep their staticblendConstantsfield, as the Vulkan model wants.Why
MARVEL Cosmic Invasion (FNA/SDL_GPU, title
010059D020C26000) draws its player character sprites through a blend factor that reads the constant colour; the run log showed[RED] dynamic state 4 not implementedand the sprites blended to nothing — a shadow and the enemies (straight alpha blending) drew fine. After the fix the sprites draw and the log has no[RED]left.Depends on
pr-vk-blit-swapchain): this branch is stacked on it — the diff is the top commit only.Checked
make -C dm/host GAME=010059D020C26000 dmhostclean on Apple M6, macOS 26.6 (windowed run through the app's bundled dmhost).[RED]in the run log.docs/reference/rendering.md(docs_symptoms.pyregenerated;test_docs.py6/6).Not checked
vkCmdSetBlendConstantslocally; static-blend pipelines are unaffected (p->blendis still what the create info held).