Shaders: one arena per program for instruction operands and effects #1756
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1757"
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 Luislariosss on 2026-11-24T22:00:39Z.
FIND-1 (claimed here): translating one instruction still cost about five heap allocations (~180 ns of ~880 ns per instruction) — the decoder's Vec of source operands and
Inst'sreads/writesVecs, each built from a temporary Vec, pluseffects()' scratch and dedup buffers. This replaces those Vecs with one arena per program.What is in it
Fields' variable-length lists (Sop.src,Ds.data,Image.addr,Valu.src) are nowgfx10::Span { start, len }intoProgram::operands: Vec<Operand>;Inst.reads/Inst.writesare spans intoProgram::effects: Vec<(Reg, Value)>.Instruction::fieldstakes the arena to append to;ir::buildreuses one scratch pair for the per-instruction register lists, so the decoder andeffectsstop allocating per instruction.Program::operands(span)andInst::reads/writes/read/write(&Program, ..).Exp.srcstays a fixed array;Instruction.wordsis unchanged (per instruction, out of scope here).Inst,FieldsandProgramstayClone/PartialEq/Eq/Debug; the offlinevictory translatepath is adapted as well.ir::tests::operand_and_effect_spans_slice_back_each_instructions_lists: 0, 2 and 3 sources, an implicit VCC operand, reads/writes order, and no gaps in either arena. A second testir::tests::split_block_copies_get_their_own_effect_spanspins the block-split path: the split copy's spans do not overlap the original's, its write values differ, and renaming through one copy leaves the other unchanged.Tested
rust-toolchain.toml).cargo test --workspace --no-fail-fast: 478 passed, 0 failed, 7 ignored at this head (29d5f6e, rebased onto upstream70564ae). Upstreammainalone on the same machine: 476 passed, 0 failed, 7 ignored — the difference of two is the two new tests, so no upstream test regressed. The GPU-executedvalu/waterfalltests ran on the RX 9060 XT (no GPU skips on this adapter).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo check --workspace --all-targets: passed.CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0— rustc 1.98.1 here dies with 0xc0000005 while compiling with debuginfo; the test behavior is unchanged by that.Not tested / not measured
Instruction.wordsand the other per-instruction Vecs the finding names remain, out of scope here.AI use
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:18:49Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
70564ae), cargo test -p victory-shader --locked → 120 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows.One arena per program for instruction operands and effects: Span/push/since/of replace per-instruction Vec allocations across ir/structure/gfx10/emit/wave/resource/io/range (12 files, +3281 diff lines). round16_after/reads_mask_as_data/simulate/constant helpers support the new allocation scheme; 2 tests added. This is a pervasive representation change — macOS unit tests are green, but the real proof is the Windows hardware suite (valu/waterfall/diff/fuzz) which exercises every lowering path; please make sure CI Windows ran green before merge.
Imported from Marvisak/VIctory. Originally posted by TinkerBell-90 on 2026-11-24T22:21:59Z.
Review: COMMENTED
Tested the "no behavior change" claim on CPU, since this touches every pass from decode to emit.
Setup: Linux x86-64, Rust 1.98.1, main
70564aeagainst this head29d5f6e, both with the random program generator from #1335 applied (identical file in both trees). For each program I ran the same stages asemit::translate(ir::build,structure,resource::track,io::raise,emit) and hashed the outcome: the wholeHostShader(its Debug output, DXIL bytes included) or the refusal text.split_irreducible(118 of them reach DXIL), 4,707 of the mutated set (68).split_irreducibleremoved, so the copies share their spans, 79 of the first 500,000 outcomes change (among them 26 translate, 52 are refused and 1 panics inemit/bitcode.rs). So the comparison does catch the aliasing that copy prevents.Allocations, which the description lists as not measured: with a counting global allocator around translation only, the same 500,000 programs make 197,059,864 allocations on main and 156,581,445 here (-20.5%), or 18.3 and 14.5 per decoded instruction across the whole pipeline. On the mutated set, 14.8 and 11.4. Time, release build, 300,000 programs, three alternating runs each: 14.94 s and 14.26 s on average (about -4.5%), on a machine with other load, so only a rough figure.
Also:
cargo test -p victory-shader --libpasses on both (118 on main, 120 here; the GPU tests are Windows only and did not run).cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warningsis clean (check only, no linker). I could not buildapps/victoryhere (victory-gpuis Windows only), so the one line change intranslate.rsis checked by reading only.One thing to keep in mind, not a bug today:
PartialEqonFieldsandInstnow compares span positions rather than operands. I found no comparison of either outside tests, but a futurea.fields == b.fieldsacross two instructions would compare offsets and never match.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:14:19Z.
VIctory V2: community PRs, merged and tested
Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.
Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).
⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.
Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2
Unofficial community fork of Marvisak/VIctory, GPL-3.0.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T23:05:04Z.
NVIDIA counterpart to the RX 9060 XT runs: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
29d5f6e(onmain70564ae).cargo test -p victory-shader --locked: 208 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures onmain, so there are no new failures from the arena change.AI-assisted (Claude Code). Synthetic tests only.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:40:45Z.
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs,ir.rsandstructure.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: a green CI
checkat the head, and a before/after timing (e.g.translateover a synthetic corpus) for this wide refactor.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.