Repository navigation
Conversation
…in Direct DXIL)
|
Two data points for the premise, RTX 3070 (Ampere), driver 616.56, Windows 11:
So the guard may not be what stops a hang on NVIDIA. It still covers Intel, where boykopovar/AnyPS5#26756 reports the ended-wave hang, and it covers waves that skip a barrier but stay alive. A test that hangs or fails without the guard on the RTX 5080 would show which case this PR fixes there. The update below runs this PR. Update, this PR's direct path: I sent the same test's early-exit shader (128 threads, the upper console wave ends before two
So on Ampere the direct path doesn't hang without the guard either. That is consistent with the HLSL result above. AI-assisted (Claude Code). Synthetic tests only. |
Port the recompiler's early-exit-safe `xcl_s_barrier` (0c02b87) to the direct DXIL translator. On RDNA2 `s_endpgm` removes the exiting wave from the workgroup's barrier count; a D3D12 group sync (`bar.sync 0` on NVIDIA) waits for every hardware wave, so one that ended (`s_endpgm`), ran out of its loop budget or diverged after a split-wave64 desync hung the SM. The direct path still lowered `s_barrier` to a bare GROUP_SYNC. Same policy as the HLSL path (`gpu/dxil/group_barrier.rs`): - Compute / Mesh groups of several hardware waves whose program has an `s_barrier`: a bounded arrival barrier on two group-shared words (`alive`: live hardware waves; `state`: generation:20 | arrived:12). Initialized in the entry block (whole group present), decremented once in the single exit block every way out of the program goes through (`s_endpgm`, end of code, exhausted loop budget). A wave that spins past 1 << 20 rounds leaves the count and only fences from then on. Opt-out: `XCL_SAFE_BARRIER=0`. - One hardware wave: a group-shared fence (nothing to wait for). - Kernel ABI: unchanged group sync. With LDS the words sit at 8189..8190 of the 32 KB block (the split form's exchange moves 2 words down; non-split LDS accesses clamp to 8188), so TGSM never exceeds the D3D12 limit; without LDS they get their own [2 x i32]. Programs without `s_barrier` are unchanged. TRANSLATOR_VERSION 6 -> 7, and `XCL_SAFE_BARRIER` joins the shader cache bypass list so toggling it never reuses a cached translation (HLSL too). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9648fe9 to
a6ace09
Compare
lewisnic94-max
left a comment
There was a problem hiding this comment.
[P1] Guest LDS address aliasing
On a6ace09, the clamp at line 80 maps guest LDS words 8188 and 8191 to the same word. After storing 11 and 22, all 64 threads read [22,22] in three RTX 3080 runs. The merge base returned [11,22]. Exposing only word 8191 restored the expected result while the barrier counters at 8189/8190 remained active.
Please preserve distinct guest addresses and add this two-word GPU readback test.
AI-assisted validation by Codex (GPT-6).
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
The direct translator dropped the clamp operand of sample, sample_b and sample_c (the implicit-LOD forms in a pixel shader) when the T# is a cube, so image_sample_cl / _b_cl / _c_cl on a cube sampled below the clamp. The HLSL path passes the clamp for cubes as for every other dimension (TextureCubeArray Sample / SampleBias / SampleCmp with a clamp, no offset), and the hardware applies the minimum LOD whatever the dimension. No validator rule is known to forbid a clamp on a cube. TRANSLATOR_VERSION 7 -> 8: the emitted containers change for these programs. Open PR xcl-dev#1793 also bumps TRANSLATOR_VERSION. Identical edits merge silently in git, so check the bump by hand at merge time: the later change takes the next free number, or the pipeline cache could serve containers of another translator under the same version. The test draws a pixel shader sampling a mipped cube at zero derivatives with clamp 2.0 through both backends, and builds the _b_cl and _c_cl cube forms on both backends (not drawn).
The HLSL path's image_sample_o in a pixel shader with an implicit LOD and a linear mip filter samples the two blended mips with SampleLevel, each moved by the offset in its own texels, and blends them by the LOD's fraction (20271d4). The direct translator still moved the coordinates once, by the offset over the size of the rounded LOD's mip, so the second mip read a texel off when the offset was half its texel or less. Port that form: LOD = the clamped implicit LOD (raised by the _cl clamp, capped at the view's last mip), mips floor(LOD) and the next one (capped too), each with its own texel offset, lerp by the fraction. It is taken under the same conditions read from the S#: MIP_FILTER linear, not anisotropic, and LOD >= 1 or min = mag filter; otherwise the single Sample as before. The texel-offset computation moves into a helper shared with the existing path. TRANSLATOR_VERSION 7 -> 8: the emitted containers change for these programs. Open PR xcl-dev#1793 also bumps TRANSLATOR_VERSION. Identical edits merge silently in git, so check the bump by hand at merge time: the later change takes the next free number, or the pipeline cache could serve containers of another translator under the same version. The existing test gpu_ps_image_sample_offset_implicit_lod_between_mips now also draws its pixel shader through the direct translator and expects the same result.
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Regression run for this PR: head main this PR: No device removals or crashes; 100 % of main's frames, 97 % of its peak commit. Not tested: the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
Summary
Makes the multi-wave Compute and Mesh
s_barrierin the Direct DXIL path safe against early-exiting waves on split-wave64 NVIDIA GPUs.#1741bounds the single-wave split exchanges. This change covers the remaining unguardedGROUP_SYNCins_barrier(lower.rs), related to#1727. A wave that exits early no longer leaves the others waiting at a barrier it will never reach.xcl_s_barrierlive-wave bookkeeping (0c02b87) to Direct DXIL (group_barrier.rs).XCL_SAFE_BARRIER=0to turn the guard off.TRANSLATOR_VERSIONto 7.XCL_SAFE_BARRIERto the translation cache-bypass list.#1741applies cleanly on top of this branch.Testing
Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, DXC 1.9.2602.17.
cargo test -p xcl --lib dxil::core_tests -- --test-threads=1: 17 passed, 0 failed, 1 ignoredXCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu_split_wave64 -- --test-threads=1: 5 passed, 0 failedcargo test -p xcl --lib gpu::dxil -- --test-threads=1: 89 passed, 0 failed, 1 ignoredcargo test -p xcl --lib -- --test-threads=1: 849 passed, 0 failed, 22 ignored (no new warnings)