fix(shader): keep cube modes for computed texel offsets without maintenance8 #28780
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28780"
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-12-03T15:52:12Z.
What
#23498 drops the texel offset of a sample or gather through a cube T#, as RDNA2 does. On a device without
VK_KHR_maintenance8(for example Mesa 25.2.8's ANV on an Intel HD Graphics 630), its testagc_driver_image_sample_cube_offsetstill fails before it runs:Without native non-constant offsets,
ApplyStaticInterfacemarks an image sampled with a computed offsetfoldTexelOffsetsOnly, andRuntimeImageModeskeeps only the modes an unnormalized S# can sample. That removes the cube modes, the only modes where the offset is dropped. The 2D modes left over cannot take the offset either when the S# cannot fold it into the coordinates (here the same S# serves a gather), so emission fails, although the T# is a cube and the offset would be ignored.This PR:
foldTexelOffsetsOnlyimage;cubeTexelOffsetsOnlywhen its S# cannot fold offsets (FoldsTexelOffsets, decided inShaderInfoCollectoronce the sampler uses are collected), and then keeps only the cube modes. Any other T# is refused when its mode is selected (… takes only cube images, whose texel offsets RDNA2 ignores, without VK_KHR_maintenance8 and shaderImageGatherExtended), instead of the whole shader failing to recompile. An image without a cube mode keeps the modes it had;DescriptorBindingBuilderwhen every image it samples takes a cube mode. Any other normalized S# is refused as before;Nothing changes on a device with
VK_KHR_maintenance8, wherefoldTexelOffsetsOnlyis never set. The Linux CI job's llvmpipe has it, so it never took this path.agc_driver_image_sample_cube_offsetnow also runs withnonConstantImageOffsetsforced off, so every device, CI's included, covers it.Tested
Linux Mint 22.3, kernel 7.0.0,
maincde48b5800, SPIRV-Tools on (as the Linux CI job builds).main's recompiler sources and the new tests:agc_driver_image_sample_cube_offsetfails on the HD 630 in its native pass and on llvmpipe in the pass withoutVK_KHR_maintenance8, both with the emission message above.agc_shader_memoryfails on the new cube case withnormalized guest sampler is used with a texel offset that is not a constant.agc_shader_disk_cachedoes not compile without the new field.agc_shader_memory,agc_shader_disk_cache,agc_driver_image_sample_cube_offset,agc_driver_image_sample_derivatives,agc_driver_image_gather*,agc_driver_emulated_color_compare,agc_driver_prepared_shadersandagc_driver_image_plane_offset_on_line, 3/3 on the GTX 1050 Ti, the HD 630, llvmpipe (Mesa 25.2.8) and lavapipe 26.0.8. The only failure isagc_driver_image_plane_offset_on_lineon the HD 630, which also fails onmainand needsVK_KHR_maintenance8for a normalized S# (#28744 skips it there). With the validation layer from Vulkan SDK 1.4.363.1, one more run on each device logged nothing.--fullrun ofmaincde48b5800: the GTX 1050 Ti fails nothing. On the HD 630,agc_driver_image_sample_cube_offsetnow passes, and every other failure is onemainhas on this machine. On llvmpipe, the failures aremain's, exceptagc_driver_msaa_resolve_publication_order, which failed inmain's run and passed here.conventions,public_headers,tools_): 162/162.check_conventions.py,check_test_registration.py,check_compile.py(7 translation units),check_main_sync.pyanddebt_fold.py --checkare clean.pr_overlap.py --branchcould not compare the 24 pull requests that touch these files and conflict withmain. I read the relevant ones by hand. #27670 adds its scaled-sampler proof right after the normalized-S# branch ofProveUnnormalizedthat this PR changes. It and #20519 also raise the cache format from 98 to 99, as this PR does, so whichever lands second takes the next number. #10867 changes thefoldOffsetcondition inSpirvImageEmitter.cpp, which this PR leaves alone, and #6412 changesApplyStaticInterface's signature, not its offset loop. None of them changes which modes afoldTexelOffsetsOnlyimage keeps.An earlier version also marked images that a gather samples with a computed offset. That broke
agc_driver_image_gather_one_dimensionaland_arrayon the HD 630, which already handle those offsets, so gathers are left as onmain.Update 2026-12-04 (head
9198e98815): rebased ontomainc1601e56d5. #9457 took shader cache format 99 onmainfor its own layout change, so this PR's bump to 99 had become a no-op; it now raises the format to 100. #21776, #14871, #27670 and #20519 also bump it, so whichever lands later takes the next number. #14871 also touches two of this PR's lines: the constant-swizzle condition inTryRuntimeImageModeand theImageResourcefield count. Both sides of each are kept. On this head (SPIRV-Tools on), the 12 focused tests pass 3/3 on the four devices, exceptagc_driver_image_plane_offset_on_lineon the HD 630 (#28744). A validation-layer run logged nothing, and the checkers anddebt_fold.py --checkare clean. The split suite fails the same tests as atd8cd56a766: GTX 1050 Ti none, HD 630 and llvmpipe onlymain's.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:59:38Z.
Review: COMMENTED
The normalized-sampler check considers every image paired with the sampler. A sampler can be shared by an offset cube instruction and an ordinary 2D sample. The 2D pair makes
cubeOnly()false even though that pair does not need computed-offset support. Can the proof distinguish the uses that actually supply an offset?On Linux/lavapipe, the cube-offset, scalar-buffer, shader-memory, and disk-cache cases passed on main at
9d362fb088fcand with this head integrated. The Vulkan runs required the device, disabled the shader cache, and loaded Khronos validation 1.4.369 without missing-layer warnings or VUIDs. These fixtures passed without exercising the mixed cube and 2D sampler case above.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T15:59:45Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
A runtime image with
cubeTexelOffsetsOnlycan still match and accept a non-cube mode, bypassing the intended rejection.What I ran
Reviewed head
178de5eb1c1585f981fa133abcb9b32f9a14f420usingrepo_read.pysearches and targeted source reads. I ran no builds or tests.Results
Negative Control
Not run; no test was changed or executed as a negative control.
Findings
Blocking
RuntimeImageModes, when no cube mode exists but an unnormalized mode does, the fallback retains unnormalized modes (core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp:2661).TryRuntimeImageModethen returns as soon as one of those modes matches, before reaching thecubeTexelOffsetsOnlyrejection at line 2733. A computed offset for a sampler that cannot fold offsets can therefore be accepted with a non-cube image, despite the intended refusal. Enforce the cube-only restriction before accepting a matched mode, while preserving valid cube matches.Sources
Not verified
No build, automated tests, GPU execution, or author-reported test results were independently verified. I read all changed files listed in
manifest.jsonandfiles.json, includingShaderMemory.cppthrough the pinned reader; those lists show no excluded files.To get this to a good state
Reject non-cube runtime descriptors when
cubeTexelOffsetsOnlyis set, before a non-cube mode can be accepted. Then rerun the cube-offset shader memory and execution coverage, including a non-cube descriptor case.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T20:03:10Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
d8cd56a76631d4fed275deb121577051cd503255usingrepo_read.pyto inspect the changed hunks and relevant source context. No tests or builds were run. The test results in the PR description are author-reported and were not reproduced.Results
Negative control
Not run; no tests were run during this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The full contents of large files were not read; review covered all changed hunks and relevant surrounding code. No hardware behavior, CI results, or author-reported test results were independently verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:32:33Z.
Review: COMMENTED
The new 1D sample-plus-gather refusal covers a useful boundary. The earlier mixed-resource case is still worth checking in its own fixture. A computed-offset cube sample and an ordinary 2D sample can share the same S#. Their combination tests the sampler proof separately from the new rejection of invalid descriptor modes.
Source review at
d8cd56a766. The head trial-merges onto700fae9438and its paired checks are queued.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T01:55:00Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and all listed changed files were inspected, and no blocking defect was verified; runtime checks were not run independently.
What I ran
Reviewed head
9198e98815b857a89eb27f3602f90eb1489895ausing the prepared diff, included head files, and the reader output for the addedShaderMemory.cpplines. No tests or build commands were run.Results
Negative control
Could not run a negative control; no test was run independently.
Findings
Blocking
None verified.
Non-blocking
None.
Sources
The main behavior claims are supported by the changed code at the pinned head: ResourceMaterializer.cpp, ShaderInfoCollector.cpp, and DescriptorBindingBuilder.cpp.
Not verified
No tests, builds, or device behavior were independently verified. The author-reported test and checker results in the PR description were not rerun. Read all files listed under
reviewedinfiles.json:ShaderDiskCache.cpp,ShaderMemory.cpp,ImageSampleCubeOffset.cpp,Resources.hpp,DescriptorBindingBuilder.cpp,ResourceMaterializer.cpp,ShaderInfoCollector.cpp,ShaderDiskCache.cpp,ShaderDiskCache.hpp, andfix-shader-cube-offsets-without-maintenance8.md.ShaderMemory.cppwas read through repo_read.py; the other changed files were read from the prepared folder.files.jsonlists no excluded changed files. Additional callers and surrounding source context were not verified because the reader could not complete its logging step in the read-only workspace.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T13:37:41Z.
Review: APPROVED
Verified on Windows 11 (GCC 15.2, Release) on main
484b0368d3, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1and the Khronos validation layer 1.4.363. Every run log shows the loader inserting the layer and none shows "was not found". It ran on an RTX 5080 (621.24) and an AMD Radeon iGPU (26.11.2), together with #28820, #28802, #28646 and #28670.agc_driver_image_sample_cube_offset*,agc_shader_memory*andagc_shader_disk_cache*passed on main and with this change on both GPUs, with noVUID-messages.agc_driver_image_sample_cube_offsetfails on both GPUs in its pass withoutVK_KHR_maintenance8, with "SPIR-V emission failed … opcode=ImageSampleRaw reason=has a texel offset that is not a constant". The tests therefore cover the fix.Not run: Linux.
AI-assisted: yes (Claude Code)
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.