WebGPU language JS and the WGSL shader language have been recently updated to make the syntax more robust and compact Following is a set of regular expression calls for updating existing older syntax to the newer version ref https webgpulab xbdev net index php page editor id about let txt stage compute workgroup_size 8 8 const renderPassDescriptor colorAttachments view undefined asign later in frame loadValue r 0 0 g 0 5 b 0 5 a 1 0 storeOp store renderPass endPass stage fragment fn main location 0 uvs vec2 f32 location 0 vec4 f32 builtin position group 0 binding 0 var mySampler sampler fn mysmoothstep edge0 f32 edge1 f32 x f32 f32 struct VSOut builtin position Position vec4 f32 location 0 uvs vec2 f32 struct uniform timer vec4 f32 location 2 iIdx u32 location 1 InstanceIdx u32 loadValue clearValue txt txt replaceAll loadValue g loadOp clear clearValue endPass end txt txt replaceAll endPass g end stage txt txt replaceAll stage vertex g stage vertex txt txt replaceAll stage fragment g stage fragment txt txt replaceAll stage compute g stage compute builtin builtin position changed to builtin position txt txt replaceAll builtin a zA Z_ g builtin 1 group 0 binding 0 var mySampler sampler group 0 binding 0 var mySampler sampler txt txt replaceAll group w binding w g group 1 binding 2 location 0 location 0 txt txt replaceAll location w g location 1 smoothstep txt txt replaceAll fn smoothstep g fn mysmoothstep stage compute workgroup_size 8 8 txt txt replaceAll stage a zA Z_ workgroup_size a zA Z_0 9 g stage 1 workgroup_size 2 location 1 iIdx u32 location 1 interpolate flat iIdx u32 txt txt replaceAll location 0 9 a zA Z_0 9 u32 g 1 interpolate flat 2 remove struct block listing save them for later semicolons commas const regexp struct a zA Z_ r n g const array txt matchAll regexp txt txt replace struct a zA Z_ r n g STRUCT console log num structs array length console log array array Restore struct blocks with added wrapping for let i 0 i array length i let arr array i 0 replaceAll txt txt replace STRUCT arr end for i console log txt textarea id in style width 100 min height 200px input to be updated const renderPassDescriptor colorAttachments view undefined asign later in frame loadValue r 0 0 g 0 5 b 0 5 a 1 0 storeOp store renderPass endPass stage fragment fn main location 0 uvs vec2 f32 location 0 vec4 f32 builtin position group 0 binding 0 var mySampler sampler fn mysmoothstep edge0 f32 edge1 f32 x f32 f32 struct VSOut builtin position Position vec4 f32 location 0 uvs vec2 f32 textarea textarea id out style width 100 min height 200px Updated output is placed here textarea button onclick update Update button script function update let txt document getElementById in value loadValue clearValue txt txt replaceAll loadValue g loadOp clear clearValue endPass end txt txt replaceAll endPass g end stage txt txt replaceAll stage vertex g stage vertex txt txt replaceAll stage fragment g stage fragment txt txt replaceAll stage compute g stage compute builtin builtin position changed to builtin position txt txt replaceAll builtin a zA Z_ g builtin 1 group 0 binding 0 var mySampler sampler group 0 binding 0 var mySampler sampler txt txt replaceAll group w binding w g group 1 binding 2 txt txt replaceAll binding w group w g binding 1 group 2 location 0 location 0 txt txt replaceAll location w g location 1 smoothstep txt txt replaceAll fn smoothstep g fn mysmoothstep depthLoadValue depthLoadOp and depthClearValue txt txt replaceAll depthLoadValue g depthLoadOp clear depthClearValue txt txt replaceAll context configure device device g 1 compositingAlphaMode opaque stage compute workgroup_size 8 8 txt txt replaceAll stage a zA Z_ workgroup_size a zA Z_0 9 g stage 1 workgroup_size 2 remove struct block listing save them for later semicolons commas const regexp struct a zA Z_ r n g const array txt matchAll regexp txt txt replace struct a zA Z_ r n g STRUCT Restore struct blocks with added wrapping for let i 0 i array length i let arr array i 0 replaceAll txt txt replace STRUCT arr end for i document getElementById out value txt console log ready script
xt textarea id in style width 100 min height 200px input to be updated const renderPassDescriptor colorAttachments view undefined asign later in frame loadValue r 0 0 g 0 5 b 0 5 a 1 0 storeOp store renderPass endPass stage fragment fn main location 0 uvs vec2 f32 location 0 vec4 f32 builtin position group 0 binding 0 var mySampler sampler fn mysmoothstep edge0 f32 edge1 f32 x f32 f32 struct VSOut builtin position Position vec4 f32 location 0 uvs vec2 f32 textarea textarea id out style width 100 min height 200px Updated output is placed here textarea button onclick update Update button script function update let txt document getElementById in value loadValue clearValue txt txt replaceAll loadValue g loadOp clear clearValue endPass end txt txt replaceAll endPass g end stage txt txt replaceAll stage vertex g stage vertex txt txt replaceAll stage fragment g stage fragment txt txt replaceAll stage compute g stage compute builtin builtin position changed to builtin position txt txt replaceAll builtin a zA Z_ g builtin 1 group 0 binding 0 var mySampler sampler group 0 binding 0 var mySampler sampler txt txt replaceAll group w binding w g group 1 binding 2 txt txt replaceAll binding w group w g binding 1 group 2 location 0 location 0 txt txt replaceAll location w g location 1 smoothstep txt txt replaceAll fn smoothstep g fn mysmoothstep depthLoadValue depthLoadOp and depthClearValue txt txt replaceAll depthLoadValue g depthLoadOp clear depthClearValue txt txt replaceAll context configure device device g 1 compositingAlphaMode opaque stage compute workgroup_size 8 8 txt txt replaceAll stage a zA Z_ workgroup_size a zA Z_0 9 g stage 1 workgroup_size 2 remove struct block listing save them for later semicolons commas const regexp struct a zA Z_ r n g const array txt matchAll regexp txt txt replace struct a zA Z_ r n g STRUCT Restore struct blocks with added wrapping for let i 0 i array length i let arr array i 0 replaceAll txt txt replace STRUCT arr end for i document getElementById out value txt console log ready script