Skip to content

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

Closed
peacocksir wants to merge 1 commit into
boykopovar:mainfrom
peacocksir:test/agc-lod-clamp-lavapipe-bias-order
Closed

peacocksir wants to merge 1 commit into
boykopovar:mainfrom
peacocksir:test/agc-lod-clamp-lavapipe-bias-order

Conversation

@peacocksir

@peacocksir peacocksir commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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:

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.

lavapipe before Mesa 26.1 lowers sampling with gradients to an explicit
LOD and folds an instruction's minimum LOD into it, and llvmpipe adds the
sampler's mipLodBias to that explicit LOD afterwards. That clamps before
the bias, while Vulkan biases first, so the -192 case that separates the
two orders fails there. Mesa 26.1 samples gradients directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: LOD bias test

Layer / File(s) Summary
Gate the negative-bias case
core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp
The test checks Mesa LLVMpipe driver information and skips the -192/256 bias case when the reported version is earlier than 26.1. Otherwise, it runs RunAndCheck.

Possibly related issues

Possibly related PRs

  • boykopovar/AnyPS5#10867: Updates the expected value for the same LOD clamp test family based on clamp-versus-bias ordering.

Suggested reviewers: michongoddijn231849, gonic0

Change: Other

Merge Risk: Minimal · up to be27e

This is a test-only change that skips one LOD-bias case on older software-rendering drivers. It has no production impact, and no merge-blocking risk remains.

Security architecture risk: Minimal · up to be27e

Only one LOD-bias test case is skipped on older Mesa LLVMpipe versions. Production behavior is unchanged, and the other test cases are unaffected.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3d09664-4c30-44dd-a9f2-26ebe03125e0
Commits

Reviewing files that changed from the base of the PR and between f73d791 and be27ea9.

Files selected for processing: 1

  • core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@arcwiser arcwiser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JJenkx

JJenkx commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Windows / AMD at this head (be27ea977602): agc_driver_image_sample_lod_clamp and agc_driver_image_sample_lod_clamp_shader_lane pass, 3/3 runs.

Setup:

  • Windows 11 22621, Ryzen 9 5950X, Radeon RX 6700 XT (AMD driver 26.11.2), GCC 15.2 UCRT r7, Release, ANYPS5_REQUIRE_VULKAN=1.
  • No validation layer loaded.
  • The exact PR head was built (not merged into main).
  • 3 runs through the shared FIFO.

The new skip only applies when DriverId() is VK_DRIVER_ID_MESA_LLVMPIPE before Mesa 26.1. The AMD proprietary driver isn't lavapipe, so the -192 LOD-bias case still runs here and passes.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10867 core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp L398-400
PR 24153 core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp L399
PR 28240 core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp L399-401

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.

Pull request Shared files not compared
PR 16953 core/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cpp

@Rug-Ket

Rug-Ket commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Tested on an Intel Arc B580 (Linux, Mesa ANV 26.2.5, not lavapipe). agc_driver_image_sample_lod_clamp_shader_lane fails here too, with the same case and value as on 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

It passed here on main b5ed908ae3, which is before #23992 (bias -96), and fails on main 1f27e2abfa. So on Mesa 26.2.5 ANV returns the same level as lavapipe before 26.1 (clamp, then bias), and the check in this PR, lavapipe before 26.1, does not cover it. I have not looked into why ANV does this, or bisected between the two commits.

Setup: Intel Arc B580 (BMG-G21, 8086:e20b, xe kernel driver), Mesa ANV 26.2.5-arch1.1 (Vulkan 1.4.354), EndeavourOS, kernel 7.2.11-zen1, GCC 16.2.1, Release, BUILD_TESTING=ON, validation layer 1.4.363. This PR's head merged with git merge --no-ff onto main 1f27e2abfa, compared with a full sweep of that same main on the same machine. ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ANYPS5_GPU=B580; "with validation" adds VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. Targeted test: ctest --test-dir build -R "^<test>$" -V -j 1, 10 times in each mode. Full sweep: ctest --test-dir build -V -j 8 with validation (7342 tests); in every sweep all 1977 Selected GPU lines name the B580, the loader logs Insert instance layer "VK_LAYER_KHRONOS_validation" 2177 times, and was not found but was requested by env var VK_INSTANCE_LAYERS never appears.

main 1f27e2abfa with #27777 (head be27ea9776)
agc_driver_image_sample_lod_clamp_shader_lane, 10x with validation 0/10 (message above) 0/10 (same)
same, 10x without validation 0/10 0/10
agc_driver_image_sample_lod_clamp, 10x in each mode 0/20 (image_sample_d_cl with T# MIN_LOD 512 over BASE_LEVEL 0 with S# MAX_LOD 4095, mip filter 1 and LOD bias 0: thread 3 component 0 is 2.000000, expected 3, #27366) 0/20 (same)
VUID- lines in those runs 0 0

Full sweep with validation: the same 9 failures as main, the same 75 skips, 0 VUID- and the same 89 Validation Warning lines in both.

AI-assisted: yes (Claude Code)

@peacocksir

Copy link
Copy Markdown
Contributor Author

Thanks for running this. You're right: this check only covers lavapipe before Mesa 26.1, so on ANV the -192 case still fails, the same as on main in your table.

It looks like the same Mesa lowering. In Mesa 26.2.5, replace_gradient_with_lod in nir_lower_tex.c still turns a gradient sample into an explicit LOD and folds the MinLod operand into it with nir_fmax (nir_lower_tex.c). If the sampler then adds its LOD bias to that explicit LOD, as llvmpipe did, the result is clamp-then-bias. Intel's lower_txd_cb in brw_nir.c asks for that lowering in several cases: arrayed and 3D images on Xe-HP and newer (verx10 >= 125, which includes the B580), a bindless sampler handle, or a sampler offset that isn't a constant below 16, together with a MinLod, cube maps, and some shadow cases (brw_nir.c). I haven't checked which of those this test's sample hits, and I have no Intel GPU to try it on. Your clamp-then-bias value fits that path, but that's an inference from the source, not a measurement.

I'd rather not widen the skip to ANV in this PR. lavapipe is a CI device. On ANV this is a wrong mip level that real use would get, so a skip there would hide it rather than work around a test-only quirk. Fixing it would mean changing how the recompiler hands the S# bias and the clamp to the driver on such devices, which is a production change I can't test here. I can record it in docs/dev/debt/ with your measurement, in this PR or separately, whichever the maintainers prefer.

@peacocksir

Copy link
Copy Markdown
Contributor Author

Closing this: #24153 (merged) wraps the same -192 line and skips it when its TextureLodFidelity probe finds the driver remaps the gradient LOD. On lavapipe (Mesa 25.2.8, validation layer 1.4.335, no VUID-), main 1841c37422 now passes agc_driver_image_sample_lod_clamp_shader_lane in 3 of 3 runs, with skipped the LOD bias -192 case, which needs the fractional LOD 0.25 (...). So this PR no longer adds anything there, and it now conflicts with that change.

I haven't checked whether that probe also skips the case on Rug-Ket's B580 run, which was on 1f27e2abfa, before #24153 merged. Thanks to everyone who reviewed and tested this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants