feat(agc): honour the DEPTH row pitch of linear 2D textures as RDNA2 does #11280
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11280"
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 Michael-KD on 2026-10-25T23:39:20Z.
What
A linear 2D T# whose
DEPTHfield (word 4) named a row pitch other than its default threwguest 2D linear texture descriptor sets a custom pitch other than its default pitch, which is not implemented. RDNA2 hardware uses that field as the row pitch, so such textures now decode and read with the measured layout instead of stopping the guest.The rule, measured with the hardware oracle: the row pitch is
DEPTH+ 1 elements, raised to the width and rounded up to 256 bytes. ADEPTHthat rounds to the default pitch, including any below the width, now decodes as the default pitch; before, onlyDEPTH= default pitch − 1 was accepted.GuestTextureResource: a newlinearPitchfield, in elements.DecodeTextureResourcesets it for a single-level, uncompressed linear 2D T# with no base array, and only when the pitch differs from the default, so every descriptor accepted before decodes as before. Block-compressed, mipmapped and base-array surfaces with aDEPTHpitch still throw (not measured).EncodeTextureResourcerefuses a resource with a custom pitch rather than dropping it.ComputeLinearMipLayoutandComputeMipLayouttake the pitch;DescribeSurfaceand the texture cache pass it, sopitchBytes,blocksPerRowand the guest size follow it.Texture::CanCopyFromandStorageTexture::SameSurfaceShapecompare the pitch, so a storage or sampled texture of one pitch does not serve another. The texture cache keys on the descriptor words, which holdDEPTH.main's rule: a linear 2D T# decodes only its default pitch and throws otherwise, since the pitch rule is measured on RDNA2 only.docs/dev/debt/libSceAgcDriver.md: a new "Linear 2D texture pitch" entry for what stays open (gfx1013; compressed, mipmapped and base-array surfaces; PS4 guests).Overlap:
tools/pr_overlap.pylists #9891, #9892, #9893 and #9895 (PS4 support; heads375f5630ba,545e2b5b3f,781ffafe9f,3e32049166). No order is needed and none is a prerequisite. Each conflicts with this PR in three adjacent additions that keep both sides: the#include <array>they add next toRdnaDecoder/RdnaInstructionDecoder.hppinGuestTextureResource.cpp, theirif (gcn) { result.gcnPitch ... }block besideresult.linearPitchthere, and theirRequire(!IsGcnTiled(tileMode), ...)line beside this PR'sComputeLinearMipLayout(..., 0u)call inComputeElementMipLayout. TheirDescribeSurfacereturns throughdescribeGcnSurfacefor a PS4 surface before the RDNA layout that readslinearPitch, and a PS4 guest's linear 2D T# keepsmain's default-pitch rule here (GcnGuestShaders()), so this PR changes nothing for PS4 guests either way. #9891's head merged into this branch with that resolution passesagc_driver_graphics,agc_driver_gcn_detileandagc_driver_linear_texture_pitchon both GPUs below with the validation layer and noVUID-lines. No PR it could not compare changes the custom-pitch check.Measurement:
image_load(DIM 2D, data mask 1) through a linear 2D T# (TYPE9, height 4, one level) over a buffer whose element at offsetoencodeso(for 8-bit texels, two runs with the low and the high byte of the offset). Each lane loads(x, y)for 16 x values and y 0 to 3, and the element it reads gives the row pitch the hardware used.yaty × pitch, with pitch =max(DEPTH + 1, width)rounded up to256 / bytes per element. For example, width 16 32_UINT:DEPTH0 to 63 give 64, 64 to 127 give 128, 128 gives 192, 1023 gives 1024. No lane read anything the rule doesn't explain.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release.
agc_driver_linear_texture_pitch(new): 128 threadsimage_loada 16×8 32_UINT linear 2D texture, whose elementiholds0xa0000000 | i, withDEPTH15, 63, 64, 127, 128 and 255 in turn over the same memory, and check every texel against the measured pitch (64, 64, 128, 128, 192, 256). Onmainit fails at its first case,DEPTH15, a pitch below the width that the hardware treats as the default:guest 2D linear texture descriptor sets a custom pitch other than its default pitch, which is not implemented (format 20, 16x8x16, type 9, tile 0, mips 0..0 of 1). With this change it passes.agc_driver_graphics(GuestTextureResource.cppcases updated): the decoded pitch for 32-bit and 8-bit formats, rounding, a pitch below the width, the surface layout, encoding with the default pitch, and the mipmapped refusal.ctest --test-dir build -R '^agc_driver_(graphics|linear_texture_pitch|gcn_detile)$' -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0, insertion confirmed withVK_LOADER_DEBUG=layer) andANYPS5_GPUset to each device, on this PR's head2baa6d8d40and on its basemainbb04a4f1ea.agc_driver_gcn_detileis included because the rebase onto the PS4 (GCN) texture path in0bec339021touched the same decode and layout code; PS4 descriptors carry their pitch in word 7 and never setlinearPitch. Themainarm builds every file this PR changes frommain, includingtests/GuestTextureResource.cpp, soagc_driver_graphicsrunsmain's own test source; it keeps only the newLinearTexturePitch.cpp, so the new test runs on both sides:main, RTX 5070 Timain, Radeon iGPUagc_driver_linear_texture_pitchagc_driver_graphicsagc_driver_gcn_detileNo log contains
was not found but was requested by env var VK_INSTANCE_LAYERS, no log has aVUID-line, and each log names the selected GPU.Full
ctest -j8with this change, before the rebase ontobb04a4f1ea(onmain48c160c58b): 2394 of 2396 pass. The two failures,agc_host_import_cut_lifetime(#10746) andagc_driver_depth_plane_partial_store(#10664), also fail with the change reverted.Checklist
main; no other open PR implements the same functionsNotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:04:58Z.
Review: CHANGES_REQUESTED
I reviewed the updated exact head
bf4b9e17d6433887e05143f09a93cd3834a565f1. The revised overlap explanation addresses the earlier question: it identifies the three adjacent insertions and describes why the PS4 GCN path does not consumelinearPitch.One required validation result is still missing.
CONTRIBUTING.mdrequires the same focused AGC tests onmainand the change, with validation enabled, on each reported GPU. The report showsagc_driver_graphicsasn/aonmain; onlyagc_driver_linear_texture_pitchis shown there. Please run the baselineagc_driver_graphicstest (using the baseline test source if the new assertions depend onlinearPitch) on both listed GPUs with the same validation settings, and add its outcome alongside the PR result. The hosted Linux/Windows product checks are skipped for this change, so CI does not supply that baseline evidence. I have not independently run these hardware tests.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:11:12Z.
Review: APPROVED
The exact-head report now includes the missing baseline run on both listed GPUs, plus the same focused tests on the change, with validation-layer insertion confirmed and no new output. The prior baseline-evidence blocker is resolved. The current conventions check passes; hosted product tests remain path-skipped, and the GPU runs are author-reported rather than independently reproduced by me.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T10:17:38Z.
Review: COMMENTED
NVIDIA run on Linux for head
3773b4960.Linux run: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 (NVIDIA 595.99.02) and lavapipe (Mesa 26.0.3), one at a time via
VK_DRIVER_FILES. Khronos validation layer 1.4.341 withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1;VK_LOADER_DEBUG=layershows the layer inserted, no "was not found but was requested", 0VUID-lines.Base
main808a557ac; the merge is clean.main+ onlyLinearTexturePitch.cpp:agc_driver_linear_texture_pitchfails on both devices withguest 2D linear texture descriptor sets a custom pitch other than its default pitch, which is not implemented (format 20, 16x8x16 ...).agc_driver_linear_texture_pitch,agc_driver_graphicsandagc_driver_linear_target_*(14 tests) pass 3/3 on each device. On lavapipelinear_target_direct_write_completionskips, as onmain. 0VUID-.^agcsuite (no flip/display/lds64,-j1): 3070 1053/1053, lavapipe 1052/1053. The one failure isagc_driver_multisample_retirement, which also fails onmain.public_headerspasses.GPUs tested: NVIDIA RTX 3070 (Linux), lavapipe.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:25:44Z.
Review: APPROVED
Re-checked — new head, looks good
The rebased head carries the measured RDNA2 linear 2D row pitch through decoding, surface sizing, and texture compatibility checks, and the reported exact-head GPU tests pass.
What I ran
Reviewed PR head
2baa6d8d407e8b79192f3e2a272cfe17c12ca9d3against basebb04a4f1ea0175e9e4f149f0359a764d62ff3296; refreshed currentmainisf46f453a56f91d77e29ce0cbd7fe5bfb2fb69834. The merge preview with currentmainis clean (treea434269dc23e81758c5b2eca46693f30da0e3ba0). Environment: Linux 6.1.0-54-amd64 x86_64; no local compiler, build, or tests run.Results
mainUnedited output from local and hosted checks
The hosted results above are the recorded output of
gh pr checks; the hardware runs are author-reported in the PR description.Negative control
DEPTHpitch is decoded and used for row addressingbb04a4f, before this change.Findings
Blocking
None found in the reviewed head. The custom pitch is accepted only for uncompressed, single-level linear 2D surfaces without a base array; it is rounded using the element size and propagated into layout and compatibility checks. PS4 GCN descriptors retain their separate pitch handling.
Non-blocking
The measured hardware rule is reported for RDNA2; the PR leaves PS5 gfx1013 and unsupported compressed, mipmapped, and base-array cases documented as unverified or unsupported.
Sources
Not verified
I did not build or run tests locally, independently reproduce the two GPU reports, or verify the behavior on PS5 hardware. Linux and specialized hosted jobs were skipped.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:48:10Z.
Review: COMMENTED
Withdrawn. The validation comparison this review asked for is already in the PR's
Testedsection:mainvs this head on both GPUs withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, noVUID-. The PR also has no title to name;Unblocks: noneis correct.