Repository navigation
shader/lower: preserve builder_bounds root header size guard when WIDE loads are enabled (D3D12-SHADER-WIDE-BUILDER-BOUNDS) - #2860
Conversation
…E loads are enabled
|
Measured on Windows 11, cargo 1.98.1, Rust 1.98.1, with the Windows SDK's The control is So the early return in One note for the record:
No game files and no GPU were needed for this check; the validator is the Windows SDK's Verified on the pull request's head One more note, measured on the same machine: on Windows this pull request's head is red in four tests - Those four are the tests that run the DXIL validator, and they are red on The fix for that is #2864 (one line's worth of name table, plus its own test): with it the four are green on the same machine, and the whole crate reads 410 tests OK, 0 failed, 5 ignored. Worth knowing before a Windows reviewer sees the red, and worth saying that the two are independent. No game files and no GPU were needed for this check; the validator is the Windows SDK's |
|
RUN (native Windows 10 + RTX 5070 verification; #2857, #2860, and #2862 merged cleanly together onto
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver AI-assisted: Antigravity |
KelboLive
left a comment
There was a problem hiding this comment.
Verified: main's WIDE fast path does skip the builder_bounds clamp — git show origin/main:.../lower.rs has the unconditional if Self::wide_loads() { … return } at the same site, so an offset == 4 header-size load never reaches IULT (1 << 20). The fix's !(size && root) is the minimal correct exclusion, and count == 1 is already implied by the size predicate, so no multi-dword or bulk path regresses. leonida-shader is 406 passed / 5 ignored here, and merge-tree against current main (3e7b34a52, not the PR's base) is clean.
The guard is pinned: reverting it to main's if Self::wide_loads() fails the new test with exactly the signature in the body (left: Inst(48), right: Inst(50)).
One nit, and it is environment-dependent: the new test asserts the clamp without pinning builder_bounds(). With LEONIDA_BVH_BOUNDS=0 in the environment it fails on this branch too (44 vs 46), so a developer running the suite with that switch set gets a red test on correct code. Set/force the flag in the test (the #[cfg(test)] thread-local override the diff already adds is the natural place) or gate the assertion on it.
VERIFY-2860 — Linux, Rust 1.98.1 (the pinned toolchain), no GPU device, no game filesVerdict: PASS. The half-line condition is what carries the fix, and the new test pins both the value and the instruction sequence. Head 1. The changeWhen the shader optimisation's // the scalar path, further down
let mask = self.s.m.i8(1);
let (u, al) = (self.s.m.undef(self.s.t.i32), self.s.m.i32(4));
… // cmp(IULT, x, 1 << 20) + select(sane, x, 0)The pull request keeps the structure header's size load on the scalar path, so the if Self::wide_loads() && !(size && root) {
2. Red and green, and the discrimination
With only The two instruction ids differ by exactly the two instructions the clamp is made of. 3. What the new test pins
— lowers it four ways (offset 4 and offset 8, wide and scalar), and asserts three things:
The last one is what makes the test worth having: it distinguishes "the clamp is there" from "the wide path happens to produce the same number here". To switch WIDE on and off inside a test, the pull request adds a test-only override: #[cfg(test)]
thread_local! {
static TEST_WIDE_LOADS: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) };
}read at the top of 4. What I did not check
AI-assisted: MiniMax M3.1 Flash. |
Claimed in the coordination issue as:
D3D12-SHADER-WIDE-BUILDER-BOUNDS(claim comment)What and why
Preserve the
builder_boundssanity clamp (x < (1 << 20) ? x : 0) on 1-dword spilled root SRV header size loads (offset == 4) whenbitcode::opt::WIDE(LEONIDA_SHADER_OPTbit 64) is enabled.main: Ind3d12/crates/leonida-shader/src/emit/lower.rs(Lower::smem),if Self::wide_loads()returns early after callingself.raw_dwords(h, addr, count), completely skipping theif size && rootsanity clamp 20 lines below.if Self::wide_loads() && !(size && root)(1-line production change). All multi-dword loads and non-header 1-dword loads still takeraw_dwords; only the 1-dword builder header size load falls through to apply theIULT (1 << 20)clamp.d3d12/crates/leonida-shader/src/emit/lower.rs:8582–8625) + red→green unit test inleonida-shader+ MEASURED 300 s in-game gate on exact PR head60ef5bd2e.Tested
python3 -I scripts/check_no_game_data.py d3d12/crates/leonida-shader/src/emit/lower.rs→ exit 0.cargo test --locked -p leonida-shader:origin/main(only the#[cfg(test)]hook + new test applied, no production change):60ef5bd2e(rebased ontocd73ddab7):docs/game_gate.md) on exact PR head60ef5bd2e(leonida.exe--profile play --features mimalloc,dlss,diagnostics, Series S + DLSS Quality 1280×720 → 1920×1080):310.97 s(world_at_s = 99.55 s,>= 300 srequired)world + 60 sto stop):3,320presented frames (3,429total world presents),15.31median FPS,106.10 msp95 frame time (15.55end-window median FPS,4,354.5median draws/frame)6.597 s(<= 10.0 srequired)6,645 MiB(<= 7,400 MiBguard)0device losses,0crashes/faults,0panics,0kernelNVRM: XiderrorsGPUs tested: NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Arch Linux (Wine 11.22 + VKD3D-Proton 3.2.0).
AI-assisted: yes (authored by Gemini 4 Neon; audited and approved in a separate independent review pass by Gemini 4 Neon).
Checklist
main(cd73ddab7) and merges cleanly.check_no_game_data.pyclean).docs/design.md(n/a — restores existingbuilder_boundsguard underWIDE).60ef5bd2e).