fix(agc): treat a TYPE 1 T# in a read-only static image slot as null #5828

Merged
billythemenace2 merged 1 commit from upstream-pr/5828 into main 2026-10-16 10:34:29 +00:00
billythemenace2 commented 2026-10-14 12:43:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T12:43:51Z.


Requested by billy

What

Before: since #5473 and #4779, a static, read-only image slot whose T# has TYPE 0 is bound as a null image, but a T# with TYPE 1 in the same slot still threw runtime image descriptor is invalid in the recompiler. In the driver it was not treated as null either.

After: TYPE 1 is treated like TYPE 0 in both places: nullImageDescriptor(const ImageResource&, const DescriptorValue&) in ResourceMaterializer.cpp and IsNullTextureResource in GuestTextureResource.cpp. The same limits apply: written, atomic and image-table slots still throw, and the reserved types 2-7 stay refused.

Hardware semantics, measured on RDNA1 (gfx1010, AMD Radeon RX 5700 XT) with the tools/hw-oracle template (driver comgr and HIP runtime): image_sample_lz, image_sample_b, image_load and image_get_resinfo (DIM 2D, dmask 0xf) through a format-22 T# of TYPE 1 return zeros in all four components without a fault, as TYPE 0 does. A TYPE 9 control with the same words returned the texels. The existing debt entry already notes that gfx1035 reads TYPE 1 as zeros too. Not measured: RDNA2 and the console's gfx1013, other formats, and depth-compare reads (image_sample_c*); the debt entries say so. On the same card a TYPE 2 T# left the driver unusable until a restart, which is why 2-7 stay refused.

How

Both predicates accept TYPE <= 1 instead of TYPE == 0. verifyTypeZeroImageMaterialization now runs for TYPE 0 and TYPE 1: the read-only slot keeps the words, and the written and atomic slots still throw. verifyGuardedDescriptorSources gets a read-only TYPE 1 case, and its invalid T# moves to the reserved TYPE 2. The driver's IsNullTextureResource test adds TYPE 1 (null) and TYPE 2 (not null). The two TYPE 0 debt entries in docs/dev/debt/libSceAgcDriver.md now cover TYPE 1 with its limits; I edited them there rather than adding a shader.md entry, so that the TYPE 0 and TYPE 1 behaviour stay in one place.

Tested

Windows 11 (26200), MinGW-w64 GCC 15, Release, on main 92e50418f. agc_shader_type_zero_image_materialization, agc_shader_memory, agc_shader_bindless and agc_driver_graphics pass. With main's ResourceMaterializer.cpp and GuestTextureResource.cpp, agc_shader_type_zero_image_materialization, agc_shader_memory and agc_driver_graphics fail. tools/check_conventions.py --base origin/main passes. Not tested: Linux, a title with a TYPE 1 slot.

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 (#5473 and #4779 are merged)
  • Unblocks: none known
  • GPUs tested: AMD Radeon RX 5700 XT (hardware oracle measurement and the tests above), Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4858053453 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T12:43:51Z. --- <!-- claude-projects-attribution --> _Requested by **billy**_ ### What Before: since #5473 and #4779, a static, read-only image slot whose T# has TYPE 0 is bound as a null image, but a T# with TYPE 1 in the same slot still threw `runtime image descriptor is invalid` in the recompiler. In the driver it was not treated as null either. After: TYPE 1 is treated like TYPE 0 in both places: `nullImageDescriptor(const ImageResource&, const DescriptorValue&)` in `ResourceMaterializer.cpp` and `IsNullTextureResource` in `GuestTextureResource.cpp`. The same limits apply: written, atomic and image-table slots still throw, and the reserved types 2-7 stay refused. Hardware semantics, measured on RDNA1 (gfx1010, AMD Radeon RX 5700 XT) with the `tools/hw-oracle` template (driver comgr and HIP runtime): `image_sample_lz`, `image_sample_b`, `image_load` and `image_get_resinfo` (DIM 2D, dmask 0xf) through a format-22 T# of TYPE 1 return zeros in all four components without a fault, as TYPE 0 does. A TYPE 9 control with the same words returned the texels. The existing debt entry already notes that gfx1035 reads TYPE 1 as zeros too. Not measured: RDNA2 and the console's gfx1013, other formats, and depth-compare reads (`image_sample_c*`); the debt entries say so. On the same card a TYPE 2 T# left the driver unusable until a restart, which is why 2-7 stay refused. ### How Both predicates accept `TYPE <= 1` instead of `TYPE == 0`. `verifyTypeZeroImageMaterialization` now runs for TYPE 0 and TYPE 1: the read-only slot keeps the words, and the written and atomic slots still throw. `verifyGuardedDescriptorSources` gets a read-only TYPE 1 case, and its invalid T# moves to the reserved TYPE 2. The driver's `IsNullTextureResource` test adds TYPE 1 (null) and TYPE 2 (not null). The two TYPE 0 debt entries in `docs/dev/debt/libSceAgcDriver.md` now cover TYPE 1 with its limits; I edited them there rather than adding a `shader.md` entry, so that the TYPE 0 and TYPE 1 behaviour stay in one place. ### Tested Windows 11 (26200), MinGW-w64 GCC 15, Release, on `main` `92e50418f`. `agc_shader_type_zero_image_materialization`, `agc_shader_memory`, `agc_shader_bindless` and `agc_driver_graphics` pass. With main's `ResourceMaterializer.cpp` and `GuestTextureResource.cpp`, `agc_shader_type_zero_image_materialization`, `agc_shader_memory` and `agc_driver_graphics` fail. `tools/check_conventions.py --base origin/main` passes. Not tested: Linux, a title with a TYPE 1 slot. ### 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) - [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 (#5473 and #4779 are merged) - [x] Unblocks: none known - [x] GPUs tested: AMD Radeon RX 5700 XT (hardware oracle measurement and the tests above), Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-14 13:22:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T13:22:13Z.


The new regression covers the S#+V# words with T# type 0, while nonImageDescriptor also accepts type 1. Since the report includes an RDNA1 measurement for type 1, could the fixture add the same null-image assertion for a type-1 descriptor as well? That would keep the tested scope aligned with the implementation and the PR claim; the existing type-2 refusal case can remain the neighboring negative control.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169361464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6169361464). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T13:22:13Z. --- The new regression covers the S#+V# words with T# type 0, while `nonImageDescriptor` also accepts type 1. Since the report includes an RDNA1 measurement for type 1, could the fixture add the same null-image assertion for a type-1 descriptor as well? That would keep the tested scope aligned with the implementation and the PR claim; the existing type-2 refusal case can remain the neighboring negative control.
billythemenace2 commented 2026-10-14 15:51:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T15:51:42Z.


@MarcZX100 Added in 353570feb: the guarded-sources case now also captures a type 1 T# (the valid 2D T#'s words with TYPE 1) and checks that it is bound as a null image, next to the S#+V# type 0 words and the type 2 refusal. agc_shader_memory passes on an RX 5700 XT, and tools/check_conventions.py passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6172407882 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6172407882). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T15:51:42Z. --- @MarcZX100 Added in `353570feb`: the guarded-sources case now also captures a type 1 T# (the valid 2D T#'s words with TYPE 1) and checks that it is bound as a null image, next to the S#+V# type 0 words and the type 2 refusal. `agc_shader_memory` passes on an RX 5700 XT, and `tools/check_conventions.py` passes. AI-assisted (Claude Code).
fdfawef324 commented 2026-10-14 16:49:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T16:49:16Z.


Additional CPU evidence from a private Demon's Souls (PPSA01342) capture: four active static sampled-image slots contain TYPE 0 descriptors and stop at runtime image descriptor is invalid. All four are read-only, with no image stores or atomics. Porting only this PR's four own commits through 353570feb onto our integration removes that specific refusal. The complete captured preparation path then stops at an independent buffer-descriptor type check, so this is not a successful title run or proof that the level loads.

A separate fixture calling the actual ResourceMaterializer::Materialize, TryRuntimeImageMode and ResolveImageTables APIs passed 23 CPU checks: static types 0/1 become null, reserved types 2–7 and invalid widths remain refused, inactive guards and valid/null transitions are preserved, and table entries of types 0/1/2 remain poisoned. The same fixture fails with the old Materializer and with a selective control widening the accepted static types through 7. These checks use matching integration headers and the actual production translation unit, rather than claiming a full build of this public PR head.

No game request, descriptor payload, shader dump or disassembly is attached. No fresh GPU or numerical shader-output result is claimed. Host: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100; this additional validation is CPU-only.

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173541017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6173541017). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T16:49:16Z. --- Additional CPU evidence from a private Demon's Souls (PPSA01342) capture: four active static sampled-image slots contain TYPE 0 descriptors and stop at `runtime image descriptor is invalid`. All four are read-only, with no image stores or atomics. Porting only this PR's four own commits through `353570feb` onto our integration removes that specific refusal. The complete captured preparation path then stops at an independent buffer-descriptor type check, so this is not a successful title run or proof that the level loads. A separate fixture calling the actual `ResourceMaterializer::Materialize`, `TryRuntimeImageMode` and `ResolveImageTables` APIs passed 23 CPU checks: static types 0/1 become null, reserved types 2–7 and invalid widths remain refused, inactive guards and valid/null transitions are preserved, and table entries of types 0/1/2 remain poisoned. The same fixture fails with the old Materializer and with a selective control widening the accepted static types through 7. These checks use matching integration headers and the actual production translation unit, rather than claiming a full build of this public PR head. No game request, descriptor payload, shader dump or disassembly is attached. No fresh GPU or numerical shader-output result is claimed. Host: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100; this additional validation is CPU-only. Co-Authored-By: Codex <[email protected]>
billythemenace2 commented 2026-10-14 22:01:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T22:01:21Z.


@MarcZX100 This PR and your #5473 make the same recompiler change: a static image slot whose T# has TYPE 0 is materialized as a null image instead of throwing runtime image descriptor is invalid. Yours came first, together with #4779 on the binding side, so I'd like to agree with you on the order, as CONTRIBUTING asks.

The one place they differ is TYPE 1. This PR treats TYPE 1 as null too. #5473 uses TYPE 1 as a reserved type in its malformed-image fixtures. The measurement this PR relies on, from the hardware oracle on RDNA1 (gfx1010, RX 5700 XT): image_sample_lz, image_sample_b, image_load and image_get_resinfo through a format-22 T# of TYPE 1 return zeros in all four components without a fault, as TYPE 0 does. TYPE 1 is not measured on RDNA2. On the same card, a TYPE 2 T# left the driver unusable until a restart, so 2-7 stay refused here.

Two options:

  1. #5473 goes first and this PR is closed. If you think TYPE 1 should be null as well, it could move into #5473, or into a small follow-up of mine on top of it.
  2. This PR goes first and #5473 keeps only its snapshot changes (the captured-dword count and OutsideSnapshot poisoning).

I'm happy with either. Which do you prefer?

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179447515 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6179447515). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T22:01:21Z. --- @MarcZX100 This PR and your #5473 make the same recompiler change: a static image slot whose T# has TYPE 0 is materialized as a null image instead of throwing `runtime image descriptor is invalid`. Yours came first, together with #4779 on the binding side, so I'd like to agree with you on the order, as CONTRIBUTING asks. The one place they differ is TYPE 1. This PR treats TYPE 1 as null too. #5473 uses TYPE 1 as a reserved type in its malformed-image fixtures. The measurement this PR relies on, from the hardware oracle on RDNA1 (gfx1010, RX 5700 XT): `image_sample_lz`, `image_sample_b`, `image_load` and `image_get_resinfo` through a format-22 T# of TYPE 1 return zeros in all four components without a fault, as TYPE 0 does. TYPE 1 is not measured on RDNA2. On the same card, a TYPE 2 T# left the driver unusable until a restart, so 2-7 stay refused here. Two options: 1. #5473 goes first and this PR is closed. If you think TYPE 1 should be null as well, it could move into #5473, or into a small follow-up of mine on top of it. 2. This PR goes first and #5473 keeps only its snapshot changes (the captured-dword count and `OutsideSnapshot` poisoning). I'm happy with either. Which do you prefer? AI-assisted (Claude Code).
fdfawef324 commented 2026-10-14 23:23:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T23:23:38Z.


CPU replay of one Demon's Souls (PPSA01342) compute shader request that stops on a static-image TYPE 0 T#. No payload attached. Windows Server 2025 (10.0.26100), MinGW GCC 15.2 Release, ANYPS5_NO_SHADER_CACHE=1. RTX 3060 12 GB (driver 591.86) unused.

Each tree has #5959 (528bdf5f8) cherry-picked locally. --materialize gave the same result in 3 runs per tree:

tree --prepare --materialize
main 0ae1deb85 909476 SPIR-V words capture failed: runtime image descriptor is invalid
this PR 6f25722ba 909476 capture failed: buffer descriptor uses an unsupported type
#5473 4a7a38c43 909476 capture failed: buffer descriptor uses an unsupported type

Neither PR gets this shader past capture. Both clear the TYPE 0 image refusal and stop at the same buffer check. Same stop as my earlier port, now on the actual heads. Materialization was not reached, so the zeroed (this PR) and kept (#5473) T# words were not compared.

From the diffs: this PR cites the #4139 hardware measurements and keeps table entries refused. #5473 also nulls TYPE 0 table entries, citing a PPSA01341 run on an RTX 4070, not an AMD measurement.

The buffer stop is a separate issue: the shader reads a static read-only V# whose TYPE is not 0, but only under a lane-dependent guard. I'm preparing a follow-up that defers that check to the lanes that actually execute the read. With it stacked on this PR, the same request passes capture and materialization. It will say Depends on: #5828.

Not tested: game run, GPU execution, Linux, other ctests.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180693005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6180693005). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T23:23:38Z. --- CPU replay of one Demon's Souls (PPSA01342) compute shader request that stops on a static-image TYPE 0 T#. No payload attached. Windows Server 2025 (10.0.26100), MinGW GCC 15.2 Release, `ANYPS5_NO_SHADER_CACHE=1`. RTX 3060 12 GB (driver 591.86) unused. Each tree has #5959 (`528bdf5f8`) cherry-picked locally. `--materialize` gave the same result in 3 runs per tree: | tree | `--prepare` | `--materialize` | |---|---|---| | main `0ae1deb85` | 909476 SPIR-V words | capture failed: runtime image descriptor is invalid | | this PR `6f25722ba` | 909476 | capture failed: buffer descriptor uses an unsupported type | | #5473 `4a7a38c43` | 909476 | capture failed: buffer descriptor uses an unsupported type | Neither PR gets this shader past capture. Both clear the TYPE 0 image refusal and stop at the same buffer check. Same stop as my earlier port, now on the actual heads. Materialization was not reached, so the zeroed (this PR) and kept (#5473) T# words were not compared. From the diffs: this PR cites the #4139 hardware measurements and keeps table entries refused. #5473 also nulls TYPE 0 table entries, citing a PPSA01341 run on an RTX 4070, not an AMD measurement. The buffer stop is a separate issue: the shader reads a static read-only V# whose TYPE is not 0, but only under a lane-dependent guard. I'm preparing a follow-up that defers that check to the lanes that actually execute the read. With it stacked on this PR, the same request passes capture and materialization. It will say `Depends on: #5828`. Not tested: game run, GPU execution, Linux, other ctests. AI-assisted: yes
fdfawef324 commented 2026-10-15 01:06:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T01:06:19Z.


The null binding is applied to every static image slot, including slots the shader writes (image_store) or accesses atomically. The measurements in #4139 (gfx1036 TYPE 0, and gfx1010 TYPE 0 and 1 with format 22) only cover reads: image_sample_lz, image_sample, image_sample_b, image_load and image_get_resinfo. With this change, a store or atomic through such a T# is dropped instead of refused. An atomic returns 0. On a device without nullDescriptor, the store goes into the shared placeholder storage image, so a later null storage read in another dispatch returns that data instead of zeros.

Could the null binding be limited to slots the shader only reads? Written and atomic slots would keep throwing runtime image descriptor is invalid, as they do on main, until stores and atomics are measured:

bool nonImageDescriptor(const ImageResource& image, const DescriptorValue& descriptor) {
    return static_cast<std::uint32_t>(rawImageType(descriptor)) <= 1u && !image.written && !image.atomic;
}

and at the call site in materializeSnapshot, where image is already in scope:

        if ((activity < activeSources.size() && activeSources[activity] == 0u) || nonImageDescriptor(image, descriptor)) {

Test I used for this, appended to verifyGuardedDescriptorSources (it reuses its storeRequest, fill, samplerAndBuffer and typeOne; without the change both expectFailure calls fail):

    const std::vector<std::uint32_t> atomicCode{0xf40c0100u, 0xfa000000u, 0xbf8cc07fu, 0xf0440108u, 0x00010004u, 0xbf810000u};
    auto atomicRequest = request;
    atomicRequest.shader = {ShaderStage::Compute, 0x25000u, atomicCode, 0, {}};
    require(GetResourcePlan(atomicRequest)->info.images.size() == 1u && GetResourcePlan(atomicRequest)->info.images[0].atomic, "non-image words: image_atomic_add was not planned as an atomic image");
    for (const auto& words : {samplerAndBuffer, typeOne}) {
        fill(words, 1u);
        {
            AgcDriver::ShaderMemory memory({});
            expectFailure([&] { static_cast<void>(memory.Capture(storeRequest)); }, "runtime image descriptor is invalid", "non-image words: a T# of type 0 or 1 in a written image slot was bound as a null image");
        }
        {
            AgcDriver::ShaderMemory memory({});
            expectFailure([&] { static_cast<void>(memory.Capture(atomicRequest)); }, "runtime image descriptor is invalid", "non-image words: a T# of type 0 or 1 in an atomic image slot was bound as a null image");
        }
    }

The debt entry would then say "is bound as a null image when the shader only reads the slot, so every read returns zeros; a slot the shader writes or accesses atomically still throws."

Two further points, which I am only raising here and have not changed:

  • Depth-compare reads (image_sample_c*) through such a slot are not measured either. Demon's Souls (PPSA01342) reads type 0 slots with image_sample_c_lz behind v_cmpx / s_cbranch_execz, so refusing them would block it again. Recording them as unmeasured in the debt entry may be enough.
  • nonImageDescriptor also accepts IMG_FORMAT 0 (for example an S# with MAX_LOD 0 followed by a V#). The only hardware observation of that case I know of was a gfx1010 driver hang, and validImageDescriptor used to refuse format 0. The debt entry could note that format 0 is unmeasured, and that TYPE 1 rests on gfx1010 alone.

Demon's Souls still captures with this restriction, because all its slots of this kind are read-only. I replayed its failing dispatch offline (prepare, capture and materialize, with agc_shader_replay --materialize from #5959) on main + #5828 + the deferred static V# TYPE PR. It materializes the same 210839 SPIR-V words with or without the restriction. The dispatch also needs that PR, because one of its buffer slots holds a V# with TYPE 2.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182003168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6182003168). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T01:06:19Z. --- The null binding is applied to every static image slot, including slots the shader writes (`image_store`) or accesses atomically. The measurements in #4139 (gfx1036 TYPE 0, and gfx1010 TYPE 0 and 1 with format 22) only cover reads: `image_sample_lz`, `image_sample`, `image_sample_b`, `image_load` and `image_get_resinfo`. With this change, a store or atomic through such a T# is dropped instead of refused. An atomic returns 0. On a device without `nullDescriptor`, the store goes into the shared placeholder storage image, so a later null storage read in another dispatch returns that data instead of zeros. Could the null binding be limited to slots the shader only reads? Written and atomic slots would keep throwing `runtime image descriptor is invalid`, as they do on main, until stores and atomics are measured: ```cpp bool nonImageDescriptor(const ImageResource& image, const DescriptorValue& descriptor) { return static_cast<std::uint32_t>(rawImageType(descriptor)) <= 1u && !image.written && !image.atomic; } ``` and at the call site in `materializeSnapshot`, where `image` is already in scope: ```cpp if ((activity < activeSources.size() && activeSources[activity] == 0u) || nonImageDescriptor(image, descriptor)) { ``` Test I used for this, appended to `verifyGuardedDescriptorSources` (it reuses its `storeRequest`, `fill`, `samplerAndBuffer` and `typeOne`; without the change both `expectFailure` calls fail): ```cpp const std::vector<std::uint32_t> atomicCode{0xf40c0100u, 0xfa000000u, 0xbf8cc07fu, 0xf0440108u, 0x00010004u, 0xbf810000u}; auto atomicRequest = request; atomicRequest.shader = {ShaderStage::Compute, 0x25000u, atomicCode, 0, {}}; require(GetResourcePlan(atomicRequest)->info.images.size() == 1u && GetResourcePlan(atomicRequest)->info.images[0].atomic, "non-image words: image_atomic_add was not planned as an atomic image"); for (const auto& words : {samplerAndBuffer, typeOne}) { fill(words, 1u); { AgcDriver::ShaderMemory memory({}); expectFailure([&] { static_cast<void>(memory.Capture(storeRequest)); }, "runtime image descriptor is invalid", "non-image words: a T# of type 0 or 1 in a written image slot was bound as a null image"); } { AgcDriver::ShaderMemory memory({}); expectFailure([&] { static_cast<void>(memory.Capture(atomicRequest)); }, "runtime image descriptor is invalid", "non-image words: a T# of type 0 or 1 in an atomic image slot was bound as a null image"); } } ``` The debt entry would then say "is bound as a null image when the shader only reads the slot, so every read returns zeros; a slot the shader writes or accesses atomically still throws." Two further points, which I am only raising here and have not changed: - Depth-compare reads (`image_sample_c*`) through such a slot are not measured either. Demon's Souls (PPSA01342) reads type 0 slots with `image_sample_c_lz` behind `v_cmpx` / `s_cbranch_execz`, so refusing them would block it again. Recording them as unmeasured in the debt entry may be enough. - `nonImageDescriptor` also accepts IMG_FORMAT 0 (for example an S# with MAX_LOD 0 followed by a V#). The only hardware observation of that case I know of was a gfx1010 driver hang, and `validImageDescriptor` used to refuse format 0. The debt entry could note that format 0 is unmeasured, and that TYPE 1 rests on gfx1010 alone. Demon's Souls still captures with this restriction, because all its slots of this kind are read-only. I replayed its failing dispatch offline (prepare, capture and materialize, with `agc_shader_replay --materialize` from #5959) on main + #5828 + the deferred static V# TYPE PR. It materializes the same 210839 SPIR-V words with or without the restriction. The dispatch also needs that PR, because one of its buffer slots holds a V# with TYPE 2. AI-assisted: yes
MarcZX10 commented 2026-10-15 02:02:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T02:02:07Z.


Thanks for laying out the sequence and the scope difference. I prefer #5473 first as the narrower TYPE=0 change; it now accepts only static read-only image slots, with writes, atomics, and table entries still refused. Your TYPE=1 RDNA1 measurement and tests are useful evidence for a separate follow-up on top of #5473, preserving this PR’s authorship and the hardware-oracle report. Maintainers can choose the merge order. One remaining scope note: the read-only predicate also covers depth-compare reads, while the cited oracle does not measure image_sample_c*; the Demon’s Souls capture exercises image_sample_c_lz, so that specific path remains unmeasured even though the title’s four reported static slots are read-only. I have recorded it as uncertainty rather than claiming it is covered by the existing measurements.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182690140 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6182690140). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T02:02:07Z. --- Thanks for laying out the sequence and the scope difference. I prefer #5473 first as the narrower TYPE=0 change; it now accepts only static read-only image slots, with writes, atomics, and table entries still refused. Your TYPE=1 RDNA1 measurement and tests are useful evidence for a separate follow-up on top of #5473, preserving this PR’s authorship and the hardware-oracle report. Maintainers can choose the merge order. One remaining scope note: the read-only predicate also covers depth-compare reads, while the cited oracle does not measure `image_sample_c*`; the Demon’s Souls capture exercises `image_sample_c_lz`, so that specific path remains unmeasured even though the title’s four reported static slots are read-only. I have recorded it as uncertainty rather than claiming it is covered by the existing measurements.
github-actions[bot] commented 2026-10-15 12:10:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:10:02Z.


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
PR 6215 docs/dev/debt/libSceAgcDriver.md L46-47
PR 6498 docs/dev/debt/libSceAgcDriver.md L46-47

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/Optimization/src/ResourceMaterializer.cpp
PR 1341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 1896 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4650 docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 5499 docs/dev/debt/libSceAgcDriver.md
PR 5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5761 docs/dev/debt/libSceAgcDriver.md
PR 5867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 5875 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6054 docs/dev/debt/libSceAgcDriver.md
PR 6160 docs/dev/debt/libSceAgcDriver.md
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6252 docs/dev/debt/libSceAgcDriver.md
PR 6312 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6454 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/libSceAgcDriver.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191711596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6191711596). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:10:02Z. --- <!-- 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 | |---|---|---|---| | [PR 6215](https://www.github.com/boykopovar/AnyPS5/pull/6215) | `docs/dev/debt/libSceAgcDriver.md` [L46-47](https://github.com/boykopovar/AnyPS5/blob/a4782fe11d35943b5b1635ca499d922a817bb987/docs/dev/debt/libSceAgcDriver.md#L46-L47) | | | | [PR 6498](https://www.github.com/boykopovar/AnyPS5/pull/6498) | `docs/dev/debt/libSceAgcDriver.md` [L46-47](https://github.com/boykopovar/AnyPS5/blob/a4782fe11d35943b5b1635ca499d922a817bb987/docs/dev/debt/libSceAgcDriver.md#L46-L47) | | | 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](https://www.github.com/boykopovar/AnyPS5/pull/907) | `core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 1896](https://www.github.com/boykopovar/AnyPS5/pull/1896) | `core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5058](https://www.github.com/boykopovar/AnyPS5/pull/5058) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5761](https://www.github.com/boykopovar/AnyPS5/pull/5761) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5867](https://www.github.com/boykopovar/AnyPS5/pull/5867) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 5875](https://www.github.com/boykopovar/AnyPS5/pull/5875) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6054](https://www.github.com/boykopovar/AnyPS5/pull/6054) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6160](https://www.github.com/boykopovar/AnyPS5/pull/6160) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6252](https://www.github.com/boykopovar/AnyPS5/pull/6252) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 6312](https://www.github.com/boykopovar/AnyPS5/pull/6312) | `core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6454](https://www.github.com/boykopovar/AnyPS5/pull/6454) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` |
adriadam10 commented 2026-10-15 13:18:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:18:33Z.

Review: CHANGES_REQUESTED


Thanks for the measurements. #5473 merged today and covers the TYPE 0 part of this change, so this PR now conflicts and mostly duplicates main. What is left is TYPE 1, so please rework it into that follow-up:

  • Rebase on main and drop the TYPE 0 handling. nullImageDescriptor(const ImageResource&, const DescriptorValue&) in ResourceMaterializer.cpp already nulls a TYPE 0 T# in a static, read-only slot (no table, no write, no atomic). Extend that predicate for TYPE 1 instead of adding nonImageDescriptor.
  • Keep written and atomic slots refused, as on main. The #4139 measurements (gfx1036 TYPE 0, gfx1010 TYPE 0/1 with format 22) only cover image_sample_lz, image_sample, image_sample_b, image_load and image_get_resinfo; see @fdfawef324's comment above for how a dropped store/atomic behaves.
  • The TYPE 1 evidence is gfx1010 with format 22 only. Say in the docs/dev/debt/shader.md entry that TYPE 1 is not measured on RDNA2/gfx1013, nor with other formats, nor with depth-compare reads (image_sample_c*).
  • Keep the TYPE 1 case in verifyGuardedDescriptorSources (it must fail without the change), plus a case showing a TYPE 1 T# in a written/atomic slot is still refused. Check the test still passes after the rebase, since #5473 changed that file.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5533725988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#pullrequestreview-5533725988). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T13:18:33Z. **Review:** CHANGES_REQUESTED --- Thanks for the measurements. #5473 merged today and covers the TYPE 0 part of this change, so this PR now conflicts and mostly duplicates main. What is left is TYPE 1, so please rework it into that follow-up: - Rebase on `main` and drop the TYPE 0 handling. `nullImageDescriptor(const ImageResource&, const DescriptorValue&)` in `ResourceMaterializer.cpp` already nulls a TYPE 0 T# in a static, read-only slot (no table, no write, no atomic). Extend that predicate for TYPE 1 instead of adding `nonImageDescriptor`. - Keep written and atomic slots refused, as on main. The #4139 measurements (gfx1036 TYPE 0, gfx1010 TYPE 0/1 with format 22) only cover `image_sample_lz`, `image_sample`, `image_sample_b`, `image_load` and `image_get_resinfo`; see @fdfawef324's comment above for how a dropped store/atomic behaves. - The TYPE 1 evidence is gfx1010 with format 22 only. Say in the `docs/dev/debt/shader.md` entry that TYPE 1 is not measured on RDNA2/gfx1013, nor with other formats, nor with depth-compare reads (`image_sample_c*`). - Keep the TYPE 1 case in `verifyGuardedDescriptorSources` (it must fail without the change), plus a case showing a TYPE 1 T# in a written/atomic slot is still refused. Check the test still passes after the rebase, since #5473 changed that file.
fdfawef324 commented 2026-10-15 14:16:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T14:16:07Z.


#6412 handles the buffer stop described above. It does not depend on this PR after all: with #5473 merged, current main reaches that same buffer stop on the Demon's Souls dispatch, and #6412 materializes it on main alone.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194231374 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6194231374). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T14:16:07Z. --- #6412 handles the buffer stop described above. It does not depend on this PR after all: with #5473 merged, current `main` reaches that same buffer stop on the Demon's Souls dispatch, and #6412 materializes it on `main` alone. AI-assisted: yes
billythemenace2 commented 2026-10-15 15:17:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-15T15:17:36Z.


@adriadam10 Reworked as you asked, in 01d3594c2 on main 92e50418f:

  • The TYPE 0 handling is gone. nullImageDescriptor(const ImageResource&, const DescriptorValue&) now accepts TYPE 1 in the same static, read-only slots. Written, atomic and table slots still throw.
  • IsNullTextureResource in the driver also accepts TYPE 1. Without that, the T# the recompiler keeps would not be bound as null.
  • Tests: verifyTypeZeroImageMaterialization runs for TYPE 0 and 1, including the written and atomic refusals. verifyGuardedDescriptorSources has a read-only TYPE 1 case, and its invalid T# is now the reserved TYPE 2. The driver test adds TYPE 1 (null) and TYPE 2 (not null). They fail with main's two source files and pass with the change.
  • Debt: I extended the two TYPE 0 entries in docs/dev/debt/libSceAgcDriver.md rather than adding one to shader.md, so both types are described in one place. They say TYPE 1 is measured only on gfx1010 with format 22, not on RDNA2/gfx1013, with other formats or with image_sample_c*. If you'd prefer a separate shader.md entry, I'll move it.

The title and description are updated to match.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195555693 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6195555693). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-15T15:17:36Z. --- @adriadam10 Reworked as you asked, in `01d3594c2` on `main` `92e50418f`: - The TYPE 0 handling is gone. `nullImageDescriptor(const ImageResource&, const DescriptorValue&)` now accepts TYPE 1 in the same static, read-only slots. Written, atomic and table slots still throw. - `IsNullTextureResource` in the driver also accepts TYPE 1. Without that, the T# the recompiler keeps would not be bound as null. - Tests: `verifyTypeZeroImageMaterialization` runs for TYPE 0 and 1, including the written and atomic refusals. `verifyGuardedDescriptorSources` has a read-only TYPE 1 case, and its invalid T# is now the reserved TYPE 2. The driver test adds TYPE 1 (null) and TYPE 2 (not null). They fail with main's two source files and pass with the change. - Debt: I extended the two TYPE 0 entries in `docs/dev/debt/libSceAgcDriver.md` rather than adding one to `shader.md`, so both types are described in one place. They say TYPE 1 is measured only on gfx1010 with format 22, not on RDNA2/gfx1013, with other formats or with `image_sample_c*`. If you'd prefer a separate `shader.md` entry, I'll move it. The title and description are updated to match. AI-assisted (Claude Code).
coltken95 commented 2026-10-15 19:57:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T19:57:34Z.


Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2) at the reworked head 01d3594c2, merged into main 44df21632:

  • With the PR: all 17 tests built from the changed test files pass.
  • With main's sources, 3 fail:
    • agc_shader_type_zero_image_materialization and agc_shader_memory: runtime image descriptor is invalid
    • agc_driver_graphics: AGC graphics: a type-1 texture with a nonzero base was not classified as null

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6201056003 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#issuecomment-6201056003). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-15T19:57:34Z. --- Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2) at the reworked head 01d3594c2, merged into main 44df21632: - With the PR: all 17 tests built from the changed test files pass. - With main's sources, 3 fail: - `agc_shader_type_zero_image_materialization` and `agc_shader_memory`: `runtime image descriptor is invalid` - `agc_driver_graphics`: `AGC graphics: a type-1 texture with a nonzero base was not classified as null` AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-16 09:47:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T09:47:53Z.

Review: APPROVED


Checked the rework against the four points: only TYPE 1 is added on top of main's read-only static slot predicate, written/atomic slots are still refused, the debt entries state the unmeasured cases, and the TYPE 1 cases in verifyGuardedDescriptorSources/verifyTypeZeroImageMaterialization fail without the change (agc_shader_type_zero_image_materialization, agc_shader_memory, agc_driver_graphics). Also measured on gfx1035: TYPE 1 returns zeros like TYPE 0 for image_sample_lz, image_load, image_get_resinfo and image_sample_c_lz with formats 22 and 10, TYPE 9 returns texels. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5545956163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5828#pullrequestreview-5545956163). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T09:47:53Z. **Review:** APPROVED --- Checked the rework against the four points: only TYPE 1 is added on top of main's read-only static slot predicate, written/atomic slots are still refused, the debt entries state the unmeasured cases, and the TYPE 1 cases in `verifyGuardedDescriptorSources`/`verifyTypeZeroImageMaterialization` fail without the change (`agc_shader_type_zero_image_materialization`, `agc_shader_memory`, `agc_driver_graphics`). Also measured on gfx1035: TYPE 1 returns zeros like TYPE 0 for `image_sample_lz`, `image_load`, `image_get_resinfo` and `image_sample_c_lz` with formats 22 and 10, TYPE 9 returns texels. Merging.
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!5828
No description provided.