Skip to content

ArrayStride and MatrixStride #36

@spencer-lunarg

Description

@spencer-lunarg

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions