fix(gpu): declare dual-source blending to the Metal converter #239
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!239
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-239"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ShadyUnderLight on GitHub · 2026-11-27 03:09 UTC · original
ShadyUnderLight:fix/blend-targets→main· +180 −23 · 9 files · 2 commits · merged 2026-11-27 03:29 UTCWhat this changes
Two pixel pipelines at the first world frame were refused by Metal Shader Converter on every run:
Both pipelines blend with the pixel shader's second output (
SRC1_*factors inCB_BLEND), so the shader writes twoSV_Targets for a singleRgba16Floatattachment. Metal spells that as[[color(0) index(1)]], and the converter only emits it whenIRCompilerSetDualSourceBlendingConfigurationenables dual-source blending for that shader. Without it the pipeline is refused and every draw that uses it is dropped, so those surfaces never appear.state::pixel_targetsreads theSV_Targetindices and write masks from the pixel shader'sOSG1part.state::dual_sourcedecides per pipeline: one more shader output than colour targets, indices0..nin order, and target 0's blend reading the second source.RenderPipelineDesc::dual_sourcecarries that tomsc::convert_with, which sets the converter option before compiling. The option is looked up withdlsym; a converter without it keeps its previous behaviour.docs/native-host.mdrecords the rule next to the blend-register notes.The branch carries one tooling commit as well, kept separate:
tools/macos/run-summary.shstripped colours withs/\x1b\[...m//g, which BSD sed reads as a literalx1b, so no timestamp ever matched and every summary printedlines 0 / last frame 0. The escape is built withprintfnow, and the self-test's synthetic log carries colours, so it fails without the strip.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory— 369 passed, 0 failedcargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings— cleanrun-native.sh --headless --seconds 170), same build, before and afterBefore: two pipelines refused per run (
vertex 55ccb5c3c932717d+pixel c2979cccbbac7e8c,vertex 62148192acfb1bb1+pixel aa9cb047b21b22b1), both guessed ascolor: [Rgba16Float],depth: D32FloatS8.After: no refusals of that kind in the whole run, and the first pipeline builds. The second now stops at a different, pre-existing check —
Fragment input(s) 'user(half10)' mismatching vertex shader output type(s) or not written by vertex shader— which it could not reach while the pipeline was refused. That is a mismatch between the vertex output and pixel input signatures and is not addressed here.Unit tests cover the decision matrix and each of the four factors on its own.
run-summary.sh --self-testpasses, and a real log now summarises tolines 2110, log span 111.0s, last frame 2116instead of zeros.Checklist
VICTORY_*variable and documented — none addedA target whose blend names SRC1_* or INV_SRC1_* factors takes two of the pixel shader's outputs into one target, so the shader writes one output more than the pipeline has targets. Metal spells that [[color(0) index(1)]], which its converter only emits when IRCompilerSetDualSourceBlendingConfiguration enables it. Without it Metal refuses the pipeline ("Fragment shader does not write to render target color(0), index(1) that is required for blending") and drops every draw with it: two pipelines at the world frame in every run, whose pixel shaders write targets 0 and 1 into one Rgba16Float target. Which pipelines are dual-source is decided per pipeline (state::dual_source: one more shader output than targets, in order, and target 0's blend reads it), and the conversion cache keeps an entry of its own for that case, so conversions of every other shader stay warm.@LakshanSivakumar on GitHub · 2026-11-27 03:29 UTC · original · approved these changes
Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!