fix(agc): treat type-0 texture descriptors as null #4779

Merged
MarcZX10 merged 2 commits from upstream-pr/4779 into main 2026-10-14 17:47:44 +00:00
MarcZX10 commented 2026-10-12 21:37:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T21:37:28Z.


What

Treat an AMD texture descriptor with TYPE=0 as a null image, even when its base address is nonzero. This lets guest shaders bind stale S#+V# words in image slots without trying to decode them as a real texture. The scope is the observed TYPE=0 case from issue #4139; this PR does not implement cube T# reads through 2D accesses.

The null predicate is shared across image precollection, binding resolution, refresh, revalidation and surface presync so each path classifies the same descriptor consistently. Regression coverage includes zero-base descriptors, TYPE=0 with a nonzero base, and a valid nonzero-base descriptor.

Evidence and limits

The issue reports S#+V# words in image slots in High on Life, including repeated TYPE=0 substitutions. An issue contributor measured TYPE=0 behavior on gfx1036 RDNA2: image sample/load/resinfo returned zero, including the reported nonzero unmapped bases, without a GPU fault. This is gfx1036 evidence; PS5 gfx1013 behavior was not measured.

Tested

  • Linux Release: agc_driver_graphics passed (1/1) on current main base 584cc4c5716b02210ca031593d1a6b0b4ce049cb.
  • python3 tools/check_conventions.py --base upstream/main passed.
  • git diff --check upstream/main...HEAD passed.
  • The reported console behavior and gfx1036 experiment were not rerun by this PR; no console/GPU hardware validation was performed here.

Checklist

  • Based on current main; no open PR implements TYPE=0 null descriptor handling
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw or use NotImplemented_nid_no_patch
  • No investigation files added to the repository
  • No new third-party code
  • Generic behavior
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835281002 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T21:37:28Z. --- ### What Treat an AMD texture descriptor with `TYPE=0` as a null image, even when its base address is nonzero. This lets guest shaders bind stale S#+V# words in image slots without trying to decode them as a real texture. The scope is the observed TYPE=0 case from [issue #4139](https://github.com/boykopovar/AnyPS5/issues/4139); this PR does not implement cube T# reads through 2D accesses. The null predicate is shared across image precollection, binding resolution, refresh, revalidation and surface presync so each path classifies the same descriptor consistently. Regression coverage includes zero-base descriptors, TYPE=0 with a nonzero base, and a valid nonzero-base descriptor. ### Evidence and limits The issue reports S#+V# words in image slots in High on Life, including repeated TYPE=0 substitutions. An issue contributor measured TYPE=0 behavior on gfx1036 RDNA2: image sample/load/resinfo returned zero, including the reported nonzero unmapped bases, without a GPU fault. **This is gfx1036 evidence; PS5 gfx1013 behavior was not measured.** ### Tested - Linux Release: `agc_driver_graphics` passed (1/1) on current `main` base `584cc4c5716b02210ca031593d1a6b0b4ce049cb`. - `python3 tools/check_conventions.py --base upstream/main` passed. - `git diff --check upstream/main...HEAD` passed. - The reported console behavior and gfx1036 experiment were not rerun by this PR; no console/GPU hardware validation was performed here. ### Checklist - [x] Based on current `main`; no open PR implements TYPE=0 null descriptor handling - [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 or use `NotImplemented_nid_no_patch` - [x] No investigation files added to the repository - [x] No new third-party code - [x] Generic behavior - [x] Depends on: none - [x] AI-assisted: yes
xXPBSXx commented 2026-10-12 23:24:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T23:24:46Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main 44ab0c39e (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it:

  • tests/GuestTextureResource.cpp, which is part of agc_driver_graphics_tests: see below.

agc_driver_graphics over the batch: 9 of 10 runs passed. The one failure is the known address-layout flake from #4660 as far as I can tell: I kept only the first lines of that run's log (the host import ... vkAllocateMemory (-2) lines, which appear in passing runs as well), not its final error message, so I can't confirm the cause for that one run. Plain main failed 2 of 10 on the same machine earlier.

Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134543291 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6134543291). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T23:24:46Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main `44ab0c39e` (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it: - `tests/GuestTextureResource.cpp`, which is part of `agc_driver_graphics_tests`: see below. `agc_driver_graphics` over the batch: 9 of 10 runs passed. The one failure is the known address-layout flake from #4660 as far as I can tell: I kept only the first lines of that run's log (the `host import ... vkAllocateMemory (-2)` lines, which appear in passing runs as well), not its final error message, so I can't confirm the cause for that one run. Plain `main` failed 2 of 10 on the same machine earlier. Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake). AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 02:43:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:43:16Z.


Two things before merging:

  • a docs/dev/debt/libSceAgcDriver.md entry: a TYPE=0 descriptor with a non-zero base is bound as a null image, after the gfx1036 measurement in #4139; not measured on the console;
  • the title: its ID, the log line where it stops on main, and a run on this head that gets past it. The test checks the predicate only; nothing has drawn through the changed binding paths yet.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6137041598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6137041598). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T02:43:16Z. --- Two things before merging: - a `docs/dev/debt/libSceAgcDriver.md` entry: a TYPE=0 descriptor with a non-zero base is bound as a null image, after the gfx1036 measurement in #4139; not measured on the console; - the title: its ID, the log line where it stops on main, and a run on this head that gets past it. The test checks the predicate only; nothing has drawn through the changed binding paths yet.
MarcZX10 commented 2026-10-13 07:12:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:12:06Z.


Thanks. The title is High on Life (PPSA15388), documented in #4139; its current-main failure is the rejected descriptor/shader-draw path. The gameplay result in that issue used a local experiment that null-bound both the TYPE=0 slot and the separate cube-through-2D case. This PR changes only the TYPE=0 handling, and I do not have an isolated run of this exact PR head that gets the title past the failure. The gfx1036 measurement is not a console measurement, so I will keep that limitation explicit and will not claim this PR alone gets High on Life to gameplay.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140319069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6140319069). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:12:06Z. --- Thanks. The title is High on Life (PPSA15388), documented in #4139; its current-main failure is the rejected descriptor/shader-draw path. The gameplay result in that issue used a local experiment that null-bound both the TYPE=0 slot and the separate cube-through-2D case. This PR changes only the TYPE=0 handling, and I do not have an isolated run of this exact PR head that gets the title past the failure. The gfx1036 measurement is not a console measurement, so I will keep that limitation explicit and will not claim this PR alone gets High on Life to gameplay.
Sam-mon7 commented 2026-10-13 19:55:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-13T19:55:03Z.


A second title with TYPE=0 image descriptors: Demon's Souls (PPSA01341 v1.07), Windows 11, RTX 4070 (driver 596.21), MinGW GCC 15.2 Release.

  • Stop: during the PS Studios intro, compute shader 0x248a05b00 (shader_248a05b00_failed.req): runtime image descriptor is invalid, then SIGABRT. In the captured request, image slots 3-6 have TYPE=0 (dword3[31:28]) with a nonzero base and nonzero remaining words. Slots 0-2 and 7-9 are valid descriptors.
  • This PR covers the driver binding paths. The recompiler's static image check (ResourceMaterializer.cpp) still treats only a zero base as null, so a TYPE=0 descriptor with a nonzero base is rejected there first. A CPU regression with such a descriptor fails with this PR applied. I have not replayed the captured request against this head alone.
  • Locally I added the same TYPE=0 predicate in ResourceMaterializer.cpp (words cleared before metadata and swizzle selection), and TYPE=0 image-table entries resolve to null. With this PR plus that change, the captured request gets past image validation, and later runs pass the intro and reach character creation. That tree carries other local changes, so it is not an isolated run of this head either.
  • On the RTX 4070 (not gfx1013): TYPE=0 descriptors with nonzero or unmapped bases read four zero components through a direct sample, a buffer-table sample and load, and a raw-pointer table sample. A reserved TYPE=1 still faults.

If it helps, I can open the recompiler half as a follow-up that depends on this PR.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153952838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6153952838). Originally posted by [Sam-mon7](https://github.com/Sam-mon7) on 2026-10-13T19:55:03Z. --- A second title with TYPE=0 image descriptors: Demon's Souls (PPSA01341 v1.07), Windows 11, RTX 4070 (driver 596.21), MinGW GCC 15.2 Release. - Stop: during the PS Studios intro, `compute shader 0x248a05b00 (shader_248a05b00_failed.req): runtime image descriptor is invalid`, then SIGABRT. In the captured request, image slots 3-6 have TYPE=0 (`dword3[31:28]`) with a nonzero base and nonzero remaining words. Slots 0-2 and 7-9 are valid descriptors. - This PR covers the driver binding paths. The recompiler's static image check (`ResourceMaterializer.cpp`) still treats only a zero base as null, so a TYPE=0 descriptor with a nonzero base is rejected there first. A CPU regression with such a descriptor fails with this PR applied. I have not replayed the captured request against this head alone. - Locally I added the same TYPE=0 predicate in `ResourceMaterializer.cpp` (words cleared before metadata and swizzle selection), and TYPE=0 image-table entries resolve to null. With this PR plus that change, the captured request gets past image validation, and later runs pass the intro and reach character creation. That tree carries other local changes, so it is not an isolated run of this head either. - On the RTX 4070 (not gfx1013): TYPE=0 descriptors with nonzero or unmapped bases read four zero components through a direct sample, a buffer-table sample and load, and a raw-pointer table sample. A reserved TYPE=1 still faults. If it helps, I can open the recompiler half as a follow-up that depends on this PR. AI-assisted: yes
MarcZX10 commented 2026-10-13 20:17:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T20:17:19Z.


Thanks, this separates the two layers clearly: this PR handles runtime binding, while ResourceMaterializer rejects the TYPE=0 descriptor earlier. The separate CPU regression and title trace are useful evidence. A focused follow-up for the recompiler path, depending on this PR, seems like the right way to carry that fix; the remaining gfx1013 behavior should stay explicit as unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154353023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6154353023). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T20:17:19Z. --- Thanks, this separates the two layers clearly: this PR handles runtime binding, while `ResourceMaterializer` rejects the TYPE=0 descriptor earlier. The separate CPU regression and title trace are useful evidence. A focused follow-up for the recompiler path, depending on this PR, seems like the right way to carry that fix; the remaining gfx1013 behavior should stay explicit as unverified.
MarcZX10 commented 2026-10-13 20:40:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T20:40:26Z.


I opened the recompiler-side follow-up as PR #5473, depending on this PR. It adds a regression for an image descriptor with TYPE=0 and a nonzero base. The focused Linux test passes with the change and fails on the previous predicate with runtime image descriptor is invalid. I recorded that this does not include the runtime binding change from this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154764286 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6154764286). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T20:40:26Z. --- I opened the recompiler-side follow-up as [PR #5473](https://github.com/boykopovar/AnyPS5/pull/5473), depending on this PR. It adds a regression for an image descriptor with TYPE=0 and a nonzero base. The focused Linux test passes with the change and fails on the previous predicate with `runtime image descriptor is invalid`. I recorded that this does not include the runtime binding change from this PR.
adriadam10 commented 2026-10-14 17:20:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:20:22Z.


Checked the shared IsNullTextureResource predicate against every site that used the old zero-base test (precollect, resolve, refresh, revalidate, presync): all consistent. agc_driver_graphics passes, and the new type-0 case fails if the type == 0 check is removed.

Added on top, per @oneandonlydean's request: a docs/dev/debt/libSceAgcDriver.md entry saying a TYPE=0 descriptor with a nonzero base is bound as a null image, from the gfx1036 measurement in #4139 and not measured on the console. Rebased onto current main; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174138806 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4779#issuecomment-6174138806). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T17:20:22Z. --- Checked the shared `IsNullTextureResource` predicate against every site that used the old zero-base test (precollect, resolve, refresh, revalidate, presync): all consistent. `agc_driver_graphics` passes, and the new type-0 case fails if the `type == 0` check is removed. Added on top, per @oneandonlydean's request: a `docs/dev/debt/libSceAgcDriver.md` entry saying a TYPE=0 descriptor with a nonzero base is bound as a null image, from the gfx1036 measurement in #4139 and not measured on the console. Rebased onto current main; merging once CI is green.
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!4779
No description provided.