GLSL mix implementation
Added mix implementation with a bvec as a 3rd argument,
which is basically a select.
Fixes 18 failures in dEQP-GLES3.
Change-Id: Ifaf4a27e1a25fbaad979a7d26ad4a424631acd08
Reviewed-on: https://swiftshader-review.googlesource.com/16288
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/compiler/Initialize.cpp b/src/OpenGL/compiler/Initialize.cpp
index 090faa8..87ea6ef 100644
--- a/src/OpenGL/compiler/Initialize.cpp
+++ b/src/OpenGL/compiler/Initialize.cpp
@@ -103,6 +103,7 @@
symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, genUType, genUType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, float1);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genType);
+ symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genBType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", genType, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", float1, genType);
symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType);
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 6afc880..5f05e46 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -1649,7 +1649,19 @@
emit(getOpcode(sw::Shader::OPCODE_MIN, result), result, result, arg[2]);
}
break;
- case EOpMix: if(visit == PostVisit) emit(sw::Shader::OPCODE_LRP, result, arg[2], arg[1], arg[0]); break;
+ case EOpMix:
+ if(visit == PostVisit)
+ {
+ if(arg[2]->getAsTyped()->getBasicType() == EbtBool)
+ {
+ emit(sw::Shader::OPCODE_SELECT, result, arg[2], arg[1], arg[0]);
+ }
+ else
+ {
+ emit(sw::Shader::OPCODE_LRP, result, arg[2], arg[1], arg[0]);
+ }
+ }
+ break;
case EOpStep: if(visit == PostVisit) emit(sw::Shader::OPCODE_STEP, result, arg[0], arg[1]); break;
case EOpSmoothStep: if(visit == PostVisit) emit(sw::Shader::OPCODE_SMOOTH, result, arg[0], arg[1], arg[2]); break;
case EOpDistance: if(visit == PostVisit) emit(sw::Shader::OPCODE_DIST(dim(arg[0])), result, arg[0], arg[1]); break;