perf(agc): reuse image tables that hold storage-viewed entries #15563

Merged
XatiX merged 3 commits from upstream-pr/15563 into main 2026-11-08 23:55:41 +00:00
XatiX commented 2026-11-03 19:02:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XatiX on 2026-11-03T19:02:29Z.


What

An image table was reused across draws only if every one of its entries was provably unchanged. One entry that failed the check, for example a sampled texture viewed through its cached storage image (SampledFromStorageEligible: host-imported memory and a storage-capable, uncompressed format), made the whole table resolve again on every draw.

Now such an entry is marked live in the remembered table. When the table is reused, a live entry is resolved through cachedTexture on every draw, as a fresh table resolves it, and the remaining entries are reused as before. CachedTableTextures and the revalidation path skip live entries in the same way. Entries that are rejected, written by the dispatch, or past the table capacity are handled as before.

PPSA18653 binds a table of about 14,200 entries in each of about 730 draws per frame. About 1.6% of each table (about 229 entries) are storage-viewed, so no table was ever reused, and Resources.Complete took about 5.5 s per frame.

The new step in agc_driver_image_table_reuse host-imports a guest block, so its entries are storage-viewed, and then checks three things:

  • the table is reused across three dispatches;
  • the texels written by two image stores, which leave results pending over one entry between those dispatches, are sampled;
  • the stores reach guest memory after a flush.

On main it fails with 0 reused and 3 resolved tables, expected 3 and 0.

Tested

  • Windows 11 Pro 26300, NVIDIA GeForce RTX 5080, driver 617.42.
  • ctest -V -R "table|texture|storage|sampled|bindless" with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1. Both runs were on the same machine, with the related execution tests built (ANYPS5_AGC_EXECUTION_TESTS):
    • this change: 117/117 passed;
    • main: 115/117 passed. Only agc_driver_image_table_reuse and agc_driver_image_table_reuse_draw_pipeline fail;
    • neither log reports the layer as not found, and neither has a VUID- error. The same 4 tests skip in both runs (multisampled pass order and 3 packed16 storage formats). Logs attached.
  • Performance: PPSA18653 (Age of Mythology: Retold v01.043) on the first-run welcome screen, idle, 3840x2160. Captured with APS5_TRACE_SECONDS=20:60 after a warm run, with no other trace or profile switch and the log not redirected. main cannot reach this screen on its own, so both builds carry #15327 (GPU hang) and the opt-in clock change, run with APS5_FAIL_UNKNOWN_CLOCKS=1. The base is 68a15ec229 and the change is 12ed9524c8, the same tree plus this commit. Traces attached.
base change
presents in the window 9 20
frame p50 / p90 7965 / 8423 ms 3178 / 3370 ms
Resources.Complete per frame 5495 ms 1206 ms
GPU busy per present 397 ms 298 ms
{"commit":"68a15ec2299e","dirty":false,"env":{"APS5_FAIL_UNKNOWN_CLOCKS":"1","APS5_TRACE_SECONDS":"20:60"},"gpu":"NVIDIA GeForce RTX 5080","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 9800X3D 8-Core Processor","cpu_threads":16,"memory_mib":32404,"title_id":"PPSA18653","title":"Age of Mythology: Retold","content_version":"01.043.000","resolution":"3840x2160","window":{"spec":"seconds 20:60","first_present":505,"ms":65172.035},"presents":9,"frame_ms":{"p50":7965.365,"p90":8422.926,"p99":8422.926,"max":8422.926},"gpu_busy_ms_per_present":396.860,"worker_busy_pct":{"queue worker 0x0":99.978},"top_phases_ms_per_frame":{"Driver.Packet":7239.496,"Driver.Packet.draw":7108.396,"Driver.Draw":7107.726,"Driver.Draw.draw_and_resource_release":5623.944,"Graphics.Draw":5599.273,"Graphics.Draw.draw_and_resource_release":5589.065,"Resources.Complete":5494.540,"Driver.Draw.shader_compile_and_link":1463.332},"trace_dropped":false,"trace":"aps5-trace-68a15ec2299e-15048.json.gz"}
{"commit":"12ed9524c874","dirty":false,"env":{"APS5_FAIL_UNKNOWN_CLOCKS":"1","APS5_TRACE_SECONDS":"20:60"},"gpu":"NVIDIA GeForce RTX 5080","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 9800X3D 8-Core Processor","cpu_threads":16,"memory_mib":32404,"title_id":"PPSA18653","title":"Age of Mythology: Retold","content_version":"01.043.000","resolution":"3840x2160","window":{"spec":"seconds 20:60","first_present":506,"ms":60279.308},"presents":20,"frame_ms":{"p50":3178.079,"p90":3369.582,"p99":3401.643,"max":3401.643},"gpu_busy_ms_per_present":298.053,"worker_busy_pct":{"queue worker 0x0":99.953},"top_phases_ms_per_frame":{"Driver.Packet":3012.245,"Driver.Packet.draw":2941.594,"Driver.Draw":2941.148,"Driver.Draw.shader_compile_and_link":1574.332,"Driver.Draw.draw_and_resource_release":1349.491,"Graphics.Draw":1324.282,"Graphics.Draw.draw_and_resource_release":1315.625,"Resources.Complete":1205.909},"trace_dropped":false,"trace":"aps5-trace-12ed9524c874-25392.json.gz"}
  • Other titles are not measured.
  • tools/check_conventions.py passes. tools/pr_overlap.py --branch reports one line overlap, with #9508 at ShaderResources.cpp L5466-5467: both change the capacity condition of the reuse loop, and the merge keeps both.

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. It speeds up PPSA18653 #15328 (welcome screen 8.0 to 3.2 s per frame), which still needs #15327
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 617.42, Windows 11 Pro 26300
  • AI-assisted: yes
    aps5-trace-12ed9524c874-25392.json.gz
    aps5-trace-68a15ec2299e-15048.json.gz
    change-ctest.log
    main-ctest.log

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5142926530 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15563). Originally posted by [XatiX](https://github.com/XatiX) on 2026-11-03T19:02:29Z. --- ### What An image table was reused across draws only if every one of its entries was provably unchanged. One entry that failed the check, for example a sampled texture viewed through its cached storage image (`SampledFromStorageEligible`: host-imported memory and a storage-capable, uncompressed format), made the whole table resolve again on every draw. Now such an entry is marked live in the remembered table. When the table is reused, a live entry is resolved through `cachedTexture` on every draw, as a fresh table resolves it, and the remaining entries are reused as before. `CachedTableTextures` and the revalidation path skip live entries in the same way. Entries that are rejected, written by the dispatch, or past the table capacity are handled as before. PPSA18653 binds a table of about 14,200 entries in each of about 730 draws per frame. About 1.6% of each table (about 229 entries) are storage-viewed, so no table was ever reused, and `Resources.Complete` took about 5.5 s per frame. The new step in `agc_driver_image_table_reuse` host-imports a guest block, so its entries are storage-viewed, and then checks three things: - the table is reused across three dispatches; - the texels written by two image stores, which leave results pending over one entry between those dispatches, are sampled; - the stores reach guest memory after a flush. On `main` it fails with `0 reused and 3 resolved tables, expected 3 and 0`. ### Tested - Windows 11 Pro 26300, NVIDIA GeForce RTX 5080, driver 617.42. - `ctest -V -R "table|texture|storage|sampled|bindless"` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`. Both runs were on the same machine, with the related execution tests built (`ANYPS5_AGC_EXECUTION_TESTS`): - this change: 117/117 passed; - `main`: 115/117 passed. Only `agc_driver_image_table_reuse` and `agc_driver_image_table_reuse_draw_pipeline` fail; - neither log reports the layer as not found, and neither has a `VUID-` error. The same 4 tests skip in both runs (multisampled pass order and 3 packed16 storage formats). Logs attached. - Performance: PPSA18653 (Age of Mythology: Retold v01.043) on the first-run welcome screen, idle, 3840x2160. Captured with `APS5_TRACE_SECONDS=20:60` after a warm run, with no other trace or profile switch and the log not redirected. `main` cannot reach this screen on its own, so both builds carry #15327 (GPU hang) and the opt-in clock change, run with `APS5_FAIL_UNKNOWN_CLOCKS=1`. The base is `68a15ec229` and the change is `12ed9524c8`, the same tree plus this commit. Traces attached. | | base | change | |---|---|---| | presents in the window | 9 | 20 | | frame p50 / p90 | 7965 / 8423 ms | 3178 / 3370 ms | | `Resources.Complete` per frame | 5495 ms | 1206 ms | | GPU busy per present | 397 ms | 298 ms | ```json {"commit":"68a15ec2299e","dirty":false,"env":{"APS5_FAIL_UNKNOWN_CLOCKS":"1","APS5_TRACE_SECONDS":"20:60"},"gpu":"NVIDIA GeForce RTX 5080","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 9800X3D 8-Core Processor","cpu_threads":16,"memory_mib":32404,"title_id":"PPSA18653","title":"Age of Mythology: Retold","content_version":"01.043.000","resolution":"3840x2160","window":{"spec":"seconds 20:60","first_present":505,"ms":65172.035},"presents":9,"frame_ms":{"p50":7965.365,"p90":8422.926,"p99":8422.926,"max":8422.926},"gpu_busy_ms_per_present":396.860,"worker_busy_pct":{"queue worker 0x0":99.978},"top_phases_ms_per_frame":{"Driver.Packet":7239.496,"Driver.Packet.draw":7108.396,"Driver.Draw":7107.726,"Driver.Draw.draw_and_resource_release":5623.944,"Graphics.Draw":5599.273,"Graphics.Draw.draw_and_resource_release":5589.065,"Resources.Complete":5494.540,"Driver.Draw.shader_compile_and_link":1463.332},"trace_dropped":false,"trace":"aps5-trace-68a15ec2299e-15048.json.gz"} ``` ```json {"commit":"12ed9524c874","dirty":false,"env":{"APS5_FAIL_UNKNOWN_CLOCKS":"1","APS5_TRACE_SECONDS":"20:60"},"gpu":"NVIDIA GeForce RTX 5080","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 9800X3D 8-Core Processor","cpu_threads":16,"memory_mib":32404,"title_id":"PPSA18653","title":"Age of Mythology: Retold","content_version":"01.043.000","resolution":"3840x2160","window":{"spec":"seconds 20:60","first_present":506,"ms":60279.308},"presents":20,"frame_ms":{"p50":3178.079,"p90":3369.582,"p99":3401.643,"max":3401.643},"gpu_busy_ms_per_present":298.053,"worker_busy_pct":{"queue worker 0x0":99.953},"top_phases_ms_per_frame":{"Driver.Packet":3012.245,"Driver.Packet.draw":2941.594,"Driver.Draw":2941.148,"Driver.Draw.shader_compile_and_link":1574.332,"Driver.Draw.draw_and_resource_release":1349.491,"Graphics.Draw":1324.282,"Graphics.Draw.draw_and_resource_release":1315.625,"Resources.Complete":1205.909},"trace_dropped":false,"trace":"aps5-trace-12ed9524c874-25392.json.gz"} ``` - Other titles are not measured. - `tools/check_conventions.py` passes. `tools/pr_overlap.py --branch` reports one line overlap, with #9508 at `ShaderResources.cpp` L5466-5467: both change the capacity condition of the reuse loop, and the merge keeps both. ### 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] Fixes: none - [x] Unblocks: none. It speeds up PPSA18653 #15328 (welcome screen 8.0 to 3.2 s per frame), which still needs #15327 - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 617.42, Windows 11 Pro 26300 - [x] AI-assisted: yes [aps5-trace-12ed9524c874-25392.json.gz](https://github.com/user-attachments/files/34335287/aps5-trace-12ed9524c874-25392.json.gz) [aps5-trace-68a15ec2299e-15048.json.gz](https://github.com/user-attachments/files/34335288/aps5-trace-68a15ec2299e-15048.json.gz) [change-ctest.log](https://github.com/user-attachments/files/34341814/change-ctest.log) [main-ctest.log](https://github.com/user-attachments/files/34341815/main-ctest.log) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
XairRrR commented 2026-11-03 19:14:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T19:14:11Z.

Review: APPROVED


Reviewed — approved

The change marks entries that cannot be proven unchanged as live and re-resolves them through cachedTexture on every reuse. That path does the same work as a fresh resolve. The new test step fails on main and passes with the change, and I found nothing blocking.

What I ran

Head 38e7f40892e428811467e05ede279911e15151e0, main 1e658521a0a599872612bb91949311e2956b5283, merged tree 48eb641f852164cb1e1a8b7d4575de365ac2b81c. Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).

git diff --check 1e658521a0a599872612bb91949311e2956b5283...38e7f40892e428811467e05ede279911e15151e0
python3 tools/check_conventions.py --base 1e658521a0a599872612bb91949311e2956b5283
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R image_table_reuse
# negative control
git show 1e658521a0a599872612bb91949311e2956b5283:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
ninja -C build agc_driver_image_table_reuse_tests
ctest --test-dir build --output-on-failure -R image_table_reuse
git show 48eb641f852164cb1e1a8b7d4575de365ac2b81c:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
ninja -C build libSceAgcDriver agc_driver_image_table_reuse_tests
git status --porcelain
ctest --test-dir build -R image_table_reuse

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build of the merged tree (script) ok
Selected tests (script, 2151 ran) no new failures and no timeouts. The 7 known failures also fail on main (agc_driver_division, the denormal-mode tests, vector_constant_factor_tininess and one unwrap test)
Validation comparison (script, 772 Vulkan tests) the layer loaded in 771 tests and was missing in none; no new VUID- lines compared with main
agc_driver_image_table_reuse (validation on) passed, 0.76 s
agc_driver_image_table_reuse_draw_pipeline (validation on) passed, 0.74 s

Host imports are available on lavapipe here, so RunViewedStore actually ran. The "host imports are unavailable" skip line does not appear in the output.

Negative control

I restored ShaderResources.cpp from main and kept the new test. Both tests then fail with the message the description quotes:

output
1/2 Test #1276: agc_driver_image_table_reuse .................***Failed    0.67 sec
AGC graphics: image table reuse: a table of storage-viewed entries, image stores leaving results pending over one between dispatches: 0 reused and 3 resolved tables, expected 3 and 0
2/2 Test #1822: agc_driver_image_table_reuse_draw_pipeline ...***Failed    0.65 sec
AGC graphics: image table reuse: a table of storage-viewed entries, image stores leaving results pending over one between dispatches: 0 reused and 3 resolved tables, expected 3 and 0

After I restored the merged file and rebuilt, both tests pass again, and git status --porcelain is empty.

Findings

Blocking

None.

Non-blocking

  1. A table with no reusable entries now takes a reuse slot. In the fresh path, an entry that fails the lookup-log check is pushed as live (core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5649-5651), and reusable stays true. So a table whose entries are all live is still remembered at ShaderResources.cpp:5656-5665. Two examples are a table of DCC-compressed entries and a table of entries with looked->source != nullptr.

    • On main such a table was never remembered.
    • Now every later draw runs TableCurrent and CachedTableTextures and then resolves every entry again anyway, so it gains nothing.
    • It also takes one of the ReusedTableCount = 4 thread-local slots (ShaderResources.cpp:2032), which can push out a table that does benefit from reuse.

    Suggested fix: skip RememberTable when no element is non-live and non-rejected (for example, when fresh.queries is empty).

  2. The live branch in revalidateFull repeats the fallback loop. The new branch at ShaderResources.cpp:3827-3836 repeats the decode and cachedTexture comparison of the fallback loop at ShaderResources.cpp:3847-3855. A small shared lambda would keep the two from drifting apart, for example if the fallback later gains layerRowsBinding the way the non-table walk at ShaderResources.cpp:3795 has it.

I also checked these and found no problem:

  • Reuse matches a fresh resolve. resolveLive does the same steps as the fresh path (decodeEntry, prepareSampled with CompletePendingCpuWrites, lookupSampled, bind). In the reuse path, storageTable and item != nullptr already exclude the imageWritten and missing-binding branches.
  • The cached-texture cursor stays in step. next advances the same way in CachedTableTextures, in the capacity branch and in the reuse loop.
  • The aggregate initialiser {{}, {}, {}, 0, firstLayer, false, {}, true} is correct. It matches the field order (live comes after message).
  • Every pass through the fresh loop either adds one element or clears reusable. So fresh.elements keeps its size equal to binding.count.

Not verified

  • I did not check the PPSA18653 performance numbers or the attached traces, and I did not launch any title. The trace commits (68a15ec229 / 12ed9524c8) also carry #15327 and are not the PR head, as the description says.
  • I did not check the claimed line overlap with #9508.
  • I could not check behaviour on non-lavapipe GPUs. The author reports an NVIDIA RTX 5080 run.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5758095953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15563#pullrequestreview-5758095953). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T19:14:11Z. **Review:** APPROVED --- # Reviewed — approved The change marks entries that cannot be proven unchanged as live and re-resolves them through `cachedTexture` on every reuse. That path does the same work as a fresh resolve. The new test step fails on `main` and passes with the change, and I found nothing blocking. ## What I ran Head `38e7f40892e428811467e05ede279911e15151e0`, `main` `1e658521a0a599872612bb91949311e2956b5283`, merged tree `48eb641f852164cb1e1a8b7d4575de365ac2b81c`. Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19). ``` git diff --check 1e658521a0a599872612bb91949311e2956b5283...38e7f40892e428811467e05ede279911e15151e0 python3 tools/check_conventions.py --base 1e658521a0a599872612bb91949311e2956b5283 env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R image_table_reuse # negative control git show 1e658521a0a599872612bb91949311e2956b5283:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp ninja -C build agc_driver_image_table_reuse_tests ctest --test-dir build --output-on-failure -R image_table_reuse git show 48eb641f852164cb1e1a8b7d4575de365ac2b81c:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp ninja -C build libSceAgcDriver agc_driver_image_table_reuse_tests git status --porcelain ctest --test-dir build -R image_table_reuse ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build of the merged tree (script) | ok | | Selected tests (script, 2151 ran) | no new failures and no timeouts. The 7 known failures also fail on `main` (`agc_driver_division`, the denormal-mode tests, `vector_constant_factor_tininess` and one unwrap test) | | Validation comparison (script, 772 Vulkan tests) | the layer loaded in 771 tests and was missing in none; no new `VUID-` lines compared with `main` | | `agc_driver_image_table_reuse` (validation on) | passed, 0.76 s | | `agc_driver_image_table_reuse_draw_pipeline` (validation on) | passed, 0.74 s | Host imports are available on lavapipe here, so `RunViewedStore` actually ran. The "host imports are unavailable" skip line does not appear in the output. ## Negative control I restored `ShaderResources.cpp` from `main` and kept the new test. Both tests then fail with the message the description quotes: <details><summary>output</summary> ``` 1/2 Test #1276: agc_driver_image_table_reuse .................***Failed 0.67 sec AGC graphics: image table reuse: a table of storage-viewed entries, image stores leaving results pending over one between dispatches: 0 reused and 3 resolved tables, expected 3 and 0 2/2 Test #1822: agc_driver_image_table_reuse_draw_pipeline ...***Failed 0.65 sec AGC graphics: image table reuse: a table of storage-viewed entries, image stores leaving results pending over one between dispatches: 0 reused and 3 resolved tables, expected 3 and 0 ``` </details> After I restored the merged file and rebuilt, both tests pass again, and `git status --porcelain` is empty. ## Findings ### Blocking None. ### Non-blocking 1. **A table with no reusable entries now takes a reuse slot.** In the fresh path, an entry that fails the lookup-log check is pushed as live (`core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5649-5651`), and `reusable` stays true. So a table whose entries are *all* live is still remembered at `ShaderResources.cpp:5656-5665`. Two examples are a table of DCC-compressed entries and a table of entries with `looked->source != nullptr`. - On `main` such a table was never remembered. - Now every later draw runs `TableCurrent` and `CachedTableTextures` and then resolves every entry again anyway, so it gains nothing. - It also takes one of the `ReusedTableCount = 4` thread-local slots (`ShaderResources.cpp:2032`), which can push out a table that does benefit from reuse. Suggested fix: skip `RememberTable` when no element is non-live and non-rejected (for example, when `fresh.queries` is empty). 2. **The live branch in `revalidateFull` repeats the fallback loop.** The new branch at `ShaderResources.cpp:3827-3836` repeats the decode and `cachedTexture` comparison of the fallback loop at `ShaderResources.cpp:3847-3855`. A small shared lambda would keep the two from drifting apart, for example if the fallback later gains `layerRowsBinding` the way the non-table walk at `ShaderResources.cpp:3795` has it. I also checked these and found no problem: - **Reuse matches a fresh resolve.** `resolveLive` does the same steps as the fresh path (`decodeEntry`, `prepareSampled` with `CompletePendingCpuWrites`, `lookupSampled`, `bind`). In the reuse path, `storageTable` and `item != nullptr` already exclude the `imageWritten` and missing-binding branches. - **The cached-texture cursor stays in step.** `next` advances the same way in `CachedTableTextures`, in the capacity branch and in the reuse loop. - **The aggregate initialiser `{{}, {}, {}, 0, firstLayer, false, {}, true}` is correct.** It matches the field order (`live` comes after `message`). - **Every pass through the fresh loop either adds one element or clears `reusable`.** So `fresh.elements` keeps its size equal to `binding.count`. ## Not verified - I did not check the PPSA18653 performance numbers or the attached traces, and I did not launch any title. The trace commits (`68a15ec229` / `12ed9524c8`) also carry #15327 and are not the PR head, as the description says. - I did not check the claimed line overlap with #9508. - I could not check behaviour on non-lavapipe GPUs. The author reports an NVIDIA RTX 5080 run. <!-- anyps5-bots job=3546 head=38e7f40892e428811467e05ede279911e15151e0 -->
XairRrR commented 2026-11-03 20:07:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T20:07:03Z.

Review: APPROVED


Re-checked — approved

Commit b2ca8faf64 resolves both non-blocking points from my last review. A table whose entries are all live is no longer remembered, and the two revalidateFull paths share currentTableEntry. The tests and the negative control behave as expected.

What changed since my last review

  • New commit b2ca8faf64 ("keep tables with nothing to reuse out of the reuse slots"). Commit 38e7f40892 is unchanged.
    • ShaderResources.cpp:5677-5678 adds anyKept. A table is remembered only when at least one element is not live. Rejected elements count as not live, so a table of rejected entries is still remembered, as on main.
    • ShaderResources.cpp:3812-3820 adds the currentTableEntry lambda, which is now used by the live branch (:3838) and by the fallback loop (:3853).
  • Test changes. RunViewedStore now points records Viewed..Records at a second block that is not imported (plain). The table therefore mixes kept and live entries, and the expected count goes from 3 reused / 0 resolved to 4 / 0. A new step at ImageTableReuse.cpp:296-301 binds a table of only storage-viewed entries and expects 0 reused and 2 resolved.
  • Author reply in the discussion, describing the above.

What I ran

Head b2ca8faf642de09526cd5d4a7b98574d7e7a7b5f, main 086c0686c8adff3ee648fdbe34e0b0b647e1d511, merged tree 0a25af341deac165d5a9ded01ebc7082aa852e88. Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).

git diff --check 086c0686c8adff3ee648fdbe34e0b0b647e1d511...b2ca8faf642de09526cd5d4a7b98574d7e7a7b5f
python3 tools/check_conventions.py --base 086c0686c8adff3ee648fdbe34e0b0b647e1d511
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R image_table_reuse
# negative control 1: drop only the new anyKept condition
sed -i "s/if (reusable && anyKept && CurrentTableState() == state)/if (reusable \&\& CurrentTableState() == state)/" core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
ninja -C build agc_driver_image_table_reuse_tests
ctest --test-dir build --output-on-failure -R image_table_reuse
# negative control 2: all production code from main
git show 086c0686c8adff3ee648fdbe34e0b0b647e1d511:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
ninja -C build agc_driver_image_table_reuse_tests
ctest --test-dir build --output-on-failure -R image_table_reuse
# validation lines of agc_driver_image_gather_volume, with the PR's file and with main's file
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R "^agc_driver_image_gather_volume$"
# restore
git show 0a25af341deac165d5a9ded01ebc7082aa852e88:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
ninja -C build libSceAgcDriver agc_driver_image_gather_volume_tests agc_driver_image_table_reuse_tests
git status --porcelain
ctest --test-dir build -R image_table_reuse
Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build of the merged tree (script) ok
Selected tests (script, 2171 ran) no new failures and no timeouts. The 7 known failures also fail on the baseline main
agc_driver_image_table_reuse / _draw_pipeline (validation on) both passed, 0.80 s and 0.76 s; host imports are available, so RunViewedStore ran
Validation comparison (script, 783 tests, layer loaded in 782, missing in none) one test with new lines, agc_driver_image_gather_volume. These lines come from main, not from this PR (see below)
Negative control 1 (anyKept removed) both tests fail: a table of only storage-viewed entries, which has nothing to reuse: 1 reused and 1 resolved tables, expected 0 and 2 (the message the author quoted)
Negative control 2 (ShaderResources.cpp from main) both tests fail: a table of storage-viewed and other entries, ...: 0 reused and 4 resolved tables, expected 4 and 0
After restore both tests pass; git status --porcelain is empty

About the agc_driver_image_gather_volume lines. The script marks them "(test not run on main)" because the test was added to main after the validation baseline 1e65852. I ran it with validation on, once with the PR's ShaderResources.cpp and once with main's. Both runs give the same IDs, so they come from main, not from this PR:

VUID counts, the same with either file
2 VUID-VkSamplerCreateInfo-addressModeU-01079
2 VUID-VkSamplerCreateInfo-addressModeU-parameter
2 VUID-VkSamplerCreateInfo-addressModeV-parameter
2 VUID-VkSamplerCreateInfo-addressModeW-parameter

Previous findings

  1. A table with no reusable entries takes a reuse slot: Resolved. ShaderResources.cpp:5677-5678 now remembers a table only if some element is not live. With that condition removed, the new step fails with 1 reused and 1 resolved tables, expected 0 and 2; with it, the step passes. The author chose "any element not live" instead of my suggested fresh.queries empty, so tables of rejected entries are still remembered as on main. That keeps their rejection messages from being decoded again, which is reasonable.
  2. The live branch in revalidateFull repeats the fallback loop: Resolved. Both paths now call currentTableEntry (ShaderResources.cpp:3812-3820, used at :3838 and :3853). The fallback condition is equivalent to the old one: the textureIndex >= textures.size() guard moved into the lambda, and the comparison is the same || chain. The lambda captures textureIndex by reference, and both callers advance it after the call, as before.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • I did not check the PPSA18653 performance numbers or traces, and launched no title. They were captured on 68a15ec229 / 12ed9524c8, which carry #15327 and the first commit only. The second commit only narrows when a table is remembered, so it should not slow the measured scene, but I have not measured that.
  • I could not check behaviour on non-lavapipe GPUs. The author reports a 117/117 rerun on the NVIDIA RTX 5080, which I accept as author-reported.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5758767049 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15563#pullrequestreview-5758767049). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T20:07:03Z. **Review:** APPROVED --- # Re-checked — approved Commit `b2ca8faf64` resolves both non-blocking points from my last review. A table whose entries are all live is no longer remembered, and the two `revalidateFull` paths share `currentTableEntry`. The tests and the negative control behave as expected. ## What changed since my last review - **New commit `b2ca8faf64`** ("keep tables with nothing to reuse out of the reuse slots"). Commit `38e7f40892` is unchanged. - `ShaderResources.cpp:5677-5678` adds `anyKept`. A table is remembered only when at least one element is not live. Rejected elements count as not live, so a table of rejected entries is still remembered, as on `main`. - `ShaderResources.cpp:3812-3820` adds the `currentTableEntry` lambda, which is now used by the live branch (`:3838`) and by the fallback loop (`:3853`). - **Test changes.** `RunViewedStore` now points records `Viewed..Records` at a second block that is not imported (`plain`). The table therefore mixes kept and live entries, and the expected count goes from 3 reused / 0 resolved to 4 / 0. A new step at `ImageTableReuse.cpp:296-301` binds a table of only storage-viewed entries and expects 0 reused and 2 resolved. - **Author reply** in the discussion, describing the above. ## What I ran Head `b2ca8faf642de09526cd5d4a7b98574d7e7a7b5f`, `main` `086c0686c8adff3ee648fdbe34e0b0b647e1d511`, merged tree `0a25af341deac165d5a9ded01ebc7082aa852e88`. Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19). ``` git diff --check 086c0686c8adff3ee648fdbe34e0b0b647e1d511...b2ca8faf642de09526cd5d4a7b98574d7e7a7b5f python3 tools/check_conventions.py --base 086c0686c8adff3ee648fdbe34e0b0b647e1d511 env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R image_table_reuse # negative control 1: drop only the new anyKept condition sed -i "s/if (reusable && anyKept && CurrentTableState() == state)/if (reusable \&\& CurrentTableState() == state)/" core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp ninja -C build agc_driver_image_table_reuse_tests ctest --test-dir build --output-on-failure -R image_table_reuse # negative control 2: all production code from main git show 086c0686c8adff3ee648fdbe34e0b0b647e1d511:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp ninja -C build agc_driver_image_table_reuse_tests ctest --test-dir build --output-on-failure -R image_table_reuse # validation lines of agc_driver_image_gather_volume, with the PR's file and with main's file env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R "^agc_driver_image_gather_volume$" # restore git show 0a25af341deac165d5a9ded01ebc7082aa852e88:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp ninja -C build libSceAgcDriver agc_driver_image_gather_volume_tests agc_driver_image_table_reuse_tests git status --porcelain ctest --test-dir build -R image_table_reuse ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build of the merged tree (script) | ok | | Selected tests (script, 2171 ran) | no new failures and no timeouts. The 7 known failures also fail on the baseline `main` | | `agc_driver_image_table_reuse` / `_draw_pipeline` (validation on) | both passed, 0.80 s and 0.76 s; host imports are available, so `RunViewedStore` ran | | Validation comparison (script, 783 tests, layer loaded in 782, missing in none) | one test with new lines, `agc_driver_image_gather_volume`. These lines come from `main`, not from this PR (see below) | | Negative control 1 (`anyKept` removed) | both tests fail: `a table of only storage-viewed entries, which has nothing to reuse: 1 reused and 1 resolved tables, expected 0 and 2` (the message the author quoted) | | Negative control 2 (`ShaderResources.cpp` from `main`) | both tests fail: `a table of storage-viewed and other entries, ...: 0 reused and 4 resolved tables, expected 4 and 0` | | After restore | both tests pass; `git status --porcelain` is empty | **About the `agc_driver_image_gather_volume` lines.** The script marks them "(test not run on main)" because the test was added to `main` after the validation baseline `1e65852`. I ran it with validation on, once with the PR's `ShaderResources.cpp` and once with `main`'s. Both runs give the same IDs, so they come from `main`, not from this PR: <details><summary>VUID counts, the same with either file</summary> ``` 2 VUID-VkSamplerCreateInfo-addressModeU-01079 2 VUID-VkSamplerCreateInfo-addressModeU-parameter 2 VUID-VkSamplerCreateInfo-addressModeV-parameter 2 VUID-VkSamplerCreateInfo-addressModeW-parameter ``` </details> ## Previous findings 1. **A table with no reusable entries takes a reuse slot: Resolved.** `ShaderResources.cpp:5677-5678` now remembers a table only if some element is not live. With that condition removed, the new step fails with `1 reused and 1 resolved tables, expected 0 and 2`; with it, the step passes. The author chose "any element not live" instead of my suggested `fresh.queries` empty, so tables of rejected entries are still remembered as on `main`. That keeps their rejection messages from being decoded again, which is reasonable. 2. **The live branch in `revalidateFull` repeats the fallback loop: Resolved.** Both paths now call `currentTableEntry` (`ShaderResources.cpp:3812-3820`, used at `:3838` and `:3853`). The fallback condition is equivalent to the old one: the `textureIndex >= textures.size()` guard moved into the lambda, and the comparison is the same `||` chain. The lambda captures `textureIndex` by reference, and both callers advance it after the call, as before. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - I did not check the PPSA18653 performance numbers or traces, and launched no title. They were captured on `68a15ec229` / `12ed9524c8`, which carry #15327 and the first commit only. The second commit only narrows when a table is remembered, so it should not slow the measured scene, but I have not measured that. - I could not check behaviour on non-lavapipe GPUs. The author reports a 117/117 rerun on the NVIDIA RTX 5080, which I accept as author-reported. <!-- anyps5-bots job=3565 head=b2ca8faf642de09526cd5d4a7b98574d7e7a7b5f -->
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!15563
No description provided.