Skip to content

Commit

Permalink
[msl-out] Permit invariant qualifier on vertex shader outputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy authored and teoxoy committed Apr 12, 2022
1 parent 4e4d918 commit 78975f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ impl Options {
return Err(Error::UnsupportedAttribute("invariant".to_string()));
}

// The 'invariant' attribute can only appear on vertex
// shader outputs, but not fragment shader inputs.
Ok(ResolvedBinding::BuiltIn {
built_in,
invariant: invariant && matches!(mode, LocationMode::FragmentOutput),
invariant: invariant && matches!(mode, LocationMode::VertexOutput),
})
}
crate::Binding::Location {
Expand Down
4 changes: 2 additions & 2 deletions tests/out/msl/interface.msl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct vertex_Input {
uint color [[attribute(10)]];
};
struct vertex_Output {
metal::float4 position [[position]];
metal::float4 position [[position, invariant]];
float varying [[user(loc1), center_perspective]];
float _point_size [[point_size]];
};
Expand Down Expand Up @@ -84,7 +84,7 @@ kernel void compute_(
struct vertex_two_structsInput {
};
struct vertex_two_structsOutput {
metal::float4 member_3 [[position]];
metal::float4 member_3 [[position, invariant]];
float _point_size [[point_size]];
};
vertex vertex_two_structsOutput vertex_two_structs(
Expand Down

0 comments on commit 78975f2

Please sign in to comment.