Repository navigation
Conversation
On top of integrate/shaders2. Conflicts: - lower.rs: Marvisak#265's scratch() stays; flat() takes Marvisak#294's root SRV/UAV doc. - valu_tests.rs: the shader side's test helpers (emit with a Target) stay; Marvisak#294's two root UAV tests are appended. - shader_cache.rs: both new tests kept (Marvisak#320 wave-size key, Marvisak#358 cache that cannot keep an entry). - HostShader initialisers in scratch_tests.rs and valu_tests.rs get root_uavs; emit() calls in tests get Target::ANY. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
|
A limit of this PR, confirmed by a probe while reviewing the open shader PRs with the same scrutiny (RTX 5070): when a scratch address cannot be bounded from the code, the per-lane array is 4 KiB, and accesses past it read 0 and drop writes. A store and load of 37 through a run-time address of 8192 returns 0, although a program with a larger scratch allocation would be within its bounds there (the RDNA 2 ISA bounds scratch by the allocation's size). The description says the size is a From synthetic probes only; I have no copy of the title. |
7463484 to
a5e73f4
Compare
scratch_load_* and scratch_store_* were refused ("flat memory"), so any
program that keeps a local array with a dynamic index, or spills to
memory, failed to translate and its draws or dispatches were dropped.
Each lane's private memory is now an alloca of i32 in the entry block, as
DXC makes local arrays. A FLAT scratch address (a VGPR, an SGPR or
neither, plus the 12-bit signed offset) is a byte offset into the lane's
own memory: the hardware interleaves the lanes' dwords itself (RDNA 2 ISA,
"Scratch"; LLVM AMDGPUUsage, "Private Segment"; Mesa ACO uses these
instructions on GFX9+ the same way), so no lane index enters the address.
Lowered: dword x1-x4 loads and stores, ubyte/sbyte/ushort/sshort loads,
byte/short stores, and the _d16 / _d16_hi forms (one half of the VGPR
written, the other kept; stores of the high half). Loads write under the
lane guard; stores run under it.
The size comes from the code: an upper bound of every scratch address
from the instructions computing it (constants through and, shifts, adds,
multiplies, selects, bfe), plus the access width. Where an address has no
such bound (a loaded or loop-carried index) the array is 4 KiB per lane,
marked as a shortcut: the program metadata read so far holds no scratch
size. At most 64 KiB, the D3D11 limit of indexable temporaries. Accesses
past the end read 0 and drop writes; the index is checked, never wrapped.
The decoder read GFX10 scratch with saddr 0x7F (EXEC_HI, LLVM's "ST" mode:
neither address register) as an SGPR base of exec_hi; it now has none.
The bitcode writer gains alloca (INST_ALLOCA, explicit type).
Still refused: generic flat_* (an aperture address that may be private,
shared or global memory), MUBUF access through a scratch descriptor (not
told apart from a buffer the title bound), and scratch loads into LDS.
Tests (emit/scratch_tests.rs) run hand-assembled 64-lane compute programs
on the hardware GPU and WARP and compare every lane with values computed
on the CPU: a per-lane array indexed by another lane's index, x2/x3/x4
accesses through an SGPR base partly and wholly out of range and with a
wrapping offset, byte and short loads with sign extension and D16 halves,
sub-dword stores, and a store under a lane guard false for some or all
lanes. Each program also passes dxil.dll validation. Unit tests cover the
size bound and generic flat memory staying refused. On main every GPU test
fails in lower with "flat memory".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On main at 8d23f07 the test target of victory-shader does not compile: Marvisak#612 gave the test helper `lowers` a second argument (rsrc2) and Marvisak#117's `scalar_bit_tests_lower`, merged beside it, still calls it with one. The call passes 0, as the helper's other callers without group ids do. Not part of the scratch-memory change; it is here so this branch's tests can run. Drop it when main has the same fix. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
a5e73f4 to
e543a41
Compare
|
Tested head Merged onto current There's no text conflict, so GitHub still shows the PR as mergeable, but merging it as it is would break With
AI-assisted (Claude Code). |
|
The test-build issue reported on #164 also affected this branch. Fixed at AI-assisted (Codex). |
|
CI exited with Local verification: three consecutive runs of the full shader library suite with AI-assisted (Codex). |
d9c04c6 to
964e3ad
Compare
|
Re-tested the new head
AI-assisted (Claude Code). |
|
Independent verification on Windows 11 + NVIDIA RTX 3070 (Ampere, Wave32, Rust 1.98.1) at head
|
|
Thank you for this, @r4tedx! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/34. You're credited as the author there. This pull request stays the original. Test results
|
The two reference draws create a host and draw on the hardware adapter and WARP without `valu_tests::ONE_AT_A_TIME`, so on CI's WARP adapter they could dispatch at the same time as the other GPU tests; the run on 6ddbdfc ended with the victory-shader test process dying with STATUS_ACCESS_VIOLATION and no failing test named, the crash seen before on Marvisak#704, Marvisak#160 and Marvisak#265 for that reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
|
Closing this. The change is not wrong; this title does not use it, and bringing it up to The numbers. Local title data (v1.0.2.1, the main shader archive), offline, CPU only; counts and reasons only.
Limits. The pass covers that one archive, not shaders anywhere else in the title, and it looked for the FLAT
Thank you @DeerSilver and @Yaekai for the runs on AI-assisted |
The two reference draws create a host and draw on the hardware adapter and WARP without `valu_tests::ONE_AT_A_TIME`, so on CI's WARP adapter they could dispatch at the same time as the other GPU tests; the run on 6ddbdfc ended with the victory-shader test process dying with STATUS_ACCESS_VIOLATION and no failing test named, the crash seen before on Marvisak#704, Marvisak#160 and Marvisak#265 for that reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e array) into the integration Kept our worklist liveness in bitcode.rs and gave it the new Alloca op; the scratch helpers sit beside inline_f16; the scratch test fills HostShader's stride_table. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
Measured on the title's shaders (by a tester)
EduAzevedo ran
victory translate --jobs 8 --listover the retail shaders (v1.0.2.1, 26,148 programs) onmaind2a4baeand on this head7463484, compared program by program (result): 0 programs gained, 0 programs lost. No refusal reason changes.So this PR does not change what translates in this title today. It adds coverage and is tested on synthetic programs only; it can wait behind PRs that unblock programs the title uses.
What
scratch_load_*andscratch_store_*were refused ("flat memory"), so a program that keeps a local array with a dynamic index, or spills to memory, failed to translate and its draws or dispatches were dropped. No open PR covers private memory.allocaofi32in the entry block, as DXC makes local arrays. A FLAT scratch address (a VGPR, an SGPR or neither, plus the 12-bit signed offset) is a byte offset into the lane's own memory; the hardware interleaves the lanes itself, so no lane index enters the address (RDNA 2 ISA, "Scratch"; LLVM AMDGPUUsage, "Private Segment"; Mesa's ACO uses these instructions the same way)._d16/_d16_hiforms (one half of the VGPR written, the other kept). Loads write under the lane guard; stores run under it.bfe, min/max), plus the access width. Where an address has no such bound (a loaded or loop-carried index) the array is 4 KiB per lane, marked as ashortcut:. At most 64 KiB. Accesses past the end read 0 and drop writes; the index is checked, never wrapped.saddr0x7F (LLVM's "ST" mode: neither address register) was read as an SGPR base ofexec_hi; it now has none.alloca.Still refused, each with its reason: generic
flat_*(the address may be private, shared or global memory), MUBUF access through a scratch descriptor (cannot be told apart from a buffer the title bound), scratch loads into LDS.Not verified
No game files were used, and this matters more here than usual:
scratch_*, this PR does not help those shaders.s_getpc_b64, a load from the global information table,s_setreg FLAT_SCR) run throughresource::trackfails with "an address from a root parameter that is no address", so programs with that prologue are still refused before they reach this code. Someone with the title's shaders can tell fromvictory translate --listwhat scratch shaders now stop at; a follow-up could skip tracking for loads whose results only feedFLAT_SCR.Tested
Windows 11, NVIDIA RTX 5070 and WARP, synthetic only. Hand-assembled 64-lane compute programs, every lane compared with values computed on the CPU, each also through
dxil.dll:With
main'slower.rs,fields.rsandbitcode.rsall four fail withUnsupported { what: "flat memory" }. Unit tests cover the size bound (exact, fallback, maximum) and generic flat staying refused.cargo test -p victory-shader: 75 passed. Rebased ontomain8d23f07(heade543a41): #104 moved the writer's liveness pass intoModule::live, soallocais now one arm of its operand visitor; #117's and #612's tests sit beside this PR's inemit/lower.rs. 94 passed, 1 ignored, on the RTX 5070.The second commit (
e543a41) is not part of this change. Onmain8d23f07the test target ofvictory-shaderdoes not compile (issue #719): #612 gave the test helperlowersa second argument and #117'sscalar_bit_tests_lowerstill calls it with one. The commit passes 0 there so this branch's tests can run; it goes away whenmainhas the fix.cargo clippy -p victory-shader --all-targets: nothing new.cargo xtask policy: ok.Does not touch
fn image,fn ds,fn bufferor wave/lane code; a trial merge with #54, #160, #164, #189 and #192 is clean.The title was not used in these tests. AI-assisted.
🤖 Generated with Claude Code