don't use position name twice to prevent collision on macos metal

This commit is contained in:
Anton-4 2022-02-19 17:06:18 +01:00
parent b1245ffd7f
commit 50928d8578
No known key found for this signature in database
GPG key ID: C954D6E0F9C0ABFD
3 changed files with 4 additions and 4 deletions

View file

@ -90,7 +90,7 @@ pub fn create_rect_buffers(
pub fn to_quad(rect_elt: &RectElt) -> Quad { pub fn to_quad(rect_elt: &RectElt) -> Quad {
Quad { Quad {
position: rect_elt.rect.top_left_coords.into(), pos: rect_elt.rect.top_left_coords.into(),
width: rect_elt.rect.width, width: rect_elt.rect.width,
height: rect_elt.rect.height, height: rect_elt.rect.height,
color: to_slice(rect_elt.color), color: to_slice(rect_elt.color),

View file

@ -3,7 +3,7 @@
/// A polygon with 4 corners /// A polygon with 4 corners
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Quad { pub struct Quad {
pub position: [f32; 2], pub pos: [f32; 2],
pub width: f32, pub width: f32,
pub height: f32, pub height: f32,
pub color: [f32; 4], pub color: [f32; 4],

View file

@ -13,7 +13,7 @@ struct VertexInput {
}; };
struct Quad { struct Quad {
@location(1) position: vec2<f32>; @location(1) pos: vec2<f32>; // can't use the name "position" twice for compatibility with metal on MacOS
@location(2) width: f32; @location(2) width: f32;
@location(3) height: f32; @location(3) height: f32;
@location(4) color: vec4<f32>; @location(4) color: vec4<f32>;
@ -38,7 +38,7 @@ fn vs_main(
vec4<f32>(quad.width, 0.0, 0.0, 0.0), vec4<f32>(quad.width, 0.0, 0.0, 0.0),
vec4<f32>(0.0, quad.height, 0.0, 0.0), vec4<f32>(0.0, quad.height, 0.0, 0.0),
vec4<f32>(0.0, 0.0, 1.0, 0.0), vec4<f32>(0.0, 0.0, 1.0, 0.0),
vec4<f32>(quad.position, 0.0, 1.0) vec4<f32>(quad.pos, 0.0, 1.0)
); );
var out: VertexOutput; var out: VertexOutput;