From e7971a82bd6281484289e35865b39e4ee66c93ce Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 8 Nov 2024 12:54:13 -0300 Subject: [PATCH] fix `generateWrapFunction()` cache includes --- src/renderers/webgpu/nodes/WGSLNodeBuilder.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/renderers/webgpu/nodes/WGSLNodeBuilder.js b/src/renderers/webgpu/nodes/WGSLNodeBuilder.js index bbeafd0020df66..f3b71446153dd0 100644 --- a/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +++ b/src/renderers/webgpu/nodes/WGSLNodeBuilder.js @@ -247,25 +247,27 @@ class WGSLNodeBuilder extends NodeBuilder { if ( nodeCode === undefined ) { + const includes = []; + let code = `fn ${ functionName }( coord : vec2f ) -> vec2f {\n\n\treturn vec2f(\n`; const addWrapSnippet = ( wrap, axis ) => { if ( wrap === RepeatWrapping ) { - this._include( 'repeatWrapping_float' ); + includes.push( wgslPolyfill.repeatWrapping_float ); code += `\t\ttsl_repeatWrapping_float( coord.${ axis } )`; } else if ( wrap === ClampToEdgeWrapping ) { - this._include( 'clampWrapping_float' ); + includes.push( wgslPolyfill.clampWrapping_float ); code += `\t\ttsl_clampWrapping_float( coord.${ axis } )`; } else if ( wrap === MirroredRepeatWrapping ) { - this._include( 'mirrorWrapping_float' ); + includes.push( wgslPolyfill.mirrorWrapping_float ); code += `\t\ttsl_mirrorWrapping_float( coord.${ axis } )`; @@ -287,7 +289,7 @@ class WGSLNodeBuilder extends NodeBuilder { code += '\n\t);\n\n}\n'; - wgslCodeCache[ functionName ] = nodeCode = new CodeNode( code ); + wgslCodeCache[ functionName ] = nodeCode = new CodeNode( code, includes ); }