fix(agc): fault image table entries the device or guest memory cannot hold #6481
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6481"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
multisampleViewTypeargument, selected-column range handling and scoped test registrations. The ordinary snapshot still callsAllocateImageMemory: pool trim, texture reclaim, retry and allowed host fallback run before an eventual allocation refusal is classified.ownTextureMemorywraps 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 additionalTRANSFER_SRCusage or its secondary mutable RGBA8 expansion combination. The written-entry storage lookup retains its inheritedstd::runtime_errorcatch. Selecting a driver-refused entry remains a documented emulation limitation.Tested
Exact clean candidate
1be24da14e8a0e9afecfa4f558018ce19d1bd895, rebased on84c1a4d9a26429cb483ec963195cff8ef25d128b; Windows Server 2025, MinGW GCC 15.2 Release/O3. Seven affected targets build. CPU/mockagc_driver_graphicsandagc_driver_image_table_cachepass, 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 failsthe 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_boundsandagc_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 is1be24da14e8a, dirty 0; natural shader SourceVersion is0xb9fb57da52370e78.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
main; no other open PR implements these entry checks (nearby image-table reuse/registration work is preserved).mdfiles or images added to the repositoryCo-Authored-By: Claude Opus 5.5 [email protected]
Co-Authored-By: Codex [email protected]
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T17:50:17Z.
P2 source-review finding at
e441ee7bc13c4f2136a8a349ce197abafe79fdcf:sampledImageFormatLimitscachesnulloptwhen the query explicitly returnsVK_ERROR_FORMAT_NOT_SUPPORTED(Texture.cpp:259–277).RequireSampledImageWithinDeviceLimitsthen falls back to broadVkPhysicalDeviceLimits(295–306). An otherwise valid, registered 8x8 entry can pass and reachcachedTexture/vkCreateImagewith the same format, type, optimal tiling, transfer-destination/sampled usage and create flags. A missing query provider already throws; thisnulloptrepresents 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.
resolveImageTablescan then record its per-entry fault through the existingruntime_errorcatch, while retainingVulkanErrorpropagation for genuine driver failures.Suggested regression in the existing recording mock: return
VK_ERROR_FORMAT_NOT_SUPPORTEDfor 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 novkCreateImagecall 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.
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T18:43:20Z.
Confirmed at e441ee7bc:
sampledImageFormatLimitscachednulloptforVK_ERROR_FORMAT_NOT_SUPPORTED, andRequireSampledImageWithinDeviceLimitsthen compared the entry withVkPhysicalDeviceLimits, so a registered 8x8 entry reachedvkCreateImagewith 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_errorpath, so the entry faults when selected like the other refusals. The device-wide limits are no longer consulted. Any other query result still goes throughCheckand propagates asVulkanError.Your regression is in
tests/ImageTableEntryValidation.cppastestUnsupportedImageCombination, unchanged apart from whitespace. Before the fix it fails withan 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_graphicsand 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
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
maina5e2a80c6with 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:VK_ERROR_OUT_OF_DEVICE_MEMORY), after the buffer pool reclaimed 1,867,581,668 bytes.resolveImageTablesrethrew theVulkanError, presentation failed, and the VideoOut thread calledstd::terminate(SIGABRT).What changed on the branch (force-pushed,
46f639206→ce99615b2):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.VulkanErrorstill 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
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,mainat5d9dcc42d2ec5401aebd089028b8d4d7410a77b4. GPU tests ran on lavapipe (Mesa 26.2.2, llvmpipe with LLVM 22.1.8).This PR and #6402 break
agc_driver_image_tabletogether.mainpasses (2 of 2), each PR alone passes, and the pair fails (2 of 2):Cause: this PR registers
FloatTexels,UintTexels,SintTexelsandDepthStorageonce for the whole run inmain()(ImageTable.cpp:1331). #6402 registers the same three texel arrays again insideRunStoreTests(ImageTable.cpp:996-1000on its head), and the allocation registry rejects the overlap. Removing theregisteredUint/Float/Sintregistration inRunStoreTestsmakes the test pass on the merge.Whichever PR lands second should drop its duplicate registration.
AI-assisted: yes
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):Checked on CPU, without a GPU:
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_boundsandagc_driver_image_table_reusepass (7 of 7). On the merge with #6402,agc_driver_image_tablepasses (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.cppand the rebase conflict above.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T01:15:04Z.
Review: CHANGES_REQUESTED
This conflicts with
maininShaderResources.cpp,Texture.cpp,tests/execution/ImageTable.cppanddocs/dev/debt/libSceAgcDriver.md, so the Build run can't test it as it would land. Please rebase.The
Texture.cppconflict is not only textual:mainnow allocates the image throughAllocateImageMemory(context, allocation, requirements.memoryTypeBits, "vkAllocateMemory texture"), which already retries in host memory when a device-local allocation is refused. Please re-derive whatownTextureMemory/TextureMemoryExhaustedshould wrap on top of it:VK_ERROR_OUT_OF_*results can still reach the entry afterAllocateImageMemoryhas fallen back (and for thevkCreateImage, staging, tiled and linear buffer paths that still allocate directly);initialResult=-2in host heap 1) should be re-checked against that fallback, and theImageTableEntryValidationOOM cases updated so they still fail without the change.The
cachedTexturecall inresolveImageTablesalso gained amultisampleViewTypeargument onmain; keep it when merging the new catch clauses.Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-19T04:35:29Z.
@adriadam10 rebased to
84c1a4d9aand re-derived the allocation boundary in clean head1be24da14e8a0e9afecfa4f558018ce19d1bd895.The snapshot retains main's complete
AllocateImageMemoryreclaim/retry/host-fallback route insideownTextureMemory. 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'smultisampleViewTypeand 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
676d42396pass 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]
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T05:27:17Z.
Review: CHANGES_REQUESTED
The queue's full Build on
1be24da14failslinux:agc_draw_descriptors, whichmaindoes not fail:Cause:
ShaderResources.cpp:4749now requiresRegisteredReadableOverlaps(...)wheremainaccepted any accessible memory.drawSnapshotTableSetTests(tests/Recorder.cpp, thetexelsarray around line 3173) points its table entries at an unregisteredstatic 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_descriptorsplus 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.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T14:24:41Z.
One coverage distinction for coordination:
RequireSampledImageWithinDeviceLimitsis currently called while resolving image-table entries. Issue #7923 reproduces a direct sampled-texture path (agc_driver_image_plane_compare_on_line): theTextureconstructor creates a 1D D16 image withTRANSFER_DST | SAMPLED, which RADV reports unsupported viavkGetPhysicalDeviceImageFormatProperties; llvmpipe supports it. That direct path still reachesvkCreateImagewithout 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.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 excludedGraphics.cppthrough the pinned reader.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:356computesleastBytesfrom only the base extent and one format block width. It omits block-compressed block height and the remaining mip levels, even thoughTexturecreates the fullmipCountimage. Consequently, an image can pass themaxResourceSizeand 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.cppthrough the pinned reader. The prepared folder excludedGraphics.cppbecause 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