Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGSLNodeBuilder: Fix generateWrapFunction() cache includes #29846

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } )`;

Expand All @@ -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 );

}

Expand Down