Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapters/images/location_example_matrix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions chapters/location_component_interface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A matrix is viewed as an array of vector, this means something like
A matrix is stored as an array of vector, this means something like

"Viewed as" implies something else.


[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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from a `Location`/`Component` point-of-view looks like
consumes locations and components identically to


[source,glsl]
----
Expand All @@ -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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Just like vector, depending on the size, it may not consume the whole `Location`. This means the following is allowed.
which in turn is stored identically to
[source,glsl]
----
// Each vector consumes only the first 2 components of each location
layout(location = 0) vec2 a0;
layout(location = 1) vec2 a1;
layout(location = 2) vec2 a2;
----
This means the following is allowed:

Also the "Arrays consume whole location" comment above is wrong - where did that come from?


[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].
Comment on lines +162 to +163
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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].
Unlike arrays or independent vectors, link:https://godbolt.org/z/f81PvP538[matrices cannot be decorated with `Component`], so will always be packed from component 0.

Maybe? "In front" seems overly vague to me.

====