panfrost: add line_smooth shader-key and lowering

Unfortunately, the lowering-pass has gotten a condition added that we
don't really want. So we need to lower away the
load_poly_line_smooth_enabled-intrinsic to always return true to get rid
of it again.

It's not great, but line-smoothing isn't the most important feature to
have max performance on, so... meh?

An alternative here could be to make the condition in
nir_lower_poly_line_smooth optional, but that seems kinda hairy
code-wise. Dunno.

We also need to run nir_lower_alu in order to lower away bit_count on
midgard.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26904>
This commit is contained in:
Erik Faye-Lund
2024-01-05 12:56:45 +01:00
committed by Marge Bot
parent 4b6972366a
commit 6343e0bbd0
2 changed files with 34 additions and 0 deletions

View File

@@ -321,6 +321,8 @@ struct panfrost_fs_key {
/* User clip plane lowering */
uint8_t clip_plane_enable;
bool line_smooth;
};
struct panfrost_shader_key {

View File

@@ -31,6 +31,7 @@
#include "pan_shader.h"
#include "nir/tgsi_to_nir.h"
#include "util/u_memory.h"
#include "nir_builder.h"
#include "nir_serialize.h"
#include "pan_bo.h"
#include "pan_context.h"
@@ -66,6 +67,31 @@ panfrost_alloc_variant(struct panfrost_uncompiled_shader *so)
return util_dynarray_grow(&so->variants, struct panfrost_compiled_shader, 1);
}
static void
lower_load_poly_line_smooth_enabled(nir_shader *nir,
const struct panfrost_shader_key *key)
{
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
nir_builder b = nir_builder_create(impl);
nir_foreach_block_safe(block, impl) {
nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_intrinsic)
continue;
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
if (intrin->intrinsic != nir_intrinsic_load_poly_line_smooth_enabled)
continue;
b.cursor = nir_before_instr(instr);
nir_def_rewrite_uses(&intrin->def, nir_imm_true(&b));
nir_instr_remove(instr);
nir_instr_free(instr);
}
}
}
static void
panfrost_shader_compile(struct panfrost_screen *screen, const nir_shader *ir,
struct util_debug_callback *dbg,
@@ -125,6 +151,12 @@ panfrost_shader_compile(struct panfrost_screen *screen, const nir_shader *ir,
if (key->fs.clip_plane_enable) {
NIR_PASS_V(s, nir_lower_clip_fs, key->fs.clip_plane_enable, false);
}
if (key->fs.line_smooth) {
NIR_PASS_V(s, nir_lower_poly_line_smooth, 16);
NIR_PASS_V(s, lower_load_poly_line_smooth_enabled, key);
NIR_PASS_V(s, nir_lower_alu);
}
}
if (dev->arch <= 5 && s->info.stage == MESA_SHADER_FRAGMENT) {