etnaviv: expose shader discard usage in etna_shader_variant
authorLucas Stach <l.stach@pengutronix.de>
Sun, 1 Nov 2020 15:49:18 +0000 (16:49 +0100)
committerLucas Stach <l.stach@pengutronix.de>
Fri, 6 Nov 2020 09:10:59 +0000 (10:10 +0100)
The information about a shader using discard/kill is interesting
to other parts of the driver, as depth states need to programmed
differently depending on this. As we don't want to deal with
NIR/TGSI differences in other parts of the driver, track this
usage in the common etna_shader_variant.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7396>

src/gallium/drivers/etnaviv/etnaviv_compiler.h
src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
src/gallium/drivers/etnaviv/etnaviv_compiler_tgsi.c

index 769cb82..2a2c779 100644 (file)
@@ -127,6 +127,9 @@ struct etna_shader_variant {
 
    /* shader is larger than GPU instruction limit, thus needs icache */
    bool needs_icache;
+
+   /* shader uses pixel kill/discard */
+   bool uses_discard;
 };
 
 struct etna_varying {
index 90b2b9c..6760a16 100644 (file)
@@ -1058,6 +1058,7 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
    const struct etna_specs *specs = c->specs;
 
    v->stage = s->info.stage;
+   v->uses_discard = s->info.fs.uses_discard;
    v->num_loops = 0; /* TODO */
    v->vs_id_in_reg = -1;
    v->vs_pos_out_reg = -1;
index d6d12ae..ed84117 100644 (file)
@@ -2471,6 +2471,7 @@ etna_compile_shader(struct etna_shader_variant *v)
 
    /* fill in output structure */
    v->stage = c->info.processor == PIPE_SHADER_FRAGMENT ? MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX;
+   v->uses_discard = c->info.uses_kill;
    v->code_size = c->inst_ptr * 4;
    v->code = mem_dup(c->code, c->inst_ptr * 16);
    v->num_loops = c->num_loops;