diff --git a/examples/jsm/transpiler/GLSLDecoder.js b/examples/jsm/transpiler/GLSLDecoder.js index 60864e5971690b..d124ffccfcd855 100644 --- a/examples/jsm/transpiler/GLSLDecoder.js +++ b/examples/jsm/transpiler/GLSLDecoder.js @@ -4,6 +4,10 @@ const unaryOperators = [ '+', '-', '~', '!', '++', '--' ]; +const arithmeticOperators = [ + '*', '/', '%', '+', '-', '<<', '>>' +]; + const precedenceOperators = [ '*', '/', '%', '-', '+', @@ -328,7 +332,11 @@ class GLSLDecoder { if ( ! token.isOperator || i === 0 || i === tokens.length - 1 ) return; // important for negate operator after arithmetic operator: a * -1, a * -( b ) - if ( ( inverse && tokens[ i - 1 ].isOperator ) || ( ! inverse && tokens[ i + 1 ].isOperator ) ) return; + if ( ( inverse && arithmeticOperators.includes( tokens[ i - 1 ].str ) ) || ( ! inverse && arithmeticOperators.includes( tokens[ i + 1 ].str ) ) ) { + + return; + + } if ( groupIndex === 0 && token.str === operator ) { diff --git a/examples/jsm/transpiler/TSLEncoder.js b/examples/jsm/transpiler/TSLEncoder.js index 725622e6458e42..231174585c0a20 100644 --- a/examples/jsm/transpiler/TSLEncoder.js +++ b/examples/jsm/transpiler/TSLEncoder.js @@ -58,7 +58,6 @@ class TSLEncoder { this.global = new Set(); this.overloadings = new Map(); this.iife = false; - this.uniqueNames = false; this.reference = false; this._currentVariable = null; @@ -726,8 +725,6 @@ ${ this.tab }} )`; for ( const param of node.params ) { - let str = `{ name: '${ param.name }', type: '${ param.type }'`; - let name = param.name; if ( param.immutable === false && ( param.qualifier !== 'inout' && param.qualifier !== 'out' ) ) { @@ -746,11 +743,9 @@ ${ this.tab }} )`; } - str += ', qualifier: \'' + param.qualifier + '\''; - } - inputs.push( str + ' }' ); + inputs.push( param.name + ': \'' + param.type + '\'' ); params.push( name ); this._currentProperties[ name ] = param; @@ -795,23 +790,15 @@ ${ this.tab }} )`; ${ bodyStr } -${ this.tab }} )`; - - const layoutInput = inputs.length > 0 ? '\n\t\t' + this.tab + inputs.join( ',\n\t\t' + this.tab ) + '\n\t' + this.tab : ''; +${ this.tab }}`; if ( node.layout !== false && hasPointer === false ) { - const uniqueName = this.uniqueNames ? fnName + '_' + Math.random().toString( 36 ).slice( 2 ) : fnName; - - funcStr += `.setLayout( { -${ this.tab }\tname: '${ uniqueName }', -${ this.tab }\ttype: '${ type }', -${ this.tab }\tinputs: [${ layoutInput }] -${ this.tab }} )`; + funcStr += ', { ' + inputs.join( ', ' ) + ', return: \'' + type + '\' }'; } - funcStr += ';\n'; + funcStr += ' );\n'; this.imports.add( 'Fn' ); diff --git a/examples/webgpu_shadertoy.html b/examples/webgpu_shadertoy.html index 0ecc229c136d51..a29609defe2008 100644 --- a/examples/webgpu_shadertoy.html +++ b/examples/webgpu_shadertoy.html @@ -192,7 +192,6 @@ const encoder = new TSLEncoder(); encoder.iife = iife; - encoder.uniqueNames = true; const jsCode = new Transpiler( decoder, encoder ).parse( glsl );