glsl: implement mid3 built-in function
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
committed by
Kenneth Graunke
parent
73c7451587
commit
eb5dc75601
@@ -586,6 +586,11 @@ private:
|
||||
const glsl_type *y_type,
|
||||
const glsl_type *z_type);
|
||||
|
||||
ir_function_signature *_mid3(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
|
||||
@@ -2156,6 +2161,23 @@ builtin_builder::create_builtins()
|
||||
_max3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
|
||||
NULL);
|
||||
|
||||
add_function("mid3",
|
||||
_mid3(shader_trinary_minmax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type),
|
||||
|
||||
_mid3(shader_trinary_minmax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type),
|
||||
|
||||
_mid3(shader_trinary_minmax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type),
|
||||
_mid3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
|
||||
NULL);
|
||||
|
||||
#undef F
|
||||
#undef FI
|
||||
#undef FIU
|
||||
@@ -4073,6 +4095,22 @@ builtin_builder::_max3(builtin_available_predicate avail,
|
||||
return sig;
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
builtin_builder::_mid3(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 *mid3 = max(min(x, y), max(min(x, z), min(y, z)));
|
||||
body.emit(ret(mid3));
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user