glsl: Implement all(v) as all_equal(v, true).
authorMatt Turner <mattst88@gmail.com>
Mon, 30 Nov 2015 20:18:27 +0000 (12:18 -0800)
committerMatt Turner <mattst88@gmail.com>
Fri, 18 Dec 2015 18:20:13 +0000 (13:20 -0500)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/builtin_functions.cpp

index 2487a2b1ae5bdfe4254efc239f0d77451068108e..602852a78d1092a6357b1fb81919be28a7e902dc 100644 (file)
@@ -4392,20 +4392,8 @@ builtin_builder::_all(const glsl_type *type)
    ir_variable *v = in_var(type, "v");
    MAKE_SIG(glsl_type::bool_type, always_available, 1, v);
 
-   switch (type->vector_elements) {
-   case 2:
-      body.emit(ret(logic_and(swizzle_x(v), swizzle_y(v))));
-      break;
-   case 3:
-      body.emit(ret(logic_and(logic_and(swizzle_x(v), swizzle_y(v)),
-                              swizzle_z(v))));
-      break;
-   case 4:
-      body.emit(ret(logic_and(logic_and(logic_and(swizzle_x(v), swizzle_y(v)),
-                                        swizzle_z(v)),
-                              swizzle_w(v))));
-      break;
-   }
+   const unsigned vec_elem = v->type->vector_elements;
+   body.emit(ret(expr(ir_binop_all_equal, v, imm(true, vec_elem))));
 
    return sig;
 }