test(agc): leave the LOD bias -192 case out on lavapipe before Mesa 26.1 #27777

Closed
peacocksir wants to merge 1 commit from upstream-pr/27777 into main
peacocksir commented 2026-11-27 10:26:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by peacocksir on 2026-11-27T10:26:23Z.


What

Since #23992 changed the clamped LOD case's bias from -96 to -192, agc_driver_image_sample_lod_clamp_shader_lane fails on Mesa lavapipe 25.2.8:

AGC graphics: image_sample_d_cl with T# MIN_LOD 256 over BASE_LEVEL 1 with S# MAX_LOD 4095, mip filter 1 and LOD bias -192: thread 5 component 0 is 1.000000, expected 2

As #23992 says, -192 also separates clamp-then-bias from bias-then-clamp. Vulkan biases first: λ' = λbase + mipLodBias, then λ is clamped to max(minLod, the instruction's MinLod). Thread 5 has λbase -1.25 and an instruction clamp of 1, so Vulkan gives max(-2.0, 1) = 1, which is level 2 over BASE_LEVEL 1. lavapipe returns level 1, which is max(-1.25, 1) - 0.75 = 0.25.

lavapipe before Mesa 26.1 clamps first:

  • lvp_pipeline.c runs nir_lower_tex with .lower_txd = true (mesa-26.0.8, line 428). replace_gradient_with_lod in nir_lower_tex.c then turns the gradient sample into an explicit LOD and folds the MinLod operand into it with nir_fmax.
  • llvmpipe adds the sampler's mipLodBias to that explicit LOD afterwards, in lp_build_lod_selector ("sampler_lod_bias", mesa-25.2.8 lp_bld_sample.c, line 979).

Mesa 56997723 ("llvmpipe: pass explicit derivatives to sampling codegen") set .lower_txd = false, first released in 26.1.0. From then on llvmpipe adds the bias before the MinLod clamp (mesa-26.1.0 lp_bld_sample.c, lines 1252 and 1283). Mesa 25.2.8 and 26.0.8 both still lower.

The test now leaves out only the -192 case when the device is llvmpipe (VK_DRIVER_ID_MESA_LLVMPIPE) and its driver info names Mesa before 26.1. It prints skipped, the device does not apply the S# LOD bias before an instruction's LOD clamp ... with the driver info. Every other case runs as before. On any other device, or on lavapipe from 26.1 on, or if the version can't be read, the test runs exactly what main runs. No production code changes.

On old lavapipe this also leaves out the case's image_sample_l and image_sample_lz results, which don't use a clamp and pass there. Check checks one case's results as a whole, so keeping them would mean restructuring it, which I didn't want to do for a driver bug.

Tested

Ubuntu 24.04, kernel 6.8, GCC 13.3.0, Ninja, Release, BUILD_TESTING=ON. Head be27ea9776 on main 580d1d3e12. GPU: Mesa lavapipe 25.2.8 (llvmpipe (LLVM 20.1.2, 256 bits), driver info Mesa 25.2.8-0ubuntu0.24.04.2 (LLVM 20.1.2)), /dev/udmabuf available. Validation layer built from source, 1.4.335.

Bisect: a first-parent bisect of 00b15fcbb0..afdd33906b on lavapipe, building only agc_driver_image_sample_lod_clamp_tests and running --shader-lane with the test's environment, found #23992's merge a8654598c5 as the first bad commit. Its parent 2bbf80e857 passes.

Cause: I printed the level each of the 32 threads sampled for each of the case's 6 instructions on main. All 192 results match clamp-then-bias. Only 115 match Vulkan's bias-then-clamp, and the 77 that don't are all image_sample_d_cl, image_sample_cl or image_sample_d_cl_o lanes with a clamp above λbase + bias. Every bias I tried from -160 to -256 fails on thread 5 the same way, and -96 passes, as on main before #23992. That local print and the bias change are not part of this PR.

Focused runs, main's test file and this branch's in the same build tree, 3 runs each, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_image_sample_lod_clamp' -V:

agc_driver_image_sample_lod_clamp_shader_lane agc_driver_image_sample_lod_clamp
main Failed 3/3, the message above Skipped 3/3 (no VK_EXT_image_view_min_lod)
this PR Passed 3/3: the skip line, then image sample LOD clamp tests passed in the shader-clamp lane Skipped 3/3, same

Every log shows Insert instance layer "VK_LAYER_KHRONOS_validation", none shows was not found but was requested by env var VK_INSTANCE_LAYERS, and none contains VUID-.

Full ctest --test-dir build --output-on-failure -j6 on this branch: 7124/7133 pass, and both LOD clamp tests are as in the table. The 9 failures are in other test executables. This PR's only changed file is compiled into agc_driver_image_sample_lod_clamp_tests alone (build.ninja), so those executables are the same as main's:

  • agc_driver_gcn_multisample_color_fill: new on main since #25802; lavapipe has no target with its sample count (the device cannot render color with the target's sample count). Not addressed here.
  • agc_driver_image_d16_load: since #22750, a 16_FLOAT signaling NaN comes back quieted on lavapipe. Not addressed here.
  • agc_driver_image_filter_mode_three: lavapipe has no min/max filtering of R8G8B8A8_UNORM; #27671 fixes the test.
  • agc_driver_scattered_runs: Mesa before 26 (#21649).
  • guest_json_copy_failure, guest_json_float_failure (SIGSEGV, 3/3 when rerun alone), guest_libressl3_object_header (timeout), nkwebkit_wtf (abort) and tools_headers_manifest: host-side tests unrelated to AGC.

main's Linux CI job has not finished a run since #23992 merged. Its 51 push runs since then are cancelled (49) or queued (2).

python3 tools/check_conventions.py --base origin/main: all checks passed.

Not tested: any real GPU, Mesa lavapipe 26.1 or later, or any console. I relied on the Mesa sources linked above for 26.1, where the case runs as on main. On any device other than llvmpipe, the new branch is never taken.

Open #10867, #16953 and #24153 change the same lines of main() in this file, and all of them are older than this PR. None of them changes what lavapipe does with the -192 case. Whichever merges first, I'll rebase this one onto it.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Mesa lavapipe 25.2.8 (Linux)
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated graphics validation for the affected LOD-bias case. It is now skipped on Mesa LLVMpipe versions earlier than 26.1, while remaining enabled on other drivers and on Mesa LLVMpipe 26.1 or later. This keeps test results aligned with the behavior observed across supported driver versions.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5525047353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27777). Originally posted by [peacocksir](https://github.com/peacocksir) on 2026-11-27T10:26:23Z. --- ### What Since #23992 changed the clamped LOD case's bias from -96 to -192, `agc_driver_image_sample_lod_clamp_shader_lane` fails on Mesa lavapipe 25.2.8: ``` AGC graphics: image_sample_d_cl with T# MIN_LOD 256 over BASE_LEVEL 1 with S# MAX_LOD 4095, mip filter 1 and LOD bias -192: thread 5 component 0 is 1.000000, expected 2 ``` As #23992 says, -192 also separates clamp-then-bias from bias-then-clamp. Vulkan biases first: λ' = λbase + mipLodBias, then λ is clamped to max(minLod, the instruction's MinLod). Thread 5 has λbase -1.25 and an instruction clamp of 1, so Vulkan gives max(-2.0, 1) = 1, which is level 2 over BASE_LEVEL 1. lavapipe returns level 1, which is max(-1.25, 1) - 0.75 = 0.25. lavapipe before Mesa 26.1 clamps first: - `lvp_pipeline.c` runs `nir_lower_tex` with `.lower_txd = true` ([mesa-26.0.8, line 428](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-26.0.8/src/gallium/frontends/lavapipe/lvp_pipeline.c#L428)). `replace_gradient_with_lod` in `nir_lower_tex.c` then turns the gradient sample into an explicit LOD and folds the MinLod operand into it with `nir_fmax`. - llvmpipe adds the sampler's mipLodBias to that explicit LOD afterwards, in `lp_build_lod_selector` (`"sampler_lod_bias"`, [mesa-25.2.8 lp_bld_sample.c, line 979](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-25.2.8/src/gallium/auxiliary/gallivm/lp_bld_sample.c#L979)). Mesa [56997723](https://gitlab.freedesktop.org/mesa/mesa/-/commit/569977238675) ("llvmpipe: pass explicit derivatives to sampling codegen") set `.lower_txd = false`, first released in 26.1.0. From then on llvmpipe adds the bias before the MinLod clamp ([mesa-26.1.0 lp_bld_sample.c, lines 1252 and 1283](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-26.1.0/src/gallium/auxiliary/gallivm/lp_bld_sample.c#L1252)). Mesa 25.2.8 and 26.0.8 both still lower. The test now leaves out only the -192 case when the device is llvmpipe (`VK_DRIVER_ID_MESA_LLVMPIPE`) and its driver info names Mesa before 26.1. It prints `skipped, the device does not apply the S# LOD bias before an instruction's LOD clamp ...` with the driver info. Every other case runs as before. On any other device, or on lavapipe from 26.1 on, or if the version can't be read, the test runs exactly what `main` runs. No production code changes. On old lavapipe this also leaves out the case's `image_sample_l` and `image_sample_lz` results, which don't use a clamp and pass there. `Check` checks one case's results as a whole, so keeping them would mean restructuring it, which I didn't want to do for a driver bug. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04, kernel 6.8, GCC 13.3.0, Ninja, Release, `BUILD_TESTING=ON`. Head `be27ea9776` on `main` `580d1d3e12`. GPU: Mesa lavapipe 25.2.8 (`llvmpipe (LLVM 20.1.2, 256 bits)`, driver info `Mesa 25.2.8-0ubuntu0.24.04.2 (LLVM 20.1.2)`), `/dev/udmabuf` available. Validation layer built from source, 1.4.335. Bisect: a first-parent bisect of `00b15fcbb0..afdd33906b` on lavapipe, building only `agc_driver_image_sample_lod_clamp_tests` and running `--shader-lane` with the test's environment, found #23992's merge `a8654598c5` as the first bad commit. Its parent `2bbf80e857` passes. Cause: I printed the level each of the 32 threads sampled for each of the case's 6 instructions on `main`. All 192 results match clamp-then-bias. Only 115 match Vulkan's bias-then-clamp, and the 77 that don't are all `image_sample_d_cl`, `image_sample_cl` or `image_sample_d_cl_o` lanes with a clamp above λbase + bias. Every bias I tried from -160 to -256 fails on thread 5 the same way, and -96 passes, as on `main` before #23992. That local print and the bias change are not part of this PR. Focused runs, `main`'s test file and this branch's in the same build tree, 3 runs each, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^agc_driver_image_sample_lod_clamp' -V`: | | `agc_driver_image_sample_lod_clamp_shader_lane` | `agc_driver_image_sample_lod_clamp` | |---|---|---| | `main` | Failed 3/3, the message above | Skipped 3/3 (no `VK_EXT_image_view_min_lod`) | | this PR | Passed 3/3: the skip line, then `image sample LOD clamp tests passed in the shader-clamp lane` | Skipped 3/3, same | Every log shows `Insert instance layer "VK_LAYER_KHRONOS_validation"`, none shows `was not found but was requested by env var VK_INSTANCE_LAYERS`, and none contains `VUID-`. Full `ctest --test-dir build --output-on-failure -j6` on this branch: 7124/7133 pass, and both LOD clamp tests are as in the table. The 9 failures are in other test executables. This PR's only changed file is compiled into `agc_driver_image_sample_lod_clamp_tests` alone (`build.ninja`), so those executables are the same as `main`'s: - `agc_driver_gcn_multisample_color_fill`: new on `main` since #25802; lavapipe has no target with its sample count (`the device cannot render color with the target's sample count`). Not addressed here. - `agc_driver_image_d16_load`: since #22750, a 16_FLOAT signaling NaN comes back quieted on lavapipe. Not addressed here. - `agc_driver_image_filter_mode_three`: lavapipe has no min/max filtering of `R8G8B8A8_UNORM`; #27671 fixes the test. - `agc_driver_scattered_runs`: Mesa before 26 (#21649). - `guest_json_copy_failure`, `guest_json_float_failure` (SIGSEGV, 3/3 when rerun alone), `guest_libressl3_object_header` (timeout), `nkwebkit_wtf` (abort) and `tools_headers_manifest`: host-side tests unrelated to AGC. `main`'s Linux CI job has not finished a run since #23992 merged. Its 51 push runs since then are cancelled (49) or queued (2). `python3 tools/check_conventions.py --base origin/main`: all checks passed. Not tested: any real GPU, Mesa lavapipe 26.1 or later, or any console. I relied on the Mesa sources linked above for 26.1, where the case runs as on `main`. On any device other than llvmpipe, the new branch is never taken. Open #10867, #16953 and #24153 change the same lines of `main()` in this file, and all of them are older than this PR. None of them changes what lavapipe does with the -192 case. Whichever merges first, I'll rebase this one onto it. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Mesa lavapipe 25.2.8 (Linux) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Updated graphics validation for the affected LOD-bias case. It is now skipped on Mesa LLVMpipe versions earlier than 26.1, while remaining enabled on other drivers and on Mesa LLVMpipe 26.1 or later. This keeps test results aligned with the behavior observed across supported driver versions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
arcwiser commented 2026-11-27 10:39:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-11-27T10:39:06Z.

Review: APPROVED


Reviewed the complete one-file diff and the surrounding test flow at be27ea9776. The exception is limited to VK_DRIVER_ID_MESA_LLVMPIPE, parses only an identifiable Mesa major.minor, skips only versions before 26.1, and fails open (runs the original case) for other drivers or unparseable/future versions. I also checked the related NVIDIA report #23232; its failure was traced to the NVIDIA texture-quality override and is not hidden by this gate. Mesa 26.1's release notes list the cited "llvmpipe: pass explicit derivatives to sampling codegen" change.

Local validation: git diff --check and python tools/check_conventions.py --base f73d791b3df4dcaa773297a93f5ae2c062ee95a3 passed. I did not run the Vulkan test because this checkout has no configured build or suitable lavapipe test environment. The author's old-lavapipe focused and full-suite evidence covers the affected path, and the PR explicitly documents that limitation. I found no blocking issue.

AI-assisted review: yes (Codex); I independently inspected the diff, surrounding code, linked issue, overlapping PR diffs, and validation results.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6086860659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27777#pullrequestreview-6086860659). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-11-27T10:39:06Z. **Review:** APPROVED --- Reviewed the complete one-file diff and the surrounding test flow at `be27ea9776`. The exception is limited to `VK_DRIVER_ID_MESA_LLVMPIPE`, parses only an identifiable `Mesa major.minor`, skips only versions before 26.1, and fails open (runs the original case) for other drivers or unparseable/future versions. I also checked the related NVIDIA report #23232; its failure was traced to the NVIDIA texture-quality override and is not hidden by this gate. Mesa 26.1's release notes list the cited "llvmpipe: pass explicit derivatives to sampling codegen" change. Local validation: `git diff --check` and `python tools/check_conventions.py --base f73d791b3df4dcaa773297a93f5ae2c062ee95a3` passed. I did not run the Vulkan test because this checkout has no configured build or suitable lavapipe test environment. The author's old-lavapipe focused and full-suite evidence covers the affected path, and the PR explicitly documents that limitation. I found no blocking issue. AI-assisted review: yes (Codex); I independently inspected the diff, surrounding code, linked issue, overlapping PR diffs, and validation results.
MarcZX10 commented 2026-11-27 10:52:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T10:52:43Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head be27ea9776021f63b42107c1067c666d941eaf69. No commands or tests were run. Read description.md, commits.md, manifest.json, diff.patch, and the changed file core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp at lines 360–432, plus targeted context from VulkanDevice.cpp and VulkanTestDevice.hpp. The sole changed file is listed as reviewed in manifest.json; no changed files were excluded.

Results

Check Result Note
Diff and targeted source review passed One changed test file
Tests not run Author-reported runs were not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests, CI, build, real GPU behavior, Mesa lavapipe 26.1 or later, and console behavior were not verified. The author's reported test results and Mesa source analysis were not independently checked. files.json was not available through the review reader, so I relied on manifest.json for the changed-file inventory.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6087041081 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27777#pullrequestreview-6087041081). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T10:52:43Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `be27ea9776021f63b42107c1067c666d941eaf69`. No commands or tests were run. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the changed file `core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp` at lines 360–432, plus targeted context from `VulkanDevice.cpp` and `VulkanTestDevice.hpp`. The sole changed file is listed as reviewed in `manifest.json`; no changed files were excluded. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | One changed test file | | Tests | not run | Author-reported runs were not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests, CI, build, real GPU behavior, Mesa lavapipe 26.1 or later, and console behavior were not verified. The author's reported test results and Mesa source analysis were not independently checked. `files.json` was not available through the review reader, so I relied on `manifest.json` for the changed-file inventory. ## To get this to a good state Nothing is required.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27777
No description provided.