Shaders: a compute shader samples at level 0, not with derivatives (735 programs) #2027
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!2027
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2027"
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?
@fiestorra on GitHub · 2026-11-25 03:29 UTC · original
fiestorra:fix/compute-sample-level→main· +27 −2 · 1 files · 2 commits · closed without mergingA compute shader has no derivatives to sample with: 735 programs, all
Cs, all refused for it — andsampleLevelat level 0 fixes themThe next class after #1987, and this time the reason was in the run I had already made: the validator's
note:line said735 programs, every one of them a compute shader (
735 x Cs, no other stage). I dumped three of them (VICTORY_EMIT_DUMP) and disassembled withdxc -dumpbin:Three implicit
dx.op.samplenext to hundreds of explicit ones, in a stage that has no neighbours to take derivatives from.dx.op.sampleis not a legal operation forcs— no shader model makes it one without the mesh/amplification derivatives feature — and the console'simage_samplein that stage has no derivatives either: level 0 is what the instruction means there.So the lowering now asks the stage: a compute program samples at level 0 with
sampleLevel(62) and keepssample(60) everywhere the implicit form is legal. The choice issample_op(compute), and the test pins the pair.Measured on the offline census over the same local 1.0.2.1 archive (26,503 containers), validator SDK 10.0.26100
dxil.dll1.9:incompatible with the shader stagemain940d32f25,520 is 1,602 more programs than
main: the 868 vertex programs of #1987 and these 735, minus the one that was in both classes.One caveat worth stating, because it is the difference between "valid" and "right": the console program samples with whatever filter and coordinate the shader computed, and level 0 is the honest reading of "implicit level in a stage with no derivatives". If a title's compute shader relied on something else — a derivative register the console keeps per lane — this would change what it samples. That is worth a picture comparison on the raytracing resolve passes, which are the ones in this class, and I have not run the title to look at them.
Recipe:
cargo test -p victory-shader --locked --lib249 passed, 3 ignored;cargo test --workspace --locked26 suites with the one failuremainalso has in a session without a desktop;clippy --workspace --all-targetswith and without--all-featuresclean under-D warnings;rustfmt --checkwith the same 19 hunksmainalready has inlower.rsand no others.No game data is involved: program names, counts, operation names and thread-group sizes.
Written with an AI assistant.
@jeremygold02 on GitHub · 2026-11-25 03:30 UTC · original
Triage verdict — Split the overlapping flag change and verify sampling semantics (
6a16a66)Evidence
Checks and limits
sample_optest checks an opcode pair; it does not emit a container or distinguish actual mip selection. I reviewed the source and existing evidence without rerunning the census or a GPU test.Next step
compute_image_sample_reads_level_zerofixture worth adapting. Use distinct mip contents and compare the intended result against the derivative-preserving path on a supported compute group. If mip 0 is a compatibility fallback, document the exact condition for using it.This verification was AI-assisted.
@upipibi on GitHub · 2026-11-25 03:34 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
6a16a66.victory-shader: 246 passed, 3 failed, 3 ignored; the newa_compute_shader_samples_at_level_zeropasses. The 3 are #1744's NVIDIA failures onmain. Same asmainon this hardware. Not run: a title.Overlap, from reading: #1237 (quad-lane gradients to
sampleGrad) and #1065 (validator 1.8 compute derivatives) fix the same 735 compute programs, and wildheathen compared the two on70564aein #1237. #1409 made the same level-0 change outside pixel shaders, and triage closed it as going againstmain's deliberate implicit-LOD samples in compute. Level 0 and the console's quad derivatives give the same result only where the coordinates move about one texel per lane. They differ where a program minifies, such as a downsample.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-11-25 03:35 UTC · original
Checked both fixes against the title itself: identical to
mainfor the first 70 s, and that is the expected answerValidation fixes are easy to ship without ever asking whether they change the executable, so I ran the title with both branches merged (this one and #2016), on this machine, in the same scenario I always use: session 1 (interactive desktop), RTX 4090, driver
32.0.16.2124, release build, empty cache, 70 s:main940d32fhost view heap capped at 1000000title slot past the host heapno host texture … 2560x1440 format 115Flags must match usageincompatible with the shader stageIdentical, line for line. That is what I expected and it is worth saying why: the run dies at frame 64, before the title reaches the passes that use the 735 compute programs and the 868 vertex programs, so neither fix can show up in this window. The values on the two validator lines were already 0 because the runtime path does not validate at all — the fixes matter to
translate --validateand to any report that counts validated programs, and they will matter to the title only once the heap cap (#1779), the texture ladder (#1630) and the removal (#1832) stop it from dying at frame 64.So: no regression in what the title does today, and no improvement either. I would rather write that down than let a green check on the census imply the game changed.
The caveat from the pull request stands and is the one thing I still owe: the level-0 sampling in
sampleLevelfor compute is the honest reading of an implicit sample in a stage with no derivatives, but nothing here proves the raytracing resolve passes look the same — they are past the point this run reaches. A picture comparison over those passes needs a build that boots further, which is the #1779 + #1630 + #1832 chain.No game data is involved: counts and warnings.
Written with an AI assistant.
@BaggyALPHA on GitHub · 2026-11-25 03:54 UTC · original
Independent synthetic comparison on Windows, RTX 3080 and WARP. I tested each head separately on upstream
940d32f. The same plain computeimage_sampleread a 32×32 texture whose texels encode their mip number. Each column below is the readback for constant coordinates, then quad coordinate spacings of 1/16 and 1/4, respectively.e198449)6a16a66)Both runtime adapters created the pipelines and returned the same values across all 32 lanes, in two runs per tree. This shows the level-zero path changes observable host sampling for the same synthetic input, while the 1.8 metadata change preserves the existing host readback. Microsoft documents quad-based compute derivatives in Shader Model 6.6. The test does not establish which result matches the console for this instruction. All inputs were synthetic. No game files were used.
AI-assisted (OpenAI Codex).
@Calvix2k on GitHub · 2026-11-25 03:55 UTC · original
Corpus measurement on the real
shaders.rpf(1.0.2.1),victory translate … --validate --list --jobs 10, Windows 10 / RX 7800 XT, SDKdxil.dll1.7 (default_path's pick here), release build of this head6a16a66:incompatible with the shader stageFlags must match usagemain 940d32f+1,602 = 735 compute (this PR) + 867 vertex (the UAV flag commit that is also in this branch). Worth stating in the body: the branch carries two commits —
3d6a54f"a vertex shader that declares a UAV says so…" (#2016) and6a16a66the compute change — so merging this lands both, and #2016 becomes redundant. That is fine, but reviewers should know, and the two flag PRs are #1989/#2016 with the mesh caveat on #2016's predicate (Dathinel's fixture).One good sign for the compute half on an older validator: these modules still validate with the SDK 1.7
dxil.dll, so the change does not declare a newer validator version — a 1.7-only machine does not lose the 735 to “validator version not supported”.@fiestorra on GitHub · 2026-11-25 04:41 UTC · original
Rebased so this pull request no longer carries #2016's commit, and measured alone: 23,918 → 24,653
When I opened this I had stacked it on #2016 (the vertex UAV flags), so the branch contained that commit and the two could not be merged in either order without a resolution in
apps/victory/src/translate.rs. That was my convenience, not the repository's: the change here has nothing to do with the UAV flag, and being stacked made two otherwise-independent pull requests into a sequence.It is now rebased onto
main940d32falone, with only its own commit, and measured on its own over the same archive (26,503 containers, validator SDK 10.0.26100dxil.dll1.9):incompatible with the shader stagemain940d32fand with #2016 also applied the pair reaches 25,520, which is the number I quoted before — the arithmetic was right, only the dependency was wrong.
Re-checked after the rebase:
cargo test -p victory-shader --locked --lib248 passed, 3 ignored;clippy --workspace --all-targetswith-D warningsclean;rustfmt --checkonlower.rsshows the same 19 hunksmainalready has and no others.No game data is involved: counts and error text.
Written with an AI assistant.
@zed6000 on GitHub · 2026-11-25 04:54 UTC · original
Measured offline on the title's shaders (the method in #1247): merged onto main
940d32f(a clean merge) and compared program by program (victory translate --validate --list,shaders.rpf1.0.2.1, dxil.dll 1.8.2502).940d32fcargo test -p victory-shader --lib(RX 7900 XTX)34d0b4e)e198449)It is the same 735 programs in both cases: all of main's "Entry function performs some operation that is incompatible with the shader stage" rejections. The two PRs merge cleanly with each other, but they are alternatives that reach the result in different ways:
The offline counts can't tell which one renders as the console does. Where those samples relied on derivative-based mip selection, level 0 would always read the top mip. The choice probably comes down to that behaviour, or to the host-runtime question raised on #1065, rather than to the counts. Offline counts only; no program names or data.
@Marvisak on GitHub · 2026-11-25 09:17 UTC · original · edited 2026-11-26 01:20 UTC
Automated triage for the maintainers.
Proposed close (unchanged). The new commit only adds the missing closing brace of the test before
a_compute_shader_samples_at_level_zeroincrates/victory-shader/src/emit/lower.rs. The change itself is the same:sample_opmakes every implicit-LODimage_samplein a compute shader intosampleLevelat level 0. That changes what those programs sample. The synthetic mip test on this PR showed mips 1 and 3 read as 0. The new test only pinssample_op's return values, not sampling behaviour.What would change this verdict: evidence that the console's
image_samplein a compute stage reads level 0 (an ISA reference or a hardware measurement), not evidence that the validator accepts the module.This PR will be closed in 48 hours unless the author pushes a change that addresses this or a maintainer removes the label.
CI: passing (
check).Generated by Claude Code
@wwwwwwww3333333 on GitHub · 2026-11-26 03:06 UTC · original
For the choice between this, #1065 and #1237: #2999 adds a GPU test that tells them apart, an
[8, 8, 1]group whose lane quads (the console's) give level 1 and whose 2x2 tiles give level 3. On an RX 6750 XT, main, #1065 and #1237 read 3. #2999 reads 1 on every lane, on hardware and WARP, wave32 and wave64. This PR samples level 0 by design, so it would read 0 there (I did not run it with this test). I have not run the shader census on #2999.@DenRakEiw on GitHub · 2026-11-25 03:57 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib a_compute_shader_samples_at_level_zero— passedcargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean fix lowering compute shader samples at level 0 instead of implicit derivatives, plus matching shader feature flags. Looks good.
AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 04:04 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.146 passed / 0 failed / 2 ignored. Compute shader samples at level 0, not with derivatives (+2 tests; references 735 affected programs) — fixes a real-world translation regression class; mixed apps+shader, apps half Windows-only.
@fiestorra on GitHub · 2026-11-26 12:23 UTC · original
Accepted: without ISA evidence this is a semantic guess, and I am measuring it
The verdict is fair. What the PR has is "the validator refuses
sample.f32in a compute stage with functions incompatible with the shader stage (cs), and 735 programs of the pack hit it" — that says a choice must be made, not which one. Choosing level 0 is a guess, and if the console's instruction isimage_sample_lwith its own LOD operand,sampleLevelat 0 is worse than the guess: it is wrong data.The measurement I am running before touching this again: take the containers of the programs that fail, decode the image instruction's opcode field with our own decoder (
gfx10/opcodes.rshasimage_sample0x20,_l0x24,_lz0x27 and the rest), and count which one those programs actually carry._l, the lowering must use the LOD the instruction names, not zero, and this PR is the wrong shape: it would become a lowering that passes the LOD operand through, which is a different change._lz, then level 0 is what the console asks for and the evidence is the instruction encoding itself, with the count of programs, not the validator's verdict.image_samplein a compute stage, the ISA question becomes why the title has an instruction the hardware cannot run there, and I would not push a lowering until that is answered.Until one of those is measured, this branch stays as it is and the 48-hour close should take it. I would rather have it closed than merged on a guess.
Written with an AI assistant.
@fiestorra on GitHub · 2026-11-26 13:32 UTC · original
Closing it: the pack names its LOD explicitly, and this would guess for 1,838 instructions
I measured what I said I would, and the answer is that this branch should not land.
Decoding every container of the title's shader pack and counting the image-sample instruction each program actually carries, per stage:
image_sample_l_lz_c_lzSo the compute programs are not short of LOD information: the overwhelming majority carry
_l(an explicit LOD operand) or_lz(level zero), and the lowering already maps both tosampleLevel. What this branch changes is the 1,838 plainimage_sampleinstructions, and it changes them to level 0 on a guess. The count is the counter-argument: 1,838 is small enough to be a decoder gap or dead code and far too large to be safe to reinterpret silently.Three outcomes were possible when I started; the data points away from the one this branch assumed. If the plain form is a decoding gap (a variant our table does not carry), the fix is in the decoder and those instructions never reach the lowering. If it is what the console compiler emitted, the hardware has no derivative source there either, and what it does is an ISA question — not something to settle by making the validator accept the module.
I would rather close this than merge a semantic change on 1,838 instructions. The measurement that would reopen it: an ISA reference or a hardware test showing what plain
image_samplereads in a compute stage.Thanks for holding it — the 48-hour close was the right call.
Written with an AI assistant.
Pull request closed