mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
glsl: Implement min3 built-in function
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
61c450fc81
commit
ce46e14729
1 changed files with 38 additions and 0 deletions
|
|
@ -576,6 +576,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 +2117,23 @@ builtin_builder::create_builtins()
|
|||
shader_atomic_counters),
|
||||
NULL);
|
||||
|
||||
add_function("min3",
|
||||
_min3(shader_trinary_minmax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type),
|
||||
|
||||
_min3(shader_trinary_minmax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type),
|
||||
|
||||
_min3(shader_trinary_minmax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type),
|
||||
_min3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
|
||||
NULL);
|
||||
|
||||
#undef F
|
||||
#undef FI
|
||||
#undef FIU
|
||||
|
|
@ -3997,6 +4019,22 @@ 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);
|
||||
|
||||
ir_expression *min3 = min(x, min(y,z));
|
||||
body.emit(ret(min3));
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue