Commit cece947a authored by Neil Roberts's avatar Neil Roberts

glsl/builtin: Add alternate versions of atan using new ops

Adds alternate versions of the atan builtin functions that use
ir_unop_atan and ir_binop_atan2 instead of inlining to the IR
implementation of the function. These alternatives are selected if the
IR is going to be consumed by NIR. In that case the IR ops will be
translated to the appropriate NIR op.
Reviewed-by: Kristian H. Kristensen's avatarKristian H. Kristensen <>
parent 77f3fbb4
Pipeline #70102 passed with stages
in 18 minutes and 34 seconds
......@@ -826,6 +826,18 @@ demote_to_helper_invocation(const _mesa_glsl_parse_state *state)
return state->EXT_demote_to_helper_invocation_enable;
static bool
is_nir(const _mesa_glsl_parse_state *state)
return state->ctx->Const.ShaderCompilerOptions[state->stage].NirOptions;
static bool
is_not_nir(const _mesa_glsl_parse_state *state)
return !is_nir(state);
/** @} */
......@@ -956,6 +968,8 @@ private:
......@@ -1729,6 +1743,14 @@ builtin_builder::create_builtins()
......@@ -4728,7 +4750,7 @@ builtin_builder::_atan2(const glsl_type *type)
const unsigned n = type->vector_elements;
ir_variable *y = in_var(type, "y");
ir_variable *x = in_var(type, "x");
MAKE_SIG(type, always_available, 2, y, x);
MAKE_SIG(type, is_not_nir, 2, y, x);
/* If we're on the left half-plane rotate the coordinates π/2 clock-wise
* for the y=0 discontinuity to end up aligned with the vertical
......@@ -4865,7 +4887,7 @@ ir_function_signature *
builtin_builder::_atan(const glsl_type *type)
ir_variable *y_over_x = in_var(type, "y_over_x");
MAKE_SIG(type, always_available, 1, y_over_x);
MAKE_SIG(type, is_not_nir, 1, y_over_x);
ir_variable *tmp = body.make_temp(type, "tmp");
do_atan(body, type, tmp, y_over_x);
......@@ -4968,6 +4990,7 @@ UNOP(exp, ir_unop_exp, always_available)
UNOP(log, ir_unop_log, always_available)
UNOP(exp2, ir_unop_exp2, always_available)
UNOP(log2, ir_unop_log2, always_available)
UNOP(atan_op, ir_unop_atan, is_nir)
UNOPA(sqrt, ir_unop_sqrt)
UNOPA(inversesqrt, ir_unop_rsq)
......@@ -5167,6 +5190,12 @@ builtin_builder::_isinf(builtin_available_predicate avail, const glsl_type *type
return sig;
ir_function_signature *
builtin_builder::_atan2_op(const glsl_type *x_type)
return binop(is_nir, ir_binop_atan2, x_type, x_type, x_type);
ir_function_signature *
builtin_builder::_floatBitsToInt(const glsl_type *type)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment