WebGPUNodeBuilder.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. import WebGPUUniformsGroup from '../WebGPUUniformsGroup.js';
  2. import {
  3. FloatNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
  4. ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
  5. } from './WebGPUNodeUniform.js';
  6. import WebGPUNodeSampler from './WebGPUNodeSampler.js';
  7. import { WebGPUNodeSampledTexture, WebGPUNodeSampledCubeTexture } from './WebGPUNodeSampledTexture.js';
  8. import WebGPUUniformBuffer from '../WebGPUUniformBuffer.js';
  9. import WebGPUStorageBuffer from '../WebGPUStorageBuffer.js';
  10. import { getVectorLength, getStrideLength } from '../WebGPUBufferUtils.js';
  11. import WebGPURenderTarget from '../WebGPURenderTarget.js';
  12. import { NodeBuilder, WGSLNodeParser, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
  13. const gpuShaderStageLib = {
  14. 'vertex': GPUShaderStage.VERTEX,
  15. 'fragment': GPUShaderStage.FRAGMENT,
  16. 'compute': GPUShaderStage.COMPUTE
  17. };
  18. const supports = {
  19. instance: true
  20. };
  21. const wgslTypeLib = {
  22. float: 'f32',
  23. int: 'i32',
  24. uint: 'u32',
  25. bool: 'bool',
  26. color: 'vec3<f32>',
  27. vec2: 'vec2<f32>',
  28. ivec2: 'vec2<i32>',
  29. uvec2: 'vec2<u32>',
  30. bvec2: 'vec2<bool>',
  31. vec3: 'vec3<f32>',
  32. ivec3: 'vec3<i32>',
  33. uvec3: 'vec3<u32>',
  34. bvec3: 'vec3<bool>',
  35. vec4: 'vec4<f32>',
  36. ivec4: 'vec4<i32>',
  37. uvec4: 'vec4<u32>',
  38. bvec4: 'vec4<bool>',
  39. mat3: 'mat3x3<f32>',
  40. imat3: 'mat3x3<i32>',
  41. umat3: 'mat3x3<u32>',
  42. bmat3: 'mat3x3<bool>',
  43. mat4: 'mat4x4<f32>',
  44. imat4: 'mat4x4<i32>',
  45. umat4: 'mat4x4<u32>',
  46. bmat4: 'mat4x4<bool>'
  47. };
  48. const wgslMethods = {
  49. dFdx: 'dpdx',
  50. dFdy: 'dpdy',
  51. mod: 'threejs_mod',
  52. lessThanEqual: 'threejs_lessThanEqual',
  53. inversesqrt: 'inverseSqrt'
  54. };
  55. const wgslPolyfill = {
  56. lessThanEqual: new CodeNode( `
  57. fn threejs_lessThanEqual( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
  58. return vec3<bool>( a.x <= b.x, a.y <= b.y, a.z <= b.z );
  59. }
  60. ` ),
  61. mod: new CodeNode( `
  62. fn threejs_mod( x : f32, y : f32 ) -> f32 {
  63. return x - y * floor( x / y );
  64. }
  65. ` ),
  66. repeatWrapping: new CodeNode( `
  67. fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
  68. let uvScaled = vec2<u32>( uv * vec2<f32>( dimension ) );
  69. return ( ( uvScaled % dimension ) + dimension ) % dimension;
  70. }
  71. ` )
  72. };
  73. class WebGPUNodeBuilder extends NodeBuilder {
  74. constructor( object, renderer ) {
  75. super( object, renderer, new WGSLNodeParser() );
  76. this.bindings = { vertex: [], fragment: [], compute: [] };
  77. this.bindingsOffset = { vertex: 0, fragment: 0, compute: 0 };
  78. this.uniformsGroup = {};
  79. this.builtins = {
  80. vertex: new Map(),
  81. fragment: new Map(),
  82. compute: new Map(),
  83. attribute: new Map()
  84. };
  85. }
  86. build() {
  87. const { object, material } = this;
  88. if ( material !== null ) {
  89. NodeMaterial.fromMaterial( material ).build( this );
  90. } else {
  91. this.addFlow( 'compute', object );
  92. }
  93. return super.build();
  94. }
  95. getSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
  96. if ( shaderStage === 'fragment' ) {
  97. return `textureSample( ${textureProperty}, ${textureProperty}_sampler, ${uvSnippet} )`;
  98. } else {
  99. this._include( 'repeatWrapping' );
  100. const dimension = `textureDimensions( ${textureProperty}, 0 )`;
  101. return `textureLoad( ${textureProperty}, threejs_repeatWrapping( ${uvSnippet}, ${dimension} ), 0 )`;
  102. }
  103. }
  104. getVideoSampler( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
  105. if ( shaderStage === 'fragment' ) {
  106. return `textureSampleBaseClampToEdge( ${textureProperty}, ${textureProperty}_sampler, vec2<f32>( ${uvSnippet}.x, 1.0 - ${uvSnippet}.y ) )`;
  107. } else {
  108. console.error( `WebGPURenderer: THREE.VideoTexture does not support ${ shaderStage } shader.` );
  109. }
  110. }
  111. getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
  112. if ( shaderStage === 'fragment' ) {
  113. return `textureSampleLevel( ${textureProperty}, ${textureProperty}_sampler, ${uvSnippet}, ${biasSnippet} )`;
  114. } else {
  115. this._include( 'repeatWrapping' );
  116. const dimension = `textureDimensions( ${textureProperty}, 0 )`;
  117. return `textureLoad( ${textureProperty}, threejs_repeatWrapping( ${uvSnippet}, ${dimension} ), i32( ${biasSnippet} ) )`;
  118. }
  119. }
  120. getTexture( texture, textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
  121. let snippet = null;
  122. if ( texture.isVideoTexture === true ) {
  123. snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
  124. } else {
  125. snippet = this.getSampler( textureProperty, uvSnippet, shaderStage );
  126. }
  127. return snippet;
  128. }
  129. getTextureLevel( texture, textureProperty, uvSnippet, biasSnippet, shaderStage = this.shaderStage ) {
  130. let snippet = null;
  131. if ( texture.isVideoTexture === true ) {
  132. snippet = this.getVideoSampler( textureProperty, uvSnippet, shaderStage );
  133. } else {
  134. snippet = this.getSamplerLevel( textureProperty, uvSnippet, biasSnippet, shaderStage );
  135. }
  136. return snippet;
  137. }
  138. getPropertyName( node, shaderStage = this.shaderStage ) {
  139. if ( node.isNodeVarying === true && node.needsInterpolation === true ) {
  140. if ( shaderStage === 'vertex' ) {
  141. return `NodeVaryings.${ node.name }`;
  142. }
  143. } else if ( node.isNodeUniform === true ) {
  144. const name = node.name;
  145. const type = node.type;
  146. if ( type === 'texture' || type === 'cubeTexture' ) {
  147. return name;
  148. } else if ( type === 'buffer' || type === 'storageBuffer' ) {
  149. return `NodeBuffer_${node.node.id}.${name}`;
  150. } else {
  151. return `NodeUniforms.${name}`;
  152. }
  153. }
  154. return super.getPropertyName( node );
  155. }
  156. getBindings() {
  157. const bindings = this.bindings;
  158. return this.material !== null ? [ ...bindings.vertex, ...bindings.fragment ] : bindings.compute;
  159. }
  160. getUniformFromNode( node, shaderStage, type ) {
  161. const uniformNode = super.getUniformFromNode( node, shaderStage, type );
  162. const nodeData = this.getDataFromNode( node, shaderStage );
  163. if ( nodeData.uniformGPU === undefined ) {
  164. let uniformGPU;
  165. const bindings = this.bindings[ shaderStage ];
  166. if ( type === 'texture' || type === 'cubeTexture' ) {
  167. const sampler = new WebGPUNodeSampler( `${uniformNode.name}_sampler`, uniformNode.node );
  168. let texture = null;
  169. if ( type === 'texture' ) {
  170. texture = new WebGPUNodeSampledTexture( uniformNode.name, uniformNode.node );
  171. } else if ( type === 'cubeTexture' ) {
  172. texture = new WebGPUNodeSampledCubeTexture( uniformNode.name, uniformNode.node );
  173. }
  174. // add first textures in sequence and group for last
  175. const lastBinding = bindings[ bindings.length - 1 ];
  176. const index = lastBinding && lastBinding.isUniformsGroup ? bindings.length - 1 : bindings.length;
  177. if ( shaderStage === 'fragment' ) {
  178. bindings.splice( index, 0, sampler, texture );
  179. uniformGPU = [ sampler, texture ];
  180. } else {
  181. bindings.splice( index, 0, texture );
  182. uniformGPU = [ texture ];
  183. }
  184. } else if ( type === 'buffer' || type === 'storageBuffer' ) {
  185. const bufferClass = type === 'storageBuffer' ? WebGPUStorageBuffer : WebGPUUniformBuffer;
  186. const buffer = new bufferClass( 'NodeBuffer_' + node.id, node.value );
  187. buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
  188. // add first textures in sequence and group for last
  189. const lastBinding = bindings[ bindings.length - 1 ];
  190. const index = lastBinding && lastBinding.isUniformsGroup ? bindings.length - 1 : bindings.length;
  191. bindings.splice( index, 0, buffer );
  192. uniformGPU = buffer;
  193. } else {
  194. let uniformsGroup = this.uniformsGroup[ shaderStage ];
  195. if ( uniformsGroup === undefined ) {
  196. uniformsGroup = new WebGPUUniformsGroup( 'nodeUniforms' );
  197. uniformsGroup.setVisibility( gpuShaderStageLib[ shaderStage ] );
  198. this.uniformsGroup[ shaderStage ] = uniformsGroup;
  199. bindings.push( uniformsGroup );
  200. }
  201. if ( node.isArrayUniformNode === true ) {
  202. uniformGPU = [];
  203. for ( const uniformNode of node.nodes ) {
  204. const uniformNodeGPU = this._getNodeUniform( uniformNode, type );
  205. // fit bounds to buffer
  206. uniformNodeGPU.boundary = getVectorLength( uniformNodeGPU.itemSize );
  207. uniformNodeGPU.itemSize = getStrideLength( uniformNodeGPU.itemSize );
  208. uniformsGroup.addUniform( uniformNodeGPU );
  209. uniformGPU.push( uniformNodeGPU );
  210. }
  211. } else {
  212. uniformGPU = this._getNodeUniform( uniformNode, type );
  213. uniformsGroup.addUniform( uniformGPU );
  214. }
  215. }
  216. nodeData.uniformGPU = uniformGPU;
  217. if ( shaderStage === 'vertex' ) {
  218. this.bindingsOffset[ 'fragment' ] = bindings.length;
  219. }
  220. }
  221. return uniformNode;
  222. }
  223. isReference( type ) {
  224. return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube';
  225. }
  226. getBuiltin( name, property, type, shaderStage = this.shaderStage ) {
  227. const map = this.builtins[ shaderStage ];
  228. if ( map.has( name ) === false ) {
  229. map.set( name, {
  230. name,
  231. property,
  232. type
  233. } );
  234. }
  235. return property;
  236. }
  237. getInstanceIndex() {
  238. if ( this.shaderStage === 'vertex' ) {
  239. return this.getBuiltin( 'instance_index', 'instanceIndex', 'u32', 'attribute' );
  240. }
  241. return 'instanceIndex';
  242. }
  243. getFrontFacing() {
  244. return this.getBuiltin( 'front_facing', 'isFront', 'bool' );
  245. }
  246. getFragCoord() {
  247. return this.getBuiltin( 'position', 'fragCoord', 'vec4<f32>', 'fragment' );
  248. }
  249. isFlipY() {
  250. return false;
  251. }
  252. getAttributes( shaderStage ) {
  253. const snippets = [];
  254. if ( shaderStage === 'compute' ) {
  255. this.getBuiltin( 'global_invocation_id', 'id', 'vec3<u32>', 'attribute' );
  256. }
  257. if ( shaderStage === 'vertex' || shaderStage === 'compute' ) {
  258. for ( const { name, property, type } of this.builtins.attribute.values() ) {
  259. snippets.push( `@builtin( ${name} ) ${property} : ${type}` );
  260. }
  261. const attributes = this.attributes;
  262. const length = attributes.length;
  263. for ( let index = 0; index < length; index ++ ) {
  264. const attribute = attributes[ index ];
  265. const name = attribute.name;
  266. const type = this.getType( attribute.type );
  267. snippets.push( `@location( ${index} ) ${ name } : ${ type }` );
  268. }
  269. }
  270. return snippets.join( ',\n\t' );
  271. }
  272. getVars( shaderStage ) {
  273. const snippets = [];
  274. const vars = this.vars[ shaderStage ];
  275. for ( const variable of vars ) {
  276. const name = variable.name;
  277. const type = this.getType( variable.type );
  278. snippets.push( `\tvar ${name} : ${type};` );
  279. }
  280. return `\n${ snippets.join( '\n' ) }\n`;
  281. }
  282. getVaryings( shaderStage ) {
  283. const snippets = [];
  284. if ( shaderStage === 'vertex' ) {
  285. this.getBuiltin( 'position', 'Vertex', 'vec4<f32>', 'vertex' );
  286. }
  287. if ( shaderStage === 'vertex' || shaderStage === 'fragment' ) {
  288. const varyings = this.varyings;
  289. const vars = this.vars[ shaderStage ];
  290. for ( let index = 0; index < varyings.length; index ++ ) {
  291. const varying = varyings[ index ];
  292. if ( varying.needsInterpolation ) {
  293. snippets.push( `@location( ${index} ) ${ varying.name } : ${ this.getType( varying.type ) }` );
  294. } else if ( vars.includes( varying ) === false ) {
  295. vars.push( varying );
  296. }
  297. }
  298. }
  299. for ( const { name, property, type } of this.builtins[ shaderStage ].values() ) {
  300. snippets.push( `@builtin( ${name} ) ${property} : ${type}` );
  301. }
  302. const code = snippets.join( ',\n\t' );
  303. return shaderStage === 'vertex' ? this._getWGSLStruct( 'NodeVaryingsStruct', '\t' + code ) : code;
  304. }
  305. getUniforms( shaderStage ) {
  306. const uniforms = this.uniforms[ shaderStage ];
  307. const bindingSnippets = [];
  308. const bufferSnippets = [];
  309. const groupSnippets = [];
  310. let index = this.bindingsOffset[ shaderStage ];
  311. for ( const uniform of uniforms ) {
  312. if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' ) {
  313. if ( shaderStage === 'fragment' ) {
  314. bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name}_sampler : sampler;` );
  315. }
  316. const texture = uniform.node.value;
  317. let textureType;
  318. if ( texture.isCubeTexture === true ) {
  319. textureType = 'texture_cube<f32>';
  320. } else if ( texture.isDepthTexture === true ) {
  321. textureType = 'texture_depth_2d';
  322. } else if ( texture.isVideoTexture === true ) {
  323. textureType = 'texture_external';
  324. } else {
  325. textureType = 'texture_2d<f32>';
  326. }
  327. bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : ${textureType};` );
  328. } else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
  329. const bufferNode = uniform.node;
  330. const bufferType = this.getType( bufferNode.bufferType );
  331. const bufferCount = bufferNode.bufferCount;
  332. const bufferCountSnippet = bufferCount > 0 ? ', ' + bufferCount : '';
  333. const bufferSnippet = `\t${uniform.name} : array< ${bufferType}${bufferCountSnippet} >\n`;
  334. const bufferAccessMode = bufferNode.isStorageBufferNode ? 'storage,read_write' : 'uniform';
  335. bufferSnippets.push( this._getWGSLStructBinding( 'NodeBuffer_' + bufferNode.id, bufferSnippet, bufferAccessMode, index ++ ) );
  336. } else {
  337. const vectorType = this.getType( this.getVectorType( uniform.type ) );
  338. if ( Array.isArray( uniform.value ) === true ) {
  339. const length = uniform.value.length;
  340. groupSnippets.push( `uniform ${vectorType}[ ${length} ] ${uniform.name}` );
  341. } else {
  342. groupSnippets.push( `\t${uniform.name} : ${ vectorType}` );
  343. }
  344. }
  345. }
  346. let code = bindingSnippets.join( '\n' );
  347. code += bufferSnippets.join( '\n' );
  348. if ( groupSnippets.length > 0 ) {
  349. code += this._getWGSLStructBinding( 'NodeUniforms', groupSnippets.join( ',\n' ), 'uniform', index ++ );
  350. }
  351. return code;
  352. }
  353. buildCode() {
  354. const shadersData = this.material !== null ? { fragment: {}, vertex: {} } : { compute: {} };
  355. for ( const shaderStage in shadersData ) {
  356. let flow = '// code\n\n';
  357. flow += this.flowCode[ shaderStage ];
  358. const flowNodes = this.flowNodes[ shaderStage ];
  359. const mainNode = flowNodes[ flowNodes.length - 1 ];
  360. for ( const node of flowNodes ) {
  361. const flowSlotData = this.getFlowData( node/*, shaderStage*/ );
  362. const slotName = node.name;
  363. if ( slotName ) {
  364. if ( flow.length > 0 ) flow += '\n';
  365. flow += `\t// flow -> ${ slotName }\n\t`;
  366. }
  367. flow += `${ flowSlotData.code }\n\t`;
  368. if ( node === mainNode && shaderStage !== 'compute' ) {
  369. flow += '// result\n\t';
  370. if ( shaderStage === 'vertex' ) {
  371. flow += 'NodeVaryings.Vertex = ';
  372. } else if ( shaderStage === 'fragment' ) {
  373. flow += 'return ';
  374. }
  375. flow += `${ flowSlotData.result };`;
  376. }
  377. }
  378. const stageData = shadersData[ shaderStage ];
  379. stageData.uniforms = this.getUniforms( shaderStage );
  380. stageData.attributes = this.getAttributes( shaderStage );
  381. stageData.varyings = this.getVaryings( shaderStage );
  382. stageData.vars = this.getVars( shaderStage );
  383. stageData.codes = this.getCodes( shaderStage );
  384. stageData.flow = flow;
  385. }
  386. if ( this.material !== null ) {
  387. this.vertexShader = this._getWGSLVertexCode( shadersData.vertex );
  388. this.fragmentShader = this._getWGSLFragmentCode( shadersData.fragment );
  389. } else {
  390. this.computeShader = this._getWGSLComputeCode( shadersData.compute, ( this.object.workgroupSize || [ 64 ] ).join( ', ' ) );
  391. }
  392. }
  393. getRenderTarget( width, height, options ) {
  394. return new WebGPURenderTarget( width, height, options );
  395. }
  396. getMethod( method ) {
  397. if ( wgslPolyfill[ method ] !== undefined ) {
  398. this._include( method );
  399. }
  400. return wgslMethods[ method ] || method;
  401. }
  402. getType( type ) {
  403. return wgslTypeLib[ type ] || type;
  404. }
  405. isAvailable( name ) {
  406. return supports[ name ] === true;
  407. }
  408. _include( name ) {
  409. wgslPolyfill[ name ].build( this );
  410. }
  411. _getNodeUniform( uniformNode, type ) {
  412. if ( type === 'float' ) return new FloatNodeUniform( uniformNode );
  413. if ( type === 'vec2' ) return new Vector2NodeUniform( uniformNode );
  414. if ( type === 'vec3' ) return new Vector3NodeUniform( uniformNode );
  415. if ( type === 'vec4' ) return new Vector4NodeUniform( uniformNode );
  416. if ( type === 'color' ) return new ColorNodeUniform( uniformNode );
  417. if ( type === 'mat3' ) return new Matrix3NodeUniform( uniformNode );
  418. if ( type === 'mat4' ) return new Matrix4NodeUniform( uniformNode );
  419. throw new Error( `Uniform "${type}" not declared.` );
  420. }
  421. _getWGSLVertexCode( shaderData ) {
  422. return `${ this.getSignature() }
  423. // uniforms
  424. ${shaderData.uniforms}
  425. // varyings
  426. ${shaderData.varyings}
  427. // codes
  428. ${shaderData.codes}
  429. @vertex
  430. fn main( ${shaderData.attributes} ) -> NodeVaryingsStruct {
  431. // system
  432. var NodeVaryings: NodeVaryingsStruct;
  433. // vars
  434. ${shaderData.vars}
  435. // flow
  436. ${shaderData.flow}
  437. return NodeVaryings;
  438. }
  439. `;
  440. }
  441. _getWGSLFragmentCode( shaderData ) {
  442. return `${ this.getSignature() }
  443. // uniforms
  444. ${shaderData.uniforms}
  445. // codes
  446. ${shaderData.codes}
  447. @fragment
  448. fn main( ${shaderData.varyings} ) -> @location( 0 ) vec4<f32> {
  449. // vars
  450. ${shaderData.vars}
  451. // flow
  452. ${shaderData.flow}
  453. }
  454. `;
  455. }
  456. _getWGSLComputeCode( shaderData, workgroupSize ) {
  457. return `${ this.getSignature() }
  458. // system
  459. var<private> instanceIndex : u32;
  460. // uniforms
  461. ${shaderData.uniforms}
  462. // codes
  463. ${shaderData.codes}
  464. @compute @workgroup_size( ${workgroupSize} )
  465. fn main( ${shaderData.attributes} ) {
  466. // system
  467. instanceIndex = id.x;
  468. // vars
  469. ${shaderData.vars}
  470. // flow
  471. ${shaderData.flow}
  472. }
  473. `;
  474. }
  475. _getWGSLStruct( name, vars ) {
  476. return `
  477. struct ${name} {
  478. ${vars}
  479. };`;
  480. }
  481. _getWGSLStructBinding( name, vars, access, binding = 0, group = 0 ) {
  482. const structName = name + 'Struct';
  483. const structSnippet = this._getWGSLStruct( structName, vars );
  484. return `${structSnippet}
  485. @binding( ${binding} ) @group( ${group} )
  486. var<${access}> ${name} : ${structName};`;
  487. }
  488. }
  489. export default WebGPUNodeBuilder;