From f1c2eda038253a7c8b73d65df2f0f4d98d03eee1 Mon Sep 17 00:00:00 2001 From: sunag Date: Sat, 4 Nov 2023 00:25:44 -0300 Subject: [PATCH] Revert "draft" This reverts commit d425fe2de8ab57e56f5892be695929083054db14. --- examples/jsm/nodes/core/UniformNode.js | 2 -- .../renderers/webgpu/nodes/WGSLNodeBuilder.js | 30 ++++++------------- .../webgpu/utils/WebGPUBindingUtils.js | 2 +- examples/webgpu_sandbox.html | 20 +++++-------- 4 files changed, 17 insertions(+), 37 deletions(-) diff --git a/examples/jsm/nodes/core/UniformNode.js b/examples/jsm/nodes/core/UniformNode.js index 3f5a6b8ceff12f..76f01739531e9e 100644 --- a/examples/jsm/nodes/core/UniformNode.js +++ b/examples/jsm/nodes/core/UniformNode.js @@ -10,8 +10,6 @@ class UniformNode extends InputNode { this.isUniformNode = true; - this.group = 'TEST'; - } getUniformHash( builder ) { diff --git a/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js b/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js index c64ddce9d7bbbb..d8e703572ef399 100644 --- a/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +++ b/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js @@ -270,7 +270,7 @@ class WGSLNodeBuilder extends NodeBuilder { } else { - return node.node.group + '.' + name; + return `NodeUniforms.${name}`; } @@ -345,17 +345,14 @@ class WGSLNodeBuilder extends NodeBuilder { } else { - const uniformsStage = this.uniforms[ shaderStage ] || ( this.uniforms[ shaderStage ] = {} ); - const uniformsGroupName = node.group; - - let uniformsGroup = uniformsStage[ uniformsGroupName ]; + let uniformsGroup = this.uniformsGroup[ shaderStage ]; if ( uniformsGroup === undefined ) { - uniformsGroup = new UniformsGroup( uniformsGroupName ); + uniformsGroup = new UniformsGroup( 'nodeUniforms' ); uniformsGroup.setVisibility( gpuShaderStageLib[ shaderStage ] ); - uniformsStage[ uniformsGroupName ] = uniformsGroup; + this.uniformsGroup[ shaderStage ] = uniformsGroup; bindings.push( uniformsGroup ); @@ -656,9 +653,7 @@ ${ flowData.code } const bindingSnippets = []; const bufferSnippets = []; - const structSnippets = []; - - const uniformGroups = {}; + const groupSnippets = []; let index = this.bindingsOffset[ shaderStage ]; @@ -725,9 +720,6 @@ ${ flowData.code } } else { const vectorType = this.getType( this.getVectorType( uniform.type ) ); - const groupName = uniform.node.group; - - const groupSnippets = uniformGroups[ groupName ] || ( uniformGroups[ groupName ] = [] ); if ( Array.isArray( uniform.value ) === true ) { @@ -745,18 +737,15 @@ ${ flowData.code } } - for ( const group in uniformGroups ) { + let code = bindingSnippets.join( '\n' ); + code += bufferSnippets.join( '\n' ); - const groupSnippets = uniformGroups[ group ]; + if ( groupSnippets.length > 0 ) { - structSnippets.push( this._getWGSLStructBinding( group, groupSnippets.join( ',\n' ), 'uniform', index ++ ) ); + code += this._getWGSLStructBinding( 'NodeUniforms', groupSnippets.join( ',\n' ), 'uniform', index ++ ); } - let code = bindingSnippets.join( '\n' ); - code += bufferSnippets.join( '\n' ); - code += structSnippets.join( '\n' ); - return code; } @@ -826,7 +815,6 @@ ${ flowData.code } this.vertexShader = this._getWGSLVertexCode( shadersData.vertex ); this.fragmentShader = this._getWGSLFragmentCode( shadersData.fragment ); - console.log( this.fragmentShader ); } else { diff --git a/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js b/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js index 9a896081f3caab..1fa6a171375a3a 100644 --- a/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +++ b/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js @@ -120,7 +120,7 @@ class WebGPUBindingUtils { } updateBinding( binding ) { -console.log( binding ); + const backend = this.backend; const device = backend.device; diff --git a/examples/webgpu_sandbox.html b/examples/webgpu_sandbox.html index 0b9f1493804236..89b5d291d2a9bc 100644 --- a/examples/webgpu_sandbox.html +++ b/examples/webgpu_sandbox.html @@ -24,7 +24,7 @@