Also ran clang-format on the affected code.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21971>
return nir_ubfe_imm(b, value, rshift, bitwidth);
}
+static bool
+is_sin_cos(const nir_instr *instr, UNUSED const void *_)
+{
+ return instr->type == nir_instr_type_alu && (nir_instr_as_alu(instr)->op == nir_op_fsin ||
+ nir_instr_as_alu(instr)->op == nir_op_fcos);
+}
+
+static nir_ssa_def *
+lower_sin_cos(struct nir_builder *b, nir_instr *instr, UNUSED void *_)
+{
+ nir_alu_instr *sincos = nir_instr_as_alu(instr);
+ nir_ssa_def *src = nir_fmul_imm(b, nir_ssa_for_alu_src(b, sincos, 0), 0.15915493667125702);
+ return sincos->op == nir_op_fsin ? nir_fsin_amd(b, src) : nir_fcos_amd(b, src);
+}
+
+bool
+ac_nir_lower_sin_cos(nir_shader *shader)
+{
+ return nir_shader_lower_instructions(shader, is_sin_cos, lower_sin_cos, NULL);
+}
+
void
ac_nir_store_var_components(nir_builder *b, nir_variable *var, nir_ssa_def *value,
unsigned component, unsigned writemask)
ac_nir_unpack_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct ac_arg arg,
unsigned rshift, unsigned bitwidth);
+bool ac_nir_lower_sin_cos(nir_shader *shader);
+
void
ac_nir_store_var_components(nir_builder *b, nir_variable *var, nir_ssa_def *value,
unsigned component, unsigned writemask);
}
static bool
-is_sincos(const nir_instr *instr, const void *_)
-{
- return instr->type == nir_instr_type_alu &&
- (nir_instr_as_alu(instr)->op == nir_op_fsin || nir_instr_as_alu(instr)->op == nir_op_fcos);
-}
-
-static nir_ssa_def *
-lower_sincos(struct nir_builder *b, nir_instr *instr, void *_)
-{
- nir_alu_instr *sincos = nir_instr_as_alu(instr);
- nir_ssa_def *src = nir_fmul_imm(b, nir_ssa_for_alu_src(b, sincos, 0), 0.15915493667125702);
- return sincos->op == nir_op_fsin ? nir_fsin_amd(b, src) : nir_fcos_amd(b, src);
-}
-
-static bool
is_not_xfb_output(nir_variable *var, void *data)
{
if (var->data.mode != nir_var_shader_out)
NIR_PASS(_, nir, nir_lower_doubles, NULL, lower_doubles);
- NIR_PASS(_, nir, nir_shader_lower_instructions, &is_sincos, &lower_sincos, NULL);
+ NIR_PASS(_, nir, ac_nir_lower_sin_cos);
}
NIR_PASS(_, nir, nir_lower_system_values);