victory-shader: split and unify return blocks so dxil-spirv's structuriser keeps a terminator #3954
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3954
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3954"
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?
@HyperRamzey on GitHub · 2026-11-30 12:58 UTC · original
HyperRamzey:fix/dxil-loop-merge-ret→main· +795 −26 · 2 files · 2 commits · draftBases
494a9df3) on upstreammain, merged withmainat5fabb46e(eaec1641); nothing from the PRs below is part of it.-HV 2018), fixing the ambientraisebuild, #2769), #4041 (GPU sweep / kept-bitmap fixes), #4338 and #4339 (hardware-ray-tracing fixes), #4203 (card-time profiler in release builds), and a localquiet_raw_chainschange (VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chainsunder Wine, for the driver's raw-access crash; no PR yet). #2449 and #3417 are both open and taken together there.Fixes
libnvidia-gpucomp.soduringvkCreateComputePipelineson compute shader4e296b1885c37b29: translation rc 0 /spirv-valrc 0 after this change (was SIGSEGV 139).a1d865bdfb3559eb0xC0000005 crash found on this rig (driver segfault invkCreateComputePipelines): the title now creates that host pipeline in game and its saved DXIL validates (oracle rc 0,spirv-valrc 0).What this fixes
Two invalid-SPIR-V shapes our emitter produced that dxil-spirv's structuriser (pin
8434b06, in vkd3d-proton through 3.1.0) turned into a driver crash:ret void. The structuriser takes that block as the loop's merge and drops the return, leaving a block that ends inOpFunctionEndwith noOpReturn.find_selection_mergescan promote a selection to a fake loop whose common post-dominator is the function-exit sentinel, andtraversenever emits EXIT, soOpLoopMerge %EXITappears twice over one block with no terminator ("already a merge block for another header").Module::writenow serialisesunify_returns(split_returns(blocks)): split first, so a shared empty return gets one pure return per predecessor (a returning block with body or phis keeps the plain split; the entry block is never dropped), then unify every return onto one appended block, so the merge candidate the structuriser picks is a real block every path reaches. Functions with no return or one return are unchanged.Evidence
spirv-val4e296b1885c37b29(#2648)spirv-valrc 0a1d865bdfb3559eb(this rig)victory-shadertests (merged withmain5fabb46e)Both invariants were sabotage-verified: disabling
unify_returnsturns 5 tests red; disabling the shared-return branch ofsplit_returnsturns 2 red.In game
Proton-CachyOS under Wayland, RTX 5070 (driver 620.73.04), vkd3d-proton built from master (rewritten structuriser; the custom DLL embeds the later split
cfg_structurizer_*.cpprefactor): the title boots past the account picker, plays the intro cutscene, and renders its frames. DLSS Super Resolution, DLSS Frame Generation (2×) and Reflex all load and report on (Reflex low latency … on=true code=0). The previously fatal containers (42683eebec081520,54bcc8478432ba15,d3e5b737ea7cc150) create their host pipelines without a crash.Milestones (draft; updated as they land)
main5fabb46e— the only conflict wasemit/bitcode.rs;victory-shader345 tests greenvkd3d-1.1-5783rewritten,vkd3d-1.1-5742compiles both,vkd3d-1.1-5656oldNot in this PR
The other crash-class reproducers found this session (
42683eebec081520,54bcc8478432ba15,d3e5b737ea7cc150) fail inside dxil-spirv's own structuriser regardless of input DXIL shape; they are fixed by its rewrite (dxil-spirva7676a1f;vkd3d-1.1-5742-g2576c0b4is the first build we can show carrying it, and it selects the rewrite by default, with the legacy path behind a flag that defaults off, whilevkd3d-1.1-5656-g0bb64c5has the old one only). Eliminating those shapes at the emitter is the stock-Proton follow-up.Measured offline against pin
8434b06,spirv-valas the oracle:place_phi_readbuilds the frontier phi fromfrontier->predonly; theassert(!frontier->pred_back_edge)above it is compiled out in release builds. A collector block that later becomes a loop header never receives its back-edge incoming:42683eebec081520emits%frontier_phi_6_collector = OpPhi %uint …with three incoming values for four predecessors, andspirv-valrejects it.OpLoopMergeimmediately precedesOpSwitch, which SPIR-V forbids.collect_and_dispatch_control_flownames the multi-way dispatcher (common_idom->name + ".collector") and assigns it as the loop merge block.OpPhion42683eebec081520and54bcc8478432ba15, a hang ond3e5b737ea7cc150. A split-only shape (per-edge returns, no unify) turns42683eebec081520andd3e5b737ea7cc150into invalid unstructured loop exits. The phi-patched structuriser then fails42683eebec081520and54bcc8478432ba15onOpLoopMerge.Which shipped binaries carry the rewrite (strings and PE headers of their
d3d12core.dll):vkd3d-1.1-5783-g71cae09vkd3d-1.1-5742-g2576c0b4vkd3d-1.1-5656-g0bb64c5The nightly's
vkd3d-low-latencyDLL is still the old structuriser despite the same PE timestamp.Measured corpus-wide through the old pin (2,943 containers from this rig,
spirv-valas the oracle, mesh validated atvulkan1.2whereSPV_EXT_mesh_shaderis legal): 2,501 valid, 442 genuine failures — 150 invalid SPIR-V (120 unstructured loop exits, 18OpPhipredecessor counts, 6 already-a-merge-block, 3OpSwitchwithoutOpSelectionMerge, 3OpLoopMergeplacement), 266 SIGSEGV, 24 hangs, 2 no output. That is the surface an emitter-side follow-up faces.@VibeCodeGuy on GitHub · 2026-12-01 00:01 UTC · original
Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs), this PR at
494a9df3against its merge-base withmain,41adb551(it does not merge cleanly ontomaine1251c31).maintoo (oversized mesh outputs).The 25698 changed programs by family
MS_VS_Transform_PositionOnlyPS_LinearDepthPS_DeferredTexturedMS_VS_TransformPS_MirrorReflectionDeferredTexturedPS_CascadeShadows_fadeMSNC_VS_TransformSkin_PositionOnlyPS_MirrorReflectionTextured_EightPS_Textured_EightPS_VfxVBuffer_AlphaClipPS_LinearDepthOpaquePS_DeferredTextured_AlphaClipPS_MirrorReflectionDeferredTextured_AlphaClipPS_VfxVBufferPS_VoxelizeVisiblityPS_PuddleDetect_ZeroMSNC_VS_TransformSkinPS_AlphaPrepassPS_EntityMaskMS_VS_MirrorReflectionTransformMS_VS_CascadeShadows_drawMS_VS_CascadeShadows_drawTextureMS_VS_TransformDPS_CascadeShadows_texturePS_MirrorReflectionDeferredDecalTexturedMS_VS_LinearDepthMSNC_VS_MirrorReflectionTransformSkinMS_VS_MirrorReflectionTransformDPS_AlphaTransmissionVS_Transform_VfxVBuffer_AlphaClipMS_VS_TransformEntityMaskVS_Transform_VfxVBufferVS_TransformSkin_VfxVBuffer_AlphaClipVS_TransformSkin_VfxVBufferVS_VoxelizeGenericMSNC_VS_TransformSkinDMS_VS_TransformTransmissionMSNC_VS_LinearDepthSkinMSNC_VS_MirrorReflectionTransformSkinDMS_VS_TransformAlphaPrepassMSNC_VS_TransformSkinEntityMaskMSNC_VS_CascadeShadows_drawskinnedTextureMSNC_VS_CascadeShadows_drawskinnedMSNC_VS_TransformSkinTransmissionMSNC_VS_TransformSkin_AlphaPrepassMS_VS_MirrorReflectionTransformDecalsDMSNC_VS_MirrorReflectionTransformSkinDecalsDPS_MirrorPedTextured_EightPS_PedAlphaPrepassPS_PedTextured_Eight_AlphaPS_StudioPedTextured_EightPS_TexturedDeferredPS_PedAlphaPrepass_DecalsPS_PedTextured_Eight_DecalsMS_VS_TransformLitMSNC_VS_PedTransformSkinAlphaPS_TrailmapDeformDataMS_VS_TrailmapDeformDataMS_VS_TransformSkin_PositionOnlyPS_PedAlphaTransmissionPS_PedAlphaTransmission_DecalsMS_VS_PedTransformAlphaPS_PuddleDetectPS_MirrorReflectionTexturedDeferredPS_CascadeShadows_texture_alphaPS_TexturedLit_8MSNC_VS_TrailmapDeformDataSkinnedPS_DeferredPedTexturedNCPS_MirrorReflectionDeferredPedTexturedNCPS_DeferredPedDecalTexturedPS_DeferredTextured_AlphaClipNCPS_MirrorReflectionDeferredTextured_AlphaClipNCMS_VS_CascadeShadows_PedTransformPreSkinDPS_TexturedLitMSR_VS_TransformSkin_PositionOnlyMSNC_VS_PedTransformSkinD_PositionOnlyPS_AlphaPrepass_FireMSNC_VS_PedTransformSkinEntityMaskDMS_VS_PedTransformD_PositionOnlyPS_Textured_Eight_FireMSNC_VS_MirrorReflectionPedTransformSkinMSNC_VS_PedTransformSkinTransmissionAlphaMSNC_VS_PedTransformSkin_DecalsPS_AlphaTransmission_FireMSNC_VS_PedTransformSkinAlpha_DecalsMSNC_VS_PedTransformSkinTransmission_DecalsMS_VS_PedTransformPreSkinD_PositionOnlyPS_PedEntityMaskMS_VS_PedTransformEntityMaskPS_MirrorReflectionTexturedDeferredAlphaClipNCPS_TexturedDeferredAlphaClipNCVS_PassthroughPS_PedEntityMaskDMS_VS_LinearDepthPreSkinPS_CascadeShadows_texture_fireMSNC_VS_MirrorReflectionPedTransformSkinDMSNC_VS_PedTransformSkinDPS_PedTexturedCutOutTint_ZeroPS_TrailMapPropDeepSurfaceFlatten_UAVMS_VS_MirrorReflectionPedTransformMS_VS_PedTransformTransmissionAlphaMS_VS_PedTransform_DecalsPS_LinearDepth_FireMSNC_VS_MirrorReflectionPedTransformSkinDecalsDMS_VS_MirrorReflectionPedTransformDMS_VS_PedTransformAlpha_DecalsMS_VS_PedTransformDMS_VS_PedTransformTransmissionAlpha_DecalsPS_TrailMapPropGrassFlatten_UAVMS_VS_MirrorReflectionPedTransformDecalsDPS_AlphaPrepassSpatterPS_AlphaTransmissionSpatterMS_VS_PedTransformPreSkinDPS_TwoLayerEntityMaskPS_AlphaPrepassSpatter_FirePS_AlphaTransmissionSpatter_FirePS_PropVehicleDeferredPS_VehicleLiveryOffComplexDirtOffDeferredPS_VehicleLiveryOffComplexDirtOffDetailMapsOffDeferredPS_VehicleLiveryOffDetailMapsOffComplexDirtOffStickersOffFlakesOffDeferredPS_VehicleLiveryOffDetailMapsOffDeferredPS_VehicleLiveryOffOnlyDeferredPS_VehicleLiveryOnDetailMapsOffDeferredPS_VehicleVariationDeferredVS_Blitptfx_PSptfx_PS_alphathreshold_mv_uvdistortptfx_PS_alphathreshold_mv_uvdistort_nolocallightsptfx_PS_nolocallightsMS_VS_TransformTransmissionFireMS_VS_Transform_FireMS_VS_Transform_Fire_AlphaPrepassMSNC_VS_BakeDecorationsMSR_VS_TransformSkinMS_VS_TransformSkinPS_DeferredPedTexturedNC_PackedPS_TexturedLit_ReflectionMapMSNC_VS_TransformSkinTransmissionFireMSNC_VS_TransformSkin_FireMSNC_VS_TransformSkin_Fire_AlphaPrepassPS_BakeDecorationsPS_DeferredPedTextured_AlphaClipNC_TintVS_TransformPreSkin_VfxVBufferMSR_VS_MirrorReflectionTransformSkinDMSR_VS_TransformSkinDMS_VS_MirrorReflectionTransformSkinDMS_VS_TransformSkinDMS_VS_TransformSpatterAlphaPrepassMS_VS_TransformTransmissionSpatterPS_DeferredPedTextured_AlphaClip_Decal_TintHow:
victory translate <dump> --validate --listbuilt for each side (release, cross-built with cargo-xwin, run under Wine),VICTORY_HOST_WAVE=32, plus the four shader-cache-key settingsplaystarts with (VICTORY_EARLY_DEPTH=1,VICTORY_NAN_SCRUB=1,VICTORY_BVH_MISS=1,VICTORY_SAMPLED_MARKS=1). Validator:dxil.dllfrom DXC v1.9.2609. "Changed" compares translate'semittedhash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. At the merge-base the same run has the same 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut inmesh_prologue) andCS_TraceShadowRays_FullAdaptive(#2993).@HyperRamzey on GitHub · 2026-12-01 06:50 UTC · original
Thanks for running this — it is the regression signal we wanted, and it lines up with our local runs.
On the 25,698 changed programs. That is expected:
Module::writenow serialisesunify_returns(split_returns(blocks)), so every function with more than one return has its return blocks restructured; only functions with no return or a single return are untouched. The number to read is the validity tally, not the hash churn: your run keeps the same 72 pre-existing failures (the 71 mesh programs over the 32 KiB output shortcut, plusCS_TraceShadowRays_FullAdaptive, #2993) and adds none.On the merge conflict. The branch is now merged with current
main(5fabb46e; mergeeaec1641). The only conflict wascrates/victory-shader/src/emit/bitcode.rs; the resolution keeps upstream'sPredecessorslatch-folding andselect_operandsalongside the split/unify work.cargo test -p victory-shader --lib: 345 passed, 0 failed, 2 ignored (Linux; Windows CI will confirm).mainhas moved on since your run — it is at5fabb46enow.The stock-Proton part got root-caused offline since your run. The old structuriser (pin
8434b06) fails our three remaining reproducers for two concrete reasons:place_phi_readbuilds the frontier phi fromfrontier->predonly; theassert(!frontier->pred_back_edge)above it is compiled out of release builds. A collector block that later becomes a loop header never receives its back-edge incoming, so42683eebec081520emits%frontier_phi_6_collector = OpPhi %uint …with three incoming values for four predecessors, andspirv-valrejects it.OpLoopMergeimmediately precedesOpSwitch.collect_and_dispatch_control_flownames the multi-way dispatcher (common_idom->name + ".collector") and assigns it as the loop merge block, so a switch dispatcher is emitted as a loop header.Return shapes do not rescue them under this pin. As this PR emits them: invalid
OpPhion42683eebec081520and54bcc8478432ba15, a hang ond3e5b737ea7cc150. A split-only shape (per-edge returns, no unify) turns42683eebec081520andd3e5b737ea7cc150into invalid unstructured loop exits. That is why these three stay out of scope here and point at the rewrite.Which shipped binaries carry the rewrite (fingerprint of the DLLs' strings and PE headers):
vkd3d-1.1-5783-g71cae09(CachyOS 11.0-20261129-nightly) is the rewritten one only;vkd3d-1.1-5742-g2576c0b4(Proton Experimental) compiles both implementations;vkd3d-1.1-5656-g0bb64c5(CachyOS Latest) is the old one only. The nightly's siblingvkd3d-low-latencyDLL is still the old structuriser despite the same PE timestamp. So "stock Proton" depends on which vkd3d-proton version the build ships — the PR body now tracks that under the milestones.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.