fix(shader): size an explicit-LOD gather's level from the base level's extent #24100
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24100"
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 GiannisG1 on 2026-11-20T06:12:14Z.
What
agc_driver_image_gather_lodfails inmain's Linux job (run 44639208734) withclamp to edge, point: thread 1 (LOD 1.000000, level 1) component 0 is 0, expected 113. The runner's device isllvmpipe (LLVM 20.1.2, 256 bits), the string Ubuntu 24.04's Mesa25.2.8-0ubuntu0.24.04.4reports, and the test fails the same way on it here.The
image_gather4_lemulation (EmitTwoDimensionalGatherLod, #12790) takes each lane's level size fromOpImageQuerySizeLodat that lane's level. llvmpipe before Mesa 26.0 answers a size query with the first lane's LOD for the whole vector (lp_build_size_query_soain 25.2.8, L4354-L4356:/* FIXME: this needs to honor per-element lod */, thenLLVMBuildExtractElement(..., params->explicit_lod, 0); 26.0.8 usesparams->explicit_lodper element, L4352). Lanes at another level then scale their coordinates by that level's extent. In the test's first case (clamp to edge, point), all 32 lanes give exactly what that predicts for groups of 8 lanes (llvmpipe's vector width here): each lane gathers from its own level with the extent of its group's first lane's level, so only lanes whose level differs from that lane's are wrong.The query now uses LOD 0, and each lane's extent is
max(1, extent >> level). That is the level size Vulkan defines ("Image mip level sizing"), also for a view whose base level is not 0, so the result does not change on a driver that honours the per-lane LOD. The fallback to the T# extent when the query returns 0 is unchanged.#23666 changes the same
OpImageQuerySizeLodline (it adds the layer count for 2D arrays). Whichever merges second needs a one-line rebase; I can rebase this one onto #23666.Tested
Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release, under Xvfb, head on
maind50640e264. lavapipe from Mesa 26.0.8 was built from the release tarball and selected withVK_DRIVER_FILES.mainagc_driver_image_gather_lodfails 3/3 with the job's messageVK_LOADER_DEBUG=layer, onagc_driver_image_gather_lod,_one_dimensional,_one_dimensional_arrayand_volume,mainand this PR, all four devices: the loader inserts the layer in every test, noVUID-,SYNC-HAZARD-orUNASSIGNED-message on either side.mainfails onlyagc_driver_image_gather_lodon llvmpipe 25.2.8; this PR passes all four tests on all four devices.tools/suite.py: every test once, GPU tests on the GTX 1050 Ti, the HD 630 and llvmpipe) on this PR, compared with the same suite of another branch on the same base (#24088, a libSceIcu change) on the same machine: the only difference isagc_driver_image_gather_lod, which fails on llvmpipe there and passes here. Both: GTX 1050 Ti 6338 run, 0 failed; HD 630 1457 GPU tests, the same 10 failures (the 9 ofmain0626a8334f's own run andagc_driver_frame_replay_rewind_copy, intermittent, #22028); llvmpipeagc_driver_image_table_packed_guards,agc_driver_scattered_runsandagc_driver_sparse_dma_buf_straddle(the last from #23272, which this base still has).check_conventions.py,check_test_registration.py,check_main_sync.py(merges cleanly with currentmain),check_compile.pyandgit diff --checkare clean.pr_overlap.py --branch: #23666, as above. Of the 22 pull requests it could not compare (they conflict withmain), none changes a line this PR changes; the two whose diffs share a line text with it (#6280, #7085) do so inDecodeSrgbTexel, another function.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 Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:23:33Z.
Review: COMMENTED
Reviewed — comments
The change addresses the stated varying-LOD query issue, but the partial view-level sizing logic needs clarification before a formal approval is justified.
What I ran
Reviewed head
efee26e8a303ce1647b4709d057847d520cf942f. I readdescription.md,commits.md,manifest.json,diff.patch, and the changed function inSpirvImageEmitter.cpp(lines 1050–1130) throughrepo_read.py. No tests or build commands were run.Results
Findings
Blocking
None verified.
Non-blocking
OpImageQuerySizeLod(image, 0)reports the extent corresponding to the view’s base level in this backend, and that its behavior is consistent for the image types accepted by this function. The changed calculation is atcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1091andcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1101.Not verified
The full changed file is listed as included, but only the changed function and its immediate context were read. No tests, build, Vulkan validation, or hardware behavior were independently verified. The author’s reported test results were not reproduced.
To get this to a good state
Nothing is required. Please clarify the view-base-level extent assumption as an optional point.