diff options
author | Marek Olšák <[email protected]> | 2017-06-05 02:00:52 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-08 23:29:07 +0200 |
commit | 4b8d0c2b1d25c2cf1b3ce57c9c1d997bff1b9408 (patch) | |
tree | 98fbcce6274dbd837227b910643bbea0263d2120 /src/gallium/drivers/radeonsi/si_state_shaders.c | |
parent | f804e0672ea56f4757b5e8d679798fa0e8132352 (diff) |
radeonsi: don't update dependent states if it has no effect (v2)
This and the previous clip_regs commit decrease IB sizes and the number of
si_update_shaders invocations as follows:
IB size si_update_shaders calls
Borderlands 2 -10% -27%
Deus Ex: MD -5% -11%
Talos Principle -8% -30%
v2: always dirty cb_render_state in set_framebuffer_state
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_state_shaders.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index c21f855d7a2..677a6de88c2 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2314,18 +2314,25 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state) static void si_bind_ps_shader(struct pipe_context *ctx, void *state) { struct si_context *sctx = (struct si_context *)ctx; + struct si_shader_selector *old_sel = sctx->ps_shader.cso; struct si_shader_selector *sel = state; /* skip if supplied shader is one already in use */ - if (sctx->ps_shader.cso == sel) + if (old_sel == sel) return; sctx->ps_shader.cso = sel; sctx->ps_shader.current = sel ? sel->first_variant : NULL; sctx->do_update_shaders = true; - if (sel && sctx->ia_multi_vgt_param_key.u.uses_tess) - si_update_tess_uses_prim_id(sctx); - si_mark_atom_dirty(sctx, &sctx->cb_render_state); + + if (sel) { + if (sctx->ia_multi_vgt_param_key.u.uses_tess) + si_update_tess_uses_prim_id(sctx); + + if (!old_sel || + old_sel->info.colors_written != sel->info.colors_written) + si_mark_atom_dirty(sctx, &sctx->cb_render_state); + } si_set_active_descriptors_for_shader(sctx, sel); } @@ -3088,6 +3095,9 @@ bool si_update_shaders(struct si_context *sctx) struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; struct si_shader *old_vs = si_get_vs_state(sctx); bool old_clip_disable = old_vs ? old_vs->key.opt.hw_vs.clip_disable : false; + struct si_shader *old_ps = sctx->ps_shader.current; + unsigned old_spi_shader_col_format = + old_ps ? old_ps->key.part.ps.epilog.spi_shader_col_format : 0; int r; compiler_state.tm = sctx->tm; @@ -3212,7 +3222,11 @@ bool si_update_shaders(struct si_context *sctx) si_mark_atom_dirty(sctx, &sctx->spi_map); } - if (sctx->screen->b.rbplus_allowed && si_pm4_state_changed(sctx, ps)) + if (sctx->screen->b.rbplus_allowed && + si_pm4_state_changed(sctx, ps) && + (!old_ps || + old_spi_shader_col_format != + sctx->ps_shader.current->key.part.ps.epilog.spi_shader_col_format)) si_mark_atom_dirty(sctx, &sctx->cb_render_state); if (sctx->ps_db_shader_control != db_shader_control) { |