fix(agc): refuse image-table entries whose base address is not mapped #27295

Merged
B-Howell merged 2 commits from upstream-pr/27295 into main 2026-11-29 04:10:05 +00:00
B-Howell commented 2026-11-25 18:57:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-25T18:57:12Z.


What

An image table binds every record its keys can reach before the shader selects one, so a record that holds other data is decoded as a T#. decodeEntry refused such an entry only when no page of its surface was committed. A record whose base lies in a reserved hole of a large guest reservation, with committed pages further on, was built and uploaded from whatever pages were committed.

God of War Ragnarök (PPSA08329) stops this way on the Image Calibration screen ([gpu] driver failure: compute shader 0x1052a03100: std::bad_alloc). A local diagnostic print of the T# words and their source showed the view comes from image-table records of shaders 0x1052a03100 and 0x1051fb1800:

large view 0x4140000000 from fresh table of shader 0x1052a03100 element 10 of 13: T# 41400000 41c00000 3e907ebb a000002c 000000ef 00000000 0000000c 00000000
large view 0x4140000000 from fresh table of shader 0x1052a03100 element 12 of 13: T# 41400000 41c00000 3ed0a7dc a000002c 00000148 00000000 00000004 00000000

Words 0 and 1 are the floats 12.0 and 24.0, word 2 is a float near 0.3, and words 4 and 6 are small integers that change between dispatches, so the width, height and depth differ every time (9522x15015x301 up to 14802x15162x754, 150 to 650 GiB). The base 0x4140000000 lies in a --- range of the 483 GB reservation 0x28a0000000..0x9ea0000000. Each such view was placed in about 160 GiB of host memory (vkAllocateMemory texture ... 170065920000 bytes placed in host memory type 0, 806723 MiB over five allocations in one 1200 s run) until a dispatch failed with std::bad_alloc, which is memory-dependent: some runs survive it.

This refuses a table entry whose base address is not mapped, before its surface is read. As for any refused entry, a shader that selects it faults (image table: ... selected the descriptor ...: rejected by the driver: ... is not mapped at its base address), and an unselected one changes nothing. Directly bound T#s are unchanged, and so is an entry whose base is mapped with later pages uncommitted (the partially committed 3D path). The unmeasured console behaviour for a selected partially resident texture whose first page is not committed is recorded in the debt fragment.

ImageTable.cpp adds a record whose first 64 KiB are reserved and whose next 64 KiB are committed. On main it is bound and the selected case samples it without a fault, so the test fails with an entry whose base address is not mapped, with a mapped page later in its surface, was bound instead of faulting when selected.

Related open work: #6481 checks table entries against maxResourceSize and classifies Vulkan memory refusals; these views are under 1 TiB and their host allocations succeed, so it would not refuse them, and the abort is a host std::bad_alloc. #9318 bounds array slices only (this is a 3D view). #10193, #13928, #13929, #20519 and #22424 move or copy the old unmapped check; none changes what it refuses. tools/pr_overlap.py --branch failed closed on conflicting PRs; their diffs were compared by hand for this check.

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, Release, NVIDIA GeForce RTX 4080 SUPER (driver 621.14), Khronos validation layer 1.4.363.1.

  • agc_driver_image_table, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '^agc_driver_image_table$' -V: passes with this change; fails on main's ShaderResources.cpp at the new case (message above). The validation comparison ran main's unchanged test against main's source and this change's test against this change: both logs show Insert instance layer "VK_LAYER_KHRONOS_validation", neither has was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has a VUID- or SYNC-HAZARD- line. These builds were on main 102cad67dae5 with #26197 merged and local diagnostic prints; the two changed source files are identical between 102cad67dae5 and this branch's base 66f88154a4cd.
  • God of War Ragnarök (PPSA08329) 6.06 on the same tree with a cold shader cache: without the change (1200 s), the table records above were built as 150-650 GiB views with five host-placed texture allocations; with it (1500 s), these records were refused, no shader selected a refused entry (no image-table fault), no view of 1 GiB or more and no host-placed texture allocation was logged, and the title went past Image Calibration into the prologue.
  • Tester @tablefrogpillow, comment, at head 18286ef4: AMD Radeon RX Vega (VEGA10, GCN5), RADV (Mesa), Linux, clean build, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 with VK_LAYER_KHRONOS_validation: agc_driver_image_table passes 3/3 with this change and fails 3/3 at the new case when only ShaderResources.cpp is reverted to the merge base.
  • Tester @nexus1692, comment, at head 18286ef4 merged onto main 9f52918eb0: Windows 11 Pro, NVIDIA GeForce RTX 5070 Ti (Blackwell), driver 621.40, WinLibs GCC 16.2.0, Release, with VK_LAYER_KHRONOS_validation: agc_driver_image_table passes 3/3 with no VUID- line and fails at the new case when only ShaderResources.cpp is reverted to main.
  • python3 tools/check_conventions.py --base origin/main and python3 tools/debt_fold.py --check pass.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: PPSA08329 #12128
  • GPUs tested: NVIDIA GeForce RTX 4080 SUPER, driver 621.14, Windows 11 Pro 10.0.26300; AMD Radeon RX Vega (VEGA10), RADV (Mesa), Linux (tester); NVIDIA GeForce RTX 5070 Ti, driver 621.40, Windows 11 Pro (tester)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5497320883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27295). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-25T18:57:12Z. --- ### What An image table binds every record its keys can reach before the shader selects one, so a record that holds other data is decoded as a T#. `decodeEntry` refused such an entry only when no page of its surface was committed. A record whose base lies in a reserved hole of a large guest reservation, with committed pages further on, was built and uploaded from whatever pages were committed. God of War Ragnarök (PPSA08329) stops this way on the Image Calibration screen (`[gpu] driver failure: compute shader 0x1052a03100: std::bad_alloc`). A local diagnostic print of the T# words and their source showed the view comes from image-table records of shaders `0x1052a03100` and `0x1051fb1800`: ``` large view 0x4140000000 from fresh table of shader 0x1052a03100 element 10 of 13: T# 41400000 41c00000 3e907ebb a000002c 000000ef 00000000 0000000c 00000000 large view 0x4140000000 from fresh table of shader 0x1052a03100 element 12 of 13: T# 41400000 41c00000 3ed0a7dc a000002c 00000148 00000000 00000004 00000000 ``` Words 0 and 1 are the floats 12.0 and 24.0, word 2 is a float near 0.3, and words 4 and 6 are small integers that change between dispatches, so the width, height and depth differ every time (9522x15015x301 up to 14802x15162x754, 150 to 650 GiB). The base `0x4140000000` lies in a `---` range of the 483 GB reservation `0x28a0000000..0x9ea0000000`. Each such view was placed in about 160 GiB of host memory (`vkAllocateMemory texture ... 170065920000 bytes placed in host memory type 0`, 806723 MiB over five allocations in one 1200 s run) until a dispatch failed with `std::bad_alloc`, which is memory-dependent: some runs survive it. This refuses a table entry whose base address is not mapped, before its surface is read. As for any refused entry, a shader that selects it faults (`image table: ... selected the descriptor ...: rejected by the driver: ... is not mapped at its base address`), and an unselected one changes nothing. Directly bound T#s are unchanged, and so is an entry whose base is mapped with later pages uncommitted (the partially committed 3D path). The unmeasured console behaviour for a selected partially resident texture whose first page is not committed is recorded in the debt fragment. `ImageTable.cpp` adds a record whose first 64 KiB are reserved and whose next 64 KiB are committed. On `main` it is bound and the selected case samples it without a fault, so the test fails with `an entry whose base address is not mapped, with a mapped page later in its surface, was bound instead of faulting when selected`. Related open work: #6481 checks table entries against `maxResourceSize` and classifies Vulkan memory refusals; these views are under 1 TiB and their host allocations succeed, so it would not refuse them, and the abort is a host `std::bad_alloc`. #9318 bounds array slices only (this is a 3D view). #10193, #13928, #13929, #20519 and #22424 move or copy the old unmapped check; none changes what it refuses. `tools/pr_overlap.py --branch` failed closed on conflicting PRs; their diffs were compared by hand for this check. ### 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 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, Release, NVIDIA GeForce RTX 4080 SUPER (driver 621.14), Khronos validation layer 1.4.363.1. - `agc_driver_image_table`, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '^agc_driver_image_table$' -V`: passes with this change; fails on main's `ShaderResources.cpp` at the new case (message above). The validation comparison ran `main`'s unchanged test against `main`'s source and this change's test against this change: both logs show `Insert instance layer "VK_LAYER_KHRONOS_validation"`, neither has `was not found but was requested by env var VK_INSTANCE_LAYERS`, and neither has a `VUID-` or `SYNC-HAZARD-` line. These builds were on `main` `102cad67dae5` with #26197 merged and local diagnostic prints; the two changed source files are identical between `102cad67dae5` and this branch's base `66f88154a4cd`. - God of War Ragnarök (PPSA08329) 6.06 on the same tree with a cold shader cache: without the change (1200 s), the table records above were built as 150-650 GiB views with five host-placed texture allocations; with it (1500 s), these records were refused, no shader selected a refused entry (no image-table fault), no view of 1 GiB or more and no host-placed texture allocation was logged, and the title went past Image Calibration into the prologue. - Tester @tablefrogpillow, [comment](https://github.com/boykopovar/AnyPS5/pull/27295#issuecomment-7172639539), at head `18286ef4`: AMD Radeon RX Vega (VEGA10, GCN5), RADV (Mesa), Linux, clean build, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` with `VK_LAYER_KHRONOS_validation`: `agc_driver_image_table` passes 3/3 with this change and fails 3/3 at the new case when only `ShaderResources.cpp` is reverted to the merge base. - Tester @nexus1692, [comment](https://github.com/boykopovar/AnyPS5/pull/27295#issuecomment-7199732561), at head `18286ef4` merged onto `main` `9f52918eb0`: Windows 11 Pro, NVIDIA GeForce RTX 5070 Ti (Blackwell), driver 621.40, WinLibs GCC 16.2.0, Release, with `VK_LAYER_KHRONOS_validation`: `agc_driver_image_table` passes 3/3 with no `VUID-` line and fails at the new case when only `ShaderResources.cpp` is reverted to main. - `python3 tools/check_conventions.py --base origin/main` and `python3 tools/debt_fold.py --check` pass. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: PPSA08329 #12128 <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 4080 SUPER, driver 621.14, Windows 11 Pro 10.0.26300; AMD Radeon RX Vega (VEGA10), RADV (Mesa), Linux (tester); NVIDIA GeForce RTX 5070 Ti, driver 621.40, Windows 11 Pro (tester) <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-25 19:21:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T19:21:33Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 18286ef4c98da09ac7cdb2175962dfffcde30ad5 using the prepared diff and pinned reader. No tests or prechecks were run in this review.

Results

Check Result Note
Diff and changed code passed Main logic, regression test, and debt note reviewed
Tests and prechecks not run Only author-reported results available

Findings

Blocking

None.

Non-blocking

None.

Not verified

ShaderResources.cpp was excluded from the prepared full-text files because it was too large; the changed hunk and its nearby table-resolution flow were read through repo_read.py. The included ImageTable.cpp was read around the changed test and its includes. The new debt fragment was visible in the diff. No other file contents were read. Tests, prechecks, and console behavior were not independently verified; test and game results in the description are author-reported.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6063620373 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27295#pullrequestreview-6063620373). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T19:21:33Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `18286ef4c98da09ac7cdb2175962dfffcde30ad5` using the prepared diff and pinned reader. No tests or prechecks were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | Main logic, regression test, and debt note reviewed | | Tests and prechecks | not run | Only author-reported results available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `ShaderResources.cpp` was excluded from the prepared full-text files because it was too large; the changed hunk and its nearby table-resolution flow were read through `repo_read.py`. The included `ImageTable.cpp` was read around the changed test and its includes. The new debt fragment was visible in the diff. No other file contents were read. Tests, prechecks, and console behavior were not independently verified; test and game results in the description are author-reported. ## To get this to a good state Nothing is required.
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!27295
No description provided.