Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
CnRJay:fix/shader-memory-select
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
CnRJay:fix/shader-memory-select

Conversation

@CnRJay

@CnRJay CnRJay commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

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

…-V 1.3

TableResult selected a uvec4 with a scalar bool condition, which needs
SPIR-V 1.4. Targets at 1.3 failed validation (agc_shader_memory with
ANYPS5_ENABLE_SPIRV_TOOLS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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).

@oneandonlydean
oneandonlydean merged commit 9651ec9 into boykopovar:main Oct 4, 2026
4 of 5 checks passed
adriadam10 pushed a commit that referenced this pull request Oct 10, 2026
…IR-V 1.3

The FMASK identity read selected a uvec4 with a scalar bool condition,
which needs SPIR-V 1.4. Devices without mesh shaders target 1.3, so
every image test that reaches the path failed validation with
ANYPS5_ENABLE_SPIRV_TOOLS (#2138), as in #574.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants