perf(recompiler): keep the vector window's unindexed slots out of the array #5757

Merged
hypermoist merged 3 commits from upstream-pr/5757 into main 2026-10-15 13:58:25 +00:00
hypermoist commented 2026-10-14 09:36:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-14T09:36:46Z.


What

A program with any v_movreld/v_movrelsd/v_swaprel keeps its whole relative-addressing window in one Function-storage array (#3856), and with indexed writes every direct access to a window register goes through that array too. Drivers put an indexable array in local memory, so every register of the window stays in memory even when the relative accesses only reach a few of them. In a PPSA08427 (Killing Floor 3) compute program with 20 v_movrels/v_movreld, the window spans 167 registers while every relative index is v_bfe_u32 ..., 10, 2 (0 to 3); the SPIR-V had ~22k OpAccessChain into the array.

  • IndexedWindowSlots estimates the slots the relative accesses reach: it bounds each run-time index through the IR (bit-field extracts, masks, shifts, adds, selects, phis, ReadFirstLane, and the stores to a window slot that reach a load of it, walking the CFG back from the load).
  • The array then holds only the slots below the largest bound that is under half the window; every slot past it is a Function variable of its own, which the device can keep in a register. Accesses with a constant index use the array or the slot's variable directly.
  • A relative access whose index has no bound, or lands past the array at run time, branches: below the array size it indexes the array, else an OpSwitch over the slot variables loads or stores the right one. The estimate only affects speed, not results.
  • APS5_NO_WINDOW_NARROWING=1 turns it off (a recompiler switch, so it is part of the shader cache key).

On the PPSA08427 program above the array shrinks from 167 slots to 4 with 163 separate variables per lane half, and the module from 517983 to 484107 SPIR-V words (replayed from a dumped request on the PPSA08427 bring-up branch, whose request format main can't read).

Tested

CachyOS Linux (kernel 7.2.9), NVIDIA GeForce RTX 3060, driver 615.78.08, GCC 16.2.1, Release, this branch merged with main 8cd937e29.

  • New execution test agc_driver_vector_window_narrowing: a 32-register window whose one bounded index (s8 & 3) keeps the array to 4 slots, and whose data index (s9) reads and writes either the array or the separate variables at run time (data index 20, 2 and 31), wave32 and wave64. It also checks the window was split; with APS5_NO_WINDOW_NARROWING=1 that check fails.

  • Pass: agc_vector_window, agc_driver_vector_window_direct_access, agc_driver_relative_indexing, agc_driver_scalar_relative_indexing, agc_driver_dpp16_operands, agc_driver_pixel_wave_reduction, agc_driver_scalar_sop1, agc_shader_memory, and the new test.

  • spirv-val --target-env vulkan1.3 accepts the PPSA08427 program's module.

  • Speed, main 8cd937e29 vs this PR (and APS5_NO_WINDOW_NARROWING=1, which emits the same module as main): a compute micro-benchmark with a 167-register window, an ALU loop over every window register (256 iterations) and relative accesses with m0 = s8 & 3, 2048 groups of 64 threads, median of 15 dispatches after a warm-up, two process runs each:

    main PR, narrowing off PR
    wave32 70.2 ms 70.1 ms 1.9-2.1 ms
    wave64 123.3 ms 123.2-123.4 ms 7.8-7.9 ms
    wave32, plus an unbounded index past the array (50 / 166) 113.2 / 112.1 ms 5.95 / 5.81 ms

    The output buffer is identical in every mode. The benchmark is in the review reply; it is not part of this PR.

  • PPSA08427 hub (bring-up branch, which carries this change behind the same switch), three on and three off runs of 80 s: 19 presents per 10 s either way, and the GPU time of the eight most expensive programs within run-to-run noise. The game is bound by the CPU there, so the earlier 17-18 to 29 figure, which mixed this change with another, is withdrawn.

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
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060, driver 615.78.08, CachyOS Linux (kernel 7.2.9)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4855880700 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5757). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-14T09:36:46Z. --- ### What A program with any `v_movreld`/`v_movrelsd`/`v_swaprel` keeps its whole relative-addressing window in one Function-storage array (#3856), and with indexed writes every direct access to a window register goes through that array too. Drivers put an indexable array in local memory, so every register of the window stays in memory even when the relative accesses only reach a few of them. In a PPSA08427 (Killing Floor 3) compute program with 20 `v_movrels`/`v_movreld`, the window spans 167 registers while every relative index is `v_bfe_u32 ..., 10, 2` (0 to 3); the SPIR-V had ~22k `OpAccessChain` into the array. - `IndexedWindowSlots` estimates the slots the relative accesses reach: it bounds each run-time index through the IR (bit-field extracts, masks, shifts, adds, selects, phis, `ReadFirstLane`, and the stores to a window slot that reach a load of it, walking the CFG back from the load). - The array then holds only the slots below the largest bound that is under half the window; every slot past it is a Function variable of its own, which the device can keep in a register. Accesses with a constant index use the array or the slot's variable directly. - A relative access whose index has no bound, or lands past the array at run time, branches: below the array size it indexes the array, else an `OpSwitch` over the slot variables loads or stores the right one. The estimate only affects speed, not results. - `APS5_NO_WINDOW_NARROWING=1` turns it off (a recompiler switch, so it is part of the shader cache key). On the PPSA08427 program above the array shrinks from 167 slots to 4 with 163 separate variables per lane half, and the module from 517983 to 484107 SPIR-V words (replayed from a dumped request on the PPSA08427 bring-up branch, whose request format `main` can't read). ### Tested CachyOS Linux (kernel 7.2.9), NVIDIA GeForce RTX 3060, driver 615.78.08, GCC 16.2.1, Release, this branch merged with `main` 8cd937e29. - New execution test `agc_driver_vector_window_narrowing`: a 32-register window whose one bounded index (`s8 & 3`) keeps the array to 4 slots, and whose data index (`s9`) reads and writes either the array or the separate variables at run time (data index 20, 2 and 31), wave32 and wave64. It also checks the window was split; with `APS5_NO_WINDOW_NARROWING=1` that check fails. - Pass: `agc_vector_window`, `agc_driver_vector_window_direct_access`, `agc_driver_relative_indexing`, `agc_driver_scalar_relative_indexing`, `agc_driver_dpp16_operands`, `agc_driver_pixel_wave_reduction`, `agc_driver_scalar_sop1`, `agc_shader_memory`, and the new test. - `spirv-val --target-env vulkan1.3` accepts the PPSA08427 program's module. - Speed, `main` 8cd937e29 vs this PR (and `APS5_NO_WINDOW_NARROWING=1`, which emits the same module as `main`): a compute micro-benchmark with a 167-register window, an ALU loop over every window register (256 iterations) and relative accesses with `m0 = s8 & 3`, 2048 groups of 64 threads, median of 15 dispatches after a warm-up, two process runs each: | | `main` | PR, narrowing off | PR | |---|---|---|---| | wave32 | 70.2 ms | 70.1 ms | 1.9-2.1 ms | | wave64 | 123.3 ms | 123.2-123.4 ms | 7.8-7.9 ms | | wave32, plus an unbounded index past the array (50 / 166) | | 113.2 / 112.1 ms | 5.95 / 5.81 ms | The output buffer is identical in every mode. The benchmark is in the review reply; it is not part of this PR. - PPSA08427 hub (bring-up branch, which carries this change behind the same switch), three on and three off runs of 80 s: 19 presents per 10 s either way, and the GPU time of the eight most expensive programs within run-to-run noise. The game is bound by the CPU there, so the earlier 17-18 to 29 figure, which mixed this change with another, is withdrawn. ### Checklist - [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] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060, driver 615.78.08, CachyOS Linux (kernel 7.2.9) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo
adriadam10 commented 2026-10-14 13:32:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:32:53Z.

Review: CHANGES_REQUESTED


Checked on the PR merged onto current main: build + the Agc/AgcDriver ctest scope with SPIR-V tools ON, and the new agc_driver_vector_window_narrowing passes and fails without the change. The only red test, agc_driver_tessellation, also segfaults on main. The design is sound: the bound estimate only chooses what goes in the array, and every access stays correct (constant index, in-array, OpSwitch over the slot variables, 0 / dropped write past the window). APS5_NO_WINDOW_NARROWING is in the shader cache key.

Two things before this can merge:

  • No measured gain. The PR is a perf change with no before/after number. The description says there is no main-vs-PR capture, and the 17-18 → 29 presents figure mixes this with a relaxed-f16 change. Please post a paired measurement of this change alone (same scene or the same shader, main vs PR, several runs, driver named), or a micro-benchmark of the PPSA08427 program on your RTX 3060. The SPIR-V size drop is not a speed claim: whether the driver keeps the 163 separate variables in registers is exactly what the technical debt line says is not measured.
  • Stale technical debt. docs/dev/debt/shader.md:119 ("Relative vector addressing") still says every register from the lowest base up lives in one function-scope array. Update it for the narrowed array, the per-slot variables, the OpSwitch fallback and the switch, and say what you measured.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5518720178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5757#pullrequestreview-5518720178). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T13:32:53Z. **Review:** CHANGES_REQUESTED --- Checked on the PR merged onto current `main`: build + the Agc/AgcDriver ctest scope with SPIR-V tools ON, and the new `agc_driver_vector_window_narrowing` passes and fails without the change. The only red test, `agc_driver_tessellation`, also segfaults on `main`. The design is sound: the bound estimate only chooses what goes in the array, and every access stays correct (constant index, in-array, `OpSwitch` over the slot variables, 0 / dropped write past the window). `APS5_NO_WINDOW_NARROWING` is in the shader cache key. Two things before this can merge: - **No measured gain.** The PR is a perf change with no before/after number. The description says there is no `main`-vs-PR capture, and the 17-18 → 29 presents figure mixes this with a relaxed-f16 change. Please post a paired measurement of this change alone (same scene or the same shader, `main` vs PR, several runs, driver named), or a micro-benchmark of the PPSA08427 program on your RTX 3060. The SPIR-V size drop is not a speed claim: whether the driver keeps the 163 separate variables in registers is exactly what the technical debt line says is not measured. - **Stale technical debt.** `docs/dev/debt/shader.md:119` ("Relative vector addressing") still says every register from the lowest base up lives in one function-scope array. Update it for the narrowed array, the per-slot variables, the `OpSwitch` fallback and the switch, and say what you measured.
hypermoist commented 2026-10-15 03:03:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-15T03:03:06Z.


Thanks for the review. Both points are addressed in a4639ad2f (merged with current main, conflict-free):

Measured gain. The PR description now has a main vs PR micro-benchmark on the RTX 3060 (driver 615.78.08, CachyOS Linux). A compute program with a 167-register window whose ALU loop touches every window register:

main 8cd937e29 PR, APS5_NO_WINDOW_NARROWING=1 PR
wave32, m0 = s8 & 3 70.2 ms 70.1 ms 1.9-2.1 ms
wave64, m0 = s8 & 3 123.3 ms 123.2-123.4 ms 7.8-7.9 ms
wave32, plus m0 = s11 (50 / 166, past the array) 113.2 / 112.1 ms 5.95 / 5.81 ms

The numbers are the median of 15 dispatches of 2048 groups after a warm-up, with two process runs per cell. The output is identical across modes. main and the switched-off PR give the same module (9321 / 17003 SPIR-V words) and the same times. The unbounded-index row covers the OpSwitch fallback: it still runs about 19x faster than main. On this driver, a whole-window Function array costs far more than the per-slot variables plus the switch.

I also ran the PPSA08427 hub paired with the switch (three runs on, three off, 80 s each). Presents per 10 s are 19 either way, and the GPU time of the eight most expensive programs stays within run-to-run noise. The title is bound by the CPU there, so I withdrew the 17-18 → 29 figure, which mixed in another change.

Technical debt. I rewrote docs/dev/debt/shader.md "Relative vector addressing" to describe the bounded array, the per-slot variables, the OpSwitch fallback and APS5_NO_WINDOW_NARROWING, and added the measurement. Whether the driver keeps the variables in registers is still listed as not measured; the benchmark only shows the time difference.

The PR's tests pass on the merged tree: agc_vector_window, agc_driver_vector_window_direct_access, agc_driver_relative_indexing, agc_driver_scalar_relative_indexing and agc_driver_vector_window_narrowing. The new test still fails with the switch set.

Benchmark (not part of the PR): drop into core/libs/prx/libSceAgcDriver/tests/execution/VectorWindowBenchmark.cpp, run agc_driver_vector_window_benchmark_tests <wave> 256 [m0 for the unbounded variant]
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include "Recompiler.hpp"
#include "VulkanTestDevice.hpp"
#include <spirv/unified1/spirv.hpp>
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <span>
#include <vector>

namespace {

constexpr std::uint32_t Groups = 2048;
alignas(256) std::array<std::uint32_t, Groups * 64> Output{};

alignas(256) constexpr std::uint32_t Code[] = {
    // words from bench.s / bench2.s (llvm-mc -triple=amdgcn -mcpu=gfx1030), see below
};

alignas(256) constexpr std::uint32_t UnboundedCode[] = {
    // words from bench.s / bench2.s (llvm-mc -triple=amdgcn -mcpu=gfx1030), see below
};

std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t bytes) {
    const auto address = reinterpret_cast<std::uintptr_t>(data);
    return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu), bytes, 0x31016facu};
}

std::uint32_t FunctionVariables(std::span<const std::uint32_t> words) {
    std::uint32_t count = 0;
    for (std::size_t at = 5; at < words.size();) {
        const auto length = words[at] >> 16u;
        if (length == 0u) break;
        if ((words[at] & 0xffffu) == spv::OpVariable && at + 3u < words.size() && words[at + 3u] == spv::StorageClassFunction) ++count;
        at += length;
    }
    return count;
}

}

int main(int argc, char** argv) {
    const auto device = OpenVulkanTestDevice();
    if (!device) return VulkanTestSkipped;
    const std::uint32_t waveSize = argc > 1 ? std::atoi(argv[1]) : 64u;
    const std::uint32_t iterations = argc > 2 ? std::atoi(argv[2]) : 256u;
    std::vector<std::uint32_t> userData(12, 0u);
    const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size() * 4u));
    std::copy(output.begin(), output.end(), userData.begin() + 4);
    userData[8] = 7u;
    userData[9] = iterations;
    const bool unbounded = argc > 3;
    userData[11] = argc > 3 ? std::atoi(argv[3]) : 0u;
    const std::span<const std::uint32_t> code = unbounded ? std::span<const std::uint32_t>(UnboundedCode) : std::span<const std::uint32_t>(Code);
    const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
    const ShaderRecompiler::ShaderComputeStageInfo compute{{64, 1, 1}, 0u, {false, false, false}, false, 1};
    ShaderRecompiler::RecompileRequest request{
        {ShaderRecompiler::ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}},
        {waveSize, 0, userData, compute, std::nullopt, std::nullopt, memory},
        device->Target(),
        {0, 0, 0, 128}
    };
    request.useCache = false;
    const auto result = ShaderRecompiler::Recompile(request);
    device->Dispatch(result, Groups, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
    device->WaitIdle();
    const auto first = Output[5];
    std::vector<double> times;
    for (int run = 0; run < 15; ++run) {
        const auto start = std::chrono::steady_clock::now();
        device->Dispatch(result, Groups, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
        device->WaitIdle();
        times.push_back(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count());
    }
    std::sort(times.begin(), times.end());
    std::printf("%s wave%u iterations %u: %u function variables, %zu SPIR-V words, dispatch min %.2f ms median %.2f ms max %.2f ms, output[5] 0x%08x\n", unbounded ? "unbounded" : "bounded", waveSize, iterations, FunctionVariables(result.spirv.Words()), result.spirv.Words().size(), times.front(), times[times.size() / 2], times.back(), first);
    return 0;
}

bench.s (bench2.s adds s_mov_b32 m0, s11, v_movrels_b32 v5, v10, v_add_nc_u32 v4, v4, v5, v_movreld_b32 v10, v4 after the first v_movreld_b32):

v_lshlrev_b32 v2, 2, v0
v_add_nc_u32 v10, 0x0, v0
... (165 more: v_add_nc_u32 v(10+k), ((k * 2654435761) & 0xffff), v0)
v_add_nc_u32 v176, 0xe8c6, v0
s_mov_b32 s10, s9
loop:
v_add_nc_u32 v10, v10, v11
... (164 more, one per window register)
v_add_nc_u32 v175, v175, v176
v_xor_b32 v176, v176, v10
s_and_b32 m0, s8, 3
v_movrels_b32 v4, v10
v_add_nc_u32 v4, v4, v0
v_movreld_b32 v10, v4
s_sub_u32 s10, s10, 1
s_cmp_lg_u32 s10, 0
s_cbranch_scc1 loop
v_add_nc_u32 v4, v4, v176
buffer_store_dword v4, v2, s[4:7], 0 offen
s_endpgm

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6183430402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5757#issuecomment-6183430402). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-15T03:03:06Z. --- Thanks for the review. Both points are addressed in a4639ad2f (merged with current `main`, conflict-free): **Measured gain.** The PR description now has a `main` vs PR micro-benchmark on the RTX 3060 (driver 615.78.08, CachyOS Linux). A compute program with a 167-register window whose ALU loop touches every window register: | | `main` 8cd937e29 | PR, `APS5_NO_WINDOW_NARROWING=1` | PR | |---|---|---|---| | wave32, `m0 = s8 & 3` | 70.2 ms | 70.1 ms | 1.9-2.1 ms | | wave64, `m0 = s8 & 3` | 123.3 ms | 123.2-123.4 ms | 7.8-7.9 ms | | wave32, plus `m0 = s11` (50 / 166, past the array) | | 113.2 / 112.1 ms | 5.95 / 5.81 ms | The numbers are the median of 15 dispatches of 2048 groups after a warm-up, with two process runs per cell. The output is identical across modes. `main` and the switched-off PR give the same module (9321 / 17003 SPIR-V words) and the same times. The unbounded-index row covers the `OpSwitch` fallback: it still runs about 19x faster than `main`. On this driver, a whole-window `Function` array costs far more than the per-slot variables plus the switch. I also ran the PPSA08427 hub paired with the switch (three runs on, three off, 80 s each). Presents per 10 s are 19 either way, and the GPU time of the eight most expensive programs stays within run-to-run noise. The title is bound by the CPU there, so I withdrew the 17-18 → 29 figure, which mixed in another change. **Technical debt.** I rewrote `docs/dev/debt/shader.md` "Relative vector addressing" to describe the bounded array, the per-slot variables, the `OpSwitch` fallback and `APS5_NO_WINDOW_NARROWING`, and added the measurement. Whether the driver keeps the variables in registers is still listed as not measured; the benchmark only shows the time difference. The PR's tests pass on the merged tree: `agc_vector_window`, `agc_driver_vector_window_direct_access`, `agc_driver_relative_indexing`, `agc_driver_scalar_relative_indexing` and `agc_driver_vector_window_narrowing`. The new test still fails with the switch set. <details><summary>Benchmark (not part of the PR): drop into <code>core/libs/prx/libSceAgcDriver/tests/execution/VectorWindowBenchmark.cpp</code>, run <code>agc_driver_vector_window_benchmark_tests &lt;wave&gt; 256 [m0 for the unbounded variant]</code></summary> ```cpp #include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp" #include "Recompiler.hpp" #include "VulkanTestDevice.hpp" #include <spirv/unified1/spirv.hpp> #include <algorithm> #include <array> #include <chrono> #include <cstdint> #include <cstdio> #include <cstdlib> #include <span> #include <vector> namespace { constexpr std::uint32_t Groups = 2048; alignas(256) std::array<std::uint32_t, Groups * 64> Output{}; alignas(256) constexpr std::uint32_t Code[] = { // words from bench.s / bench2.s (llvm-mc -triple=amdgcn -mcpu=gfx1030), see below }; alignas(256) constexpr std::uint32_t UnboundedCode[] = { // words from bench.s / bench2.s (llvm-mc -triple=amdgcn -mcpu=gfx1030), see below }; std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t bytes) { const auto address = reinterpret_cast<std::uintptr_t>(data); return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu), bytes, 0x31016facu}; } std::uint32_t FunctionVariables(std::span<const std::uint32_t> words) { std::uint32_t count = 0; for (std::size_t at = 5; at < words.size();) { const auto length = words[at] >> 16u; if (length == 0u) break; if ((words[at] & 0xffffu) == spv::OpVariable && at + 3u < words.size() && words[at + 3u] == spv::StorageClassFunction) ++count; at += length; } return count; } } int main(int argc, char** argv) { const auto device = OpenVulkanTestDevice(); if (!device) return VulkanTestSkipped; const std::uint32_t waveSize = argc > 1 ? std::atoi(argv[1]) : 64u; const std::uint32_t iterations = argc > 2 ? std::atoi(argv[2]) : 256u; std::vector<std::uint32_t> userData(12, 0u); const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size() * 4u)); std::copy(output.begin(), output.end(), userData.begin() + 4); userData[8] = 7u; userData[9] = iterations; const bool unbounded = argc > 3; userData[11] = argc > 3 ? std::atoi(argv[3]) : 0u; const std::span<const std::uint32_t> code = unbounded ? std::span<const std::uint32_t>(UnboundedCode) : std::span<const std::uint32_t>(Code); const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}}; const ShaderRecompiler::ShaderComputeStageInfo compute{{64, 1, 1}, 0u, {false, false, false}, false, 1}; ShaderRecompiler::RecompileRequest request{ {ShaderRecompiler::ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}}, {waveSize, 0, userData, compute, std::nullopt, std::nullopt, memory}, device->Target(), {0, 0, 0, 128} }; request.useCache = false; const auto result = ShaderRecompiler::Recompile(request); device->Dispatch(result, Groups, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data())); device->WaitIdle(); const auto first = Output[5]; std::vector<double> times; for (int run = 0; run < 15; ++run) { const auto start = std::chrono::steady_clock::now(); device->Dispatch(result, Groups, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data())); device->WaitIdle(); times.push_back(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count()); } std::sort(times.begin(), times.end()); std::printf("%s wave%u iterations %u: %u function variables, %zu SPIR-V words, dispatch min %.2f ms median %.2f ms max %.2f ms, output[5] 0x%08x\n", unbounded ? "unbounded" : "bounded", waveSize, iterations, FunctionVariables(result.spirv.Words()), result.spirv.Words().size(), times.front(), times[times.size() / 2], times.back(), first); return 0; } ``` `bench.s` (bench2.s adds `s_mov_b32 m0, s11`, `v_movrels_b32 v5, v10`, `v_add_nc_u32 v4, v4, v5`, `v_movreld_b32 v10, v4` after the first `v_movreld_b32`): ```asm v_lshlrev_b32 v2, 2, v0 v_add_nc_u32 v10, 0x0, v0 ... (165 more: v_add_nc_u32 v(10+k), ((k * 2654435761) & 0xffff), v0) v_add_nc_u32 v176, 0xe8c6, v0 s_mov_b32 s10, s9 loop: v_add_nc_u32 v10, v10, v11 ... (164 more, one per window register) v_add_nc_u32 v175, v175, v176 v_xor_b32 v176, v176, v10 s_and_b32 m0, s8, 3 v_movrels_b32 v4, v10 v_add_nc_u32 v4, v4, v0 v_movreld_b32 v10, v4 s_sub_u32 s10, s10, 1 s_cmp_lg_u32 s10, 0 s_cbranch_scc1 loop v_add_nc_u32 v4, v4, v176 buffer_store_dword v4, v2, s[4:7], 0 offen s_endpgm ``` </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-15 12:09:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:09:14Z.


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
#3891 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4048 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/shader.md
#4156 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4396 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4397 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4422 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4423 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4424 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4520 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4521 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4522 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4523 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4566 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4599 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4650 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
#4718 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4740 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4749 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4760 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#4813 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#5021 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
docs/dev/debt/shader.md
#5371 docs/dev/debt/shader.md
#5426 docs/dev/debt/shader.md
#5500 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/shader.md
#5804 docs/dev/debt/shader.md
#5828 docs/dev/debt/shader.md
#5884 core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
#6177 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
#6222 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/shader.md
#6235 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/shader.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191697157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5757#issuecomment-6191697157). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:09:14Z. --- <!-- pr-overlap --> 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 | |---|---| | #3891 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4048 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp`<br>`docs/dev/debt/shader.md` | | #4156 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4396 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4397 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4422 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4423 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4424 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4520 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4521 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4522 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4523 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4566 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4599 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4650 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | #4718 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4740 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4749 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4760 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #4813 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #5021 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`docs/dev/debt/shader.md` | | #5371 | `docs/dev/debt/shader.md` | | #5426 | `docs/dev/debt/shader.md` | | #5500 | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp`<br>`docs/dev/debt/shader.md` | | #5804 | `docs/dev/debt/shader.md` | | #5828 | `docs/dev/debt/shader.md` | | #5884 | `core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | #6177 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` | | #6222 | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp`<br>`docs/dev/debt/shader.md` | | #6235 | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp`<br>`docs/dev/debt/shader.md` |
adriadam10 commented 2026-10-15 12:36:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T12:36:47Z.

Review: APPROVED


Re-checked on the PR merged onto current main: build + Agc/AgcDriver ctest, agc_driver_vector_window_narrowing passes; the only red test, agc_driver_tessellation, also segfaults on main. Both earlier points are addressed: the paired main / narrowing-off / PR measurement is in the description (and the withdrawn presents figure), and the technical debt line for relative vector addressing now describes the narrowed array, the slot variables, the OpSwitch fallback, the switch and the numbers. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5533171609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5757#pullrequestreview-5533171609). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T12:36:47Z. **Review:** APPROVED --- Re-checked on the PR merged onto current `main`: build + Agc/AgcDriver ctest, `agc_driver_vector_window_narrowing` passes; the only red test, `agc_driver_tessellation`, also segfaults on `main`. Both earlier points are addressed: the paired `main` / narrowing-off / PR measurement is in the description (and the withdrawn presents figure), and the technical debt line for relative vector addressing now describes the narrowed array, the slot variables, the `OpSwitch` fallback, the switch and the numbers. Merging once the full Build is green.
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!5757
No description provided.