feat(agc): scale unnormalized samples to the selected mip on multi-level 2D views #16935
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16935"
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 akkadbakkad89 on 2026-11-07T23:54:22Z.
What
A guest
image_sample_lthat explicitly selects a nonzero mip through an unnormalized S# on a single-layer 2D view with more than one level could not be bound: Vulkan'sunnormalizedCoordinatescan only read level 0, so the dispatch threw ("guest texture sampled with unnormalized coordinates ... (base level 0, levels 10, layers 1, view type 1)" in PPSA01317).Samplers proven to read only explicit LODs with a point mip filter, matching point or bilinear minification/magnification, no reduction, no mirror and no LOD bias now decode to a normalized host sampler and keep the measured unnormalized edge-or-border addressing. The emitted shader clamps the LOD argument to the S# range, rounds it to the selected level, queries that level's extent with
OpImageQuerySizeLodand divides the guest texel coordinates by it — texel-center coordinates for point filters — before an explicit-LOD sample. Mirrored, mip-linear, anisotropic, unequal-filter and biased S#s, and views starting above mip 0 or read by non-explicit-LOD forms, keep the existing single-level handling.Tested
Windows 11, synthetic AGC execution tests only; no title run.
agc_driver_image_sample_unnormalized(extended: a 3-level and the 4-level view read byimage_sample_l, per-texel data on every level with an LOD-1 row that lands on different texels than level 0 at the same coordinates, fractional LOD rows at 0.49, 0.5, 1.5 and 2.7 plus a MAX_LOD-clamped row pinningtrunc(clamp(lod, MIN_LOD, MAX_LOD) + 0.5), texel offsets, wrap-on-X addressing, and new rejections for mirrored, linear-mip and biased S#s) — passed underANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationon both GPUs; the layer loaded and the logs contain noVUID-lines and nowas not found but was requestedwarning.agc_shader_memory(scaled-flag andOpImageQuerySizeLodassertions inverifyUnnormalizedSamplers, folded-offset verifier walk extended to the scaled coordinate),agc_driver_image_sample_lod_clamp(both lanes),agc_driver_image_table_packed(13 lanes) — passed under the same environment on the RTX 3070.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 Devin
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-11T23:47:29Z.
Review: CHANGES_REQUESTED
Thanks, the two points from the previous review are fixed on e556d7a494. Three things before this can go in:
FillTexturewrites one constant to every texel of levels 2 and 3 (ImageSampleUnnormalized.cpp:183), andFetchreturns that constant for any coordinate inside them (:260). The newCheckcalls only select levels 2 and 3 (3x1 and 1x1 here), so dividing by the level-0 extent, or by no extent at all, would pass everywhere except the border rows. Please give every level per-texel values (as levels 0 and 1 have) and add an explicit LOD that selects level 1 (6x3), with coordinates that land on different texels there and on the level-0 texels with the same numbers, e.g. u = 0.5, 2.5, 5.75, 6.0, -0.5 for point, and the same for the bilinear and border S#s.floor(clamp(lod) + 0.5)(SpirvImageEmitter.cpp:1988) and passes that level to the host sample. Vulkan leaves the.5tie open for nearest mip selection, so this rule is a choice the code makes. Please add rows at LOD 0.49, 0.5, 1.5 and 2.7 (and one LOD clamped byMAX_LOD) so the rule is pinned, and name the rule in the debt line.docs/dev/debt/shader.md:103anddocs/dev/debt/libSceAgcDriver.md:243say the coordinates count texels of the selected level. In #16650 that was inferred from PPSA01317's hull shader ((a >> L) + 0.5with LOD = L), and the request there for an RDNA hardware-oracle check has no answer yet. The same goes for clamp mode 6 bordering at the selected level's extent, the LOD tie, and bilinear filtering at a level above 0 (the title only uses point filtering with an integer LOD). Please say in those lines that this follows the title's shader and is not measured on RDNA or gfx1013, and list the forms that aren't covered. If someone posts an oracle run, the lines can drop that.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:00:11Z.
Review: COMMENTED
Reviewed — no blocking findings
A complete approval is not justified because three changed files were excluded from the review bundle; no verified blocking defect was found in the code inspected.
What I ran
Reviewed head
2b947a52394437a51b8a3cb775dd8bbf12e9037cusing the prepared diff and the pinnedrepo_read.pyreader. No tests or build commands were run.Results
Findings
Blocking
None verified in the files read.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review bundle and was not read. These are three of 19 changed files; the other 16 changed files were read through the diff. Build, automated tests, and runtime behavior were not independently verified. The author reports synthetic Windows 11 execution tests, but these were not run by this review.To get this to a good state
Nothing is required. Optional: review the three excluded files and run the reported checks on this head before relying on approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T17:37:06Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: preserve repeat addressing for scaled unnormalized samplers that use clamp mode 0.
What I ran
Reviewed head
623ff8d5e302aa07342e5aa59bce35930c9fe88cusing the prepared diff and targeted reads throughrepo_read.py; no tests or builds were run.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp:173: scaled unnormalized samplers map every non-border clamp mode toCLAMP_TO_EDGE. The new proof accepts clamp mode 0, whichtoVkAddressModemaps toREPEAT; the added wrap-on-X execution case also uses mode 0 (ImageSampleUnnormalized.cpp:461). As a result, the newly supported repeat case samples edge-clamped texels instead of wrapping. Preserve the decoded address mode for repeat and clamp-to-edge, while retaining the intended border mapping.Non-blocking
None.
Not verified
No tests or build were run. The full text of these changed files was excluded from the review folder and was not read:
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp. Other changed files were inspected through the prepared diff; targeted repository reads coveredGuestSamplerResource.cpp,DescriptorBindingBuilder.cpp, andSpirvImageEmitter.cpp. The author's reported Windows GPU test results were not independently verified.To get this to a good state
Correct the scaled-sampler address mode mapping so accepted repeat mode retains repeat addressing, then run the unnormalized image-sample execution test on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:34:02Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the source reviewed; the new lowering clamps and rounds the explicit LOD, queries that mip’s extent, and scales the coordinates before sampling.
What I ran
Reviewed head
23a5a3e3ca53b4ec308ec7aa35362dda1a059169. No commands or tests were run; the author reports synthetic Vulkan execution tests on Windows 11.Results
Findings
Blocking
None identified in the files reviewed.
Non-blocking
None.
Not verified
Full source was read for 12 changed files.
ShaderResources.cpp,Graphics.cpp, andShaderMemory.cppwere inspected only at relevant diff hunks; their complete changed-line sets were not read. No tests, build, CI, or physical-console behavior were run. The author reports tests on Windows 11 with RTX 3070 and Intel UHD Graphics 630.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T07:04:02Z.
Review: COMMENTED
Actionable comments posted: 3
9baebd1b-8d5b-4dae-b50a-199925302815Reviewing files that changed from the base of the PR and between
c6331cc61band122dee7b08.core/libs/prx/libSceAgcDriver/Graphics/include/GuestSamplerResource.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleUnnormalized.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/PipelineSpecialization.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/changes/feat-agc-scaled-unnormalized-mip.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T07:23:11Z.
Review: COMMENTED
Reviewed — comments
The change’s core scaling path is supported by the inspected code, but I did not run the reported checks, so a formal approval is not justified.
What I ran
No commands or tests were run. Reviewed head
122dee7b08e01cfb7ad5390cbf895d5536722618; no merged-preview check was performed.Results
Findings
Blocking
None verified.
Non-blocking
Sources
Not verified
No tests were run. The description’s reported GPU and validation-layer results were not independently verified. I reviewed changed regions from all listed files; full text was unavailable in the review folder for
Graphics/src/ShaderResources.cpp,tests/Graphics.cpp, andtests/ShaderMemory.cpp, so I inspected their relevant changed regions throughrepo_read.py. Other changed files were inspected at relevant changed regions rather than read in full.To get this to a good state
Nothing is required. Optional: run the reported synthetic execution checks on this head and share the resulting output.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T05:53:18Z.
Review: COMMENTED
Reviewed — comments
The review covered the prepared diff at head
aff05664b8e48a650f017159461f6e1d40f6c8c3; no checks were run, and the full review is incomplete because some changed files were not read.What I ran
No commands or tests were run. I inspected the prepared description, commits, manifest, diff, and selected code at the pinned head.
Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Sources
The reviewed behavior is in
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppandcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppat the reviewed head.Not verified
I did not read every changed line. In particular,
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded from the review folder due to size; I inspected only targeted ranges ofShaderResources.cppthrough the pinned reader. I also did not read all added lines in the other changed files or run the reported Windows GPU tests. The remaining changed files are listed inreview/README.mdandreview/manifest.json.To get this to a good state
Nothing is required. Optional: complete inspection of all changed lines and run the reported tests before making a formal review decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T06:00:29Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
77ac9915-a5c5-49f0-a6eb-2ca786ad0b30Reviewing files that changed from the base of the PR and between
122dee7b08andaff05664b8.core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T13:11:01Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: replace the duplicate sampler definitions with valid definitions that preserve both border-color and scaled-unnormalized handling.
What I ran
Reviewed head
f8227a52cda9bf337fe773297d10239a12fe8c84. Read the prepared description, commits, manifest, and diff, then inspected a source excerpt withrepo_read.py. No build or tests were run.Results
Negative control
Not run; no tests or build were executed.
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp:72adds a function definition inside the existingDecodeSamplerResourcefunction, which is invalid C++. The added overload also usestableColorin its body although its parameter isscaledUnnormalized. The same nested-definition pattern appears atcore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cpp:85. Replace the existing definitions with valid implementations that handle both options. GuestSamplerResource.cpp at the reviewed headNon-blocking
None.
Sources
Not verified
No build, tests, or runtime behavior were verified. The prepared diff covered all 17 changed files, but full head source was inspected only for an excerpt of
GuestSamplerResource.cpp; the reader failed when it attempted to write its read log in the read-only run folder. Three changed files were marked as too large for the prepared folder:ShaderResources.cpp,Graphics.cpp, andShaderMemory.cpp.To get this to a good state
Fix the invalid sampler definitions, then run the relevant build and tests on the new head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T13:18:29Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
💬 Code review
Actionable comments posted (9)
b56d4dab-c61a-49f0-9ff5-b16cf76bc84bReviewing files that changed from the base of the PR and between
aff05664b8andf8227a52cd.core/libs/prx/libSceAgcDriver/Graphics/include/GuestSamplerResource.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T13:41:00Z.
Review: APPROVED
Reviewed — looks good
The reviewed head
2e2759309683d028f03a69d8c5f1b3ac4fcad244adds mip-dependent coordinate scaling for the proven unnormalized sampling cases, and I found no defect that blocks merging.What I ran
Reviewed the prepared diff and source at the exact head above. No merged-preview check, build, or test ran; no base was used for a merged preview. The review environment was read-only. I inspected the prepared review files and used
repo_read.pyfor pinned source context.The author reports synthetic AGC execution and shader memory tests passed on Windows 11; I did not run those tests.
Results
Negative control
Not run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No local runtime or hardware behavior was verified. The author’s Windows 11 test results were not independently run.
files.jsonlists no excluded files. Full text was not present in the review folder forcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; I inspected their relevant changed regions withrepo_read.py.Files read (17/17):
core/libs/prx/libSceAgcDriver/Graphics/include/GuestSamplerResource.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cpp,core/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cpp,core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp,core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleUnnormalized.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp,core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp,core/shader/recompiler/PipelineSpecialization.hpp,core/shader/recompiler/Recompiler.cpp,core/shader/recompiler/Recompiler.hpp,core/shader/recompiler/ShaderDiskCache.cpp,core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp, anddocs/dev/debt/changes/feat-agc-scaled-unnormalized-mip.md.To get this to a good state
No changes are required before merge. No commands need rerunning.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T13:48:56Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
💬 Code review
707cdff5-41c8-40d7-98b8-904b9934c866Reviewing files that changed from the base of the PR and between
f8227a52cdand2e27593096.core/libs/prx/libSceAgcDriver/Graphics/include/GuestSamplerResource.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestSamplerResource.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T14:21:58Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
26d779d68193233fae735949f2c238d30152f8c7against the prepared diff and manifest. I read all 17 changed-file hunks; full head text was included for 14 files, and targeted ranges for the three files omitted by size were returned byrepo_read.py. No tests or builds were run.The reader returned the requested source ranges, then reported that it could not append its read log because the run folder is read-only.
Results
Negative control
Not run; no source changes or tests were made during this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
The sampler proof restricts scaled unnormalized sampling to explicit LOD uses and supported filters; the emitter clamps the LOD, queries the selected level's extent, and scales coordinates before sampling: DescriptorBindingBuilder.cpp at the reviewed head, SpirvImageEmitter.cpp at the reviewed head.
Not verified
The author-reported Windows 11 GPU test runs were not independently performed. No title run or physical-console behavior was verified. The three files whose full text was omitted by size were
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; their changed hunks were present in the prepared diff, and targeted source ranges were read where needed. No files were excluded byfiles.json.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T14:26:09Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
e6255967-cfbd-4f70-ab28-4b553e1f7b60Reviewing files that changed from the base of the PR and between
2e27593096and26d779d681.core/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T15:16:03Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed prepared diff for head
5e89588befe0a3f41fb95e750599b56451af4227. No tests or build checks were run. The pinned reader could not complete: it failed while writing its read log in the read-only workspace.Results
Findings
Blocking
None verified.
Non-blocking
files/can be inspected at the pinned head:core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp. Their changed lines were present indiff.patch.Not verified
The full head source for the three files listed above was not read because the pinned reader failed. No tests, builds, or runtime behavior were independently verified. The other changed files were available under
files/; the review used the prepared diff and selected available file context.files.jsonlists no rule-based exclusions.To get this to a good state
Nothing is required. Optional: rerun the review with the pinned reader able to complete so the omitted source context can be checked.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T16:31:30Z.
Review: APPROVED
Reviewed — looks good
The reviewed change supports eligible explicit-LOD unnormalized sampling across mip levels, and the inspected code and test additions support merging.
What I ran
Reviewed head
983790d5092f12a501a3ecf8bc8c914e78d21f5dusing the prepared diff and manifest, plus targeted reads withrepo_read.py. No tests or build commands were run. The three files whose full text was omitted from the review folder were inspected at their changed hunks.Results
Negative control
Not run; no tests were executed in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
ShaderResources.cpp,Graphics.cpp, andShaderMemory.cpp; their changed hunks were reviewed from the diff and targeted source reads.To get this to a good state
Nothing required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:44:04Z.
Review: COMMENTED
On Linux/lavapipe,
agc_driver_image_sample_unnormalizedandagc_driver_gcn_scalar_buffer_basepassed on main atba0ff896612band with this head integrated. Both sides required Vulkan, disabled the shader cache, and loaded Khronos validation 1.4.369 for both tests. Neither log reported a missing layer or a VUID.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.