Skip to content

spirv-opt: Handle OpTypeVectorIdEXT in fix-storage-class access chains - #6971

Merged
s-perron merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:fix-storage-class-vector-id
Oct 14, 2026
Merged

s-perron merged 1 commit into
KhronosGroup:mainfrom
apollo-2006:fix-storage-class-vector-id

Conversation

@apollo-2006

Copy link
Copy Markdown
Contributor

--fix-storage-class (and so --legalize-hlsl) turns valid long-vector SPIR-V invalid:

OpAccessChain result type <id> (OpTypeVectorIdEXT) does not match the type that results from indexing into the base <id> (OpTypeFloat)

WalkAccessChainType steps into the element type for vectors, arrays, matrices and coop matrices, but not OpTypeVectorIdEXT, so it "fixes" a correct pointer-to-component into a pointer to the whole vector. This adds the missing case. I noticed it running glslang's spv.longVectorSpecConst.comp and spv.coopvec.comp through spirv-opt.

Added FixStorageClassTest.AccessChainIntoLongVector, and test_opt passes. A few other passes probably need the same case too, happy to look into those if that's useful :)

@s-perron
s-perron enabled auto-merge (squash) October 14, 2026 16:07
@s-perron
s-perron merged commit 35fe089 into KhronosGroup:main Oct 14, 2026
25 of 27 checks passed
s-perron pushed a commit that referenced this pull request Oct 30, 2026
…ss chains (#6982)

Same as #6971, but for NV cooperative matrices. `WalkAccessChainType`
didn't step into `OpTypeCooperativeMatrixNV`, so `--fix-storage-class`
turned a correct pointer-to-component access chain into a pointer to the
whole matrix:

```
OpAccessChain result type <id> (OpTypeCooperativeMatrixNV) does not match the type that results from indexing into the base <id> (OpTypeFloat)
```

glslang's `spv.coopmat.comp` and `spv.intcoopmat.comp` hit this. Added
the case next to the KHR one, with a test :)
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.

3 participants