test(shader): translate random GFX10 programs on every test run #1335
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!1335
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1335"
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?
@Levichu51 on GitHub · 2026-11-24 17:32 UTC · original
Levichu51:test/shader-random-programs→main· +623 −0 · 3 files · 3 commits · openThe title translates its shaders in its own process when it creates pipelines, so a panic anywhere in ir, structure, resource, io or emit ends the title, and a translation that differs between runs defeats the shader cache and the pipeline library. Earlier panics of this kind were found by one-off random-input runs; nothing keeps that search going while some 290 open pull requests change the translator.
random_tests assembles 4,096 random but plausible programs per run (about three seconds in a debug build): opcodes from our tables with small register numbers, descriptors loaded from root tables first, branches that land on instructions a few before or after their own (loops among them), v_interp in pixel programs whose input element starts at any channel, and a store or export that needs what the body computes. Compute programs run as 32 or 64 lanes. Each program must translate or be refused with a reason, twice, with the same result; about one in ten reaches DXIL, and the test fails if fewer than one in fifty do, so that it keeps testing emission. A failure names the seeds and lists the first program in SP3. VICTORY_RANDOM_PROGRAMS, VICTORY_RANDOM_SEED and VICTORY_RANDOM_TRACE scale a run up, replay one program, and name the program a stack overflow aborts in.
It finds both earlier random-input bugs at their parent commit, without being aimed at them:
97c78d10: a stack overflow (wave64, a write of exec_hi alone; fixed byea24ea10);97c78d10+ea24ea10: seed 93 panics with "attempt to subtract with overflow" at lower.rs:1022 (an input element starting at w; fixed by5fbea473). On main, 300,000 programs (release build with overflow checks) all pass.gfx10::opcodes exposes the opcode tables to tests.
@Marvisak on GitHub · 2026-11-25 01:22 UTC · original · edited 2026-11-25 20:22 UTC
Automated triage for the maintainers.
Merge candidate. This adds a seeded random-program test for the shader translator (
crates/victory-shader/src/emit/random_tests.rs,#[cfg(test)]) and a test-onlygfx10::opcodesaccessor. Each program must translate, or be refused with a reason, twice and with identical results. A failure names the seed and prints the program as SP3.The point from the last review is fixed in
3541e51.random_tests::translatenow callsrange::buildfollowed byresource::track,io::raiseand emission, the same sequenceemit::translate_withruns onmain, so the bounded rebuild of relative moves is now fuzzed. The newrelative_movegenerator puts an M0 set to a constant, or clamped bys_min_u32/s_and_b32, in front of av_movrel*/v_swaprel_b32. I checked its SOP1/SOP2/VOP1 encodings against the GFX10 layout, and they are correct.One optional note: the test emits through
emit(no view write marks), while the runtime translates withview_marks: true. Callingemit_withwith those options would cover that path too.Reply to the author: thanks. Making the generator produce boundable M0 values (642 of 4,096 programs now reach the rebuilt program) is exactly what was needed for the range analysis to be exercised, not just called.
CI: passing.
Generated by Claude Code
@Levichu51 on GitHub · 2026-11-25 17:54 UTC · original
Rebased onto current main (
13f91ca); conflict in emit/mod.rs resolved.@Levichu51 on GitHub · 2026-11-25 18:52 UTC · original
Thanks. translate now goes through crate::range::build, as translate_with does (
3541e51).Switching alone didn't reach range's fixed point: in 4,096 programs, 240 had a relative move and none got a bound, because their M0 was almost never boundable. The generator now adds relative moves mostly after an M0 set to a constant or clamped by s_min_u32 / s_and_b32. Of the default 4,096 programs, 1,363 have a relative move and 642 get a proven bound and a rebuilt program. 500,000 programs pass in release with overflow checks.
@fuzeofficlal on GitHub · 2026-11-26 01:19 UTC · original
Code review and Windows 11 verification at head
3541e51ea6d3merged cleanly ontomain(63bcca43c6a0;emit/lower.rsuntouched):crates/victory-shader/src/emit/random_tests.rs,gfx10/mod.rs:335-362):splitmix64->xorshift64over defaultseed = 1..=4096, no clock/entropy or HashMap nondeterminism), checks both panic-freedom and byte-identical DXIL/error reproducibility across two passes per seed, and requires>= 2%to reach DXIL emit whencount >= 1000.2..=31instructions, bounded[k-6, k+6]branch window, boundedSMEMretry loop) — ran all 4,096 x 2 translations in 4.57 s in debug mode with zero hang risk.cargo xtask policy:192 files ok;cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningsvictory-shader -- random_programs: 2/2 passed (4.57 s).LGTM.
3541e51ea6to7399813379@Levichu51 on GitHub · 2026-11-26 13:12 UTC · original
Rebased onto current main (
63bcca4). Took the optional note: translate now calls emit_with, with write marks on odd seeds (as the title's pipelines are made) and without on even ones, so both paths are fuzzed at no extra cost (7399813). 147 of the default 4,096 programs are translated with marks emitted; 300,000 programs pass in release with overflow checks.@Levichu51 on GitHub · 2026-11-26 14:29 UTC · original
Follow-up ready: I extended the random-program test to vertex and mesh programs (plus more pixel I/O: depth/stencil exports, f16 interpolation, 16-bit inputs), on the branch test/shader-random-vs-ms in my fork. It builds on this PR, so I'll open it as a separate PR once this one is merged, rebased to a single commit.
Short summary of the follow-up:
No changes needed here; this PR stays as it is.
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.