Skip to content

fix(shader): fold texel offsets into base-level unnormalized samples - #7240

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
gjonn:fix/shader-unnormalized-offset-base-level
Oct 18, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
gjonn:fix/shader-unnormalized-offset-base-level

Conversation

@gjonn

@gjonn gjonn commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

What

An implicit-LOD or gradient sample with a texel offset through an unnormalized S# was refused at bind time with unnormalized guest sampler is used by an implicit-LOD sample, which is not implemented.

On PPSA01317 a pixel shader image_sample_o (implicit LOD with an offset) through an unnormalized point S# hits this on boot and the title aborts with that message; with this change it gets past it on main.

The base-level path (SamplesBaseLevelIfUnnormalized) already samples such a sampler through OpImageSampleExplicitLod with LOD 0, which Vulkan allows for unnormalized samplers, but it did not accept samplers whose uses include offsets because that branch dropped the offset. The branch now adds the offset to the coordinates (FoldedOffsetCoord, as the explicit-LOD offset fold does), and SamplerUseOffset is accepted by SamplesBaseLevelIfUnnormalized. A normalized S# keeps the implicit-LOD sample with its offset operand.

The new cases in verifyUnnormalizedSamplers (agc_shader_memory) recompile a pixel image_sample_o through an unnormalized S#, check the offset is folded into the base-level coordinates, and check that the normalized variant stays an implicit-LOD sample with an offset operand. On main the test fails with the bind-time refusal above; it passes with the change.

Tested

Windows 11, MinGW GCC Release build with BUILD_TESTING=ON.

  • agc_shader_memory fails on main (with only the test applied) with unnormalized guest sampler is used by an implicit-LOD sample and passes with the change.
  • Every ctest registered on agc_shader_memory_tests, agc_shader_device_profile_tests and agc_driver_graphics_tests (22 tests), plus agc_driver_image_sample_unnormalized (Vulkan execution) and agc_shader_disk_cache, pass.
  • python tools/check_conventions.py --base origin/main passes; tools/check_test_registration.py reports no unregistered tests.
  • PPSA01317: the boot abort no longer occurs and the title continues past 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
  • 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: PPSA01317 Gran Turismo 7 (PPSA01317) #4697
  • GPUs tested: NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92, Windows 11
  • AI-assisted: yes

An implicit-LOD or gradient sample with a texel offset through an
unnormalized S# was refused at bind time with "unnormalized guest sampler
is used by an implicit-LOD sample". PPSA01317 aborts on boot on such a
pixel image_sample_o. The base-level path already samples these through
OpImageSampleExplicitLod with LOD 0, which Vulkan allows for unnormalized
samplers, but it dropped the offset. It now adds the offset to the
coordinates in that branch, as the explicit-LOD offset fold does, so a
sampler whose uses also include offsets takes the base-level path. A
normalized S# keeps the offset operand.

AI-assisted: yes
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

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 907 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 1341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5021 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5958 core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6094 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6232 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6503 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6645 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6674 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 6941 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6946 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6947 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6989 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6995 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7002 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7223 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7332 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp
PR 7395 core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 17, 2026
@akkadbakkad89

Copy link
Copy Markdown
Contributor

Independent hardware run, head 7c19c66def, Windows 11, MinGW (WinLibs GCC 15.2.0), Release: agc_shader_memory, agc_shader_device_profile, agc_shader_disk_cache, agc_driver_graphics, agc_driver_image_sample_unnormalized all pass on NVIDIA RTX 3070 (driver 617.42); the two driver tests also pass on Intel UHD 630 (ANYPS5_GPU=UHD, igvk64).

alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
@frankea

frankea commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

RTX 4090 data point on PPSA01317, continuing the chain from my #7243 and #7238 runs tonight, where the title stopped on unnormalized guest sampler is used by an implicit-LOD sample. Short version: with this PR on top of that stack the bind-time refusal is gone on this GPU too, 3 of 3 runs, the title registers about 390 more shaders and goes into its cube map pass, and the next stop is the layered-draw refusal that #7254 describes for exactly this pass.

Setup. Gran Turismo 7 PPSA01317 01.000.001 (base package), Windows 11 (26200), RTX 4090 (NVIDIA 616.92), AMD Ryzen 7 5800X, MinGW-w64 GCC 15.2.0 r7 (UCRT), Release libs target only (no tests built). app.exe is the relink from main 31cbb55 (--windows --registry --module-dir .); only libs/ is swapped between runs. Tree: main e1041f6 + #7137 2aa6bfc + #7207 ec28b6b + #7175 555b7e8 + #5958 87a9b8d + #7243 da158d6 + #7238 4aaf276 (1be778eea, the set that stopped on the sampler refusal) + #7240 7c19c66 cherry-picked (clean, ac5e28d17; SpirvImageEmitter.cpp and the Resources.hpp dependents rebuilt). The libSceSsl.prx is the one from #7319 (1f26755), because the title calls sceSslConnect after its save-data mount and the stock export throws there. Current main is not usable as the base for this title since #7323 (sceHmd2ReprojectionQueryBufferSizeAlign not implemented 5 s in, see the #7243 comment). No controller, no input, nobody at the keyboard; one-shot interactive task per run, 600 s cap, box otherwise idle.

Result. Run 1 recompiled the shader cache (1,785 shaders, 793 MiB; the recompiler source changed), runs 2 and 3 were warm. All three get past the sampler refusal: splash, then the black loading screen with the GT spinner (title-bar counter 48 to 60 FPS, 789 frames by the last capture of run 3), save data mounted, three sceNetResolverStartNtoa -> host DNS lookup failed, then 388 further shaders registered (all from the cache in the warm runs), and then, identically every time:

[gpu] driver failure: AGC graphics: layered draws into a color view of several array slices are unsupported
[videoout] presentation failed: AGC graphics: layered draws into a color view of several array slices are unsupported
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: layered draws into a color view of several array slices are unsupported
FATAL: abort() (SIGABRT) on thread 2332

That is the State.cpp refusal of a layered draw into a CB_COLOR_VIEW of several slices, which #7254 lifts for the 512x512 cube map pass of this title (and #7256 then handles its depth side), so #7254 + #7256 are the next two to stack here. Nothing else new appears in between: no partial writes, no color export format refusal, no device loss, and the stall I saw once on the first #7238 run did not recur (three runs, one of them cold).

run shader cache exit after stop
stack without #7240 (earlier tonight, 3 runs) warm / cold 33 to 37 s shader 0x1258d04700 stage 5: ... unnormalized guest sampler is used by an implicit-LOD sample
1 cold (1,785 misses) 40 s layered draws into a color view of several array slices are unsupported
2 warm 34 s same
3 warm 34 s same
stderr of run 3 (warm, box idle) from the second 10 s summary to the abort, the 388 per-shader ShaderRegistry lines removed
[log] 10.3 s: 190 lines (18 stdout, 172 stderr), 26.6 KiB written, 0 repeats coalesced; callers spent 0.38 ms queueing and formatting (0.004% of one thread), logger thread 93.07 ms, queue peak 4.7 KiB
[SAVEDATA:native] mount3 user=268435456 dir=DRFILEIV mode=0x1 blocks=673 -> 0x809f0008 point= status=0
[SAVEDATA:native] getMemory2 user=268435456 slot=0 -> 0x00000000
[shader-disk-cache] (10 s): 118 hits, 0 misses, 0 writes (0.0 MiB), 0 load failures, 0 write failures; resource plans: 112 hits, 0 misses, 0 writes, 0 load failures; 12.6 MiB read in 24.1 ms (totals: 1792 hits, 0 misses, 0 writes; plans 1760 hits, 0 misses)
[SOFT-NET] sceNetResolverStartNtoa -> host DNS lookup failed
[SOFT-NET] sceNetResolverStartNtoa -> host DNS lookup failed
[SOFT-NET] sceNetResolverStartNtoa -> host DNS lookup failed
[gpu] driver failure: AGC graphics: layered draws into a color view of several array slices are unsupported
[videoout] presentation failed: AGC graphics: layered draws into a color view of several array slices are unsupported
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: layered draws into a color view of several array slices are unsupported
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: layered draws into a color view of several array slices are unsupported
FATAL: abort() (SIGABRT) on thread 2332

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit ccb0c09 into boykopovar:main Oct 18, 2026
9 checks passed
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 18, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
alex73630 added a commit to alex73630/AnyPS5 that referenced this pull request Oct 19, 2026
Integrate the remaining regression coverage from Gjonn PRs boykopovar#7238, boykopovar#7243 and boykopovar#7256 while retaining the larger storage heap, packed float blending and shared depth arrays. The offset folding from boykopovar#7240 is already covered.

Co-authored-by: Gjon Gojcevic <gjonn@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants