mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
naga: Accept var<function> syntax for local variables (#8710)
This commit is contained in:
1 parent
a35e5a28c1
commit
12259ba9f4
5 files changed
+53
No files matched your search
@@ -206,6 +206,7 @@ By @cwfitzgerald in [#8609](https://github.com/gfx-rs/wgpu/pull/8609).
|
||||
|
||||
- Prevent UB with invalid ray query calls on spirv. By @Vecvec in [#8390](https://github.com/gfx-rs/wgpu/pull/8390).
|
||||
- Update the set of binding_array capabilities. In most cases, they are set automatically from `wgpu` features, and this change should not be user-visible. By @andyleiserson in [#8671](https://github.com/gfx-rs/wgpu/pull/8671).
|
||||
- Naga now accepts the `var<function>` syntax for declaring local variables. By @andyleiserson in [#8710](https://github.com/gfx-rs/wgpu/pull/8710).
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ webgpu:shader,execution,flow_control,return:*
|
||||
// Many other vertex_buffer_access subtests also passing, but there are too many to enumerate.
|
||||
// Fails on Metal in CI only, not when running locally.
|
||||
fails-if(metal) webgpu:shader,execution,robust_access_vertex:vertex_buffer_access:indexed=true;indirect=false;drawCallTestParameter="baseVertex";type="float32x4";additionalBuffers=4;partialLastNumber=false;offsetVertexBuffer=true
|
||||
webgpu:shader,validation,expression,call,builtin,all:arguments:test="ptr_deref"
|
||||
webgpu:shader,validation,expression,call,builtin,max:values:*
|
||||
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break"
|
||||
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break_if"
|
||||
|
||||
@@ -199,6 +199,7 @@ pub(crate) enum Error<'a> {
|
||||
InvalidIdentifierUnderscore(Span),
|
||||
ReservedIdentifierPrefix(Span),
|
||||
UnknownAddressSpace(Span),
|
||||
InvalidLocalVariableAddressSpace(Span),
|
||||
RepeatedAttribute(Span),
|
||||
UnknownAttribute(Span),
|
||||
UnknownBuiltin(Span),
|
||||
@@ -660,6 +661,11 @@ impl<'a> Error<'a> {
|
||||
labels: vec![(bad_span, "unknown address space".into())],
|
||||
notes: vec![],
|
||||
},
|
||||
Error::InvalidLocalVariableAddressSpace(bad_span) => ParseError {
|
||||
message: format!("invalid address space for local variable: `{}`", &source[bad_span]),
|
||||
labels: vec![(bad_span, "local variables can only use 'function' address space".into())],
|
||||
notes: vec![],
|
||||
},
|
||||
Error::RepeatedAttribute(bad_span) => ParseError {
|
||||
message: format!("repeated attribute: `{}`", &source[bad_span]),
|
||||
labels: vec![(bad_span, "repeated attribute".into())],
|
||||
|
||||
@@ -2273,6 +2273,16 @@ impl Parser {
|
||||
"var" => {
|
||||
let _ = lexer.next();
|
||||
|
||||
if lexer.skip(Token::Paren('<')) {
|
||||
let (class_str, span) = lexer.next_ident_with_span()?;
|
||||
if class_str != "function" {
|
||||
return Err(Box::new(Error::InvalidLocalVariableAddressSpace(
|
||||
span,
|
||||
)));
|
||||
}
|
||||
lexer.expect(Token::Paren('>'))?;
|
||||
}
|
||||
|
||||
let name = lexer.next_ident()?;
|
||||
let ty = if lexer.skip(Token::Separator(':')) {
|
||||
let ty = this.type_decl(lexer, ctx)?;
|
||||
|
||||
@@ -456,6 +456,41 @@ fn parse_assignment_statements() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_local_var_address_space() {
|
||||
parse_str(
|
||||
"
|
||||
fn foo() {
|
||||
var<function> a = true;
|
||||
var<function> b: i32 = 5;
|
||||
var c = 10;
|
||||
}",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let error = parse_str(
|
||||
"fn foo() {
|
||||
var<private> x: i32 = 5;
|
||||
}",
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(
|
||||
error.message(),
|
||||
"invalid address space for local variable: `private`",
|
||||
);
|
||||
|
||||
let error = parse_str(
|
||||
"fn foo() {
|
||||
var<storage> x: i32 = 5;
|
||||
}",
|
||||
)
|
||||
.unwrap_err();
|
||||
assert_eq!(
|
||||
error.message(),
|
||||
"invalid address space for local variable: `storage`",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binary_expression_mixed_scalar_and_vector_operands() {
|
||||
for (operand, expect_splat) in [
|
||||
|
||||
Reference in new issue
Block a user