wgsl: declare attribtues with @

This commit is contained in:
Dzmitry Malyshau 2022-01-19 10:33:06 -05:00
parent adc6821751
commit 4bd1efc34d
88 changed files with 618 additions and 713 deletions

View File

@ -159,7 +159,7 @@ impl<W: Write> Writer<W> {
],
};
self.write_attributes(&attributes, false)?;
self.write_attributes(&attributes)?;
// Add a newline after attribute
writeln!(self.out)?;
@ -244,11 +244,10 @@ impl<W: Write> Writer<W> {
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<W: Write> Writer<W> {
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,62 +330,40 @@ impl<W: Write> Writer<W> {
}
/// 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 {
match *attribute {
Attribute::Location(id) => write!(self.out, "location({})", id)?,
Attribute::Location(id) => write!(self.out, "@location({}) ", id)?,
Attribute::BuiltIn(builtin_attrib) => {
if let Some(builtin) = builtin_str(builtin_attrib) {
write!(self.out, "builtin({})", builtin)?;
write!(self.out, "@builtin({}) ", builtin)?;
} else {
log::warn!("Unsupported builtin attribute: {:?}", builtin_attrib);
}
}
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::Stride(stride) => write!(self.out, "@stride({}) ", stride)?,
Attribute::WorkGroupSize(size) => {
write!(
self.out,
"workgroup_size({}, {}, {})",
"@workgroup_size({}, {}, {}) ",
size[0], size[1], size[2]
)?;
}
Attribute::Binding(id) => write!(self.out, "binding({})", id)?,
Attribute::Group(id) => write!(self.out, "group({})", id)?,
Attribute::Binding(id) => write!(self.out, "@binding({}) ", id)?,
Attribute::Group(id) => write!(self.out, "@group({}) ", id)?,
Attribute::Interpolate(interpolation, sampling) => {
if sampling.is_some() && sampling != Some(crate::Sampling::Center) {
write!(
self.out,
"interpolate({}, {})",
"@interpolate({}, {}) ",
interpolation_str(
interpolation.unwrap_or(crate::Interpolation::Perspective)
),
@ -397,7 +374,7 @@ impl<W: Write> Writer<W> {
{
write!(
self.out,
"interpolate({})",
"@interpolate({}) ",
interpolation_str(
interpolation.unwrap_or(crate::Interpolation::Perspective)
)
@ -405,19 +382,7 @@ impl<W: Write> Writer<W> {
}
}
};
// 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 +412,10 @@ impl<W: Write> Writer<W> {
// 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 +427,7 @@ impl<W: Write> Writer<W> {
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 +1681,10 @@ impl<W: Write> Writer<W> {
) -> 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)?;
}

View File

@ -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 == '_');
@ -724,9 +717,9 @@ fn test_tokens() {
#[test]
fn test_variable_decl() {
sub_test(
"[[ group(0 )]] var< uniform> texture: texture_multisampled_2d <f32 >;",
"@group(0 ) var< uniform> texture: texture_multisampled_2d <f32 >;",
&[
Token::DoubleParen('['),
Token::Attribute,
Token::Word("group"),
Token::Paren('('),
Token::Number {
@ -735,7 +728,6 @@ fn test_variable_decl() {
width: None,
},
Token::Paren(')'),
Token::DoubleParen(']'),
Token::Word("var"),
Token::Paren('<'),
Token::Word("uniform"),

View File

@ -57,7 +57,7 @@ pub enum Token<'a> {
Separator(char),
DoubleColon,
Paren(char),
DoubleParen(char),
Attribute,
Number {
value: &'a str,
ty: NumberType,
@ -89,11 +89,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,
@ -103,8 +101,6 @@ pub enum ExpectedToken<'a> {
WorkgroupSizeSeparator,
/// Expected: 'struct', 'let', 'var', 'type', ';', 'fn', eof
GlobalItem,
/// Expected: ']]', 'size', 'align'
StructAttribute,
}
#[derive(Clone, Debug, Error)]
@ -168,6 +164,7 @@ pub enum Error<'a> {
UnknownLocalFunction(Span),
InitializationTypeMismatch(Span, String),
MissingType(Span),
MissingAttribute(&'static str, Span),
InvalidAtomicPointer(Span),
InvalidAtomicOperandType(Span),
Pointer(&'static str, Span),
@ -191,7 +188,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)
}
@ -234,14 +231,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::TypeAttribute => "type attribute ('stride')".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!(
@ -428,6 +423,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())],
@ -2830,51 +2830,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)?,
}
}
@ -3270,21 +3242,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);
}
@ -4008,24 +3977,12 @@ impl Parser {
&mut self,
lexer: &mut Lexer<'a>,
) -> Result<Option<crate::Binding>, 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);
@ -4174,83 +4131,77 @@ impl Parser {
) -> Result<bool, Error<'a>> {
// 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(')'))?;
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,
))
}
}
}
("group", _) => {
lexer.expect(Token::Paren('('))?;
bind_group = Some(parse_non_negative_sint_literal(lexer, 4)?);
lexer.expect(Token::Paren(')'))?;
for size in workgroup_size.iter_mut() {
if *size == 0 {
*size = 1;
}
}
("stage", _) => {
lexer.expect(Token::Paren('('))?;
}
("early_depth_test", _) => {
let conservative = if lexer.skip(Token::Paren('(')) {
let (ident, ident_span) = lexer.next_ident_with_span()?;
stage = Some(conv::map_shader_stage(ident, ident_span)?);
let value = conv::map_conservative_depth(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;
}
}
}
("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)),
}
match lexer.next() {
(Token::DoubleParen(']'), _) => {
break;
}
(Token::Separator(','), _) => {}
other => {
return Err(Error::Unexpected(other, ExpectedToken::AttributeSeparator))
}
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

View File

@ -159,9 +159,9 @@ fn parse_struct() {
"
struct Foo { x: i32; };
struct Bar {
[[size(16)]] x: vec2<i32>;
[[align(16)]] y: f32;
[[size(32), align(8)]] z: vec3<f32>;
@size(16) x: vec2<i32>;
@align(16) y: f32;
@size(32) @align(8) z: vec3<f32>;
};
struct Empty {};
var<storage,read_write> s: Foo;
@ -384,7 +384,7 @@ fn parse_struct_instantiation() {
b: vec3<f32>;
};
[[stage(fragment)]]
@stage(fragment)
fn fs_main() {
var foo: Foo = Foo(0.0, vec3<f32>(0.0, 1.0, 42.0));
}
@ -398,13 +398,13 @@ fn parse_array_length() {
parse_str(
"
struct Foo {
data: [[stride(4)]] array<u32>;
data: @stride(4) array<u32>;
}; // this is used as both input and output for convenience
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage> foo: Foo;
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> bar: array<u32>;
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<storage> foo: array<u32>;
",
)
.unwrap();
parse_str(
"
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage,read> foo: array<u32>;
",
)
.unwrap();
parse_str(
"
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage,write> foo: array<u32>;
",
)
.unwrap();
parse_str(
"
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage,read_write> foo: array<u32>;
",
)

View File

@ -4,19 +4,19 @@ struct Bar {
matrix: mat4x4<f32>;
matrix_array: array<mat2x2<f32>, 2>;
atom: atomic<i32>;
arr: [[stride(8)]] array<vec2<u32>, 2>;
data: [[stride(8)]] array<i32>;
arr: @stride(8) array<vec2<u32>, 2>;
data: @stride(8) array<i32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage,read_write> bar: Bar;
fn read_from_private(foo: ptr<function, f32>) -> f32 {
return *foo;
}
[[stage(vertex)]]
fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4<f32> {
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<f32> {
return matrix * vec4<f32>(vec4<i32>(value));
}
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn atomics() {
var tmp: i32;
let value = atomicLoad(&bar.atom);

View File

@ -1,4 +1,4 @@
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn main() {
var i = 0;
var i2 = vec2<i32>(0);

View File

@ -16,16 +16,16 @@ struct SimParams {
};
struct Particles {
particles : [[stride(16)]] array<Particle>;
particles : @stride(16) array<Particle>;
};
[[group(0), binding(0)]] var<uniform> params : SimParams;
[[group(0), binding(1)]] var<storage> particlesSrc : Particles;
[[group(0), binding(2)]] var<storage,read_write> particlesDst : Particles;
@group(0) @binding(0) var<uniform> params : SimParams;
@group(0) @binding(1) var<storage> particlesSrc : Particles;
@group(0) @binding(2) var<storage,read_write> 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<u32>) {
@stage(compute) @workgroup_size(64)
fn main(@builtin(global_invocation_id) global_invocation_id : vec3<u32>) {
let index : u32 = global_invocation_id.x;
if (index >= NUM_PARTICLES) {
return;

View File

@ -1,81 +1,81 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_1d<f32>;
fn test_textureLoad_1d(coords: i32, level: i32) -> vec4<f32> {
return textureLoad(image_1d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_2d: texture_2d<f32>;
fn test_textureLoad_2d(coords: vec2<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_2d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_2d_array: texture_2d_array<f32>;
fn test_textureLoad_2d_array(coords: vec2<i32>, index: i32, level: i32) -> vec4<f32> {
return textureLoad(image_2d_array, coords, index, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_3d: texture_3d<f32>;
fn test_textureLoad_3d(coords: vec3<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_3d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_multisampled_2d: texture_multisampled_2d<f32>;
fn test_textureLoad_multisampled_2d(coords: vec2<i32>, sample: i32) -> vec4<f32> {
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<i32>, 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<i32>, 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<i32>, 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<rgba8unorm, write>;
fn test_textureStore_1d(coords: i32, value: vec4<f32>) {
textureStore(image_storage_1d, coords, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_2d: texture_storage_2d<rgba8unorm, write>;
fn test_textureStore_2d(coords: vec2<i32>, value: vec4<f32>) {
textureStore(image_storage_2d, coords, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_2d_array: texture_storage_2d_array<rgba8unorm, write>;
fn test_textureStore_2d_array(coords: vec2<i32>, array_index: i32, value: vec4<f32>) {
textureStore(image_storage_2d_array, coords, array_index, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_3d: texture_storage_3d<rgba8unorm, write>;
fn test_textureStore_3d(coords: vec3<i32>, value: vec4<f32>) {

View File

@ -1,81 +1,81 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_1d<f32>;
fn test_textureLoad_1d(coords: i32, level: i32) -> vec4<f32> {
return textureLoad(image_1d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_2d: texture_2d<f32>;
fn test_textureLoad_2d(coords: vec2<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_2d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_2d_array: texture_2d_array<f32>;
fn test_textureLoad_2d_array(coords: vec2<i32>, index: i32, level: i32) -> vec4<f32> {
return textureLoad(image_2d_array, coords, index, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_3d: texture_3d<f32>;
fn test_textureLoad_3d(coords: vec3<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_3d, coords, level);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_multisampled_2d: texture_multisampled_2d<f32>;
fn test_textureLoad_multisampled_2d(coords: vec2<i32>, sample: i32) -> vec4<f32> {
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<i32>, 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<i32>, 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<i32>, 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<rgba8unorm, write>;
fn test_textureStore_1d(coords: i32, value: vec4<f32>) {
textureStore(image_storage_1d, coords, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_2d: texture_storage_2d<rgba8unorm, write>;
fn test_textureStore_2d(coords: vec2<i32>, value: vec4<f32>) {
textureStore(image_storage_2d, coords, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_2d_array: texture_storage_2d_array<rgba8unorm, write>;
fn test_textureStore_2d_array(coords: vec2<i32>, array_index: i32, value: vec4<f32>) {
textureStore(image_storage_2d_array, coords, array_index, value);
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_storage_3d: texture_storage_3d<rgba8unorm, write>;
fn test_textureStore_3d(coords: vec3<i32>, value: vec4<f32>) {

View File

@ -7,7 +7,7 @@ struct Globals {
d: array<f32>;
};
[[group(0), binding(0)]] var<storage, read_write> globals: Globals;
@group(0) @binding(0) var<storage, read_write> globals: Globals;
fn index_array(i: i32) -> f32 {
return globals.a[i];

View File

@ -7,7 +7,7 @@ struct Globals {
d: array<f32>;
};
[[group(0), binding(0)]] var<storage, read_write> globals: Globals;
@group(0) @binding(0) var<storage, read_write> globals: Globals;
fn index_array(i: i32) -> f32 {
return globals.a[i];

View File

@ -1,8 +1,8 @@
struct PrimeIndices {
data: [[stride(4)]] array<u32>;
data: @stride(4) array<u32>;
}; // this is used as both input and output for convenience
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage,read_write> 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<u32>) {
@stage(compute) @workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
v_indices.data[global_id.x] = collatz_iterations(v_indices.data[global_id.x]);
}

View File

@ -1,5 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main([[builtin(global_invocation_id)]] global_id: vec3<u32>) {
@stage(compute) @workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
//TODO: execution-only barrier?
storageBarrier();
workgroupBarrier();

View File

@ -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<f32> {
@stage(fragment)
fn fragment() -> @location(0) vec4<f32> {
let frag_ls = vec4<f32>(1., 1., 2., 1.).xyz;
let a = textureSampleCompare(point_shadow_textures, point_shadow_textures_sampler, frag_ls, i32(1), 1.);

View File

@ -1,2 +1,2 @@
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn main() {}

View File

@ -5,12 +5,12 @@ struct PushConstants {
var<push_constant> pc: PushConstants;
struct FragmentIn {
[[location(0)]] color: vec4<f32>;
[[builtin(primitive_index)]] primitive_index: u32;
@location(0) color: vec4<f32>;
@builtin(primitive_index) primitive_index: u32;
};
[[stage(fragment)]]
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
if (in.primitive_index % 2u == 0u) {
return in.color;
} else {

View File

@ -7,7 +7,7 @@ fn test_fma() -> vec2<f32> {
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
let a = test_fma();
}

View File

@ -9,7 +9,7 @@ fn test_fma() -> vec2<f32> {
}
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn main() {
let a = test_fma();
}

View File

@ -10,17 +10,17 @@ struct Foo {
// test packed vec3
v1: f32;
};
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> alignment: Foo;
struct Dummy {
arr: array<vec2<f32>>;
};
[[group(0), binding(2)]]
@group(0) @binding(2)
var<storage> dummy: Dummy;
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn main() {
wg[3] = alignment.v1;
wg[2] = alignment.v3.x;

View File

@ -1,25 +1,25 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_mipmapped_src: texture_2d<u32>;
[[group(0), binding(3)]]
@group(0) @binding(3)
var image_multisampled_src: texture_multisampled_2d<u32>;
[[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<rgba8uint, read>;
[[group(0), binding(5)]]
@group(0) @binding(5)
var image_array_src: texture_2d_array<u32>;
[[group(0), binding(6)]]
@group(0) @binding(6)
var image_dup_src: texture_storage_1d<r32uint,read>; // for #1307
[[group(0), binding(7)]]
@group(0) @binding(7)
var image_1d_src: texture_1d<u32>;
[[group(0), binding(2)]]
@group(0) @binding(2)
var image_dst: texture_storage_1d<r32uint,write>;
[[stage(compute), workgroup_size(16)]]
@stage(compute) @workgroup_size(16)
fn main(
[[builtin(local_invocation_id)]] local_id: vec3<u32>,
@builtin(local_invocation_id) local_id: vec3<u32>,
//TODO: https://github.com/gpuweb/gpuweb/issues/1590
//[[builtin(workgroup_size)]] wg_size: vec3<u32>
//@builtin(workgroup_size) wg_size: vec3<u32>
) {
let dim = textureDimensions(image_storage_src);
let itc = dim * vec2<i32>(local_id.xy) % vec2<i32>(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<u32>) {
@stage(compute) @workgroup_size(16, 1, 1)
fn depth_load(@builtin(local_invocation_id) local_id: vec3<u32>) {
let dim: vec2<i32> = textureDimensions(image_storage_src);
let itc: vec2<i32> = ((dim * vec2<i32>(local_id.xy)) % vec2<i32>(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<u32>) {
return;
}
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_1d<f32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var image_2d: texture_2d<f32>;
[[group(0), binding(2)]]
@group(0) @binding(2)
var image_2d_array: texture_2d_array<f32>;
[[group(0), binding(3)]]
@group(0) @binding(3)
var image_cube: texture_cube<f32>;
[[group(0), binding(4)]]
@group(0) @binding(4)
var image_cube_array: texture_cube_array<f32>;
[[group(0), binding(5)]]
@group(0) @binding(5)
var image_3d: texture_3d<f32>;
[[group(0), binding(6)]]
@group(0) @binding(6)
var image_aa: texture_multisampled_2d<f32>;
[[stage(vertex)]]
fn queries() -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn queries() -> @builtin(position) vec4<f32> {
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<f32> {
return vec4<f32>(f32(sum));
}
[[stage(vertex)]]
fn levels_queries() -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn levels_queries() -> @builtin(position) vec4<f32> {
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<f32> {
return vec4<f32>(f32(sum));
}
[[group(1), binding(0)]]
@group(1) @binding(0)
var sampler_reg: sampler;
[[stage(fragment)]]
fn sample() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn sample() -> @location(0) vec4<f32> {
let tc = vec2<f32>(0.5);
let level = 2.3;
let s1d = textureSample(image_1d, sampler_reg, tc.x);
@ -107,13 +107,13 @@ fn sample() -> [[location(0)]] vec4<f32> {
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<f32>(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<f32> {
@stage(fragment)
fn gather() -> @location(0) vec4<f32> {
let tc = vec2<f32>(0.5);
let dref = 0.5;
let s2d = textureGather(1, image_2d, sampler_reg, tc);
@ -132,8 +132,8 @@ fn gather() -> [[location(0)]] vec4<f32> {
return s2d + s2d_offset + s2d_depth + s2d_depth_offset;
}
[[stage(fragment)]]
fn depth_no_comparison() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn depth_no_comparison() -> @location(0) vec4<f32> {
let tc = vec2<f32>(0.5);
let s2d = textureSample(image_2d_depth, sampler_reg, tc);
let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc);

View File

@ -1,32 +1,32 @@
// Testing various parts of the pipeline interface: locations, built-ins, and entry points
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(1)]] varying: f32;
@builtin(position) position: vec4<f32>;
@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<f32>(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<workgroup> output: array<u32, 1>;
[[stage(compute), workgroup_size(1)]]
@stage(compute) @workgroup_size(1)
fn compute(
[[builtin(global_invocation_id)]] global_id: vec3<u32>,
[[builtin(local_invocation_id)]] local_id: vec3<u32>,
[[builtin(local_invocation_index)]] local_index: u32,
[[builtin(workgroup_id)]] wg_id: vec3<u32>,
[[builtin(num_workgroups)]] num_wgs: vec3<u32>,
@builtin(global_invocation_id) global_id: vec3<u32>,
@builtin(local_invocation_id) local_id: vec3<u32>,
@builtin(local_invocation_index) local_index: u32,
@builtin(workgroup_id) wg_id: vec3<u32>,
@builtin(num_workgroups) num_wgs: vec3<u32>,
) {
output[0] = global_id.x + local_id.x + local_index + wg_id.x + num_wgs.x;
}

View File

@ -1,17 +1,17 @@
//TODO: merge with "interface"?
struct FragmentInput {
[[builtin(position)]] position: vec4<f32>;
[[location(0), interpolate(flat)]] flat : u32;
[[location(1), interpolate(linear)]] linear : f32;
[[location(2), interpolate(linear, centroid)]] linear_centroid : vec2<f32>;
[[location(3), interpolate(linear, sample)]] linear_sample : vec3<f32>;
[[location(4), interpolate(perspective)]] perspective : vec4<f32>;
[[location(5), interpolate(perspective, centroid)]] perspective_centroid : f32;
[[location(6), interpolate(perspective, sample)]] perspective_sample : f32;
@builtin(position) position: vec4<f32>;
@location(0) @interpolate(flat) flat : u32;
@location(1) @interpolate(linear) linear : f32;
@location(2) @interpolate(linear, centroid) linear_centroid : vec2<f32>;
@location(3) @interpolate(linear, sample) linear_sample : vec3<f32>;
@location(4) @interpolate(perspective) perspective : vec4<f32>;
@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) { }

View File

@ -1,4 +1,4 @@
[[stage(vertex)]]
@stage(vertex)
fn main() {
let f = 1.0;
let v = vec4<f32>(0.0);

View File

@ -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();

View File

@ -8,7 +8,7 @@ struct DynamicArray {
arr: array<u32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> dynamic_array: DynamicArray;
fn index_unsized(i: i32, v: u32) {

View File

@ -5,15 +5,15 @@
struct InStorage {
a: array<vec4<f32>, 10>;
};
[[group(0), binding(0)]] var<storage> in_storage: InStorage;
@group(0) @binding(0) var<storage> in_storage: InStorage;
struct InUniform {
a: array<vec4<f32>, 20>;
};
[[group(0), binding(1)]] var<uniform> in_uniform: InUniform;
@group(0) @binding(1) var<uniform> in_uniform: InUniform;
// Textures automatically land in the `handle` storage class.
[[group(0), binding(2)]] var image_2d_array: texture_2d_array<f32>;
@group(0) @binding(2) var image_2d_array: texture_2d_array<f32>;
// None of the above.
var<workgroup> in_workgroup: array<f32, 30>;

View File

@ -4,10 +4,10 @@ struct PushConstants {
var<push_constant> pc: PushConstants;
struct FragmentIn {
[[location(0)]] color: vec4<f32>;
@location(0) color: vec4<f32>;
};
[[stage(fragment)]]
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
return in.color * pc.multiplier;
}

View File

@ -2,24 +2,24 @@
let c_scale: f32 = 1.2;
struct VertexOutput {
[[location(0)]] uv : vec2<f32>;
[[builtin(position)]] position : vec4<f32>;
@location(0) uv : vec2<f32>;
@builtin(position) position : vec4<f32>;
};
[[stage(vertex)]]
@stage(vertex)
fn vert_main(
[[location(0)]] pos : vec2<f32>,
[[location(1)]] uv : vec2<f32>,
@location(0) pos : vec2<f32>,
@location(1) uv : vec2<f32>,
) -> VertexOutput {
return VertexOutput(uv, vec4<f32>(c_scale * pos, 0.0, 1.0));
}
// fragment
[[group(0), binding(0)]] var u_texture : texture_2d<f32>;
[[group(0), binding(1)]] var u_sampler : sampler;
@group(0) @binding(0) var u_texture : texture_2d<f32>;
@group(0) @binding(1) var u_sampler : sampler;
[[stage(fragment)]]
fn frag_main([[location(0)]] uv : vec2<f32>) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn frag_main(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
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<f32>) -> [[location(0)]] vec4<f32> {
// 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<f32> {
@stage(fragment)
fn fs_extra() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
}

View File

@ -2,7 +2,7 @@ struct Globals {
num_lights: vec4<u32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> u_globals: Globals;
struct Light {
@ -12,14 +12,14 @@ struct Light {
};
struct Lights {
data: [[stride(96)]] array<Light>;
data: @stride(96) array<Light>;
};
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> 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>) -> f32 {
@ -34,11 +34,11 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4<f32>) -> f32 {
let c_ambient: vec3<f32> = vec3<f32>(0.05, 0.05, 0.05);
let c_max_lights: u32 = 10u;
[[stage(fragment)]]
@stage(fragment)
fn fs_main(
[[location(0)]] raw_normal: vec3<f32>,
[[location(1)]] position: vec4<f32>
) -> [[location(0)]] vec4<f32> {
@location(0) raw_normal: vec3<f32>,
@location(1) position: vec4<f32>
) -> @location(0) vec4<f32> {
let normal: vec3<f32> = normalize(raw_normal);
// accumulate color
var color = c_ambient;

View File

@ -1,17 +1,17 @@
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] uv: vec3<f32>;
@builtin(position) position: vec4<f32>;
@location(0) uv: vec3<f32>;
};
struct Data {
proj_inv: mat4x4<f32>;
view: mat4x4<f32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> 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<f32>;
[[group(0), binding(2)]]
@group(0) @binding(2)
var r_sampler: sampler;
[[stage(fragment)]]
fn fs_main(in: VertexOutput) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(r_texture, r_sampler, in.uv);
}

View File

@ -1,7 +1,7 @@
// Standard functions.
[[stage(fragment)]]
fn derivatives([[builtin(position)]] foo: vec4<f32>) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn derivatives(@builtin(position) foo: vec4<f32>) -> @location(0) vec4<f32> {
let x = dpdx(foo);
let y = dpdy(foo);
let z = fwidth(foo);

View File

@ -1,13 +1,13 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var Texture: texture_2d<f32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var Sampler: sampler;
fn test(Passed_Texture: texture_2d<f32>, Passed_Sampler: sampler) -> vec4<f32> {
return textureSample(Passed_Texture, Passed_Sampler, vec2<f32>(0.0, 0.0));
}
[[stage(fragment)]]
fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
return test(Texture, Sampler);
}

View File

@ -3,12 +3,12 @@ struct ColorMaterial_color {
};
struct FragmentOutput {
[[location(0)]] o_Target: vec4<f32>;
@location(0) o_Target: vec4<f32>;
};
var<private> v_Uv_1: vec2<f32>;
var<private> o_Target: vec4<f32>;
[[group(1), binding(0)]]
@group(1) @binding(0)
var<uniform> global: ColorMaterial_color;
fn main_1() {
@ -21,8 +21,8 @@ fn main_1() {
return;
}
[[stage(fragment)]]
fn main([[location(0)]] v_Uv: vec2<f32>) -> FragmentOutput {
@stage(fragment)
fn main(@location(0) v_Uv: vec2<f32>) -> FragmentOutput {
v_Uv_1 = v_Uv;
main_1();
let _e9 = o_Target;

View File

@ -11,19 +11,19 @@ struct Sprite_size {
};
struct VertexOutput {
[[location(0)]] v_Uv: vec2<f32>;
[[builtin(position)]] member: vec4<f32>;
@location(0) v_Uv: vec2<f32>;
@builtin(position) member: vec4<f32>;
};
var<private> Vertex_Position_1: vec3<f32>;
var<private> Vertex_Normal_1: vec3<f32>;
var<private> Vertex_Uv_1: vec2<f32>;
var<private> v_Uv: vec2<f32>;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> global: Camera;
[[group(2), binding(0)]]
@group(2) @binding(0)
var<uniform> global_1: Transform;
[[group(2), binding(1)]]
@group(2) @binding(1)
var<uniform> global_2: Sprite_size;
var<private> gl_Position: vec4<f32>;
@ -42,8 +42,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] Vertex_Position: vec3<f32>, [[location(1)]] Vertex_Normal: vec3<f32>, [[location(2)]] Vertex_Uv: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) Vertex_Position: vec3<f32>, @location(1) Vertex_Normal: vec3<f32>, @location(2) Vertex_Uv: vec2<f32>) -> VertexOutput {
Vertex_Position_1 = Vertex_Position;
Vertex_Normal_1 = Vertex_Normal;
Vertex_Uv_1 = Vertex_Uv;

View File

@ -7,10 +7,10 @@ struct Transform {
};
struct VertexOutput {
[[location(0)]] v_Position: vec3<f32>;
[[location(1)]] v_Normal: vec3<f32>;
[[location(2)]] v_Uv: vec2<f32>;
[[builtin(position)]] member: vec4<f32>;
@location(0) v_Position: vec3<f32>;
@location(1) v_Normal: vec3<f32>;
@location(2) v_Uv: vec2<f32>;
@builtin(position) member: vec4<f32>;
};
var<private> Vertex_Position_1: vec3<f32>;
@ -19,9 +19,9 @@ var<private> Vertex_Uv_1: vec2<f32>;
var<private> v_Position: vec3<f32>;
var<private> v_Normal: vec3<f32>;
var<private> v_Uv: vec2<f32>;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> global: Camera;
[[group(2), binding(0)]]
@group(2) @binding(0)
var<uniform> global_1: Transform;
var<private> gl_Position: vec4<f32>;
@ -43,8 +43,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] Vertex_Position: vec3<f32>, [[location(1)]] Vertex_Normal: vec3<f32>, [[location(2)]] Vertex_Uv: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) Vertex_Position: vec3<f32>, @location(1) Vertex_Normal: vec3<f32>, @location(2) Vertex_Uv: vec2<f32>) -> VertexOutput {
Vertex_Position_1 = Vertex_Position;
Vertex_Normal_1 = Vertex_Normal;
Vertex_Uv_1 = Vertex_Uv;

View File

@ -1,8 +1,8 @@
struct PrimeIndices {
indices: [[stride(4)]] array<u32>;
indices: @stride(4) array<u32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> global: PrimeIndices;
var<private> gl_GlobalInvocationID: vec3<u32>;
@ -51,8 +51,8 @@ fn main_1() {
return;
}
[[stage(compute), workgroup_size(1, 1, 1)]]
fn main([[builtin(global_invocation_id)]] param: vec3<u32>) {
@stage(compute) @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) param: vec3<u32>) {
gl_GlobalInvocationID = param;
main_1();
return;

View File

@ -3,7 +3,7 @@ fn main_1() {
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -4,7 +4,7 @@ fn main_1() {
let _e1 = f32(1);
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -2,7 +2,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -7,11 +7,11 @@ struct VertexPushConstants {
};
struct VertexOutput {
[[location(0)]] frag_color: vec4<f32>;
[[builtin(position)]] member: vec4<f32>;
@location(0) frag_color: vec4<f32>;
@builtin(position) member: vec4<f32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> global: Globals;
var<push_constant> global_1: VertexPushConstants;
var<private> position_1: vec2<f32>;
@ -32,8 +32,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] position: vec2<f32>, [[location(1)]] color: vec4<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) position: vec2<f32>, @location(1) color: vec4<f32>) -> VertexOutput {
position_1 = position;
color_1 = color;
main_1();

View File

@ -8,7 +8,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -61,7 +61,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -5,7 +5,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -6,7 +6,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -16,7 +16,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -1,12 +1,12 @@
struct Bar {
matrix: mat4x4<f32>;
matrix_array: [[stride(16)]] array<mat2x2<f32>,2>;
matrix_array: @stride(16) array<mat2x2<f32>,2>;
atom: atomic<i32>;
arr: [[stride(8)]] array<vec2<u32>,2>;
data: [[stride(8)]] array<i32>;
arr: @stride(8) array<vec2<u32>,2>;
data: @stride(8) array<i32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> bar: Bar;
fn read_from_private(foo_2: ptr<function, f32>) -> f32 {
@ -14,8 +14,8 @@ fn read_from_private(foo_2: ptr<function, f32>) -> f32 {
return _e2;
}
[[stage(vertex)]]
fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn foo(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4<f32> {
var foo_1: f32 = 0.0;
var c: array<i32,5>;
@ -37,7 +37,7 @@ fn foo([[builtin(vertex_index)]] vi: u32) -> [[builtin(position)]] vec4<f32> {
return (matrix * vec4<f32>(vec4<i32>(value)));
}
[[stage(compute), workgroup_size(1, 1, 1)]]
@stage(compute) @workgroup_size(1, 1, 1)
fn atomics() {
var tmp: i32;

View File

@ -20,8 +20,8 @@ struct CameraPosition {
struct Lights {
AmbientColor: vec4<f32>;
NumLights: vec4<u32>;
PointLights: [[stride(48)]] array<PointLight,10u>;
DirectionalLights: [[stride(32)]] array<DirectionalLight,1u>;
PointLights: @stride(48) array<PointLight,10u>;
DirectionalLights: @stride(32) array<DirectionalLight,1u>;
};
struct StandardMaterial_base_color {
@ -45,7 +45,7 @@ struct StandardMaterial_emissive {
};
struct FragmentOutput {
[[location(0)]] o_Target: vec4<f32>;
@location(0) o_Target: vec4<f32>;
};
var<private> v_WorldPosition_1: vec3<f32>;
@ -53,41 +53,41 @@ var<private> v_WorldNormal_1: vec3<f32>;
var<private> v_Uv_1: vec2<f32>;
var<private> v_WorldTangent_1: vec4<f32>;
var<private> o_Target: vec4<f32>;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> global: CameraViewProj;
[[group(0), binding(1)]]
@group(0) @binding(1)
var<uniform> global_1: CameraPosition;
[[group(1), binding(0)]]
@group(1) @binding(0)
var<uniform> global_2: Lights;
[[group(3), binding(0)]]
@group(3) @binding(0)
var<uniform> global_3: StandardMaterial_base_color;
[[group(3), binding(1)]]
@group(3) @binding(1)
var StandardMaterial_base_color_texture: texture_2d<f32>;
[[group(3), binding(2)]]
@group(3) @binding(2)
var StandardMaterial_base_color_texture_sampler: sampler;
[[group(3), binding(3)]]
@group(3) @binding(3)
var<uniform> global_4: StandardMaterial_roughness;
[[group(3), binding(4)]]
@group(3) @binding(4)
var<uniform> global_5: StandardMaterial_metallic;
[[group(3), binding(5)]]
@group(3) @binding(5)
var StandardMaterial_metallic_roughness_texture: texture_2d<f32>;
[[group(3), binding(6)]]
@group(3) @binding(6)
var StandardMaterial_metallic_roughness_texture_sampler: sampler;
[[group(3), binding(7)]]
@group(3) @binding(7)
var<uniform> global_6: StandardMaterial_reflectance;
[[group(3), binding(8)]]
@group(3) @binding(8)
var StandardMaterial_normal_map: texture_2d<f32>;
[[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<f32>;
[[group(3), binding(11)]]
@group(3) @binding(11)
var StandardMaterial_occlusion_texture_sampler: sampler;
[[group(3), binding(12)]]
@group(3) @binding(12)
var<uniform> global_7: StandardMaterial_emissive;
[[group(3), binding(13)]]
@group(3) @binding(13)
var StandardMaterial_emissive_texture: texture_2d<f32>;
[[group(3), binding(14)]]
@group(3) @binding(14)
var StandardMaterial_emissive_texture_sampler: sampler;
var<private> gl_FrontFacing: bool;
@ -895,8 +895,8 @@ fn main_1() {
return;
}
[[stage(fragment)]]
fn main([[location(0)]] v_WorldPosition: vec3<f32>, [[location(1)]] v_WorldNormal: vec3<f32>, [[location(2)]] v_Uv: vec2<f32>, [[location(3)]] v_WorldTangent: vec4<f32>, [[builtin(front_facing)]] param: bool) -> FragmentOutput {
@stage(fragment)
fn main(@location(0) v_WorldPosition: vec3<f32>, @location(1) v_WorldNormal: vec3<f32>, @location(2) v_Uv: vec2<f32>, @location(3) v_WorldTangent: vec4<f32>, @builtin(front_facing) param: bool) -> FragmentOutput {
v_WorldPosition_1 = v_WorldPosition;
v_WorldNormal_1 = v_WorldNormal;
v_Uv_1 = v_Uv;

View File

@ -7,11 +7,11 @@ struct Transform {
};
struct VertexOutput {
[[location(0)]] v_WorldPosition: vec3<f32>;
[[location(1)]] v_WorldNormal: vec3<f32>;
[[location(2)]] v_Uv: vec2<f32>;
[[location(3)]] v_WorldTangent: vec4<f32>;
[[builtin(position)]] member: vec4<f32>;
@location(0) v_WorldPosition: vec3<f32>;
@location(1) v_WorldNormal: vec3<f32>;
@location(2) v_Uv: vec2<f32>;
@location(3) v_WorldTangent: vec4<f32>;
@builtin(position) member: vec4<f32>;
};
var<private> Vertex_Position_1: vec3<f32>;
@ -21,10 +21,10 @@ var<private> Vertex_Tangent_1: vec4<f32>;
var<private> v_WorldPosition: vec3<f32>;
var<private> v_WorldNormal: vec3<f32>;
var<private> v_Uv: vec2<f32>;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> global: CameraViewProj;
var<private> v_WorldTangent: vec4<f32>;
[[group(2), binding(0)]]
@group(2) @binding(0)
var<uniform> global_1: Transform;
var<private> gl_Position: vec4<f32>;
@ -52,8 +52,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] Vertex_Position: vec3<f32>, [[location(1)]] Vertex_Normal: vec3<f32>, [[location(2)]] Vertex_Uv: vec2<f32>, [[location(3)]] Vertex_Tangent: vec4<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) Vertex_Position: vec3<f32>, @location(1) Vertex_Normal: vec3<f32>, @location(2) Vertex_Uv: vec2<f32>, @location(3) Vertex_Tangent: vec4<f32>) -> VertexOutput {
Vertex_Position_1 = Vertex_Position;
Vertex_Normal_1 = Vertex_Normal;
Vertex_Uv_1 = Vertex_Uv;

View File

@ -180,7 +180,7 @@ fn main1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main1();
return;

View File

@ -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<i32>;

View File

@ -105,7 +105,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main_1();
return;

View File

@ -14,20 +14,20 @@ struct SimParams {
};
struct Particles {
particles: [[stride(16)]] array<Particle>;
particles: @stride(16) array<Particle>;
};
let NUM_PARTICLES: u32 = 1500u;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> params: SimParams;
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> particlesSrc: Particles;
[[group(0), binding(2)]]
@group(0) @binding(2)
var<storage, read_write> particlesDst: Particles;
[[stage(compute), workgroup_size(64, 1, 1)]]
fn main([[builtin(global_invocation_id)]] global_invocation_id: vec3<u32>) {
@stage(compute) @workgroup_size(64, 1, 1)
fn main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) {
var vPos: vec2<f32>;
var vVel: vec2<f32>;
var cMass: vec2<f32>;

View File

@ -1,5 +1,5 @@
struct FragmentOutput {
[[location(0)]] o_color: vec4<f32>;
@location(0) o_color: vec4<f32>;
};
var<private> o_color: vec4<f32>;
@ -37,7 +37,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() -> FragmentOutput {
main_1();
let _e3 = o_color;

View File

@ -1,5 +1,5 @@
struct VertexOutput {
[[builtin(position)]] member: vec4<f32>;
@builtin(position) member: vec4<f32>;
};
var<private> a_pos_1: vec2<f32>;
@ -12,8 +12,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] a_pos: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) a_pos: vec2<f32>) -> VertexOutput {
a_pos_1 = a_pos;
main_1();
let _e5 = gl_Position;

View File

@ -1,8 +1,8 @@
struct PrimeIndices {
data: [[stride(4)]] array<u32>;
data: @stride(4) array<u32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> 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<u32>) {
@stage(compute) @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
let _e8 = v_indices.data[global_id.x];
let _e9 = collatz_iterations(_e8);
v_indices.data[global_id.x] = _e9;

View File

@ -1,8 +1,8 @@
struct Data {
vecs: [[stride(16)]] array<vec4<f32>,42u>;
vecs: @stride(16) array<vec4<f32>,42u>;
};
[[group(1), binding(0)]]
@group(1) @binding(0)
var<uniform> global: Data;
fn function_() -> vec4<f32> {
@ -33,7 +33,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -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<u32>) {
@stage(compute) @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
var pos: i32;
storageBarrier();

View File

@ -14,8 +14,8 @@ struct TestStruct {
};
struct VertexOutput {
[[location(0)]] position: vec2<f32>;
[[location(1)]] a: vec2<f32>;
@location(0) position: vec2<f32>;
@location(1) a: vec2<f32>;
};
var<private> vert: VertexData;
@ -27,8 +27,8 @@ fn main_1() {
}
[[stage(vertex)]]
fn main([[location(0)]] position: vec2<f32>, [[location(1)]] a: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) position: vec2<f32>, @location(1) a: vec2<f32>) -> VertexOutput {
vert.position = position;
vert.a = a;
main_1();

View File

@ -2,7 +2,7 @@ struct type_1 {
member: i32;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> 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_();
}

View File

@ -1,4 +1,4 @@
[[stage(compute), workgroup_size(1, 1, 1)]]
@stage(compute) @workgroup_size(1, 1, 1)
fn main() {
return;
}

View File

@ -211,7 +211,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main_1();
return;

View File

@ -4,14 +4,14 @@ struct PushConstants {
};
struct FragmentIn {
[[location(0)]] color: vec4<f32>;
[[builtin(primitive_index)]] primitive_index: u32;
@location(0) color: vec4<f32>;
@builtin(primitive_index) primitive_index: u32;
};
var<push_constant> pc: PushConstants;
[[stage(fragment)]]
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
if (((in.primitive_index % 2u) == 0u)) {
return in.color;
} else {

View File

@ -37,7 +37,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main_1();
return;

View File

@ -5,7 +5,7 @@ fn test_fma() -> vec2<f32> {
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;

View File

@ -6,7 +6,7 @@ fn main_1() {
let _e2 = i;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -4,19 +4,19 @@ struct Foo {
};
struct Dummy {
arr: [[stride(8)]] array<vec2<f32>>;
arr: @stride(8) array<vec2<f32>>;
};
let Foo_2: bool = true;
var<workgroup> wg: array<f32,10u>;
var<workgroup> at_1: atomic<u32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> alignment: Foo;
[[group(0), binding(2)]]
@group(0) @binding(2)
var<storage> 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;

View File

@ -1,42 +1,42 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_mipmapped_src: texture_2d<u32>;
[[group(0), binding(3)]]
@group(0) @binding(3)
var image_multisampled_src: texture_multisampled_2d<u32>;
[[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<rgba8uint,read>;
[[group(0), binding(5)]]
@group(0) @binding(5)
var image_array_src: texture_2d_array<u32>;
[[group(0), binding(6)]]
@group(0) @binding(6)
var image_dup_src: texture_storage_1d<r32uint,read>;
[[group(0), binding(7)]]
@group(0) @binding(7)
var image_1d_src: texture_1d<u32>;
[[group(0), binding(2)]]
@group(0) @binding(2)
var image_dst: texture_storage_1d<r32uint,write>;
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_1d<f32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var image_2d: texture_2d<f32>;
[[group(0), binding(2)]]
@group(0) @binding(2)
var image_2d_array: texture_2d_array<f32>;
[[group(0), binding(3)]]
@group(0) @binding(3)
var image_cube: texture_cube<f32>;
[[group(0), binding(4)]]
@group(0) @binding(4)
var image_cube_array: texture_cube_array<f32>;
[[group(0), binding(5)]]
@group(0) @binding(5)
var image_3d: texture_3d<f32>;
[[group(0), binding(6)]]
@group(0) @binding(6)
var image_aa: texture_multisampled_2d<f32>;
[[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<u32>) {
@stage(compute) @workgroup_size(16, 1, 1)
fn main(@builtin(local_invocation_id) local_id: vec3<u32>) {
let dim = textureDimensions(image_storage_src);
let itc = ((dim * vec2<i32>(local_id.xy)) % vec2<i32>(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<u32>) {
return;
}
[[stage(compute), workgroup_size(16, 1, 1)]]
fn depth_load([[builtin(local_invocation_id)]] local_id_1: vec3<u32>) {
@stage(compute) @workgroup_size(16, 1, 1)
fn depth_load(@builtin(local_invocation_id) local_id_1: vec3<u32>) {
let dim_1 = textureDimensions(image_storage_src);
let itc_1 = ((dim_1 * vec2<i32>(local_id_1.xy)) % vec2<i32>(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<u32>) {
return;
}
[[stage(vertex)]]
fn queries() -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn queries() -> @builtin(position) vec4<f32> {
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<f32> {
return vec4<f32>(f32(sum));
}
[[stage(vertex)]]
fn levels_queries() -> [[builtin(position)]] vec4<f32> {
@stage(vertex)
fn levels_queries() -> @builtin(position) vec4<f32> {
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<f32> {
return vec4<f32>(f32(sum_1));
}
[[stage(fragment)]]
fn sample() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn sample() -> @location(0) vec4<f32> {
let tc = vec2<f32>(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<f32> {
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<f32>(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<f32> {
@stage(fragment)
fn gather() -> @location(0) vec4<f32> {
let tc_2 = vec2<f32>(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<i32>(3, 1));
@ -118,8 +118,8 @@ fn gather() -> [[location(0)]] vec4<f32> {
return (((s2d_1 + s2d_offset_1) + s2d_depth_1) + s2d_depth_offset);
}
[[stage(fragment)]]
fn depth_no_comparison() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn depth_no_comparison() -> @location(0) vec4<f32> {
let tc_3 = vec2<f32>(0.5);
let s2d_2 = textureSample(image_2d_depth, sampler_reg, tc_3);
let s2d_gather = textureGather(image_2d_depth, sampler_reg, tc_3);

View File

@ -1,31 +1,31 @@
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(1)]] varying: f32;
@builtin(position) position: vec4<f32>;
@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<workgroup> output: array<u32,1>;
[[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<f32>(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<u32>, [[builtin(local_invocation_id)]] local_id: vec3<u32>, [[builtin(local_invocation_index)]] local_index: u32, [[builtin(workgroup_id)]] wg_id: vec3<u32>, [[builtin(num_workgroups)]] num_wgs: vec3<u32>) {
@stage(compute) @workgroup_size(1, 1, 1)
fn compute(@builtin(global_invocation_id) global_id: vec3<u32>, @builtin(local_invocation_id) local_id: vec3<u32>, @builtin(local_invocation_index) local_index: u32, @builtin(workgroup_id) wg_id: vec3<u32>, @builtin(num_workgroups) num_wgs: vec3<u32>) {
output[0] = ((((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x);
return;
}

View File

@ -1,15 +1,15 @@
struct FragmentInput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] flat: u32;
[[location(1), interpolate(linear)]] linear: f32;
[[location(2), interpolate(linear, centroid)]] linear_centroid: vec2<f32>;
[[location(3), interpolate(linear, sample)]] linear_sample: vec3<f32>;
[[location(4)]] perspective: vec4<f32>;
[[location(5), interpolate(perspective, centroid)]] perspective_centroid: f32;
[[location(6), interpolate(perspective, sample)]] perspective_sample: f32;
@builtin(position) position: vec4<f32>;
@location(0) flat: u32;
@location(1) @interpolate(linear) linear: f32;
@location(2) @interpolate(linear, centroid) linear_centroid: vec2<f32>;
@location(3) @interpolate(linear, sample) linear_sample: vec3<f32>;
@location(4) perspective: vec4<f32>;
@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;
}

View File

@ -14,7 +14,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
}

View File

@ -25,7 +25,7 @@ fn main_1() {
let _e129 = vec4<f32>(f32(1));
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -154,7 +154,7 @@ fn main_1() {
return;
}
[[stage(vertex)]]
@stage(vertex)
fn main() {
main_1();
return;

View File

@ -1,4 +1,4 @@
[[stage(vertex)]]
@stage(vertex)
fn main() {
let v = vec4<f32>(0.0);
let a = degrees(1.0);

View File

@ -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();

View File

@ -1,8 +1,8 @@
struct DynamicArray {
arr: [[stride(4)]] array<u32>;
arr: @stride(4) array<u32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<storage, read_write> dynamic_array: DynamicArray;
fn f() {

View File

@ -33,7 +33,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main_1();
return;

View File

@ -1,10 +1,10 @@
struct gl_PerVertex {
[[builtin(position)]] gl_Position: vec4<f32>;
@builtin(position) gl_Position: vec4<f32>;
};
struct VertexOutput {
[[location(0)]] member: vec2<f32>;
[[builtin(position)]] gl_Position: vec4<f32>;
@location(0) member: vec2<f32>;
@builtin(position) gl_Position: vec4<f32>;
};
var<private> v_uv: vec2<f32>;
@ -20,8 +20,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(1)]] a_uv: vec2<f32>, [[location(0)]] a_pos: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(1) a_uv: vec2<f32>, @location(0) a_pos: vec2<f32>) -> VertexOutput {
a_uv_1 = a_uv;
a_pos_1 = a_pos;
main_1();

View File

@ -1,22 +1,22 @@
struct VertexOutput {
[[location(0)]] uv: vec2<f32>;
[[builtin(position)]] position: vec4<f32>;
@location(0) uv: vec2<f32>;
@builtin(position) position: vec4<f32>;
};
let c_scale: f32 = 1.2000000476837158;
[[group(0), binding(0)]]
@group(0) @binding(0)
var u_texture: texture_2d<f32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var u_sampler: sampler;
[[stage(vertex)]]
fn vert_main([[location(0)]] pos: vec2<f32>, [[location(1)]] uv: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn vert_main(@location(0) pos: vec2<f32>, @location(1) uv: vec2<f32>) -> VertexOutput {
return VertexOutput(uv, vec4<f32>((c_scale * pos), 0.0, 1.0));
}
[[stage(fragment)]]
fn frag_main([[location(0)]] uv_1: vec2<f32>) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn frag_main(@location(0) uv_1: vec2<f32>) -> @location(0) vec4<f32> {
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<f32>) -> [[location(0)]] vec4<f32> {
return premultiplied;
}
[[stage(fragment)]]
fn fs_extra() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn fs_extra() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.5, 0.0, 0.5);
}

View File

@ -1,5 +1,5 @@
struct FragmentOutput {
[[location(0)]] o_color: vec4<f32>;
@location(0) o_color: vec4<f32>;
};
var<private> v_uv_1: vec2<f32>;
@ -10,8 +10,8 @@ fn main_1() {
return;
}
[[stage(fragment)]]
fn main([[location(0)]] v_uv: vec2<f32>) -> FragmentOutput {
@stage(fragment)
fn main(@location(0) v_uv: vec2<f32>) -> FragmentOutput {
v_uv_1 = v_uv;
main_1();
let _e7 = o_color;

View File

@ -1,6 +1,6 @@
struct VertexOutput {
[[location(0)]] v_uv: vec2<f32>;
[[builtin(position)]] member: vec4<f32>;
@location(0) v_uv: vec2<f32>;
@builtin(position) member: vec4<f32>;
};
var<private> a_pos_1: vec2<f32>;
@ -17,8 +17,8 @@ fn main_1() {
return;
}
[[stage(vertex)]]
fn main([[location(0)]] a_pos: vec2<f32>, [[location(1)]] a_uv: vec2<f32>) -> VertexOutput {
@stage(vertex)
fn main(@location(0) a_pos: vec2<f32>, @location(1) a_uv: vec2<f32>) -> VertexOutput {
a_pos_1 = a_pos;
a_uv_1 = a_uv;
main_1();

View File

@ -1,30 +1,30 @@
[[group(1), binding(0)]]
@group(1) @binding(0)
var tex1D: texture_1d<f32>;
[[group(1), binding(1)]]
@group(1) @binding(1)
var tex1DArray: texture_1d_array<f32>;
[[group(1), binding(2)]]
@group(1) @binding(2)
var tex2D: texture_2d<f32>;
[[group(1), binding(3)]]
@group(1) @binding(3)
var tex2DArray: texture_2d_array<f32>;
[[group(1), binding(4)]]
@group(1) @binding(4)
var texCube: texture_cube<f32>;
[[group(1), binding(5)]]
@group(1) @binding(5)
var texCubeArray: texture_cube_array<f32>;
[[group(1), binding(6)]]
@group(1) @binding(6)
var tex3D: texture_3d<f32>;
[[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<f32>;
[[group(1), binding(17)]]
@group(1) @binding(17)
var sampShadow: sampler_comparison;
var<private> texcoord_1: vec4<f32>;
@ -566,8 +566,8 @@ fn main_1() {
return;
}
[[stage(fragment)]]
fn main([[location(0)]] texcoord: vec4<f32>) {
@stage(fragment)
fn main(@location(0) texcoord: vec4<f32>) {
texcoord_1 = texcoord;
main_1();
return;

View File

@ -9,19 +9,19 @@ struct Light {
};
struct Lights {
data: [[stride(96)]] array<Light>;
data: @stride(96) array<Light>;
};
let c_ambient: vec3<f32> = vec3<f32>(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
let c_max_lights: u32 = 10u;
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> u_globals: Globals;
[[group(0), binding(1)]]
@group(0) @binding(1)
var<storage> 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>) -> f32 {
@ -34,8 +34,8 @@ fn fetch_shadow(light_id: u32, homogeneous_coords: vec4<f32>) -> f32 {
return _e26;
}
[[stage(fragment)]]
fn fs_main([[location(0)]] raw_normal: vec3<f32>, [[location(1)]] position: vec4<f32>) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn fs_main(@location(0) raw_normal: vec3<f32>, @location(1) position: vec4<f32>) -> @location(0) vec4<f32> {
var color: vec3<f32> = vec3<f32>(0.05000000074505806, 0.05000000074505806, 0.05000000074505806);
var i: u32 = 0u;

View File

@ -1,6 +1,6 @@
struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
[[location(0)]] uv: vec3<f32>;
@builtin(position) position: vec4<f32>;
@location(0) uv: vec3<f32>;
};
struct Data {
@ -8,15 +8,15 @@ struct Data {
view: mat4x4<f32>;
};
[[group(0), binding(0)]]
@group(0) @binding(0)
var<uniform> r_data: Data;
[[group(0), binding(1)]]
@group(0) @binding(1)
var r_texture: texture_cube<f32>;
[[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<f32> {
@stage(fragment)
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let _e5 = textureSample(r_texture, r_sampler, in.uv);
return _e5;
}

View File

@ -1,5 +1,5 @@
[[stage(fragment)]]
fn derivatives([[builtin(position)]] foo: vec4<f32>) -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn derivatives(@builtin(position) foo: vec4<f32>) -> @location(0) vec4<f32> {
let x = dpdx(foo);
let y = dpdy(foo);
let z = fwidth(foo);

View File

@ -30,7 +30,7 @@ fn main_1() {
return;
}
[[stage(fragment)]]
@stage(fragment)
fn main() {
main_1();
return;

View File

@ -1,6 +1,6 @@
[[group(0), binding(0)]]
@group(0) @binding(0)
var Texture: texture_2d<f32>;
[[group(0), binding(1)]]
@group(0) @binding(1)
var Sampler: sampler;
fn test(Passed_Texture: texture_2d<f32>, Passed_Sampler: sampler) -> vec4<f32> {
@ -8,8 +8,8 @@ fn test(Passed_Texture: texture_2d<f32>, Passed_Sampler: sampler) -> vec4<f32> {
return _e7;
}
[[stage(fragment)]]
fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
let _e2 = test(Texture, Sampler);
return _e2;
}

View File

@ -62,7 +62,7 @@ fn sampler1d() {
require(
&[Ca::Sampled1D],
r#"
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_1d<f32>;
"#,
);
@ -73,7 +73,7 @@ fn storage1d() {
require(
&[Ca::Image1D],
r#"
[[group(0), binding(0)]]
@group(0) @binding(0)
var image_1d: texture_storage_1d<rgba8unorm,write>;
"#,
);
@ -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<f32>;
"#,
);
@ -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<rgba16uint, read>;
"#,
);
@ -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<rg32float, read>;
"#,
);

View File

@ -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<f32> {
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
let a = 3;
return textureSample(a, sampler1, vec2<f32>(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<bool>;
@group(0) @binding(0) var sampler1 : sampler;
@group(0) @binding(1) var texture : texture_2d<bool>;
[[stage(fragment)]]
fn main() -> [[location(0)]] vec4<f32> {
@stage(fragment)
fn main() -> @location(0) vec4<f32> {
return textureSample(texture, sampler1, vec2<f32>(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<bool>;
^^^^ must be one of f32, i32 or u32
3 @group(0) @binding(1) var texture : texture_2d<bool>;
^^^^ 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<bad> texture: texture_2d<f32>;
@group(0) @binding(0) var<bad> texture: texture_2d<f32>;
"#,
r#"error: unknown storage class: 'bad'
wgsl:2:42
wgsl:2:39
2 [[group(0), binding(0)]] var<bad> texture: texture_2d<f32>;
^^^ unknown storage class
2 @group(0) @binding(0) var<bad> texture: texture_2d<f32>;
^^^ 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<f32>;
type zero = @stride(0) array<f32>;
"#,
r#"error: array stride must not be zero
wgsl:2:34
wgsl:2:33
2 type zero = [[stride(0)]] array<f32>;
^ array stride must not be zero
2 type zero = @stride(0) array<f32>;
^ array stride must not be zero
"#,
);
@ -390,14 +390,14 @@ fn struct_member_zero_size() {
check(
r#"
struct Bar {
[[size(0)]] data: array<f32>;
@size(0) data: array<f32>;
};
"#,
r#"error: struct member size or alignment must not be 0
wgsl:3:24
wgsl:3:23
3 [[size(0)]] data: array<f32>;
^ struct member size or alignment must not be 0
3 @size(0) data: array<f32>;
^ 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<f32>;
@align(0) data: array<f32>;
};
"#,
r#"error: struct member size or alignment must not be 0
wgsl:3:25
wgsl:3:24
3 [[align(0)]] data: array<f32>;
^ struct member size or alignment must not be 0
3 @align(0) data: array<f32>;
^ 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<f32, 4>;
type Bad = @stride(2) array<f32, 4>;
"#:
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<f32>) -> [[location(0)]] vec4<f32> {
@stage(vertex)
fn vertex(input: vec4<f32>) -> @location(0) vec4<f32> {
return input;
}
":
@ -988,8 +988,8 @@ fn missing_bindings() {
check_validation_error! {
"
[[stage(vertex)]]
fn vertex([[location(0)]] input: vec4<f32>, more_input: f32) -> [[location(0)]] vec4<f32> {
@stage(vertex)
fn vertex(@location(0) input: vec4<f32>, more_input: f32) -> @location(0) vec4<f32> {
return input + more_input;
}
":
@ -1005,8 +1005,8 @@ fn missing_bindings() {
check_validation_error! {
"
[[stage(vertex)]]
fn vertex([[location(0)]] input: vec4<f32>) -> vec4<f32> {
@stage(vertex)
fn vertex(@location(0) input: vec4<f32>) -> vec4<f32> {
return input;
}
":
@ -1022,12 +1022,12 @@ fn missing_bindings() {
check_validation_error! {
"
struct VertexIn {
[[location(0)]] pos: vec4<f32>;
@location(0) pos: vec4<f32>;
uv: vec2<f32>;
};
[[stage(vertex)]]
fn vertex(input: VertexIn) -> [[location(0)]] vec4<f32> {
@stage(vertex)
fn vertex(input: VertexIn) -> @location(0) vec4<f32> {
return input.pos;
}
":
@ -1176,7 +1176,7 @@ fn invalid_runtime_sized_arrays() {
unsized: Unsized;
};
[[group(0), binding(0)]] var<storage> outer: Outer;
@group(0) @binding(0) var<storage> 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<storage> 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<uniform> globals: Globals;
fn store(v: i32) {