Fix validation errors in native matrix shaders #73

Merged
klimovich008 merged 6 commits from codex/cooperative-memory-model into main 2026-11-07 23:46:13 +00:00
klimovich008 commented 2026-11-07 08:55:24 +00:00 (Migrated from github.com)

What this fixes

Native cooperative-matrix shaders declare CooperativeMatrixKHR with GLSL450, failing SPIR-V validation. Device-scope barriers also require the corresponding Vulkan memory-model capability.

Why merge

  • Use the Vulkan memory model for native matrices and their self-test.
  • Require both memory-model features before enabling native matrices; preserve physical addressing.
  • Preserve upstream's default-on robust buffer access and RX_VK_ROBUST=0 opt-out.
  • Software matrix and ordinary shader paths stay unchanged.

Change

  • gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp: native capabilities/model.
  • gpu/vk/vk_coopmat.cpp: self-test memory model.
  • gpu/vk/vk_main.cpp: required feature gating.
  • gpu/vk/sirit/include/sirit/sirit.h: declare addressing-preserving setter.
  • gpu/vk/sirit/src/sirit.cpp: implement setter.
  • nx2/test_coop_spirv.py: seven native/software/ordinary and physical-addressing cases.

Tested

In a compiler developer shell with builder CPM cache in RX_CPM and SPIR-V Tools on PATH:

python nx2/test_coop_spirv.py --headers "$env:RX_CPM/spirv-headers/vulkan-sdk-1.4.341.0/include" --spirv-val spirv-val --cxx clang++

Fails on the old code, passes now. All seven cases and CPU syntax checks pass. Local RX 9070 XT lacks the required native matrix configuration.

Contributor RTX 2070 test, driver 621.01: builds and runs with native matrices enabled; unrelated device loss remains at frame 1071, as without this change.

Please check

NVIDIA execution is contributor-reported, not locally reproduced. This does not claim to fix #132 or improve performance.

## What this fixes Native cooperative-matrix shaders declare `CooperativeMatrixKHR` with GLSL450, failing SPIR-V validation. Device-scope barriers also require the corresponding Vulkan memory-model capability. ## Why merge - Use the Vulkan memory model for native matrices and their self-test. - Require both memory-model features before enabling native matrices; preserve physical addressing. - Preserve upstream's default-on robust buffer access and `RX_VK_ROBUST=0` opt-out. - Software matrix and ordinary shader paths stay unchanged. ## Change - `gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv.cpp`: native capabilities/model. - `gpu/vk/vk_coopmat.cpp`: self-test memory model. - `gpu/vk/vk_main.cpp`: required feature gating. - `gpu/vk/sirit/include/sirit/sirit.h`: declare addressing-preserving setter. - `gpu/vk/sirit/src/sirit.cpp`: implement setter. - `nx2/test_coop_spirv.py`: seven native/software/ordinary and physical-addressing cases. ## Tested In a compiler developer shell with builder CPM cache in `RX_CPM` and SPIR-V Tools on PATH: ```powershell python nx2/test_coop_spirv.py --headers "$env:RX_CPM/spirv-headers/vulkan-sdk-1.4.341.0/include" --spirv-val spirv-val --cxx clang++ ``` Fails on the old code, passes now. All seven cases and CPU syntax checks pass. Local RX 9070 XT lacks the required native matrix configuration. [Contributor RTX 2070 test, driver 621.01](https://git.magicbean.dev/MagicBeanDev/Hookshot/pulls/73): builds and runs with native matrices enabled; unrelated device loss remains at frame 1071, as without this change. ## Please check NVIDIA execution is contributor-reported, not locally reproduced. This does not claim to fix #132 or improve performance.
leonidasmark commented 2026-11-07 16:04:11 +00:00 (Migrated from github.com)

Tested this on an RTX 2070 (Turing, driver 621.01), merged onto c02f290: it built and ran, with "native matrix multiplies on", but the GPU was still lost in a compute dispatch (frame 1071), as without it. So on Turing it does not fix that hang, though it may still be right for the spec. (On 1c7c9c7 with driver 621.14 the native path has since run stably without it; details in #132.)

Tested this on an RTX 2070 (Turing, driver 621.01), merged onto c02f290: it built and ran, with "native matrix multiplies on", but the GPU was still lost in a compute dispatch (frame 1071), as without it. So on Turing it does not fix that hang, though it may still be right for the spec. (On 1c7c9c7 with driver 621.14 the native path has since run stably without it; details in #132.)
klimovich008 commented 2026-11-07 16:08:30 +00:00 (Migrated from github.com)

Thanks for testing on Turing! That confirms the native path builds and runs with the Vulkan memory model enabled. Agreed, this isn't a fix for the #132 hang; it only makes the cooperative-matrix shaders valid SPIR-V, since the spec requires VulkanMemoryModel alongside CooperativeMatrixKHR. Glad 1c7c9c7 + 621.14 resolved the hang separately.

Thanks for testing on Turing! That confirms the native path builds and runs with the Vulkan memory model enabled. Agreed, this isn't a fix for the #132 hang; it only makes the cooperative-matrix shaders valid SPIR-V, since the spec requires `VulkanMemoryModel` alongside `CooperativeMatrixKHR`. Glad 1c7c9c7 + 621.14 resolved the hang separately.
Commenting is not possible because the repository is archived.
No description provided.