diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 67ed936478f..d7473ee4922 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -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: B1(acos) B1(atan2) B1(atan) + B1(atan2_op) + B1(atan_op) B1(sinh) B1(cosh) B1(tanh) @@ -1729,6 +1743,14 @@ builtin_builder::create_builtins() _atan2(glsl_type::vec2_type), _atan2(glsl_type::vec3_type), _atan2(glsl_type::vec4_type), + _atan_op(glsl_type::float_type), + _atan_op(glsl_type::vec2_type), + _atan_op(glsl_type::vec3_type), + _atan_op(glsl_type::vec4_type), + _atan2_op(glsl_type::float_type), + _atan2_op(glsl_type::vec2_type), + _atan2_op(glsl_type::vec3_type), + _atan2_op(glsl_type::vec4_type), NULL); F(sinh) @@ -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) {