fix(shader): sample one-slice volumes through plain, level-zero and explicit-LOD 2D accesses #22583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22583"
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 JJenkx on 2026-11-17T22:31:19Z.
What
A pixel shader's 2D
image_samplethrough a one-slice, single-level 3D T# was accepted only in its biased form (image_sample_b, since89777fcaa114), and only with a normalized point sampler. Any other form stopped withimage descriptor is incompatible with the static runtime image interface, because no 3D runtime mode was offered for the access. Spirit of the North: Enhanced Edition (PPSA02306) samples a 1x1x1 placeholder volume this way (T#10049900 03800000 00000000 a0500f2e 00000000 00700000 00000000 00000000), with implicit LOD and a bilinear sampler (00000092 00fff000 06500000 00000000: clamp-to-last-texel on X, Y and Z, bilinear XY, linear Z, point mips).ImageResource::singleMipPlaneSampleCompatibleoffers the 3D mode for pixel-stage 2D samples with implicit LOD, LOD zero, explicit LOD or bias, in the same 32-bit, direct, unpacked shape as the bias case. The T# check (one slice, mip level zero only) applies to all of them.FormatVersion88 to 89).Why the other forms match the bias form on the hardware
Measured with
tools/hw-oracleon an RX 6650 XT (gfx1032, RDNA2, Linux 7.2.14, hsa-rocr 10.1, clang 23.1.5; wave32, IEEE off, DX10 clamp on, denormals preserved, round to nearest even, FP16 overflow off). A 64x64 8_8_8_8_UNORM linear texture, read through a 2D T# (type 9) and through a 64x64x1 3D T# (type 10) with the same words otherwise, DIM 2D:92/00fff000/05500000(bilinear XY, point Z)92/00fff000/06500000(bilinear XY, linear Z)image_sampleimage_sample_lzimage_sample_limage_sample_bimage_sample_dimage_loadEach column is two runs of 32 rows: at texel centres, where every row returns the expected texel, and 0.3 texels off them, where 28 of 32 rows are blends of neighbouring texels. This is an RDNA2 measurement, not PS5/gfx1013 evidence.
image_sample_dis measured but not accepted here.Tested
Additional Windows NVIDIA qualification (reported 2026-11-24): maskym’s head-matched retest applies
2c31ede18dalone to main2b09db6f11. Windows 11 26300, i7-12700K, RTX 2070 SUPER, WinLibs GCC 15.2.0, Release; the GPU driver version is not specified. With required Vulkan, shader-cache disabling and validation 1.4.366, both main and the PR pass 2170/2171 AGC/VideoOut/pad checks, with 1966 layer insertions per tree, no missing-layer reports and no VUIDs. The shared failure isagc_driver_store_over_untracked; the contributor reports every test added or changed by this PR passing in that run. These are contributor-reported compatibility results, not an all-green full suite, console measurement or performance result.Linux 7.2.14, Ryzen 9 7950X, RX 6650 XT, RADV (Mesa 26.2.7), GCC 16.2.1, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF.agc_driver_image_plane_bias_on_single_level_volumenow also draws withimage_sample_lzandimage_sample(gfx1013 encodings fromllvm-mc). With a bilinear clamp-to-last-texel sampler, the volume's pixels equal the plane's for the bias, LOD-zero and implicit forms. A two-slice volume is refused for each form, and the sampler refusals cover border Z with a bilinear sampler, min reduction with a bilinear sampler and unnormalized coordinates. Its existing bias cases are unchanged.ctest -R "single_level_volume|^agc_shader_disk_cache|^agc_shader_memory": 6 of 6 pass.main8a1f57ac1485it stops at 16 to 58 s on the incompatible image interface. With this PR it passes that point and stops at 16 to 42 s on the same draws' sampler, which in those runs holds other descriptors' words (the volume's own T# words, or a V# such as938cfd00 00100010 0000002d 0004dfac) that read as an unnormalized sampler. That is still refused, so this PR does not unblock the title.app.elf+0x51dd95, a read at0x1aa80c0c4during loading); the same crash at the same address happened on 2026-11-14 on an unrelated branch (aaa396c71327), and this title otherwise runs the full 70 s, so it is an intermittent crash of the title's, not of this change.Independent NVIDIA Linux validation reported by @Doorriiaann: RTX 3070 test results at
84192d7fb9; the contributor reports passing focused checks with no Vulkan validation errors.Independent validation reported by domx4q on RTX 4090, NVIDIA 620.70.06: 6/6 focused tests passed; the extended one-slice volume fixture failed in both negative-control runs with main’s recompiler files. Khronos validation was loaded for the GPU cases; no VUID errors were reported. These are contributor-reported results.
Independent AMD Windows validation reported by Helldiverr: head
2c31ede18dmerged onto mainefc6f9c3baas0ab8ec5da4, R9700/gfx1201, driver 32.0.31044.16, Windows 11, validation 1.4.363. The contributor reports 22 focused tests passing in each of three runs with no VUIDs, the extended fixture failing on main, and three detected mutations. Point XY with linear Z has no new Vulkan execution coverage in this report; the existing author's hardware-oracle evidence remains the cited support. The shader-memory test was not run because of the host's post-link objcopy failure. Other pending cache-layout changes still need distinct format versions when composed. These are contributor-reported results, not new local runs.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-17T23:11:26Z.
Review: COMMENTED
I read this against
main9f75bf0be3. I didn't build it. It doesn't overlap my #22534, which touches the cube-face branch ofRuntimeImageModes, andgit merge-treeof the two heads is clean.The S# checks read right to me against the gfx10 layout:
FILTER_MODEis word 0 bits 29-30, and it must be 0 (blend) once the sample filters.XY_MAG/XY_MIN_FILTERis word 2 bits 20-23, and must be all point or all bilinear (5).Z_FILTERabove point counts as filtering.MIP_FILTERmust be at most point.CLAMP_Zmust not be one of the border modes when filtering. With a one-slice volume, wrap, mirror and the two clamp-to-edge modes all fetch the same slice.Two questions:
sample_lhas no test. TheResourceTrackermask now also acceptsRdnaImageSampleFlagLod, but the execution test only runsBiasSample,LevelZeroSampleandImplicitSample. An explicit-LOD case would pin that path, ideally at LOD 0 and at a LOD above 0, which clamps to the only level on both the plane and the volume. Otherwise, leaveLodout of the mask until it's tested.MAX_ANISO_RATIO(word 0 bits 9-11) isn't part of the check. For a filtered 2D sample, the plane is sampled with the guest's anisotropy and the 3D view with the same host sampler. I don't know that every driver applies anisotropy to a 3D image the way it does to a 2D one, so the two may not match. Requiring ratio 0 whenfiltered, or a plane-vs-volume case with an anisotropic sampler, would settle it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T05:55:07Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports the stated sampling restrictions and cache serialization updates.
What I ran
Reviewed head
b95755c4bfe4582107004a3f613c3c16959ba335usingrepo_read.pyto inspect the prepared diff and targeted source ranges. No tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full contents of
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded as too large; its changed lines were present in the diff but the file was not read. No tests or hardware behavior were independently verified. Read:review/description.md,review/commits.md,review/manifest.json,review/diff.patch,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp(diff only),core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/ShaderDiskCache.hpp,core/shader/recompiler/ShaderDiskCache.cpp(targeted ranges). Also inspected changed lines forcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImagePlaneBiasOnSingleLevelVolume.cpp, anddocs/dev/debt/changes/fix-agc-sample-single-level-volume-planes.mdin the diff.ShaderMemory.cppwas excluded by the review-folder size rule.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:55:31Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the focused behavior and cache updates are supported by the inspected code and reported validation.
What I ran
Reviewed head
2bdb6db72a6eb9bf99116d819241122ac34dd859. Read the prepared description, commits, manifest, and diff; inspected the changed sampling, runtime image mode, sampler validation, cache serialization, and execution-test code at the pinned head. No test commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the review folder as too large; only the changed test lines and adjacent context were read throughrepo_read.py. The rest of that file and the broader repository were not reviewed. Hardware and title runs in the description are reported by the author or contributors and were not reproduced.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T08:37:05Z.
Review: APPROVED
Reviewed — looks good
The change extends one-slice 3D texture compatibility to additional 2D sampling forms and includes focused regression coverage; I found no verified blocking defect in the code read.
What I ran
17f4707d5df482b9ea633b50c87e0e6618c52a1eusing the preparedreviewbundle and the pinned repository reader.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the prepared bundle because it was too large; its changed line is visible inreview/diff.patch, but the file’s full text was not read.review/files.jsonwas unavailable through the reader, so exclusions are reported fromreview/manifest.json.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T07:25:47Z.
Review: COMMENTED
Reviewed — no blocking findings
The code changes are coherent with the stated scope, but the review is incomplete because one changed file was not read and no checks were run.
What I ran
2c31ede18da9e859bdcff6bea8ecb5f88b890154and the prepared diff; no build or tests were run.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp(changed line),core/libs/prx/libSceAgcDriver/tests/execution/ImagePlaneBiasOnSingleLevelVolume.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp,core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/ShaderDiskCache.cpp,core/shader/recompiler/ShaderDiskCache.hpp, anddocs/dev/debt/changes/fix-agc-sample-single-level-volume-planes.md.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review folder; only the changed lines were read through the repository reader.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere not read; only its changed region was inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T07:55:11Z.
Review: APPROVED
Reviewed — looks good
The reviewed head is
1e3681625dd188c347ec99a059968fae711ba873; the implementation and changed test coverage inspected support merging, with no blocking defects found.What I ran
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the prepared full-text files because it exceeded the review folder limit; its changed hunk and surrounding function were inspected in the diff, but the file was not read at the pinned head.files.jsonwas not available through the reader. The manifest lists 9 changed files: 8 included and 1 excluded. The full text at the head was read for 7 included files;ShaderMemory.cppwas not read. The debt note was present in the diff but not separately read at the head.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T08:27:16Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes add guarded 2D sampling modes for one-slice, single-level volumes; I found no concrete blocking defect, but the full review is incomplete because the large ShaderMemory.cpp file was only read around its changed line and no checks were run.
What I ran
Read the prepared review bundle and targeted source ranges using
repo_read.pyat head4fb6a12e3dfa51e1fadd051140c2698b1f9b90d6. No tests or build commands were run. The prepared bundle reports contributor-run tests; those results were not independently verified here.Results
Findings
Blocking
None identified in the inspected ranges.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the review bundle because it was too large; only lines 13295–13320 around its changed line were read through the pinned reader. No build, automated checks, physical console behavior, or author-reported hardware results were independently verified. Files read:description.md,commits.md,manifest.json,diff.patch,ShaderDiskCache.cpp(test),ShaderMemory.cpp(targeted range only),ImagePlaneBiasOnSingleLevelVolume.cpp,Resources.hpp,DescriptorBindingBuilder.cpp,ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.cpp(recompiler),ShaderDiskCache.hpp, andfix-agc-sample-single-level-volume-planes.md. Excluded from full-text review:ShaderMemory.cpp.To get this to a good state
Nothing is required. Optional: run the focused tests and build on this head, and inspect the rest of
ShaderMemory.cppif a complete review is needed.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:11:19Z.
Review: COMMENTED
The one-slice volume, shader-memory, and scalar-buffer CTests passed on main and this head. Both Vulkan runs used the same Linux lavapipe device with Vulkan required, shader cache disabled, and validation layer 1.4.369. The logs show layer insertion and contain no missing-layer diagnostic or
VUID-entry.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.