diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index dbf0d503ae9..407e3dd6afc 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -321,6 +321,8 @@ struct panfrost_fs_key { /* User clip plane lowering */ uint8_t clip_plane_enable; + + bool line_smooth; }; struct panfrost_shader_key { diff --git a/src/gallium/drivers/panfrost/pan_shader.c b/src/gallium/drivers/panfrost/pan_shader.c index f0d46d32629..9256e0799bf 100644 --- a/src/gallium/drivers/panfrost/pan_shader.c +++ b/src/gallium/drivers/panfrost/pan_shader.c @@ -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) {