Skip to content

Commit 21829d8

Browse files
authored
TSL: Make not() on vector produce component-wise logical not (#33442)
1 parent 523f780 commit 21829d8

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/nodes/math/OperatorNode.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ class OperatorNode extends TempNode {
128128

129129
return builder.getIntegerType( typeA );
130130

131-
} else if ( op === '!' || op === '&&' || op === '||' || op === '^^' ) {
131+
} else if ( op === '&&' || op === '||' || op === '^^' ) {
132132

133133
return 'bool';
134134

135+
} else if ( op === '!' ) {
136+
137+
const typeLength = builder.getTypeLength( typeA );
138+
139+
return typeLength > 1 ? `bvec${ typeLength }` : 'bool';
140+
135141
} else if ( op === '==' || op === '!=' || op === '<' || op === '>' || op === '<=' || op === '>=' ) {
136142

137143
const typeLength = Math.max( builder.getTypeLength( typeA ), builder.getTypeLength( typeB ) );
@@ -330,9 +336,23 @@ class OperatorNode extends TempNode {
330336

331337
}
332338

333-
} else if ( op === '!' || op === '~' ) {
339+
} else if ( op === '!' ) {
340+
341+
if ( isGLSL && builder.isVector( typeA ) ) {
342+
343+
return builder.format( `not( ${a} )`, output );
344+
345+
} else {
346+
347+
// WGSL and scalars on GLSL
348+
349+
return builder.format( `( ${op} ${a} )`, typeA, output );
350+
351+
}
352+
353+
} else if ( op === '~' ) {
334354

335-
return builder.format( `(${op}${a})`, typeA, output );
355+
return builder.format( `( ${op} ${a} )`, typeA, output );
336356

337357
} else if ( fnOpSnippet ) {
338358

0 commit comments

Comments
 (0)