fix(shader): ignore unused descriptor fields for scalar buffer loads #5049

Merged
eljackjoestar-cmd merged 2 commits from upstream-pr/5049 into main 2026-10-14 10:06:34 +00:00
eljackjoestar-cmd commented 2026-10-13 09:40:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-13T09:40:39Z.


What

A scalar-only s_buffer_load_* resource can carry non-buffer fields in its descriptor. The recompiler previously rejected word 3's TYPE; this PR normalizes word 3 only for scalar-only resources. Review also found that Kena reached ShaderResources::addGuestBuffer and stopped on reserved bit 30 of word 1. The same scalar-only normalization now clears that bit before building the driver-visible descriptor, preserving base address, stride and record count.

Vector, mixed scalar/vector, formatted, writable, atomic and image-alias resources retain their validation. No driver-wide acceptance of reserved bits is added.

Semantics source: AMD RDNA2 ISA §7.2.1, printed page 52 (PDF page 60), describes the scalar buffer fields as base address, stride and record count, with other fields ignored: https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf . Native console/ISA comparison of the ignored reserved bit is not claimed.

Lost Soul Aside (PPSA26358), captured shader 0x12c2298400, previously stopped on unsupported descriptor TYPE. A Kena run reported in review exposed the later reserved-bit rejection. This addresses those validation rules; no new Kena game run or completed gameplay is claimed.

Tested

Rebased onto current main f87799aa3, Windows 11 Pro, GCC 15.2, Release, SPIRV-Tools OFF. Full Windows build passed.

The new native regression failed before the reserved-bit normalization with AGC graphics: buffer descriptor has reserved bits set. With the fix, every lane receives the expected scalar value across both reserved-bit states and four word-3 patterns (including image-shaped TYPE and all bits set). Vector-only and mixed scalar/vector resources still reject non-buffer TYPE during recompilation and reserved word-1 bits during driver dispatch.

  • NVIDIA RTX 5070, driver 617.14: four focused tests passed without skips in 1.93 s: agc_driver_buffer_descriptor_runtime, agc_shader_memory, agc_driver_buffer_load_store, agc_driver_scalar_wide_loads.
  • AMD Radeon integrated gfx1036, driver 32.0.21036.18: the three Vulkan buffer/scalar tests passed without skips in 1.25 s.
  • Conventions and whitespace checks passed. Linux/full-suite/CI and complete game playability are not claimed. These checks use this branch alone on the stated main, not the combined title integration.

Checklist

  • Based on current main; no equivalent open PR found
  • One topic per PR
  • No comments in code added
  • Unimplemented paths throw; no silent stubs
  • No investigation files, requests, logs or screenshots added to the repository
  • No third-party code added
  • Generic scalar-load behaviour; vector/mixed validation retained
  • Depends on: none
  • Unblocks: PPSA26358 #4401 (one descriptor-validation blocker; later blockers remain)
  • GPUs tested: NVIDIA RTX 5070 / 617.14 and AMD Radeon integrated gfx1036 / 32.0.21036.18, Windows 11 Pro 10.0.26300
  • AI-assisted: yes, OpenAI Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4841317413 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-13T09:40:39Z. --- ### What A scalar-only `s_buffer_load_*` resource can carry non-buffer fields in its descriptor. The recompiler previously rejected word 3's TYPE; this PR normalizes word 3 only for scalar-only resources. Review also found that Kena reached `ShaderResources::addGuestBuffer` and stopped on reserved bit 30 of word 1. The same scalar-only normalization now clears that bit before building the driver-visible descriptor, preserving base address, stride and record count. Vector, mixed scalar/vector, formatted, writable, atomic and image-alias resources retain their validation. No driver-wide acceptance of reserved bits is added. Semantics source: AMD RDNA2 ISA §7.2.1, printed page 52 (PDF page 60), describes the scalar buffer fields as base address, stride and record count, with other fields ignored: https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf . Native console/ISA comparison of the ignored reserved bit is not claimed. Lost Soul Aside (PPSA26358), captured shader `0x12c2298400`, previously stopped on unsupported descriptor TYPE. A Kena run reported in review exposed the later reserved-bit rejection. This addresses those validation rules; no new Kena game run or completed gameplay is claimed. ### Tested Rebased onto current main `f87799aa3`, Windows 11 Pro, GCC 15.2, Release, SPIRV-Tools OFF. Full Windows build passed. The new native regression failed before the reserved-bit normalization with `AGC graphics: buffer descriptor has reserved bits set`. With the fix, every lane receives the expected scalar value across both reserved-bit states and four word-3 patterns (including image-shaped TYPE and all bits set). Vector-only and mixed scalar/vector resources still reject non-buffer TYPE during recompilation and reserved word-1 bits during driver dispatch. - NVIDIA RTX 5070, driver 617.14: four focused tests passed without skips in 1.93 s: `agc_driver_buffer_descriptor_runtime`, `agc_shader_memory`, `agc_driver_buffer_load_store`, `agc_driver_scalar_wide_loads`. - AMD Radeon integrated gfx1036, driver 32.0.21036.18: the three Vulkan buffer/scalar tests passed without skips in 1.25 s. - Conventions and whitespace checks passed. Linux/full-suite/CI and complete game playability are not claimed. These checks use this branch alone on the stated main, not the combined title integration. ### Checklist - [x] Based on current `main`; no equivalent open PR found - [x] One topic per PR - [x] No comments in code added - [x] Unimplemented paths throw; no silent stubs - [x] No investigation files, requests, logs or screenshots added to the repository - [x] No third-party code added - [x] Generic scalar-load behaviour; vector/mixed validation retained - [x] Depends on: none - [x] Unblocks: PPSA26358 #4401 (one descriptor-validation blocker; later blockers remain) - [x] GPUs tested: NVIDIA RTX 5070 / 617.14 and AMD Radeon integrated gfx1036 / 32.0.21036.18, Windows 11 Pro 10.0.26300 - [x] AI-assisted: yes, OpenAI Codex
alfalfa-star commented 2026-10-13 17:08:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-13T17:08:00Z.


Tested on Kena: Bridge of Spirits (PPSA01802), Linux/RADV (RX 9070 XT), on main 0214069e3 with this PR merged.

Kena has the same pattern: a pixel shader binds a T# in buffer slot 1 and reads it only with scalar loads. The read extent is 108 to 112 bytes, first used at pc 0x94. One example of the words is 20f56700 caa00000 03ffc3ff 909c0fac.

  • Without this PR, those draws stop at buffer descriptor uses an unsupported type (about 7.1k skips in a 5 minute run).
  • With this PR the recompiler accepts them, and the type refusal is gone. The same draws now stop in the driver instead: ShaderResources::addGuestBuffer checks word 1 bit 30 before anything else and refuses with buffer descriptor has reserved bits set (1,353 skips in the same window). The T#'s word 1 (0xcaa00000) has that bit set, and this PR only normalizes word 3.
  • Read as a V#, the base is 0x20f56700 (T# word 0 plus the low 16 bits of word 1). That address isn't registered guest memory here (RegisteredReadableEnd returns 0). Stride × NUM_RECORDS from the T# words also comes out at several GB, over maxStorageBufferRange.

So for this title the scalar-only case also needs the driver path to stop validating fields that s_buffer_load doesn't use, and to decide what an unmapped base reads. As a local test only, I bound it as an empty buffer, and Kena then reaches its combat tutorial with the arena lit. I'm not claiming that is the right upstream behaviour.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150946914 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049#issuecomment-6150946914). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-13T17:08:00Z. --- Tested on Kena: Bridge of Spirits (PPSA01802), Linux/RADV (RX 9070 XT), on main 0214069e3 with this PR merged. Kena has the same pattern: a pixel shader binds a T# in buffer slot 1 and reads it only with scalar loads. The read extent is 108 to 112 bytes, first used at pc 0x94. One example of the words is `20f56700 caa00000 03ffc3ff 909c0fac`. - Without this PR, those draws stop at `buffer descriptor uses an unsupported type` (about 7.1k skips in a 5 minute run). - With this PR the recompiler accepts them, and the type refusal is gone. The same draws now stop in the driver instead: `ShaderResources::addGuestBuffer` checks word 1 bit 30 before anything else and refuses with `buffer descriptor has reserved bits set` (1,353 skips in the same window). The T#'s word 1 (`0xcaa00000`) has that bit set, and this PR only normalizes word 3. - Read as a V#, the base is `0x20f56700` (T# word 0 plus the low 16 bits of word 1). That address isn't registered guest memory here (`RegisteredReadableEnd` returns 0). Stride × NUM_RECORDS from the T# words also comes out at several GB, over `maxStorageBufferRange`. So for this title the scalar-only case also needs the driver path to stop validating fields that `s_buffer_load` doesn't use, and to decide what an unmapped base reads. As a local test only, I bound it as an empty buffer, and Kena then reaches its combat tutorial with the arena lit. I'm not claiming that is the right upstream behaviour.
oneandonlydean commented 2026-10-14 05:10:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:10:41Z.


The conventions check fails because the body lost the template sections (What, Tested, Checklist); please put them back.
alfalfa-star's Kena run shows the same scalar-only T# now stops in the driver instead: ShaderResources::addGuestBuffer refuses word 1 with buffer descriptor has reserved bits set. If s_buffer_load ignores those fields, the driver check needs the same rule for scalar-only buffers, otherwise the titles still stop. Can you cover that here?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161391220 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049#issuecomment-6161391220). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:10:41Z. --- The conventions check fails because the body lost the template sections (What, Tested, Checklist); please put them back. alfalfa-star's Kena run shows the same scalar-only T# now stops in the driver instead: `ShaderResources::addGuestBuffer` refuses word 1 with `buffer descriptor has reserved bits set`. If `s_buffer_load` ignores those fields, the driver check needs the same rule for scalar-only buffers, otherwise the titles still stop. Can you cover that here?
eljackjoestar-cmd commented 2026-10-14 07:51:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-14T07:51:46Z.


Restored the What, Tested and Checklist sections and rebased onto f87799aa3. The scalar-only snapshot normalization now also clears reserved bit 30 of word 1 before the driver-visible binding is built, while preserving the base, stride and record count. The general driver check remains strict for vector/mixed and other non-scalar-only uses.

The new native case failed before the change with AGC graphics: buffer descriptor has reserved bits set. With afd9b92b0, all scalar readbacks pass across both word-1 states and four word-3 patterns; vector-only and mixed uses still reject reserved bits during dispatch and non-buffer TYPE during recompilation. Full Windows Release build, four focused NVIDIA checks and three AMD Vulkan checks pass without skips; conventions pass. I have not rerun Kena itself, so this is an end-to-end driver regression result, not a new Kena gameplay claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6163601506 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049#issuecomment-6163601506). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-14T07:51:46Z. --- Restored the `What`, `Tested` and `Checklist` sections and rebased onto `f87799aa3`. The scalar-only snapshot normalization now also clears reserved bit 30 of word 1 before the driver-visible binding is built, while preserving the base, stride and record count. The general driver check remains strict for vector/mixed and other non-scalar-only uses. The new native case failed before the change with `AGC graphics: buffer descriptor has reserved bits set`. With `afd9b92b0`, all scalar readbacks pass across both word-1 states and four word-3 patterns; vector-only and mixed uses still reject reserved bits during dispatch and non-buffer TYPE during recompilation. Full Windows Release build, four focused NVIDIA checks and three AMD Vulkan checks pass without skips; conventions pass. I have not rerun Kena itself, so this is an end-to-end driver regression result, not a new Kena gameplay claim.
oneandonlydean commented 2026-10-14 09:43:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T09:43:19Z.


Rebased onto main: kept both debt entries in docs/dev/debt/shader.md; build and shader tests pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165489503 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049#issuecomment-6165489503). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T09:43:19Z. --- Rebased onto main: kept both debt entries in `docs/dev/debt/shader.md`; build and shader tests pass.
p3n1cillin commented 2026-10-14 14:33:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-14T14:33:08Z.


Heads-up @eljackjoestar-cmd: a first-parent bisect points at this merge for a regression in Surround Sound Studio (PPSA99051). It exits about 3 s in with [ps5-agc] submission retirement failed on Windows/NVIDIA, and is fine on eecf90953. Details and the bisect table are in #5876.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6170811346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5049#issuecomment-6170811346). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-14T14:33:08Z. --- Heads-up @eljackjoestar-cmd: a first-parent bisect points at this merge for a regression in Surround Sound Studio (PPSA99051). It exits about 3 s in with `[ps5-agc] submission retirement failed` on Windows/NVIDIA, and is fine on `eecf90953`. Details and the bisect table are in #5876.
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!5049
No description provided.