fix(agc): fault image table entries the device or guest memory cannot hold #6481

Closed
fdfawef324 wants to merge 9 commits from upstream-pr/6481 into main
fdfawef324 commented 2026-10-15 17:03:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T17:03:26Z.


What

Resolving a bindless image table creates textures before the shader selects an entry. Descriptors over the sampled-image or heap limits, and surfaces in unregistered host memory, could therefore reach image creation even when the entry was never used.

Validate registered guest-memory overlap, the ordinary sampled image's format combination, extent, layers and minimum footprint before reading its surface. Refused entries fault when selected. A final host/device memory refusal from an entry's own snapshot image or upload allocation also becomes an entry fault; that incomplete table is resolved again on its next use. Other errors from the sampled-texture lookup, including device loss and submission failure, propagate.

The rebase preserves main's multisampleViewType argument, selected-column range handling and scoped test registrations. The ordinary snapshot still calls AllocateImageMemory: pool trim, texture reclaim, retry and allowed host fallback run before an eventual allocation refusal is classified. ownTextureMemory wraps that complete operation, rather than replacing it with raw allocation. It also wraps the snapshot's own image creation/binding, upload allocations and ordinary sRGB expansion. Storage-copy expansion and recorder submission failures retain their existing propagation.

The historical 7,520,387,072-byte Demon's Souls allocation was already attempting host heap 1 when its upload allocation failed after reclaim (initialResult=-2, two attempts). Main's device-to-host fallback does not create additional host-heap capacity. This explains why a final refusal can still reach the entry classifier; the historical run is not a new execution on this head, and does not show whether that entry would be selected. No title memory, FPS or first-level improvement is claimed.

Limits recorded in technical debt: format preflight queries the original sampled format with TRANSFER_DST | SAMPLED. It does not separately preflight the sRGB upload's additional TRANSFER_SRC usage or its secondary mutable RGBA8 expansion combination. The written-entry storage lookup retains its inherited std::runtime_error catch. Selecting a driver-refused entry remains a documented emulation limitation.

Tested

Exact clean candidate 1be24da14e8a0e9afecfa4f558018ce19d1bd895, rebased on 84c1a4d9a26429cb483ec963195cff8ef25d128b; Windows Server 2025, MinGW GCC 15.2 Release/O3. Seven affected targets build. CPU/mock agc_driver_graphics and agc_driver_image_table_cache pass, 2/2 in 10.84 seconds. The selected entry-validation suite also passes, with its arena/write-watch checks exercised.

The recording mock keeps image identity across allocation retries. A temporary first refusal must recover and serve the entry. Persistent image/upload refusals must fault only that entry, release its resources, allow the next entry, and retry resolution on later use. Device loss and submission failure retain typed error propagation. The ordinary sampled sRGB expansion has separate allocation-refusal and device-loss controls.

Two selective CPU regression controls fail at their intended assertions: removing only the sRGB expansion classifier fails the expanded sampled image classified its allocation failure incorrectly; replacing only the normal snapshot's common allocator with raw allocation fails the sampled image did not retry its initial device-memory refusal. Build plus selected-test feedback was 46.08 and 41.40 seconds respectively. Final source was restored and rebuilt clean. These controls test allocation contracts with mocks; they do not measure title performance.

Fresh managed-slot Vulkan checks on the exact candidate: agc_driver_bindless_images, agc_driver_image_sint8, agc_driver_image_table, agc_driver_image_table_cache_bounds and agc_driver_image_table_reuse, 5/5 pass in 5.22 seconds, no skipped cases or reported skipped subcases, with Vulkan required and shader caching disabled. Actual binaries/libraries were hash-checked before and after. Independent source review and 308 readiness pins were checked. Generated TraceRevision is 1be24da14e8a, dirty 0; natural shader SourceVersion is 0xb9fb57da52370e78.

Conventions pass against fetched main 676d423968a1a8fcc79c6247020ce22090a8e0d4; a clean merge-tree into that main was checked separately. All execution results above belong to the exact candidate, not the merge tree. Earlier RTX 3060 results and @nicolasfalesy's Linux/lavapipe composition report remain evidence for their recorded older heads. No new Linux, full-suite, title or real exhausted-heap result is claimed.

Checklist

  • Based on main; no other open PR implements these entry checks (nearby image-table reuse/registration work is preserved)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in their library's technical debt (no new stub)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none demonstrated on this head
  • GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100
  • AI-assisted: yes (Claude Code and Codex)

Co-Authored-By: Claude Opus 5.5 [email protected]
Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4876971216 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T17:03:26Z. --- ### What Resolving a bindless image table creates textures before the shader selects an entry. Descriptors over the sampled-image or heap limits, and surfaces in unregistered host memory, could therefore reach image creation even when the entry was never used. Validate registered guest-memory overlap, the ordinary sampled image's format combination, extent, layers and minimum footprint before reading its surface. Refused entries fault when selected. A final host/device memory refusal from an entry's own snapshot image or upload allocation also becomes an entry fault; that incomplete table is resolved again on its next use. Other errors from the sampled-texture lookup, including device loss and submission failure, propagate. The rebase preserves main's `multisampleViewType` argument, selected-column range handling and scoped test registrations. The ordinary snapshot still calls `AllocateImageMemory`: pool trim, texture reclaim, retry and allowed host fallback run before an eventual allocation refusal is classified. `ownTextureMemory` wraps that complete operation, rather than replacing it with raw allocation. It also wraps the snapshot's own image creation/binding, upload allocations and ordinary sRGB expansion. Storage-copy expansion and recorder submission failures retain their existing propagation. The historical 7,520,387,072-byte Demon's Souls allocation was already attempting host heap 1 when its upload allocation failed after reclaim (`initialResult=-2`, two attempts). Main's device-to-host fallback does not create additional host-heap capacity. This explains why a final refusal can still reach the entry classifier; the historical run is not a new execution on this head, and does not show whether that entry would be selected. No title memory, FPS or first-level improvement is claimed. Limits recorded in technical debt: format preflight queries the original sampled format with `TRANSFER_DST | SAMPLED`. It does not separately preflight the sRGB upload's additional `TRANSFER_SRC` usage or its secondary mutable RGBA8 expansion combination. The written-entry storage lookup retains its inherited `std::runtime_error` catch. Selecting a driver-refused entry remains a documented emulation limitation. ### Tested Exact clean candidate `1be24da14e8a0e9afecfa4f558018ce19d1bd895`, rebased on `84c1a4d9a26429cb483ec963195cff8ef25d128b`; Windows Server 2025, MinGW GCC 15.2 Release/O3. Seven affected targets build. CPU/mock `agc_driver_graphics` and `agc_driver_image_table_cache` pass, 2/2 in 10.84 seconds. The selected entry-validation suite also passes, with its arena/write-watch checks exercised. The recording mock keeps image identity across allocation retries. A temporary first refusal must recover and serve the entry. Persistent image/upload refusals must fault only that entry, release its resources, allow the next entry, and retry resolution on later use. Device loss and submission failure retain typed error propagation. The ordinary sampled sRGB expansion has separate allocation-refusal and device-loss controls. Two selective CPU regression controls fail at their intended assertions: removing only the sRGB expansion classifier fails `the expanded sampled image classified its allocation failure incorrectly`; replacing only the normal snapshot's common allocator with raw allocation fails `the sampled image did not retry its initial device-memory refusal`. Build plus selected-test feedback was 46.08 and 41.40 seconds respectively. Final source was restored and rebuilt clean. These controls test allocation contracts with mocks; they do not measure title performance. Fresh managed-slot Vulkan checks on the exact candidate: `agc_driver_bindless_images`, `agc_driver_image_sint8`, `agc_driver_image_table`, `agc_driver_image_table_cache_bounds` and `agc_driver_image_table_reuse`, 5/5 pass in 5.22 seconds, no skipped cases or reported skipped subcases, with Vulkan required and shader caching disabled. Actual binaries/libraries were hash-checked before and after. Independent source review and 308 readiness pins were checked. Generated TraceRevision is `1be24da14e8a`, dirty 0; natural shader SourceVersion is `0xb9fb57da52370e78`. Conventions pass against fetched main `676d423968a1a8fcc79c6247020ce22090a8e0d4`; a clean merge-tree into that main was checked separately. All execution results above belong to the exact candidate, not the merge tree. Earlier RTX 3060 results and @nicolasfalesy's Linux/lavapipe composition report remain evidence for their recorded older heads. No new Linux, full-suite, title or real exhausted-heap result is claimed. ### Checklist - [x] Based on `main`; no other open PR implements these entry checks (nearby image-table reuse/registration work is preserved) - [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; silent stubs are listed in their library's technical debt (no new stub) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none demonstrated on this head - [x] GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 - [x] AI-assisted: yes (Claude Code and Codex) Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex <[email protected]>
fdfawef324 commented 2026-10-15 17:50:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T17:50:17Z.


P2 source-review finding at e441ee7bc13c4f2136a8a349ce197abafe79fdcf: sampledImageFormatLimits caches nullopt when the query explicitly returns VK_ERROR_FORMAT_NOT_SUPPORTED (Texture.cpp:259–277). RequireSampledImageWithinDeviceLimits then falls back to broad VkPhysicalDeviceLimits (295–306). An otherwise valid, registered 8x8 entry can pass and reach cachedTexture / vkCreateImage with the same format, type, optimal tiling, transfer-destination/sampled usage and create flags. A missing query provider already throws; this nullopt represents an explicit rejection.

The Vulkan query contract defines that result as an unsupported combination. Broad dimension/layer limits cannot establish support for it; see also image-creation support requirements.

Please turn the explicit unsupported result into an ordinary descriptive entry refusal before creation. resolveImageTables can then record its per-entry fault through the existing runtime_error catch, while retaining VulkanError propagation for genuine driver failures.

Suggested regression in the existing recording mock: return VK_ERROR_FORMAT_NOT_SUPPORTED for a registered 8x8 entry, use a fresh physical-device identity to avoid a cached positive result, and assert that the query ran, the table element is rejected, and no vkCreateImage call was recorded. The present stub always returns success.

Source/specification review only. A native regression patch was prepared and checked for applicability, but remains uncompiled/unexecuted. No GPU failure or connection to the observed title device loss is established.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6198602879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6198602879). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T17:50:17Z. --- P2 source-review finding at `e441ee7bc13c4f2136a8a349ce197abafe79fdcf`: `sampledImageFormatLimits` caches `nullopt` when the query explicitly returns `VK_ERROR_FORMAT_NOT_SUPPORTED` (`Texture.cpp:259–277`). `RequireSampledImageWithinDeviceLimits` then falls back to broad `VkPhysicalDeviceLimits` (`295–306`). An otherwise valid, registered 8x8 entry can pass and reach `cachedTexture` / `vkCreateImage` with the same format, type, optimal tiling, transfer-destination/sampled usage and create flags. A missing query provider already throws; this `nullopt` represents an explicit rejection. The [Vulkan query contract](https://docs.vulkan.org/refpages/latest/refpages/source/vkGetPhysicalDeviceImageFormatProperties.html) defines that result as an unsupported combination. Broad dimension/layer limits cannot establish support for it; see also [image-creation support requirements](https://docs.vulkan.org/refpages/latest/refpages/source/VkImageCreateInfo.html#VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251). Please turn the explicit unsupported result into an ordinary descriptive entry refusal before creation. `resolveImageTables` can then record its per-entry fault through the existing `runtime_error` catch, while retaining `VulkanError` propagation for genuine driver failures. Suggested regression in the existing recording mock: return `VK_ERROR_FORMAT_NOT_SUPPORTED` for a registered 8x8 entry, use a fresh physical-device identity to avoid a cached positive result, and assert that the query ran, the table element is rejected, and no `vkCreateImage` call was recorded. The present stub always returns success. Source/specification review only. A native regression patch was prepared and checked for applicability, but remains uncompiled/unexecuted. No GPU failure or connection to the observed title device loss is established.
fdfawef324 commented 2026-10-15 18:43:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T18:43:20Z.


Confirmed at e441ee7bc: sampledImageFormatLimits cached nullopt for VK_ERROR_FORMAT_NOT_SUPPORTED, and RequireSampledImageWithinDeviceLimits then compared the entry with VkPhysicalDeviceLimits, so a registered 8x8 entry reached vkCreateImage with the combination the query had rejected.

Fixed in c578222b3: an unsupported combination is now refused before the entry's guest memory is read (the message names the VkFormat, image type and create flags), through the existing runtime_error path, so the entry faults when selected like the other refusals. The device-wide limits are no longer consulted. Any other query result still goes through Check and propagates as VulkanError.

Your regression is in tests/ImageTableEntryValidation.cpp as testUnsupportedImageCombination, unchanged apart from whitespace. Before the fix it fails with an 8x8 registered texture whose exact image combination is unsupported: the entry was served instead of faulting when selected; images created: 8x8x1/1 layers; with it, agc_driver_graphics and the 73 image-related AGC tests pass on the RTX 3060 (591.86, Windows Server 2025). The technical debt entry and the PR body's Tested section are updated.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6199637541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6199637541). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T18:43:20Z. --- Confirmed at e441ee7bc: `sampledImageFormatLimits` cached `nullopt` for `VK_ERROR_FORMAT_NOT_SUPPORTED`, and `RequireSampledImageWithinDeviceLimits` then compared the entry with `VkPhysicalDeviceLimits`, so a registered 8x8 entry reached `vkCreateImage` with the combination the query had rejected. Fixed in c578222b3: an unsupported combination is now refused before the entry's guest memory is read (the message names the VkFormat, image type and create flags), through the existing `runtime_error` path, so the entry faults when selected like the other refusals. The device-wide limits are no longer consulted. Any other query result still goes through `Check` and propagates as `VulkanError`. Your regression is in `tests/ImageTableEntryValidation.cpp` as `testUnsupportedImageCombination`, unchanged apart from whitespace. Before the fix it fails with `an 8x8 registered texture whose exact image combination is unsupported: the entry was served instead of faulting when selected; images created: 8x8x1/1 layers`; with it, `agc_driver_graphics` and the 73 image-related AGC tests pass on the RTX 3060 (591.86, Windows Server 2025). The technical debt entry and the PR body's Tested section are updated. AI-assisted: yes
fdfawef324 commented 2026-10-16 07:29:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-16T07:29:28Z.


ds-main5-c01: one image table entry's out-of-memory error stopped Demon's Souls (PPSA01342)

Windows Server 2025, RTX 3060 12 GB, driver 591.86, 32 GB RAM. The build was main a5e2a80c6 with an earlier head of this PR and other open PRs, among them #5987 and #6553, which print the two [gpu] texture: placement lines. Emulator log lines only:

stderr 11037   [gpu] texture 0x27ad00000 (format 22) has unreadable DCC keys at 0x909809240000; its texels are read as stored
stdout 457474  [src/Texture.cpp:348 Texture] Texture address=0x27ad00000 1024x1024 mips=1 layers=1793 dim=2 tile=4 format=22 vk=100 element=4
stderr 11044   [gpu] texture: device-local heap 0 uses 7970 of its 10053 MiB budget and no allowed host heap has room, 7520387072 bytes kept in device-local memory type 1; 1 such allocations, 7172 MiB
stderr 11045   [gpu] texture: device-local memory type 1 is out of device memory for 7520387072 bytes; placed in host memory type 0; 1 such allocations, 7172 MiB
stderr 11046   [videoout] presentation failed: AGC graphics: vkAllocateMemory buffer: allocation=7520387072 memoryType=4 reclaimed=1867581668 initialResult=-2 attempts=2: Vulkan result -2
stderr 11050   FATAL: abort() (SIGABRT) on thread 12272
  • The entry (stdout L457474): a 1024x1024 format 22, tile 4 array of 1793 layers, 4 MiB x 1793 = 7,520,387,072 bytes. Its first four dwords match a render target the run uses with 3 and 4 layers. Its last slice (0x700) and its DCC address (0x909809240000, L11037) are not a T#. 1793 layers is under the device's 2048 and the surface starts in registered memory, so this PR's checks passed it.
  • Memory (L11044–L11046): device-local heap 0 was at 7970 of its 10053 MiB budget. The image went to host memory type 0 (heap 1, 16334.9 MiB). Its 7,520,387,072-byte staging buffer in host type 4 (also heap 1) then failed with -2 (VK_ERROR_OUT_OF_DEVICE_MEMORY), after the buffer pool reclaimed 1,867,581,668 bytes.
  • The stop (L11046–L11050): resolveImageTables rethrew the VulkanError, presentation failed, and the VideoOut thread called std::terminate (SIGABRT).
  • Not system commit: private memory rose from 28.6 to 42.4 GB between 652 and 672 s, while commit stood at 70.8 of 95.9 GB. What ran out was Vulkan heap 1.

What changed on the branch (force-pushed, 46f639206 → ce99615b2):

  • c72f29095 refuses an entry whose level 0 is larger than the largest memory heap. This is an exact limit (VUID-vkAllocateMemory-pAllocateInfo-01713). The bound is the heap's size, not the budget: L11044 reports no host heap with budget room, yet L11045 shows the driver allocated the image there. This entry fits heap 1, so it is not refused by size.
  • ce99615b2 turns an out-of-memory result from the entry's own image or upload buffers into a faulting entry, and resolves the table again on its next use. Every other VulkanError still stops the draw, including out-of-memory errors from a recorder submit or a storage image refresh. With it, this entry would stop the title only if a shader selected it.

This is one run, and it does not show whether a shader selects the entry.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6210417890 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6210417890). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-16T07:29:28Z. --- **ds-main5-c01: one image table entry's out-of-memory error stopped Demon's Souls (PPSA01342)** Windows Server 2025, RTX 3060 12 GB, driver 591.86, 32 GB RAM. The build was `main` `a5e2a80c6` with an earlier head of this PR and other open PRs, among them #5987 and #6553, which print the two `[gpu] texture:` placement lines. Emulator log lines only: ``` stderr 11037 [gpu] texture 0x27ad00000 (format 22) has unreadable DCC keys at 0x909809240000; its texels are read as stored stdout 457474 [src/Texture.cpp:348 Texture] Texture address=0x27ad00000 1024x1024 mips=1 layers=1793 dim=2 tile=4 format=22 vk=100 element=4 stderr 11044 [gpu] texture: device-local heap 0 uses 7970 of its 10053 MiB budget and no allowed host heap has room, 7520387072 bytes kept in device-local memory type 1; 1 such allocations, 7172 MiB stderr 11045 [gpu] texture: device-local memory type 1 is out of device memory for 7520387072 bytes; placed in host memory type 0; 1 such allocations, 7172 MiB stderr 11046 [videoout] presentation failed: AGC graphics: vkAllocateMemory buffer: allocation=7520387072 memoryType=4 reclaimed=1867581668 initialResult=-2 attempts=2: Vulkan result -2 stderr 11050 FATAL: abort() (SIGABRT) on thread 12272 ``` - **The entry (stdout L457474):** a 1024x1024 format 22, tile 4 array of 1793 layers, 4 MiB x 1793 = 7,520,387,072 bytes. Its first four dwords match a render target the run uses with 3 and 4 layers. Its last slice (0x700) and its DCC address (0x909809240000, L11037) are not a T#. 1793 layers is under the device's 2048 and the surface starts in registered memory, so this PR's checks passed it. - **Memory (L11044–L11046):** device-local heap 0 was at 7970 of its 10053 MiB budget. The image went to host memory type 0 (heap 1, 16334.9 MiB). Its 7,520,387,072-byte staging buffer in host type 4 (also heap 1) then failed with -2 (`VK_ERROR_OUT_OF_DEVICE_MEMORY`), after the buffer pool reclaimed 1,867,581,668 bytes. - **The stop (L11046–L11050):** `resolveImageTables` rethrew the `VulkanError`, presentation failed, and the VideoOut thread called `std::terminate` (SIGABRT). - **Not system commit:** private memory rose from 28.6 to 42.4 GB between 652 and 672 s, while commit stood at 70.8 of 95.9 GB. What ran out was Vulkan heap 1. **What changed on the branch (force-pushed, `46f639206` → `ce99615b2`):** - **c72f29095** refuses an entry whose level 0 is larger than the largest memory heap. This is an exact limit (`VUID-vkAllocateMemory-pAllocateInfo-01713`). The bound is the heap's size, not the budget: L11044 reports no host heap with budget room, yet L11045 shows the driver allocated the image there. This entry fits heap 1, so it is not refused by size. - **ce99615b2** turns an out-of-memory result from the entry's own image or upload buffers into a faulting entry, and resolves the table again on its next use. Every other `VulkanError` still stops the draw, including out-of-memory errors from a recorder submit or a storage image refresh. With it, this entry would stop the title only if a shader selected it. This is one run, and it does not show whether a shader selects the entry. AI-assisted: yes
nicolasfalesy commented 2026-10-16 08:53:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T08:53:08Z.


Tested on Linux (Arch), c++ (GCC) 16.2.1 20260810, Release, BUILD_TESTING=ON, main at 5d9dcc42d2ec5401aebd089028b8d4d7410a77b4. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8).

This PR and #6402 break agc_driver_image_table together. main passes (2 of 2), each PR alone passes, and the pair fails (2 of 2):

overlapping guest allocation

Cause: this PR registers FloatTexels, UintTexels, SintTexels and DepthStorage once for the whole run in main() (ImageTable.cpp:1331). #6402 registers the same three texel arrays again inside RunStoreTests (ImageTable.cpp:996-1000 on its head), and the allocation registry rejects the overlap. Removing the registeredUint/Float/Sint registration in RunStoreTests makes the test pass on the merge.

Whichever PR lands second should drop its duplicate registration.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6211830423 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6211830423). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-16T08:53:08Z. --- Tested on Linux (Arch), `c++ (GCC) 16.2.1 20260810`, Release, `BUILD_TESTING=ON`, `main` at `5d9dcc42d2ec5401aebd089028b8d4d7410a77b4`. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8). This PR and #6402 break `agc_driver_image_table` together. `main` passes (2 of 2), each PR alone passes, and the pair fails (2 of 2): ``` overlapping guest allocation ``` Cause: this PR registers `FloatTexels`, `UintTexels`, `SintTexels` and `DepthStorage` once for the whole run in `main()` (`ImageTable.cpp:1331`). #6402 registers the same three texel arrays again inside `RunStoreTests` (`ImageTable.cpp:996-1000` on its head), and the allocation registry rejects the overlap. Removing the `registeredUint/Float/Sint` registration in `RunStoreTests` makes the test pass on the merge. Whichever PR lands second should drop its duplicate registration. AI-assisted: yes
fdfawef324 commented 2026-10-16 19:53:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-16T19:53:45Z.


Thank you, @nicolasfalesy. Your reading is right. Our agc_driver_image_table change registered FloatTexels, UintTexels, SintTexels and DepthStorage once in main() for the whole run. #6402's RunStoreTests registers the same three texel arrays again, and the guest allocation registry throws "overlapping guest allocation" when an address is registered twice. Each PR passes alone, and the two fail together. We confirmed that from the code; we have not reproduced your lavapipe run.

What changed (new head d1f785774, was ce99615b2; rebased onto current main c84249186):

  • tests/execution/ImageTable.cpp: the four registrations are now one scoped helper (TexelRegistrations) that is alive only while the tests that sample those arrays run. RunStoreTests runs outside that scope, so nothing of ours is registered while #6402 registers its own copies. No assertion of our tests changed.
  • The rebase had one conflict, in docs/dev/debt/libSceAgcDriver.md. We kept main's new Pipeline journal entry and our extended AGC buffer allocations entry.

Checked on CPU, without a GPU:

  • #6402 (9161151ef) merged into this head with no conflicts, and agc_driver_image_table builds there.
  • Rebasing our five commits one at a time onto main plus #6402 has no conflicts either, and ends in the same tree as the merge, so the landing order should not matter.
  • agc_driver_graphics (mock Vulkan, includes our ImageTableEntryValidation tests) passes on this head and on the merge with #6402. tools/check_conventions.py --base upstream/main passes.

GPU, on the RTX 3060 (driver 591.86, Windows Server 2025): on this head agc_driver_graphics, agc_driver_bindless_images, agc_driver_image_sint8, agc_driver_image_table, agc_driver_image_table_cache, agc_driver_image_table_cache_bounds and agc_driver_image_table_reuse pass (7 of 7). On the merge with #6402, agc_driver_image_table passes (1 of 1).

The test change is folded into the first commit of this PR, so the push is a force-push; the difference to the previous head is tests/execution/ImageTable.cpp and the rebase conflict above.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223517988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6223517988). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-16T19:53:45Z. --- Thank you, @nicolasfalesy. Your reading is right. Our agc_driver_image_table change registered FloatTexels, UintTexels, SintTexels and DepthStorage once in main() for the whole run. #6402's RunStoreTests registers the same three texel arrays again, and the guest allocation registry throws "overlapping guest allocation" when an address is registered twice. Each PR passes alone, and the two fail together. We confirmed that from the code; we have not reproduced your lavapipe run. What changed (new head d1f785774, was ce99615b2; rebased onto current main c84249186): - tests/execution/ImageTable.cpp: the four registrations are now one scoped helper (TexelRegistrations) that is alive only while the tests that sample those arrays run. RunStoreTests runs outside that scope, so nothing of ours is registered while #6402 registers its own copies. No assertion of our tests changed. - The rebase had one conflict, in docs/dev/debt/libSceAgcDriver.md. We kept main's new Pipeline journal entry and our extended AGC buffer allocations entry. Checked on CPU, without a GPU: - #6402 (9161151ef) merged into this head with no conflicts, and agc_driver_image_table builds there. - Rebasing our five commits one at a time onto main plus #6402 has no conflicts either, and ends in the same tree as the merge, so the landing order should not matter. - agc_driver_graphics (mock Vulkan, includes our ImageTableEntryValidation tests) passes on this head and on the merge with #6402. tools/check_conventions.py --base upstream/main passes. GPU, on the RTX 3060 (driver 591.86, Windows Server 2025): on this head `agc_driver_graphics`, `agc_driver_bindless_images`, `agc_driver_image_sint8`, `agc_driver_image_table`, `agc_driver_image_table_cache`, `agc_driver_image_table_cache_bounds` and `agc_driver_image_table_reuse` pass (7 of 7). On the merge with #6402, `agc_driver_image_table` passes (1 of 1). The test change is folded into the first commit of this PR, so the push is a force-push; the difference to the previous head is `tests/execution/ImageTable.cpp` and the rebase conflict above. AI-assisted: yes
adriadam10 commented 2026-10-19 01:15:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T01:15:04Z.

Review: CHANGES_REQUESTED


This conflicts with main in ShaderResources.cpp, Texture.cpp, tests/execution/ImageTable.cpp and docs/dev/debt/libSceAgcDriver.md, so the Build run can't test it as it would land. Please rebase.

The Texture.cpp conflict is not only textual: main now allocates the image through AllocateImageMemory(context, allocation, requirements.memoryTypeBits, "vkAllocateMemory texture"), which already retries in host memory when a device-local allocation is refused. Please re-derive what ownTextureMemory / TextureMemoryExhausted should wrap on top of it:

  • which VK_ERROR_OUT_OF_* results can still reach the entry after AllocateImageMemory has fallen back (and for the vkCreateImage, staging, tiled and linear buffer paths that still allocate directly);
  • the second-run case in the description (7520387072-byte allocation, initialResult=-2 in host heap 1) should be re-checked against that fallback, and the ImageTableEntryValidation OOM cases updated so they still fail without the change.

The cachedTexture call in resolveImageTables also gained a multisampleViewType argument on main; keep it when merging the new catch clauses.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5566012465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#pullrequestreview-5566012465). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T01:15:04Z. **Review:** CHANGES_REQUESTED --- This conflicts with `main` in `ShaderResources.cpp`, `Texture.cpp`, `tests/execution/ImageTable.cpp` and `docs/dev/debt/libSceAgcDriver.md`, so the Build run can't test it as it would land. Please rebase. The `Texture.cpp` conflict is not only textual: `main` now allocates the image through `AllocateImageMemory(context, allocation, requirements.memoryTypeBits, "vkAllocateMemory texture")`, which already retries in host memory when a device-local allocation is refused. Please re-derive what `ownTextureMemory` / `TextureMemoryExhausted` should wrap on top of it: - which `VK_ERROR_OUT_OF_*` results can still reach the entry after `AllocateImageMemory` has fallen back (and for the `vkCreateImage`, staging, tiled and linear buffer paths that still allocate directly); - the second-run case in the description (7520387072-byte allocation, `initialResult=-2` in host heap 1) should be re-checked against that fallback, and the `ImageTableEntryValidation` OOM cases updated so they still fail without the change. The `cachedTexture` call in `resolveImageTables` also gained a `multisampleViewType` argument on `main`; keep it when merging the new catch clauses.
fdfawef324 commented 2026-10-19 04:35:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-19T04:35:29Z.


@adriadam10 rebased to 84c1a4d9a and re-derived the allocation boundary in clean head 1be24da14e8a0e9afecfa4f558018ce19d1bd895.

The snapshot retains main's complete AllocateImageMemory reclaim/retry/host-fallback route inside ownTextureMemory. Only a final host/device allocation refusal becomes an entry fault. Its own image creation/binding, upload allocations and ordinary sRGB expansion are classified too; device loss, recorder submission and storage-copy expansion errors retain propagation. Main's multisampleViewType and scoped image-table registrations are preserved.

The historical 7.52 GB upload refusal was already in host heap 1 after reclaim; device-to-host fallback cannot provide more room there. I have qualified the body: that old run is not a test of this head or proof that the entry remains unselected. The format preflight's sRGB usage/expansion limits are also explicit.

The allocation mock now tracks the same image across retries. One temporary refusal must recover; persistent refusals fault the entry and permit the next one. Removing only the common allocator or only the ordinary sRGB classifier produces the intended new assertions. Both CPU/mock suites pass; the five required-Vulkan image-table adjacency cases pass on RTX 3060 in 5.22 s without skips. Conventions and a clean merge-tree against 676d42396 pass separately; tests ran on the exact candidate. No new title or Linux result is claimed.

GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100.

AI-assisted: yes (Claude Code and Codex)

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6259746778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6259746778). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-19T04:35:29Z. --- @adriadam10 rebased to `84c1a4d9a` and re-derived the allocation boundary in clean head `1be24da14e8a0e9afecfa4f558018ce19d1bd895`. The snapshot retains main's complete `AllocateImageMemory` reclaim/retry/host-fallback route inside `ownTextureMemory`. Only a final host/device allocation refusal becomes an entry fault. Its own image creation/binding, upload allocations and ordinary sRGB expansion are classified too; device loss, recorder submission and storage-copy expansion errors retain propagation. Main's `multisampleViewType` and scoped image-table registrations are preserved. The historical 7.52 GB upload refusal was already in host heap 1 after reclaim; device-to-host fallback cannot provide more room there. I have qualified the body: that old run is not a test of this head or proof that the entry remains unselected. The format preflight's sRGB usage/expansion limits are also explicit. The allocation mock now tracks the same image across retries. One temporary refusal must recover; persistent refusals fault the entry and permit the next one. Removing only the common allocator or only the ordinary sRGB classifier produces the intended new assertions. Both CPU/mock suites pass; the five required-Vulkan image-table adjacency cases pass on RTX 3060 in 5.22 s without skips. Conventions and a clean merge-tree against `676d42396` pass separately; tests ran on the exact candidate. No new title or Linux result is claimed. GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100. AI-assisted: yes (Claude Code and Codex) Co-Authored-By: Codex <[email protected]>
adriadam10 commented 2026-10-19 05:27:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T05:27:17Z.

Review: CHANGES_REQUESTED


The queue's full Build on 1be24da14 fails linux:agc_draw_descriptors, which main does not fail:

AGC graphics: the draw snapshot wrote the wrong number of image table descriptors into the vertex set

Cause: ShaderResources.cpp:4749 now requires RegisteredReadableOverlaps(...) where main accepted any accessible memory. drawSnapshotTableSetTests (tests/Recorder.cpp, the texels array around line 3173) points its table entries at an unregistered static std::array, so every entry now faults when resolved and the expected 1 (vertex) / 2 (fragment) descriptor writes don't happen.

Please register that array as a guest allocation in the test (like the image-table tests do), and run agc_draw_descriptors plus the other tests that build image-table entries from host memory (grep -rn "imageTable\|ImageTable" core/libs/prx/libSceAgcDriver/tests/*.cpp), since the stricter check can affect any of them. Once the full Build is green this is ready to merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5567280619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#pullrequestreview-5567280619). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T05:27:17Z. **Review:** CHANGES_REQUESTED --- The queue's full Build on `1be24da14` fails `linux:agc_draw_descriptors`, which `main` does not fail: ``` AGC graphics: the draw snapshot wrote the wrong number of image table descriptors into the vertex set ``` Cause: `ShaderResources.cpp:4749` now requires `RegisteredReadableOverlaps(...)` where `main` accepted any accessible memory. `drawSnapshotTableSetTests` (`tests/Recorder.cpp`, the `texels` array around line 3173) points its table entries at an unregistered `static std::array`, so every entry now faults when resolved and the expected 1 (vertex) / 2 (fragment) descriptor writes don't happen. Please register that array as a guest allocation in the test (like the image-table tests do), and run `agc_draw_descriptors` plus the other tests that build image-table entries from host memory (`grep -rn "imageTable\|ImageTable" core/libs/prx/libSceAgcDriver/tests/*.cpp`), since the stricter check can affect any of them. Once the full Build is green this is ready to merge.
MarcZX10 commented 2026-10-19 14:24:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T14:24:41Z.


One coverage distinction for coordination: RequireSampledImageWithinDeviceLimits is currently called while resolving image-table entries. Issue #7923 reproduces a direct sampled-texture path (agc_driver_image_plane_compare_on_line): the Texture constructor creates a 1D D16 image with TRANSFER_DST | SAMPLED, which RADV reports unsupported via vkGetPhysicalDeviceImageFormatProperties; llvmpipe supports it. That direct path still reaches vkCreateImage without this preflight. I have a local candidate that queries support immediately before creation, but it overlaps this constructor hunk, so I’m holding it for sequencing. I have not run the RADV validation case locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6269557953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#issuecomment-6269557953). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T14:24:41Z. --- One coverage distinction for coordination: `RequireSampledImageWithinDeviceLimits` is currently called while resolving image-table entries. Issue #7923 reproduces a direct sampled-texture path (`agc_driver_image_plane_compare_on_line`): the `Texture` constructor creates a 1D D16 image with `TRANSFER_DST | SAMPLED`, which RADV reports unsupported via `vkGetPhysicalDeviceImageFormatProperties`; llvmpipe supports it. That direct path still reaches `vkCreateImage` without this preflight. I have a local candidate that queries support immediately before creation, but it overlaps this constructor hunk, so I’m holding it for sequencing. I have not run the RADV validation case locally.
MarcZX10 commented 2026-11-16 18:34:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T18:34:23Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the sampled-image size preflight so it accounts for the complete image footprint.

What I ran

Reviewed head 1be24da14e8a0e9afecfa4f558018ce19d1bd895. No build or tests were run; the build and test results in the PR description are author-reported. Read the prepared description, commits, manifest, diff, and changed source and test files listed below. Read excluded Graphics.cpp through the pinned reader.

Results

Check Result Note
Source review failed Found an incomplete image-size preflight
Build and tests not run Results are author-reported
Changed-file coverage passed All changed files were read

Findings

Blocking

  • core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:356 computes leastBytes from only the base extent and one format block width. It omits block-compressed block height and the remaining mip levels, even though Texture creates the full mipCount image. Consequently, an image can pass the maxResourceSize and largest-heap checks while its actual allocation exceeds those limits, allowing an oversized table entry to reach image creation. Compute a conservative lower bound for the full mip chain using the format’s block dimensions and all image layers/depth before accepting the entry.

Non-blocking

None.

Sources

Not verified

No build, tests, hardware run, or independent verification of author-reported results was performed. Files read: all 14 changed files, including Graphics.cpp through the pinned reader. The prepared folder excluded Graphics.cpp because it was too large; no changed files remain unread.

To get this to a good state

Correct the full-footprint size calculation and rerun the affected build and image-table validation tests on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5925345401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6481#pullrequestreview-5925345401). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T18:34:23Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the sampled-image size preflight so it accounts for the complete image footprint. ## What I ran Reviewed head `1be24da14e8a0e9afecfa4f558018ce19d1bd895`. No build or tests were run; the build and test results in the PR description are author-reported. Read the prepared description, commits, manifest, diff, and changed source and test files listed below. Read excluded `Graphics.cpp` through the pinned reader. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Found an incomplete image-size preflight | | Build and tests | not run | Results are author-reported | | Changed-file coverage | passed | All changed files were read | ## Findings ### Blocking - `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:356` computes `leastBytes` from only the base extent and one format block width. It omits block-compressed block height and the remaining mip levels, even though `Texture` creates the full `mipCount` image. Consequently, an image can pass the `maxResourceSize` and largest-heap checks while its actual allocation exceeds those limits, allowing an oversized table entry to reach image creation. Compute a conservative lower bound for the full mip chain using the format’s block dimensions and all image layers/depth before accepting the entry. ### Non-blocking None. ## Sources - [Texture.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/1be24da14e8a0e9afecfa4f558018ce19d1bd895/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L347-L384) - [GuestTextureResource.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/1be24da14e8a0e9afecfa4f558018ce19d1bd895/core/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cpp#L206-L234) ## Not verified No build, tests, hardware run, or independent verification of author-reported results was performed. Files read: all 14 changed files, including `Graphics.cpp` through the pinned reader. The prepared folder excluded `Graphics.cpp` because it was too large; no changed files remain unread. ## To get this to a good state Correct the full-footprint size calculation and rerun the affected build and image-table validation tests on the new head.

Pull request closed

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!6481
No description provided.