Repository navigation
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
# Conflicts: # crates/xcl/src/gpu/recomp/tests.rs
|
Nothing has happened on this PR for 3 days, so it is marked |
util::mac_host(): the process runs under Wine on a Mac (CrossOver or the Game Porting Toolkit), where D3D12 is Apple's D3DMetal and the title's code runs through Rosetta 2. ntdll's wine_get_host_version names the host's system; "Darwin" is a Mac. XCL_MAC_HOST=1 / 0 overrides it. Nothing calls it yet. The Mac changes that need to know they run there (the barrier default, title textures on shared pages) build on it; until now only Ahmet-Dedeler's mac7 branch had it. Part of xcl-dev#258.
|
Please keep this open: |
… default xcl_s_barrier (the LDS spin barrier for multi-wave Compute / Mesh groups) starves the waves it waits for on D3DMetal: in a 1024-thread group in the split form, the one wave still working ran about 1000 times slower while the others spun, until the 2^20-poll bound gave up and the barrier let threads read LDS early (wrong output; a hang at world entry was reported in xcl-dev#258). D3DMetal's GroupMemoryBarrierWithGroupSync is correct in every case tried, including waves that already ran s_endpgm, LDS exchange across the two halves, barriers in loops and partial console waves. safe_barrier_wanted(): XCL_SAFE_BARRIER=0 / 1 decides; by default the spin barrier everywhere but on a macOS host (util::mac_host). It keeps deciding for both translators (the HLSL emitter and the direct translator's s_barrier) and for the compute build key, which read the variable on its own until now. translate_geometry's refusal of the split form's ES phase (xcl-dev#1727's pattern) is unchanged: only XCL_SAFE_BARRIER=0 lifts it (safe_barrier_set_off), on a Mac too. Windows is unchanged. gpu_s_barrier_1024_threads_waits_for_working_waves fails without this on the Mac (128 of 1024 threads read their partner's LDS word before it was written) and passes with it; with XCL_SAFE_BARRIER=1 it fails again. Part of xcl-dev#258.
c917219 to
e69da9d
Compare
|
Reworked on current |
|
Stacked on #2361 ( AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Conflicts in 25 files. Where the fork carried an early copy of an upstream change (the shader preparation PR, the copy back after a submission, the static sampler across branches, PR xcl-dev#1329), upstream's later form is kept. Fork-only changes are ported onto upstream's new code: - Shaders / xcl run: on a Mac compute pipelines are prepared in the title's process (default_workers), preparation is left out without DXC (outside a pipeline corpus), the launcher watch passes its handle to before_guest. The fork's MiB worker count is dropped for upstream's 231c4f1. - Recompiler: one safe_barrier_wanted() with the Mac default, also read by the direct DXIL translator and ComputePolicyKey; safe_barrier_set_off() keeps upstream's split-geometry refusal unless XCL_SAFE_BARRIER=0 (as in xcl-dev#2363). The translated cache keeps its emitter-switch key. - D3D12.X: stall-report hooks moved into SubmissionGate, the new dispatch signature and State::wait_for_ms; the Mac GPU-wait cap sits in take_expired_gpu_wait (a capped wait now stops the title like any timed-out wait unless XCL_WAIT_TIMEOUT_CONTINUE=1); late-release ring and native-host Release on upstream's res_release (forget_released_as); level tiles on upstream's title-queue upload path and with_title_bytes. - sparse.rs is upstream's file plus the fork's stall report line. Test title built from this tree, run under CrossOver 26.3 / D3DMetal (bottle xcl-agent-1, xcl run <game> -- --hello): 50 passed, failures 0. Full unit suite not run.
Stacked on #2361; only the top commit belongs here.
On a macOS host (CrossOver / D3DMetal), multi-wave Compute and Mesh
s_barriers now use the nativeGroupMemoryBarrierWithGroupSyncby default instead of the emulated spin barrierxcl_s_barrier. On D3DMetal, in a 1024-thread group in the split form, the waves spinning inxcl_s_barrierstarve the one wave still working (its loop ran about 1000 times slower) until the spin's 2^20-poll bound gives up and threads read LDS before it is written: wrong output, or the hang at world entry reported in #258. The native barrier was correct in every case I tried, including waves that already rans_endpgm, LDS exchange across the split-wave64 halves, barriers in loops and partial console waves. Windows keeps the spin barrier.The default goes into
main'ssafe_barrier_wanted(), soXCL_SAFE_BARRIERstill decides the same way for both translators. The refusal of the split form's geometry ES phase (#1727's pattern) is unchanged on a Mac: onlyXCL_SAFE_BARRIER=0lifts it, as onmain.Part of #258.
What is in it
crates/xcl/src/gpu/recomp/emit.rs:safe_barrier_wanted().XCL_SAFE_BARRIER=0/1decides; by default the spin barrier everywhere except on a macOS host (util::mac_host, Memory: detect a macOS host under Wine (mac_host) #2361). Newsafe_barrier_set_off(): whetherXCL_SAFE_BARRIER=0is set.crates/xcl/src/gpu/recomp/pso.rs: the compute build key'ssafe_barriercomes fromsafe_barrier_wanted(). It read the variable on its own, so on a Mac a default run and anXCL_SAFE_BARRIER=1run would have shared keys.crates/xcl/src/gpu/dxil/kernel.rs:translate_geometryrefuses the split ES phase unlesssafe_barrier_set_off(), which ismain's behaviour. Its two tests (lower_mem.rs,geometry_tests.rs) ask the same.crates/xcl/src/gpu/recomp/tests.rs: new GPU testgpu_s_barrier_1024_threads_waits_for_working_waves(1024 threads; every wave runs 1000v_readfirstlanes, then reads the LDS word of the farthest wave after the barrier). Two tests that read the variable themselves now asksafe_barrier_wanted().Tested
x86_64-pc-windows-gnu, debug, DXC 1.9.2609; heade69da9don Memory: detect a macOS host under Wine (mac_host) #2361's69c0b04onmain9dfbe3e. Base:69c0b04with only this PR'stests.rs.barrierin its name, all ofgpu::dxil::geometry_testsandgpu::dxil::robustness_tests,geometry_export_rejected, the compute build key tests, and the two that look forxcl_s_barrier()in the HLSL. Each ran in its own process (<lib test exe> --exact <test> --test-threads=1):XCL_SAFE_BARRIER=1XCL_SAFE_BARRIER=0XCL_SAFE_BARRIER=0gpu_s_barrier_1024_threads_waits_for_working_waves: fails on the base (128 threads read their partner's LDS word before it was written); passes with this PR, and withXCL_SAFE_BARRIER=0on either; fails withXCL_SAFE_BARRIER=1(128 threads).gpu::dxil::ops_tests::groupshared_barrier_and_atomics_runfails in all five runs on the same assertion (ops_tests.rs:398); this switch does not reach it.programs_left_to_the_hlsl_path_for_their_barrier_translate_and_compile(XCL_SAMPLE_BARRIER). No SKIPPED tests.Regression run
scripts/smoke.ps1on. On Windowsmac_host()is false, so the default there is unchanged.Not tested
XCL_SAFE_BARRIER(Shaders: translations made with XCL_SAFE_BARRIER=0 are cached and reused by later runs #1409); Shaders: XCL_SAFE_BARRIER turns the translation caches off (#1409) #1413 turns it off only while the variable is set. So on a Mac, switching between the default andXCL_SAFE_BARRIER=1can reuse the other's translations until one of them lands.AI use
main, ran the tests above and wrote this description. I checked it before posting.