They removed [[block]] from WGSL struct declarations.

This commit is contained in:
Rezmason
2021-12-14 23:01:53 -08:00
parent 17b6d7b9aa
commit 68ad689e1e
8 changed files with 19 additions and 19 deletions

View File

@@ -123,7 +123,7 @@ const parseAttributes = (str) => {
return attributes;
};
const parseStructLayout = (identifier, body, isBlock, structLayouts) => {
const parseStructLayout = (identifier, body, structLayouts) => {
const fields = [];
let byteOffset = 0;
const lines = body
@@ -154,7 +154,7 @@ const parseStructLayout = (identifier, body, isBlock, structLayouts) => {
const minSizeInBytes = byteOffset;
const align = Math.max(...fields.map((field) => field.align));
const size = Math.ceil(minSizeInBytes / align) * align;
return { identifier, isBlock, fields, size, align };
return { identifier, fields, size, align };
};
const parseStructLayoutsFromShader = (wgsl) => {
@@ -164,10 +164,10 @@ const parseStructLayoutsFromShader = (wgsl) => {
.replace(/\s+/gm, " "); // convert all contiguous whitespace to single space characters
const structLayouts = {};
const structMatches = Array.from(wgsl.matchAll(/(\[\[block\]\])? ?struct (\w+) ?\{(.*?)\};/g)); // [[block]] struct Foo {...}
const structMatches = Array.from(wgsl.matchAll(/struct (\w+) ?\{(.*?)\};/g)); // struct Foo {...}
for (const structMatch of structMatches) {
const [_, block, identifier, body] = structMatch;
const layout = parseStructLayout(identifier, body, block != null, structLayouts);
const [_, identifier, body] = structMatch;
const layout = parseStructLayout(identifier, body, structLayouts);
if (layout != null) {
structLayouts[layout.identifier] = layout;
}