fix(agc): skip null storage images in a dispatch's write ranges #7932

Merged
m335671 merged 1 commit from upstream-pr/7932 into main 2026-10-20 04:00:12 +00:00
m335671 commented 2026-10-19 14:47:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by m335671 on 2026-10-19T14:47:06Z.


What

DispatchWriteRanges (Execution/src/Driver/Memory/WrittenBuffers.cpp) decodes the T# of every written storage image element with DecodeTextureResource before checking for a null base address. DecodeTextureResource throws on a null base (guest texture descriptor has a null base address), so the if (resource.baseAddress == 0) continue; after it never runs. A dispatch that writes a storage image slot whose descriptor is null makes the call throw instead of contributing no range.

On main, the only caller is the APS5_PIPELINE_DISPATCH item path (Dispatch.cpp, a cache hit with a recipe), so this needs the opt-in switch. I hit it on Sword of the Sea (PPSA25344) at boot with a local change that also pipelines dispatch-cache misses. The exception left the queue-0 worker and the title aborted:

[videoout] presentation failed: AGC graphics: guest texture descriptor has a null base address
terminate called after throwing an instance of 'std::runtime_error'

The fix checks IsNullTextureResource before decoding and skips the element. This is what DrawWriteRanges already does for draws; the existing test checks that case for draws.

Tested

Windows 11 Pro 26200, RTX 4070, NVIDIA 617.42, WinLibs GCC 15.2.0, Release, on main a4440ed93.

  • agc_driver_draw_write_ranges now also runs DispatchWriteRanges on the program it already builds, a written image next to a null one. It checks three things: the result is bounded, the real image is a write range, and nothing covers the null one.
    • On main the new check fails with AGC graphics: guest texture descriptor has a null base address.
    • With this PR it passes.
  • I ran the same focused tests on main and on this PR (agc_driver_draw_write_ranges, agc_driver_pipelined_dispatch, agc_driver_pipelined_dispatch_item) with ctest -V, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1. On both, the three pass. Neither log has was not found but was requested by env var VK_INSTANCE_LAYERS or any VUID- line. (On main, agc_driver_draw_write_ranges runs without the new check.)
  • python tools/check_conventions.py --base origin/main: all checks passed.

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 4070, driver 617.42, Windows 11 Pro 26200
  • AI-assisted: yes (Claude Code). The investigation, the change, the runs and this description were done and written by Claude Code on my machine.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PqKN8pgLXDvWRPSucJTLU7

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4922816580 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7932). Originally posted by [m335671](https://github.com/m335671) on 2026-10-19T14:47:06Z. --- ### What `DispatchWriteRanges` (`Execution/src/Driver/Memory/WrittenBuffers.cpp`) decodes the T# of every written storage image element with `DecodeTextureResource` before checking for a null base address. `DecodeTextureResource` throws on a null base (`guest texture descriptor has a null base address`), so the `if (resource.baseAddress == 0) continue;` after it never runs. A dispatch that writes a storage image slot whose descriptor is null makes the call throw instead of contributing no range. On `main`, the only caller is the `APS5_PIPELINE_DISPATCH` item path (`Dispatch.cpp`, a cache hit with a recipe), so this needs the opt-in switch. I hit it on Sword of the Sea (PPSA25344) at boot with a local change that also pipelines dispatch-cache misses. The exception left the queue-0 worker and the title aborted: ``` [videoout] presentation failed: AGC graphics: guest texture descriptor has a null base address terminate called after throwing an instance of 'std::runtime_error' ``` The fix checks `IsNullTextureResource` before decoding and skips the element. This is what `DrawWriteRanges` already does for draws; the existing test checks that case for draws. ### Tested Windows 11 Pro 26200, RTX 4070, NVIDIA 617.42, WinLibs GCC 15.2.0, Release, on `main` `a4440ed93`. - `agc_driver_draw_write_ranges` now also runs `DispatchWriteRanges` on the program it already builds, a written image next to a null one. It checks three things: the result is bounded, the real image is a write range, and nothing covers the null one. - On `main` the new check fails with `AGC graphics: guest texture descriptor has a null base address`. - With this PR it passes. - I ran the same focused tests on `main` and on this PR (`agc_driver_draw_write_ranges`, `agc_driver_pipelined_dispatch`, `agc_driver_pipelined_dispatch_item`) with `ctest -V`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`. On both, the three pass. Neither log has `was not found but was requested by env var VK_INSTANCE_LAYERS` or any `VUID-` line. (On `main`, `agc_driver_draw_write_ranges` runs without the new check.) - `python tools/check_conventions.py --base origin/main`: all checks passed. ### 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 4070, driver 617.42, Windows 11 Pro 26200 - [x] AI-assisted: yes (Claude Code). The investigation, the change, the runs and this description were done and written by Claude Code on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PqKN8pgLXDvWRPSucJTLU7
github-actions[bot] commented 2026-10-19 14:59:51 +00:00 (Migrated from github.com)

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


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
PR 6947 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6270312816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7932#issuecomment-6270312816). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T14:59:51Z. --- <!-- 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 | |---|---| | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/WrittenBuffers.cpp` |
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!7932
No description provided.