--- src/glsl/builtin_functions.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++ src/glsl/ir_builder.cpp | 5 +++++ src/glsl/ir_builder.h | 2 ++ 3 files changed, 52 insertions(+)
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 481a456..7399e8f 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -402,6 +402,8 @@ private: ir_expression *asin_expr(ir_variable *x); + ir_expression *min3_expr(ir_variable *x, ir_variable *y, ir_variable *z); + /** * Call function \param f with parameters specified as the linked * list \param params of \c ir_variable objects. \param ret should @@ -576,6 +578,11 @@ private: ir_function_signature *_atomic_op(const char *intrinsic, builtin_available_predicate avail); + ir_function_signature *_min3(builtin_available_predicate avail, + const glsl_type *x_type, + const glsl_type *y_type, + const glsl_type *z_type); + #undef B0 #undef B1 #undef B2 @@ -2112,6 +2119,23 @@ builtin_builder::create_builtins() shader_atomic_counters), NULL); + add_function("min3", + _min3(shader_trinary_mimax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type), + _min3(shader_trinary_mimax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type), + _min3(shader_trinary_mimax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type), + _min3(shader_trinary_mimax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type), + + _min3(shader_trinary_mimax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type), + _min3(shader_trinary_mimax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type), + _min3(shader_trinary_mimax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type), + _min3(shader_trinary_mimax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type), + + _min3(shader_trinary_mimax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type), + _min3(shader_trinary_mimax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type), + _min3(shader_trinary_mimax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type), + _min3(shader_trinary_mimax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type), + NULL); + #undef F #undef FI #undef FIU @@ -2327,6 +2351,12 @@ builtin_builder::asin_expr(ir_variable *x) mul(abs(x), imm(-0.03102955f)))))))))); } +ir_expression * +builtin_builder::min3_expr(ir_variable *x, ir_variable *y, ir_variable *z) +{ + return min(x, min(y,z)); +} + ir_call * builtin_builder::call(ir_function *f, ir_variable *ret, exec_list params) { @@ -3997,6 +4027,21 @@ builtin_builder::_atomic_op(const char *intrinsic, return sig; } +ir_function_signature * +builtin_builder::_min3(builtin_available_predicate avail, + const glsl_type *x_type, const glsl_type *y_type, + const glsl_type *z_type) +{ + ir_variable *x = in_var(x_type, "x"); + ir_variable *y = in_var(y_type, "y"); + ir_variable *z = in_var(z_type, "z"); + MAKE_SIG(x_type, avail, 3, x, y, z); + + body.emit(ret(min3_expr(x, y, z))); + + return sig; +} + /** @} */ /******************************************************************************/ diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp index 6c49734..7091e9a 100644 --- a/src/glsl/ir_builder.cpp +++ b/src/glsl/ir_builder.cpp @@ -211,6 +211,11 @@ ir_expression *sub(operand a, operand b) return expr(ir_binop_sub, a, b); } +ir_expression *min(operand a, operand b) +{ + return expr(ir_binop_min, a, b); +} + ir_expression *mul(operand a, operand b) { return expr(ir_binop_mul, a, b); diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h index 1f07788..f564b07 100644 --- a/src/glsl/ir_builder.h +++ b/src/glsl/ir_builder.h @@ -184,6 +184,8 @@ ir_expression *i2b(operand a); ir_expression *f2b(operand a); ir_expression *b2f(operand a); +ir_expression *min(operand a, operand b); + ir_expression *fma(operand a, operand b, operand c); ir_expression *lrp(operand x, operand y, operand a); ir_expression *csel(operand a, operand b, operand c); -- 1.8.5.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev