feat(agc): apply a texture descriptor's MIN_LOD clamp through the image view #130

Merged
oneandonlydean merged 1 commit from upstream-pr/130 into main 2026-10-01 07:17:19 +00:00
oneandonlydean commented 2026-09-29 00:33:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-29T00:33:10Z.


What

A texture descriptor with a nonzero MIN_LOD (T# word1, unsigned 4.8, counted in levels of the whole surface) was rejected at decode.

Sampled views now chain VkImageViewMinLodCreateInfoEXT (VK_EXT_image_view_min_lod, enabled when the device reports the minLod feature). Its minLod counts levels of the whole image the same way MIN_LOD counts levels of the whole surface, because the image holds every mip and the view starts at BASE_LEVEL.

  • A clamp at or below BASE_LEVEL can't change which level a sample reads, so it isn't applied.
  • A clamp past the view's last level is capped at that level. The view would pick that level anyway, and Vulkan requires the cap.
  • The texture cache already keys by all eight descriptor words, so views with different clamps are never shared.

What still throws:

  • A clamp that would apply, on a device without the extension/feature.
  • A storage (image load/store) descriptor whose clamp is above the one level the view addresses. A clamp at or below that level is accepted.

This is separate from #37, which handles the sampler's (S#) min LOD, not the texture descriptor's.

Tested

  • Linux (CachyOS, RADV): agc_driver_tests covers the decode and the effective clamp: below, at and above BASE_LEVEL, past the last level, and the smallest step.
  • agc_driver_recorder_tests gets minLodTests, which uploads a 4-level surface with a different constant in each mip, samples it at explicit LODs through views with different clamps and checks the red channel: integer and fractional clamps, clamps past the last level, and views starting at level 1. With the view clamp left out, the test fails ("MIN_LOD 1 reads level 1 at LOD 0: read 0.000000, expected 0.250980").
  • ctest: 57/57 pass.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4670962967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/130). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-29T00:33:10Z. --- ### What A texture descriptor with a nonzero MIN_LOD (T# word1, unsigned 4.8, counted in levels of the whole surface) was rejected at decode. Sampled views now chain `VkImageViewMinLodCreateInfoEXT` (`VK_EXT_image_view_min_lod`, enabled when the device reports the `minLod` feature). Its `minLod` counts levels of the whole image the same way MIN_LOD counts levels of the whole surface, because the image holds every mip and the view starts at BASE_LEVEL. - A clamp at or below BASE_LEVEL can't change which level a sample reads, so it isn't applied. - A clamp past the view's last level is capped at that level. The view would pick that level anyway, and Vulkan requires the cap. - The texture cache already keys by all eight descriptor words, so views with different clamps are never shared. What still throws: - A clamp that would apply, on a device without the extension/feature. - A storage (image load/store) descriptor whose clamp is above the one level the view addresses. A clamp at or below that level is accepted. This is separate from #37, which handles the sampler's (S#) min LOD, not the texture descriptor's. ### Tested - Linux (CachyOS, RADV): `agc_driver_tests` covers the decode and the effective clamp: below, at and above BASE_LEVEL, past the last level, and the smallest step. - `agc_driver_recorder_tests` gets `minLodTests`, which uploads a 4-level surface with a different constant in each mip, samples it at explicit LODs through views with different clamps and checks the red channel: integer and fractional clamps, clamps past the last level, and views starting at level 1. With the view clamp left out, the test fails ("MIN_LOD 1 reads level 1 at LOD 0: read 0.000000, expected 0.250980"). - `ctest`: 57/57 pass. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-30 16:12:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-30T16:12:47Z.


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
#131 core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp
#148 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L212-213, L404-405
#167 core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp
#181 core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5915142554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/130#issuecomment-5915142554). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-30T16:12:47Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #131 | | | `core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp` | | #148 | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L212-213](https://github.com/boykopovar/AnyPS5/blob/89afcdc070bc6301d81561adbdeb9bfa51e04252/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L212-L213), [L404-405](https://github.com/boykopovar/AnyPS5/blob/89afcdc070bc6301d81561adbdeb9bfa51e04252/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L404-L405) | | | | #167 | | | `core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp` | | #181 | | | `core/libs/prx/libSceAgcDriver/tests/shaders/SampleLod.comp` |
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!130
No description provided.