KhronosGroup / KhronosGroup/SPIRV-Guide
ArrayStride and MatrixStride
- Dominant language
- GLSL
- Stars
- 247
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
The `ArrayStride` and `MatrixStride` difference is confusing when trying to get the size of a struct
Some internal notes I wrote putting here for safe keeping:
The matrix type is created to define the mathematical concept, not having to do with how it's laid out in memory. That's nice from the perspective that it means you don't have to change types when passing a matrix as a parameter, or deciding in the compiler to put it in registers vs. making a local variable. (local variables don't have layout).
The MatrixStride is an attribute of the variable or struct member that has matrix type, or array-of or array-of-array-of matrix, etc.
It's a weird wrinkle, yes. But it goes down to defining the type by its mathematical properties
layouts are properties of variables in memory.
Check the logical addressing: you've got an access chain: first in
dex must fit in the matrix type's column count; second index must fit in the column vector's element count
don't think of it as a physical address
-----
related internal issues
https://gitlab.khronos.org/vulkan/vulkan/-/issues/4121
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/763
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/462
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/688
https://gitlab.khronos.org/spirv/SPIR-V/-/issues/179
----
OpMemberDecorate %Bar 0 MatrixStride 16
and
OpDecorate %_arr_mat3v3float_uint_8 ArrayStride 48
https://godbolt.org/z/YKz86afha
Contributor guide
Research direction
No file, test, or documentation page is identified. Start by reviewing the ArrayStride and MatrixStride notes and the linked SPIR-V and Vulkan issues, then define a concrete guide location and verify that it clearly explains the distinction and examples.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100