Shaders: a census that no opcode of the ISA may translate by crashing #2376
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2378"
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 borosf on 2026-11-25T12:16:19Z.
Summary
Okor a refusal naming what it lacks, andcatch_unwindturns any panic into a test failure — a title could reach any of these encodings, so none may crash the translator.pub(crate)now so the census iterates the real decoder tables and stays in sync as opcodes are added.cargo test -- --nocapture(e.g. all VOP3 f64/dot/div ops refuse by name; every FLAT/GLOBAL op hits the flat-memory guard; DS ops hit the LDS-allocation guard).claiming: ISA-CENSUS (commenting from this account is blocked by the integration's permissions, so the claim rides this PR).
Verification
cargo test -p victory-shader --lib: 147 passed, 0 failed (incl.emit::census_tests::every_opcode_translate_or_refuse_never_panic).cargo clippy -p victory-shader --all-targets: identical to pristine main940d32f.cargo check --target x86_64-pc-windows-msvc -p victory-shader --all-targets: clean.cargo run -p xtask -- policy: 183 files ok. No game data used.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T12:31:11Z.
Review: APPROVED
Verified against
origin/main(940d32f):census_testsensures no opcode panics during decode/lower and runs fast (0.22s).cargo test -p victory-shader census_tests: 1/1 passed (every_opcode_translate_or_refuse_never_panic).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 184 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T12:35:57Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — census of ISA opcodes that may not translate.Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-25T12:20:36Z.
Expanding on why the census is more useful than it looks from a one-line test:
It turns "shader coverage" from an anecdote into a number. The frame-rate problem on world rendering isn't compute cost in translated shaders — it's the draws that never happen because translation refuses. Before this, refusal coverage was known from reading code; now
cargo test -- --nocaptureprints the complete map: which of the ~1,230 table entries translate, which refuse, and the exact reason per opcode. That's a per-family, per-reason backlog in one command.It's the input the refusal-kind work needs. The whole-wave refusal logging (per operation kind) only pays off if you know which kinds exist and how much each costs. The census answers that: e.g.
v_cmpx_f64is 17 opcodes behind one reason, the f64 VOP1s are 14 behind another, permlane/mul_lo/min3_i16 are singles. Fixing one reason class and re-running the census gives a measurable delta — the same loop that H-6.3/FIND-7 set up for whole-wave sections, now covering the whole ISA.It guards the crash path a title can reach. Any of these encodings can appear in real title code, so a panic on one is a runtime crash of the translator, not a test failure. With
catch_unwind, a future commit that turns any refusal into a panic fails CI here instead of killing the emulator on a user's machine. The same applies to a new opcode landing in a table: the census picks it up automatically because it walks the tables, so "added but never wired through the pipeline" gets caught.It pins the decoder contract, not just translation. The name round-trip check means an opcode that decodes under the wrong family — e.g. anything drifting into the SOPP 0x17F window or aliasing a VOP1/VOPC prefix — fails with the exact mismatch. That's the class of bug you normally only find by disassembling a miscompiled shader.
All of this is why it refuses rather than skips: the failure output lists every offender by family, opcode, and name, so a red census tells you what happened before you open the diff.
Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T13:08:15Z.
First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head
fe10149merged ontomain940d32f,cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.The PR's new test(s) pass on this card:
emit::census_tests::every_opcode_translate_or_refuse_never_panic. The rest is the same asmainon this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests invictory-gpu, 3 invictory-shader), nothing new.One run, unit tests only, title not run.
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-25T13:24:06Z.
Thanks — useful datapoint: the census ran clean on Blackwell (RTX 5070, 621.24), with the same 5 known NVIDIA failures from #1744 as pristine main and nothing new. That's now the census verified across three vendors with the same result — Intel Arc B580 (Battlemage), and this run — all confirming the census itself is platform-stable: it's pure CPU translation, so hardware only enters through the suites everyone already knows.
If anyone's curious what it actually covers beyond the one test name: each opcode in all 19 decode tables is encoded into a pixel program and taken through decode → ir → structure → resource → io → emit, with a name round-trip assert (encoder/decoder can't drift apart), each outcome classified as translate / named refusal / panic, and any panic failing CI — with
-- --nocaptureprinting the per-opcode map (census: 544 translated, 688 refused, 0 panicked).Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:55:38Z.
Automated triage for the maintainers.
Merge candidate. A test-only change:
emit/census_tests.rsencodes every opcode of every decoder table (gfx10/opcodes.rs, nowpub(crate)) into a minimal pixel program and runs it through decode, IR, structure, resources, IO and emit. It fails if the decoder reads back another name than the table gives, or if any opcode panics instead of translating or refusing. I checked the per-family encodings against the field layouts the decoder uses (MUBUF opcode bit 7 in bit 25, MIMG's in bit 0, the literal-eatingmadmk/fmaak/setreg_imm32forms), and that nothing outside tests changes. A panic in the translator is a crash a title can reach, so this guard is useful and walks new table entries automatically.Optional: it
eprintln!s about 690 refusal lines on every run; printing only a summary unless asked (e.g. an env var) would keep test logs readable.CI:
checkpassing.Generated by Claude Code