wgsl_reflect
wgsl_reflect copied to clipboard
Add strict mode
trafficstars
Currently invalid syntax will silently fail. I'd like an error returned or an exception thrown instead of the results up until the invalid syntax.
Example:
import wgsl_reflect from "@feng3d/wgsl_reflect";
const { WgslReflect } = wgsl_reflect;
const reflect = new WgslReflect(`
const valid_not_skipped: u32 = 0u;
some invalid syntax;
const valid_but_skipped: u32 = 0u;
`);
console.log(reflect);
/*
_WgslReflect2 {
structs: [],
overrides: [],
uniforms: [],
storages: [],
textures: [],
samplers: [],
functions: [],
aliases: [],
ast: [
Const {
name: 'valid_not_skipped',
type: [Type],
storage: '',
access: '',
value: [LiteralExpr],
attributes: null
}
],
entry: EntryFunctions { vertex: [], fragment: [], compute: [] }
}
*/
I'll look into adding better error exceptions.
For me, I just compile with WebGPU, if it fails then don't call wgsl_reflect.