diff options
author | Matt Turner <[email protected]> | 2015-11-30 10:50:05 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-12-18 13:20:12 -0500 |
commit | 249bb8961726fe98ea6f3ba625487f6935a9f093 (patch) | |
tree | d20ed1baebfec43414548fdab0e17ac5949245cf | |
parent | 0a6a17b9d72c57f0840d91756924632fee91f2c2 (diff) |
glsl: Implement any(v) as any_nequal(v, false).
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/glsl/builtin_functions.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 0e79a89bff8..2487a2b1ae5 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -550,6 +550,7 @@ private: ir_variable *in_var(const glsl_type *type, const char *name); ir_variable *out_var(const glsl_type *type, const char *name); ir_constant *imm(float f, unsigned vector_elements=1); + ir_constant *imm(bool b, unsigned vector_elements=1); ir_constant *imm(int i, unsigned vector_elements=1); ir_constant *imm(unsigned u, unsigned vector_elements=1); ir_constant *imm(double d, unsigned vector_elements=1); @@ -3012,6 +3013,12 @@ builtin_builder::out_var(const glsl_type *type, const char *name) } ir_constant * +builtin_builder::imm(bool b, unsigned vector_elements) +{ + return new(mem_ctx) ir_constant(b, vector_elements); +} + +ir_constant * builtin_builder::imm(float f, unsigned vector_elements) { return new(mem_ctx) ir_constant(f, vector_elements); @@ -4370,7 +4377,13 @@ builtin_builder::_notEqual(builtin_available_predicate avail, ir_function_signature * builtin_builder::_any(const glsl_type *type) { - return unop(always_available, ir_unop_any, glsl_type::bool_type, type); + ir_variable *v = in_var(type, "v"); + MAKE_SIG(glsl_type::bool_type, always_available, 1, v); + + const unsigned vec_elem = v->type->vector_elements; + body.emit(ret(expr(ir_binop_any_nequal, v, imm(false, vec_elem)))); + + return sig; } ir_function_signature * |