Shaders/Lower: reject non-zero soffset/built_offset on typed buffer_store_format_xyzw #3007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3009"
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?
Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T03:19:30Z.
Lower::buffer's typedbuffer_load_format_*path (crates/victory-shader/src/emit/lower.rs:9785) rejects any non-zerosoffsetorbuilt_offsetviaif *offen || matches!(off, V::Inst(_)) || *offset != 0, whereas the typedbuffer_store_format_xyzwpath (L9675) checked onlycount != 4 || *offen || *offset != 0.When
soffsetwas a scalar register or non-zero inline constant (orbuilt_offsetadded a non-zero base/extra),buffer_store_format_xyzwsilently discardedoffand wrote to elementindexat offset 0 instead of returningErr.Add
matches!(off, V::Inst(_))to matchbuffer_load_format_*. Tests live incrates/victory-shader/src/emit/lower/typed_store_tests.rs(keepinglower.rsat520,628 B, well under the 512 KiB limit).Verification
typed_buffer_store_rejects_nonzero_soffset_and_accepts_zerofailed (typed buffer store with inline soffset=16 must not silently drop the offset).soffset = 16and SGPRsoffset = s0, whilesoffset = 0continues lowering cleanly and passingdxil.dllvalidation.--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45747688145 (green, combined Wave 9 check on63bcca4).AI-assisted: T3 Code (Antigravity, gemini-4-neon).
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:31:59Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib typed_store_tests: 1 passed, 0 failed (typed_buffer_store_rejects_nonzero_soffset_and_accepts_zero).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:38:39Z.
Review: CHANGES_REQUESTED
Code review on
4eeb2eb1(static source inspection; no runtime GPU/DXIL validation executed):soffsetis provably constant zero (crates/victory-shader/src/emit/lower.rs:9443-9449, 9677):lower.rs:9443-9449, anysoffsetother thanNULLor inline constant128(0) emitsoff = self.s.m.bin(c, Bin::Add, off, so), which unconditionally returnsV::Inst(_)without constant-folding0 + 0.matches!(off, V::Inst(_))atlower.rs:9677rejects a valid typed store whose scalar register holds constant zero (for instance, passings13— initialized vias_mov_b32 s13, 0intyped_store_tests.rs:44— assoffset), regressing shaders that previously lowered cleanly.Bin::Addwhensoresolves toV::Const(0)(and addinglower_typed_store(0x0d)as a positive test case alongside inline zero and nonzerosoffset).emit/lower.rsis520,628 B(within the 512 KiB limit).Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T03:58:36Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head
4eeb2eb(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.typed_buffer_store_rejects_nonzero_soffset_and_accepts_zero.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:39:50Z.
Review: APPROVED
LGTM — matches the load-side check: a nonzero soffset carried in an SGPR (V::Inst) was silently discarded before; now refused. Test covers scalar and inline-constant soffset.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:03Z.
Automated triage for the maintainers.
This is a one-line change to the typed-store branch of
Lower::buffer(emit/lower.rs). Today that branch drops a non-zerosoffset, or abuilt_offsetbase or extra, without warning and writes at elementindex. The PR addsmatches!(off, V::Inst(_))to the refusal condition, the same check the typed-load branch already uses. I confirmed thatModule::bindoesn't fold constants, so any offset added tooffmakes it aV::Inst, and only a zero or nullsoffsetwith no built offset keeps the store. The new testtyped_store_tests.rschecks refusal for an inlinesoffsetof 16 and for an SGPRsoffset, and acceptance for zero.Trade-off for the maintainer: a typed store whose SGPR
soffsethappens to be zero at run time now refuses the shader, where today it works. That matches the typed-load behaviour.CI:
checkpassing.Generated by Claude Code
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.