fix(agc): bind a V# of exactly the range limit within the limit #7717

Merged
xXPBSXx merged 4 commits from upstream-pr/7717 into main 2026-11-02 07:56:31 +00:00
xXPBSXx commented 2026-10-19 02:38:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-19T02:38:17Z.


What

Teardown (PPSA15246) stops with guest buffer view exceeds descriptor range limit from compute shader 0x1409cd300. A local print before the check in GuestBufferMemory::Descriptor shows why (lines 29-34 of the 71 lines of that run's stderr; main 5d9dcc42d plus the print; lines 32 and 34 are the SIGABRT output of the same abort):

[diag-td] address 2571b565c bytes ffffffff adjustment 12 range 10000000b limit ffffffff region 202000000-384000000 end 384000000 direct 0 mirror 0 cut 0
[gpu] driver failure: compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit

The V# size is exactly maxStorageBufferRange (0xffffffff), so the clamp that #5778 added in ShaderResources::addGuestBuffer (size past the limit) does not apply. The address is 12 bytes past a 16-byte offset-alignment boundary, so Descriptor binds from the alignment below and adds that 12 to the range (ViewBytes): 0x10000000b, one DWORD-rounded step over the limit, and it throws. The registered region behind the address is larger than the limit.

The debt entry for #5778 gets one sentence on this case. Descriptor now limits the range to maxStorageBufferRange rounded down to a DWORD when the V# itself fits the limit. A V# larger than the limit still reaches the existing check. What the console does for an access past the bound range is not known, as for #5778.

New viewAtRangeLimitTests binds a V# of exactly the limit 12 bytes into a registered block, with a second V# at the block start so that the view's region begins before it and the offset alignment is 16. It fails on main with guest buffer view exceeds descriptor range limit and passes with the change.

Tested

Windows 10 (19045), MinGW-w64, Release; the run below is from the earlier head e74c6abb4 on upstream/main 43797ca8a. The current head 4c615cbac4 has the same source and test hunks (compared by patch id) plus two debt-only commits; it merges cleanly with main 8b426927d7 and tools/check_conventions.py --base upstream/main passes on it. The test run was not repeated on it. ctest -R '^agc_driver_graphics$': passed (11.5 s). Without the one-line change, the same test fails with AGC graphics: guest buffer view exceeds descriptor range limit (0.66 s, run before the rebase onto 43797ca8a; the test file did not change with it). tools/check_conventions.py --base upstream/main: all checks passed. The test module runs against the mock Vulkan device; no GPU was used for the PASS. The title reproduction above ran on an NVIDIA GeForce RTX 4080 SUPER (Windows 10); Teardown (PPSA15246) with this change (e74c6abb4 on 43797ca8a, fresh libs, no input from me, played by hand from the menu into the first area): the run's stderr (160 lines) no longer contains exceeds descriptor range limit (0 matches, counted with Python). The run then stops at line 139 with driver failure: AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369 (SIGABRT, lines 139-142); that is a separate stop and not part of this change. Measured by others on earlier heads: karimibrahim07 on Windows 11 (NVIDIA GeForce RTX 3060, driver 610.88) at head e74c6abb4: agc_driver_graphics passes 3 of 3 with the change and fails with GuestBufferMemory.cpp of main; savvaniss on Windows 11 (Intel UHD 770 and AMD Radeon RX 9070 XT) at head 76012a2bf: all 21 tests pass with the change, agc_driver_graphics fails without it on both. Linux/lavapipe not tested.

Checklist

  • Based on current main; no open PR implements the same functions (related: #5778 merged, #3202 closed)
  • One topic per PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no new stubs
  • No notes, investigation .md files or images added
  • No new dependencies
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: none for the unit test (mock Vulkan); the stop was observed on NVIDIA GeForce RTX 4080 SUPER, Windows 10 19045
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4915032499 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7717). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-19T02:38:17Z. --- ### What Teardown (PPSA15246) stops with `guest buffer view exceeds descriptor range limit` from compute shader `0x1409cd300`. A local print before the check in `GuestBufferMemory::Descriptor` shows why (lines 29-34 of the 71 lines of that run's stderr; `main` `5d9dcc42d` plus the print; lines 32 and 34 are the SIGABRT output of the same abort): ``` [diag-td] address 2571b565c bytes ffffffff adjustment 12 range 10000000b limit ffffffff region 202000000-384000000 end 384000000 direct 0 mirror 0 cut 0 [gpu] driver failure: compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit ``` The V# size is exactly `maxStorageBufferRange` (0xffffffff), so the clamp that #5778 added in `ShaderResources::addGuestBuffer` (size past the limit) does not apply. The address is 12 bytes past a 16-byte offset-alignment boundary, so `Descriptor` binds from the alignment below and adds that 12 to the range (`ViewBytes`): 0x10000000b, one DWORD-rounded step over the limit, and it throws. The registered region behind the address is larger than the limit. The debt entry for #5778 gets one sentence on this case. `Descriptor` now limits the range to `maxStorageBufferRange` rounded down to a DWORD when the V# itself fits the limit. A V# larger than the limit still reaches the existing check. What the console does for an access past the bound range is not known, as for #5778. New `viewAtRangeLimitTests` binds a V# of exactly the limit 12 bytes into a registered block, with a second V# at the block start so that the view's region begins before it and the offset alignment is 16. It fails on `main` with `guest buffer view exceeds descriptor range limit` and passes with the change. ### Tested Windows 10 (19045), MinGW-w64, Release; the run below is from the earlier head `e74c6abb4` on `upstream/main` `43797ca8a`. The current head `4c615cbac4` has the same source and test hunks (compared by patch id) plus two debt-only commits; it merges cleanly with `main` `8b426927d7` and `tools/check_conventions.py --base upstream/main` passes on it. The test run was not repeated on it. `ctest -R '^agc_driver_graphics$'`: passed (11.5 s). Without the one-line change, the same test fails with `AGC graphics: guest buffer view exceeds descriptor range limit` (0.66 s, run before the rebase onto `43797ca8a`; the test file did not change with it). `tools/check_conventions.py --base upstream/main`: all checks passed. The test module runs against the mock Vulkan device; no GPU was used for the PASS. The title reproduction above ran on an NVIDIA GeForce RTX 4080 SUPER (Windows 10); Teardown (PPSA15246) with this change (`e74c6abb4` on `43797ca8a`, fresh libs, no input from me, played by hand from the menu into the first area): the run's stderr (160 lines) no longer contains `exceeds descriptor range limit` (0 matches, counted with Python). The run then stops at line 139 with `driver failure: AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369` (SIGABRT, lines 139-142); that is a separate stop and not part of this change. Measured by others on earlier heads: karimibrahim07 on Windows 11 (NVIDIA GeForce RTX 3060, driver 610.88) at head `e74c6abb4`: `agc_driver_graphics` passes 3 of 3 with the change and fails with `GuestBufferMemory.cpp` of `main`; savvaniss on Windows 11 (Intel UHD 770 and AMD Radeon RX 9070 XT) at head `76012a2bf`: all 21 tests pass with the change, `agc_driver_graphics` fails without it on both. Linux/lavapipe not tested. ### Checklist - [x] Based on current `main`; no open PR implements the same functions (related: #5778 merged, #3202 closed) - [x] One topic per PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no new stubs - [x] No notes, investigation `.md` files or images added - [x] No new dependencies - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: none for the unit test (mock Vulkan); the stop was observed on NVIDIA GeForce RTX 4080 SUPER, Windows 10 19045 - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
karimibrahim07 commented 2026-10-19 03:17:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-19T03:17:30Z.

Review: COMMENTED


Windows run of head e74c6abb4, merged onto main ccbd40240 together with #7669, #7670, #7709 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600, NVIDIA GeForce RTX 3060 (driver 610.88), WinLibs GCC 15.2.0 r7, Ninja Release.

  • agc_driver_graphics with viewAtRangeLimitTests passes, --repeat until-fail:3.
  • Negative control: with main's GuestBufferMemory.cpp it fails with AGC graphics: guest buffer view exceeds descriptor range limit, as in your description.

Code: ViewBytes(bytes, adjustment) adds the offset adjustment to the view, so a V# of exactly maxStorageBufferRange at an address off minStorageBufferOffsetAlignment always ended up past the limit and threw. Capping it at the limit rounded down to a DWORD fixes that. The cap only applies when bytes <= maxStorageBufferRange, so a V# over the limit still goes through the existing allocation-end and placeholder handling.

One wording point for the debt line: the cap applies to any V# whose size plus its adjustment passes the limit, not only one of exactly the limit. A V# a few bytes under the limit at an unaligned address also loses its last bytes. Something like "a V# within its offset adjustment of the limit" would describe what the code does. The test covers the exact-limit case, which is the Teardown one.

Not checked: a title. I don't have Teardown.

AI-assisted: yes. I ran the build, the test and the negative control above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5566546420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7717#pullrequestreview-5566546420). Originally posted by [karimibrahim07](https://github.com/karimibrahim07) on 2026-10-19T03:17:30Z. **Review:** COMMENTED --- Windows run of head `e74c6abb4`, merged onto `main` `ccbd40240` together with #7669, #7670, #7709 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600, NVIDIA GeForce RTX 3060 (driver 610.88), WinLibs GCC 15.2.0 r7, Ninja Release. - `agc_driver_graphics` with `viewAtRangeLimitTests` passes, `--repeat until-fail:3`. - Negative control: with `main`'s `GuestBufferMemory.cpp` it fails with `AGC graphics: guest buffer view exceeds descriptor range limit`, as in your description. **Code:** `ViewBytes(bytes, adjustment)` adds the offset adjustment to the view, so a V# of exactly `maxStorageBufferRange` at an address off `minStorageBufferOffsetAlignment` always ended up past the limit and threw. Capping it at the limit rounded down to a DWORD fixes that. The cap only applies when `bytes <= maxStorageBufferRange`, so a V# over the limit still goes through the existing allocation-end and placeholder handling. One wording point for the debt line: the cap applies to any V# whose size plus its adjustment passes the limit, not only one of exactly the limit. A V# a few bytes under the limit at an unaligned address also loses its last bytes. Something like "a V# within its offset adjustment of the limit" would describe what the code does. The test covers the exact-limit case, which is the Teardown one. Not checked: a title. I don't have Teardown. AI-assisted: yes. I ran the build, the test and the negative control above.
xXPBSXx commented 2026-10-19 04:52:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-19T04:52:43Z.


Thanks for the Windows run and the negative control. You are right that the cap applies to any V# whose size plus its offset adjustment passes the limit, not only to one of exactly the limit. The debt line now says "a V# within its offset adjustment of the limit (for example exactly the limit)" (76012a2bf, documentation only; the code and the test are unchanged from 72abbb5bc, on which agc_driver_graphics passed on Windows 10, RTX 4080 SUPER).

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6259944257 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7717#issuecomment-6259944257). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-19T04:52:43Z. --- Thanks for the Windows run and the negative control. You are right that the cap applies to any V# whose size plus its offset adjustment passes the limit, not only to one of exactly the limit. The debt line now says "a V# within its offset adjustment of the limit (for example exactly the limit)" (76012a2bf, documentation only; the code and the test are unchanged from 72abbb5bc, on which `agc_driver_graphics` passed on Windows 10, RTX 4080 SUPER). AI-assisted: yes.
savvaniss commented 2026-10-19 09:34:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T09:34:33Z.


Intel and AMD Windows data: with this PR's test changes, agc_driver_graphics fails on main and passes with the PR, on an Intel UHD 770 and an AMD RX 9070 XT.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head 76012a2bf merged into main 6b8228b2b. "Without" means only this PR's diff to tests/Graphics.cpp, applied to main 6b8228b2b.

Tests, ×3 UHD 770 RX 9070 XT
This head: the 21 tests built from tests/Graphics.cpp 21 of 21 pass 21 of 21 pass
Without agc_driver_graphics fails: guest buffer view exceeds descriptor range limit; the other 20 pass same

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264157965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7717#issuecomment-6264157965). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-19T09:34:33Z. --- Intel and AMD Windows data: with this PR's test changes, `agc_driver_graphics` fails on `main` and passes with the PR, on an Intel UHD 770 and an AMD RX 9070 XT. Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, `ANYPS5_NO_SHADER_CACHE=1`, serial CTest. Intel UHD Graphics 770 (`8086:a780`), driver 32.0.101.7088. AMD Radeon RX 9070 XT (`1002:7550`), driver 32.0.31041.1004, with `VkCache` emptied first. This head `76012a2bf` merged into `main` `6b8228b2b`. "Without" means only this PR's diff to `tests/Graphics.cpp`, applied to `main` `6b8228b2b`. | Tests, ×3 | UHD 770 | RX 9070 XT | |---|---|---| | This head: the 21 tests built from `tests/Graphics.cpp` | 21 of 21 pass | 21 of 21 pass | | Without | `agc_driver_graphics` fails: `guest buffer view exceeds descriptor range limit`; the other 20 pass | same | AI-assisted: yes (Claude Code)
xXPBSXx commented 2026-10-21 11:14:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T11:14:00Z.


Title data point for this PR (data only).

Title: PPSA15246, 300 s per run through the runner, Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0, Release, relinker and all libs built from one tree. Baseline: upstream/main 50efb5c405. With the PR: the same main with 4c615cbac4 merged (a local merge, not pushed). The Selected GPU line of each .out names the card.

NVIDIA GeForce RTX 4080 SUPER (ANYPS5_GPU=4080, vendor=0x10de):

  • Baseline, run_120957.err lines 134-139: compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit, then SIGABRT.
  • With the PR, run_124109.err: that refusal does not occur. The run stops later, at AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369 (lines 146 and 162), which this PR does not touch.

AMD Radeon RX 6400 (ANYPS5_GPU="RX 6400", vendor=0x1002, 4 GiB card, device-local heap 3227 MiB in the log):

  • Baseline, run_121237.err line 140, and with the PR, run_124555.err line 140: the same stop in the same shader, compute shader 0x1409cd300: AGC graphics: vkAllocateMemory buffer: allocation=5435817984 ... Vulkan result -13. On this card the PR changes nothing for this title.

One run per card and state. I did not look at the picture, and I did not run the PR's test on this machine for this comment.

Not run: other GPUs, other titles, the console.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314544073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7717#issuecomment-6314544073). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T11:14:00Z. --- Title data point for this PR (data only). **Title:** PPSA15246, 300 s per run through the runner, Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0, Release, relinker and all libs built from one tree. Baseline: `upstream/main` `50efb5c405`. With the PR: the same `main` with `4c615cbac4` merged (a local merge, not pushed). The `Selected GPU` line of each `.out` names the card. **NVIDIA GeForce RTX 4080 SUPER** (`ANYPS5_GPU=4080`, `vendor=0x10de`): - Baseline, run_120957.err lines 134-139: `compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit`, then SIGABRT. - With the PR, run_124109.err: that refusal does not occur. The run stops later, at `AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369` (lines 146 and 162), which this PR does not touch. **AMD Radeon RX 6400** (`ANYPS5_GPU="RX 6400"`, `vendor=0x1002`, 4 GiB card, device-local heap 3227 MiB in the log): - Baseline, run_121237.err line 140, and with the PR, run_124555.err line 140: the same stop in the same shader, `compute shader 0x1409cd300: AGC graphics: vkAllocateMemory buffer: allocation=5435817984 ... Vulkan result -13`. On this card the PR changes nothing for this title. One run per card and state. I did not look at the picture, and I did not run the PR's test on this machine for this comment. **Not run:** other GPUs, other titles, the console. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7717
No description provided.