Repository navigation
feat(agc): apply a T#'s MIN_LOD clamp in the shader without VK_EXT_image_view_min_lod - #12662
1 commit merged into
Conversation
|
@Gonic0 Please reject unsupported sampler/image combinations or preserve the late view-clamp semantics before enabling this lane. With BASE_LEVEL=0, LAST_LEVEL>=2, T# MIN_LOD=2 and S# MAX_LOD=1, adding shader MinLod makes lod_min exceed lod_max (undefined in Vulkan), whereas the view clamp applies after sampler LOD limiting. FMax on an explicit LOD also runs before that limiting. The debt entry describes this gap but the code accepts it. Please cover this and the no-mip-filter case with defined output or a clear rejection. Please exercise the no-extension lane explicitly and add fractional MIN_LOD, explicit L/lz and bias cases, plus alternating textures/clamps through cache hits. Check converted/emulated comparison samples too: EmitSampleOp returns into EmitEmulatedSample before the new clamp, and that implementation fetches mip 0. Preserve or reject the clamp there as appropriate. Include an extension-enabled SPIR-V equivalence control. The new target bit and generated source version change cache keys on extension devices as well, so distinguish unchanged shader instructions from cache invalidation. One more: the request serialization version goes from 49 to 50 here, and other open PRs (#10547, #11483, #10846) also move it to 50. When you rebase, please take the next number strictly above whatever main has at that point, so two requests never share a version. |
adriadam10
left a comment
There was a problem hiding this comment.
Agreeing with @oneandonlydean's review; the points below are still open on this head:
DescriptorBindingBuilder.cpp:366-370writes the T# clamp intoMinLodBase + imageregardless of the S#. With T# MIN_LOD above S# MAX_LOD,MinLodexceedslod_max, which Vulkan leaves undefined, while the old view clamp applied after the sampler's LOD limit. The debt line indocs/dev/debt/shader.mddescribes the gap but the code accepts it: either reject that combination (throw) or reproduce the late-clamp semantics.SpirvImageEmitter.cpp: theFMaxon an explicit LOD runs before the sampler's limit too, so it has the same problem.- Cover the S# MAX_LOD below the clamp case and a sampler with no mip filter with defined output or a clear rejection, and add a fractional MIN_LOD case (e.g. 0x180) to
ImageSampleLodClamp.cpp. agc_driver_image_sample_lod_clamp_testsskips unlessshaderResourceMinLodis present but never forces the no-extension lane on a device that has the extension, so CI (lavapipe) doesn't exerciseshaderImageMinLod. Please add a way to run that lane explicitly.
The rest (relative clamp, base-level handling, v50 serialization, MinLod capability in ValidateShaders) reads correctly.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The current head does not build in the Linux Release configuration, and the fallback clamp still differs from Vulkan’s defined LOD behavior in several reachable sampling cases.
What I ran
- Linux GCC 12.2 Release build of
agc_driver_image_sample_lod_clamp_tests,agc_shader_memory_tests, andagc_driver_graphics_tests. python3 tools/check_conventions.py --base upstream/main --head HEAD.git diff --check upstream/main...HEAD.git merge-tree --write-tree upstream/main HEAD.- Refreshed the hosted checks and inspected the exact current diff at
9d42922fc0d218f0bf7581e2d2a8a1955a75e730.
Results
| Check | Result |
|---|---|
| Linux Release build | Failed compiling ShaderDiskCache.cpp; diagnostics below |
| Conventions | Passed |
| Diff whitespace | Passed |
Merge preview against current main |
Clean; tree e1e7de7a2f442c0e40b52c674e5f71f8ab8eb416 |
| Hosted checks at review time | Windows build and two macOS relinker jobs pending; Linux product, register-context, and write-watch jobs skipped. Ubuntu/Windows relinker, relinker ASAN, conventions, eligibility, intake, labels, and report passed. |
Raw compiler diagnostic excerpt
FAILED: core/libs/prx/libSceAgcDriver/CMakeFiles/shader_recompiler_agc_driver.dir/__/__/__/shader/recompiler/ShaderDiskCache.cpp.o
/tmp/anyps5-pr12664-review/core/shader/recompiler/ShaderDiskCache.cpp:88:46: error: static assertion failed: CompiledShaderArtifact changed: update the artifact encoder
88 | static_assert(sizeof(CompiledShaderArtifact) == 288, "CompiledShaderArtifact changed: update the artifact encoder");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/tmp/anyps5-pr12664-review/core/shader/recompiler/ShaderDiskCache.cpp:88:46: note: the comparison reduces to ‘(296 == 288)’
/tmp/anyps5-pr12664-review/core/shader/recompiler/ShaderDiskCache.cpp:90:39: error: static assertion failed: RecompileResult changed: update EncodeResult and DecodeResult
90 | static_assert(sizeof(RecompileResult) == 552, "RecompileResult changed: update EncodeResult and DecodeResult");
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/tmp/anyps5-pr12664-review/core/shader/recompiler/ShaderDiskCache.cpp:90:39: note: the comparison reduces to ‘(560 == 552)’
ninja: build stopped: subcommand failed.
Negative control
Not run. The build stops at the new Linux structure-size assertions before the focused test binaries can be built.
Findings
Blocking
-
Linux build fails on the new artifact field. The PR adds
shaderImageMinLodto bothCompiledShaderArtifactandSpirvTarget, and updates the artifact encoder, but the Linux-only size assertions remain at 288 and 552 bytes. GCC reports actual sizes of 296 and 560. Update the assertions/encoding contract as appropriate and rerun the build. -
Explicit LOD is clamped before sampler bias. At
EmitSampleOp, the explicit Lod operand is replaced withFMax(lod, clamp); Vulkan then addssampler.mipLodBiasto that operand before applying the LOD bounds. For example, explicit LOD 2, T# MIN_LOD 2, and S# bias -1 produce an effective LOD of 1, below the requested clamp. The guest sampler path accepts negative bias. Preserve the clamp after bias, or reject this combination, and add an explicit-LOD regression case with negative bias. -
T# MIN_LOD above S# MAX_LOD yields undefined shader-operand behavior. Vulkan sets
lodmin = max(sampler.minLod, shaderOp.minLod),lodmax = sampler.maxLod, and declares the result undefined whenlodmin > lodmax. The current shader path emits the T# clamp asshaderOp.minLodwithout checking the paired sampler’s maximum. The PR’s debt note acknowledges this case, but the runtime currently accepts it. Preserve the view-clamp result or reject the incompatible pair; include the no-mip-filter / maxLOD 0 case. -
Emulated sample paths bypass this clamp.
EmitSampleOpreturns toEmitEmulatedSamplefor emulated depth comparison and converted 11:11:10 samples before reaching the descriptor-clamp logic. That implementation fetches mip 0 for its texels. Apply the T# clamp to these emulated sample paths or reject the combination explicitly, with focused tests. -
The new serializer version collides with three other open PRs. This change moves request serialization from version 49 to 50, as do open #10547 (head
2b1908e3621c0e7a6e62b7f8729cda06d6c5de87), #11483 (headb81b8a12ff1e0b0ccaae3c7e11baebaac54b5e18), and #10846 (headd21510c5d279c8dd35392fa88b453c1e6b180eac), each for a different trailing field. Coordinate a merge order, declare the dependency required by the repository rules, and assign this field a unique version after rebasing onto the resultingmain.
Non-blocking
- The focused GPU tests and the no-extension path could not be exercised locally because compilation stopped at the assertions. The hosted macOS and Windows full-build checks were still pending at the time checked.
Sources
- PR head
9d42922fc0d218f0bf7581e2d2a8a1955a75e730: explicit LOD handling and descriptor clamp, emulated sample dispatch, mip-0 fetches, Linux size assertions, and request serializer version bump. - Vulkan 1.4.351 LOD operation defines sampler bias, shader MinLod, and the undefined
lodmin > lodmaxcase. - Open #10547, #11483, and #10846 each currently allocate serializer version 50.
Not verified
- PS5 hardware behavior.
- The reported Apple M5 Pro/MoltenVK title run.
- Full Linux or Windows product tests, focused Vulkan tests, and the pending hosted jobs.
- Exact console output for the unsupported sampler/image combinations above.
To get this to a good state
- Fix the size-assertion build failure and rerun the focused build/tests.
- Preserve or explicitly reject explicit-LOD-plus-negative-bias and T# MIN_LOD-above-S# MAX_LOD combinations.
- Cover emulated compare and converted sampling.
- Coordinate and declare the serializer version order, then rebase and rerun checks on the new head.
Source correction — citation updatedThe Vulkan specification URL in my review used an invalid path. The cited LOD rules are in the official Vulkan-Docs snapshot at commit Sources |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Thanks @oneandonlydean, @adriadam10 and @MarcZX10. Pushed Linux build. The size assertions in Combinations the shader clamp cannot match are now rejected.
When the clamp is at most every paired MAX_LOD, Tests (
Cache keys. Serializer version. Tested on macOS 27.2, Apple M5 Pro, MoltenVK 1.4.2 (no extension, no GPL, so the shader lane):
Not verified: a Linux build, a lavapipe run, and the image-view lane on a device with AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — approved
The current head resolves the blocking build and LOD-semantics findings from my previous review. I approve commit 279911dd95b25dc56cff05e7708ed103bf556446.
What I ran
- Configured a Linux Release build with GCC 12.2 and
BUILD_TESTING=ON. - Built
agc_driver_image_sample_lod_clamp_testsand its dependencies. - Built and ran the request serializer test.
- Ran the shader-clamp and image-view CTest entries.
- Ran
python3 tools/check_conventions.py --base upstream/main --head HEAD,git diff --check upstream/main...HEAD, and a merge preview against currentupstream/main. - Refreshed hosted checks and inspected the current diff at the exact head above.
Results
| Check | Result |
|---|---|
| Linux Release focused build | Passed; target linked successfully |
request_serializer |
Passed |
| Conventions | Passed |
| Diff whitespace | Passed |
| Merge preview | Clean; tree f299f5db8359900a0bbb67fe4d50ced8dd9e7b43 |
agc_driver_image_sample_lod_clamp_shader_lane |
Could not run: host CPU is below the project's minimum |
agc_driver_image_sample_lod_clamp |
Could not run: same CPU limitation |
| Hosted checks | Windows, Ubuntu/Windows relinker, ASan, conventions, eligibility, labels, and report pass; Linux product and specialized jobs skip; two macOS relinker jobs remain pending |
The local GPU test runner stopped before opening Vulkan:
The host CPU (Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz) lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA. The PS5's Zen 2 CPU has these extensions and titles run their instructions natively, so this CPU cannot run them.
The author reports that the shader lane and title scenario pass on an Apple M5 Pro with MoltenVK 1.4.2. I did not independently reproduce those GPU/title results.
Negative control
| Control | Result |
|---|---|
| Local mutation test | Not run; this host cannot execute the project test binary |
| Author-reported shader mutations | The PR comment reports that clamp truncation and dropping the MAX_LOD validation fail the focused test; not independently reproduced |
Findings
Blocking
None found at this head.
The earlier Linux size-assertion failure is fixed; the focused target now builds. The descriptor binding path rejects sampler combinations where shader MinLod would differ from the view clamp, and the tests now include explicit LOD/bias, fractional clamps, cache re-specialization, and the unsupported MAX_LOD/no-mip-filter cases.
Non-blocking
- Request serialization is version 50, which is also used by other open PRs. Current
mainremains at 49, so this head is valid against the current base; if another version-50 change lands first, rebase and advance the version before merging this one. - I could not execute either Vulkan test locally because the available CPU lacks the required instruction set. The author-reported M5 Pro shader-lane and title tests provide the hardware evidence for this path.
Sources
All code links point to the reviewed commit 279911dd95b25dc56cff05e7708ed103bf556446.
- Sampler/image compatibility validation
- Per-image clamp specialization
- SPIR-V clamp emission
- Shader-lane and regression cases
- Request serializer version and field handling, deserialization
- Vulkan LOD operation and image-level selection
Not verified
- Local Vulkan execution of either lane.
- macOS relinker jobs still pending at check refresh.
- PS5 hardware behavior; the reported title run was performed by the author.
To get to a good state
The current implementation is in good state for review. Reassign the serializer version if another version-50 change reaches main before this PR.
|
Pushed
The test and PPSA21564 01.007.000 were rerun on MoltenVK, with the same results as before. The new rejections do not fire in the title. AI-assisted: yes |
XairRrR
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
The shader-clamp lane works on an NVIDIA RTX 4070 Ti SUPER, but one new test case asks for a rounding that Vulkan leaves to the implementation. Because of it, both agc_driver_image_sample_lod_clamp and the new agc_driver_image_sample_lod_clamp_shader_lane fail on this GPU, and the first one passes on main.
What I ran
- Head:
a8f8087cb5789322d750562faa66f6ba944d4b87 main:3a2b91981651569163768854a1fcdc7193b6667b- Merge of head into
main: clean (ab662524130a8d8f1aa9dd85e0ac43238aaf9203) - Machine: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release, Ninja. These are the first runs on NVIDIA hardware posted in this thread. Earlier reviewers could not run the Vulkan tests, and the author ran them on an Apple M5 Pro.
git diff --check origin/main...pr-head
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10
ctest --test-dir build -j4 --output-on-failure -R '^(request_serializer|agc_shader_memory|agc_shader_disk_cache|agc_driver_graphics)$'
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
ctest --test-dir build -V -R agc_driver_image_sample_lod_clamp # merged tree, then main
# diagnosis: same ctest with the bias of the second Case{0x100u, 1u, 0xfffu, 1u, -128} (ImageSampleLodClamp.cpp:283) set to -96
# negative control: SpirvImageEmitter.cpp from origin/main, test as in the diagnosis runResults
| Check | Result |
|---|---|
Merge with main |
Clean |
git diff --check |
Clean |
check_conventions.py |
All conventions checks passed. |
| Full build (merged tree) | Passed |
request_serializer, agc_shader_memory, agc_shader_disk_cache, agc_driver_graphics |
4/4 passed |
agc_driver_image_sample_lod_clamp on main |
Passed (0.39 s) |
agc_driver_image_sample_lod_clamp on the merged tree (image-view lane) |
Failed |
agc_driver_image_sample_lod_clamp_shader_lane on the merged tree |
Failed |
| Both entries, with bias -96 in place of -128 on line 283 | Both passed (0.52 s and 0.39 s); the shader lane printed passed in the shader-clamp lane |
| Validation layer | Loaded in every run (Insert instance layer "VK_LAYER_KHRONOS_validation"). No was not found but was requested by env var VK_INSTANCE_LAYERS. No VUID- lines on main or on the merged tree |
Merged tree, both entries fail on the same case
863: AGC graphics: image_sample_cl with T# MIN_LOD 256 over BASE_LEVEL 1 with S# MAX_LOD 4095, mip filter 1 and LOD bias -128: thread 3 component 0 is 2.000000, expected 1
1/2 Test #863: agc_driver_image_sample_lod_clamp_shader_lane ...***Failed 0.84 sec
1181: AGC graphics: image_sample_cl with T# MIN_LOD 256 over BASE_LEVEL 1 with S# MAX_LOD 4095, mip filter 1 and LOD bias -128: thread 3 component 0 is 2.000000, expected 1
2/2 Test #1181: agc_driver_image_sample_lod_clamp ...............***Failed 0.59 sec
main, same machine
1180: image sample LOD clamp tests passed
1/1 Test #1180: agc_driver_image_sample_lod_clamp ... Passed 0.39 sec
Negative control
On the merged tree, with the tie-free test from the diagnosis run, I restored core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp from origin/main and rebuilt.
- Both entries fail at the prepared-SPIR-V control:
a target with the shader clamp does not declare exactly the image's minimum LOD specialization constant. - With that control call also skipped, the shader lane still fails on the sampled levels:
image_sample_d_cl with T# MIN_LOD 512 over BASE_LEVEL 0 ... thread 0 component 0 is 0.000000, expected 2. The image-view lane passes, as it should.
The test therefore catches a missing shader clamp at run time. I restored every file afterwards.
Findings
Blocking
- The new bias case lands exactly on a mip rounding tie, so the test fails on NVIDIA in both lanes. At
core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp:283,Case{0x100u, 1u, 0xfffu, 1u, -128}runsCode. Itsimage_sample_clandimage_sample_lresults use integer LODs and integer clamps, and the S# bias is -128/256 = -0.5. Every λ is therefore a half-integer. For thread 3, the explicit LOD is 0, the instruction clamp is 1 and the view clamp is 0, so λ = max(0, 1) − 0.5 = 0.5.Level()(line 98) usesceil(λ + 0.5) − 1and expects relative level 0. The Vulkan spec allows⌈d′ + 0.5⌉ − 1(preferred) or⌊d′ + 0.5⌋(alternative) forVK_SAMPLER_MIPMAP_MODE_NEAREST(Image Level(s) Selection inchapters/textures.adoc). The RTX 4070 Ti SUPER takes the alternative and returns level 1 (absolute 2). This breaksagc_driver_image_sample_lod_clamp, which passes onmain, and the new shader-lane entry. Neither failure comes from the driver code: with -96 in place of -128, both entries pass on this GPU.
Fix: use a bias that keeps λ off .5 for every integer LOD and clamp, such as -96 (verified here) or -64. Alternatively, accept either level when λ is within a small epsilon of a half-integer. The fractional MIN_LOD cases look tie-free, but check them for the same pattern.
Non-blocking
- Serialization version 50 also appears in other open PRs. @oneandonlydean and @MarcZX10 already raised this; I have nothing to add.
- I checked the parts of the code that stand out, and they look correct:
- The plan cache key in
preparedBindingPlan(Recompiler.cpp) already includes the T# MIN_LOD bits (dwords[1] & ~0xff) and every S# word, so a cached plan cannot reuse a stale clamp. - Each compile gets its own
variantId, so both target settings can share one process. - The filter-mismatch check compares only bit 0 of each filter field, which matches
toVkFilter(aniso point is NEAREST, aniso bilinear is LINEAR). shaderImageMinLodis computed after bothimageViewMinLodandgraphicsPipelineLibraryare final.
- The plan cache key in
Not verified
- MoltenVK, macOS and the PPSA21564 title results (the title was not launched, as the review rules require).
- A device that lacks
VK_EXT_image_view_min_lodnatively. I reached the shader lane only throughAPS5_NO_IMAGE_VIEW_MIN_LOD=1andAPS5_NO_GPL=1. - Graphics-pipeline paths with the shader clamp (only the compute test exercises them), Windows, and lavapipe. Lavapipe may hit the same tie depending on its rounding.
To get this to a good state
- Move the bias case on line 283 off the rounding tie (for example, -96), or make the expected level tolerant at exact half-integers. Then confirm that both
agc_driver_image_sample_lod_clampentries pass on a non-Apple GPU.
|
Thanks @XairRrR, that's right. The
Re-run on MoltenVK: the shader lane passes. NVIDIA and the image-view lane are not re-run here. AI-assisted: yes |
XairRrR
left a comment
There was a problem hiding this comment.
Re-checked — approved
a2ece0bdac moves the Code bias case off the nearest-mip rounding tie and makes Level() reject any expected LOD that sits on a tie. Both agc_driver_image_sample_lod_clamp entries now pass on an NVIDIA RTX 4070 Ti SUPER, with no validation errors.
What changed since my last review
- One new commit,
a2ece0bdac("test(agc): keep the LOD clamp test off nearest-mip rounding ties"). It changes onlycore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp(+11/−3):- The second
Codebias case is nowCase{0x100u, 1u, 0xfffu, 1u, -96}instead of-128. Level()nowRequires that the expected LOD lies more than 1/512 from a half-integer.Check()computes the expected level only for the results a case reads, so the gradient-only runs (one result) keep their-128bias.
- The second
- Author reply: they agree with the finding and report that the shader lane passes on MoltenVK. They did not re-run NVIDIA or the image-view lane, so I re-ran those here.
- No production code, build file or description change.
mainmoved to3f23b35ccein the meantime, and that range touchesSpirvImageEmitter.cppanddocs/dev/debt/shader.md. The merge is still clean.
What I ran
- Head:
a2ece0bdac63d6e5b89af7c4bd3f0bfa32b9fb0b main:3f23b35cce4029d1ef08cf6b69091d96b87fe462- Merge of head into
main: clean (7757d04229833176b4631d01f6cf239e3519e067). A merge preview against the newermainb433c40f2f, which landed during the run, is also clean. - Machine: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release, Ninja.
git diff --check origin/main...pr-head
python3 tools/check_conventions.py --base 3f23b35cce
cmake --build build -j10
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
ctest --test-dir build -V -R agc_driver_image_sample_lod_clamp
ctest --test-dir build -j4 --output-on-failure -R '^(request_serializer|agc_shader_memory|agc_shader_disk_cache|agc_driver_graphics)$'
# negative control 1: SpirvImageEmitter.cpp from main, rebuild the test target, rerun both entries
# negative control 2: PR code, but the Code bias case set back to -128, rebuild, rerun both entries
git merge-tree --write-tree b433c40f2f pr-head| Check | Result |
|---|---|
Merge with main |
Clean |
git diff --check |
Clean |
check_conventions.py |
All conventions checks passed. |
| Full build (merged tree) | Passed |
agc_driver_image_sample_lod_clamp (image-view lane) |
Passed (0.39 s), image sample LOD clamp tests passed in the image-view lane |
agc_driver_image_sample_lod_clamp_shader_lane |
Passed (0.53 s), image sample LOD clamp tests passed in the shader-clamp lane |
| Validation layer | Insert instance layer "VK_LAYER_KHRONOS_validation" in both runs. No was not found but was requested by env var VK_INSTANCE_LAYERS. 0 VUID- lines |
request_serializer, agc_shader_memory, agc_shader_disk_cache, agc_driver_graphics |
4/4 passed |
I did not rerun main with the validation layer this time. The merged-tree log has no VUID- lines, so the change cannot add any, and my previous review already recorded the main baseline.
Negative control
- With
SpirvImageEmitter.cpprestored frommain(the rest of the PR kept), both entries fail:a target with the shader clamp does not declare exactly the image's minimum LOD specialization constant. - With all PR code in place and only the bias case set back to
-128, both entries fail on the new guard before any GPU comparison:image sample LOD clamp: an expected LOD of 0.500000 sits on a nearest-mip rounding tie, which Vulkan leaves to the implementation. The guard therefore catches the case that failed in my last review.
Restoring every production file from main at once does not work as a control: the test no longer compiles, because PipelineSpecialization::MinLodBase and SpirvTarget::shaderImageMinLod are missing. All files were restored afterwards.
Previous findings
- Blocking 1 (bias case on a rounding tie fails on NVIDIA): Resolved. The case now uses
-96. With it, an explicit λ has a fractional part of .625 and the sampled λ .375, both 1/8 from a tie. Both entries pass here, and the new guard rejects the old value (control 2). - Non-blocking 1 (serialization version 50 shared with other open PRs): Still open, unchanged.
mainis still at 49, so it only needs attention at rebase time. - Non-blocking 2 (the cache-key,
variantId, filter-bit andshaderImageMinLodordering checks): No longer applies. No production code changed.
New findings
Blocking
None.
Non-blocking
ImageSampleLodClamp.cpp:182: the tie margin of 1/512 is finer than Vulkan's minimummipmapPrecisionBitsof 4. An implementation may snap λ to 1/16 steps before it selects a level, so a future case within 1/32 of a tie could still round either way. Every current case is at least 1/8 away, so nothing fails today. Consider a margin of 1/16 so the guard covers every conformant device.
Not verified
- MoltenVK and macOS (author-reported pass of the shader lane on
a2ece0bdac), Windows and lavapipe. - A device without
VK_EXT_image_view_min_lodnatively. I reached the shader lane only through the_shader_laneentry (APS5_NO_IMAGE_VIEW_MIN_LOD=1,APS5_NO_GPL=1). - The PPSA21564 result (the title was not launched, as the review rules require).
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — approved
The latest change corrects the test inputs that landed on implementation-dependent nearest-mip ties. The production change is unchanged from the implementation I reviewed previously, and the author and an independent reviewer report the adjusted shader-lane test passes on this exact head.
What I ran
- Reviewed exact head a2ece0b; the delta since my prior approval is confined to ImageSampleLodClamp.cpp.
- Ran git merge-tree --write-tree against current main 52c09d5 and git diff --check.
- Inspected the updated Level() guard, the -96 bias case, and the changed expected-level selection.
- I did not run the Vulkan test locally.
Results
| Check | Result |
|---|---|
| Current-main merge preview | Clean |
| git diff --check | Pass |
| Exact-head test evidence | Author and XairRrR report the MoltenVK shader-lane test passes; XairRrR also reports both GPU LOD tests pass on NVIDIA without validation errors |
| Hosted checks | Windows, relinker matrix, ASan, conventions, eligibility, labels, and report pass; macOS x86_64 relinker is pending; Linux, register-context, and write-watch jobs are skipped |
Negative control
- Not run on the latest test-only head. The prior review recorded mutation evidence for the unchanged production path; I am not presenting that as a fresh run.
Findings
No blocking issue found in this exact diff. The test now rejects expected LODs near half-integers, moves the Code case to a bias whose checked LODs are not ties, and computes expected levels only for results the case actually checks.
The console behavior and image-view lane remain unverified as recorded in the PR. The serializer-version coordination with other open PRs also remains a rebase-time integration task.
Sources
- PR diff at the approved head
- Author’s exact-head rerun and explanation
- Independent NVIDIA LOD test result
- Image sample LOD clamp test at the reviewed head
Not verified
- I did not run the Vulkan test locally, validate on console hardware, or run Linux/lavapipe or the image-view lane.
- The report about NVIDIA validation is from the independent reviewer; I did not reproduce it.
To get this to a good state
No further change is required for the findings in this review. Rebase and resolve the serializer-version coordination if another competing version-50 PR lands first.
Source correction — review link fixedThe independent NVIDIA result cited in my approval is XairRrR’s exact-head review at the corrected URL below. The review itself approves head a2ece0b. What I checked
Sources |
|
@Gonic0 thanks. The new checks answer the earlier concern: the shader clamp is now refused wherever it couldn't match the view clamp (MAX_LOD below the clamp, table samplers, Two things before this can merge:
@adriadam10 FYI, as the assignee. |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head a2ece0bdac63d6e5b89af7c4bd3f0bfa32b9fb0b after the new integration comment. The reported current-main conflict in core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp reproduces in my merge preview. Please merge current main and retain both test changes. The request-serialization version also needs coordination with the open #10547, #11483, and #10846 work: record the agreed landing order, allocate the next unused version if needed, and update the serializer tests. The earlier shader-lane evidence remains useful, but I cannot keep approval while these integration points are unresolved. I did not run GPU tests locally.
|
Thanks @oneandonlydean and @MarcZX10. Merged current
#12790 ( AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — new head, baseline evidence still needed
The new lavapipe report says the shader-lane test passes on bb9fae9d5d8b0b8024c34840bb4c40e68530eed2, but the required matched run against current main is not documented and Linux CI is skipped.
Please run agc_driver_image_sample_lod_clamp and agc_driver_image_sample_lod_clamp_shader_lane on current main (ddd99fdadb399867211fc1c33fed62e5a4b73d9f) and this PR head on the same lavapipe machine, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Include the exact commands and logs, confirm the requested validation layer was loaded, and compare the logs for new VUID- errors. I have not built or run these GPU tests locally.
|
Linux / AMD RDNA 4 (RADV) paired validation run for current head Host & GPU: CachyOS Linux ( Environment:
AI-assisted hardware test run (Antigravity). |
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (5 IDs in 480 tests)Skipped (44)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
d6b9dd6 to
606b74b
Compare
…age_view_min_lod MoltenVK has no VK_EXT_image_view_min_lod, so since boykopovar#130 the first T# with a MIN_LOD clamp above its base level threw. ASTRO BOT (PPSA21564 01.007.000) hits it on the title screen, about four minutes after boot. MoltenVK does offer shaderResourceMinLod, which maps the SPIR-V MinLod operand to Metal's min_lod_clamp. On a device with shaderResourceMinLod, without the extension and without graphics pipeline libraries, the new target flag shaderImageMinLod moves the clamp into the shader: - DescriptorBindingBuilder writes each direct image's clamp, relative to the view's base level and bounded by its last level and MAX_MIP, as a float specialization constant at MinLodBase + image. - Samples of direct images take it as the MinLod operand, or as an FMax on an explicit LOD when the clamp is above 0, combined with an instruction's _cl clamp. - The image view no longer chains the clamp there; image table entries with a clamp are still rejected, and devices with the extension are unaffected. APS5_NO_IMAGE_VIEW_MIN_LOD forces the shader lane. - It throws when the clamp sits above a paired S#'s MAX_LOD or has no mip filter, follows an explicit LOD or gradient with a nonzero S# LOD bias, pairs with a run-time S# or different min and mag filters, or meets image_get_lod, gathers at a clamp of a level or more, or the emulated depth-compare or 11:11:10 sample. - ValidateShaders accepts CapabilityMinLod when the device enables shaderResourceMinLod. - The flag is written after hostInterpolationFirst as request serialization version 53; older versions read it as false. The gaps, including llvmpipe applying the S# bias after the clamp, are recorded in docs/dev/debt/shader.md. Tested on an M-series Mac (MoltenVK 1.4.2, x86_64 under Rosetta): image_sample_lod_clamp samples a T# with fractional and level clamps over BASE_LEVEL 0 and 1 in both lanes, and fails without the shader clamp or with an absolute one; graphics, shader disk cache, shader memory and request serializer tests pass. PPSA21564 renders the title and reaches the warp sequence after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
606b74b to
fe18496
Compare
Version 53 is taken by boykopovar#12662 (and boykopovar#12980 on top of it) and boykopovar#11551 takes 54, so the heap profile tail moves to 55: it is read at version 55 and later, versions 52 to 54 default it, and the byte-exact fixtures follow.
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 510 tests)Skipped (45)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
XairRrR
left a comment
There was a problem hiding this comment.
Re-checked — approved
The branch is now one squashed commit (fe18496c95) on current main. It moves request serialization to version 53 and the specialization IDs to MinLodBase = 57600. It no longer rejects an S# bias on implicit or gradient samples, recorded as debt, and it skips on devices that have neither lane. On lavapipe the shader lane passes with no validation errors, and the negative control fails.
What changed since my last review
- The PR is rewritten as one commit on
main0278ca9831. Compared with9d6ffe5ed2, these are the changes:- Request serialization moves to version 53, written after
hostInterpolationFirst.mainalready writes 52 and rejects 50, so the version-50 plan no longer applies.RequestSerializerTestscovers the version 53 field both ways and reads 52 as false. It also moves every tail offset by one. - Specialization IDs:
MinLodBaseis 57600. That is directly afterMirrorUnnormalizedBase(57536, which takes up to 32 samplers).MinLodBase+ 64 images stays belowImageComponentBase(65536), so the IDs don't overlap. - S# bias on implicit or gradient samples is accepted again, as in
22cc617ebe/bb9fae9d5dfrom the discussion. Only the bias on an explicit LOD is rejected (DescriptorBindingBuilder.cpp:228). The llvmpipe ordering difference is now recorded indocs/dev/debt/shader.md. The three gradient and implicit bias cases that fail on llvmpipe run only in the image-view lane (ImageSampleLodClamp.cpp:305-307). - Skips: the test exits 77 when the device has neither lane, and the
_shader_laneentry exits 77 when the forced environment doesn't produce the shader lane (ImageSampleLodClamp.cpp:294-301).
- Request serialization moves to version 53, written after
- The description and checklist were updated to match:
Depends on: none, version 53.
What I ran
Head fe18496c95ae0b0f03c6956b8b77649c679314f0, main a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8, merged tree e1be4dac1100e7bdaa6b503e2a400b0356ad6b9f. Debian 13 VM, GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19): no VK_EXT_image_view_min_lod, graphics pipeline libraries on.
git diff --check a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8...fe18496c95ae0b0f03c6956b8b77649c679314f0
python3 tools/check_conventions.py --base a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir build -j4 --test-load 8 --output-on-failure \
-R '^(agc_driver_image_sample_lod_clamp|agc_driver_image_sample_lod_clamp_shader_lane|request_serializer|agc_shader_memory|agc_shader_disk_cache|agc_driver_graphics)$'
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
ctest --test-dir build -V -R '^agc_driver_image_sample_lod_clamp(_shader_lane)?$'
# negative control
git show a4eca2a056:core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp > core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
ninja -C build -j8 -l8 agc_driver_image_sample_lod_clamp_tests
ctest --test-dir build --output-on-failure -R '^agc_driver_image_sample_lod_clamp_shader_lane$'
git show e1be4dac11:core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp > core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
ninja -C build -j8 -l8 agc_driver_image_sample_lod_clamp_tests
git status --porcelain| Check | Result |
|---|---|
git diff --check |
Clean |
check_conventions.py |
All conventions checks passed. |
| Build (script) | Passed; 0 new failures, 0 timeouts among 2137 selected tests. 7 known main failures, and 2 main_sync_renames_* tests that fail on main now pass. |
agc_driver_image_sample_lod_clamp_shader_lane |
Passed (4.5 s): image sample LOD clamp tests passed in the shader-clamp lane |
agc_driver_image_sample_lod_clamp |
Skipped (77): skipped, the device has no VK_EXT_image_view_min_lod, and graphics pipeline libraries keep T# minimum LODs out of the shader. check_skips.py accepts it. |
request_serializer, agc_shader_memory, agc_shader_disk_cache, agc_driver_graphics |
4/4 passed |
| Validation layer | Insert instance layer "VK_LAYER_KHRONOS_validation" in both tests. No was not found but was requested, 0 VUID- lines. |
| Worktree after the control | git status --porcelain empty |
Negative control
I restored SpirvImageEmitter.cpp from main and kept the rest of the merged tree, which leaves the target flag and the specialization values without the shader clamp. agc_driver_image_sample_lod_clamp_shader_lane then fails with a target with the shader clamp does not declare exactly the image's minimum LOD specialization constant. With the merged file restored, it passes again.
Previous findings
- Serialization version 50 shared with #10547, #11483 and #10846: no longer applies.
mainnow writes 52 and rejects 50, and this PR takes 53, the next free number (RequestSerializer.cpp,WriteU32(53u), and theversion >= 53uread).request_serializerandagc_shader_memorypass. - The 1/512 tie margin in
ImageSampleLodClamp.cpp:190is finer than the minimummipmapPrecisionBitsof 4: still open, non-blocking. The code is unchanged. Every current case still sits at least 1/8 away from a tie, so nothing fails today. A 1/16 margin would hold on any conformant device.
New findings
Blocking
None.
Non-blocking
None. The S# bias on implicit and gradient samples (DescriptorBindingBuilder.cpp:228 rejects only explicit LODs) follows the Vulkan order: the sampler bias comes first, then the MinLod and maxLod clamp. llvmpipe differs from that order, and the debt entry records it. On lavapipe the bias cases that depend on this run only in the image-view lane, so CI does not depend on llvmpipe's ordering.
Not verified
- The image-view lane: this lavapipe device has no
VK_EXT_image_view_min_lod, soagc_driver_image_sample_lod_clampskipped. The RADV and NVIDIA reports in the discussion cover that lane. - No validation comparison against
main: the script's baseline has no validation run yet, and the shader-lane test does not exist onmain. The merged-tree run has noVUID-lines. agc_driver_graphicstook 34.7 s here, running in parallel with other tests. This PR only adds one small capability-validation block to that test (Graphics.cpp). The NVIDIA report from the discussion lists the same test at about 30 s, so I don't count the time against this PR, but I did not time it onmain.- MoltenVK, Windows, and the PPSA21564 run are author-reported only.
a5c53e9
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (12, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 513 tests)Skipped (54)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
What
MoltenVK has no
VK_EXT_image_view_min_lod. Since #130, the first T# whose MIN_LOD clamp sits above its base level throws there. ASTRO BOT (PPSA21564 01.007.000) hits this on the title screen. MoltenVK does offershaderResourceMinLod, which turns the SPIR-VMinLodoperand into Metal'smin_lod_clamp.A new target flag,
shaderImageMinLod, moves the clamp into the shader. It is set on devices that haveshaderResourceMinLod, lack the extension, and do not use graphics pipeline libraries.DescriptorBindingBuilderwrites the clamp of each direct image as a float specialization constant atMinLodBase + image. The value is relative to the view's base level and bounded by its last level.MinLodoperand, or as anFMaxon an explicit LOD that is skipped when the clamp is 0. It combines with an instruction's_clclamp.image_get_lod;APS5_NO_IMAGE_VIEW_MIN_LODdisables the extension, so devices that have it can run this lane._shader_laneentry skips when its environment does not produce that lane.ValidateShadersnow acceptsCapabilityMinLodwhen the device enablesshaderResourceMinLod. This also changes devices with the extension: graphics shaders that use an instruction_clclamp threw "unsupported device capability 42" on every device before.shaderImageMinLodwritten afterhostInterpolationFirst.maintook 51 (fix(shader): run tessellation evaluation stages one lane per invocation on devices without subgroups there #13807) and 52 (fix(agc): prefer host interpolation on RADV to avoid the quad seam #10547), and rejects 50, which several open pull requests write.The remaining gaps are recorded in
docs/dev/debt/shader.md:Tested
Machine: macOS 27.2, Apple M5 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363), x86_64 build under Rosetta.
Build tree: upstream
maindoes not build on macOS without the open macOS port PRs (libkernel). Builds and tests therefore ran onmainmerged with those, plus this commit. On this branch alone, the touched recompiler and libSceAgcDriver translation units compile andrequest_serializer_testspasses.agc_driver_image_sample_lod_clamp_tests: passes in the shader lane. It also has a new_shader_laneCTest entry that forces that lane withAPS5_NO_IMAGE_VIEW_MIN_LOD=1andAPS5_NO_GPL=1. It now covers:_d_cl,_cl,_d_cl_o,_land_lz;Each mutation fails it: writing 0, an absolute clamp, a truncated fractional clamp, dropping the MAX_LOD check, or an unconditional
FMaxon an explicit LOD.Other tests:
agc_driver_graphics_testsandagc_shader_disk_cache_testspass on the current head, andagc_shader_memory_testson the first commit.agc_driver_recorder_testsdid not load Vulkan here, and itsminLodTestsskips without the extension anyway.PPSA21564 01.007.000:
guest texture descriptor uses a minimum LOD clamp, which needs VK_EXT_image_view_min_lodat about 250 s.v_permlanex16_b32in a vertex shader.Not verified: a Linux build, lavapipe (no lavapipe on this Mac; the two lavapipe failures from the CI review are what
e006bc1f78addresses), and the image-view lane.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)main, which rejects 50, so this PR takes 53, the next free version. The specialization constants move toMinLodBase = 57600, aftermain'sMirrorUnnormalizedBase.🤖 Generated with Claude Code