mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 18:50:10 +01:00
ac/nir: Move ac_nir_lower_sin_cos to separate file.
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32966>
This commit is contained in:
parent
19bca6d425
commit
a986f9b90d
3 changed files with 32 additions and 21 deletions
|
|
@ -196,27 +196,6 @@ ac_nir_unpack_arg(nir_builder *b, const struct ac_shader_args *ac_args, struct a
|
|||
return ac_nir_unpack_value(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_def *
|
||||
lower_sin_cos(struct nir_builder *b, nir_instr *instr, UNUSED void *_)
|
||||
{
|
||||
nir_alu_instr *sincos = nir_instr_as_alu(instr);
|
||||
nir_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_def *value,
|
||||
unsigned component, unsigned writemask)
|
||||
|
|
|
|||
31
src/amd/common/ac_nir_lower_sin_cos.c
Normal file
31
src/amd/common/ac_nir_lower_sin_cos.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright © 2021 Valve Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "ac_nir.h"
|
||||
#include "ac_nir_helpers.h"
|
||||
|
||||
#include "nir_builder.h"
|
||||
|
||||
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_def *
|
||||
lower_sin_cos(struct nir_builder *b, nir_instr *instr, UNUSED void *_)
|
||||
{
|
||||
nir_alu_instr *sincos = nir_instr_as_alu(instr);
|
||||
nir_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);
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@ amd_common_files = files(
|
|||
'ac_nir_lower_ngg.c',
|
||||
'ac_nir_lower_ps_early.c',
|
||||
'ac_nir_lower_ps_late.c',
|
||||
'ac_nir_lower_sin_cos.c',
|
||||
'ac_nir_meta.h',
|
||||
'ac_nir_meta_cs_blit.c',
|
||||
'ac_nir_meta_cs_clear_copy_buffer.c',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue