Shader: key every heap handle cache by element type (#177 on main, fixes the NVIDIA compute-pipeline crash) #2723
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2723
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2723"
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?
@andyeox-systemd on GitHub · 2026-11-25 18:50 UTC · original
andyeox-systemd:nvidia-atomic-handles→main· +112 −6 · 2 files · 1 commits · openBuilds on #177 (Ortomanic's fix and gingertonik's test, credited as co-authors), resolved against current
main(13f91ca), and extended to the two handle cachesmainadded since.The bug
When a UAV is read as float and is also the target of an atomic, the lowering reused one float-typed handle for both. After conversion to SPIR-V, the atomic is invalid (
AtomicOr/AtomicUMax: expected Result Type to be integer scalar type), and NVIDIA's compiler crashes invkCreateComputePipelines(0xc0000005/0xc000001din the Unix call). This is the crash in #144.#177 added the element type (
props.1) to thehandleskey.mainhas since addedentry_handlesandjoin_handles, which had the same problem, so this PR keys those by both property words as well. #177's test is included, withview_marksadded for the currentParts.Testing
RTX 4070 Ti, Arch Linux,
nvidia-open-dkms620.73.04, Wine 11.22, vkd3d-proton built from master (71cae09, dxil-spirvb540c8a). Shaders were dumped withVKD3D_SHADER_DUMP_PATHand checked withspirv-val --target-env vulkan1.3. I used fresh caches for both runs.main(13f91ca)vkCreateComputePipelines0xc0000005)AtomicOr,AtomicUMaxon a non-integer)cargo test -p victory-shader --libon Linux (with the Windows-only validator blocks compiled out locally): 159 passed, 0 failed, against 158 onmain. The extra one is #177's test.Separate vkd3d-proton issue
On vkd3d-proton 3.1 and earlier, the title crashes earlier for a different reason. dxil-spirv's old structurizer emits invalid control flow for three shaders ("Function end cannot be called in blocks", "block exits the loop headed by…"). Microsoft's
dxvaccepts our DXIL for all three, so that's not a VIctory bug. It is fixed by dxil-spirv's structurizer rewrite, which is in vkd3d-proton master and not in 3.1. NVIDIA under Wine needs both fixes.AI-assisted. No game data is included.
A UAV read as float and also used by an atomic needs two handles: an atomic on the float handle is invalid SPIR-V after conversion ("AtomicOr/AtomicUMax: expected Result Type to be integer scalar type") and crashes NVIDIA's compiler in vkCreateComputePipelines. #177 added the element type to the `handles` key. main has since added `entry_handles` and `join_handles`, which had the same problem; they are keyed by both property words now as well. Includes #177's test, with `view_marks` added for the current `Parts`. Co-authored-by: Ortomanic <[email protected]> Co-authored-by: gingertonik <[email protected]>@kotekompotek on GitHub · 2026-11-25 18:59 UTC · original
Correct root cause and fix: one UAV read as float and targeted by an atomic legitimately needs two annotated handles (atomic requires integer component type), and caching by props.0 alone collapsed them. Extending the key to props.1 across all three caches (handles, entry_handles, join_handles) is the complete version of #177's fix. The test constructs the exact shape (image_load + image_atomic_umin, same descriptor) and asserts the two distinct annotations. Hardware-verified against the actual crash.
@DrDarkDK on GitHub · 2026-11-25 19:06 UTC · original
The float-load/atomic regression uses one fixed table entry, so it exercises
entry_handles. The fixture would still pass ifprops.1were removed from thehandlesorjoin_handleskey.Could you add a uniform dynamic-offset case for
handlesand a case where the descriptor is selected at a control-flow join forjoin_handles? Each should fail if only its corresponding cache key dropsprops.1.AI-assisted with Codex.
@fuzeofficlal on GitHub · 2026-11-25 19:32 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP +
dxil.dllverification and code review of235c48c6(on13f91ca):Verification (
rustc 1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warningsand--features host: 0 warnings.cargo test --locked -p victory-shader --features host --lib -- an_image_read_as_float_and_by_an_atomic_is_annotated_twice: 1 passed, 0 failed.cargo test --locked -p victory-shader --features host --lib -- emit::valu_tests --test-threads=1(RTX 5090 hardware + WARP +dxil.dll): 30 passed, 0 failed.Review Notes
entry_handles,handles, andjoin_handles) now includeprops.1(component type/count), avoiding redundant handle creation for raw/structured/CBV/sampler handles (props.1 == 0) while splitting mixed float/integer typed accesses on the same descriptor.handlesandjoin_handleswould pin all three caches, though the production code already updates all three.)@pablogonz12 on GitHub · 2026-11-25 19:41 UTC · original
AMD/RADV offline check of the head commit (no game run).
origin/main13f91caee.victory-shader --example retranslate, then dxil-spirv (master),spirv-val --target-env vulkan1.3, and a realvkCreateCompute/GraphicsPipelineson RADV (vkpipe, one process per program, so a driver crash or hang is recorded per program rather than stopping the batch).Result, base
13f91caeevs head 235c48c68: both translate 749 / 751 (the same 2 refused in both trees,a lane mask read as data is not supported).18 programs' DXIL bytes change — 12 pixel, 6 compute — and this PR is the difference between "the host rejects the shader" and a working pipeline:
13f91caeeOpAtomicUMax/OpAtomicIAddwith a%floatresult typeExamples:
compute-11bbed94ee7a3243baseerror: line 352: AtomicUMax: expected Result Type to be integer scalar type %297 = OpAtomicUMax %float ...;pixel-15c34c906ac8b908baseAtomicIAdd: expected Result Type to be integer scalar type. Head translates the same programs into integer atomics and all 18 build.The other 731 translated programs are byte-identical to main, so nothing else moves. Worth mentioning in the description: on main these 18 shaders produce SPIR-V that validation refuses, i.e. any pipeline that uses them cannot be created at all.
Not tested in a game run; not tested on NVIDIA.
@oni-swr on GitHub · 2026-11-25 19:41 UTC · original
Independent WARP/CPU verification for head 235c48c6827171084ec7215de92f974c9f1a7c5b against origin/main
13f91caee2. State check: open, non-draft, clean merge-tree; no oni-swr comment found.Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); WARP/D3D12 WARP env vars set; CARGO_TARGET_DIR=D:\victory-warp-2720-target.
Commands/results:
Review: no production blocker found. The regression test proves the float/U32 annotations coexist. It exercises the fixture’s actual cache path; the three cache-key edits are otherwise not independently isolated by separate fixtures.
Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).
@Kajanos on GitHub · 2026-11-25 20:43 UTC · original
NVIDIA + vkd3d-proton unit-test run, head
235c48c682merged ontomain13f91caee2.Setup: Linux (Gentoo) / wine-proton 11.0.3 / vkd3d-proton 3.1, RTX 5080, NVIDIA 620.73.04; cross-built with cargo-xwin, rustc 1.98.1,
dxil.dllfrom DXC v1.9.2609.cargo xwin test -p victory-shader: 268 passed, 3 failed, 3 ignored.maingives 267 passed with the same 3 failures, so the new test passes and nothing else changed.mainin this environment, so they come from vkd3d-proton/Wine and not from this PR:emit::tests::stub_pipeline_is_created(a zero digest is accepted)semantics_tests::rounding_matches_the_hardware(v_fract_f32on negative denormals)stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros(dispatch fails with "Invalid parameter")Not run: the retail title. The #144 world-load crash itself is not reproduced or verified here.
AI-assisted (Claude Code)
@neonbyte1 on GitHub · 2026-11-25 22:35 UTC · original
Tested on an RTX 5090 (driver 620.73.04) under Linux: Wine 11.22, vkd3d-proton 3.1-83 (GE-Proton11-14) and vkd3d-proton master
ec207194, DXVKdxgi, diagnostics build.Base:
mainat13f91cawith this PR, #1129 (pipeline worker stack), the one-line #747 heap change, and a constant-table fix equivalent to #2143.main940d32fwith the same other fixes, the run hits an NVIDIA MMU fault (Xid 13) at world entry, at frame 1349. The two bases differ by 83maincommits besides this PR, so that comparison isn't fully isolated.vkCreateComputePipelinesno longer crashes on76c35de1c2444e67(CS_Primary_EstimateProbeShadingChange), on either vkd3d-proton.AI-assisted (Claude); measured on my machine, no game data shared.
@Marvisak on GitHub · 2026-11-25 23:19 UTC · original · edited 2026-11-26 04:24 UTC
Automated triage for the maintainers.
Merge candidate. Now merges cleanly. The element type (
props.1) joins the keys of all three handle caches inemit/lower.rs(handles,entry_handles,join_handles), so a UAV read as float and used by an atomic gets its own integer-typed annotation, matching D3D12's rule that atomics need integer UAVs; raw, structured, CBV and sampler handles haveprops.1 == 0and are unchanged, consistent with 731 of 749 programs coming out byte-identical. The test covers onlyentry_handles; thehandles/join_handlescases offered on your fork would be worth folding in. This supersedes #177.CI: not run yet on this head.
Generated by Claude Code
@Anzymanz on GitHub · 2026-11-26 00:40 UTC · original
From a tester working with Claude (AI-assisted, Claude Code). Two things: a crash this fixes on AMD/Linux that isn't in the description yet, and a rebase onto main.
Crash. Under vkd3d-proton (GE's 3.2 and master
71cae09) on an RX 9070 XT, the title ends withterminate called without an active exceptionabout 90 s into the world. A colleague traced it to dxil-spirv:fixup_load_type_typed(opcode 66, TextureLoad) sees an image it has marked 64-bit, because of anatomicBinOp.i64on the same handle, loaded as float, andcast<IntegerType>aborts the whole process. In the dumped DXIL, one handle annotatedRWTexture2D<4xF32>(props0x1002,0x409) takes both thetextureLoad.f32and the 64-bit image atomic. That's this PR's bug: the atomic's0x105handle collapses into the load's.Whole-corpus check (all 25,889 distinct containers of the title's shader archive, translated offline through
translate_with, main + this change against main):b6df66af105d8b2d,edc43d3e658a4b9d, both compute, the dump's shape; master with a local guard reportsTyped load of a 64-bit resource into a non-integer type is not supportedwhere 3.2 aborts); after, all 1,025 convert.Rebase. The conflict with main is only test-side:
Lowered's#[cfg(test)]fields and the test module, where main addeduses_lane_index,has_half_wave_maskandds_bpermute_wave64_preserves_32_lane_halfnext to this PR's additions. Keeping both sides resolves it. I have it as one commit on main63bcca4: https://github.com/Anzymanz/VIctory/tree/handle-key-2723-on-main (8281e38). Its diff is line for line yours.cargo checkis clean andan_image_read_as_float_and_by_an_atomic_is_annotated_twicepasses. @andyeox-systemd, feel free to take it as is or redo it yourself.No game data: hashes, counts and error text only.
@necrobytes on GitHub · 2026-11-26 01:28 UTC · original
I sent the two requested regression tests directly to this branch in andyeox-systemd/VIctory#1. All 30 shader-lowering tests passed on this PR head. Removing the element type from either cache key made just its corresponding test fail.
I tested the cache-key change on an RX 9060 XT with RADV 26.2.7 and vkd3d-proton 3.2.0. I compared
63bcca43with the same revision plus the production changes from235c48c6. One input came from the compiler abort discussed above. The other corresponds to the Strix Halo report on #714. Each isolated test used one compute shader, one worker and a fresh driver cache. I checked that the baseline DXIL matched the bytes cached by the failing game runs.Main exited with code 3 in all four affected cases. Microsoft’s DXIL validator accepted both affected shaders before and after the change. The difference showed up during D3D12 pipeline creation.
I also ran the game with #1722 and this change together. It created the second affected pipeline and presented another 35 frames. The run completed the planned 110 seconds after the world marker and reached the opening credits. The first affected pipeline was exercised only in the isolated test.
AI-assisted with Codex.
@ntgata1-dotcom on GitHub · 2026-11-26 05:19 UTC · original
This head fails the asset-policy check.
cargo xtask policyon38f3697:main's copy is 520,563 bytes, so this PR's additions take it 282 bytes over. CI hasn't run on this PR yet, which is probably why it hasn't shown.cargo testruns the same check (repository_passes_policy).Moving
an_image_read_as_float_and_by_an_atomic_is_annotated_twiceand itsmimg_2dhelper into a test module of their own underemit/(as the*_tests.rsmodules there are) brings the file back under, with room for necrobytes' tests from andyeox-systemd/VIctory#1. #2977 also growslower.rs: with both, it comes to 527,667 bytes.AI-assisted (Claude Code); checked on my machine.
@Dukestar69 on GitHub · 2026-11-26 04:26 UTC · original · reviewed
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib emit::lower::tests: 34 passed, 0 failed (including newan_image_read_as_float_and_by_an_atomic_is_annotated_twice).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: FAIL — adding the new test inline inlower.rspushes it 282 bytes past the 512 KiB policy limit on currentmain(63bcca4):Moving the new test into a submodule under
crates/victory-shader/src/emit/lower/will clear thextask policygate cleanly.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@ClosetPie107 on GitHub · 2026-11-26 09:04 UTC · original
Tested on the retail title under Proton: this PR fixes the dxil-spirv abort from #3101, both offline and in-game.
Stack
experimental-11.0-20261112(Wine 11, ntsync), DXVK 3.1.1dxgiec207194(3.2.0) with dxil-spirv masterb540c8a2, built locally (-Db_ndebug=true)d3dcompiler_47in the prefix (the indirect clamp still needs it onmain, #170)main63bcca4, merged with this PR (38f3697), cross-built forx86_64-pc-windows-gnu; Series X files, 1.0.2.1Offline (dxil-spirv
b540c8a2CLI,--bindless --enable-shader-demote --ssbo-uav --ssbo-srv --bindless-typed-buffer-offsets, run on every moduletranslate --listemits)mainmain+ #2723smh_draw_64andsmh_draw_128CS_VisHair_969c6f85(Invalid type ID in cast<T>infixup_load_type_typed, exit 134)CS_VisHairUAV handles{4098, 1033}used bytextureLoad.f32andatomicBinOp.i64{4098, 1033}for the load,{4098, 261}for the atomicdxil.dllvalidatorIn-game
translate --cache --pipelinescompletes: 27,135 pipelines made in 219 s, no abort (onmainit dies around pipeline 1,200, as in #3101).VICTORY_SKIP_PIPELINES, warm caches:CS_VisHair(b6df66af105d8b2d) gets its host pipeline and runs. The intro cutscene plays and the run reaches the prologue (prison scene), lit, with characters and hair. 25 minutes, ended by my time cap, with no crash or device removal. About 1 fps in the cutscene, a steady 2.9–3.3 fps in the prologue, about 12.7 GB of VRAM.main, the same setup ended about 10 minutes in when vkd3d-proton hit this abort (terminate called without an active exception, exit 3). WithVICTORY_SKIP_PIPELINES=b6df66af105d8b2dinstead, the title crashed about 8 minutes in at+0xb6fb9, reading0xffffffffffffffff, with f16 infinities inrax. That did not happen with this PR, so it may have come from the skipped hair pass. Unconfirmed.Still visible with this PR: blocky bands over the lower part of some shots, and 76–264 draws a frame dropped for untranslated shaders. These look unrelated.
No game files attached. AI-assisted (Claude Code).
@fuzeofficlal on GitHub · 2026-11-26 12:26 UTC · original · requested changes
Keying
entry_handles,handles, andjoin_handleson both(props.0, props.1)(crates/victory-shader/src/emit/lower.rs:220-228, 5376, 5392, 5501) matches whatShader::annotatereceives and preserves non-typed raw/structured/CBV/sampler sharing (props.1 == 0).However,
crates/victory-shader/src/emit/lower.rson38f36978is 524,570 bytes—282 bytes over the repository's 524,288-byte asset-policy limit—causingcargo run --locked -p xtask -- policyto fail (exit 1).Please move
mimg_2dandan_image_read_as_float_and_by_an_atomic_is_annotated_twice(emit/lower.rs:12220-12309, ~3,513 bytes) into a separate test module solower.rspassesxtask policycleanly. (Optional follow-up: the new regression currently hitsentry_handles; adding a dynamicSource::Loadedand a uniformSource::Phiproperty-mismatch case would directly exercisehandlesandjoin_handlestoo.)Local checks on
38f36978:cargo run --locked -p xtask -- policy: failed (524570 bytes exceeds the 524288-byte limit).cargo clippy -p victory-shader --all-targets -- -D warnings(default &--all-features): clean.emit::lower::tests34 passed,emit::shader::tests1 passed; onVICTORY_WARP=1,emit::memory_tests5 passedandemit::stride_tests8 passed; on RTX 5090,emit::memory_tests4 passed(skipping pre-existing Blackwellheap_direct_texture_reads_mark_their_heap_index) andemit::stride_tests6 passed(2 pre-existing NVIDIA 1M view-heap-cap failures).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.