Shaders: a census that no opcode of the ISA may translate by crashing #2378
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!2378
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2378/head"
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?
@borosf on GitHub · 2026-11-25 12:16 UTC · original
borosf:vibe/isa-census-842ca5→main· +209 −20 · 4 files · 1 commits · merged 2026-11-25 21:56 UTCSummary
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.@borosf on GitHub · 2026-11-25 12:20 UTC · original
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.
@welisonzika14-jpg on GitHub · 2026-11-25 13:08 UTC · original
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.
@borosf on GitHub · 2026-11-25 13:24 UTC · original
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).@Marvisak on GitHub · 2026-11-25 14:55 UTC · original
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