mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-15 06:58:20 +02:00
ac/nir: rename ac_nir_lower_tex -> ac_nir_lower_image_tex
It will lower txf and buffer image loads to load_buffer_amd. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39474>
This commit is contained in:
parent
94058ff179
commit
30ee7044bc
5 changed files with 27 additions and 19 deletions
|
|
@ -112,6 +112,7 @@ amd_common_files = files(
|
|||
'nir/ac_nir_lower_esgs_io_to_mem.c',
|
||||
'nir/ac_nir_lower_global_access.c',
|
||||
'nir/ac_nir_lower_image_opcodes_cdna.c',
|
||||
'nir/ac_nir_lower_image_tex.c',
|
||||
'nir/ac_nir_lower_intrinsics_to_args.c',
|
||||
'nir/ac_nir_lower_legacy_gs.c',
|
||||
'nir/ac_nir_lower_legacy_vs.c',
|
||||
|
|
@ -119,7 +120,6 @@ amd_common_files = files(
|
|||
'nir/ac_nir_lower_resinfo.c',
|
||||
'nir/ac_nir_lower_taskmesh_io_to_mem.c',
|
||||
'nir/ac_nir_lower_tess_io_to_mem.c',
|
||||
'nir/ac_nir_lower_tex.c',
|
||||
'nir/ac_nir_lower_ngg.c',
|
||||
'nir/ac_nir_lower_ngg_gs.c',
|
||||
'nir/ac_nir_lower_ngg_mesh.c',
|
||||
|
|
|
|||
|
|
@ -401,10 +401,10 @@ typedef struct {
|
|||
*/
|
||||
bool fix_derivs_in_divergent_cf;
|
||||
unsigned max_wqm_vgprs;
|
||||
} ac_nir_lower_tex_options;
|
||||
} ac_nir_lower_image_tex_options;
|
||||
|
||||
bool
|
||||
ac_nir_lower_tex(nir_shader *nir, const ac_nir_lower_tex_options *options);
|
||||
ac_nir_lower_image_tex(nir_shader *nir, const ac_nir_lower_image_tex_options *options);
|
||||
|
||||
void
|
||||
ac_nir_store_debug_log_amd(nir_builder *b, nir_def *uvec4);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ build_cube_select(nir_builder *b, nir_def *ma, nir_def *id, nir_def *deriv,
|
|||
|
||||
static void
|
||||
prepare_cube_coords(nir_builder *b, nir_tex_instr *tex, nir_def **coord, nir_src *ddx,
|
||||
nir_src *ddy, const ac_nir_lower_tex_options *options)
|
||||
nir_src *ddy, const ac_nir_lower_image_tex_options *options)
|
||||
{
|
||||
nir_def *coords[NIR_MAX_VEC_COMPONENTS] = {0};
|
||||
for (unsigned i = 0; i < (*coord)->num_components; i++)
|
||||
|
|
@ -179,7 +179,7 @@ lower_array_layer_round_even(nir_builder *b, nir_tex_instr *tex, nir_def **coord
|
|||
|
||||
static bool
|
||||
lower_tex_coords(nir_builder *b, nir_tex_instr *tex, nir_def **coords,
|
||||
const ac_nir_lower_tex_options *options)
|
||||
const ac_nir_lower_image_tex_options *options)
|
||||
{
|
||||
bool progress = false;
|
||||
if ((options->lower_array_layer_round_even || tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE) &&
|
||||
|
|
@ -200,18 +200,14 @@ lower_tex_coords(nir_builder *b, nir_tex_instr *tex, nir_def **coords,
|
|||
}
|
||||
|
||||
static bool
|
||||
lower_tex(nir_builder *b, nir_instr *instr, void *options_)
|
||||
lower_tex(nir_builder *b, nir_tex_instr *tex, const ac_nir_lower_image_tex_options *options)
|
||||
{
|
||||
const ac_nir_lower_tex_options *options = options_;
|
||||
if (instr->type != nir_instr_type_tex)
|
||||
return false;
|
||||
|
||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||
int coord_idx = nir_tex_instr_src_index(tex, nir_tex_src_coord);
|
||||
if (coord_idx < 0 || nir_tex_instr_src_index(tex, nir_tex_src_backend1) >= 0)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_before_instr(instr);
|
||||
b->cursor = nir_before_instr(&tex->instr);
|
||||
|
||||
nir_def *coords = tex->src[coord_idx].src.ssa;
|
||||
if (lower_tex_coords(b, tex, &coords, options)) {
|
||||
tex->coord_components = coords->num_components;
|
||||
|
|
@ -222,6 +218,17 @@ lower_tex(nir_builder *b, nir_instr *instr, void *options_)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_image_tex(nir_builder *b, nir_instr *instr, void *options_)
|
||||
{
|
||||
const ac_nir_lower_image_tex_options *options = options_;
|
||||
|
||||
if (instr->type == nir_instr_type_tex)
|
||||
return lower_tex(b, nir_instr_as_tex(instr), options);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
nir_intrinsic_instr *bary;
|
||||
nir_intrinsic_instr *load;
|
||||
|
|
@ -280,7 +287,7 @@ static bool can_move_coord(nir_scalar scalar, coord_info *info, nir_block *tople
|
|||
}
|
||||
|
||||
struct move_tex_coords_state {
|
||||
const ac_nir_lower_tex_options *options;
|
||||
const ac_nir_lower_image_tex_options *options;
|
||||
unsigned num_wqm_vgprs;
|
||||
nir_builder toplevel_b;
|
||||
};
|
||||
|
|
@ -561,9 +568,10 @@ static bool move_coords_from_divergent_cf(struct move_tex_coords_state *state,
|
|||
}
|
||||
|
||||
bool
|
||||
ac_nir_lower_tex(nir_shader *nir, const ac_nir_lower_tex_options *options)
|
||||
ac_nir_lower_image_tex(nir_shader *nir, const ac_nir_lower_image_tex_options *options)
|
||||
{
|
||||
bool progress = false;
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
nir_metadata_require(
|
||||
|
|
@ -582,7 +590,7 @@ ac_nir_lower_tex(nir_shader *nir, const ac_nir_lower_tex_options *options)
|
|||
}
|
||||
|
||||
progress |= nir_shader_instructions_pass(
|
||||
nir, lower_tex, nir_metadata_control_flow, (void *)options);
|
||||
nir, lower_image_tex, nir_metadata_control_flow, (void *)options);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
|
@ -335,8 +335,8 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat
|
|||
if (progress)
|
||||
constant_fold_for_push_const = true;
|
||||
|
||||
NIR_PASS(_, stage->nir, ac_nir_lower_tex,
|
||||
&(ac_nir_lower_tex_options){
|
||||
NIR_PASS(_, stage->nir, ac_nir_lower_image_tex,
|
||||
&(ac_nir_lower_image_tex_options){
|
||||
.gfx_level = gfx_level,
|
||||
.lower_array_layer_round_even =
|
||||
!pdev->info.conformant_trunc_coord || instance->drirc.debug.disable_trunc_coord,
|
||||
|
|
|
|||
|
|
@ -938,8 +938,8 @@ static void si_postprocess_nir(struct si_nir_shader_ctx *ctx)
|
|||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
NIR_PASS(progress, nir, nir_lower_fragcoord_wtrans);
|
||||
|
||||
NIR_PASS(progress, nir, ac_nir_lower_tex,
|
||||
&(ac_nir_lower_tex_options){
|
||||
NIR_PASS(progress, nir, ac_nir_lower_image_tex,
|
||||
&(ac_nir_lower_image_tex_options){
|
||||
.gfx_level = sel->screen->info.gfx_level,
|
||||
.lower_array_layer_round_even = !sel->screen->info.conformant_trunc_coord,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue