mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
They removed [[block]] from WGSL struct declarations.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user