fix(agc): read 128-bit T#s that start past MAX_MIP from their resident levels #8962

Merged
Celegans12 merged 1 commit from upstream-pr/8962 into main 2026-10-22 23:10:18 +00:00
Celegans12 commented 2026-10-21 07:38:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-21T07:38:02Z.


What

An R128 image instruction reads only words 0-3 of its T#, and the recompiler passes words 4-7 as zero (getImageResource), so DecodeTextureResource sees MAX_MIP 0. A 128-bit T# with a BASE_LEVEL above 0 then throws "starts past the surface's last mip level at levels that would move the surface's own". Ghost of Yōtei's streamed textures are like that: a 2048x2048 BC3 T# naming levels 2..11, of which only those 10 levels are resident.

  • When words 4-7 are all zero and the T# would be refused this way, the decoder reads it as a 128-bit T#: MAX_MIP = LAST_LEVEL, with levels BASE..LAST described as their own chain (size shifted by BASE_LEVEL, MIN_LOD moved with it). It does this only when DescribeSurface gives each of those levels the same offset, size and tail slot as in the full chain (GFX10 places a chain from its last level up, so the resident levels start the allocation).
  • Only 1D and 2D T#s are read this way. Any other type, a layout that doesn't match, or a T# with any of words 4-7 set still throws as before.
  • The driver can't tell a 128-bit access from a 256-bit T# whose words 4-7 are zero, so it takes the 128-bit reading only where the 256-bit one is refused. A zero-tail T# starting at level 0 still decodes as one level.

Overlaps: #8564 adds EncodeTextureResource right below the refusal this PR changes (textual only). #7948 and #8429 edit other parts of DecodeTextureResource and its test and merge cleanly with this PR. #6977 edits the same function too but already conflicts with main.

Tested

  • Windows 11 Pro, MinGW-w64 GCC 15.2.0, -DBUILD_TESTING=ON, RTX 3080 Laptop, based on main 65c393a684: ctest 1834/1838. log_macros, log_macros_timestamps and agc_driver_image_array_window_past_layer_limit (doesn't compile with MinGW) fail on main too; guest_raise_in_host_code timed out under load and passed 3/3 alone.
  • Linux (WSL, lavapipe), CI's job on the merge: 1772/1792; the same 20 fail on main.
  • New R128 cases in agc_driver_graphics: the streamed T# decodes as 512x512 with 10 levels, each equal to level n+2 of the 12-level chain; a 1024x2048 T# of levels 4..11 as 64x128 with 8; MIN_LOD moves with the base level. They fail on main with the "starts past" message. The old 1920x1080 refusal case gets a PERF_MOD so it stays a 256-bit T#.
  • PPSA26344: this reading in our tree's bindless path fixed black streamed rocks in the open world; not run on main.
  • Not tested: AMD, Intel, console behaviour.

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: none
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.62, Windows 11 Pro; lavapipe (Mesa 25.2.8, WSL Ubuntu 24.04)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4948104318 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8962). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-21T07:38:02Z. --- ### What An R128 image instruction reads only words 0-3 of its T#, and the recompiler passes words 4-7 as zero (`getImageResource`), so `DecodeTextureResource` sees MAX_MIP 0. A 128-bit T# with a BASE_LEVEL above 0 then throws "starts past the surface's last mip level at levels that would move the surface's own". Ghost of Yōtei's streamed textures are like that: a 2048x2048 BC3 T# naming levels 2..11, of which only those 10 levels are resident. - When words 4-7 are all zero and the T# would be refused this way, the decoder reads it as a 128-bit T#: MAX_MIP = LAST_LEVEL, with levels BASE..LAST described as their own chain (size shifted by BASE_LEVEL, MIN_LOD moved with it). It does this only when `DescribeSurface` gives each of those levels the same offset, size and tail slot as in the full chain (GFX10 places a chain from its last level up, so the resident levels start the allocation). - Only 1D and 2D T#s are read this way. Any other type, a layout that doesn't match, or a T# with any of words 4-7 set still throws as before. - The driver can't tell a 128-bit access from a 256-bit T# whose words 4-7 are zero, so it takes the 128-bit reading only where the 256-bit one is refused. A zero-tail T# starting at level 0 still decodes as one level. Overlaps: #8564 adds `EncodeTextureResource` right below the refusal this PR changes (textual only). #7948 and #8429 edit other parts of `DecodeTextureResource` and its test and merge cleanly with this PR. #6977 edits the same function too but already conflicts with `main`. ### Tested - Windows 11 Pro, MinGW-w64 GCC 15.2.0, `-DBUILD_TESTING=ON`, RTX 3080 Laptop, based on `main` 65c393a684: ctest 1834/1838. `log_macros`, `log_macros_timestamps` and `agc_driver_image_array_window_past_layer_limit` (doesn't compile with MinGW) fail on `main` too; `guest_raise_in_host_code` timed out under load and passed 3/3 alone. - Linux (WSL, lavapipe), CI's job on the merge: 1772/1792; the same 20 fail on `main`. - New R128 cases in `agc_driver_graphics`: the streamed T# decodes as 512x512 with 10 levels, each equal to level n+2 of the 12-level chain; a 1024x2048 T# of levels 4..11 as 64x128 with 8; MIN_LOD moves with the base level. They fail on `main` with the "starts past" message. The old 1920x1080 refusal case gets a PERF_MOD so it stays a 256-bit T#. - PPSA26344: this reading in our tree's bindless path fixed black streamed rocks in the open world; not run on `main`. - Not tested: AMD, Intel, console behaviour. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) - [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: none - [x] GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.62, Windows 11 Pro; lavapipe (Mesa 25.2.8, WSL Ubuntu 24.04) - [x] AI-assisted: yes
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!8962
No description provided.