diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 59c7048c33..37d8f23005 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -159,7 +159,7 @@ impl Writer { ], }; - self.write_attributes(&attributes, false)?; + self.write_attributes(&attributes)?; // Add a newline after attribute writeln!(self.out)?; @@ -244,11 +244,10 @@ impl Writer { for (index, arg) in func.arguments.iter().enumerate() { // Write argument attribute if a binding is present if let Some(ref binding) = arg.binding { - self.write_attributes( - &map_binding_to_attribute(binding, module.types[arg.ty].inner.scalar_kind()), - false, - )?; - write!(self.out, " ")?; + self.write_attributes(&map_binding_to_attribute( + binding, + module.types[arg.ty].inner.scalar_kind(), + ))?; } // Write argument name let argument_name = match func_ctx.ty { @@ -275,10 +274,10 @@ impl Writer { if let Some(ref result) = func.result { write!(self.out, " -> ")?; if let Some(ref binding) = result.binding { - self.write_attributes( - &map_binding_to_attribute(binding, module.types[result.ty].inner.scalar_kind()), - true, - )?; + self.write_attributes(&map_binding_to_attribute( + binding, + module.types[result.ty].inner.scalar_kind(), + ))?; } self.write_type(module, result.ty)?; } @@ -331,30 +330,9 @@ impl Writer { } /// Helper method to write a attribute - /// - /// # Notes - /// Adds an extra space if required - fn write_attributes(&mut self, attributes: &[Attribute], extra_space: bool) -> BackendResult { - write!(self.out, "[[")?; - - let mut need_last_comma = true; - if let Some(last_attrib) = attributes.last() { - // We duplicate the logic a little, but this will help to avoid extra heap allocation - match *last_attrib { - Attribute::BuiltIn(builtin_attrib) => { - need_last_comma = builtin_str(builtin_attrib).is_some(); - } - Attribute::Interpolate(interpolation, sampling) => { - need_last_comma = (sampling.is_some() - && sampling != Some(crate::Sampling::Center)) - || (interpolation.is_some() - && interpolation != Some(crate::Interpolation::Perspective)) - } - _ => {} - } - } - - for (index, attribute) in attributes.iter().enumerate() { + fn write_attributes(&mut self, attributes: &[Attribute]) -> BackendResult { + for attribute in attributes { + write!(self.out, "@")?; match *attribute { Attribute::Location(id) => write!(self.out, "location({})", id)?, Attribute::BuiltIn(builtin_attrib) => { @@ -366,11 +344,11 @@ impl Writer { } Attribute::Stage(shader_stage) => { let stage_str = match shader_stage { - ShaderStage::Vertex => "stage(vertex)", - ShaderStage::Fragment => "stage(fragment)", - ShaderStage::Compute => "stage(compute)", + ShaderStage::Vertex => "vertex", + ShaderStage::Fragment => "fragment", + ShaderStage::Compute => "compute", }; - write!(self.out, "{}", stage_str)?; + write!(self.out, "stage({})", stage_str)?; } Attribute::Stride(stride) => write!(self.out, "stride({})", stride)?, Attribute::WorkGroupSize(size) => { @@ -405,19 +383,8 @@ impl Writer { } } }; - - // Only write a comma if isn't the last element - if index + 1 != attributes.len() && need_last_comma { - // The leading space is for readability only - write!(self.out, ", ")?; - } - } - - write!(self.out, "]]")?; - if extra_space { write!(self.out, " ")?; } - Ok(()) } @@ -447,10 +414,10 @@ impl Writer { // The indentation is only for readability write!(self.out, "{}", back::INDENT)?; if let Some(ref binding) = member.binding { - self.write_attributes( - &map_binding_to_attribute(binding, module.types[member.ty].inner.scalar_kind()), - true, - )?; + self.write_attributes(&map_binding_to_attribute( + binding, + module.types[member.ty].inner.scalar_kind(), + ))?; } // Write struct member name and type let member_name = &self.names[&NameKey::StructMember(handle, index as u32)]; @@ -462,7 +429,7 @@ impl Writer { stride, } = module.types[member.ty].inner { - self.write_attributes(&[Attribute::Stride(stride)], true)?; + self.write_attributes(&[Attribute::Stride(stride)])?; } self.write_type(module, member.ty)?; write!(self.out, ";")?; @@ -1716,13 +1683,10 @@ impl Writer { ) -> BackendResult { // Write group and dinding attributes if present if let Some(ref binding) = global.binding { - self.write_attributes( - &[ - Attribute::Group(binding.group), - Attribute::Binding(binding.binding), - ], - false, - )?; + self.write_attributes(&[ + Attribute::Group(binding.group), + Attribute::Binding(binding.binding), + ])?; writeln!(self.out)?; } diff --git a/src/front/wgsl/lexer.rs b/src/front/wgsl/lexer.rs index be419fd42b..fab07cc8f1 100644 --- a/src/front/wgsl/lexer.rs +++ b/src/front/wgsl/lexer.rs @@ -315,7 +315,8 @@ fn consume_token(mut input: &str, generic: bool) -> (Token<'_>, &str) { _ => (Token::Separator(cur), og_chars), } } - '(' | ')' | '{' | '}' => (Token::Paren(cur), chars.as_str()), + '@' => (Token::Attribute, chars.as_str()), + '(' | ')' | '{' | '}' | '[' | ']' => (Token::Paren(cur), chars.as_str()), '<' | '>' => { input = chars.as_str(); let next = chars.next(); @@ -332,14 +333,6 @@ fn consume_token(mut input: &str, generic: bool) -> (Token<'_>, &str) { (Token::Paren(cur), input) } } - '[' | ']' => { - input = chars.as_str(); - if chars.next() == Some(cur) { - (Token::DoubleParen(cur), chars.as_str()) - } else { - (Token::Paren(cur), input) - } - } '0'..='9' => consume_number(input), '_' | 'a'..='z' | 'A'..='Z' => { let (word, rest) = consume_any(input, |c| c.is_ascii_alphanumeric() || c == '_'); @@ -678,9 +671,9 @@ fn test_tokens() { #[test] fn test_variable_decl() { sub_test( - "[[ group(0 )]] var< uniform> texture: texture_multisampled_2d ;", + "@group(0 ) var< uniform> texture: texture_multisampled_2d ;", &[ - Token::DoubleParen('['), + Token::Attribute, Token::Word("group"), Token::Paren('('), Token::Number { @@ -689,7 +682,6 @@ fn test_variable_decl() { width: None, }, Token::Paren(')'), - Token::DoubleParen(']'), Token::Word("var"), Token::Paren('<'), Token::Word("uniform"), diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index 5b7c343554..b500025aef 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -57,7 +57,7 @@ pub enum Token<'a> { Separator(char), DoubleColon, Paren(char), - DoubleParen(char), + Attribute, Number { value: &'a str, ty: NumberType, @@ -88,11 +88,9 @@ pub enum ExpectedToken<'a> { Constant, /// Expected: constant, parenthesized expression, identifier PrimaryExpression, - /// Expected: ']]', ',' - AttributeSeparator, /// Expected: '}', identifier FieldName, - /// Expected: ']]', 'access', 'stride' + /// Expected: attribute for a type TypeAttribute, /// Expected: ';', '{', word Statement, @@ -102,8 +100,6 @@ pub enum ExpectedToken<'a> { WorkgroupSizeSeparator, /// Expected: 'struct', 'let', 'var', 'type', ';', 'fn', eof GlobalItem, - /// Expected: ']]', 'size', 'align' - StructAttribute, } #[derive(Clone, Debug, Error)] @@ -167,6 +163,7 @@ pub enum Error<'a> { UnknownLocalFunction(Span), InitializationTypeMismatch(Span, String), MissingType(Span), + MissingAttribute(&'static str, Span), InvalidAtomicPointer(Span), InvalidAtomicOperandType(Span), Pointer(&'static str, Span), @@ -190,7 +187,7 @@ impl<'a> Error<'a> { Token::Separator(c) => format!("'{}'", c), Token::DoubleColon => "'::'".to_string(), Token::Paren(c) => format!("'{}'", c), - Token::DoubleParen(c) => format!("'{}{}'", c, c), + Token::Attribute => "@".to_string(), Token::Number { value, .. } => { format!("number ({})", value) } @@ -232,14 +229,12 @@ impl<'a> Error<'a> { ExpectedToken::Integer => "unsigned/signed integer literal".to_string(), ExpectedToken::Constant => "constant".to_string(), ExpectedToken::PrimaryExpression => "expression".to_string(), - ExpectedToken::AttributeSeparator => "attribute separator (',') or an end of the attribute list (']]')".to_string(), ExpectedToken::FieldName => "field name or a closing curly bracket to signify the end of the struct".to_string(), ExpectedToken::TypeAttribute => "type attribute ('stride') or an end of the attribute list (']]')".to_string(), ExpectedToken::Statement => "statement".to_string(), ExpectedToken::SwitchItem => "switch item ('case' or 'default') or a closing curly bracket to signify the end of the switch statement ('}')".to_string(), ExpectedToken::WorkgroupSizeSeparator => "workgroup size separator (',') or a closing parenthesis".to_string(), ExpectedToken::GlobalItem => "global item ('struct', 'let', 'var', 'type', ';', 'fn') or the end of the file".to_string(), - ExpectedToken::StructAttribute => "struct attribute ('size' or 'align') or an end of the attribute list (']]')".to_string(), }; ParseError { message: format!( @@ -426,6 +421,11 @@ impl<'a> Error<'a> { labels: vec![(name_span.clone(), format!("definition of `{}`", &source[name_span.clone()]).into())], notes: vec![], }, + Error::MissingAttribute(name, ref name_span) => ParseError { + message: format!("variable `{}` needs a '{}' attribute", &source[name_span.clone()], name), + labels: vec![(name_span.clone(), format!("definition of `{}`", &source[name_span.clone()]).into())], + notes: vec![], + }, Error::InvalidAtomicPointer(ref span) => ParseError { message: "atomic operation is done on a pointer to a non-atomic".to_string(), labels: vec![(span.clone(), "atomic pointer is invalid".into())], @@ -2828,51 +2828,23 @@ impl Parser { let (mut size, mut align) = (None, None); self.push_scope(Scope::Attribute, lexer); let mut bind_parser = BindingParser::default(); - if lexer.skip(Token::DoubleParen('[')) { - let mut ready = true; - loop { - match lexer.next() { - (Token::DoubleParen(']'), _) => { - break; - } - (Token::Separator(','), _) if !ready => { - ready = true; - } - (Token::Word(word), word_span) if ready => { - match word { - "size" => { - lexer.expect(Token::Paren('('))?; - let (value, span) = lexer.capture_span(|lexer| { - parse_non_negative_sint_literal(lexer, 4) - })?; - lexer.expect(Token::Paren(')'))?; - size = Some( - NonZeroU32::new(value) - .ok_or(Error::ZeroSizeOrAlign(span))?, - ); - } - "align" => { - lexer.expect(Token::Paren('('))?; - let (value, span) = lexer.capture_span(|lexer| { - parse_non_negative_sint_literal(lexer, 4) - })?; - lexer.expect(Token::Paren(')'))?; - align = Some( - NonZeroU32::new(value) - .ok_or(Error::ZeroSizeOrAlign(span))?, - ); - } - _ => bind_parser.parse(lexer, word, word_span)?, - } - ready = false; - } - other if ready => { - return Err(Error::Unexpected(other, ExpectedToken::StructAttribute)) - } - other => { - return Err(Error::Unexpected(other, ExpectedToken::AttributeSeparator)) - } + while lexer.skip(Token::Attribute) { + match lexer.next_ident_with_span()? { + ("size", _) => { + lexer.expect(Token::Paren('('))?; + let (value, span) = lexer + .capture_span(|lexer| parse_non_negative_sint_literal(lexer, 4))?; + lexer.expect(Token::Paren(')'))?; + size = Some(NonZeroU32::new(value).ok_or(Error::ZeroSizeOrAlign(span))?); } + ("align", _) => { + lexer.expect(Token::Paren('('))?; + let (value, span) = lexer + .capture_span(|lexer| parse_non_negative_sint_literal(lexer, 4))?; + lexer.expect(Token::Paren(')'))?; + align = Some(NonZeroU32::new(value).ok_or(Error::ZeroSizeOrAlign(span))?); + } + (word, word_span) => bind_parser.parse(lexer, word, word_span)?, } } @@ -3268,21 +3240,18 @@ impl Parser { self.push_scope(Scope::TypeDecl, lexer); let mut attribute = TypeAttributes::default(); - if lexer.skip(Token::DoubleParen('[')) { + while lexer.skip(Token::Attribute) { self.push_scope(Scope::Attribute, lexer); - loop { - match lexer.next() { - (Token::Word("stride"), _) => { - lexer.expect(Token::Paren('('))?; - let (stride, span) = lexer - .capture_span(|lexer| parse_non_negative_sint_literal(lexer, 4))?; - attribute.stride = - Some(NonZeroU32::new(stride).ok_or(Error::ZeroStride(span))?); - lexer.expect(Token::Paren(')'))?; - } - (Token::DoubleParen(']'), _) => break, - other => return Err(Error::Unexpected(other, ExpectedToken::TypeAttribute)), + match lexer.next() { + (Token::Word("stride"), _) => { + lexer.expect(Token::Paren('('))?; + let (stride, span) = + lexer.capture_span(|lexer| parse_non_negative_sint_literal(lexer, 4))?; + attribute.stride = + Some(NonZeroU32::new(stride).ok_or(Error::ZeroStride(span))?); + lexer.expect(Token::Paren(')'))?; } + other => return Err(Error::Unexpected(other, ExpectedToken::TypeAttribute)), } self.pop_scope(lexer); } @@ -4006,24 +3975,12 @@ impl Parser { &mut self, lexer: &mut Lexer<'a>, ) -> Result, Error<'a>> { + let mut bind_parser = BindingParser::default(); self.push_scope(Scope::Attribute, lexer); - if !lexer.skip(Token::DoubleParen('[')) { - self.pop_scope(lexer); - return Ok(None); - } - - let mut bind_parser = BindingParser::default(); - loop { + while lexer.skip(Token::Attribute) { let (word, span) = lexer.next_ident_with_span()?; bind_parser.parse(lexer, word, span)?; - match lexer.next() { - (Token::DoubleParen(']'), _) => { - break; - } - (Token::Separator(','), _) => {} - other => return Err(Error::Unexpected(other, ExpectedToken::AttributeSeparator)), - } } let span = self.pop_scope(lexer); @@ -4172,83 +4129,77 @@ impl Parser { ) -> Result> { // read attributes let mut binding = None; - // Perspective is the default qualifier. let mut stage = None; let mut workgroup_size = [0u32; 3]; let mut early_depth_test = None; + let (mut bind_index, mut bind_group) = (None, None); - if lexer.skip(Token::DoubleParen('[')) { - let (mut bind_index, mut bind_group) = (None, None); - self.push_scope(Scope::Attribute, lexer); - loop { - match lexer.next_ident_with_span()? { - ("binding", _) => { - lexer.expect(Token::Paren('('))?; - bind_index = Some(parse_non_negative_sint_literal(lexer, 4)?); - lexer.expect(Token::Paren(')'))?; - } - ("group", _) => { - lexer.expect(Token::Paren('('))?; - bind_group = Some(parse_non_negative_sint_literal(lexer, 4)?); - lexer.expect(Token::Paren(')'))?; - } - ("stage", _) => { - lexer.expect(Token::Paren('('))?; - let (ident, ident_span) = lexer.next_ident_with_span()?; - stage = Some(conv::map_shader_stage(ident, ident_span)?); - lexer.expect(Token::Paren(')'))?; - } - ("workgroup_size", _) => { - lexer.expect(Token::Paren('('))?; - for (i, size) in workgroup_size.iter_mut().enumerate() { - *size = parse_generic_non_negative_int_literal(lexer, 4)?; - match lexer.next() { - (Token::Paren(')'), _) => break, - (Token::Separator(','), _) if i != 2 => (), - other => { - return Err(Error::Unexpected( - other, - ExpectedToken::WorkgroupSizeSeparator, - )) - } - } - } - for size in workgroup_size.iter_mut() { - if *size == 0 { - *size = 1; + self.push_scope(Scope::Attribute, lexer); + while lexer.skip(Token::Attribute) { + match lexer.next_ident_with_span()? { + ("binding", _) => { + lexer.expect(Token::Paren('('))?; + bind_index = Some(parse_non_negative_sint_literal(lexer, 4)?); + lexer.expect(Token::Paren(')'))?; + } + ("group", _) => { + lexer.expect(Token::Paren('('))?; + bind_group = Some(parse_non_negative_sint_literal(lexer, 4)?); + lexer.expect(Token::Paren(')'))?; + } + ("stage", _) => { + lexer.expect(Token::Paren('('))?; + let (ident, ident_span) = lexer.next_ident_with_span()?; + stage = Some(conv::map_shader_stage(ident, ident_span)?); + lexer.expect(Token::Paren(')'))?; + } + ("workgroup_size", _) => { + lexer.expect(Token::Paren('('))?; + for (i, size) in workgroup_size.iter_mut().enumerate() { + *size = parse_generic_non_negative_int_literal(lexer, 4)?; + match lexer.next() { + (Token::Paren(')'), _) => break, + (Token::Separator(','), _) if i != 2 => (), + other => { + return Err(Error::Unexpected( + other, + ExpectedToken::WorkgroupSizeSeparator, + )) } } } - ("early_depth_test", _) => { - let conservative = if lexer.skip(Token::Paren('(')) { - let (ident, ident_span) = lexer.next_ident_with_span()?; - let value = conv::map_conservative_depth(ident, ident_span)?; - lexer.expect(Token::Paren(')'))?; - Some(value) - } else { - None - }; - early_depth_test = Some(crate::EarlyDepthTest { conservative }); + for size in workgroup_size.iter_mut() { + if *size == 0 { + *size = 1; + } } - (_, word_span) => return Err(Error::UnknownAttribute(word_span)), } - match lexer.next() { - (Token::DoubleParen(']'), _) => { - break; - } - (Token::Separator(','), _) => {} - other => { - return Err(Error::Unexpected(other, ExpectedToken::AttributeSeparator)) - } + ("early_depth_test", _) => { + let conservative = if lexer.skip(Token::Paren('(')) { + let (ident, ident_span) = lexer.next_ident_with_span()?; + let value = conv::map_conservative_depth(ident, ident_span)?; + lexer.expect(Token::Paren(')'))?; + Some(value) + } else { + None + }; + early_depth_test = Some(crate::EarlyDepthTest { conservative }); } + (_, word_span) => return Err(Error::UnknownAttribute(word_span)), } - if let (Some(group), Some(index)) = (bind_group, bind_index) { + } + + let attrib_scope = self.pop_scope(lexer); + match (bind_group, bind_index) { + (Some(group), Some(index)) => { binding = Some(crate::ResourceBinding { group, binding: index, }); } - self.pop_scope(lexer); + (Some(_), None) => return Err(Error::MissingAttribute("binding", attrib_scope)), + (None, Some(_)) => return Err(Error::MissingAttribute("group", attrib_scope)), + (None, None) => {} } // read items diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs index 60c02c4e6d..bb415fa7cd 100644 --- a/src/front/wgsl/tests.rs +++ b/src/front/wgsl/tests.rs @@ -159,9 +159,9 @@ fn parse_struct() { " struct Foo { x: i32; }; struct Bar { - [[size(16)]] x: vec2; - [[align(16)]] y: f32; - [[size(32), align(8)]] z: vec3; + @size(16) x: vec2; + @align(16) y: f32; + @size(32) @align(8) z: vec3; }; struct Empty {}; var s: Foo; @@ -384,7 +384,7 @@ fn parse_struct_instantiation() { b: vec3; }; - [[stage(fragment)]] + @stage(fragment) fn fs_main() { var foo: Foo = Foo(0.0, vec3(0.0, 1.0, 42.0)); } @@ -398,13 +398,13 @@ fn parse_array_length() { parse_str( " struct Foo { - data: [[stride(4)]] array; + data: @stride(4) array; }; // this is used as both input and output for convenience - [[group(0), binding(0)]] + @group(0) @binding(0) var foo: Foo; - [[group(0), binding(1)]] + @group(0) @binding(1) var bar: array; fn baz() { @@ -420,28 +420,28 @@ fn parse_array_length() { fn parse_storage_buffers() { parse_str( " - [[group(0), binding(0)]] + @group(0) @binding(0) var foo: array; ", ) .unwrap(); parse_str( " - [[group(0), binding(0)]] + @group(0) @binding(0) var foo: array; ", ) .unwrap(); parse_str( " - [[group(0), binding(0)]] + @group(0) @binding(0) var foo: array; ", ) .unwrap(); parse_str( " - [[group(0), binding(0)]] + @group(0) @binding(0) var foo: array; ", ) diff --git a/tests/in/access.wgsl b/tests/in/access.wgsl index ed088e7de1..ce26cb8a4c 100644 --- a/tests/in/access.wgsl +++ b/tests/in/access.wgsl @@ -4,19 +4,19 @@ struct Bar { matrix: mat4x4; matrix_array: array, 2>; atom: atomic; - arr: [[stride(8)]] array, 2>; - data: [[stride(8)]] array; + arr: @stride(8) array, 2>; + data: @stride(8) array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var bar: Bar; fn read_from_private(foo: ptr) -> f32 { return *foo; } -[[stage(vertex)]] -fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { +@stage(vertex) +fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { var foo: f32 = 0.0; // We should check that backed doesn't skip this expression let baz: f32 = foo; @@ -47,7 +47,7 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { return matrix * vec4(vec4(value)); } -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn atomics() { var tmp: i32; let value = atomicLoad(&bar.atom); diff --git a/tests/in/bits.wgsl b/tests/in/bits.wgsl index 4bec623aa4..6851f243f5 100644 --- a/tests/in/bits.wgsl +++ b/tests/in/bits.wgsl @@ -1,4 +1,4 @@ -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn main() { var i = 0; var i2 = vec2(0); diff --git a/tests/in/boids.wgsl b/tests/in/boids.wgsl index 5e712ac56c..1cc54cfc48 100644 --- a/tests/in/boids.wgsl +++ b/tests/in/boids.wgsl @@ -16,16 +16,16 @@ struct SimParams { }; struct Particles { - particles : [[stride(16)]] array; + particles : @stride(16) array; }; -[[group(0), binding(0)]] var params : SimParams; -[[group(0), binding(1)]] var particlesSrc : Particles; -[[group(0), binding(2)]] var particlesDst : Particles; +@group(0) @binding(0) var params : SimParams; +@group(0) @binding(1) var particlesSrc : Particles; +@group(0) @binding(2) var particlesDst : Particles; // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp -[[stage(compute), workgroup_size(64)]] -fn main([[builtin(global_invocation_id)]] global_invocation_id : vec3) { +@stage(compute) @workgroup_size(64) +fn main(@builtin(global_invocation_id) global_invocation_id : vec3) { let index : u32 = global_invocation_id.x; if (index >= NUM_PARTICLES) { return; diff --git a/tests/in/bounds-check-image-restrict.wgsl b/tests/in/bounds-check-image-restrict.wgsl index e2f9131832..d308452911 100644 --- a/tests/in/bounds-check-image-restrict.wgsl +++ b/tests/in/bounds-check-image-restrict.wgsl @@ -1,81 +1,81 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var image_1d: texture_1d; fn test_textureLoad_1d(coords: i32, level: i32) -> vec4 { return textureLoad(image_1d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_2d: texture_2d; fn test_textureLoad_2d(coords: vec2, level: i32) -> vec4 { return textureLoad(image_2d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_2d_array: texture_2d_array; fn test_textureLoad_2d_array(coords: vec2, index: i32, level: i32) -> vec4 { return textureLoad(image_2d_array, coords, index, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_3d: texture_3d; fn test_textureLoad_3d(coords: vec3, level: i32) -> vec4 { return textureLoad(image_3d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_multisampled_2d: texture_multisampled_2d; fn test_textureLoad_multisampled_2d(coords: vec2, sample: i32) -> vec4 { return textureLoad(image_multisampled_2d, coords, sample); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_2d: texture_depth_2d; fn test_textureLoad_depth_2d(coords: vec2, level: i32) -> f32 { return textureLoad(image_depth_2d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_2d_array: texture_depth_2d_array; fn test_textureLoad_depth_2d_array(coords: vec2, index: i32, level: i32) -> f32 { return textureLoad(image_depth_2d_array, coords, index, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_multisampled_2d: texture_depth_multisampled_2d; fn test_textureLoad_depth_multisampled_2d(coords: vec2, sample: i32) -> f32 { return textureLoad(image_depth_multisampled_2d, coords, sample); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_1d: texture_storage_1d; fn test_textureStore_1d(coords: i32, value: vec4) { textureStore(image_storage_1d, coords, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_2d: texture_storage_2d; fn test_textureStore_2d(coords: vec2, value: vec4) { textureStore(image_storage_2d, coords, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_2d_array: texture_storage_2d_array; fn test_textureStore_2d_array(coords: vec2, array_index: i32, value: vec4) { textureStore(image_storage_2d_array, coords, array_index, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_3d: texture_storage_3d; fn test_textureStore_3d(coords: vec3, value: vec4) { diff --git a/tests/in/bounds-check-image-rzsw.wgsl b/tests/in/bounds-check-image-rzsw.wgsl index e2f9131832..d308452911 100644 --- a/tests/in/bounds-check-image-rzsw.wgsl +++ b/tests/in/bounds-check-image-rzsw.wgsl @@ -1,81 +1,81 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var image_1d: texture_1d; fn test_textureLoad_1d(coords: i32, level: i32) -> vec4 { return textureLoad(image_1d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_2d: texture_2d; fn test_textureLoad_2d(coords: vec2, level: i32) -> vec4 { return textureLoad(image_2d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_2d_array: texture_2d_array; fn test_textureLoad_2d_array(coords: vec2, index: i32, level: i32) -> vec4 { return textureLoad(image_2d_array, coords, index, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_3d: texture_3d; fn test_textureLoad_3d(coords: vec3, level: i32) -> vec4 { return textureLoad(image_3d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_multisampled_2d: texture_multisampled_2d; fn test_textureLoad_multisampled_2d(coords: vec2, sample: i32) -> vec4 { return textureLoad(image_multisampled_2d, coords, sample); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_2d: texture_depth_2d; fn test_textureLoad_depth_2d(coords: vec2, level: i32) -> f32 { return textureLoad(image_depth_2d, coords, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_2d_array: texture_depth_2d_array; fn test_textureLoad_depth_2d_array(coords: vec2, index: i32, level: i32) -> f32 { return textureLoad(image_depth_2d_array, coords, index, level); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_depth_multisampled_2d: texture_depth_multisampled_2d; fn test_textureLoad_depth_multisampled_2d(coords: vec2, sample: i32) -> f32 { return textureLoad(image_depth_multisampled_2d, coords, sample); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_1d: texture_storage_1d; fn test_textureStore_1d(coords: i32, value: vec4) { textureStore(image_storage_1d, coords, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_2d: texture_storage_2d; fn test_textureStore_2d(coords: vec2, value: vec4) { textureStore(image_storage_2d, coords, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_2d_array: texture_storage_2d_array; fn test_textureStore_2d_array(coords: vec2, array_index: i32, value: vec4) { textureStore(image_storage_2d_array, coords, array_index, value); } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_storage_3d: texture_storage_3d; fn test_textureStore_3d(coords: vec3, value: vec4) { diff --git a/tests/in/bounds-check-restrict.wgsl b/tests/in/bounds-check-restrict.wgsl index 8550fd7033..fefcdec0cd 100644 --- a/tests/in/bounds-check-restrict.wgsl +++ b/tests/in/bounds-check-restrict.wgsl @@ -7,7 +7,7 @@ struct Globals { d: array; }; -[[group(0), binding(0)]] var globals: Globals; +@group(0) @binding(0) var globals: Globals; fn index_array(i: i32) -> f32 { return globals.a[i]; diff --git a/tests/in/bounds-check-zero.wgsl b/tests/in/bounds-check-zero.wgsl index 4838701c23..e1a05ac927 100644 --- a/tests/in/bounds-check-zero.wgsl +++ b/tests/in/bounds-check-zero.wgsl @@ -7,7 +7,7 @@ struct Globals { d: array; }; -[[group(0), binding(0)]] var globals: Globals; +@group(0) @binding(0) var globals: Globals; fn index_array(i: i32) -> f32 { return globals.a[i]; diff --git a/tests/in/collatz.wgsl b/tests/in/collatz.wgsl index 878b18d09b..f4341c24a6 100644 --- a/tests/in/collatz.wgsl +++ b/tests/in/collatz.wgsl @@ -1,8 +1,8 @@ struct PrimeIndices { - data: [[stride(4)]] array; + data: @stride(4) array; }; // this is used as both input and output for convenience -[[group(0), binding(0)]] +@group(0) @binding(0) var v_indices: PrimeIndices; // The Collatz Conjecture states that for any integer n: @@ -29,7 +29,7 @@ fn collatz_iterations(n_base: u32) -> u32 { return i; } -[[stage(compute), workgroup_size(1)]] -fn main([[builtin(global_invocation_id)]] global_id: vec3) { +@stage(compute) @workgroup_size(1) +fn main(@builtin(global_invocation_id) global_id: vec3) { v_indices.data[global_id.x] = collatz_iterations(v_indices.data[global_id.x]); } diff --git a/tests/in/control-flow.wgsl b/tests/in/control-flow.wgsl index e875d63e85..9ce08fff73 100644 --- a/tests/in/control-flow.wgsl +++ b/tests/in/control-flow.wgsl @@ -1,5 +1,5 @@ -[[stage(compute), workgroup_size(1)]] -fn main([[builtin(global_invocation_id)]] global_id: vec3) { +@stage(compute) @workgroup_size(1) +fn main(@builtin(global_invocation_id) global_id: vec3) { //TODO: execution-only barrier? storageBarrier(); workgroupBarrier(); diff --git a/tests/in/cubeArrayShadow.wgsl b/tests/in/cubeArrayShadow.wgsl index a2a376564c..aad2d5ae8e 100644 --- a/tests/in/cubeArrayShadow.wgsl +++ b/tests/in/cubeArrayShadow.wgsl @@ -1,10 +1,10 @@ -[[group(0), binding(4)]] +@group(0) @binding(4) var point_shadow_textures: texture_depth_cube_array; -[[group(0), binding(5)]] +@group(0) @binding(5) var point_shadow_textures_sampler: sampler_comparison; -[[stage(fragment)]] -fn fragment() -> [[location(0)]] vec4 { +@stage(fragment) +fn fragment() -> @location(0) vec4 { let frag_ls = vec4(1., 1., 2., 1.).xyz; let a = textureSampleCompare(point_shadow_textures, point_shadow_textures_sampler, frag_ls, i32(1), 1.); diff --git a/tests/in/empty.wgsl b/tests/in/empty.wgsl index 9bd04d80cf..8628444794 100644 --- a/tests/in/empty.wgsl +++ b/tests/in/empty.wgsl @@ -1,2 +1,2 @@ -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn main() {} diff --git a/tests/in/extra.wgsl b/tests/in/extra.wgsl index fa8c466c4d..d728c56be5 100644 --- a/tests/in/extra.wgsl +++ b/tests/in/extra.wgsl @@ -5,12 +5,12 @@ struct PushConstants { var pc: PushConstants; struct FragmentIn { - [[location(0)]] color: vec4; - [[builtin(primitive_index)]] primitive_index: u32; + @location(0) color: vec4; + @builtin(primitive_index) primitive_index: u32; }; -[[stage(fragment)]] -fn main(in: FragmentIn) -> [[location(0)]] vec4 { +@stage(fragment) +fn main(in: FragmentIn) -> @location(0) vec4 { if (in.primitive_index % 2u == 0u) { return in.color; } else { diff --git a/tests/in/functions-webgl.wgsl b/tests/in/functions-webgl.wgsl index 2ec56f88f3..2e058ec72f 100644 --- a/tests/in/functions-webgl.wgsl +++ b/tests/in/functions-webgl.wgsl @@ -7,7 +7,7 @@ fn test_fma() -> vec2 { } -[[stage(vertex)]] +@stage(vertex) fn main() { let a = test_fma(); } diff --git a/tests/in/functions.wgsl b/tests/in/functions.wgsl index e9d64a99ff..71f736a2b9 100644 --- a/tests/in/functions.wgsl +++ b/tests/in/functions.wgsl @@ -9,7 +9,7 @@ fn test_fma() -> vec2 { } -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn main() { let a = test_fma(); } diff --git a/tests/in/globals.wgsl b/tests/in/globals.wgsl index 6c9fc1c162..02c9e069a2 100644 --- a/tests/in/globals.wgsl +++ b/tests/in/globals.wgsl @@ -10,17 +10,17 @@ struct Foo { // test packed vec3 v1: f32; }; -[[group(0), binding(1)]] +@group(0) @binding(1) var alignment: Foo; struct Dummy { arr: array>; }; -[[group(0), binding(2)]] +@group(0) @binding(2) var dummy: Dummy; -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn main() { wg[3] = alignment.v1; wg[2] = alignment.v3.x; diff --git a/tests/in/image.wgsl b/tests/in/image.wgsl index 0e2a735c33..d722fcf41e 100644 --- a/tests/in/image.wgsl +++ b/tests/in/image.wgsl @@ -1,25 +1,25 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var image_mipmapped_src: texture_2d; -[[group(0), binding(3)]] +@group(0) @binding(3) var image_multisampled_src: texture_multisampled_2d; -[[group(0), binding(4)]] +@group(0) @binding(4) var image_depth_multisampled_src: texture_depth_multisampled_2d; -[[group(0), binding(1)]] +@group(0) @binding(1) var image_storage_src: texture_storage_2d; -[[group(0), binding(5)]] +@group(0) @binding(5) var image_array_src: texture_2d_array; -[[group(0), binding(6)]] +@group(0) @binding(6) var image_dup_src: texture_storage_1d; // for #1307 -[[group(0), binding(7)]] +@group(0) @binding(7) var image_1d_src: texture_1d; -[[group(0), binding(2)]] +@group(0) @binding(2) var image_dst: texture_storage_1d; -[[stage(compute), workgroup_size(16)]] +@stage(compute) @workgroup_size(16) fn main( - [[builtin(local_invocation_id)]] local_id: vec3, + @builtin(local_invocation_id) local_id: vec3, //TODO: https://github.com/gpuweb/gpuweb/issues/1590 - //[[builtin(workgroup_size)]] wg_size: vec3 + //@builtin(workgroup_size) wg_size: vec3 ) { let dim = textureDimensions(image_storage_src); let itc = dim * vec2(local_id.xy) % vec2(10, 20); @@ -31,8 +31,8 @@ fn main( textureStore(image_dst, itc.x, value1 + value2 + value4 + value5 + value6); } -[[stage(compute), workgroup_size(16, 1, 1)]] -fn depth_load([[builtin(local_invocation_id)]] local_id: vec3) { +@stage(compute) @workgroup_size(16, 1, 1) +fn depth_load(@builtin(local_invocation_id) local_id: vec3) { let dim: vec2 = textureDimensions(image_storage_src); let itc: vec2 = ((dim * vec2(local_id.xy)) % vec2(10, 20)); let val: f32 = textureLoad(image_depth_multisampled_src, itc, i32(local_id.z)); @@ -40,23 +40,23 @@ fn depth_load([[builtin(local_invocation_id)]] local_id: vec3) { return; } -[[group(0), binding(0)]] +@group(0) @binding(0) var image_1d: texture_1d; -[[group(0), binding(1)]] +@group(0) @binding(1) var image_2d: texture_2d; -[[group(0), binding(2)]] +@group(0) @binding(2) var image_2d_array: texture_2d_array; -[[group(0), binding(3)]] +@group(0) @binding(3) var image_cube: texture_cube; -[[group(0), binding(4)]] +@group(0) @binding(4) var image_cube_array: texture_cube_array; -[[group(0), binding(5)]] +@group(0) @binding(5) var image_3d: texture_3d; -[[group(0), binding(6)]] +@group(0) @binding(6) var image_aa: texture_multisampled_2d; -[[stage(vertex)]] -fn queries() -> [[builtin(position)]] vec4 { +@stage(vertex) +fn queries() -> @builtin(position) vec4 { let dim_1d = textureDimensions(image_1d); let dim_1d_lod = textureDimensions(image_1d, i32(dim_1d)); let dim_2d = textureDimensions(image_2d); @@ -76,8 +76,8 @@ fn queries() -> [[builtin(position)]] vec4 { return vec4(f32(sum)); } -[[stage(vertex)]] -fn levels_queries() -> [[builtin(position)]] vec4 { +@stage(vertex) +fn levels_queries() -> @builtin(position) vec4 { let num_levels_2d = textureNumLevels(image_2d); let num_levels_2d_array = textureNumLevels(image_2d_array); let num_layers_2d = textureNumLayers(image_2d_array); @@ -92,11 +92,11 @@ fn levels_queries() -> [[builtin(position)]] vec4 { return vec4(f32(sum)); } -[[group(1), binding(0)]] +@group(1) @binding(0) var sampler_reg: sampler; -[[stage(fragment)]] -fn sample() -> [[location(0)]] vec4 { +@stage(fragment) +fn sample() -> @location(0) vec4 { let tc = vec2(0.5); let level = 2.3; let s1d = textureSample(image_1d, sampler_reg, tc.x); @@ -107,13 +107,13 @@ fn sample() -> [[location(0)]] vec4 { return s1d + s2d + s2d_offset + s2d_level + s2d_level_offset; } -[[group(1), binding(1)]] +@group(1) @binding(1) var sampler_cmp: sampler_comparison; -[[group(1), binding(2)]] +@group(1) @binding(2) var image_2d_depth: texture_depth_2d; -[[stage(fragment)]] -fn sample_comparison() -> [[location(0)]] f32 { +@stage(fragment) +fn sample_comparison() -> @location(0) f32 { let tc = vec2(0.5); let dref = 0.5; let s2d_depth = textureSampleCompare(image_2d_depth, sampler_cmp, tc, dref); @@ -121,8 +121,8 @@ fn sample_comparison() -> [[location(0)]] f32 { return s2d_depth + s2d_depth_level; } -[[stage(fragment)]] -fn gather() -> [[location(0)]] vec4 { +@stage(fragment) +fn gather() -> @location(0) vec4 { let tc = vec2(0.5); let dref = 0.5; let s2d = textureGather(1, image_2d, sampler_reg, tc); @@ -132,8 +132,8 @@ fn gather() -> [[location(0)]] vec4 { return s2d + s2d_offset + s2d_depth + s2d_depth_offset; } -[[stage(fragment)]] -fn depth_no_comparison() -> [[location(0)]] vec4 { +@stage(fragment) +fn depth_no_comparison() -> @location(0) vec4 { let tc = vec2(0.5); let s2d = textureSample(image_2d_depth, sampler_reg, tc); let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc); diff --git a/tests/in/interface.wgsl b/tests/in/interface.wgsl index 6b38a434ea..f5946c13a2 100644 --- a/tests/in/interface.wgsl +++ b/tests/in/interface.wgsl @@ -1,32 +1,32 @@ // Testing various parts of the pipeline interface: locations, built-ins, and entry points struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(1)]] varying: f32; + @builtin(position) position: vec4; + @location(1) varying: f32; }; -[[stage(vertex)]] +@stage(vertex) fn vertex( - [[builtin(vertex_index)]] vertex_index: u32, - [[builtin(instance_index)]] instance_index: u32, - [[location(10)]] color: u32, + @builtin(vertex_index) vertex_index: u32, + @builtin(instance_index) instance_index: u32, + @location(10) color: u32, ) -> VertexOutput { let tmp = vertex_index + instance_index + color; return VertexOutput(vec4(1.0), f32(tmp)); } struct FragmentOutput { - [[builtin(frag_depth)]] depth: f32; - [[builtin(sample_mask)]] sample_mask: u32; - [[location(0)]] color: f32; + @builtin(frag_depth) depth: f32; + @builtin(sample_mask) sample_mask: u32; + @location(0) color: f32; }; -[[stage(fragment)]] +@stage(fragment) fn fragment( in: VertexOutput, - [[builtin(front_facing)]] front_facing: bool, - [[builtin(sample_index)]] sample_index: u32, - [[builtin(sample_mask)]] sample_mask: u32, + @builtin(front_facing) front_facing: bool, + @builtin(sample_index) sample_index: u32, + @builtin(sample_mask) sample_mask: u32, ) -> FragmentOutput { let mask = sample_mask & (1u << sample_index); let color = select(0.0, 1.0, front_facing); @@ -35,13 +35,13 @@ fn fragment( var output: array; -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn compute( - [[builtin(global_invocation_id)]] global_id: vec3, - [[builtin(local_invocation_id)]] local_id: vec3, - [[builtin(local_invocation_index)]] local_index: u32, - [[builtin(workgroup_id)]] wg_id: vec3, - [[builtin(num_workgroups)]] num_wgs: vec3, + @builtin(global_invocation_id) global_id: vec3, + @builtin(local_invocation_id) local_id: vec3, + @builtin(local_invocation_index) local_index: u32, + @builtin(workgroup_id) wg_id: vec3, + @builtin(num_workgroups) num_wgs: vec3, ) { output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x; } diff --git a/tests/in/interpolate.wgsl b/tests/in/interpolate.wgsl index 9b869e3430..a3dea61e50 100644 --- a/tests/in/interpolate.wgsl +++ b/tests/in/interpolate.wgsl @@ -1,17 +1,17 @@ //TODO: merge with "interface"? struct FragmentInput { - [[builtin(position)]] position: vec4; - [[location(0), interpolate(flat)]] flat : u32; - [[location(1), interpolate(linear)]] linear : f32; - [[location(2), interpolate(linear, centroid)]] linear_centroid : vec2; - [[location(3), interpolate(linear, sample)]] linear_sample : vec3; - [[location(4), interpolate(perspective)]] perspective : vec4; - [[location(5), interpolate(perspective, centroid)]] perspective_centroid : f32; - [[location(6), interpolate(perspective, sample)]] perspective_sample : f32; + @builtin(position) position: vec4; + @location(0) @interpolate(flat) flat : u32; + @location(1) @interpolate(linear) linear : f32; + @location(2) @interpolate(linear, centroid) linear_centroid : vec2; + @location(3) @interpolate(linear, sample) linear_sample : vec3; + @location(4) @interpolate(perspective) perspective : vec4; + @location(5) @interpolate(perspective, centroid) perspective_centroid : f32; + @location(6) @interpolate(perspective, sample) perspective_sample : f32; }; -[[stage(vertex)]] +@stage(vertex) fn vert_main() -> FragmentInput { var out: FragmentInput; @@ -27,5 +27,5 @@ fn vert_main() -> FragmentInput { return out; } -[[stage(fragment)]] +@stage(fragment) fn frag_main(val : FragmentInput) { } diff --git a/tests/in/math-functions.wgsl b/tests/in/math-functions.wgsl index 90e5720c4c..5d3a1f5920 100644 --- a/tests/in/math-functions.wgsl +++ b/tests/in/math-functions.wgsl @@ -1,4 +1,4 @@ -[[stage(vertex)]] +@stage(vertex) fn main() { let f = 1.0; let v = vec4(0.0); diff --git a/tests/in/operators.wgsl b/tests/in/operators.wgsl index a7aedb7f25..5252d4031f 100644 --- a/tests/in/operators.wgsl +++ b/tests/in/operators.wgsl @@ -96,7 +96,7 @@ fn binary_assignment() { a &= 0; } -[[stage(compute), workgroup_size(1)]] +@stage(compute) @workgroup_size(1) fn main() { let a = builtins(); let b = splat(); diff --git a/tests/in/pointers.wgsl b/tests/in/pointers.wgsl index cf365f3904..6eddb77953 100644 --- a/tests/in/pointers.wgsl +++ b/tests/in/pointers.wgsl @@ -8,7 +8,7 @@ struct DynamicArray { arr: array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var dynamic_array: DynamicArray; fn index_unsized(i: i32, v: u32) { diff --git a/tests/in/policy-mix.wgsl b/tests/in/policy-mix.wgsl index 4dc1e1bce8..fe05a3232a 100644 --- a/tests/in/policy-mix.wgsl +++ b/tests/in/policy-mix.wgsl @@ -5,15 +5,15 @@ struct InStorage { a: array, 10>; }; -[[group(0), binding(0)]] var in_storage: InStorage; +@group(0) @binding(0) var in_storage: InStorage; struct InUniform { a: array, 20>; }; -[[group(0), binding(1)]] var in_uniform: InUniform; +@group(0) @binding(1) var in_uniform: InUniform; // Textures automatically land in the `handle` storage class. -[[group(0), binding(2)]] var image_2d_array: texture_2d_array; +@group(0) @binding(2) var image_2d_array: texture_2d_array; // None of the above. var in_workgroup: array; diff --git a/tests/in/push-constants.wgsl b/tests/in/push-constants.wgsl index bb5b0e732a..d5b4cf99dd 100644 --- a/tests/in/push-constants.wgsl +++ b/tests/in/push-constants.wgsl @@ -4,10 +4,10 @@ struct PushConstants { var pc: PushConstants; struct FragmentIn { - [[location(0)]] color: vec4; + @location(0) color: vec4; }; -[[stage(fragment)]] -fn main(in: FragmentIn) -> [[location(0)]] vec4 { +@stage(fragment) +fn main(in: FragmentIn) -> @location(0) vec4 { return in.color * pc.multiplier; } diff --git a/tests/in/quad.wgsl b/tests/in/quad.wgsl index 4dd8e8a7d2..48334cac13 100644 --- a/tests/in/quad.wgsl +++ b/tests/in/quad.wgsl @@ -2,24 +2,24 @@ let c_scale: f32 = 1.2; struct VertexOutput { - [[location(0)]] uv : vec2; - [[builtin(position)]] position : vec4; + @location(0) uv : vec2; + @builtin(position) position : vec4; }; -[[stage(vertex)]] +@stage(vertex) fn vert_main( - [[location(0)]] pos : vec2, - [[location(1)]] uv : vec2, + @location(0) pos : vec2, + @location(1) uv : vec2, ) -> VertexOutput { return VertexOutput(uv, vec4(c_scale * pos, 0.0, 1.0)); } // fragment -[[group(0), binding(0)]] var u_texture : texture_2d; -[[group(0), binding(1)]] var u_sampler : sampler; +@group(0) @binding(0) var u_texture : texture_2d; +@group(0) @binding(1) var u_sampler : sampler; -[[stage(fragment)]] -fn frag_main([[location(0)]] uv : vec2) -> [[location(0)]] vec4 { +@stage(fragment) +fn frag_main(@location(0) uv : vec2) -> @location(0) vec4 { let color = textureSample(u_texture, u_sampler, uv); if (color.a == 0.0) { discard; @@ -32,7 +32,7 @@ fn frag_main([[location(0)]] uv : vec2) -> [[location(0)]] vec4 { // We need to make sure that backends are successfully handling multiple entry points for the same shader stage. -[[stage(fragment)]] -fn fs_extra() -> [[location(0)]] vec4 { +@stage(fragment) +fn fs_extra() -> @location(0) vec4 { return vec4(0.0, 0.5, 0.0, 0.5); } diff --git a/tests/in/shadow.wgsl b/tests/in/shadow.wgsl index f17f7af395..367762d517 100644 --- a/tests/in/shadow.wgsl +++ b/tests/in/shadow.wgsl @@ -2,7 +2,7 @@ struct Globals { num_lights: vec4; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var u_globals: Globals; struct Light { @@ -12,14 +12,14 @@ struct Light { }; struct Lights { - data: [[stride(96)]] array; + data: @stride(96) array; }; -[[group(0), binding(1)]] +@group(0) @binding(1) var s_lights: Lights; -[[group(0), binding(2)]] +@group(0) @binding(2) var t_shadow: texture_depth_2d_array; -[[group(0), binding(3)]] +@group(0) @binding(3) var sampler_shadow: sampler_comparison; fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { @@ -34,11 +34,11 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { let c_ambient: vec3 = vec3(0.05, 0.05, 0.05); let c_max_lights: u32 = 10u; -[[stage(fragment)]] +@stage(fragment) fn fs_main( - [[location(0)]] raw_normal: vec3, - [[location(1)]] position: vec4 -) -> [[location(0)]] vec4 { + @location(0) raw_normal: vec3, + @location(1) position: vec4 +) -> @location(0) vec4 { let normal: vec3 = normalize(raw_normal); // accumulate color var color = c_ambient; diff --git a/tests/in/skybox.wgsl b/tests/in/skybox.wgsl index b21624853f..afbc38718e 100644 --- a/tests/in/skybox.wgsl +++ b/tests/in/skybox.wgsl @@ -1,17 +1,17 @@ struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] uv: vec3; + @builtin(position) position: vec4; + @location(0) uv: vec3; }; struct Data { proj_inv: mat4x4; view: mat4x4; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var r_data: Data; -[[stage(vertex)]] -fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput { +@stage(vertex) +fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput { // hacky way to draw a large triangle var tmp1 = i32(vertex_index) / 2; var tmp2 = i32(vertex_index) & 1; @@ -27,12 +27,12 @@ fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput { return VertexOutput(pos, inv_model_view * unprojected.xyz); } -[[group(0), binding(1)]] +@group(0) @binding(1) var r_texture: texture_cube; -[[group(0), binding(2)]] +@group(0) @binding(2) var r_sampler: sampler; -[[stage(fragment)]] -fn fs_main(in: VertexOutput) -> [[location(0)]] vec4 { +@stage(fragment) +fn fs_main(in: VertexOutput) -> @location(0) vec4 { return textureSample(r_texture, r_sampler, in.uv); } diff --git a/tests/in/standard.wgsl b/tests/in/standard.wgsl index a9db49e784..9171db1900 100644 --- a/tests/in/standard.wgsl +++ b/tests/in/standard.wgsl @@ -1,7 +1,7 @@ // Standard functions. -[[stage(fragment)]] -fn derivatives([[builtin(position)]] foo: vec4) -> [[location(0)]] vec4 { +@stage(fragment) +fn derivatives(@builtin(position) foo: vec4) -> @location(0) vec4 { let x = dpdx(foo); let y = dpdy(foo); let z = fwidth(foo); diff --git a/tests/in/texture-arg.wgsl b/tests/in/texture-arg.wgsl index af4c382bea..70fd586f0c 100644 --- a/tests/in/texture-arg.wgsl +++ b/tests/in/texture-arg.wgsl @@ -1,13 +1,13 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var Texture: texture_2d; -[[group(0), binding(1)]] +@group(0) @binding(1) var Sampler: sampler; fn test(Passed_Texture: texture_2d, Passed_Sampler: sampler) -> vec4 { return textureSample(Passed_Texture, Passed_Sampler, vec2(0.0, 0.0)); } -[[stage(fragment)]] -fn main() -> [[location(0)]] vec4 { +@stage(fragment) +fn main() -> @location(0) vec4 { return test(Texture, Sampler); } diff --git a/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl b/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl index e66de740d6..c21fed383a 100644 --- a/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl +++ b/tests/out/wgsl/210-bevy-2d-shader-frag.wgsl @@ -3,12 +3,12 @@ struct ColorMaterial_color { }; struct FragmentOutput { - [[location(0)]] o_Target: vec4; + @location(0) @ o_Target: vec4; }; var v_Uv_1: vec2; var o_Target: vec4; -[[group(1), binding(0)]] +@group(1) @binding(0) var global: ColorMaterial_color; fn main_1() { @@ -21,8 +21,8 @@ fn main_1() { return; } -[[stage(fragment)]] -fn main([[location(0)]] v_Uv: vec2) -> FragmentOutput { +@stage(fragment) +fn main(@location(0) @ v_Uv: vec2) -> FragmentOutput { v_Uv_1 = v_Uv; main_1(); let _e9 = o_Target; diff --git a/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl b/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl index c368e38d95..bf8d389643 100644 --- a/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl +++ b/tests/out/wgsl/210-bevy-2d-shader-vert.wgsl @@ -11,19 +11,19 @@ struct Sprite_size { }; struct VertexOutput { - [[location(0)]] v_Uv: vec2; - [[builtin(position)]] member: vec4; + @location(0) @ v_Uv: vec2; + @builtin(position) member: vec4; }; var Vertex_Position_1: vec3; var Vertex_Normal_1: vec3; var Vertex_Uv_1: vec2; var v_Uv: vec2; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: Camera; -[[group(2), binding(0)]] +@group(2) @binding(0) var global_1: Transform; -[[group(2), binding(1)]] +@group(2) @binding(1) var global_2: Sprite_size; var gl_Position: vec4; @@ -42,8 +42,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] Vertex_Position: vec3, [[location(1)]] Vertex_Normal: vec3, [[location(2)]] Vertex_Uv: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ Vertex_Position: vec3, @location(1) @ Vertex_Normal: vec3, @location(2) @ Vertex_Uv: vec2) -> VertexOutput { Vertex_Position_1 = Vertex_Position; Vertex_Normal_1 = Vertex_Normal; Vertex_Uv_1 = Vertex_Uv; diff --git a/tests/out/wgsl/210-bevy-shader-vert.wgsl b/tests/out/wgsl/210-bevy-shader-vert.wgsl index 4f476b9f15..e0fc94f9a4 100644 --- a/tests/out/wgsl/210-bevy-shader-vert.wgsl +++ b/tests/out/wgsl/210-bevy-shader-vert.wgsl @@ -7,10 +7,10 @@ struct Transform { }; struct VertexOutput { - [[location(0)]] v_Position: vec3; - [[location(1)]] v_Normal: vec3; - [[location(2)]] v_Uv: vec2; - [[builtin(position)]] member: vec4; + @location(0) @ v_Position: vec3; + @location(1) @ v_Normal: vec3; + @location(2) @ v_Uv: vec2; + @builtin(position) member: vec4; }; var Vertex_Position_1: vec3; @@ -19,9 +19,9 @@ var Vertex_Uv_1: vec2; var v_Position: vec3; var v_Normal: vec3; var v_Uv: vec2; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: Camera; -[[group(2), binding(0)]] +@group(2) @binding(0) var global_1: Transform; var gl_Position: vec4; @@ -43,8 +43,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] Vertex_Position: vec3, [[location(1)]] Vertex_Normal: vec3, [[location(2)]] Vertex_Uv: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ Vertex_Position: vec3, @location(1) @ Vertex_Normal: vec3, @location(2) @ Vertex_Uv: vec2) -> VertexOutput { Vertex_Position_1 = Vertex_Position; Vertex_Normal_1 = Vertex_Normal; Vertex_Uv_1 = Vertex_Uv; diff --git a/tests/out/wgsl/246-collatz-comp.wgsl b/tests/out/wgsl/246-collatz-comp.wgsl index fc344ea509..45d08357cb 100644 --- a/tests/out/wgsl/246-collatz-comp.wgsl +++ b/tests/out/wgsl/246-collatz-comp.wgsl @@ -1,8 +1,8 @@ struct PrimeIndices { - indices: [[stride(4)]] array; + indices: @stride(4) array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: PrimeIndices; var gl_GlobalInvocationID: vec3; @@ -51,8 +51,8 @@ fn main_1() { return; } -[[stage(compute), workgroup_size(1, 1, 1)]] -fn main([[builtin(global_invocation_id)]] param: vec3) { +@stage(compute) @workgroup_size(1, 1, 1) +fn main(@builtin(global_invocation_id) param: vec3) { gl_GlobalInvocationID = param; main_1(); return; diff --git a/tests/out/wgsl/277-casting-vert.wgsl b/tests/out/wgsl/277-casting-vert.wgsl index f05db0372d..92ab6a5164 100644 --- a/tests/out/wgsl/277-casting-vert.wgsl +++ b/tests/out/wgsl/277-casting-vert.wgsl @@ -3,7 +3,7 @@ fn main_1() { } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/280-matrix-cast-vert.wgsl b/tests/out/wgsl/280-matrix-cast-vert.wgsl index 8826e9e543..b5ee6454df 100644 --- a/tests/out/wgsl/280-matrix-cast-vert.wgsl +++ b/tests/out/wgsl/280-matrix-cast-vert.wgsl @@ -4,7 +4,7 @@ fn main_1() { let _e1 = f32(1); } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/484-preprocessor-if-vert.wgsl b/tests/out/wgsl/484-preprocessor-if-vert.wgsl index ebd8567c94..ea9cd03d5b 100644 --- a/tests/out/wgsl/484-preprocessor-if-vert.wgsl +++ b/tests/out/wgsl/484-preprocessor-if-vert.wgsl @@ -2,7 +2,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl b/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl index 351482d7da..4739216110 100644 --- a/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl +++ b/tests/out/wgsl/800-out-of-bounds-panic-vert.wgsl @@ -7,11 +7,11 @@ struct VertexPushConstants { }; struct VertexOutput { - [[location(0)]] frag_color: vec4; - [[builtin(position)]] member: vec4; + @location(0) @ frag_color: vec4; + @builtin(position) member: vec4; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: Globals; var global_1: VertexPushConstants; var position_1: vec2; @@ -32,8 +32,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] position: vec2, [[location(1)]] color: vec4) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ position: vec2, @location(1) @ color: vec4) -> VertexOutput { position_1 = position; color_1 = color; main_1(); diff --git a/tests/out/wgsl/896-push-constant-vert.wgsl b/tests/out/wgsl/896-push-constant-vert.wgsl index dec43d8d44..f7f2dcfb31 100644 --- a/tests/out/wgsl/896-push-constant-vert.wgsl +++ b/tests/out/wgsl/896-push-constant-vert.wgsl @@ -8,7 +8,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/900-implicit-conversions-vert.wgsl b/tests/out/wgsl/900-implicit-conversions-vert.wgsl index bb86b505f9..90d97dfab6 100644 --- a/tests/out/wgsl/900-implicit-conversions-vert.wgsl +++ b/tests/out/wgsl/900-implicit-conversions-vert.wgsl @@ -61,7 +61,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/901-lhs-field-select-vert.wgsl b/tests/out/wgsl/901-lhs-field-select-vert.wgsl index 13695097b9..6aa3bedd2d 100644 --- a/tests/out/wgsl/901-lhs-field-select-vert.wgsl +++ b/tests/out/wgsl/901-lhs-field-select-vert.wgsl @@ -5,7 +5,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/931-constant-emitting-vert.wgsl b/tests/out/wgsl/931-constant-emitting-vert.wgsl index 0e3e656a7f..515f41c62e 100644 --- a/tests/out/wgsl/931-constant-emitting-vert.wgsl +++ b/tests/out/wgsl/931-constant-emitting-vert.wgsl @@ -6,7 +6,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/932-for-loop-if-vert.wgsl b/tests/out/wgsl/932-for-loop-if-vert.wgsl index f00782e9b8..9927e46b0f 100644 --- a/tests/out/wgsl/932-for-loop-if-vert.wgsl +++ b/tests/out/wgsl/932-for-loop-if-vert.wgsl @@ -16,7 +16,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index ca5313a808..2e4ee4142a 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -1,12 +1,12 @@ struct Bar { matrix: mat4x4; - matrix_array: [[stride(16)]] array,2>; + matrix_array: @stride(16) array,2>; atom: atomic; - arr: [[stride(8)]] array,2>; - data: [[stride(8)]] array; + arr: @stride(8) array,2>; + data: @stride(8) array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var bar: Bar; fn read_from_private(foo_2: ptr) -> f32 { @@ -14,8 +14,8 @@ fn read_from_private(foo_2: ptr) -> f32 { return _e2; } -[[stage(vertex)]] -fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { +@stage(vertex) +fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { var foo_1: f32 = 0.0; var c: array; @@ -37,7 +37,7 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4 { return (matrix * vec4(vec4(value))); } -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn atomics() { var tmp: i32; diff --git a/tests/out/wgsl/bevy-pbr-frag.wgsl b/tests/out/wgsl/bevy-pbr-frag.wgsl index f73f517d4e..be85f2aa5f 100644 --- a/tests/out/wgsl/bevy-pbr-frag.wgsl +++ b/tests/out/wgsl/bevy-pbr-frag.wgsl @@ -20,8 +20,8 @@ struct CameraPosition { struct Lights { AmbientColor: vec4; NumLights: vec4; - PointLights: [[stride(48)]] array; - DirectionalLights: [[stride(32)]] array; + PointLights: @stride(48) array; + DirectionalLights: @stride(32) array; }; struct StandardMaterial_base_color { @@ -45,7 +45,7 @@ struct StandardMaterial_emissive { }; struct FragmentOutput { - [[location(0)]] o_Target: vec4; + @location(0) @ o_Target: vec4; }; var v_WorldPosition_1: vec3; @@ -53,41 +53,41 @@ var v_WorldNormal_1: vec3; var v_Uv_1: vec2; var v_WorldTangent_1: vec4; var o_Target: vec4; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: CameraViewProj; -[[group(0), binding(1)]] +@group(0) @binding(1) var global_1: CameraPosition; -[[group(1), binding(0)]] +@group(1) @binding(0) var global_2: Lights; -[[group(3), binding(0)]] +@group(3) @binding(0) var global_3: StandardMaterial_base_color; -[[group(3), binding(1)]] +@group(3) @binding(1) var StandardMaterial_base_color_texture: texture_2d; -[[group(3), binding(2)]] +@group(3) @binding(2) var StandardMaterial_base_color_texture_sampler: sampler; -[[group(3), binding(3)]] +@group(3) @binding(3) var global_4: StandardMaterial_roughness; -[[group(3), binding(4)]] +@group(3) @binding(4) var global_5: StandardMaterial_metallic; -[[group(3), binding(5)]] +@group(3) @binding(5) var StandardMaterial_metallic_roughness_texture: texture_2d; -[[group(3), binding(6)]] +@group(3) @binding(6) var StandardMaterial_metallic_roughness_texture_sampler: sampler; -[[group(3), binding(7)]] +@group(3) @binding(7) var global_6: StandardMaterial_reflectance; -[[group(3), binding(8)]] +@group(3) @binding(8) var StandardMaterial_normal_map: texture_2d; -[[group(3), binding(9)]] +@group(3) @binding(9) var StandardMaterial_normal_map_sampler: sampler; -[[group(3), binding(10)]] +@group(3) @binding(10) var StandardMaterial_occlusion_texture: texture_2d; -[[group(3), binding(11)]] +@group(3) @binding(11) var StandardMaterial_occlusion_texture_sampler: sampler; -[[group(3), binding(12)]] +@group(3) @binding(12) var global_7: StandardMaterial_emissive; -[[group(3), binding(13)]] +@group(3) @binding(13) var StandardMaterial_emissive_texture: texture_2d; -[[group(3), binding(14)]] +@group(3) @binding(14) var StandardMaterial_emissive_texture_sampler: sampler; var gl_FrontFacing: bool; @@ -895,8 +895,8 @@ fn main_1() { return; } -[[stage(fragment)]] -fn main([[location(0)]] v_WorldPosition: vec3, [[location(1)]] v_WorldNormal: vec3, [[location(2)]] v_Uv: vec2, [[location(3)]] v_WorldTangent: vec4, [[builtin(front_facing)]] param: bool) -> FragmentOutput { +@stage(fragment) +fn main(@location(0) @ v_WorldPosition: vec3, @location(1) @ v_WorldNormal: vec3, @location(2) @ v_Uv: vec2, @location(3) @ v_WorldTangent: vec4, @builtin(front_facing) param: bool) -> FragmentOutput { v_WorldPosition_1 = v_WorldPosition; v_WorldNormal_1 = v_WorldNormal; v_Uv_1 = v_Uv; diff --git a/tests/out/wgsl/bevy-pbr-vert.wgsl b/tests/out/wgsl/bevy-pbr-vert.wgsl index 34f836704e..1c29142da9 100644 --- a/tests/out/wgsl/bevy-pbr-vert.wgsl +++ b/tests/out/wgsl/bevy-pbr-vert.wgsl @@ -7,11 +7,11 @@ struct Transform { }; struct VertexOutput { - [[location(0)]] v_WorldPosition: vec3; - [[location(1)]] v_WorldNormal: vec3; - [[location(2)]] v_Uv: vec2; - [[location(3)]] v_WorldTangent: vec4; - [[builtin(position)]] member: vec4; + @location(0) @ v_WorldPosition: vec3; + @location(1) @ v_WorldNormal: vec3; + @location(2) @ v_Uv: vec2; + @location(3) @ v_WorldTangent: vec4; + @builtin(position) member: vec4; }; var Vertex_Position_1: vec3; @@ -21,10 +21,10 @@ var Vertex_Tangent_1: vec4; var v_WorldPosition: vec3; var v_WorldNormal: vec3; var v_Uv: vec2; -[[group(0), binding(0)]] +@group(0) @binding(0) var global: CameraViewProj; var v_WorldTangent: vec4; -[[group(2), binding(0)]] +@group(2) @binding(0) var global_1: Transform; var gl_Position: vec4; @@ -52,8 +52,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] Vertex_Position: vec3, [[location(1)]] Vertex_Normal: vec3, [[location(2)]] Vertex_Uv: vec2, [[location(3)]] Vertex_Tangent: vec4) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ Vertex_Position: vec3, @location(1) @ Vertex_Normal: vec3, @location(2) @ Vertex_Uv: vec2, @location(3) @ Vertex_Tangent: vec4) -> VertexOutput { Vertex_Position_1 = Vertex_Position; Vertex_Normal_1 = Vertex_Normal; Vertex_Uv_1 = Vertex_Uv; diff --git a/tests/out/wgsl/binop-frag.wgsl b/tests/out/wgsl/binop-frag.wgsl index 40e8c82162..8edf934b34 100644 --- a/tests/out/wgsl/binop-frag.wgsl +++ b/tests/out/wgsl/binop-frag.wgsl @@ -180,7 +180,7 @@ fn main1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main1(); return; diff --git a/tests/out/wgsl/bits.wgsl b/tests/out/wgsl/bits.wgsl index 45037118bf..1af9b969d7 100644 --- a/tests/out/wgsl/bits.wgsl +++ b/tests/out/wgsl/bits.wgsl @@ -1,4 +1,4 @@ -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn main() { var i: i32 = 0; var i2_: vec2; diff --git a/tests/out/wgsl/bits_glsl-frag.wgsl b/tests/out/wgsl/bits_glsl-frag.wgsl index 29f77ca764..8faa6e26e9 100644 --- a/tests/out/wgsl/bits_glsl-frag.wgsl +++ b/tests/out/wgsl/bits_glsl-frag.wgsl @@ -105,7 +105,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main_1(); return; diff --git a/tests/out/wgsl/boids.wgsl b/tests/out/wgsl/boids.wgsl index 6a5d4c269b..7b1e9af1ea 100644 --- a/tests/out/wgsl/boids.wgsl +++ b/tests/out/wgsl/boids.wgsl @@ -14,20 +14,20 @@ struct SimParams { }; struct Particles { - particles: [[stride(16)]] array; + particles: @stride(16) array; }; let NUM_PARTICLES: u32 = 1500u; -[[group(0), binding(0)]] +@group(0) @binding(0) var params: SimParams; -[[group(0), binding(1)]] +@group(0) @binding(1) var particlesSrc: Particles; -[[group(0), binding(2)]] +@group(0) @binding(2) var particlesDst: Particles; -[[stage(compute), workgroup_size(64, 1, 1)]] -fn main([[builtin(global_invocation_id)]] global_invocation_id: vec3) { +@stage(compute) @workgroup_size(64, 1, 1) +fn main(@builtin(global_invocation_id) global_invocation_id: vec3) { var vPos: vec2; var vVel: vec2; var cMass: vec2; diff --git a/tests/out/wgsl/bool-select-frag.wgsl b/tests/out/wgsl/bool-select-frag.wgsl index 1b0ce4b294..af9e169236 100644 --- a/tests/out/wgsl/bool-select-frag.wgsl +++ b/tests/out/wgsl/bool-select-frag.wgsl @@ -1,5 +1,5 @@ struct FragmentOutput { - [[location(0)]] o_color: vec4; + @location(0) @ o_color: vec4; }; var o_color: vec4; @@ -37,7 +37,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() -> FragmentOutput { main_1(); let _e3 = o_color; diff --git a/tests/out/wgsl/clamp-splat-vert.wgsl b/tests/out/wgsl/clamp-splat-vert.wgsl index 15cf4abbe5..c13ebd8b9b 100644 --- a/tests/out/wgsl/clamp-splat-vert.wgsl +++ b/tests/out/wgsl/clamp-splat-vert.wgsl @@ -1,5 +1,5 @@ struct VertexOutput { - [[builtin(position)]] member: vec4; + @builtin(position) member: vec4; }; var a_pos_1: vec2; @@ -12,8 +12,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] a_pos: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ a_pos: vec2) -> VertexOutput { a_pos_1 = a_pos; main_1(); let _e5 = gl_Position; diff --git a/tests/out/wgsl/collatz.wgsl b/tests/out/wgsl/collatz.wgsl index 281df6fb78..054ecf3640 100644 --- a/tests/out/wgsl/collatz.wgsl +++ b/tests/out/wgsl/collatz.wgsl @@ -1,8 +1,8 @@ struct PrimeIndices { - data: [[stride(4)]] array; + data: @stride(4) array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var v_indices: PrimeIndices; fn collatz_iterations(n_base: u32) -> u32 { @@ -30,8 +30,8 @@ fn collatz_iterations(n_base: u32) -> u32 { return _e24; } -[[stage(compute), workgroup_size(1, 1, 1)]] -fn main([[builtin(global_invocation_id)]] global_id: vec3) { +@stage(compute) @workgroup_size(1, 1, 1) +fn main(@builtin(global_invocation_id) global_id: vec3) { let _e8 = v_indices.data[global_id.x]; let _e9 = collatz_iterations(_e8); v_indices.data[global_id.x] = _e9; diff --git a/tests/out/wgsl/constant-array-size-vert.wgsl b/tests/out/wgsl/constant-array-size-vert.wgsl index 02d04dc520..9a767c8588 100644 --- a/tests/out/wgsl/constant-array-size-vert.wgsl +++ b/tests/out/wgsl/constant-array-size-vert.wgsl @@ -1,8 +1,8 @@ struct Data { - vecs: [[stride(16)]] array,42u>; + vecs: @stride(16) array,42u>; }; -[[group(1), binding(0)]] +@group(1) @binding(0) var global: Data; fn function_() -> vec4 { @@ -33,7 +33,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/control-flow.wgsl b/tests/out/wgsl/control-flow.wgsl index 06b6f48657..fad5a45e8e 100644 --- a/tests/out/wgsl/control-flow.wgsl +++ b/tests/out/wgsl/control-flow.wgsl @@ -30,8 +30,8 @@ fn loop_switch_continue(x: i32) { return; } -[[stage(compute), workgroup_size(1, 1, 1)]] -fn main([[builtin(global_invocation_id)]] global_id: vec3) { +@stage(compute) @workgroup_size(1, 1, 1) +fn main(@builtin(global_invocation_id) global_id: vec3) { var pos: i32; storageBarrier(); diff --git a/tests/out/wgsl/declarations-vert.wgsl b/tests/out/wgsl/declarations-vert.wgsl index 654a1cc2ce..28d7332a64 100644 --- a/tests/out/wgsl/declarations-vert.wgsl +++ b/tests/out/wgsl/declarations-vert.wgsl @@ -14,8 +14,8 @@ struct TestStruct { }; struct VertexOutput { - [[location(0)]] position: vec2; - [[location(1)]] a: vec2; + @location(0) @ position: vec2; + @location(1) @ a: vec2; }; var vert: VertexData; @@ -27,8 +27,8 @@ fn main_1() { } -[[stage(vertex)]] -fn main([[location(0)]] position: vec2, [[location(1)]] a: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ position: vec2, @location(1) @ a: vec2) -> VertexOutput { vert.position = position; vert.a = a; main_1(); diff --git a/tests/out/wgsl/empty-global-name.wgsl b/tests/out/wgsl/empty-global-name.wgsl index f912dfdff4..1baaf03e29 100644 --- a/tests/out/wgsl/empty-global-name.wgsl +++ b/tests/out/wgsl/empty-global-name.wgsl @@ -2,7 +2,7 @@ struct type_1 { member: i32; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var unnamed: type_1; fn function_() { @@ -11,7 +11,7 @@ fn function_() { return; } -[[stage(compute), workgroup_size(64, 1, 1)]] +@stage(compute) @workgroup_size(64, 1, 1) fn main() { function_(); } diff --git a/tests/out/wgsl/empty.wgsl b/tests/out/wgsl/empty.wgsl index 1ee73b5809..527a0d56c2 100644 --- a/tests/out/wgsl/empty.wgsl +++ b/tests/out/wgsl/empty.wgsl @@ -1,4 +1,4 @@ -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn main() { return; } diff --git a/tests/out/wgsl/expressions-frag.wgsl b/tests/out/wgsl/expressions-frag.wgsl index 22354e38ed..86589b1af1 100644 --- a/tests/out/wgsl/expressions-frag.wgsl +++ b/tests/out/wgsl/expressions-frag.wgsl @@ -211,7 +211,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main_1(); return; diff --git a/tests/out/wgsl/extra.wgsl b/tests/out/wgsl/extra.wgsl index b9fbfb74ca..619c7f55e9 100644 --- a/tests/out/wgsl/extra.wgsl +++ b/tests/out/wgsl/extra.wgsl @@ -4,14 +4,14 @@ struct PushConstants { }; struct FragmentIn { - [[location(0)]] color: vec4; - [[builtin(primitive_index)]] primitive_index: u32; + @location(0) @ color: vec4; + @builtin(primitive_index) primitive_index: u32; }; var pc: PushConstants; -[[stage(fragment)]] -fn main(in: FragmentIn) -> [[location(0)]] vec4 { +@stage(fragment) +fn main(in: FragmentIn) -> @location(0) @ vec4 { if (((in.primitive_index % 2u) == 0u)) { return in.color; } else { diff --git a/tests/out/wgsl/fma-frag.wgsl b/tests/out/wgsl/fma-frag.wgsl index d125e1353c..543311de9a 100644 --- a/tests/out/wgsl/fma-frag.wgsl +++ b/tests/out/wgsl/fma-frag.wgsl @@ -37,7 +37,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main_1(); return; diff --git a/tests/out/wgsl/functions.wgsl b/tests/out/wgsl/functions.wgsl index 9b6b41a09f..5a53e38c6e 100644 --- a/tests/out/wgsl/functions.wgsl +++ b/tests/out/wgsl/functions.wgsl @@ -5,7 +5,7 @@ fn test_fma() -> vec2 { return fma(a, b, c); } -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn main() { let _e0 = test_fma(); return; diff --git a/tests/out/wgsl/global-constant-array-vert.wgsl b/tests/out/wgsl/global-constant-array-vert.wgsl index f94744eb9c..117c2e57ca 100644 --- a/tests/out/wgsl/global-constant-array-vert.wgsl +++ b/tests/out/wgsl/global-constant-array-vert.wgsl @@ -6,7 +6,7 @@ fn main_1() { let _e2 = i; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/globals.wgsl b/tests/out/wgsl/globals.wgsl index c332963333..84705602af 100644 --- a/tests/out/wgsl/globals.wgsl +++ b/tests/out/wgsl/globals.wgsl @@ -4,19 +4,19 @@ struct Foo { }; struct Dummy { - arr: [[stride(8)]] array>; + arr: @stride(8) array>; }; let Foo_2: bool = true; var wg: array; var at_1: atomic; -[[group(0), binding(1)]] +@group(0) @binding(1) var alignment: Foo; -[[group(0), binding(2)]] +@group(0) @binding(2) var dummy: Dummy; -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn main() { var Foo_1: f32 = 1.0; var at: bool = true; diff --git a/tests/out/wgsl/image.wgsl b/tests/out/wgsl/image.wgsl index ec40004e14..db8e160cdc 100644 --- a/tests/out/wgsl/image.wgsl +++ b/tests/out/wgsl/image.wgsl @@ -1,42 +1,42 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var image_mipmapped_src: texture_2d; -[[group(0), binding(3)]] +@group(0) @binding(3) var image_multisampled_src: texture_multisampled_2d; -[[group(0), binding(4)]] +@group(0) @binding(4) var image_depth_multisampled_src: texture_depth_multisampled_2d; -[[group(0), binding(1)]] +@group(0) @binding(1) var image_storage_src: texture_storage_2d; -[[group(0), binding(5)]] +@group(0) @binding(5) var image_array_src: texture_2d_array; -[[group(0), binding(6)]] +@group(0) @binding(6) var image_dup_src: texture_storage_1d; -[[group(0), binding(7)]] +@group(0) @binding(7) var image_1d_src: texture_1d; -[[group(0), binding(2)]] +@group(0) @binding(2) var image_dst: texture_storage_1d; -[[group(0), binding(0)]] +@group(0) @binding(0) var image_1d: texture_1d; -[[group(0), binding(1)]] +@group(0) @binding(1) var image_2d: texture_2d; -[[group(0), binding(2)]] +@group(0) @binding(2) var image_2d_array: texture_2d_array; -[[group(0), binding(3)]] +@group(0) @binding(3) var image_cube: texture_cube; -[[group(0), binding(4)]] +@group(0) @binding(4) var image_cube_array: texture_cube_array; -[[group(0), binding(5)]] +@group(0) @binding(5) var image_3d: texture_3d; -[[group(0), binding(6)]] +@group(0) @binding(6) var image_aa: texture_multisampled_2d; -[[group(1), binding(0)]] +@group(1) @binding(0) var sampler_reg: sampler; -[[group(1), binding(1)]] +@group(1) @binding(1) var sampler_cmp: sampler_comparison; -[[group(1), binding(2)]] +@group(1) @binding(2) var image_2d_depth: texture_depth_2d; -[[stage(compute), workgroup_size(16, 1, 1)]] -fn main([[builtin(local_invocation_id)]] local_id: vec3) { +@stage(compute) @workgroup_size(16, 1, 1) +fn main(@builtin(local_invocation_id) local_id: vec3) { let dim = textureDimensions(image_storage_src); let itc = ((dim * vec2(local_id.xy)) % vec2(10, 20)); let value1_ = textureLoad(image_mipmapped_src, itc, i32(local_id.z)); @@ -48,8 +48,8 @@ fn main([[builtin(local_invocation_id)]] local_id: vec3) { return; } -[[stage(compute), workgroup_size(16, 1, 1)]] -fn depth_load([[builtin(local_invocation_id)]] local_id_1: vec3) { +@stage(compute) @workgroup_size(16, 1, 1) +fn depth_load(@builtin(local_invocation_id) local_id_1: vec3) { let dim_1 = textureDimensions(image_storage_src); let itc_1 = ((dim_1 * vec2(local_id_1.xy)) % vec2(10, 20)); let val = textureLoad(image_depth_multisampled_src, itc_1, i32(local_id_1.z)); @@ -57,8 +57,8 @@ fn depth_load([[builtin(local_invocation_id)]] local_id_1: vec3) { return; } -[[stage(vertex)]] -fn queries() -> [[builtin(position)]] vec4 { +@stage(vertex) +fn queries() -> @builtin(position) vec4 { let dim_1d = textureDimensions(image_1d); let dim_1d_lod = textureDimensions(image_1d, i32(dim_1d)); let dim_2d = textureDimensions(image_2d); @@ -75,8 +75,8 @@ fn queries() -> [[builtin(position)]] vec4 { return vec4(f32(sum)); } -[[stage(vertex)]] -fn levels_queries() -> [[builtin(position)]] vec4 { +@stage(vertex) +fn levels_queries() -> @builtin(position) vec4 { let num_levels_2d = textureNumLevels(image_2d); let num_levels_2d_array = textureNumLevels(image_2d_array); let num_layers_2d = textureNumLayers(image_2d_array); @@ -89,8 +89,8 @@ fn levels_queries() -> [[builtin(position)]] vec4 { return vec4(f32(sum_1)); } -[[stage(fragment)]] -fn sample() -> [[location(0)]] vec4 { +@stage(fragment) +fn sample() -> @location(0) @ vec4 { let tc = vec2(0.5); let s1d = textureSample(image_1d, sampler_reg, tc.x); let s2d = textureSample(image_2d, sampler_reg, tc); @@ -100,16 +100,16 @@ fn sample() -> [[location(0)]] vec4 { return ((((s1d + s2d) + s2d_offset) + s2d_level) + s2d_level_offset); } -[[stage(fragment)]] -fn sample_comparison() -> [[location(0)]] f32 { +@stage(fragment) +fn sample_comparison() -> @location(0) @ f32 { let tc_1 = vec2(0.5); let s2d_depth = textureSampleCompare(image_2d_depth, sampler_cmp, tc_1, 0.5); let s2d_depth_level = textureSampleCompareLevel(image_2d_depth, sampler_cmp, tc_1, 0.5); return (s2d_depth + s2d_depth_level); } -[[stage(fragment)]] -fn gather() -> [[location(0)]] vec4 { +@stage(fragment) +fn gather() -> @location(0) @ vec4 { let tc_2 = vec2(0.5); let s2d_1 = textureGather(1, image_2d, sampler_reg, tc_2); let s2d_offset_1 = textureGather(3, image_2d, sampler_reg, tc_2, vec2(3, 1)); @@ -118,8 +118,8 @@ fn gather() -> [[location(0)]] vec4 { return (((s2d_1 + s2d_offset_1) + s2d_depth_1) + s2d_depth_offset); } -[[stage(fragment)]] -fn depth_no_comparison() -> [[location(0)]] vec4 { +@stage(fragment) +fn depth_no_comparison() -> @location(0) @ vec4 { let tc_3 = vec2(0.5); let s2d_2 = textureSample(image_2d_depth, sampler_reg, tc_3); let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc_3); diff --git a/tests/out/wgsl/interface.wgsl b/tests/out/wgsl/interface.wgsl index f576915f35..1aac05c9a1 100644 --- a/tests/out/wgsl/interface.wgsl +++ b/tests/out/wgsl/interface.wgsl @@ -1,31 +1,31 @@ struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(1)]] varying: f32; + @builtin(position) position: vec4; + @location(1) @ varying: f32; }; struct FragmentOutput { - [[builtin(frag_depth)]] depth: f32; - [[builtin(sample_mask)]] sample_mask: u32; - [[location(0)]] color: f32; + @builtin(frag_depth) depth: f32; + @builtin(sample_mask) sample_mask: u32; + @location(0) @ color: f32; }; var output: array; -[[stage(vertex)]] -fn vertex([[builtin(vertex_index)]] vertex_index: u32, [[builtin(instance_index)]] instance_index: u32, [[location(10)]] color: u32) -> VertexOutput { +@stage(vertex) +fn vertex(@builtin(vertex_index) vertex_index: u32, @builtin(instance_index) instance_index: u32, @location(10) color: u32) -> VertexOutput { let tmp: u32 = ((vertex_index + instance_index) + color); return VertexOutput(vec4(1.0), f32(tmp)); } -[[stage(fragment)]] -fn fragment(in: VertexOutput, [[builtin(front_facing)]] front_facing: bool, [[builtin(sample_index)]] sample_index: u32, [[builtin(sample_mask)]] sample_mask: u32) -> FragmentOutput { +@stage(fragment) +fn fragment(in: VertexOutput, @builtin(front_facing) front_facing: bool, @builtin(sample_index) sample_index: u32, @builtin(sample_mask) sample_mask: u32) -> FragmentOutput { let mask: u32 = (sample_mask & (1u << sample_index)); let color_1: f32 = select(0.0, 1.0, front_facing); return FragmentOutput(in.varying, mask, color_1); } -[[stage(compute), workgroup_size(1, 1, 1)]] -fn compute([[builtin(global_invocation_id)]] global_id: vec3, [[builtin(local_invocation_id)]] local_id: vec3, [[builtin(local_invocation_index)]] local_index: u32, [[builtin(workgroup_id)]] wg_id: vec3, [[builtin(num_workgroups)]] num_wgs: vec3) { +@stage(compute) @workgroup_size(1, 1, 1) +fn compute(@builtin(global_invocation_id) global_id: vec3, @builtin(local_invocation_id) local_id: vec3, @builtin(local_invocation_index) local_index: u32, @builtin(workgroup_id) wg_id: vec3, @builtin(num_workgroups) num_wgs: vec3) { output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x); return; } diff --git a/tests/out/wgsl/interpolate.wgsl b/tests/out/wgsl/interpolate.wgsl index c98b74f641..49e8732c32 100644 --- a/tests/out/wgsl/interpolate.wgsl +++ b/tests/out/wgsl/interpolate.wgsl @@ -1,15 +1,15 @@ struct FragmentInput { - [[builtin(position)]] position: vec4; - [[location(0)]] flat: u32; - [[location(1), interpolate(linear)]] linear: f32; - [[location(2), interpolate(linear, centroid)]] linear_centroid: vec2; - [[location(3), interpolate(linear, sample)]] linear_sample: vec3; - [[location(4)]] perspective: vec4; - [[location(5), interpolate(perspective, centroid)]] perspective_centroid: f32; - [[location(6), interpolate(perspective, sample)]] perspective_sample: f32; + @builtin(position) position: vec4; + @location(0) flat: u32; + @location(1) @interpolate(linear) linear: f32; + @location(2) @interpolate(linear, centroid) linear_centroid: vec2; + @location(3) @interpolate(linear, sample) linear_sample: vec3; + @location(4) @ perspective: vec4; + @location(5) @interpolate(perspective, centroid) perspective_centroid: f32; + @location(6) @interpolate(perspective, sample) perspective_sample: f32; }; -[[stage(vertex)]] +@stage(vertex) fn vert_main() -> FragmentInput { var out: FragmentInput; @@ -25,7 +25,7 @@ fn vert_main() -> FragmentInput { return _e30; } -[[stage(fragment)]] +@stage(fragment) fn frag_main(val: FragmentInput) { return; } diff --git a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl index 87ee333686..d1bd7724f5 100644 --- a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl +++ b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl @@ -14,7 +14,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); } diff --git a/tests/out/wgsl/long-form-matrix-vert.wgsl b/tests/out/wgsl/long-form-matrix-vert.wgsl index b3056a9b57..7b0958044d 100644 --- a/tests/out/wgsl/long-form-matrix-vert.wgsl +++ b/tests/out/wgsl/long-form-matrix-vert.wgsl @@ -25,7 +25,7 @@ fn main_1() { let _e129 = vec4(f32(1)); } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/math-functions-vert.wgsl b/tests/out/wgsl/math-functions-vert.wgsl index ee04f886d9..3053f0240a 100644 --- a/tests/out/wgsl/math-functions-vert.wgsl +++ b/tests/out/wgsl/math-functions-vert.wgsl @@ -154,7 +154,7 @@ fn main_1() { return; } -[[stage(vertex)]] +@stage(vertex) fn main() { main_1(); return; diff --git a/tests/out/wgsl/math-functions.wgsl b/tests/out/wgsl/math-functions.wgsl index 53a293e51f..c4ae1673a6 100644 --- a/tests/out/wgsl/math-functions.wgsl +++ b/tests/out/wgsl/math-functions.wgsl @@ -1,4 +1,4 @@ -[[stage(vertex)]] +@stage(vertex) fn main() { let v = vec4(0.0); let a = degrees(1.0); diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index ee1ef36d6c..53c1c17015 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -87,7 +87,7 @@ fn binary_assignment() { return; } -[[stage(compute), workgroup_size(1, 1, 1)]] +@stage(compute) @workgroup_size(1, 1, 1) fn main() { let _e4 = builtins(); let _e5 = splat(); diff --git a/tests/out/wgsl/pointers.wgsl b/tests/out/wgsl/pointers.wgsl index df8e6553ae..0ac148e1ca 100644 --- a/tests/out/wgsl/pointers.wgsl +++ b/tests/out/wgsl/pointers.wgsl @@ -1,8 +1,8 @@ struct DynamicArray { - arr: [[stride(4)]] array; + arr: @stride(4) array; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var dynamic_array: DynamicArray; fn f() { diff --git a/tests/out/wgsl/prepostfix-frag.wgsl b/tests/out/wgsl/prepostfix-frag.wgsl index 54147d5a0c..e7a32ef746 100644 --- a/tests/out/wgsl/prepostfix-frag.wgsl +++ b/tests/out/wgsl/prepostfix-frag.wgsl @@ -33,7 +33,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main_1(); return; diff --git a/tests/out/wgsl/quad-vert.wgsl b/tests/out/wgsl/quad-vert.wgsl index b08aae9e68..80a2981be7 100644 --- a/tests/out/wgsl/quad-vert.wgsl +++ b/tests/out/wgsl/quad-vert.wgsl @@ -1,10 +1,10 @@ struct gl_PerVertex { - [[builtin(position)]] gl_Position: vec4; + @builtin(position) gl_Position: vec4; }; struct VertexOutput { - [[location(0)]] member: vec2; - [[builtin(position)]] gl_Position: vec4; + @location(0) @ member: vec2; + @builtin(position) gl_Position: vec4; }; var v_uv: vec2; @@ -20,8 +20,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(1)]] a_uv: vec2, [[location(0)]] a_pos: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(1) @ a_uv: vec2, @location(0) @ a_pos: vec2) -> VertexOutput { a_uv_1 = a_uv; a_pos_1 = a_pos; main_1(); diff --git a/tests/out/wgsl/quad.wgsl b/tests/out/wgsl/quad.wgsl index c5dcbdadc1..d6b6f139cd 100644 --- a/tests/out/wgsl/quad.wgsl +++ b/tests/out/wgsl/quad.wgsl @@ -1,22 +1,22 @@ struct VertexOutput { - [[location(0)]] uv: vec2; - [[builtin(position)]] position: vec4; + @location(0) @ uv: vec2; + @builtin(position) position: vec4; }; let c_scale: f32 = 1.2000000476837158; -[[group(0), binding(0)]] +@group(0) @binding(0) var u_texture: texture_2d; -[[group(0), binding(1)]] +@group(0) @binding(1) var u_sampler: sampler; -[[stage(vertex)]] -fn vert_main([[location(0)]] pos: vec2, [[location(1)]] uv: vec2) -> VertexOutput { +@stage(vertex) +fn vert_main(@location(0) @ pos: vec2, @location(1) @ uv: vec2) -> VertexOutput { return VertexOutput(uv, vec4((c_scale * pos), 0.0, 1.0)); } -[[stage(fragment)]] -fn frag_main([[location(0)]] uv_1: vec2) -> [[location(0)]] vec4 { +@stage(fragment) +fn frag_main(@location(0) @ uv_1: vec2) -> @location(0) @ vec4 { let color = textureSample(u_texture, u_sampler, uv_1); if ((color.w == 0.0)) { discard; @@ -25,7 +25,7 @@ fn frag_main([[location(0)]] uv_1: vec2) -> [[location(0)]] vec4 { return premultiplied; } -[[stage(fragment)]] -fn fs_extra() -> [[location(0)]] vec4 { +@stage(fragment) +fn fs_extra() -> @location(0) @ vec4 { return vec4(0.0, 0.5, 0.0, 0.5); } diff --git a/tests/out/wgsl/quad_glsl-frag.wgsl b/tests/out/wgsl/quad_glsl-frag.wgsl index 6e9b6f1a80..6f1b35afbc 100644 --- a/tests/out/wgsl/quad_glsl-frag.wgsl +++ b/tests/out/wgsl/quad_glsl-frag.wgsl @@ -1,5 +1,5 @@ struct FragmentOutput { - [[location(0)]] o_color: vec4; + @location(0) @ o_color: vec4; }; var v_uv_1: vec2; @@ -10,8 +10,8 @@ fn main_1() { return; } -[[stage(fragment)]] -fn main([[location(0)]] v_uv: vec2) -> FragmentOutput { +@stage(fragment) +fn main(@location(0) @ v_uv: vec2) -> FragmentOutput { v_uv_1 = v_uv; main_1(); let _e7 = o_color; diff --git a/tests/out/wgsl/quad_glsl-vert.wgsl b/tests/out/wgsl/quad_glsl-vert.wgsl index 5af301d959..6acb9561a4 100644 --- a/tests/out/wgsl/quad_glsl-vert.wgsl +++ b/tests/out/wgsl/quad_glsl-vert.wgsl @@ -1,6 +1,6 @@ struct VertexOutput { - [[location(0)]] v_uv: vec2; - [[builtin(position)]] member: vec4; + @location(0) @ v_uv: vec2; + @builtin(position) member: vec4; }; var a_pos_1: vec2; @@ -17,8 +17,8 @@ fn main_1() { return; } -[[stage(vertex)]] -fn main([[location(0)]] a_pos: vec2, [[location(1)]] a_uv: vec2) -> VertexOutput { +@stage(vertex) +fn main(@location(0) @ a_pos: vec2, @location(1) @ a_uv: vec2) -> VertexOutput { a_pos_1 = a_pos; a_uv_1 = a_uv; main_1(); diff --git a/tests/out/wgsl/samplers-frag.wgsl b/tests/out/wgsl/samplers-frag.wgsl index a902c4e835..724f3a0da6 100644 --- a/tests/out/wgsl/samplers-frag.wgsl +++ b/tests/out/wgsl/samplers-frag.wgsl @@ -1,30 +1,30 @@ -[[group(1), binding(0)]] +@group(1) @binding(0) var tex1D: texture_1d; -[[group(1), binding(1)]] +@group(1) @binding(1) var tex1DArray: texture_1d_array; -[[group(1), binding(2)]] +@group(1) @binding(2) var tex2D: texture_2d; -[[group(1), binding(3)]] +@group(1) @binding(3) var tex2DArray: texture_2d_array; -[[group(1), binding(4)]] +@group(1) @binding(4) var texCube: texture_cube; -[[group(1), binding(5)]] +@group(1) @binding(5) var texCubeArray: texture_cube_array; -[[group(1), binding(6)]] +@group(1) @binding(6) var tex3D: texture_3d; -[[group(1), binding(7)]] +@group(1) @binding(7) var samp: sampler; -[[group(1), binding(12)]] +@group(1) @binding(12) var tex2DShadow: texture_depth_2d; -[[group(1), binding(13)]] +@group(1) @binding(13) var tex2DArrayShadow: texture_depth_2d_array; -[[group(1), binding(14)]] +@group(1) @binding(14) var texCubeShadow: texture_depth_cube; -[[group(1), binding(15)]] +@group(1) @binding(15) var texCubeArrayShadow: texture_depth_cube_array; -[[group(1), binding(16)]] +@group(1) @binding(16) var tex3DShadow: texture_3d; -[[group(1), binding(17)]] +@group(1) @binding(17) var sampShadow: sampler_comparison; var texcoord_1: vec4; @@ -566,8 +566,8 @@ fn main_1() { return; } -[[stage(fragment)]] -fn main([[location(0)]] texcoord: vec4) { +@stage(fragment) +fn main(@location(0) @ texcoord: vec4) { texcoord_1 = texcoord; main_1(); return; diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index d27b0a8951..3243c62092 100644 --- a/tests/out/wgsl/shadow.wgsl +++ b/tests/out/wgsl/shadow.wgsl @@ -9,19 +9,19 @@ struct Light { }; struct Lights { - data: [[stride(96)]] array; + data: @stride(96) array; }; let c_ambient: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); let c_max_lights: u32 = 10u; -[[group(0), binding(0)]] +@group(0) @binding(0) var u_globals: Globals; -[[group(0), binding(1)]] +@group(0) @binding(1) var s_lights: Lights; -[[group(0), binding(2)]] +@group(0) @binding(2) var t_shadow: texture_depth_2d_array; -[[group(0), binding(3)]] +@group(0) @binding(3) var sampler_shadow: sampler_comparison; fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { @@ -34,8 +34,8 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4) -> f32 { return _e26; } -[[stage(fragment)]] -fn fs_main([[location(0)]] raw_normal: vec3, [[location(1)]] position: vec4) -> [[location(0)]] vec4 { +@stage(fragment) +fn fs_main(@location(0) @ raw_normal: vec3, @location(1) @ position: vec4) -> @location(0) @ vec4 { var color: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); var i: u32 = 0u; diff --git a/tests/out/wgsl/skybox.wgsl b/tests/out/wgsl/skybox.wgsl index 8b52c97da0..108339493a 100644 --- a/tests/out/wgsl/skybox.wgsl +++ b/tests/out/wgsl/skybox.wgsl @@ -1,6 +1,6 @@ struct VertexOutput { - [[builtin(position)]] position: vec4; - [[location(0)]] uv: vec3; + @builtin(position) position: vec4; + @location(0) @ uv: vec3; }; struct Data { @@ -8,15 +8,15 @@ struct Data { view: mat4x4; }; -[[group(0), binding(0)]] +@group(0) @binding(0) var r_data: Data; -[[group(0), binding(1)]] +@group(0) @binding(1) var r_texture: texture_cube; -[[group(0), binding(2)]] +@group(0) @binding(2) var r_sampler: sampler; -[[stage(vertex)]] -fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput { +@stage(vertex) +fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput { var tmp1_: i32; var tmp2_: i32; @@ -34,8 +34,8 @@ fn vs_main([[builtin(vertex_index)]] vertex_index: u32) -> VertexOutput { return VertexOutput(pos, (inv_model_view * unprojected.xyz)); } -[[stage(fragment)]] -fn fs_main(in: VertexOutput) -> [[location(0)]] vec4 { +@stage(fragment) +fn fs_main(in: VertexOutput) -> @location(0) @ vec4 { let _e5 = textureSample(r_texture, r_sampler, in.uv); return _e5; } diff --git a/tests/out/wgsl/standard.wgsl b/tests/out/wgsl/standard.wgsl index c6a94c4943..5b069057db 100644 --- a/tests/out/wgsl/standard.wgsl +++ b/tests/out/wgsl/standard.wgsl @@ -1,5 +1,5 @@ -[[stage(fragment)]] -fn derivatives([[builtin(position)]] foo: vec4) -> [[location(0)]] vec4 { +@stage(fragment) +fn derivatives(@builtin(position) foo: vec4) -> @location(0) @ vec4 { let x = dpdx(foo); let y = dpdy(foo); let z = fwidth(foo); diff --git a/tests/out/wgsl/swizzle_write-frag.wgsl b/tests/out/wgsl/swizzle_write-frag.wgsl index 04bbd7ec5b..5ca505041c 100644 --- a/tests/out/wgsl/swizzle_write-frag.wgsl +++ b/tests/out/wgsl/swizzle_write-frag.wgsl @@ -30,7 +30,7 @@ fn main_1() { return; } -[[stage(fragment)]] +@stage(fragment) fn main() { main_1(); return; diff --git a/tests/out/wgsl/texture-arg.wgsl b/tests/out/wgsl/texture-arg.wgsl index 2be8f185c4..316f31260b 100644 --- a/tests/out/wgsl/texture-arg.wgsl +++ b/tests/out/wgsl/texture-arg.wgsl @@ -1,6 +1,6 @@ -[[group(0), binding(0)]] +@group(0) @binding(0) var Texture: texture_2d; -[[group(0), binding(1)]] +@group(0) @binding(1) var Sampler: sampler; fn test(Passed_Texture: texture_2d, Passed_Sampler: sampler) -> vec4 { @@ -8,8 +8,8 @@ fn test(Passed_Texture: texture_2d, Passed_Sampler: sampler) -> vec4 { return _e7; } -[[stage(fragment)]] -fn main() -> [[location(0)]] vec4 { +@stage(fragment) +fn main() -> @location(0) @ vec4 { let _e2 = test(Texture, Sampler); return _e2; } diff --git a/tests/spirv-capabilities.rs b/tests/spirv-capabilities.rs index 0567c19f0f..f7511571d4 100644 --- a/tests/spirv-capabilities.rs +++ b/tests/spirv-capabilities.rs @@ -62,7 +62,7 @@ fn sampler1d() { require( &[Ca::Sampled1D], r#" - [[group(0), binding(0)]] + @group(0) @binding(0) var image_1d: texture_1d; "#, ); @@ -73,7 +73,7 @@ fn storage1d() { require( &[Ca::Image1D], r#" - [[group(0), binding(0)]] + @group(0) @binding(0) var image_1d: texture_storage_1d; "#, ); @@ -87,7 +87,7 @@ fn cube_array() { &[Ca::SampledCubeArray], &[Ca::ImageCubeArray], r#" - [[group(0), binding(0)]] + @group(0) @binding(0) var image_cube: texture_cube_array; "#, ); @@ -134,16 +134,16 @@ fn sample_rate_shading() { require( &[Ca::SampleRateShading], r#" - [[stage(fragment)]] - fn f([[location(0), interpolate(perspective, sample)]] x: f32) { } + @stage(fragment) + fn f(@location(0) @interpolate(perspective, sample) x: f32) { } "#, ); require( &[Ca::SampleRateShading], r#" - [[stage(fragment)]] - fn f([[builtin(sample_index)]] x: u32) { } + @stage(fragment) + fn f(@builtin(sample_index) x: u32) { } "#, ); } @@ -153,8 +153,8 @@ fn geometry() { require( &[Ca::Geometry], r#" - [[stage(fragment)]] - fn f([[builtin(primitive_index)]] x: u32) { } + @stage(fragment) + fn f(@builtin(primitive_index) x: u32) { } "#, ); } @@ -165,7 +165,7 @@ fn storage_image_formats() { &[Ca::Shader], &[Ca::StorageImageExtendedFormats], r#" - [[group(0), binding(0)]] + @group(0) @binding(0) var image_rg32f: texture_storage_2d; "#, ); @@ -173,7 +173,7 @@ fn storage_image_formats() { require( &[Ca::StorageImageExtendedFormats], r#" - [[group(0), binding(0)]] + @group(0) @binding(0) var image_rg32f: texture_storage_2d; "#, ); diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index ac0d216880..d6224ce8af 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -128,10 +128,10 @@ fn negative_index() { fn bad_texture() { check( r#" - [[group(0), binding(0)]] var sampler1 : sampler; + @group(0) @binding(0) var sampler1 : sampler; - [[stage(fragment)]] - fn main() -> [[location(0)]] vec4 { + @stage(fragment) + fn main() -> @location(0) vec4 { let a = 3; return textureSample(a, sampler1, vec2(0.0)); } @@ -168,19 +168,19 @@ fn bad_type_cast() { fn bad_texture_sample_type() { check( r#" - [[group(0), binding(0)]] var sampler1 : sampler; - [[group(0), binding(1)]] var texture : texture_2d; + @group(0) @binding(0) var sampler1 : sampler; + @group(0) @binding(1) var texture : texture_2d; - [[stage(fragment)]] - fn main() -> [[location(0)]] vec4 { + @stage(fragment) + fn main() -> @location(0) vec4 { return textureSample(texture, sampler1, vec2(0.0)); } "#, r#"error: texture sample type must be one of f32, i32 or u32, but found bool - ┌─ wgsl:3:63 + ┌─ wgsl:3:60 │ -3 │ [[group(0), binding(1)]] var texture : texture_2d; - │ ^^^^ must be one of f32, i32 or u32 +3 │ @group(0) @binding(1) var texture : texture_2d; + │ ^^^^ must be one of f32, i32 or u32 "#, ); @@ -208,13 +208,13 @@ fn bad_for_initializer() { fn unknown_storage_class() { check( r#" - [[group(0), binding(0)]] var texture: texture_2d; + @group(0) @binding(0) var texture: texture_2d; "#, r#"error: unknown storage class: 'bad' - ┌─ wgsl:2:42 + ┌─ wgsl:2:39 │ -2 │ [[group(0), binding(0)]] var texture: texture_2d; - │ ^^^ unknown storage class +2 │ @group(0) @binding(0) var texture: texture_2d; + │ ^^^ unknown storage class "#, ); @@ -224,14 +224,14 @@ fn unknown_storage_class() { fn unknown_attribute() { check( r#" - [[a]] + @a fn x() {} "#, r#"error: unknown attribute: 'a' - ┌─ wgsl:2:15 + ┌─ wgsl:2:14 │ -2 │ [[a]] - │ ^ unknown attribute +2 │ @a + │ ^ unknown attribute "#, ); @@ -241,13 +241,13 @@ fn unknown_attribute() { fn unknown_built_in() { check( r#" - fn x([[builtin(unknown_built_in)]] y: u32) {} + fn x(@builtin(unknown_built_in) y: u32) {} "#, r#"error: unknown builtin: 'unknown_built_in' - ┌─ wgsl:2:28 + ┌─ wgsl:2:27 │ -2 │ fn x([[builtin(unknown_built_in)]] y: u32) {} - │ ^^^^^^^^^^^^^^^^ unknown builtin +2 │ fn x(@builtin(unknown_built_in) y: u32) {} + │ ^^^^^^^^^^^^^^^^ unknown builtin "#, ); @@ -273,13 +273,13 @@ fn unknown_access() { fn unknown_shader_stage() { check( r#" - [[stage(geometry)]] fn main() {} + @stage(geometry) fn main() {} "#, r#"error: unknown shader stage: 'geometry' - ┌─ wgsl:2:21 + ┌─ wgsl:2:20 │ -2 │ [[stage(geometry)]] fn main() {} - │ ^^^^^^^^ unknown shader stage +2 │ @stage(geometry) fn main() {} + │ ^^^^^^^^ unknown shader stage "#, ); @@ -357,13 +357,13 @@ fn unknown_storage_format() { fn unknown_conservative_depth() { check( r#" - [[early_depth_test(abc)]] fn main() {} + @early_depth_test(abc) fn main() {} "#, r#"error: unknown conservative depth: 'abc' - ┌─ wgsl:2:32 + ┌─ wgsl:2:31 │ -2 │ [[early_depth_test(abc)]] fn main() {} - │ ^^^ unknown conservative depth +2 │ @early_depth_test(abc) fn main() {} + │ ^^^ unknown conservative depth "#, ); @@ -373,13 +373,13 @@ fn unknown_conservative_depth() { fn zero_array_stride() { check( r#" - type zero = [[stride(0)]] array; + type zero = @stride(0) array; "#, r#"error: array stride must not be zero - ┌─ wgsl:2:34 + ┌─ wgsl:2:33 │ -2 │ type zero = [[stride(0)]] array; - │ ^ array stride must not be zero +2 │ type zero = @stride(0) array; + │ ^ array stride must not be zero "#, ); @@ -390,14 +390,14 @@ fn struct_member_zero_size() { check( r#" struct Bar { - [[size(0)]] data: array; + @size(0) data: array; }; "#, r#"error: struct member size or alignment must not be 0 - ┌─ wgsl:3:24 + ┌─ wgsl:3:23 │ -3 │ [[size(0)]] data: array; - │ ^ struct member size or alignment must not be 0 +3 │ @size(0) data: array; + │ ^ struct member size or alignment must not be 0 "#, ); @@ -408,14 +408,14 @@ fn struct_member_zero_align() { check( r#" struct Bar { - [[align(0)]] data: array; + @align(0) data: array; }; "#, r#"error: struct member size or alignment must not be 0 - ┌─ wgsl:3:25 + ┌─ wgsl:3:24 │ -3 │ [[align(0)]] data: array; - │ ^ struct member size or alignment must not be 0 +3 │ @align(0) data: array; + │ ^ struct member size or alignment must not be 0 "#, ); @@ -425,13 +425,13 @@ fn struct_member_zero_align() { fn inconsistent_binding() { check( r#" - fn foo([[builtin(vertex_index), location(0)]] x: u32) {} + fn foo(@builtin(vertex_index) @location(0) x: u32) {} "#, r#"error: input/output binding is not consistent ┌─ wgsl:2:16 │ -2 │ fn foo([[builtin(vertex_index), location(0)]] x: u32) {} - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input/output binding is not consistent +2 │ fn foo(@builtin(vertex_index) @location(0) x: u32) {} + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ input/output binding is not consistent "#, ); @@ -834,7 +834,7 @@ fn invalid_arrays() { check_validation_error! { r#" - type Bad = [[stride(2)]] array; + type Bad = @stride(2) array; "#: Err(naga::valid::ValidationError::Type { error: naga::valid::TypeError::InsufficientArrayStride { stride: 2, base_size: 4 }, @@ -971,8 +971,8 @@ fn pointer_type_equivalence() { fn missing_bindings() { check_validation_error! { " - [[stage(vertex)]] - fn vertex(input: vec4) -> [[location(0)]] vec4 { + @stage(vertex) + fn vertex(input: vec4) -> @location(0) vec4 { return input; } ": @@ -988,8 +988,8 @@ fn missing_bindings() { check_validation_error! { " - [[stage(vertex)]] - fn vertex([[location(0)]] input: vec4, more_input: f32) -> [[location(0)]] vec4 { + @stage(vertex) + fn vertex(@location(0) input: vec4, more_input: f32) -> @location(0) vec4 { return input + more_input; } ": @@ -1005,8 +1005,8 @@ fn missing_bindings() { check_validation_error! { " - [[stage(vertex)]] - fn vertex([[location(0)]] input: vec4) -> vec4 { + @stage(vertex) + fn vertex(@location(0) input: vec4) -> vec4 { return input; } ": @@ -1022,12 +1022,12 @@ fn missing_bindings() { check_validation_error! { " struct VertexIn { - [[location(0)]] pos: vec4; + @location(0) pos: vec4; uv: vec2; }; - [[stage(vertex)]] - fn vertex(input: VertexIn) -> [[location(0)]] vec4 { + @stage(vertex) + fn vertex(input: VertexIn) -> @location(0) vec4 { return input.pos; } ": @@ -1176,7 +1176,7 @@ fn invalid_runtime_sized_arrays() { unsized: Unsized; }; - [[group(0), binding(0)]] var outer: Outer; + @group(0) @binding(0) var outer: Outer; fn fetch(i: i32) -> f32 { return outer.unsized.arr[i]; @@ -1284,7 +1284,7 @@ fn wrong_access_mode() { i: i32; }; - [[group(0), binding(0)]] + @group(0) @binding(0) var globals: Globals; fn store(v: i32) { @@ -1296,7 +1296,7 @@ fn wrong_access_mode() { i: i32; }; - [[group(0), binding(0)]] + @group(0) @binding(0) var globals: Globals; fn store(v: i32) {