perf(shader): span single-wave wave64 compute by default after a uniformity check #7922

Merged
ThatsLeo merged 6 commits from upstream-pr/7922 into main 2026-11-02 10:22:27 +00:00
ThatsLeo commented 2026-10-19 14:08:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-19T14:08:00Z.


What

#5405 runs a single-wave wave64 compute program at one guest lane per invocation, across two full 32-lane host subgroups. It is off unless APS5_SPANNED_WAVE is set, because its cross-lane exchanges use workgroup barriers, and the emitter could not tell whether every invocation reaches them: its debt entry lists a manual spirv-dis scan as the only check. This PR adds that check and turns the layout on by default.

  • SpannedBarrierInDivergentFlow (SpirvSpannedUniformity.cpp) runs on every spanned module after emission. It marks the values that can differ between the invocations of a wave, iterating until nothing changes:

    • lane and subgroup IDs (LocalInvocationId/Index, GlobalInvocationId, SubgroupId, SubgroupLocalInvocationId, the subgroup masks);
    • atomic and subgroup-operation results, and function parameters;
    • loads of private or function variables stored in per-invocation control flow;
    • loads at a uniform address of memory the program writes, unless it is workgroup memory that a barrier fences on every path since the last write. Storage buffers, uniform buffers and device addresses all reach guest memory, so a write through any of them counts for all three;
    • image reads, when the program writes an image;
    • phis inside, or at the merge of, a construct such a value decides;
    • anything computed from these.

    A selection is divergent when its condition is marked. A loop is divergent when its header condition is marked, or when it can be left from per-invocation control flow. The construct's blocks are read off the dominator tree: the header's subtree minus the merge's. A construct is also divergent when a per-invocation branch without a merge instruction leaves it or continues its loop. When a divergent construct returns or kills, everything reachable from its merge is divergent; when it branches past its merge, as a continue does, the merge's subtree is.

  • If an OpControlBarrier, or a call that reaches one, sits in a divergent construct, Emit throws SpannedWaveUnsupported. Recompile already catches that and emits the program at two lanes per invocation, so a rejected program runs as on main. The check runs before SpirvEmitInfo::fullSubgroups is set, so the fallback is not created with REQUIRE_FULL_SUBGROUPS.

  • VulkanDevice turns spanning on wherever it was available under the switch (computeFullSubgroups with 32-lane compute subgroups). APS5_NO_SPANNED_WAVE turns it off; APS5_SPANNED_WAVE is gone.

  • The analysis runs until nothing changes, so it cannot stop early and throw. It is skipped for a module with no OpControlBarrier, and each function's flow graph is built once.

  • Opcode, Result and VisitIdOperands move unchanged from SpirvSpecialization.cpp to SpirvInstructionOperands.hpp, templated on the instruction container, so both passes share the operand table. SpirvSpecialization.cpp keeps main's arena-backed Instruction.

  • Guarded SRT reads. A spanned wave does not stop an invocation after a fault (bdaStopsInvocations is false), so each later guarded read of a poisoned pointer wrote its record over the first. agc_driver_guarded_null_pointer then reported the second dword of an s_load_dwordx2 (address=0x4). Where invocations do not stop, the record is now written with a compare-exchange against 0, as record_bda_fault already does, so the first fault is kept. Programs whose invocations stop keep the atomic store.

  • The debt entry states what the check proves and what it does not: writes by other dispatches or queues, and the unexplained one-barrier ballot loss. spanned_uniformity_tests links libc on MinGW, as spirv_validator_exit_tests does.

Tested

Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Fedora 44, Linux 7.2.10, GCC 16.2.1, Release.

  • spanned_uniformity (new) builds twenty-one modules by hand:

    • rejected: a barrier under a lane comparison; a barrier in a loop a lane value leaves; a call reaching a barrier under a lane comparison; a barrier after a per-lane return; a barrier after a per-lane continue, with or without a selection merge; a barrier under a buffer word read after a store through a device address; a barrier under a phi joining a per-lane selection; a barrier under a variable stored on one side of a per-lane selection; a barrier under an atomic result; a barrier under a workgroup word read at a lane index; a barrier under a workgroup word read after a store with no barrier between, or with a store on one path past the barrier;
    • kept: the same barriers under a constant comparison, after a uniform return or a uniform unmerged continue, under a buffer word the program never writes, in a uniform loop after a per-lane selection, under a workgroup word read at a uniform index, and under one read after a store and a barrier.

    With LocalInvocationIndex removed from the per-invocation built-ins, the lane-dependent cases fail. Without the fence, early-exit, guest-memory and unmerged-continue rules, the cases they cover fail.

  • Stray's compute requests: all 1,751 (PPSA02101) replayed through agc_shader_replay with a 32-lane target and spanning on, using a local switch that is not part of this PR. 1,117 programs span, the same with the guest-memory and unmerged-continue rules. The fence rule sends 13 programs back to two lanes per invocation that spanned without it (1,130). Stray's heaviest programs, 0x2011300000 and 0x200e390000, still span. A Python prototype of the first analysis agreed with it.

  • ctest on main 3bb15be09 + this PR:

    • Arc: 1617 of 1623 pass. The six failures fail the same way with APS5_NO_SPANNED_WAVE=1: application_heap_scripting, application_heap_lazy, agc_driver_image_table_vouched_lookups, agc_driver_guest_memory_lifetime, agc_driver_multisample_retirement, plus guest_kernel_fcntl, which passes alone.
    • lavapipe: 1621 of 1623 pass. Only the two application_heap tests fail.
    • agc_driver_lds_mask_waterfall still runs both modes and still spans.
    • After rebasing onto main eda7477ac, with #8004 on top: see #8004. The Arc and lavapipe failures also fail on main, and the focused tests under the validation layer show no VUID- error. agc_driver_guarded_null_pointer, new on main, failed with spanning on before the guarded-read fix and passes after it, 5 of 5 runs.
  • Stray, frames 20 to 50 of the boot (APS5_TRACE_FRAMES=20:30, 3840x2160).

    • Builds: main + #7811, against main + this PR + #7811. Stray stops on main without #7811 (#7693).
    • Runs: three interleaved rounds after one warm run each. Every capture started below 55 °C, because this laptop throttles the GPU at 97–99 °C otherwise.
    • Commit of the PR captures: 128b8c1f8 is this PR's first push. The final head differs from it only in the helper header's template parameters.
GPU busy per present (ms) frame p50 (ms)
main + #7811 308.9 / 313.0 / 288.3 (mean 303.4) 451.2 / 464.2 / 432.6 (mean 449.3)
this PR + #7811 180.7 / 165.1 / 173.5 (mean 173.1) 334.9 / 324.6 / 335.0 (mean 331.5)

trace_digest.py, first capture of each:

main: frames 20:30 from present 20: 30 presents, frame p50 451.2 / p90 472.1 / p99 586.3 / max 586.3 ms, GPU busy 308.9 ms per present
PR:   frames 20:30 from present 20: 30 presents, frame p50 334.9 / p90 347.4 / p99 418.7 / max 418.7 ms, GPU busy 180.7 ms per present

aps5-summary.jsonl lines, main + #7811:

{"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13716.468},"presents":30,"frame_ms":{"p50":451.183,"p90":472.083,"p99":586.282,"max":586.282},"gpu_busy_ms_per_present":308.934,"worker_busy_pct":{"queue worker 0x0":96.582,"queue worker 0x20":97.047},"top_phases_ms_per_frame":{"Driver.Packet":882.201,"Driver.Packet.memory_wait":418.127,"Driver.Packet.device_lock":208.359,"Driver.Packet.prepare_memory":138.870,"Graphics.Draw":127.060,"Graphics.Draw.draw_and_resource_release":126.577,"Recorder.Submit":114.858,"Driver.Packet.dispatch":68.164},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-938192.json.gz"}
{"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13995.080},"presents":30,"frame_ms":{"p50":464.151,"p90":479.730,"p99":509.222,"max":509.222},"gpu_busy_ms_per_present":312.990,"worker_busy_pct":{"queue worker 0x0":96.781,"queue worker 0x20":96.913},"top_phases_ms_per_frame":{"Driver.Packet":900.975,"Driver.Packet.memory_wait":428.313,"Driver.Packet.device_lock":205.633,"Driver.Packet.prepare_memory":148.125,"Graphics.Draw":128.606,"Graphics.Draw.draw_and_resource_release":128.151,"Recorder.Submit":107.255,"Driver.Packet.dispatch":72.186},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-940261.json.gz"}
{"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13088.121},"presents":30,"frame_ms":{"p50":432.628,"p90":450.240,"p99":530.799,"max":530.799},"gpu_busy_ms_per_present":288.316,"worker_busy_pct":{"queue worker 0x0":96.056,"queue worker 0x20":96.773},"top_phases_ms_per_frame":{"Driver.Packet":837.222,"Driver.Packet.memory_wait":395.185,"Driver.Packet.device_lock":213.902,"Graphics.Draw":129.895,"Graphics.Draw.draw_and_resource_release":129.422,"Recorder.Submit":114.352,"Driver.Packet.prepare_memory":110.092,"Driver.Packet.dispatch":71.040},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-942091.json.gz"}

This PR + #7811:

{"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10177.000},"presents":30,"frame_ms":{"p50":334.856,"p90":347.438,"p99":418.694,"max":418.694},"gpu_busy_ms_per_present":180.675,"worker_busy_pct":{"queue worker 0x0":95.362,"queue worker 0x20":96.360},"top_phases_ms_per_frame":{"Driver.Packet":646.122,"Driver.Packet.memory_wait":298.561,"Driver.Packet.device_lock":193.196,"Graphics.Draw":116.729,"Graphics.Draw.draw_and_resource_release":116.290,"Recorder.Submit":108.061,"Driver.Packet.dispatch":69.570,"Driver.Dispatch":64.534},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-939198.json.gz"}
{"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":9748.101},"presents":30,"frame_ms":{"p50":324.600,"p90":332.281,"p99":340.520,"max":340.520},"gpu_busy_ms_per_present":165.056,"worker_busy_pct":{"queue worker 0x0":95.368,"queue worker 0x20":97.098},"top_phases_ms_per_frame":{"Driver.Packet":622.706,"Driver.Packet.memory_wait":285.025,"Driver.Packet.device_lock":182.915,"Graphics.Draw":113.762,"Graphics.Draw.draw_and_resource_release":113.340,"Recorder.Submit":97.834,"Driver.Packet.dispatch":72.730,"Driver.Dispatch":68.024},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-941263.json.gz"}
{"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10014.061},"presents":30,"frame_ms":{"p50":334.968,"p90":340.775,"p99":354.031,"max":354.031},"gpu_busy_ms_per_present":173.489,"worker_busy_pct":{"queue worker 0x0":95.324,"queue worker 0x20":96.938},"top_phases_ms_per_frame":{"Driver.Packet":639.070,"Driver.Packet.memory_wait":298.617,"Driver.Packet.device_lock":189.827,"Graphics.Draw":115.684,"Graphics.Draw.draw_and_resource_release":115.257,"Recorder.Submit":104.396,"Driver.Packet.dispatch":72.309,"Driver.Dispatch":68.740},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-943100.json.gz"}

Traces, digests and summaries: ThatsLeo:evidence/spanned-default.

The fence and early-exit rules on Stray. Same scene and machine, main 559f35d68 + this PR (without, then with, the second commit) + #8004 + #7811. One warm run each, then four interleaved rounds. After a battery drain this laptop idled at 56 °C, so every capture started below 58 °C, not 55.

GPU busy per present (ms) frame p50 (ms)
without the rules 111.5 / 113.9 / 117.5 / 116.3 (mean 114.8) 276.6 / 271.6 / 285.3 / 280.8 (mean 278.6)
with the rules 115.0 / 114.6 / 114.0 / 112.7 (mean 114.1) 268.9 / 279.8 / 272.2 / 278.3 (mean 274.8)

The difference is inside the spread.

without: frames 20:30 from present 20: 30 presents, frame p50 276.6 / p90 287.9 / p99 294.7 / max 294.7 ms, GPU busy 111.5 ms per present
with:    frames 20:30 from present 20: 30 presents, frame p50 268.9 / p90 282.2 / p99 285.1 / max 285.1 ms, GPU busy 115.0 ms per present
aps5-summary.jsonl lines
{"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8273.368},"presents":30,"frame_ms":{"p50":276.642,"p90":287.880,"p99":294.712,"max":294.712},"gpu_busy_ms_per_present":111.544,"worker_busy_pct":{"queue worker 0x0":97.191,"queue worker 0x20":97.311},"top_phases_ms_per_frame":{"Driver.Packet":532.809,"Driver.Packet.memory_wait":229.082,"Driver.Packet.device_lock":165.884,"Graphics.Draw":114.639,"Graphics.Draw.draw_and_resource_release":114.308,"Driver.Packet.dispatch":85.599,"Driver.Dispatch":59.489,"Recorder.Submit":48.015},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-108138.json.gz"}
{"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8223.104},"presents":30,"frame_ms":{"p50":271.596,"p90":287.082,"p99":292.329,"max":292.329},"gpu_busy_ms_per_present":113.868,"worker_busy_pct":{"queue worker 0x0":97.306,"queue worker 0x20":96.759},"top_phases_ms_per_frame":{"Driver.Packet":529.169,"Driver.Packet.memory_wait":216.791,"Driver.Packet.device_lock":164.966,"Graphics.Draw":115.568,"Graphics.Draw.draw_and_resource_release":115.240,"Driver.Packet.dispatch":94.578,"Driver.Dispatch":63.130,"Vulkan.Dispatch":47.380},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-113059.json.gz"}
{"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8561.265},"presents":30,"frame_ms":{"p50":285.252,"p90":299.190,"p99":305.800,"max":305.800},"gpu_busy_ms_per_present":117.525,"worker_busy_pct":{"queue worker 0x0":97.291,"queue worker 0x20":97.585},"top_phases_ms_per_frame":{"Driver.Packet":552.832,"Driver.Packet.memory_wait":224.121,"Driver.Packet.device_lock":164.165,"Graphics.Draw":115.802,"Graphics.Draw.draw_and_resource_release":115.458,"Driver.Packet.dispatch":109.259,"Driver.Dispatch":72.453,"Vulkan.Dispatch":47.232},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-116244.json.gz"}
{"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8493.756},"presents":30,"frame_ms":{"p50":280.819,"p90":298.458,"p99":301.837,"max":301.837},"gpu_busy_ms_per_present":116.292,"worker_busy_pct":{"queue worker 0x0":97.613,"queue worker 0x20":97.336},"top_phases_ms_per_frame":{"Driver.Packet":549.554,"Driver.Packet.memory_wait":230.652,"Driver.Packet.device_lock":163.134,"Graphics.Draw":115.009,"Graphics.Draw.draw_and_resource_release":114.660,"Driver.Packet.dispatch":100.944,"Driver.Dispatch":72.601,"Recorder.Submit":49.593},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-119633.json.gz"}
{"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8094.501},"presents":30,"frame_ms":{"p50":268.921,"p90":282.204,"p99":285.051,"max":285.051},"gpu_busy_ms_per_present":115.018,"worker_busy_pct":{"queue worker 0x0":97.361,"queue worker 0x20":96.984},"top_phases_ms_per_frame":{"Driver.Packet":522.612,"Driver.Packet.memory_wait":216.751,"Driver.Packet.device_lock":163.550,"Graphics.Draw":115.508,"Graphics.Draw.draw_and_resource_release":115.189,"Driver.Packet.dispatch":89.641,"Driver.Dispatch":54.537,"Recorder.Submit":47.263},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-110545.json.gz"}
{"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8388.481},"presents":30,"frame_ms":{"p50":279.752,"p90":289.914,"p99":307.567,"max":307.567},"gpu_busy_ms_per_present":114.558,"worker_busy_pct":{"queue worker 0x0":97.228,"queue worker 0x20":97.175},"top_phases_ms_per_frame":{"Driver.Packet":541.081,"Driver.Packet.memory_wait":229.579,"Driver.Packet.device_lock":164.570,"Graphics.Draw":115.558,"Graphics.Draw.draw_and_resource_release":115.217,"Driver.Packet.dispatch":97.113,"Driver.Dispatch":67.063,"Recorder.Submit":47.239},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-114700.json.gz"}
{"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8163.070},"presents":30,"frame_ms":{"p50":272.213,"p90":284.784,"p99":291.836,"max":291.836},"gpu_busy_ms_per_present":114.038,"worker_busy_pct":{"queue worker 0x0":97.290,"queue worker 0x20":96.736},"top_phases_ms_per_frame":{"Driver.Packet":524.954,"Driver.Packet.memory_wait":218.094,"Driver.Packet.device_lock":160.249,"Graphics.Draw":114.762,"Graphics.Draw.draw_and_resource_release":114.432,"Driver.Packet.dispatch":88.844,"Driver.Dispatch":56.043,"Recorder.Submit":46.681},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-117978.json.gz"}
{"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8315.173},"presents":30,"frame_ms":{"p50":278.251,"p90":288.303,"p99":290.344,"max":290.344},"gpu_busy_ms_per_present":112.656,"worker_busy_pct":{"queue worker 0x0":97.424,"queue worker 0x20":97.292},"top_phases_ms_per_frame":{"Driver.Packet":532.199,"Driver.Packet.memory_wait":217.928,"Driver.Packet.device_lock":162.971,"Graphics.Draw":116.778,"Graphics.Draw.draw_and_resource_release":116.362,"Driver.Packet.dispatch":101.673,"Driver.Dispatch":67.305,"Recorder.Submit":48.184},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-120956.json.gz"}

Traces, digests and summaries: ThatsLeo:evidence/spanned-fence.

Runs by others, on earlier heads:

  • @hamb3r ran Demon's Souls on an RTX 3080 Ti (Windows) with spanning on: no device loss or hang, and compute pipeline compile time roughly halved.
  • @wachi35676 ran the GPU tests on an RTX 5070 Ti and a Radeon iGPU (Windows) with #8004: no new failures.
  • @CPritch measured GTA V on an RTX 5060 (Linux) with #8004: frame p50 −6%.

Not tested:

  • A title with wave64 compute on AMD; the AMD runs above are the GPU tests only.
  • Other titles than Stray on the Arc.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Linux; lavapipe (Mesa 26.2.4), Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4922248150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-19T14:08:00Z. --- ### What #5405 runs a single-wave wave64 compute program at one guest lane per invocation, across two full 32-lane host subgroups. It is off unless `APS5_SPANNED_WAVE` is set, because its cross-lane exchanges use workgroup barriers, and the emitter could not tell whether every invocation reaches them: its debt entry lists a manual `spirv-dis` scan as the only check. This PR adds that check and turns the layout on by default. - **`SpannedBarrierInDivergentFlow`** (`SpirvSpannedUniformity.cpp`) runs on every spanned module after emission. It marks the values that can differ between the invocations of a wave, iterating until nothing changes: - lane and subgroup IDs (`LocalInvocationId`/`Index`, `GlobalInvocationId`, `SubgroupId`, `SubgroupLocalInvocationId`, the subgroup masks); - atomic and subgroup-operation results, and function parameters; - loads of private or function variables stored in per-invocation control flow; - loads at a uniform address of memory the program writes, unless it is workgroup memory that a barrier fences on every path since the last write. Storage buffers, uniform buffers and device addresses all reach guest memory, so a write through any of them counts for all three; - image reads, when the program writes an image; - phis inside, or at the merge of, a construct such a value decides; - anything computed from these. A selection is divergent when its condition is marked. A loop is divergent when its header condition is marked, or when it can be left from per-invocation control flow. The construct's blocks are read off the dominator tree: the header's subtree minus the merge's. A construct is also divergent when a per-invocation branch without a merge instruction leaves it or continues its loop. When a divergent construct returns or kills, everything reachable from its merge is divergent; when it branches past its merge, as a `continue` does, the merge's subtree is. - If an `OpControlBarrier`, or a call that reaches one, sits in a divergent construct, `Emit` throws `SpannedWaveUnsupported`. `Recompile` already catches that and emits the program at two lanes per invocation, so a rejected program runs as on `main`. The check runs before `SpirvEmitInfo::fullSubgroups` is set, so the fallback is not created with `REQUIRE_FULL_SUBGROUPS`. - `VulkanDevice` turns spanning on wherever it was available under the switch (`computeFullSubgroups` with 32-lane compute subgroups). `APS5_NO_SPANNED_WAVE` turns it off; `APS5_SPANNED_WAVE` is gone. - The analysis runs until nothing changes, so it cannot stop early and throw. It is skipped for a module with no `OpControlBarrier`, and each function's flow graph is built once. - `Opcode`, `Result` and `VisitIdOperands` move unchanged from `SpirvSpecialization.cpp` to `SpirvInstructionOperands.hpp`, templated on the instruction container, so both passes share the operand table. `SpirvSpecialization.cpp` keeps `main`'s arena-backed `Instruction`. - **Guarded SRT reads.** A spanned wave does not stop an invocation after a fault (`bdaStopsInvocations` is false), so each later guarded read of a poisoned pointer wrote its record over the first. `agc_driver_guarded_null_pointer` then reported the second dword of an `s_load_dwordx2` (`address=0x4`). Where invocations do not stop, the record is now written with a compare-exchange against 0, as `record_bda_fault` already does, so the first fault is kept. Programs whose invocations stop keep the atomic store. - The debt entry states what the check proves and what it does not: writes by other dispatches or queues, and the unexplained one-barrier ballot loss. `spanned_uniformity_tests` links `libc` on MinGW, as `spirv_validator_exit_tests` does. ### Tested Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Fedora 44, Linux 7.2.10, GCC 16.2.1, Release. - **`spanned_uniformity`** (new) builds twenty-one modules by hand: - **rejected:** a barrier under a lane comparison; a barrier in a loop a lane value leaves; a call reaching a barrier under a lane comparison; a barrier after a per-lane return; a barrier after a per-lane continue, with or without a selection merge; a barrier under a buffer word read after a store through a device address; a barrier under a phi joining a per-lane selection; a barrier under a variable stored on one side of a per-lane selection; a barrier under an atomic result; a barrier under a workgroup word read at a lane index; a barrier under a workgroup word read after a store with no barrier between, or with a store on one path past the barrier; - **kept:** the same barriers under a constant comparison, after a uniform return or a uniform unmerged continue, under a buffer word the program never writes, in a uniform loop after a per-lane selection, under a workgroup word read at a uniform index, and under one read after a store and a barrier. With `LocalInvocationIndex` removed from the per-invocation built-ins, the lane-dependent cases fail. Without the fence, early-exit, guest-memory and unmerged-continue rules, the cases they cover fail. - **Stray's compute requests:** all 1,751 (PPSA02101) replayed through `agc_shader_replay` with a 32-lane target and spanning on, using a local switch that is not part of this PR. 1,117 programs span, the same with the guest-memory and unmerged-continue rules. The fence rule sends 13 programs back to two lanes per invocation that spanned without it (1,130). Stray's heaviest programs, `0x2011300000` and `0x200e390000`, still span. A Python prototype of the first analysis agreed with it. - **`ctest`** on `main` `3bb15be09` + this PR: - **Arc:** 1617 of 1623 pass. The six failures fail the same way with `APS5_NO_SPANNED_WAVE=1`: `application_heap_scripting`, `application_heap_lazy`, `agc_driver_image_table_vouched_lookups`, `agc_driver_guest_memory_lifetime`, `agc_driver_multisample_retirement`, plus `guest_kernel_fcntl`, which passes alone. - **lavapipe:** 1621 of 1623 pass. Only the two `application_heap` tests fail. - `agc_driver_lds_mask_waterfall` still runs both modes and still spans. - **After rebasing onto `main` `eda7477ac`, with #8004 on top:** see #8004. The Arc and lavapipe failures also fail on `main`, and the focused tests under the validation layer show no `VUID-` error. `agc_driver_guarded_null_pointer`, new on `main`, failed with spanning on before the guarded-read fix and passes after it, 5 of 5 runs. - **Stray, frames 20 to 50 of the boot** (`APS5_TRACE_FRAMES=20:30`, 3840x2160). - **Builds:** `main` + #7811, against `main` + this PR + #7811. Stray stops on `main` without #7811 (#7693). - **Runs:** three interleaved rounds after one warm run each. Every capture started below 55 °C, because this laptop throttles the GPU at 97–99 °C otherwise. - **Commit of the PR captures:** `128b8c1f8` is this PR's first push. The final head differs from it only in the helper header's template parameters. | | GPU busy per present (ms) | frame p50 (ms) | |---|---|---| | `main` + #7811 | 308.9 / 313.0 / 288.3 (mean 303.4) | 451.2 / 464.2 / 432.6 (mean 449.3) | | this PR + #7811 | 180.7 / 165.1 / 173.5 (mean 173.1) | 334.9 / 324.6 / 335.0 (mean 331.5) | `trace_digest.py`, first capture of each: ``` main: frames 20:30 from present 20: 30 presents, frame p50 451.2 / p90 472.1 / p99 586.3 / max 586.3 ms, GPU busy 308.9 ms per present PR: frames 20:30 from present 20: 30 presents, frame p50 334.9 / p90 347.4 / p99 418.7 / max 418.7 ms, GPU busy 180.7 ms per present ``` `aps5-summary.jsonl` lines, `main` + #7811: ```json {"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13716.468},"presents":30,"frame_ms":{"p50":451.183,"p90":472.083,"p99":586.282,"max":586.282},"gpu_busy_ms_per_present":308.934,"worker_busy_pct":{"queue worker 0x0":96.582,"queue worker 0x20":97.047},"top_phases_ms_per_frame":{"Driver.Packet":882.201,"Driver.Packet.memory_wait":418.127,"Driver.Packet.device_lock":208.359,"Driver.Packet.prepare_memory":138.870,"Graphics.Draw":127.060,"Graphics.Draw.draw_and_resource_release":126.577,"Recorder.Submit":114.858,"Driver.Packet.dispatch":68.164},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-938192.json.gz"} {"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13995.080},"presents":30,"frame_ms":{"p50":464.151,"p90":479.730,"p99":509.222,"max":509.222},"gpu_busy_ms_per_present":312.990,"worker_busy_pct":{"queue worker 0x0":96.781,"queue worker 0x20":96.913},"top_phases_ms_per_frame":{"Driver.Packet":900.975,"Driver.Packet.memory_wait":428.313,"Driver.Packet.device_lock":205.633,"Driver.Packet.prepare_memory":148.125,"Graphics.Draw":128.606,"Graphics.Draw.draw_and_resource_release":128.151,"Recorder.Submit":107.255,"Driver.Packet.dispatch":72.186},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-940261.json.gz"} {"commit":"4b4d52f7d953","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":13088.121},"presents":30,"frame_ms":{"p50":432.628,"p90":450.240,"p99":530.799,"max":530.799},"gpu_busy_ms_per_present":288.316,"worker_busy_pct":{"queue worker 0x0":96.056,"queue worker 0x20":96.773},"top_phases_ms_per_frame":{"Driver.Packet":837.222,"Driver.Packet.memory_wait":395.185,"Driver.Packet.device_lock":213.902,"Graphics.Draw":129.895,"Graphics.Draw.draw_and_resource_release":129.422,"Recorder.Submit":114.352,"Driver.Packet.prepare_memory":110.092,"Driver.Packet.dispatch":71.040},"trace_dropped":false,"trace":"aps5-trace-4b4d52f7d953-942091.json.gz"} ``` This PR + #7811: ```json {"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10177.000},"presents":30,"frame_ms":{"p50":334.856,"p90":347.438,"p99":418.694,"max":418.694},"gpu_busy_ms_per_present":180.675,"worker_busy_pct":{"queue worker 0x0":95.362,"queue worker 0x20":96.360},"top_phases_ms_per_frame":{"Driver.Packet":646.122,"Driver.Packet.memory_wait":298.561,"Driver.Packet.device_lock":193.196,"Graphics.Draw":116.729,"Graphics.Draw.draw_and_resource_release":116.290,"Recorder.Submit":108.061,"Driver.Packet.dispatch":69.570,"Driver.Dispatch":64.534},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-939198.json.gz"} {"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":9748.101},"presents":30,"frame_ms":{"p50":324.600,"p90":332.281,"p99":340.520,"max":340.520},"gpu_busy_ms_per_present":165.056,"worker_busy_pct":{"queue worker 0x0":95.368,"queue worker 0x20":97.098},"top_phases_ms_per_frame":{"Driver.Packet":622.706,"Driver.Packet.memory_wait":285.025,"Driver.Packet.device_lock":182.915,"Graphics.Draw":113.762,"Graphics.Draw.draw_and_resource_release":113.340,"Recorder.Submit":97.834,"Driver.Packet.dispatch":72.730,"Driver.Dispatch":68.024},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-941263.json.gz"} {"commit":"128b8c1f83c0","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":10014.061},"presents":30,"frame_ms":{"p50":334.968,"p90":340.775,"p99":354.031,"max":354.031},"gpu_busy_ms_per_present":173.489,"worker_busy_pct":{"queue worker 0x0":95.324,"queue worker 0x20":96.938},"top_phases_ms_per_frame":{"Driver.Packet":639.070,"Driver.Packet.memory_wait":298.617,"Driver.Packet.device_lock":189.827,"Graphics.Draw":115.684,"Graphics.Draw.draw_and_resource_release":115.257,"Recorder.Submit":104.396,"Driver.Packet.dispatch":72.309,"Driver.Dispatch":68.740},"trace_dropped":false,"trace":"aps5-trace-128b8c1f83c0-943100.json.gz"} ``` Traces, digests and summaries: [`ThatsLeo:evidence/spanned-default`](https://github.com/ThatsLeo/AnyPS5/tree/evidence/spanned-default). **The fence and early-exit rules on Stray.** Same scene and machine, `main` `559f35d68` + this PR (without, then with, the second commit) + #8004 + #7811. One warm run each, then four interleaved rounds. After a battery drain this laptop idled at 56 °C, so every capture started below 58 °C, not 55. | | GPU busy per present (ms) | frame p50 (ms) | |---|---|---| | without the rules | 111.5 / 113.9 / 117.5 / 116.3 (mean 114.8) | 276.6 / 271.6 / 285.3 / 280.8 (mean 278.6) | | with the rules | 115.0 / 114.6 / 114.0 / 112.7 (mean 114.1) | 268.9 / 279.8 / 272.2 / 278.3 (mean 274.8) | The difference is inside the spread. ``` without: frames 20:30 from present 20: 30 presents, frame p50 276.6 / p90 287.9 / p99 294.7 / max 294.7 ms, GPU busy 111.5 ms per present with: frames 20:30 from present 20: 30 presents, frame p50 268.9 / p90 282.2 / p99 285.1 / max 285.1 ms, GPU busy 115.0 ms per present ``` <details><summary><code>aps5-summary.jsonl</code> lines</summary> ```json {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8273.368},"presents":30,"frame_ms":{"p50":276.642,"p90":287.880,"p99":294.712,"max":294.712},"gpu_busy_ms_per_present":111.544,"worker_busy_pct":{"queue worker 0x0":97.191,"queue worker 0x20":97.311},"top_phases_ms_per_frame":{"Driver.Packet":532.809,"Driver.Packet.memory_wait":229.082,"Driver.Packet.device_lock":165.884,"Graphics.Draw":114.639,"Graphics.Draw.draw_and_resource_release":114.308,"Driver.Packet.dispatch":85.599,"Driver.Dispatch":59.489,"Recorder.Submit":48.015},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-108138.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8223.104},"presents":30,"frame_ms":{"p50":271.596,"p90":287.082,"p99":292.329,"max":292.329},"gpu_busy_ms_per_present":113.868,"worker_busy_pct":{"queue worker 0x0":97.306,"queue worker 0x20":96.759},"top_phases_ms_per_frame":{"Driver.Packet":529.169,"Driver.Packet.memory_wait":216.791,"Driver.Packet.device_lock":164.966,"Graphics.Draw":115.568,"Graphics.Draw.draw_and_resource_release":115.240,"Driver.Packet.dispatch":94.578,"Driver.Dispatch":63.130,"Vulkan.Dispatch":47.380},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-113059.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8561.265},"presents":30,"frame_ms":{"p50":285.252,"p90":299.190,"p99":305.800,"max":305.800},"gpu_busy_ms_per_present":117.525,"worker_busy_pct":{"queue worker 0x0":97.291,"queue worker 0x20":97.585},"top_phases_ms_per_frame":{"Driver.Packet":552.832,"Driver.Packet.memory_wait":224.121,"Driver.Packet.device_lock":164.165,"Graphics.Draw":115.802,"Graphics.Draw.draw_and_resource_release":115.458,"Driver.Packet.dispatch":109.259,"Driver.Dispatch":72.453,"Vulkan.Dispatch":47.232},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-116244.json.gz"} {"commit":"9667780a1567","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8493.756},"presents":30,"frame_ms":{"p50":280.819,"p90":298.458,"p99":301.837,"max":301.837},"gpu_busy_ms_per_present":116.292,"worker_busy_pct":{"queue worker 0x0":97.613,"queue worker 0x20":97.336},"top_phases_ms_per_frame":{"Driver.Packet":549.554,"Driver.Packet.memory_wait":230.652,"Driver.Packet.device_lock":163.134,"Graphics.Draw":115.009,"Graphics.Draw.draw_and_resource_release":114.660,"Driver.Packet.dispatch":100.944,"Driver.Dispatch":72.601,"Recorder.Submit":49.593},"trace_dropped":false,"trace":"aps5-trace-9667780a1567-119633.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8094.501},"presents":30,"frame_ms":{"p50":268.921,"p90":282.204,"p99":285.051,"max":285.051},"gpu_busy_ms_per_present":115.018,"worker_busy_pct":{"queue worker 0x0":97.361,"queue worker 0x20":96.984},"top_phases_ms_per_frame":{"Driver.Packet":522.612,"Driver.Packet.memory_wait":216.751,"Driver.Packet.device_lock":163.550,"Graphics.Draw":115.508,"Graphics.Draw.draw_and_resource_release":115.189,"Driver.Packet.dispatch":89.641,"Driver.Dispatch":54.537,"Recorder.Submit":47.263},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-110545.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8388.481},"presents":30,"frame_ms":{"p50":279.752,"p90":289.914,"p99":307.567,"max":307.567},"gpu_busy_ms_per_present":114.558,"worker_busy_pct":{"queue worker 0x0":97.228,"queue worker 0x20":97.175},"top_phases_ms_per_frame":{"Driver.Packet":541.081,"Driver.Packet.memory_wait":229.579,"Driver.Packet.device_lock":164.570,"Graphics.Draw":115.558,"Graphics.Draw.draw_and_resource_release":115.217,"Driver.Packet.dispatch":97.113,"Driver.Dispatch":67.063,"Recorder.Submit":47.239},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-114700.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8163.070},"presents":30,"frame_ms":{"p50":272.213,"p90":284.784,"p99":291.836,"max":291.836},"gpu_busy_ms_per_present":114.038,"worker_busy_pct":{"queue worker 0x0":97.290,"queue worker 0x20":96.736},"top_phases_ms_per_frame":{"Driver.Packet":524.954,"Driver.Packet.memory_wait":218.094,"Driver.Packet.device_lock":160.249,"Graphics.Draw":114.762,"Graphics.Draw.draw_and_resource_release":114.432,"Driver.Packet.dispatch":88.844,"Driver.Dispatch":56.043,"Recorder.Submit":46.681},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-117978.json.gz"} {"commit":"219315aabfb1","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_FRAMES":"20:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.10-200.fc44.x86_64","cpu":"Intel(R) Core(TM) Ultra 7 155H","cpu_threads":22,"memory_mib":15333,"title_id":"PPSA02101","title":"Stray","content_version":"01.002.000","resolution":"3840x2160","window":{"spec":"frames 20:30","first_present":20,"ms":8315.173},"presents":30,"frame_ms":{"p50":278.251,"p90":288.303,"p99":290.344,"max":290.344},"gpu_busy_ms_per_present":112.656,"worker_busy_pct":{"queue worker 0x0":97.424,"queue worker 0x20":97.292},"top_phases_ms_per_frame":{"Driver.Packet":532.199,"Driver.Packet.memory_wait":217.928,"Driver.Packet.device_lock":162.971,"Graphics.Draw":116.778,"Graphics.Draw.draw_and_resource_release":116.362,"Driver.Packet.dispatch":101.673,"Driver.Dispatch":67.305,"Recorder.Submit":48.184},"trace_dropped":false,"trace":"aps5-trace-219315aabfb1-120956.json.gz"} ``` </details> Traces, digests and summaries: [`ThatsLeo:evidence/spanned-fence`](https://github.com/ThatsLeo/AnyPS5/tree/evidence/spanned-fence). **Runs by others, on earlier heads:** - @hamb3r ran Demon's Souls on an RTX 3080 Ti (Windows) with spanning on: no device loss or hang, and compute pipeline compile time roughly halved. - @wachi35676 ran the GPU tests on an RTX 5070 Ti and a Radeon iGPU (Windows) with #8004: no new failures. - @CPritch measured GTA V on an RTX 5060 (Linux) with #8004: frame p50 −6%. **Not tested:** - A title with wave64 compute on AMD; the AMD runs above are the GPU tests only. - Other titles than Stray on the Arc. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Linux; lavapipe (Mesa 26.2.4), Linux - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 14:08:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T14:08:14Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269195796 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6269195796). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T14:08:14Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
CnRJay commented 2026-10-19 17:49:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-19T17:49:08Z.

Review: COMMENTED


The Stray numbers are strong (GPU busy per present 303.4 to 173.1 ms, frame p50 449.3 to 331.5 ms, three interleaved rounds, spread small next to the gain), and the fallback to two lanes per invocation when the check rejects is the right shape. Turning this on by default for every device with 32-lane compute subgroups is where I don't agree yet.

  • Everything measured is one Intel Arc (Meteor Lake) on ANV. "Wherever it was available under the switch" means NVIDIA and RDNA wave32 parts get a different compute layout for 1,130 of Stray's 1,751 programs without a run on either. Barrier-in-divergent-flow on a vendor that implements OpControlBarrier differently is a hang or VK_ERROR_DEVICE_LOST, not a wrong picture. Please post spanned_uniformity plus the Stray (or any wave64-compute title) pair on an NVIDIA card and a Radeon, or keep the default off for vendors that haven't been run.
  • The description says the check treats a load from workgroup, storage or uniform memory at a uniform address as uniform, "not proven for memory another invocation writes without a barrier in between", and that a one-barrier ballot loss is unexplained. That is a known hole in the analysis that decides whether the program can hang, and it is being made the default path. Either close it (treat such a load as divergent unless a barrier dominates it, and see what fraction of the 1,130 still spans), or state the programs it affects and keep the switch default-off until the ballot loss is explained.
  • The replay of 1,751 requests ran with a local switch that isn't in the PR, and found 0 rejections. A check that never rejects on its real corpus only shows the false-positive rate; the rejected cases are the hand-built eleven modules. It would help to have at least one real program from the corpus where the barrier sits under a divergent construct, to show the check reaches it on real SPIR-V.
  • APS5_SPANNED_WAVE is removed and APS5_NO_SPANNED_WAVE added. Is the spanning decision part of the shader disk cache key and the pipeline journal key? A cache written under the old switch must not serve a two-lane module to a spanned layout (or the other way round) after this default flips.
  • 858 added lines moving Opcode, Result and VisitIdOperands between files alongside the new pass. Splitting the move out of the behavior change would make the pass reviewable.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5575502139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#pullrequestreview-5575502139). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-19T17:49:08Z. **Review:** COMMENTED --- The Stray numbers are strong (GPU busy per present 303.4 to 173.1 ms, frame p50 449.3 to 331.5 ms, three interleaved rounds, spread small next to the gain), and the fallback to two lanes per invocation when the check rejects is the right shape. Turning this on by default for every device with 32-lane compute subgroups is where I don't agree yet. - Everything measured is one Intel Arc (Meteor Lake) on ANV. "Wherever it was available under the switch" means NVIDIA and RDNA wave32 parts get a different compute layout for 1,130 of Stray's 1,751 programs without a run on either. Barrier-in-divergent-flow on a vendor that implements `OpControlBarrier` differently is a hang or `VK_ERROR_DEVICE_LOST`, not a wrong picture. Please post `spanned_uniformity` plus the Stray (or any wave64-compute title) pair on an NVIDIA card and a Radeon, or keep the default off for vendors that haven't been run. - The description says the check treats a load from workgroup, storage or uniform memory at a uniform address as uniform, "not proven for memory another invocation writes without a barrier in between", and that a one-barrier ballot loss is unexplained. That is a known hole in the analysis that decides whether the program can hang, and it is being made the default path. Either close it (treat such a load as divergent unless a barrier dominates it, and see what fraction of the 1,130 still spans), or state the programs it affects and keep the switch default-off until the ballot loss is explained. - The replay of 1,751 requests ran with a local switch that isn't in the PR, and found 0 rejections. A check that never rejects on its real corpus only shows the false-positive rate; the rejected cases are the hand-built eleven modules. It would help to have at least one real program from the corpus where the barrier sits under a divergent construct, to show the check reaches it on real SPIR-V. - `APS5_SPANNED_WAVE` is removed and `APS5_NO_SPANNED_WAVE` added. Is the spanning decision part of the shader disk cache key and the pipeline journal key? A cache written under the old switch must not serve a two-lane module to a spanned layout (or the other way round) after this default flips. - 858 added lines moving `Opcode`, `Result` and `VisitIdOperands` between files alongside the new pass. Splitting the move out of the behavior change would make the pass reviewable.
blawesom commented 2026-10-20 19:01:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T19:01:59Z.


This PR looks strictly contained in #8004: its single commit 753bb56e3 ("span single-wave wave64 compute by default after a uniformity check") is exactly the first commit of #8004's branch, which carries one more on top (2276a44aa, "let spanned waves run at any host subgroup size where it can be narrower than 32"). Both are from the same series opened ~3 hours apart.

If the intent was one review thread, closing this in favour of #8004 would keep a single place for the maintainers to look — #8004 also has a verified rebase handoff onto current main (including main's WordArena infrastructure kept, the VisitIdOperands alias restored, and main's five InsertMeshBarycentricFlag sites preserved across your version-bump rewrites).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298849696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6298849696). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-20T19:01:59Z. --- This PR looks strictly contained in #8004: its single commit `753bb56e3` ("span single-wave wave64 compute by default after a uniformity check") is exactly the first commit of #8004's branch, which carries one more on top (`2276a44aa`, "let spanned waves run at any host subgroup size where it can be narrower than 32"). Both are from the same series opened ~3 hours apart. If the intent was one review thread, closing this in favour of #8004 would keep a single place for the maintainers to look — #8004 also has a verified rebase handoff onto current `main` (including `main`'s `WordArena` infrastructure kept, the `VisitIdOperands` alias restored, and `main`'s five `InsertMeshBarycentricFlag` sites preserved across your version-bump rewrites).
hamb3r commented 2026-10-20 20:43:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-20T20:43:06Z.


Tested enabling spannedWaves (state->spannedWaves = state->computeFullSubgroups) on Windows 10 / NVIDIA GeForce RTX 3080 (driver 595.71, hostSubgroupSize = 32) with Demon's Souls (PPSA01341 01.007.000), which dispatches dozens of heavy single-wave wave64 compute shaders (workgroupSize <= 64, >213,000 compute dispatches across boot, intro, and title screen):

  • No VK_ERROR_DEVICE_LOST or hangs on NVIDIA across cold-cache and warm-cache runs.
  • Avoiding the laneCount = 2 unroll on single-wave wave64 compute shaders (0x1ee14f3c0, 0x1eeb34840, etc.) cuts the specialized SPIR-V word count and vkCreateComputePipelines compile time in nvgpucomp64.dll nearly in half.

Also reviewed SpirvSpannedUniformity.cpp and noticed four technical points worth addressing when rebasing onto main:

  1. Early exits (OpReturn / break / continue) inside a divergent OpSelectionMerge (Construct, L215–227):
    Construct(flow, header, merge) stops at if (node == merge) continue;. If a branch inside a per-lane OpSelectionMerge exits early via OpReturn (or jumps to an enclosing loop's merge/continue block instead of merge), only a subset of lanes reaches merge. Any OpControlBarrier placed in merge (or dominated by merge after an early return) executes under a divergent active lane mask, but inDivergentFlow will currently be false for merge.
  2. Analysis::Run() throws std::runtime_error instead of falling back (L148):
    If the 64-round cap is hit on a deep loop-carried OpStore/OpLoad chain, Run() throws std::runtime_error("spanned wave uniformity did not settle") instead of returning a rejection reason for SpannedWaveUnsupported, which aborts shader compilation rather than falling back to unspanned wave64 (laneCount = 2).
  3. Fast-path when a module has no OpControlBarrier:
    In SpannedBarrierInDivergentFlow(words) / Analysis::Run(), if the module contains no OpControlBarrier instructions (barriers.empty()), Parse(words) and Run() still allocate a std::vector<std::uint32_t> per instruction and run the fixed-point dataflow loop. Scanning words for spv::OpControlBarrier before Parse(words) (and checking if (barriers.empty()) return std::nullopt;) avoids ~100k heap allocations on large 500k–850k word compute shaders that have no workgroup barriers.
  4. BuildFlow(function) inside Visit(function) (L238):
    BuildFlow(function) rebuilds the CFG postorder and dominator tree on every iteration of the round loop in Run(), even though the CFG is static. Precomputing Flow once per function avoids repeating dominator intersection on large shaders.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301047298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6301047298). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-20T20:43:06Z. --- Tested enabling `spannedWaves` (`state->spannedWaves = state->computeFullSubgroups`) on **Windows 10 / NVIDIA GeForce RTX 3080 (driver 595.71, `hostSubgroupSize = 32`)** with **Demon's Souls (`PPSA01341` 01.007.000)**, which dispatches dozens of heavy single-wave `wave64` compute shaders (`workgroupSize <= 64`, `>213,000` compute dispatches across boot, intro, and title screen): - No `VK_ERROR_DEVICE_LOST` or hangs on NVIDIA across cold-cache and warm-cache runs. - Avoiding the `laneCount = 2` unroll on single-wave `wave64` compute shaders (`0x1ee14f3c0`, `0x1eeb34840`, etc.) cuts the specialized SPIR-V word count and `vkCreateComputePipelines` compile time in `nvgpucomp64.dll` nearly in half. Also reviewed `SpirvSpannedUniformity.cpp` and noticed four technical points worth addressing when rebasing onto `main`: 1. **Early exits (`OpReturn` / `break` / `continue`) inside a divergent `OpSelectionMerge` (`Construct`, L215–227):** `Construct(flow, header, merge)` stops at `if (node == merge) continue;`. If a branch inside a per-lane `OpSelectionMerge` exits early via `OpReturn` (or jumps to an enclosing loop's merge/continue block instead of `merge`), only a subset of lanes reaches `merge`. Any `OpControlBarrier` placed in `merge` (or dominated by `merge` after an early return) executes under a divergent active lane mask, but `inDivergentFlow` will currently be `false` for `merge`. 2. **`Analysis::Run()` throws `std::runtime_error` instead of falling back (`L148`):** If the 64-round cap is hit on a deep loop-carried `OpStore`/`OpLoad` chain, `Run()` throws `std::runtime_error("spanned wave uniformity did not settle")` instead of returning a rejection reason for `SpannedWaveUnsupported`, which aborts shader compilation rather than falling back to unspanned `wave64` (`laneCount = 2`). 3. **Fast-path when a module has no `OpControlBarrier`:** In `SpannedBarrierInDivergentFlow(words)` / `Analysis::Run()`, if the module contains no `OpControlBarrier` instructions (`barriers.empty()`), `Parse(words)` and `Run()` still allocate a `std::vector<std::uint32_t>` per instruction and run the fixed-point dataflow loop. Scanning `words` for `spv::OpControlBarrier` before `Parse(words)` (and checking `if (barriers.empty()) return std::nullopt;`) avoids ~100k heap allocations on large 500k–850k word compute shaders that have no workgroup barriers. 4. **`BuildFlow(function)` inside `Visit(function)` (`L238`):** `BuildFlow(function)` rebuilds the CFG postorder and dominator tree on every iteration of the `round` loop in `Run()`, even though the CFG is static. Precomputing `Flow` once per function avoids repeating dominator intersection on large shaders.
ThatsLeo commented 2026-10-20 23:46:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-20T23:46:23Z.


Rebased onto main 559f35d68, with two more commits. The description is updated.

@CnRJay, on your two points:

  • The analysis gap is closed rather than documented. A load at a uniform address is now uniform only from memory the program never writes, or from workgroup memory that a barrier fences on every path since the last write. Image reads count as per-invocation when the program writes an image. Of Stray's 1,130 spanning programs, 1,117 still span, and the heaviest ones are among them. The 13 others fall back to two lanes per invocation. Four interleaved Stray rounds with and without the rule are inside each other's spread (GPU 114.1 against 114.8 ms per present, frame p50 274.8 against 278.6 ms).

  • Other vendors. I first restricted the default to Mesa's Intel driver. Then the runs here and on #8004 came in:

    • @hamb3r: Demon's Souls on NVIDIA, with no device loss or hang;
    • @wachi35676: the GPU tests on NVIDIA and a Radeon, with no new failures;
    • @CPritch: GTA V on NVIDIA, frame p50 −6%.

    So I left it on wherever 32-lane full subgroups exist, with APS5_NO_SPANNED_WAVE as the switch. If you'd still rather gate AMD until someone runs a title there, it's a one-line change.

The one-barrier ballot loss from #5405 is still unexplained, and the debt entry says so.

@hamb3r, thanks for the run and the review:

  1. Early exits. You were right. A divergent construct that returns or kills now makes everything reachable from its merge divergent, and one that branches past its merge, as a continue does, makes the merge's subtree divergent. The tests cover a per-lane return and a per-lane continue (both rejected) and a uniform return (kept). The return case passed the old check.
  2. The analysis no longer has a round cap. The marked sets only grow, so it always settles.
  3. A module with no OpControlBarrier is skipped before it is parsed.
  4. Each function's flow graph is built once per module.

The rebase also showed that main's new agc_driver_guarded_null_pointer failed with spanning on. A spanned wave doesn't stop an invocation after a fault, so the second dword of a poisoned s_load_dwordx2 overwrote the first record. Where invocations don't stop, the record is now written only while the guard word is 0, as record_bda_fault already does.

@blawesom, thanks. I'd keep #7922 open because @CnRJay's review and the assignment are here. #8004 lists it under Depends on, and reviewing #8004 covers both.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304360299 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6304360299). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-20T23:46:23Z. --- Rebased onto `main` `559f35d68`, with two more commits. The description is updated. @CnRJay, on your two points: - **The analysis gap is closed rather than documented.** A load at a uniform address is now uniform only from memory the program never writes, or from workgroup memory that a barrier fences on every path since the last write. Image reads count as per-invocation when the program writes an image. Of Stray's 1,130 spanning programs, 1,117 still span, and the heaviest ones are among them. The 13 others fall back to two lanes per invocation. Four interleaved Stray rounds with and without the rule are inside each other's spread (GPU 114.1 against 114.8 ms per present, frame p50 274.8 against 278.6 ms). - **Other vendors.** I first restricted the default to Mesa's Intel driver. Then the runs here and on #8004 came in: - @hamb3r: Demon's Souls on NVIDIA, with no device loss or hang; - @wachi35676: the GPU tests on NVIDIA and a Radeon, with no new failures; - @CPritch: GTA V on NVIDIA, frame p50 −6%. So I left it on wherever 32-lane full subgroups exist, with `APS5_NO_SPANNED_WAVE` as the switch. If you'd still rather gate AMD until someone runs a title there, it's a one-line change. The one-barrier ballot loss from #5405 is still unexplained, and the debt entry says so. @hamb3r, thanks for the run and the review: 1. **Early exits.** You were right. A divergent construct that returns or kills now makes everything reachable from its merge divergent, and one that branches past its merge, as a `continue` does, makes the merge's subtree divergent. The tests cover a per-lane return and a per-lane continue (both rejected) and a uniform return (kept). The return case passed the old check. 2. **The analysis no longer has a round cap.** The marked sets only grow, so it always settles. 3. **A module with no `OpControlBarrier` is skipped** before it is parsed. 4. **Each function's flow graph is built once** per module. The rebase also showed that `main`'s new `agc_driver_guarded_null_pointer` failed with spanning on. A spanned wave doesn't stop an invocation after a fault, so the second dword of a poisoned `s_load_dwordx2` overwrote the first record. Where invocations don't stop, the record is now written only while the guard word is 0, as `record_bda_fault` already does. @blawesom, thanks. I'd keep #7922 open because @CnRJay's review and the assignment are here. #8004 lists it under Depends on, and reviewing #8004 covers both. AI-assisted: yes
oneandonlydean commented 2026-10-21 00:00:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:00:51Z.


@ThatsLeo Thanks for closing the analysis gap. I read SpirvSpannedUniformity.cpp against the emitter at 4d84eb2a1d and ran the analysis standalone with your test builder. Your seventeen cases pass, and mutants that drop LocalInvocationIndex, the fence reset or the early-exit rule each fail them. One gap needs a fix before this can be on by default, and two smaller points:

  1. Guest memory written through one storage class and read through another. Written and Racy only ask whether the load's own class is written. But guest memory is reached through both StorageBuffer descriptors and BDA PhysicalStorageBuffer pointers (SpirvRuntimeBuffer.cpp emits both forms for the same buffer atomic). So a program that stores only through a BDA pointer and loads at a uniform address through a buffer descriptor gets that load counted as uniform. Inside one spanned wave, the two host subgroups can then read different values, which is the hazard the rule exists for. A minimal module (uniform StorageBuffer load, OpIEqual, barrier inside the selection, plus one OpStore through an OpConvertUToPtr PSB pointer) is kept today. With the store going to the StorageBuffer instead, it's rejected. Could you treat the guest-memory classes as one class in Written, add that case as a rejected test, and post the new span count for PPSA02101?
  2. A per-lane continue without a selection merge. The loop rule only looks at branches to the loop's merge block, and selections are only found through OpSelectionMerge. So OpBranchConditional %lane %continue %rest in a non-header block (valid structured SPIR-V; SpirvFlowEmitter emits no merge when the terminator has none) leaves a barrier in %rest unflagged. If the emitter can never produce that with a per-invocation condition, a sentence saying why is enough. Otherwise, treating a non-uniform conditional branch to the continue target like a per-lane break would close it.
  3. The registration re-emit in Recompile runs after the SpannedWaveUnsupported catch and still spans. The check then runs on a different module, and a rejection there fails the compile instead of falling back. Wrapping it the same way, or re-emitting with spanning off, avoids that.

The rest looks right to me: the fallback doesn't set REQUIRE_FULL_SUBGROUPS, the operand table move is mechanical, and the first-fault compare-exchange is sound because the host zeroes the guard word.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304549869 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6304549869). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T00:00:51Z. --- @ThatsLeo Thanks for closing the analysis gap. I read `SpirvSpannedUniformity.cpp` against the emitter at 4d84eb2a1d and ran the analysis standalone with your test builder. Your seventeen cases pass, and mutants that drop `LocalInvocationIndex`, the fence reset or the early-exit rule each fail them. One gap needs a fix before this can be on by default, and two smaller points: 1. **Guest memory written through one storage class and read through another.** `Written` and `Racy` only ask whether the load's own class is written. But guest memory is reached through both `StorageBuffer` descriptors and BDA `PhysicalStorageBuffer` pointers (`SpirvRuntimeBuffer.cpp` emits both forms for the same buffer atomic). So a program that stores only through a BDA pointer and loads at a uniform address through a buffer descriptor gets that load counted as uniform. Inside one spanned wave, the two host subgroups can then read different values, which is the hazard the rule exists for. A minimal module (uniform `StorageBuffer` load, `OpIEqual`, barrier inside the selection, plus one `OpStore` through an `OpConvertUToPtr` PSB pointer) is kept today. With the store going to the `StorageBuffer` instead, it's rejected. Could you treat the guest-memory classes as one class in `Written`, add that case as a rejected test, and post the new span count for PPSA02101? 2. **A per-lane `continue` without a selection merge.** The loop rule only looks at branches to the loop's merge block, and selections are only found through `OpSelectionMerge`. So `OpBranchConditional %lane %continue %rest` in a non-header block (valid structured SPIR-V; `SpirvFlowEmitter` emits no merge when the terminator has none) leaves a barrier in `%rest` unflagged. If the emitter can never produce that with a per-invocation condition, a sentence saying why is enough. Otherwise, treating a non-uniform conditional branch to the continue target like a per-lane break would close it. 3. **The registration re-emit in `Recompile`** runs after the `SpannedWaveUnsupported` catch and still spans. The check then runs on a different module, and a rejection there fails the compile instead of falling back. Wrapping it the same way, or re-emitting with spanning off, avoids that. The rest looks right to me: the fallback doesn't set `REQUIRE_FULL_SUBGROUPS`, the operand table move is mechanical, and the first-fault compare-exchange is sound because the host zeroes the guard word.
ThatsLeo commented 2026-10-21 00:14:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-21T00:14:15Z.


@oneandonlydean Thanks, all three are addressed. Both PRs are rebased onto main eda7477ac.

  1. Guest memory as one class. Uniform, StorageBuffer and PhysicalStorageBuffer now count as one class for both writes and loads. Your case is a rejected test: a uniform StorageBuffer load, a barrier under it, and one store through an OpConvertUToPtr pointer. Next to it, a kept test reads the same buffer with no store anywhere. PPSA02101 still has 1,117 spanned programs, including 0x2011300000 and 0x200e390000. The check only accepts or rejects modules, so the spanned modules are byte-identical to the previous push and the Stray A/B in the description still applies.
  2. Unmerged per-lane continue. The emitter can produce one: SpirvFlowEmitter emits OpBranchConditional with no merge whenever the IR terminator has none. A construct is now divergent when a block inside it ends in a per-invocation OpBranchConditional or OpSwitch without a merge instruction and targets the construct's merge or, for a loop, its continue target. The per-lane version of your example is rejected and the uniform one is kept. Before this commit the per-lane one was kept.
  3. The registration re-emit can't span. registration is only true for vertex and fragment stages (Recompiler.cpp:584), and SpirvEmitter.cpp sets spannedWave only for compute. The second emit therefore never carries a spanned module, so the check never runs there.

Tests on the new heads:

  • Arc: 1742 of 1748 pass. The six failures also fail on main.
  • lavapipe: 1746 of 1748 pass. Only the two application_heap tests fail.
  • Validation layer: the 54 focused tests, including agc_driver_guarded_null_pointer, show no VUID- error.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304736632 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6304736632). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-21T00:14:15Z. --- @oneandonlydean Thanks, all three are addressed. Both PRs are rebased onto `main` `eda7477ac`. 1. **Guest memory as one class.** `Uniform`, `StorageBuffer` and `PhysicalStorageBuffer` now count as one class for both writes and loads. Your case is a rejected test: a uniform `StorageBuffer` load, a barrier under it, and one store through an `OpConvertUToPtr` pointer. Next to it, a kept test reads the same buffer with no store anywhere. PPSA02101 still has 1,117 spanned programs, including `0x2011300000` and `0x200e390000`. The check only accepts or rejects modules, so the spanned modules are byte-identical to the previous push and the Stray A/B in the description still applies. 2. **Unmerged per-lane `continue`.** The emitter can produce one: `SpirvFlowEmitter` emits `OpBranchConditional` with no merge whenever the IR terminator has none. A construct is now divergent when a block inside it ends in a per-invocation `OpBranchConditional` or `OpSwitch` without a merge instruction and targets the construct's merge or, for a loop, its continue target. The per-lane version of your example is rejected and the uniform one is kept. Before this commit the per-lane one was kept. 3. **The registration re-emit can't span.** `registration` is only true for vertex and fragment stages (`Recompiler.cpp:584`), and `SpirvEmitter.cpp` sets `spannedWave` only for compute. The second emit therefore never carries a spanned module, so the check never runs there. Tests on the new heads: - **Arc:** 1742 of 1748 pass. The six failures also fail on `main`. - **lavapipe:** 1746 of 1748 pass. Only the two `application_heap` tests fail. - **Validation layer:** the 54 focused tests, including `agc_driver_guarded_null_pointer`, show no `VUID-` error. AI-assisted: yes
thuanquang commented 2026-10-21 06:24:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T06:24:21Z.


A discrete RDNA 2 run with spanning on by default: RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0, Release. It compares main a07e985c8 with main merged with this head, 8d4f48671 (the merge is clean).

  • Spanning is active on this driver: with this PR, the device log prints single-wave wave64 compute spans two full 32-lane subgroups: 1, next to Wave32 programs run on subgroups of 32: compute 1.
  • Suite: ctest -R "agc|shader|spirv|recomp|subgroup" --parallel 4 --timeout 120, ANYPS5_REQUIRE_VULKAN=1. Both sides pass 868 of 870, and the same two tests miss on each:
    • agc_driver_image_array_window_past_layer_limit was not run, since it doesn't build with MinGW on main (#8310).
    • agc_driver_tessellation fails on AMD's Windows driver on main (#8861, fixed by #8884).

Not run: the Khronos validation layer, other AMD drivers, and titles.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309554733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6309554733). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T06:24:21Z. --- A discrete RDNA 2 run with spanning on by default: RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0, Release. It compares `main` `a07e985c8` with `main` merged with this head, `8d4f48671` (the merge is clean). - **Spanning is active on this driver:** with this PR, the device log prints `single-wave wave64 compute spans two full 32-lane subgroups: 1`, next to `Wave32 programs run on subgroups of 32: compute 1`. - **Suite:** `ctest -R "agc|shader|spirv|recomp|subgroup" --parallel 4 --timeout 120`, `ANYPS5_REQUIRE_VULKAN=1`. Both sides pass 868 of 870, and the same two tests miss on each: - `agc_driver_image_array_window_past_layer_limit` was not run, since it doesn't build with MinGW on `main` (#8310). - `agc_driver_tessellation` fails on AMD's Windows driver on `main` (#8861, fixed by #8884). Not run: the Khronos validation layer, other AMD drivers, and titles.
oneandonlydean commented 2026-10-21 06:32:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T06:32:59Z.


@ThatsLeo a discrete RDNA 2 data point from @thuanquang: with spanning on by default on AMD's Windows driver, the device log confirms spanning is active, and main and this PR both pass 868 of 870 on the agc/shader/subgroup set, missing the same two known tests. Thanks @thuanquang.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309680715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#issuecomment-6309680715). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T06:32:59Z. --- @ThatsLeo a discrete RDNA 2 data point from @thuanquang: with spanning on by default on AMD's Windows driver, the device log confirms spanning is active, and `main` and this PR both pass 868 of 870 on the agc/shader/subgroup set, missing the same two known tests. Thanks @thuanquang.
CnRJay commented 2026-10-26 23:11:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-26T23:11:12Z.

Review: COMMENTED


@oneandonlydean I don't have a setup that runs these titles, so I can't rerun 4844a289c2 on a GPU and won't post a result I haven't measured. My cross-vendor point was that every number came from one Intel/ANV machine; since then NVIDIA (@hamb3r, RTX 3080, Demon's Souls) and AMD (@thuanquang, RX 6700 XT, spanning confirmed active) runs have come in with no device loss, hang or corruption, which answers it. What the current head still needs from the people who have the hardware is a run of the same scene with and without APS5_NO_SPANNED_WAVE=1 on each vendor, with the GPU and driver, so the default has a paired result on NVIDIA and AMD and not only a clean boot.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5660313575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7922#pullrequestreview-5660313575). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-26T23:11:12Z. **Review:** COMMENTED --- @oneandonlydean I don't have a setup that runs these titles, so I can't rerun 4844a289c2 on a GPU and won't post a result I haven't measured. My cross-vendor point was that every number came from one Intel/ANV machine; since then NVIDIA (@hamb3r, RTX 3080, Demon's Souls) and AMD (@thuanquang, RX 6700 XT, spanning confirmed active) runs have come in with no device loss, hang or corruption, which answers it. What the current head still needs from the people who have the hardware is a run of the same scene with and without `APS5_NO_SPANNED_WAVE=1` on each vendor, with the GPU and driver, so the default has a paired result on NVIDIA and AMD and not only a clean boot.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7922
No description provided.