radeonsi: remove all varyings for depth-only rendering or rasterization off
authorMarek Olšák <marek.olsak@amd.com>
Tue, 15 Nov 2016 20:15:55 +0000 (21:15 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 21 Nov 2016 20:44:35 +0000 (21:44 +0100)
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index 847281e..42cbecb 100644 (file)
@@ -167,6 +167,7 @@ struct si_framebuffer {
        unsigned                        nr_samples;
        unsigned                        log_samples;
        unsigned                        compressed_cb_mask;
+       unsigned                        colorbuf_enabled_4bit;
        unsigned                        spi_shader_col_format;
        unsigned                        spi_shader_col_format_alpha;
        unsigned                        spi_shader_col_format_blend;
index b3299a9..b4683c5 100644 (file)
@@ -2360,6 +2360,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
        si_dec_framebuffer_counters(&sctx->framebuffer.state);
        util_copy_framebuffer_state(&sctx->framebuffer.state, state);
 
+       sctx->framebuffer.colorbuf_enabled_4bit = 0;
        sctx->framebuffer.spi_shader_col_format = 0;
        sctx->framebuffer.spi_shader_col_format_alpha = 0;
        sctx->framebuffer.spi_shader_col_format_blend = 0;
@@ -2382,6 +2383,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
                        si_initialize_color_surface(sctx, surf);
                }
 
+               sctx->framebuffer.colorbuf_enabled_4bit |= 0xf << (i * 4);
                sctx->framebuffer.spi_shader_col_format |=
                        surf->spi_shader_col_format << (i * 4);
                sctx->framebuffer.spi_shader_col_format_alpha |=
index 7834f87..cd4b339 100644 (file)
@@ -867,7 +867,24 @@ static void si_shader_selector_key_hw_vs(struct si_context *sctx,
                !vs->info.culldist_writemask;
 
        /* Find out if PS is disabled. */
-       bool ps_disabled = ps == NULL;
+       bool ps_disabled = true;
+       if (ps) {
+               bool ps_modifies_zs = ps->info.uses_kill ||
+                                     ps->info.writes_z ||
+                                     ps->info.writes_stencil ||
+                                     ps->info.writes_samplemask ||
+                                     si_get_alpha_test_func(sctx) != PIPE_FUNC_ALWAYS;
+
+               unsigned ps_colormask = sctx->framebuffer.colorbuf_enabled_4bit &
+                                       sctx->queued.named.blend->cb_target_mask;
+               if (!ps->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
+                       ps_colormask &= ps->colors_written_4bit;
+
+               ps_disabled = sctx->queued.named.rasterizer->rasterizer_discard ||
+                             (!ps_colormask &&
+                              !ps_modifies_zs &&
+                              !ps->info.writes_memory);
+       }
 
        /* Find out which VS outputs aren't used by the PS. */
        uint64_t outputs_written = vs->outputs_written;