From 141d2e76615c9cbdbe8bec7be4d65d01dc76994c Mon Sep 17 00:00:00 2001 From: Anthony Cowley Date: Fri, 12 Feb 2021 14:26:14 -0500 Subject: [PATCH] [wgsl] ignore offset decorations on struct fields naga does not require offset decorations on struct fields in WGSL source, and automatically adds them to spv output. The `tint` compiler does not automatically add them, and requires that they be present in the WGSL source. A potential confusion is that an spv binary missing required `OpMemberDecorate` instructions that set the field's offset will fail validation when run through `spirv-val`. But since naga automatically produces these offsets, the same spv binary passed through naga will be successfully validated. This change is to ignore these decorations in naga's WGSL front end so that the same WGSL source can be used with naga and tint to produce valid spv. --- src/front/wgsl/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index c2bb94e922..b66cfb7134 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -1197,6 +1197,12 @@ impl Parser { lexer.expect(Token::Paren(')'))?; ready = false; } + Token::Word("offset") if ready => { + lexer.expect(Token::Paren('('))?; + let _offset = lexer.next_uint_literal()?; + lexer.expect(Token::Paren(')'))?; + ready = false; + } other => return Err(Error::Unexpected(other, "decoration separator")), } }