diff --git a/chapters/images/location_example_matrix.svg b/chapters/images/location_example_matrix.svg index ab98e3f..e400b5e 100644 --- a/chapters/images/location_example_matrix.svg +++ b/chapters/images/location_example_matrix.svg @@ -1,4 +1,4 @@ -
undef
Location 0
0        1        2        3
Location 1
components
undef
undef
Location 2
undef
undef
a
a
a
b
Invalid
a
a
a
\ No newline at end of file +
undef
undef
Location 0
Location 0
0        1        2        3
0        1        2        3
Location 1
Location 1
components
components
undef
undef
Location 2
Location 2
undef
undef
undef
undef
a
a
a
a
a
a
b
b
a
a
a
a
a
a
c
c
\ No newline at end of file diff --git a/chapters/location_component_interface.adoc b/chapters/location_component_interface.adoc index ad1912f..5f7b924 100644 --- a/chapters/location_component_interface.adoc +++ b/chapters/location_component_interface.adoc @@ -128,16 +128,14 @@ Some shader stages, like geometry shaders, have an array around its interface ma == Matrix -A matrix is viewed as an array, which consume all 4 components. - -So something like +A matrix is viewed as an array of vector, this means something like [source,glsl] ---- layout(location = 0) in mat3x2 a; ---- -From a `Location`/`Component` point-of-view looks like +from a `Location`/`Component` point-of-view looks like [source,glsl] ---- @@ -146,14 +144,21 @@ From a `Location`/`Component` point-of-view looks like layout(location = 0) in vec2 a[3]; ---- -As stated above, arrays consume the whole `Location` so the following is **not** allowed. +Just like vector, depending on the size, it may not consume the whole `Location`. This means the following is allowed. [source,glsl] ---- layout(location = 0) in mat3x2 a; -layout(location = 2, component = 2) in float b; +layout(location = 1, component = 2) in float b; +layout(location = 2, component = 2) in float c; ---- -`float b` is invalid because the implicit array of the matrix consumes all of `Location` 2. +The `b` and `c` float are still valid here. image::{images}location_example_matrix.svg[location_example_matrix] + +[NOTE] +==== +You don't need to worry about things going "in front" of a matrix because the `Component` decoration +link:https://godbolt.org/z/f81PvP538[can not be applied on a matrix type]. +==== \ No newline at end of file