feat(agc): sample 1D arrays past maxImageArrayLayers as rows of a 2D image #12246
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12246"
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 B-Howell on 2026-10-28T04:46:57Z.
What
A sampled 1D-array view with more than
maxImageArrayLayersslices throwsan image view of more array slices than maxImageArrayLayers is not implementedinArrayLayerWindow. That limit is 2,048 on the tested NVIDIA GeForce RTX 4080 SUPER. God of War Ragnarök stops there: compute shader0x10527b8200samples a linear 1D array 256 texels wide with 5,120 slices, using nineimage_sample_lzwithDIM = 1D_ARRAY.Such a view is now bound as a 2D image with each viewed slice stored in two adjacent rows.
image_sample_lzorimage_sample_lreceives thelayerRowsruntime image mode only after capture encounters a view larger than the device limit. The registered shader is prepared again with that mode, and subsequent oversized or within-limit views reuse the promoted artifact. A shader that has only seen within-limit views keeps its original descriptor interface. This excludes depth comparison, gather, gradients, offsets, loads, stores, queries, tables, 128-bit T#s and packed formats.ResourceMaterializerpicks that mode only when the T#'s viewed slice count (last_array - base_array + 1) is more than the device'smaxImageArrayLayers. The newSpirvTarget::maxImageArrayLayerscarries the device's value and is part of the cache key. The shader keepsuand replaces the layer withv = (2 * NClamp(RoundEven(layer), 0, L - 1) + 1) / (2 * L), where2Lis the image height fromOpImageQuerySizeLod.cachedTexturebuilds that image from a guest-memory snapshot: W × 2·slices rows, one level, with each slice copied into rows 2i and 2i+1. Storage-image views and native depth surfaces at the same address are not used for it. A depth surface there throws. The descriptor-set revalidation walk looks the texture up the same way.Semantics and their sources:
ImageArrayWindowPastLayerLimitexpects the same rule (nearbyint, clamp). How RDNA rounds a slice coordinate that lies exactly halfway is not measured; the debt entry says so. A NaN layer reads slice 0 (GLSL.std.450NClamp).v·H = 2r + 1. Linear filtering then takes rowsfloor(v·H - 0.5) = 2rand2r + 1, both copies of slice r. Nearest takesfloor(v·H) = 2r + 1. Either holds for any coordinate error under half a texel. At most 2 × 8192 = 16,384 rows (13-bitlast_array), so fp32 rounding plusOpFDiv's 2.5 ULP (Vulkan SPIR-V precision) stays below 0.01 texel. That is also well inside the minimumsubTexelPrecisionBitsof 4. Addressing, filtering and borders inuare the sampler's own, unchanged.image_sample_lzsamples level 0 (RDNA2 ISA, MIMGIMAGE_SAMPLE_LZ). Only a view of level 0 alone is accepted, so an explicit LOD selects the same single level as in a 1D array. A view of other levels throws.What still throws is listed in
docs/dev/debt/libSceAgcDriver.md: other uses of such a view, block-compressed and RGBA8-expanded formats, native depth surfaces, and more rows thanmaxImageDimension2D.RequestSerializeris not changed, so a request replayed withShaderReplaycarries no limit and still throws; the debt entry records that too.The preceding functional repair candidate
6adb491cd99bb8ff4411b1bbbab15ac82b5cef5adescends from an ordinary two-parent merge5fbb979d2bf84420dd2c55178d429187580b4634of published PR head987fb3206f0315c59a19d9b38a88b76d929d78e3and frozen mainf776fddcffd1cfece220ecdd894371988b164f6a. It retains the registered-allocation effective-window and cache-key corrections, and excludes the separate unmerged #9318 TextureTiling policy changes. The still-rows oracle computes complete registered slices fromregisteredBytes / layerBytes, checks captured geometry before dispatch, and retains actual first, last and beyond-limit ClampEdge readbacks. Two focused-test CMake follow-ups add Vulkan headers and the three existing Graphics implementation units required to compile and link the ShaderMemory target.The existing oversized-window regression gains a sample-only row-plus-DCC-clear case with a nonzero base slice. It checks the clear key, actual sampled output and, in cached mode, the sampled-clear counter. This does not add over-limit
image_loadsupport: the original mixed-access unsupported boundary remains, and ordinary within-limit sample/load coverage stays separate. Main's pending-clear/recorder behavior and the existing row-mode resource identity/revalidation paths are retained.Tested
Earlier matched Windows standalone qualification — 2026-10-31
The matched control used frozen main
f776fddcffd1cfece220ecdd894371988b164f6a(treea8c33fd50b81f2e23d28bc7e72e1e3fad5a8eaad). Candidate6adb491cd99bb8ff4411b1bbbab15ac82b5cef5a(tree0cc10959b23c25bf3d264f0444adccacdc62b0cd) descends from the ordinary merge of that main with published PR head987fb3206f0315c59a19d9b38a88b76d929d78e3, followed by the reviewed focused-test CMake dependency change. Relative to frozen main, the candidate diff is 37 files (+1,214/-104). The candidate keeps the owned registered-window and cache-key changes and does not include the unmerged #9318 policy patch.Windows / WinLibs GCC 15.2.0 r7 / Ninja / Release, using the existing warm
b12250acache and at most two build jobs. The frozen-main arm builtagc_shader_memory_testsandagc_driver_image_table_tests; the candidate built those plusagc_driver_image_array_rows_past_layer_limit_tests. All selected CTest names resolved to real compiled executables.agc_shader_memory(CPU)agc_driver_image_table(GPU)agc_driver_image_array_rows_past_layer_limit(GPU)The three GPU calls ran serially under the existing GPU lock on the NVIDIA GeForce RTX 4080 SUPER. Each process had
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the verified localVK_LAYER_PATH, andVK_LOADER_DEBUG=layer;APS5_NO_TEXTURE_CACHEwas unset. Each log positively records Khronos instance and device layer insertion and the selected GPU. There were noVUID-entries, missing requested-layer warnings, skips, or unreleased locks. CPU and GPU scopes are reported separately. This matched-source comparison is focused component evidence, not a game run or full-suite result; its source did not include #9318, whose separate current-pin integration gate is recorded below.Windows standalone test header qualification — 2026-10-31
The Windows hosted build exposed missing
ResourcePlan.hppinclude paths in standalone AGC tests. This repair exports the shader recompiler's public include directories throughlibSceAgcDriver, matching the public headers' dependency without propagating link libraries or compiler options. At commit6440cbcbd09fea05114afc706b92cace8b997591(parent6adb491cd99bb8ff4411b1bbbab15ac82b5cef5a), all six affected standalone targets compiled and linked in the existingb12250aRelease/Ninja cache with WinLibs GCC 15.2.0 r7:agc_driver_cmask_fast_clear_tests,agc_shader_fusion_tests,agc_driver_frame_capture_eop_tests,agc_driver_mesh_tests,agc_driver_key_miss_tests, andagc_driver_recorder_tests.The focused CTest
^agc_driver_cmask_fast_clear$passed 1/1. It ran serially under the existing GPU lock withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the verified localVK_LAYER_PATH, andVK_LOADER_DEBUG=layer;APS5_NO_TEXTURE_CACHEwas unset. The log records Khronos instance and device insertion on the NVIDIA GeForce RTX 4080 SUPER, with no skips, missing-layer warnings, orVUID-entries. The other five targets were compile/link checked only; this is not a complete hosted build or full-suite result.Current-pin #9318 joint integration gate — 2026-10-31
The deferred integration check used a private two-parent composition with this PR's published repair head
6440cbcbd09fea05114afc706b92cace8b997591and the then-current #9318 head8ed6ddb40781f559cf60b855a99c1e794147b42d. The true merge base was951e5963a4dc4905913931a3c17d87c172ce4624; #9318 remained open with its five-file, +67/-3 topic unchanged. The oneShaderResources.cppconflict was resolved using the reviewed composition that preserves both the row-mode handling and #9318's complete registered-window behavior. The resulting private integration tree wasb0b57dcdd6884d8238f92b4f983f42973ad4615e; it was used only for these checks and was not pushed.Windows / WinLibs GCC 15.2.0 r7 / Ninja / Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF. The focused cache retainedImageOneDimensionalArrayand addedImageArrayRowsPastLayerLimit, compiling the real Rows fixture source rather than its skip stub. The selected targets wereagc_driver_graphics_testsandagc_driver_image_array_rows_past_layer_limit_tests.agc_driver_graphicsTextureTiling.cppchecksagc_driver_image_array_rows_past_layer_limitThe Rows call ran under the serial GPU lock on the NVIDIA GeForce RTX 4080 SUPER with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the verified localVK_LAYER_PATH, andVK_LOADER_DEBUG=layer;APS5_NO_TEXTURE_CACHEwas unset. Its log positively records Khronos instance and device insertion, with noVUID-entries, missing requested-layer warnings, skips, or unreleased lock. The graphics helper result is CPU/mock evidence and makes no GPU-layer claim.This is bounded current-pin integration evidence for the #9318 helper and the #12246 still-rows path. It is not the full #9318 suite, validation of every view-policy case, a console or title run, or evidence that #9318 has landed.
Historical matched Windows focused qualification
Control: frozen main
0836dfdf4fecb1e0326100c490476e15d3a74da5(tree11490d4c1cdcc3a116647e4723b000e22b579dd4). Candidate:987fb3206f0315c59a19d9b38a88b76d929d78e3(tree93172b8afc975cec4041ddbfc9f2c1e003276c9b), composed from frozen main and this PR's owned source changes. The candidate excludes the separate unmerged #9318 TextureTiling policy patch. The existingb12250aRelease/Ninja cache used WinLibs GCC 15.2.0 r7; exact selectors, source pins, build settings and selected test artifacts are preserved in the qualification evidence.The paired checks used the common
agc_driver_graphicsCPU/mock test andagc_driver_image_tableGPU test on both arms. The newagc_driver_image_array_rows_past_layer_limitregression uses a capture API absent from main, so it ran only on the candidate.agc_driver_graphics(CPU/mock)agc_driver_image_table(GPU)agc_driver_image_array_rows_past_layer_limit(GPU)All three GPU calls ran serially under the existing GPU lock on an NVIDIA GeForce RTX 4080 SUPER (
0x10de:0x2702) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation;APS5_NO_TEXTURE_CACHEwas unset. Each raw log records insertion of the Khronos validation layer at both instance and device levels. No requested-layer-missing diagnostic, skip orVUID-message was present, and the lock was released. A post-run host metadata query reports Windows 11 Pro build 26300 and NVIDIA driver 32.0.16.2101; those version values were not emitted by the test processes.Child test time and full CTest time are distinct. In main/candidate order, the Graphics child/CTest totals were 14.15/14.88s and 14.23/14.62s; ImageTable totals were 1.35/1.49s and 1.20/1.34s; candidate Rows totals were 0.75/0.88s.
The main build exited 0; its streamed output was not retained as a raw log. The candidate build exited 0 and compiled the real Rows and ImageTable fixtures before linking the selected targets. GCC emitted
-Wstringop-overreaddiagnostics on main and candidate and an unresolved candidate-Wfree-nonheap-objectdiagnostic inVulkanDevice.cpp/PrebuildGraphicsLibraries. These warnings were retained without suppression and are not claimed to be false positives or inherited.This is focused component qualification on the recorded Windows host. It is not a title run or a claim of joint validation against the separate unmerged #9318 policy patch.
Historical qualification — separate pins
Published head
1dee304edc78556cb5df1b9c4154f59b72c6ef06was qualified against frozen mainf25279c0ca4cb068370df4baaa46de7b4f4741c7: 15 focused executions across the recorded Windows/Linux configurations. Those component, codec and GPU results retain their original source/toolchain/device limits; they do not qualify candidate929bf9731f337575bbbc35b40ad0c761d0d0e9c4or current main. This update's qualification is Windows-only.Earlier title runs removed the reported oversized-view refusal but produced black frames without reaching gameplay. They establish neither correct rendering nor a performance gain. No new title run is claimed. RDNA halfway-coordinate behavior, other GPU vendors and the remaining unsupported-view/debt cases remain unverified. Historical source-overlap findings likewise retain their reviewed pins; they are not whole-PR integration or runtime clearance.
Checklist
main; no other open PR implements the same functionsf776fddcffd1cfece220ecdd894371988b164f6a(treea8c33fd50b81f2e23d28bc7e72e1e3fad5a8eaad). The earlier 0836 qualification remains documented above with its original pins. The bounded open-PR source review found no duplicate primary behavior for this implementation.RecompileResultguard; after #12250 lands, this PR rebases to drop its duplicate guard. Historical source findings retain their recorded pins.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted: Claude Code and Codex.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T04:53:03Z.
Review: CHANGES_REQUESTED
The uncompressed 1D-array path is well scoped and has focused GPU evidence, but the runtime mode currently also admits block-compressed descriptors.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T08:38:46Z.
Review: COMMENTED
The new block-compressed guard resolves my earlier finding, and the added
image_sample_lGPU case improves coverage. I’m not approving yet: there is still no boundary test for a view of exactlymaxImageArrayLayersslices, and the existing test coversmax + 3(with its base-slice view atmax + 1). The runtime-mode generation also adds alayerRowsvariant for every eligible 1D-array resource, while the description does not quantify the extra binding/compile cost. The GoW run is correctly scoped as inconclusive (43 presents over 422 seconds, black frames, no gameplay); it does not provide the requested texture-build cost. Please address the exact-limit boundary and the outstanding mode-cost evidence raised in the existing review thread. Also refresh onto current main: main has advanced from the PR baseee5e247to87b810aand adds fields to the sameCacheKey.hppandRecompiler.hppfiles plus an update to the same debt entry.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:55:15Z.
Review: CHANGES_REQUESTED
The GPU validation report is useful, and the description now correctly limits the tested behavior. My earlier open questions remain: there is still no exact-
maxImageArrayLayersboundary case, and no evidence/analysis of the extralayerRowsvariant's binding and compile cost. In addition, GitHub currently reports this head asCONFLICTING/DIRTYwithmain(706d1fa4e363); the last review discussion already identified overlapping cache-key, recompiler and debt edits on the advancing base. Please rebase onto currentmain, resolve those conflicts, add the exact-limit boundary coverage, and address the mode-cost question. The current hosted Windows/conventions checks do not validate a clean merge of this head.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:24:12Z.
Review: CHANGES_REQUESTED
Thanks, the seam argument holds and the refusals (block-compressed, depth, other levels) look right. Still open, mostly what @oneandonlydean and @MarcZX10 already asked:
maxImageArrayLayersslices (stays a 1D array) and one ofmaxImageArrayLayers + 1(rows path); the current test only reachesmax + 3and a base-2 view. The description and the debt entry still say "at leastmaxImageArrayLayers", while the code (last - base >= max,ResourceMaterializer.cpp:231;ShaderResources.cpp:4864) means more than.RuntimeImageModes(ResourceMaterializer.cpp:2085) adds alayerRowsvariant to every 1D-array image sampled only with_lz/_l, even when no view can exceed the limit. State that in the description and either show the extra binding/compile cost on such a shader, or restrict the mode to where it can be needed.APS5_PROFILE_DRAW), or say it is not yet checked.main(cache key, recompiler, debt,cachedTexturesignature vs #9318): please rebase.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T22:50:38Z.
Review: COMMENTED
Re-checked — new head, approval deferred
The exact-limit and limit-plus-one cases, explicit-LOD coverage, and lazy promotion/reuse checks are now present; I found no standalone blocking defect, but I’m deferring approval until the related #9318 array-window change is integrated and jointly validated.
What I ran
Reviewed head
0931c89fe926dd0d8a2c9b9a5291d91d60ee37a8on PR base4c8cff191609bc5f28bf9ee2f93672b531285aa4. I also previewed it against currentmainfdd1753204a4732e1011539cc9d3bb69f70b27a6; the merge preview was clean. Local environment: Linux; no compiler was invoked.I read the updated PR description and the exact-head diff, including the resource-mode promotion path, image construction and upload path, SPIR-V coordinate conversion, cache metadata, and the new Vulkan fixture.
Results
Unedited local command output
The PR description reports Windows 11 / RTX 4080 SUPER results of 6/6 focused image fixtures on this change and 5/6 on main, with the sole main failure being the expected oversized-array refusal; it also reports 2/2 shader-memory and shader-disk-cache checks on both arms. These are author-reported runs, not runs I performed.
Findings
Blocking
None found in the standalone source and test review. I am not requesting changes.
Non-blocking
Approval is deferred pending combined validation with #9318, which remains open at
8ed6ddb40781f559cf60b855a99c1e794147b42d. The two PRs affect the sampled array-view path, and the current description explicitly leaves combined validation pending. This is an integration evidence gap, not a newly identified defect.Sources
Not verified
I did not build or run tests. The reported Windows/GPU runs above are from the PR description. Current Windows and relinker CI jobs are still pending; Linux and specialized jobs are skipped. Combined #9318 integration, title rendered output, title-level construction cost, other GPUs, and Linux behavior remain unverified.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:15:06Z.
Review: COMMENTED
Re-checked — current head, integration pending
The exact-head GPU qualification is now documented, but dependent #9318 remains open with an adjacent-range safety issue and no combined current-head validation.
What I ran
Reviewed head
0931c89fe926dd0d8a2c9b9a5291d91d60ee37a8against PR base4c8cff191609bc5f28bf9ee2f93672b531285aa4; the merge preview against currentmaindc38224141e0b6096007b876b4c42fc9144d11b8is clean. Local checks ran in Linux; no compiler or build was invoked.Results
main74c5ff53af7eb0a915e991f24501b798b17027f5Unedited local check output
Findings
Blocking
I found no standalone defect in #12246's reviewed changes. I am withholding approval because this PR consumes #9318's bounded array-window result, and #9318 remains open at
8ed6ddb40781f559cf60b855a99c1e794147b42dwith an unresolved adjacent-allocation/incomplete-slice issue. The new image qualification is for #12246 alone; no combined test verifies the dependency path after that issue is fixed.Non-blocking
The exact-head Windows qualification and baseline comparison are detailed and useful. No title or performance claim is made.
Sources
Not verified
I did not run a local build or tests, a console test, or a combined #9318/#12246 test. The author-reported image fixtures do not exercise the dependency's adjacent-range case.
To get this to a good state
After #9318 resolves the adjacent-range and incomplete-slice behavior and lands in the agreed order, run the relevant combined tests on the resulting #12246 head. I will recheck that exact head and evidence.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T11:25:04Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The exact-head GCC build report fails because
ImageResourceis now 104 bytes while its Linux layout assertion still requires 96.What I ran
Reviewed head
62a6590bd872109275d2bdbd4ea876bba0f30d41against PR base1a217758a55c09e817366fa4411daac854eeb3f9; the no-build precheck passed diff and conventions checks. It also found a current-main merge conflict inShaderDiskCache.cpp. The declared dependency #9318 remains open, so I did not request an immediate rebase. Local environment: Linux x86_64, Python 3.11.2. I did not build locally.Results
ShaderDiskCache.cpp:sizeof(ImageResource)is 104, expected 96ShaderDiskCache.cpp; #9318 is an open declared dependency whose current head is not includedThe PR adds three fields to
ImageResourceand updates its field-count assertion and encode/decode routines, but leaves the Linuxsizeof(ImageResource) == 96assertion unchanged. The reported compile error is therefore consistent with the changed structure: the expected size must be updated to match the encoded layout. The precheck's ABI and test-quality helper scripts were absent from its isolated checkout; its stack check independently reported the current-main conflict and outstanding dependency.Findings
Blocking
ImageResourcesize assertion rejects the new 104-byte structure. Update the layout assertion and confirm the serializer still covers the added fields, then rerun the Linux build. The reported Windows build does not exercise this Linux-only assertion.Non-blocking
None.
Sources
ImageResourcefields at the reviewed headNot verified
I did not reproduce the Linux build locally or run the GPU tests. The build error is from the attached CI report. The current-main merge conflict and the unmerged #9318 dependency should be revisited after that dependency lands.
To get this to a good state
Update the
ImageResourcesize assertion for the new layout and provide a passing Linux build. After #9318 merges, resolve the current-main conflict and rerun the relevant checks on the resulting head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T23:48:20Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The exact current head fails the Windows changed-test build because the new transitive
ResourcePlan.hppinclude is unavailable to an existing AGC test target.What I ran
Reviewed head
6adb491cd99bb8ff4411b1bbbab15ac82b5cef5aagainst PR basef776fddcffd1cfece220ecdd894371988b164f6a; the merge preview against currentmainb08c539c505c48341146c705bc72d9b603cdb3a7was clean. Environment: Debian GNU/Linux 12, x86_64, Python 3.11.2, GCC 12.2.0. I ran the repository no-build precheck and inspected the exact-head hosted Windows build log; I did not build locally.Results
mainfor PR #12246, #9318, and #12250; the declared dependency heads are not included in #12246agc_driver_cmask_fast_clear_testsUnedited Windows build failure excerpt
Findings
Blocking
ShaderResources.hppnow includesIntermediateRepresentation/IrMetadata/ResourcePlan.hpp, and the existingagc_driver_cmask_fast_clear_teststarget includesShaderResources.hppthrough itsPipeline.hpp/VulkanDevice.hppchain. The Windows compile command has-I core/shader/recompilerbut lacks-I core/shader/recompiler/IntermediateRepresentation/include, so the new header cannot be resolved. This makes the hosted changed-test build fail before tests run.Minimal fix: make the
IntermediateRepresentation/includedirectory available to every target that consumes this transitive header (for example through the appropriate shared CMake target include interface), or restructure the include so unrelated AGC tests do not require an unprovided path. Then rerun the Windows changed-test workflow.Non-blocking: The PR description explicitly declares #9318 and #12250 as dependencies; its current focused qualification does not claim joint validation with unmerged #9318. Reassess that integration when the dependency lands.
Sources
Not verified
To get this to a good state
Fix the missing include path and rerun the Windows changed-test workflow on the new head. I will recheck the same build result and affected source paths after the update.