From 68ad689e1e3b6a7b0196993888338e7aed573471 Mon Sep 17 00:00:00 2001 From: Rezmason Date: Tue, 14 Dec 2021 23:01:53 -0800 Subject: [PATCH] They removed [[block]] from WGSL struct declarations. --- js/webgpu/main.js | 2 +- lib/gpu-buffer.js | 10 +++++----- shaders/wgsl/bloomBlur.wgsl | 2 +- shaders/wgsl/bloomCombine.wgsl | 2 +- shaders/wgsl/palettePass.wgsl | 6 +++--- shaders/wgsl/rainPass.wgsl | 8 ++++---- shaders/wgsl/resurrectionPass.wgsl | 4 ++-- shaders/wgsl/stripePass.wgsl | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/js/webgpu/main.js b/js/webgpu/main.js index e41a8b3..8a95dba 100644 --- a/js/webgpu/main.js +++ b/js/webgpu/main.js @@ -50,7 +50,7 @@ export default async (canvas, config) => { GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST, }; - const timeUniforms = structs.from(`[[block]] struct Time { seconds : f32; frames : i32; };`).Time; + const timeUniforms = structs.from(`struct Time { seconds : f32; frames : i32; };`).Time; const timeBuffer = makeUniformBuffer(device, timeUniforms); const context = { diff --git a/lib/gpu-buffer.js b/lib/gpu-buffer.js index 280dec1..b5fb6c7 100644 --- a/lib/gpu-buffer.js +++ b/lib/gpu-buffer.js @@ -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; } diff --git a/shaders/wgsl/bloomBlur.wgsl b/shaders/wgsl/bloomBlur.wgsl index fb778c2..cfcaf75 100644 --- a/shaders/wgsl/bloomBlur.wgsl +++ b/shaders/wgsl/bloomBlur.wgsl @@ -1,6 +1,6 @@ let ONE_OVER_SQRT_2PI = 0.39894; -[[block]] struct Config { +struct Config { bloomRadius : f32; direction : vec2; }; diff --git a/shaders/wgsl/bloomCombine.wgsl b/shaders/wgsl/bloomCombine.wgsl index 689511c..3be338e 100644 --- a/shaders/wgsl/bloomCombine.wgsl +++ b/shaders/wgsl/bloomCombine.wgsl @@ -1,4 +1,4 @@ -[[block]] struct Config { +struct Config { bloomStrength : f32; pyramidHeight : f32; }; diff --git a/shaders/wgsl/palettePass.wgsl b/shaders/wgsl/palettePass.wgsl index 5935505..60b3fe2 100644 --- a/shaders/wgsl/palettePass.wgsl +++ b/shaders/wgsl/palettePass.wgsl @@ -1,13 +1,13 @@ -[[block]] struct Config { +struct Config { ditherMagnitude : f32; backgroundColor : vec3; }; -[[block]] struct Palette { +struct Palette { colors : array, 512>; }; -[[block]] struct Time { +struct Time { seconds : f32; frames : i32; }; diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index e417a1a..8538d4a 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -1,7 +1,7 @@ // This shader module is the star of the show. // It is where the cell states update and the symbols get drawn to the screen. -[[block]] struct Config { +struct Config { // common properties used for compute and rendering animationSpeed : f32; glyphSequenceLength : i32; @@ -41,20 +41,20 @@ }; // The properties that change over time get their own buffer. -[[block]] struct Time { +struct Time { seconds : f32; frames : i32; }; // The properties related to the size of the canvas get their own buffer. -[[block]] struct Scene { +struct Scene { screenSize : vec2; camera : mat4x4; transform : mat4x4; }; // The array of cells that the compute shader updates, and the fragment shader draws. -[[block]] struct CellData { +struct CellData { cells: array>; }; diff --git a/shaders/wgsl/resurrectionPass.wgsl b/shaders/wgsl/resurrectionPass.wgsl index d601210..2732476 100644 --- a/shaders/wgsl/resurrectionPass.wgsl +++ b/shaders/wgsl/resurrectionPass.wgsl @@ -1,9 +1,9 @@ -[[block]] struct Config { +struct Config { ditherMagnitude : f32; backgroundColor : vec3; }; -[[block]] struct Time { +struct Time { seconds : f32; frames : i32; }; diff --git a/shaders/wgsl/stripePass.wgsl b/shaders/wgsl/stripePass.wgsl index 4bcf153..20f94e7 100644 --- a/shaders/wgsl/stripePass.wgsl +++ b/shaders/wgsl/stripePass.wgsl @@ -1,9 +1,9 @@ -[[block]] struct Config { +struct Config { ditherMagnitude : f32; backgroundColor : vec3; }; -[[block]] struct Time { +struct Time { seconds : f32; frames : i32; };