perf(shader): keep the vector window to the blocks between relative accesses #15520

Merged
beardsciences merged 2 commits from upstream-pr/15520 into main 2026-11-09 18:35:01 +00:00
beardsciences commented 2026-11-03 17:18:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by beardsciences on 2026-11-03T17:18:56Z.


What

A program that addresses vector registers relatively (v_movrels_b32, v_movreld_b32, v_movrelsd_b32, v_movrelsd_2_b32, v_swaprel_b32) keeps its registers from the lowest relatively addressed one up in a window array. When it also writes through the window, every direct access in every block went through that array, even in blocks no relative access can reach or follow.

This keeps the window only in the blocks on a path from one relative access to another (the relative blocks plus every block both reachable from one and reaching one). Every other block keeps the registers in SSA values. Execution cannot return into those blocks once it leaves them, so the registers are copied into the window once where control enters them and, for a program with relative writes, back where it leaves. A copy sits at the start of the target block when all of that block's predecessors are on the other side, otherwise at the end of the source block. When the relative blocks are the whole program nothing changes. APS5_NO_SCOPED_VECTOR_WINDOW=1 keeps every block in the window; it is a recompiler switch, so it is part of the shader cache key.

The case that showed it: MediEvil: Resurrection (PPSA07550) runs in the PS5's PSP emulator, whose clipping geometry program (3184 words) has all 104 of its relative accesses in a section entered only by a wave with a primitive to clip. With APS5_PIPELINE_STATS=1 on NVIDIA (RTX 3060 Ti), a run from boot to the 3D menu creates 27 pipelines with that program. On main each of their mesh executables has 255 registers, 13,648–14,928 bytes of local memory per thread and 1.57–1.61 MB of code; with this change 255 registers, 3,312–3,744 bytes and 1.24–1.27 MB (Local Memory Size less the 2^36 the driver adds to every value; both logs attached). That program draws all of the title's 3D; every PS5 PSP release runs the same emulator.

pipeline-stats-main-4f41f4c375.txt
pipeline-stats-pr-a572e50206.txt

Cost in PPSA07550 gameplay: Dan's Crypt, the first level, with Sir Dan standing at the start after the level's opening movie (no input after the menu; presents and GPU time stay flat in 5 s steps across every window in the table). RTX 3060 Ti, warm caches, APS5_TRACE_SECONDS=640:60 and no other trace or profile switch, runs alternating in the order main 1, change 1, main 2, change 2, main 3. main is 4f41f4c375, the change is this PR's commit a572e50206 on it.

presents in 60 s frame p50 / p90 / p99 ms GPU busy per present
main, run 2 597 99.2 / 193.3 / 216.2 99.9 ms
main, run 3 662 89.8 / 163.1 / 184.7 90.4 ms
change, run 1 1590 37.9 / 42.7 / 58.4 37.3 ms
change, run 2 1578 38.9 / 42.3 / 59.5 37.6 ms

Each build first ran once untraced with frame dumps to warm the caches. main's untraced run never started a new game (its scripted presses did not get it past the menu), so its traced run 1 was the first to build the level's pipelines and was still in the level's opening movie during the window (1739 presents, 6.1 ms GPU busy per present); it is not in the table, but its trace and summary are attached. The four runs in the table report trace_dropped (the event buffers of the queue worker and the draw committer filled after 7–33 s); totals_full is false for every thread, so the summary numbers are complete. Traces and tools/trace_digest.py output attached.

aps5-trace-4f41f4c375f5-22248.json.gz
aps5-trace-4f41f4c375f5-38360.json.gz
aps5-trace-4f41f4c375f5-41496.json.gz
aps5-trace-a572e502064e-42364.json.gz
aps5-trace-a572e502064e-43468.json.gz
digest-main-1.txt
digest-main-2.txt
digest-main-3.txt
digest-pr-1.txt
digest-pr-2.txt
summary-main-1.txt
summary-main-2.txt
summary-main-3.txt
summary-pr-1.txt
summary-pr-2.txt

Summary lines, in run order
{"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":13995,"ms":60028.524},"presents":1739,"frame_ms":{"p50":31.114,"p90":40.619,"p99":41.598,"max":42.083},"gpu_busy_ms_per_present":6.134,"worker_busy_pct":{"queue worker 0x0":7.300},"top_phases_ms_per_frame":{"VideoOut.Flip":6.491,"VideoOut.Flip.present":6.307,"Driver.Present":6.306,"Driver.Present.render_fence_wait":5.904,"Vulkan.Retire":5.904,"Vulkan.Retire.wait":5.895,"Driver.Packet":2.509,"Graphics.Draw":1.749},"trace_dropped":false,"trace":"aps5-trace-4f41f4c375f5-41496.json.gz"}
{"commit":"a572e502064e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":18241,"ms":60018.478},"presents":1590,"frame_ms":{"p50":37.942,"p90":42.748,"p99":58.382,"max":71.954},"gpu_busy_ms_per_present":37.330,"worker_busy_pct":{"queue worker 0x0":86.640},"top_phases_ms_per_frame":{"Driver.Packet":32.675,"VideoOut.Flip":32.297,"Driver.Present":32.126,"VideoOut.Flip.present":32.108,"Driver.Present.render_fence_wait":31.464,"Vulkan.Retire":31.464,"Vulkan.Retire.wait":31.453,"Driver.Packet.draw":25.329},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.504,"events_lost":1830725,"totals_full":false},"draw committer":{"events_full_after_s":12.089,"events_lost":1021395,"totals_full":false}},"trace":"aps5-trace-a572e502064e-42364.json.gz"}
{"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":16452,"ms":60059.768},"presents":597,"frame_ms":{"p50":99.172,"p90":193.318,"p99":216.152,"max":287.487},"gpu_busy_ms_per_present":99.915,"worker_busy_pct":{"queue worker 0x0":90.310},"top_phases_ms_per_frame":{"VideoOut.Flip":99.029,"Driver.Present":98.523,"VideoOut.Flip.present":98.352,"Driver.Present.render_fence_wait":97.692,"Vulkan.Retire":97.692,"Vulkan.Retire.wait":97.678,"Driver.Packet":90.811,"Driver.Packet.rendering_wait":61.132},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":19.348,"events_lost":559515,"totals_full":false},"draw committer":{"events_full_after_s":32.833,"events_lost":215610,"totals_full":false}},"trace":"aps5-trace-4f41f4c375f5-38360.json.gz"}
{"commit":"a572e502064e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":18227,"ms":60015.649},"presents":1578,"frame_ms":{"p50":38.879,"p90":42.327,"p99":59.463,"max":79.446},"gpu_busy_ms_per_present":37.623,"worker_busy_pct":{"queue worker 0x0":83.734},"top_phases_ms_per_frame":{"VideoOut.Flip":34.866,"Driver.Present":34.688,"VideoOut.Flip.present":34.669,"Driver.Present.render_fence_wait":33.932,"Vulkan.Retire":33.932,"Vulkan.Retire.wait":33.921,"Driver.Packet":31.820,"Driver.Packet.draw":23.122},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.508,"events_lost":1822930,"totals_full":false},"draw committer":{"events_full_after_s":12.721,"events_lost":977646,"totals_full":false}},"trace":"aps5-trace-a572e502064e-43468.json.gz"}
{"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":16690,"ms":60158.202},"presents":662,"frame_ms":{"p50":89.835,"p90":163.077,"p99":184.732,"max":189.693},"gpu_busy_ms_per_present":90.375,"worker_busy_pct":{"queue worker 0x0":92.326},"top_phases_ms_per_frame":{"VideoOut.Flip":90.028,"Driver.Present":89.502,"VideoOut.Flip.present":89.373,"Driver.Present.render_fence_wait":88.815,"Vulkan.Retire":88.815,"Vulkan.Retire.wait":88.803,"Driver.Packet":83.860,"Driver.Packet.rendering_wait":60.556},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":17.294,"events_lost":636913,"totals_full":false},"draw committer":{"events_full_after_s":31.818,"events_lost":231696,"totals_full":false}},"trace":"aps5-trace-4f41f4c375f5-22248.json.gz"}

#15362 (open) stops zeroing the NVIDIA mesh window buffer at workgroup start; it and this PR change different files and merge without a conflict. Neither build above has it.

The change edits the recompiler, so the shader cache's source version changes and cached modules are rebuilt once.

Tests: agc_vector_window gains a translation check that registers outside a loop of relative writes stay out of the window (it fails on main). The new GPU test agc_driver_vector_window_region runs relative reads and writes inside a loop that only some waves enter, in wave32 and wave64, with a fully active, a partly active and a skipped wave, and covers each copy placement: into the window at the end of a source block and at the start of a target block, back at the start of a target block and at the end of a source block that also leads to a join, and a window that includes the entry block, read relatively at a register only the entry prologue sets (added in a04c37a63c after review). It also checks inactive lanes, a register only read relatively and a register never written. docs/dev/debt/shader.md describes the scoped window and where its copies run.

Overlap: 172 open PRs share a file with this one. tools/pr_overlap.py --branch finds no overlap with the 98 it could compare; it could not compare the other 74 because they conflict with main. Checked by hand with git merge-tree of each against main and against this branch: 70 add no conflict with this change, among them #7410, #10359, #11265 and #11490 (they edit InstructionTranslator.cpp or TranslationContext.hpp) and #12548 (VectorWindow.cpp). #6924, #10757 and #12324 each add an ENVIRONMENT.md row in the same place as this PR's row, and #14212 rewraps the whole debt file, so whichever of those lands second needs a one-line rebase. #15362 and this PR merge without a conflict.

Tested

Windows 11, NVIDIA GeForce RTX 3060 Ti, driver 621.01 (32.0.16.2101). main is 4f41f4c375 and the change is this PR's commit a572e50206 on it; every build below is a clean tree at one of those two commits, apart from the two local edits named in the second item. tools/check_conventions.py --base origin/main passes.

  • Validation, main and the change: ctest --test-dir build -R "mesh|vector_window|relative|window_lane|ngg|provoking" -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer; both logs attached, each starting with its commit. Neither contains was not found but was requested by env var VK_INSTANCE_LAYERS; the loader inserts VK_LAYER_KHRONOS_validation into every Vulkan instance (24 in main's run, 25 in the change's, which has the new test), next to the machine's implicit layers (NVIDIA's and the OBS and Overwolf capture hooks). The layer reports the same 20 messages in both, all WARNING-VkImageSubresourceRange-layerCount-compatibility, and no VUID- error. main passes 28 of 28, the change 29 of 29.
    validation-main-4f41f4c375.txt
    validation-pr-a572e50206.txt

  • agc_driver_vector_window_region fails when any copy placement is removed from the translator (local edits, not in this PR): without the copies at the start of a target block, loop, wave32 lane 0 v10 is 0x00000002, expected 0x00000001; without the copies at the end of a source block, v1 is 0x00000000, expected 0x00000001; without the copy into the window after the entry prologue (entryIr.SyncVectorWindow(true), checked at a04c37a63c), entry block reads an input register, wave32 lane 1 v1 is 0xdeadbeef, expected 0x00000011. The new agc_vector_window check fails with APS5_NO_SCOPED_VECTOR_WINDOW=1.

  • agc_driver_mesh_vector_window_waves passes with this change (2 of 2) and still fails with APS5_NO_MESH_WINDOW_BUFFER=1 (2 of 2, wrong threads per wave: 0 64 64 64); log attached.
    regression-pr-a572e50206.txt

  • python tools/select_tests.py ctest build --output-on-failure --timeout 120 --parallel 4 on the change: 3907 of 3919 pass. Six of the twelve failures pass when run alone. The other six: test_registration and select_tests_MissingCommandTests need symlink rights (os.symlink, WinError 1314), annotate_module and conventions_wrapped_declarations time out, and agc_driver_direct_write_completion and agc_driver_store_over_untracked fail the same way on main and with APS5_NO_SCOPED_VECTOR_WINDOW=1 (neither has relative addressing).

  • MediEvil: Resurrection (PPSA07550), both builds from boot through the 3D main menu, the New Game movie and Dan's Crypt: the menu and the level render the same.

    Before: main, the spot the traces measure (frames from separate runs of the same builds with APS5_DUMP_FRAMES).
    gameplay-main

    After: this PR, the same spot.
    gameplay-pr

    Pixel compare of these two frames: 5,911 of 518,400 pixels differ (1.14 %), 49 of them by more than 24 of 255, all on Sir Dan's idle pose, the flickering light in the doorway and a few dust pixels; the rest is identical bit for bit. The closest pair of frames within one build differs more: main 1.95 %, this PR 1.55 %. Red marks every pixel that differs.
    dans-crypt-diff-main-vs-change

    3D main menu, main and then this PR (the skeleton's idle pose differs between the two frames).
    menu-main
    menu-pr

  • Not tested here: AMD and Intel GPUs (the change applies on every GPU), other NVIDIA GPUs and drivers. TechLevelZero's CI passed on a572e50206 and a04c37a63c on an NVIDIA RTX 2000 Ada (Linux, 595.99.02) and an AMD Radeon RX 6300 (RADV, Mesa 25.2.8).

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: NVIDIA GeForce RTX 3060 Ti, driver 621.01 (32.0.16.2101), Windows 11
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5141549294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15520). Originally posted by [beardsciences](https://github.com/beardsciences) on 2026-11-03T17:18:56Z. --- ### What A program that addresses vector registers relatively (`v_movrels_b32`, `v_movreld_b32`, `v_movrelsd_b32`, `v_movrelsd_2_b32`, `v_swaprel_b32`) keeps its registers from the lowest relatively addressed one up in a window array. When it also writes through the window, every direct access in every block went through that array, even in blocks no relative access can reach or follow. This keeps the window only in the blocks on a path from one relative access to another (the relative blocks plus every block both reachable from one and reaching one). Every other block keeps the registers in SSA values. Execution cannot return into those blocks once it leaves them, so the registers are copied into the window once where control enters them and, for a program with relative writes, back where it leaves. A copy sits at the start of the target block when all of that block's predecessors are on the other side, otherwise at the end of the source block. When the relative blocks are the whole program nothing changes. `APS5_NO_SCOPED_VECTOR_WINDOW=1` keeps every block in the window; it is a recompiler switch, so it is part of the shader cache key. The case that showed it: MediEvil: Resurrection (PPSA07550) runs in the PS5's PSP emulator, whose clipping geometry program (3184 words) has all 104 of its relative accesses in a section entered only by a wave with a primitive to clip. With `APS5_PIPELINE_STATS=1` on NVIDIA (RTX 3060 Ti), a run from boot to the 3D menu creates 27 pipelines with that program. On `main` each of their mesh executables has 255 registers, 13,648–14,928 bytes of local memory per thread and 1.57–1.61 MB of code; with this change 255 registers, 3,312–3,744 bytes and 1.24–1.27 MB (`Local Memory Size` less the 2^36 the driver adds to every value; both logs attached). That program draws all of the title's 3D; every PS5 PSP release runs the same emulator. [pipeline-stats-main-4f41f4c375.txt](https://github.com/user-attachments/files/34331338/pipeline-stats-main-4f41f4c375.txt) [pipeline-stats-pr-a572e50206.txt](https://github.com/user-attachments/files/34331339/pipeline-stats-pr-a572e50206.txt) Cost in PPSA07550 gameplay: Dan's Crypt, the first level, with Sir Dan standing at the start after the level's opening movie (no input after the menu; presents and GPU time stay flat in 5 s steps across every window in the table). RTX 3060 Ti, warm caches, `APS5_TRACE_SECONDS=640:60` and no other trace or profile switch, runs alternating in the order `main` 1, change 1, `main` 2, change 2, `main` 3. `main` is 4f41f4c375, the change is this PR's commit a572e50206 on it. | | presents in 60 s | frame p50 / p90 / p99 ms | GPU busy per present | |---|---|---|---| | `main`, run 2 | 597 | 99.2 / 193.3 / 216.2 | 99.9 ms | | `main`, run 3 | 662 | 89.8 / 163.1 / 184.7 | 90.4 ms | | change, run 1 | 1590 | 37.9 / 42.7 / 58.4 | 37.3 ms | | change, run 2 | 1578 | 38.9 / 42.3 / 59.5 | 37.6 ms | Each build first ran once untraced with frame dumps to warm the caches. `main`'s untraced run never started a new game (its scripted presses did not get it past the menu), so its traced run 1 was the first to build the level's pipelines and was still in the level's opening movie during the window (1739 presents, 6.1 ms GPU busy per present); it is not in the table, but its trace and summary are attached. The four runs in the table report `trace_dropped` (the event buffers of the queue worker and the draw committer filled after 7–33 s); `totals_full` is false for every thread, so the summary numbers are complete. Traces and `tools/trace_digest.py` output attached. [aps5-trace-4f41f4c375f5-22248.json.gz](https://github.com/user-attachments/files/34331380/aps5-trace-4f41f4c375f5-22248.json.gz) [aps5-trace-4f41f4c375f5-38360.json.gz](https://github.com/user-attachments/files/34331382/aps5-trace-4f41f4c375f5-38360.json.gz) [aps5-trace-4f41f4c375f5-41496.json.gz](https://github.com/user-attachments/files/34331384/aps5-trace-4f41f4c375f5-41496.json.gz) [aps5-trace-a572e502064e-42364.json.gz](https://github.com/user-attachments/files/34331385/aps5-trace-a572e502064e-42364.json.gz) [aps5-trace-a572e502064e-43468.json.gz](https://github.com/user-attachments/files/34331386/aps5-trace-a572e502064e-43468.json.gz) [digest-main-1.txt](https://github.com/user-attachments/files/34331389/digest-main-1.txt) [digest-main-2.txt](https://github.com/user-attachments/files/34331390/digest-main-2.txt) [digest-main-3.txt](https://github.com/user-attachments/files/34331391/digest-main-3.txt) [digest-pr-1.txt](https://github.com/user-attachments/files/34331392/digest-pr-1.txt) [digest-pr-2.txt](https://github.com/user-attachments/files/34331393/digest-pr-2.txt) [summary-main-1.txt](https://github.com/user-attachments/files/34331394/summary-main-1.txt) [summary-main-2.txt](https://github.com/user-attachments/files/34331395/summary-main-2.txt) [summary-main-3.txt](https://github.com/user-attachments/files/34331396/summary-main-3.txt) [summary-pr-1.txt](https://github.com/user-attachments/files/34331397/summary-pr-1.txt) [summary-pr-2.txt](https://github.com/user-attachments/files/34331398/summary-pr-2.txt) <details><summary>Summary lines, in run order</summary> ```json {"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":13995,"ms":60028.524},"presents":1739,"frame_ms":{"p50":31.114,"p90":40.619,"p99":41.598,"max":42.083},"gpu_busy_ms_per_present":6.134,"worker_busy_pct":{"queue worker 0x0":7.300},"top_phases_ms_per_frame":{"VideoOut.Flip":6.491,"VideoOut.Flip.present":6.307,"Driver.Present":6.306,"Driver.Present.render_fence_wait":5.904,"Vulkan.Retire":5.904,"Vulkan.Retire.wait":5.895,"Driver.Packet":2.509,"Graphics.Draw":1.749},"trace_dropped":false,"trace":"aps5-trace-4f41f4c375f5-41496.json.gz"} {"commit":"a572e502064e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":18241,"ms":60018.478},"presents":1590,"frame_ms":{"p50":37.942,"p90":42.748,"p99":58.382,"max":71.954},"gpu_busy_ms_per_present":37.330,"worker_busy_pct":{"queue worker 0x0":86.640},"top_phases_ms_per_frame":{"Driver.Packet":32.675,"VideoOut.Flip":32.297,"Driver.Present":32.126,"VideoOut.Flip.present":32.108,"Driver.Present.render_fence_wait":31.464,"Vulkan.Retire":31.464,"Vulkan.Retire.wait":31.453,"Driver.Packet.draw":25.329},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.504,"events_lost":1830725,"totals_full":false},"draw committer":{"events_full_after_s":12.089,"events_lost":1021395,"totals_full":false}},"trace":"aps5-trace-a572e502064e-42364.json.gz"} {"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":16452,"ms":60059.768},"presents":597,"frame_ms":{"p50":99.172,"p90":193.318,"p99":216.152,"max":287.487},"gpu_busy_ms_per_present":99.915,"worker_busy_pct":{"queue worker 0x0":90.310},"top_phases_ms_per_frame":{"VideoOut.Flip":99.029,"Driver.Present":98.523,"VideoOut.Flip.present":98.352,"Driver.Present.render_fence_wait":97.692,"Vulkan.Retire":97.692,"Vulkan.Retire.wait":97.678,"Driver.Packet":90.811,"Driver.Packet.rendering_wait":61.132},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":19.348,"events_lost":559515,"totals_full":false},"draw committer":{"events_full_after_s":32.833,"events_lost":215610,"totals_full":false}},"trace":"aps5-trace-4f41f4c375f5-38360.json.gz"} {"commit":"a572e502064e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":18227,"ms":60015.649},"presents":1578,"frame_ms":{"p50":38.879,"p90":42.327,"p99":59.463,"max":79.446},"gpu_busy_ms_per_present":37.623,"worker_busy_pct":{"queue worker 0x0":83.734},"top_phases_ms_per_frame":{"VideoOut.Flip":34.866,"Driver.Present":34.688,"VideoOut.Flip.present":34.669,"Driver.Present.render_fence_wait":33.932,"Vulkan.Retire":33.932,"Vulkan.Retire.wait":33.921,"Driver.Packet":31.820,"Driver.Packet.draw":23.122},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.508,"events_lost":1822930,"totals_full":false},"draw committer":{"events_full_after_s":12.721,"events_lost":977646,"totals_full":false}},"trace":"aps5-trace-a572e502064e-43468.json.gz"} {"commit":"4f41f4c375f5","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"640:60"},"gpu":"NVIDIA GeForce RTX 3060 Ti","driver":"NVIDIA 621.01","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32674,"title_id":"PPSA07550","title":"MediEvil: Resurrection","content_version":"01.000.003","resolution":"3840x2160","window":{"spec":"seconds 640:60","first_present":16690,"ms":60158.202},"presents":662,"frame_ms":{"p50":89.835,"p90":163.077,"p99":184.732,"max":189.693},"gpu_busy_ms_per_present":90.375,"worker_busy_pct":{"queue worker 0x0":92.326},"top_phases_ms_per_frame":{"VideoOut.Flip":90.028,"Driver.Present":89.502,"VideoOut.Flip.present":89.373,"Driver.Present.render_fence_wait":88.815,"Vulkan.Retire":88.815,"Vulkan.Retire.wait":88.803,"Driver.Packet":83.860,"Driver.Packet.rendering_wait":60.556},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":17.294,"events_lost":636913,"totals_full":false},"draw committer":{"events_full_after_s":31.818,"events_lost":231696,"totals_full":false}},"trace":"aps5-trace-4f41f4c375f5-22248.json.gz"} ``` </details> #15362 (open) stops zeroing the NVIDIA mesh window buffer at workgroup start; it and this PR change different files and merge without a conflict. Neither build above has it. The change edits the recompiler, so the shader cache's source version changes and cached modules are rebuilt once. Tests: `agc_vector_window` gains a translation check that registers outside a loop of relative writes stay out of the window (it fails on `main`). The new GPU test `agc_driver_vector_window_region` runs relative reads and writes inside a loop that only some waves enter, in wave32 and wave64, with a fully active, a partly active and a skipped wave, and covers each copy placement: into the window at the end of a source block and at the start of a target block, back at the start of a target block and at the end of a source block that also leads to a join, and a window that includes the entry block, read relatively at a register only the entry prologue sets (added in a04c37a63c after review). It also checks inactive lanes, a register only read relatively and a register never written. `docs/dev/debt/shader.md` describes the scoped window and where its copies run. Overlap: 172 open PRs share a file with this one. `tools/pr_overlap.py --branch` finds no overlap with the 98 it could compare; it could not compare the other 74 because they conflict with `main`. Checked by hand with `git merge-tree` of each against `main` and against this branch: 70 add no conflict with this change, among them #7410, #10359, #11265 and #11490 (they edit `InstructionTranslator.cpp` or `TranslationContext.hpp`) and #12548 (`VectorWindow.cpp`). #6924, #10757 and #12324 each add an `ENVIRONMENT.md` row in the same place as this PR's row, and #14212 rewraps the whole debt file, so whichever of those lands second needs a one-line rebase. #15362 and this PR merge without a conflict. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, NVIDIA GeForce RTX 3060 Ti, driver 621.01 (32.0.16.2101). `main` is 4f41f4c375f5abb487dbd184fbc150f31994d762 and the change is this PR's commit a572e502064e488ff130b37a19bea17981789e91 on it; every build below is a clean tree at one of those two commits, apart from the two local edits named in the second item. `tools/check_conventions.py --base origin/main` passes. - Validation, `main` and the change: `ctest --test-dir build -R "mesh|vector_window|relative|window_lane|ngg|provoking" -V` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LOADER_DEBUG=layer`; both logs attached, each starting with its commit. Neither contains `was not found but was requested by env var VK_INSTANCE_LAYERS`; the loader inserts `VK_LAYER_KHRONOS_validation` into every Vulkan instance (24 in `main`'s run, 25 in the change's, which has the new test), next to the machine's implicit layers (NVIDIA's and the OBS and Overwolf capture hooks). The layer reports the same 20 messages in both, all `WARNING-VkImageSubresourceRange-layerCount-compatibility`, and no `VUID-` error. `main` passes 28 of 28, the change 29 of 29. [validation-main-4f41f4c375.txt](https://github.com/user-attachments/files/34331413/validation-main-4f41f4c375.txt) [validation-pr-a572e50206.txt](https://github.com/user-attachments/files/34331414/validation-pr-a572e50206.txt) - `agc_driver_vector_window_region` fails when any copy placement is removed from the translator (local edits, not in this PR): without the copies at the start of a target block, `loop, wave32 lane 0 v10 is 0x00000002, expected 0x00000001`; without the copies at the end of a source block, `v1 is 0x00000000, expected 0x00000001`; without the copy into the window after the entry prologue (`entryIr.SyncVectorWindow(true)`, checked at a04c37a63c), `entry block reads an input register, wave32 lane 1 v1 is 0xdeadbeef, expected 0x00000011`. The new `agc_vector_window` check fails with `APS5_NO_SCOPED_VECTOR_WINDOW=1`. - `agc_driver_mesh_vector_window_waves` passes with this change (2 of 2) and still fails with `APS5_NO_MESH_WINDOW_BUFFER=1` (2 of 2, wrong threads per wave: 0 64 64 64); log attached. [regression-pr-a572e50206.txt](https://github.com/user-attachments/files/34331429/regression-pr-a572e50206.txt) - `python tools/select_tests.py ctest build --output-on-failure --timeout 120 --parallel 4` on the change: 3907 of 3919 pass. Six of the twelve failures pass when run alone. The other six: `test_registration` and `select_tests_MissingCommandTests` need symlink rights (`os.symlink`, WinError 1314), `annotate_module` and `conventions_wrapped_declarations` time out, and `agc_driver_direct_write_completion` and `agc_driver_store_over_untracked` fail the same way on `main` and with `APS5_NO_SCOPED_VECTOR_WINDOW=1` (neither has relative addressing). - MediEvil: Resurrection (PPSA07550), both builds from boot through the 3D main menu, the New Game movie and Dan's Crypt: the menu and the level render the same. **Before:** `main`, the spot the traces measure (frames from separate runs of the same builds with `APS5_DUMP_FRAMES`). <img width="960" height="540" alt="gameplay-main" src="https://github.com/user-attachments/assets/4dae62e7-e40f-4767-a8aa-b739344957ec" /> **After:** this PR, the same spot. <img width="960" height="540" alt="gameplay-pr" src="https://github.com/user-attachments/assets/2bd01b7b-14c5-47f9-a8e7-00c43f58d09a" /> **Pixel compare** of these two frames: 5,911 of 518,400 pixels differ (1.14 %), 49 of them by more than 24 of 255, all on Sir Dan's idle pose, the flickering light in the doorway and a few dust pixels; the rest is identical bit for bit. The closest pair of frames within one build differs more: `main` 1.95 %, this PR 1.55 %. Red marks every pixel that differs. <img width="960" height="540" alt="dans-crypt-diff-main-vs-change" src="https://github.com/user-attachments/assets/9921ab92-1569-4488-afab-6b3d77e05ad7" /> **3D main menu,** `main` and then this PR (the skeleton's idle pose differs between the two frames). <img width="960" height="540" alt="menu-main" src="https://github.com/user-attachments/assets/80422143-4480-4a76-aeef-7529b14ad8ca" /> <img width="960" height="540" alt="menu-pr" src="https://github.com/user-attachments/assets/c066e97b-2a5b-43c0-9c4f-52f06836ace8" /> - Not tested here: AMD and Intel GPUs (the change applies on every GPU), other NVIDIA GPUs and drivers. TechLevelZero's CI passed on a572e50206 and a04c37a63c on an NVIDIA RTX 2000 Ada (Linux, 595.99.02) and an AMD Radeon RX 6300 (RADV, Mesa 25.2.8). ### 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: NVIDIA GeForce RTX 3060 Ti, driver 621.01 (32.0.16.2101), Windows 11 - [x] AI-assisted: yes (Claude Code)
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!15520
No description provided.