fix(shader): splat the bindless table hit into a bool vector for SPIR-V 1.3 #574

Merged
CnRJay merged 1 commit from upstream-pr/574 into main 2026-10-04 23:59:54 +00:00
CnRJay commented 2026-10-04 23:05:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-04T23:05:16Z.


What

TableResult (bindless image tables) emitted OpSelect %v4uint <scalar bool> .... A scalar condition on a vector select is only valid from SPIR-V 1.4, and the recompiler also accepts 1.3 targets (the emitter default, and the target agc_shader_memory uses). With -DANYPS5_ENABLE_SPIRV_TOOLS=ON the test failed:

Expected vector sizes of Result Type and the condition to be equal: Select
  %299 = OpSelect %v4uint %265 %297 %298

The condition is now built into a bvec4 with OpCompositeConstruct first. This is valid in every SPIR-V version and gives the same result.

Tested

Windows 11, MinGW GCC 15.2.0 r7, NVIDIA Vulkan, -DANYPS5_ENABLE_SPIRV_TOOLS=ON: agc_shader_memory now passes, and the full ctest run passes 213/213.

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 (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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4738298067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/574). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-04T23:05:16Z. --- ### What `TableResult` (bindless image tables) emitted `OpSelect %v4uint <scalar bool> ...`. A scalar condition on a vector select is only valid from SPIR-V 1.4, and the recompiler also accepts 1.3 targets (the emitter default, and the target `agc_shader_memory` uses). With `-DANYPS5_ENABLE_SPIRV_TOOLS=ON` the test failed: ``` Expected vector sizes of Result Type and the condition to be equal: Select %299 = OpSelect %v4uint %265 %297 %298 ``` The condition is now built into a `bvec4` with `OpCompositeConstruct` first. This is valid in every SPIR-V version and gives the same result. ### Tested Windows 11, MinGW GCC 15.2.0 r7, NVIDIA Vulkan, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`: `agc_shader_memory` now passes, and the full `ctest` run passes 213/213. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-04 23:44:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T23:44:03Z.


Thanks. A scalar condition on a vector OpSelect is only valid from SPIR-V 1.4, and the runtime builds every non-mesh shader for 1.3 (VulkanDevice.cpp, meshShader ? 0x00010400 : 0x00010300), so every bindless-table image op on main emits invalid SPIR-V that drivers happen to accept. Splatting the condition into a bvec4 gives the same per-component result in every version, and this is the only vector select with a scalar condition I could find. The shader cache version is derived from the recompiler sources, so existing caches are rebuilt automatically.

There's no new test, since agc_shader_memory only validates with -DANYPS5_ENABLE_SPIRV_TOOLS=ON, which is off by default and in CI. I built it that way: on main it fails with "Expected vector sizes of Result Type and the condition to be equal: Select" (OpSelect %v4uint with a scalar condition), and on this branch it passes. That's enough for a fix like this.

Ready to merge from my side once CI has run (it still needs approval).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985702878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/574#issuecomment-5985702878). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T23:44:03Z. --- Thanks. A scalar condition on a vector `OpSelect` is only valid from SPIR-V 1.4, and the runtime builds every non-mesh shader for 1.3 (`VulkanDevice.cpp`, `meshShader ? 0x00010400 : 0x00010300`), so every bindless-table image op on main emits invalid SPIR-V that drivers happen to accept. Splatting the condition into a `bvec4` gives the same per-component result in every version, and this is the only vector select with a scalar condition I could find. The shader cache version is derived from the recompiler sources, so existing caches are rebuilt automatically. There's no new test, since `agc_shader_memory` only validates with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, which is off by default and in CI. I built it that way: on main it fails with "Expected vector sizes of Result Type and the condition to be equal: Select" (`OpSelect %v4uint` with a scalar condition), and on this branch it passes. That's enough for a fix like this. Ready to merge from my side once CI has run (it still needs approval).
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!574
No description provided.