fix(shader): point-filter a filter mode 3 sampler as a weighted average #27452

Merged
milescoviello merged 1 commit from upstream-pr/27452 into main 2026-11-27 02:50:56 +00:00
milescoviello commented 2026-11-26 12:46:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-26T12:46:03Z.


What

#22665 samples S# filter mode 3 as a weighted average and lets image-table samplers with mode 3 into the table, but ReducesBetweenTexels still counted any nonzero filter mode as a min or max reduction. The point-filtered variant of such a sampler, built for a sint, converted or depth-bits image, then threw 'a min or max reduction sampler that filters between texels or mip levels samples an image that needs point filtering'. Only modes 1 and 2 reduce; mode 3 now point-filters like mode 0.

Tested

Ghost of Tsushima (PPSA02225), Linux, NVIDIA RTX 4070 Ti (driver 615.71.09), the same 600 s scripted run:

  • main 341a9eec1, which has #22665: the title stops at 145 s with what(): compute shader 0x2000106500: DescriptorBindingBuilder: a min or max reduction sampler that filters between texels or mip levels samples an image that needs point filtering (sint, converted or depth-bits format), which is not implemented. The three rotation runs just before #22665 merged, on main 8a4371011, 8deb9bf1d and f171065f7, ran the full 600 s with no such error.
  • main 9931d320d, the next rotation run: stops the same way at 94 s, in compute shader 0x20001ac700.
  • main f0f208dc7, the run after that: stops the same way at 167 s, in compute shader 0x2000106500.
  • main 9415030dfe3 + this change: ran the full 604 s with no such error, the loading screen at 150 s and 300 s, then the night beach combat in the game at 450 s and 600 s.

Tests (agc_graphics_profile_draw runs the sampler tests in GuestSamplerResource.cpp):

  • Linux (Ubuntu 26.04, GCC 15.2, Release, NVIDIA RTX 4070 Ti), head 6f423f550bf on main 9415030dfe3: agc_graphics_profile_draw, agc_driver_image_sample_reduction and agc_driver_image_filter_mode_three (#22665's test) pass in 3 of 3 runs.
  • Mutation check: with ReducesBetweenTexels counting any nonzero filter mode again, agc_graphics_profile_draw fails in 3 of 3 runs.
  • Windows 11 VM (WinLibs GCC 16.2.0, Release, NVIDIA GT 1030), head 6f423f550bf: agc_graphics_profile_draw and agc_driver_image_sample_reduction pass in 3 of 3 runs. (agc_driver_image_filter_mode_three was not yet in that build.)

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: PPSA02225 #4461 (since #22665 main stops at 94 to 167 s; with this change the run reached the game, see Tested)
  • GPUs tested: NVIDIA RTX 4070 Ti (Linux, title and tests), NVIDIA GT 1030 (Windows, tests)
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved texture filtering behavior so mode 3 is handled consistently during sampling and does not trigger between-sample reduction.
    • Existing minification, magnification, and mip filtering behavior remains unchanged.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5510270547 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27452). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-26T12:46:03Z. --- ### What #22665 samples S# filter mode 3 as a weighted average and lets image-table samplers with mode 3 into the table, but ReducesBetweenTexels still counted any nonzero filter mode as a min or max reduction. The point-filtered variant of such a sampler, built for a sint, converted or depth-bits image, then threw 'a min or max reduction sampler that filters between texels or mip levels samples an image that needs point filtering'. Only modes 1 and 2 reduce; mode 3 now point-filters like mode 0. ### Tested Ghost of Tsushima (PPSA02225), Linux, NVIDIA RTX 4070 Ti (driver 615.71.09), the same 600 s scripted run: - `main` `341a9eec1`, which has #22665: the title stops at 145 s with `what(): compute shader 0x2000106500: DescriptorBindingBuilder: a min or max reduction sampler that filters between texels or mip levels samples an image that needs point filtering (sint, converted or depth-bits format), which is not implemented`. The three rotation runs just before #22665 merged, on `main` `8a4371011`, `8deb9bf1d` and `f171065f7`, ran the full 600 s with no such error. - `main` `9931d320d`, the next rotation run: stops the same way at 94 s, in compute shader `0x20001ac700`. - `main` `f0f208dc7`, the run after that: stops the same way at 167 s, in compute shader `0x2000106500`. - `main` `9415030dfe3` + this change: ran the full 604 s with no such error, the loading screen at 150 s and 300 s, then the night beach combat in the game at 450 s and 600 s. Tests (`agc_graphics_profile_draw` runs the sampler tests in `GuestSamplerResource.cpp`): - Linux (Ubuntu 26.04, GCC 15.2, Release, NVIDIA RTX 4070 Ti), head `6f423f550bf` on `main` `9415030dfe3`: `agc_graphics_profile_draw`, `agc_driver_image_sample_reduction` and `agc_driver_image_filter_mode_three` (#22665's test) pass in 3 of 3 runs. - Mutation check: with `ReducesBetweenTexels` counting any nonzero filter mode again, `agc_graphics_profile_draw` fails in 3 of 3 runs. - Windows 11 VM (WinLibs GCC 16.2.0, Release, NVIDIA GT 1030), head `6f423f550bf`: `agc_graphics_profile_draw` and `agc_driver_image_sample_reduction` pass in 3 of 3 runs. (`agc_driver_image_filter_mode_three` was not yet in that build.) ### Checklist - [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: PPSA02225 #4461 (since #22665 `main` stops at 94 to 167 s; with this change the run reached the game, see Tested) - [x] GPUs tested: NVIDIA RTX 4070 Ti (Linux, title and tests), NVIDIA GT 1030 (Windows, tests) - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Improved texture filtering behavior so mode 3 is handled consistently during sampling and does not trigger between-sample reduction. - Existing minification, magnification, and mip filtering behavior remains unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-26 12:56:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:56:37Z.

Review: APPROVED


Reviewed — looks good

Nothing in the inspected change blocks merging; the code distinguishes min/max reductions from weighted-average mode 3 and adds a focused regression assertion.

What I ran

Reviewed head 6f423f550bf67282fa502b6dc5cad9613417230b. I read the prepared description, commit list, manifest, diff, and both changed files at the changed functions. No tests or builds were run in this review.

Results

Check Result Note
Changed logic passed Mode 3 no longer triggers reduction handling
Regression assertion passed Compares point-filtered mode 3 with mode 0
Tests/build not run Relied on the inspected code and author-reported results

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read all files listed under reviewed in the manifest: core/libs/prx/libSceAgcDriver/tests/GuestSamplerResource.cpp and core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp. The excluded-file list was not present in the supplied manifest. I did not independently verify the reported game runs, test runs, or mutation check.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6074497564 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27452#pullrequestreview-6074497564). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T12:56:37Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the inspected change blocks merging; the code distinguishes min/max reductions from weighted-average mode 3 and adds a focused regression assertion. ## What I ran Reviewed head `6f423f550bf67282fa502b6dc5cad9613417230b`. I read the prepared description, commit list, manifest, diff, and both changed files at the changed functions. No tests or builds were run in this review. ## Results | Check | Result | Note | |---|---|---| | Changed logic | passed | Mode 3 no longer triggers reduction handling | | Regression assertion | passed | Compares point-filtered mode 3 with mode 0 | | Tests/build | not run | Relied on the inspected code and author-reported results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read all files listed under `reviewed` in the manifest: `core/libs/prx/libSceAgcDriver/tests/GuestSamplerResource.cpp` and `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp`. The excluded-file list was not present in the supplied manifest. I did not independently verify the reported game runs, test runs, or mutation check. ## To get this to a good state Nothing is required.
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!27452
No description provided.