fix(shader): record a BDA lookup's fault from one call site #5814

Closed
MarcZX10 wants to merge 1 commit from upstream-pr/5814 into main
MarcZX10 commented 2026-10-14 12:03:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T12:03:13Z.


What

Follow up on #3655 and the compiler-pressure measurements in #2972. The BDA page-table lookup currently emits separate record_bda_fault call sites for its table checks, unmapped index, and range checks. Collapse those branches to one fault-recording exit per lookup. The first failing check, check order, guarded table reads, and recorded reason/address/size/instruction stay unchanged; non-recording probe lookups remain non-recording.

This carries Miles Coviello's follow-up commit from his public branch, preserving the original author and commit metadata.

Measured

The original author compared this follow-up on Intel Arrow Lake with Mesa 26.1.8 ANV, after #3655:

Shader test #3655 With one fault-recording exit
flat_store 65 s 51 s
masked_global_store 4.7 s 3.8 s
flat_loads_x2_x3 0.2 s 0.2 s

These are the author's cold-compile measurements, not a local run. The change is a measured compile-time reduction; it does not claim a new correctness fix for current Mesa versions.

A later Intel HD Graphics 520 / Mesa 25.2.8 ANV report on DOOM Shareware found the opposite runtime tradeoff on the title's presentation dispatch: the median rose from about 527 ms on main to about 874 ms with this change, and 5/6 runs with the change hit an i915 reset and device loss versus 0/6 on main. The reporter's shader dump attributes this to increased register pressure and spills after replacing multiple fault exits with a merged exit. This PR is therefore not a general runtime performance improvement; the compile-time benefit comes with a measured regression on this Gen9 workload.

Tested

  • The regression assertion in agc_shader_memory requires exactly one lookup fault-recording call site.
  • The original author built this commit cherry-picked onto main da4d5f2e6 on Ubuntu 24.04 with GCC 13.3, Release, and an RTX 4070 Ti (NVIDIA 580.142). agc_shader_memory passed 3/3, including the new assertion.
  • In the same run, 530/531 agc_* tests passed; agc_host_import_sparse, agc_driver_sparse_dma_buf_import, and agc_driver_stencil_ref_export were skipped on that machine. The only failure, agc_driver_waterfall_images, also fails on unmodified main da4d5f2e6 with the same VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151 validation error.
  • git diff --check passes.
  • I did not build or run this follow-up locally.

Checklist

  • Based on current main; the original commit is a one-commit follow-up to merged #3655
  • One topic per PR
  • No comments in code except technical debt
  • Unimplemented paths still throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code or dependencies
  • Generic behavior, not specific to one title
  • Depends on: none
  • Refs: #2972
  • AI-assisted: yes (original implementation/commit metadata retained)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4857560522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T12:03:13Z. --- ### What Follow up on #3655 and the compiler-pressure measurements in #2972. The BDA page-table lookup currently emits separate `record_bda_fault` call sites for its table checks, unmapped index, and range checks. Collapse those branches to one fault-recording exit per lookup. The first failing check, check order, guarded table reads, and recorded reason/address/size/instruction stay unchanged; non-recording probe lookups remain non-recording. This carries Miles Coviello's follow-up commit from his public branch, preserving the original author and commit metadata. ### Measured The original author compared this follow-up on Intel Arrow Lake with Mesa 26.1.8 ANV, after #3655: | Shader test | #3655 | With one fault-recording exit | |---|---:|---:| | `flat_store` | 65 s | 51 s | | `masked_global_store` | 4.7 s | 3.8 s | | `flat_loads_x2_x3` | 0.2 s | 0.2 s | These are the author's cold-compile measurements, not a local run. The change is a measured compile-time reduction; it does not claim a new correctness fix for current Mesa versions. A later Intel HD Graphics 520 / Mesa 25.2.8 ANV report on DOOM Shareware found the opposite runtime tradeoff on the title's presentation dispatch: the median rose from about 527 ms on `main` to about 874 ms with this change, and 5/6 runs with the change hit an i915 reset and device loss versus 0/6 on `main`. The reporter's shader dump attributes this to increased register pressure and spills after replacing multiple fault exits with a merged exit. This PR is therefore not a general runtime performance improvement; the compile-time benefit comes with a measured regression on this Gen9 workload. ### Tested - The regression assertion in `agc_shader_memory` requires exactly one lookup fault-recording call site. - The original author built this commit cherry-picked onto `main` `da4d5f2e6` on Ubuntu 24.04 with GCC 13.3, Release, and an RTX 4070 Ti (NVIDIA 580.142). `agc_shader_memory` passed 3/3, including the new assertion. - In the same run, 530/531 `agc_*` tests passed; `agc_host_import_sparse`, `agc_driver_sparse_dma_buf_import`, and `agc_driver_stencil_ref_export` were skipped on that machine. The only failure, `agc_driver_waterfall_images`, also fails on unmodified `main` `da4d5f2e6` with the same `VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151` validation error. - `git diff --check` passes. - I did not build or run this follow-up locally. ### Checklist - [x] Based on current `main`; the original commit is a one-commit follow-up to merged #3655 - [x] One topic per PR - [x] No comments in code except technical debt - [x] Unimplemented paths still throw; no silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No new third-party code or dependencies - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] Refs: #2972 - [x] AI-assisted: yes (original implementation/commit metadata retained)
milescoviello commented 2026-10-14 12:10:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T12:10:31Z.


Thanks for carrying it. I built the commit cherry-picked onto main da4d5f2e6 (it applies cleanly; the branch itself is 37 commits behind): Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti with NVIDIA 580.142.

  • agc_shader_memory passes 3 of 3, with the new assertion that a lookup has one fault-recording call site.
  • 530 of 531 agc_* tests pass; agc_host_import_sparse, agc_driver_sparse_dma_buf_import and agc_driver_stencil_ref_export are skipped on this machine.
  • The one failure, agc_driver_waterfall_images, fails the same way on main da4d5f2e6 without this commit (VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151: local size 32×1 with the quad derivative group), so it is not from this change.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168018259 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6168018259). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T12:10:31Z. --- Thanks for carrying it. I built the commit cherry-picked onto `main` da4d5f2e6 (it applies cleanly; the branch itself is 37 commits behind): Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti with NVIDIA 580.142. - `agc_shader_memory` passes 3 of 3, with the new assertion that a lookup has one fault-recording call site. - 530 of 531 `agc_*` tests pass; `agc_host_import_sparse`, `agc_driver_sparse_dma_buf_import` and `agc_driver_stencil_ref_export` are skipped on this machine. - The one failure, `agc_driver_waterfall_images`, fails the same way on `main` da4d5f2e6 without this commit (`VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151`: local size 32×1 with the quad derivative group), so it is not from this change. AI-assisted: yes
MarcZX10 commented 2026-10-14 12:18:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T12:18:06Z.


Thanks for building the commit and checking the baseline. I added the agc_shader_memory 3/3 result, the 530/531 AGC suite count, skips, and the same failure on unmodified main to the Tested section of the PR description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168150030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6168150030). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T12:18:06Z. --- Thanks for building the commit and checking the baseline. I added the `agc_shader_memory` 3/3 result, the 530/531 AGC suite count, skips, and the same failure on unmodified `main` to the Tested section of the PR description.
milescoviello commented 2026-10-14 13:30:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T13:30:12Z.


odntht has since run this commit on the hardware #2972 is about, in https://github.com/boykopovar/AnyPS5/issues/5437#issuecomment-6169333279: an Intel HD Graphics 520 with Mesa 25.2.8 ANV, DOOM Shareware homebrew (PPSA99666) on main c7601b7.

  • main: 8 of 8 runs fall back to the CPU scaler, 2 of them after an i915 preemption reset.
  • main + 934348f2: no reset in 4 runs, and 2 of them stay on GPU presentation. The title's presentation kernel takes about 472 ms per dispatch, against about 690 ms on main, below i915's 640 ms preemption timeout.

My results above are NVIDIA only, so this is the first run of the change on an Intel GPU.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169517271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6169517271). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T13:30:12Z. --- odntht has since run this commit on the hardware #2972 is about, in https://github.com/boykopovar/AnyPS5/issues/5437#issuecomment-6169333279: an Intel HD Graphics 520 with Mesa 25.2.8 ANV, DOOM Shareware homebrew (PPSA99666) on `main` c7601b7. - `main`: 8 of 8 runs fall back to the CPU scaler, 2 of them after an i915 preemption reset. - `main` + 934348f2: no reset in 4 runs, and 2 of them stay on GPU presentation. The title's presentation kernel takes about 472 ms per dispatch, against about 690 ms on `main`, below i915's 640 ms preemption timeout. My results above are NVIDIA only, so this is the first run of the change on an Intel GPU. AI-assisted: yes
github-actions[bot] commented 2026-10-14 14:06:37 +00:00 (Migrated from github.com)

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


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5859 core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp L13-22, L40-45, L52-57, L126-127

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
#1341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#5828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#5867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#5884 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#6222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
#6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6170265650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6170265650). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T14:06:37Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5859 | `core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp` [L13-22](https://github.com/boykopovar/AnyPS5/blob/34454bd835ce334c3c395467da50546b433fe200/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L13-L22), [L40-45](https://github.com/boykopovar/AnyPS5/blob/34454bd835ce334c3c395467da50546b433fe200/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L40-L45), [L52-57](https://github.com/boykopovar/AnyPS5/blob/34454bd835ce334c3c395467da50546b433fe200/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L52-L57), [L126-127](https://github.com/boykopovar/AnyPS5/blob/34454bd835ce334c3c395467da50546b433fe200/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L126-L127) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | #1341 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #5371 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #5500 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #5828 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #5867 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #5884 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #6177 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #6222 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | #6235 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` |
github-actions[bot] commented 2026-10-14 17:56:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T17:56:48Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5859 core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp L13-22, L40-45, L52-57, L126-127
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174831276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6174831276). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T17:56:48Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5859 | `core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp` [L13-22](https://github.com/boykopovar/AnyPS5/blob/61cec424390984a861f16d7a603cb1eba3b1fe0b/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L13-L22), [L40-45](https://github.com/boykopovar/AnyPS5/blob/61cec424390984a861f16d7a603cb1eba3b1fe0b/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L40-L45), [L52-57](https://github.com/boykopovar/AnyPS5/blob/61cec424390984a861f16d7a603cb1eba3b1fe0b/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L52-L57), [L126-127](https://github.com/boykopovar/AnyPS5/blob/61cec424390984a861f16d7a603cb1eba3b1fe0b/core/shader/recompiler/SpirvBackend/src/SpirvBdaLookup.cpp#L126-L127) | | |
odntht commented 2026-10-14 18:45:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by odntht on 2026-10-14T18:45:27Z.


Gen9 data for this commit, and it has a cost on the HD 520 that the compile numbers do not show.

Setup: Intel HD Graphics 520 (Skylake GT2, 0x1916), Mesa 25.2.8 ANV (Ubuntu 24.04 container), Debian 13 host, kernel 6.12 (i915, preempt_timeout_ms 640), Weston headless with the GL renderer plus Xwayland. main 5adefa6f8 against main + abfc62077 (merged locally, no conflict), Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF.

Cold compile, median of 3 runs, Mesa cache emptied before every run, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU="HD Graphics 520":

Test c7601b7 (before #3655, 1 run) main main + this PR
agc_driver_flat_store 432.8 s 139.6 s 108.7 s
agc_driver_masked_global_store 129.4 s 9.9 s 8.1 s
agc_driver_flat_loads_x2_x3 18.9 s 0.41 s 0.35 s

agc_shader_memory passes on both, including the new assertion. So the compile gain on Gen9 matches the Arrow Lake numbers above.

Runtime is the other way. DOOM Shareware homebrew (PPSA99666 v1.1.1, relinked with --to-intel), the case from #5437. 6 runs of each build, alternated main / PR, warm Mesa cache, APS5_TRACE_GPU=1. The duration is from execute serial=3 to its WAIT_REG_MEM, which is the title's presentation kernel (0x202c81800):

main main + this PR
serial 3 dispatch 512 to 554 ms (median ~527) 853 to 891 ms (median ~874)
i915 GPU HANG (Resetting rcs0 for preemption time out) 0 of 6 5 of 6
vkWaitForFences present: Vulkan result -4 0 of 6 5 of 6
falls back to the CPU scaler 6 of 6 6 of 6

5 earlier back-to-back runs of each gave the same split (0 of 5 against 4 of 5 resets).

So on this GPU the single fault-recording exit makes that dispatch about 66% slower and pushes it past the 640 ms preemption timeout. On main it stays below it and the title only falls back to the CPU scaler. My guess is that the merged exit costs more at run time than the separate call sites did on Gen9, but I have not checked the generated code. I can dump the SPIR-V for 0x202c81800 from both builds if that helps.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175744107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6175744107). Originally posted by [odntht](https://github.com/odntht) on 2026-10-14T18:45:27Z. --- Gen9 data for this commit, and it has a cost on the HD 520 that the compile numbers do not show. Setup: Intel HD Graphics 520 (Skylake GT2, 0x1916), Mesa 25.2.8 ANV (Ubuntu 24.04 container), Debian 13 host, kernel 6.12 (i915, `preempt_timeout_ms` 640), Weston headless with the GL renderer plus Xwayland. `main` `5adefa6f8` against `main` + abfc62077 (merged locally, no conflict), Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Cold compile, median of 3 runs, Mesa cache emptied before every run, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_GPU="HD Graphics 520"`: | Test | `c7601b7` (before #3655, 1 run) | `main` | `main` + this PR | |---|---:|---:|---:| | `agc_driver_flat_store` | 432.8 s | 139.6 s | 108.7 s | | `agc_driver_masked_global_store` | 129.4 s | 9.9 s | 8.1 s | | `agc_driver_flat_loads_x2_x3` | 18.9 s | 0.41 s | 0.35 s | `agc_shader_memory` passes on both, including the new assertion. So the compile gain on Gen9 matches the Arrow Lake numbers above. Runtime is the other way. DOOM Shareware homebrew (PPSA99666 v1.1.1, relinked with `--to-intel`), the case from #5437. 6 runs of each build, alternated main / PR, warm Mesa cache, `APS5_TRACE_GPU=1`. The duration is from `execute serial=3` to its `WAIT_REG_MEM`, which is the title's presentation kernel (`0x202c81800`): | | `main` | `main` + this PR | |---|---:|---:| | serial 3 dispatch | 512 to 554 ms (median ~527) | 853 to 891 ms (median ~874) | | i915 `GPU HANG` (`Resetting rcs0 for preemption time out`) | 0 of 6 | 5 of 6 | | `vkWaitForFences present: Vulkan result -4` | 0 of 6 | 5 of 6 | | falls back to the CPU scaler | 6 of 6 | 6 of 6 | 5 earlier back-to-back runs of each gave the same split (0 of 5 against 4 of 5 resets). So on this GPU the single fault-recording exit makes that dispatch about 66% slower and pushes it past the 640 ms preemption timeout. On `main` it stays below it and the title only falls back to the CPU scaler. My guess is that the merged exit costs more at run time than the separate call sites did on Gen9, but I have not checked the generated code. I can dump the SPIR-V for `0x202c81800` from both builds if that helps. AI-assisted: yes
odntht commented 2026-10-14 18:51:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by odntht on 2026-10-14T18:51:13Z.


Follow-up with the shader dump I offered above. It points at register pressure in the Intel backend, not at the SPIR-V size.

Same machine and builds. The title creates one compute pipeline, captured with APS5_DUMP_COMPUTE_PIPELINES and ANYPS5_NO_SHADER_CACHE=1. ANV statistics come from INTEL_DEBUG=cs with an empty Mesa cache, one run each:

main main + this PR
SPIR-V words 27,503 27,755
OpFunctionCall 66 57
OpReturnValue 35 15
OpPhi 106 136
ANV SIMD32 instructions 49,568 58,069
spills:fills 1,276:3,901 1,868:5,540
sends 1,667 1,127
non-SSA regs after NIR 581 633

The module grows by under 1%. The single exit trades 9 call sites and 20 returns for 30 more phis. After NIR the backend needs 52 more registers, emits 17% more instructions and about 45% more spills and fills. On Gen9 those go to scratch memory, which fits the dispatch going from ~527 ms to ~874 ms. Fewer sends with more spills also fits the faster compile in the table above, with a slower result.

I have the two capture.aps5cp files and the full INTEL_DEBUG=cs output for both builds, and can attach them if useful.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175851999 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6175851999). Originally posted by [odntht](https://github.com/odntht) on 2026-10-14T18:51:13Z. --- Follow-up with the shader dump I offered above. It points at register pressure in the Intel backend, not at the SPIR-V size. Same machine and builds. The title creates one compute pipeline, captured with `APS5_DUMP_COMPUTE_PIPELINES` and `ANYPS5_NO_SHADER_CACHE=1`. ANV statistics come from `INTEL_DEBUG=cs` with an empty Mesa cache, one run each: | | `main` | `main` + this PR | |---|---:|---:| | SPIR-V words | 27,503 | 27,755 | | `OpFunctionCall` | 66 | 57 | | `OpReturnValue` | 35 | 15 | | `OpPhi` | 106 | 136 | | ANV SIMD32 instructions | 49,568 | 58,069 | | spills:fills | 1,276:3,901 | 1,868:5,540 | | sends | 1,667 | 1,127 | | non-SSA regs after NIR | 581 | 633 | The module grows by under 1%. The single exit trades 9 call sites and 20 returns for 30 more phis. After NIR the backend needs 52 more registers, emits 17% more instructions and about 45% more spills and fills. On Gen9 those go to scratch memory, which fits the dispatch going from ~527 ms to ~874 ms. Fewer sends with more spills also fits the faster compile in the table above, with a slower result. I have the two `capture.aps5cp` files and the full `INTEL_DEBUG=cs` output for both builds, and can attach them if useful. AI-assisted: yes
MarcZX10 commented 2026-10-15 02:06:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T02:06:55Z.


Thanks for the follow-up shader dump. The Gen9 run changes the tradeoff: the one-exit form cuts cold compile time in the cited tests, but on this real dispatch it increases latency from about 527 ms to 874 ms, raises spills/fills and register count, and crosses the reported 640 ms preemption threshold. I have updated the PR description to state the author-reported compile-time gain only; this should not be treated as a general performance improvement. Would maintainers prefer to close this follow-up or consider a separately gated/reworked form? I will leave the implementation unchanged pending that direction.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182753701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6182753701). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T02:06:55Z. --- Thanks for the follow-up shader dump. The Gen9 run changes the tradeoff: the one-exit form cuts cold compile time in the cited tests, but on this real dispatch it increases latency from about 527 ms to 874 ms, raises spills/fills and register count, and crosses the reported 640 ms preemption threshold. I have updated the PR description to state the author-reported compile-time gain only; this should not be treated as a general performance improvement. Would maintainers prefer to close this follow-up or consider a separately gated/reworked form? I will leave the implementation unchanged pending that direction.
adriadam10 commented 2026-10-15 13:08:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:08:00Z.


Closing: the PR's own measurements show a runtime regression that outweighs the compile-time gain.

  • On Intel HD Graphics 520 / Mesa 25.2.8 ANV (@odntht's runs on DOOM Shareware, PPSA99666), the presentation dispatch goes from ~527 ms on main to ~874 ms with this change, and 5 of 6 runs hit an i915 preemption reset (Resetting rcs0 for preemption time out, vkWaitForFences result -4) against 0 of 6 on main.
  • The ANV statistics point at register pressure: the merged exit trades 9 call sites and 20 returns for ~30 more OpPhi; the backend then needs 52 more registers, emits 17% more instructions and ~45% more spills/fills.
  • The compile-time gain is real (flat_store 139.6 s → 108.7 s on HD 520, 65 s → 51 s on Arrow Lake) but it only affects the cold compile of those tests, and a device loss at run time is not a trade we can take for it.

You are welcome to reopen with a variant that keeps the compile-time gain without raising register pressure on Gen9 (for example a lookup that avoids the extra phis), with the HD 520 dispatch time and reset counts in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192810339 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5814#issuecomment-6192810339). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T13:08:00Z. --- Closing: the PR's own measurements show a runtime regression that outweighs the compile-time gain. - On Intel HD Graphics 520 / Mesa 25.2.8 ANV (@odntht's runs on DOOM Shareware, PPSA99666), the presentation dispatch goes from ~527 ms on `main` to ~874 ms with this change, and 5 of 6 runs hit an i915 preemption reset (`Resetting rcs0 for preemption time out`, `vkWaitForFences` result -4) against 0 of 6 on `main`. - The ANV statistics point at register pressure: the merged exit trades 9 call sites and 20 returns for ~30 more `OpPhi`; the backend then needs 52 more registers, emits 17% more instructions and ~45% more spills/fills. - The compile-time gain is real (`flat_store` 139.6 s → 108.7 s on HD 520, 65 s → 51 s on Arrow Lake) but it only affects the cold compile of those tests, and a device loss at run time is not a trade we can take for it. You are welcome to reopen with a variant that keeps the compile-time gain without raising register pressure on Gen9 (for example a lookup that avoids the extra phis), with the HD 520 dispatch time and reset counts in the description.

Pull request closed

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!5814
No description provided.