[glsl-in] Fix mix ordering for boolean selector

The mix builtin is defined with the inverse order for it's arguments
compared to the IR when the selector is a boolean vector.
This commit is contained in:
João Capucho 2021-08-03 00:19:31 +01:00 committed by Dzmitry Malyshau
parent a1395ddb99
commit 2ff7dcb417

View File

@ -730,10 +730,19 @@ impl Program {
.resolve_type(ctx, selector, selector_meta)?
.scalar_kind()
{
// When the selector is a boolean vector the result is
// calculated per component, for each component of the
// selector if it's false the respective component from the
// first argument is selected, if it's true the respective
// component from the second argument is selected
//
// Note(jcapucho): yes, it's inverted in comparison with the
// IR and SPIR-V and yes I spent a full debugging a shader
// because of this weird behavior
Some(ScalarKind::Bool) => Expression::Select {
condition: selector,
accept: arg,
reject: arg1,
accept: arg1,
reject: arg,
},
_ => Expression::Math {
fun: MathFunction::Mix,