Duplicate code output in generated WGSL

I have this piece of TSL:

If(diffuseColor.a.mul(alphaFactor).lessThanEqual(0.1337), () => Discard())

and in the output WGSL I see discard twice:

	if ( ( ( DiffuseColor.w * nodeVar1 ) <= 0.1337 ) ) {

		discard;
		discard;
		

	}

Am I doing something silly? Or is this a (probably harmless) bug?

Ah, if I instead write this TSL,

diffuseColor.a.mul(alphaFactor).lessThanEqual(0.1337).discard()

then it no longer produces duplicates:

	if ( ( ( DiffuseColor.w * nodeVar1 ) <= 0.1337 ) ) {

		discard;
		

	}

It might be worth to investigate why the first version produces a double discard statement. Please report this issue at GitHub.

Done, moved to #32589.

1 Like