diff options
author | Marek Olšák <[email protected]> | 2016-08-02 11:51:21 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-08-03 17:46:46 +0200 |
commit | c15a9dec298940c918403353c6830f4f71115592 (patch) | |
tree | 07a3698288fe4c8b7db203f4e8d8d0728a4958dc /src | |
parent | c2a0e991694f1fa84f24aacd2c2d47eecbd4da0f (diff) |
radeonsi: skip unnecessary si_update_shaders calls
Small decrease in draw call overhead.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_draw.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 7 |
4 files changed, 27 insertions, 7 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 326b8191475..41e94487c8a 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -260,6 +260,7 @@ struct si_context { struct si_vertex_element *vertex_elements; unsigned sprite_coord_enable; bool flatshade; + bool do_update_shaders; /* shader descriptors */ struct si_descriptors vertex_buffers; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index c5b61e94114..47fc7a0b14b 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -572,6 +572,7 @@ static void si_bind_blend_state(struct pipe_context *ctx, void *state) struct si_context *sctx = (struct si_context *)ctx; si_pm4_bind_state(sctx, blend, (struct si_state_blend *)state); si_mark_atom_dirty(sctx, &sctx->cb_render_state); + sctx->do_update_shaders = true; } static void si_delete_blend_state(struct pipe_context *ctx, void *state) @@ -869,6 +870,7 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) si_update_poly_offset_state(sctx); si_mark_atom_dirty(sctx, &sctx->clip_regs); + sctx->do_update_shaders = true; } static void si_delete_rs_state(struct pipe_context *ctx, void *state) @@ -1018,6 +1020,7 @@ static void si_bind_dsa_state(struct pipe_context *ctx, void *state) sctx->stencil_ref.dsa_part = dsa->stencil_ref; si_mark_atom_dirty(sctx, &sctx->stencil_ref.atom); } + sctx->do_update_shaders = true; } static void si_delete_dsa_state(struct pipe_context *ctx, void *state) @@ -2388,6 +2391,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, } sctx->need_check_render_feedback = true; + sctx->do_update_shaders = true; } static void si_emit_framebuffer_state(struct si_context *sctx, struct r600_atom *atom) @@ -2628,6 +2632,7 @@ static void si_set_min_samples(struct pipe_context *ctx, unsigned min_samples) return; sctx->ps_iter_samples = min_samples; + sctx->do_update_shaders = true; if (sctx->framebuffer.nr_samples > 1) si_mark_atom_dirty(sctx, &sctx->msaa_config); @@ -3267,6 +3272,7 @@ static void si_bind_vertex_elements(struct pipe_context *ctx, void *state) sctx->vertex_elements = v; sctx->vertex_buffers_dirty = true; + sctx->do_update_shaders = true; } static void si_delete_vertex_element(struct pipe_context *ctx, void *state) diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 24fa682926c..30b644ee42b 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -867,7 +867,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) struct si_context *sctx = (struct si_context *)ctx; struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; struct pipe_index_buffer ib = {}; - unsigned mask, dirty_fb_counter, dirty_tex_counter; + unsigned mask, dirty_fb_counter, dirty_tex_counter, rast_prim; if (!info->count && !info->indirect && (info->indexed || !info->count_from_stream_output)) @@ -911,15 +911,21 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info) * draw_vbo recursively, and before si_update_shaders, which uses * current_rast_prim for this draw_vbo call. */ if (sctx->gs_shader.cso) - sctx->current_rast_prim = sctx->gs_shader.cso->gs_output_prim; + rast_prim = sctx->gs_shader.cso->gs_output_prim; else if (sctx->tes_shader.cso) - sctx->current_rast_prim = - sctx->tes_shader.cso->info.properties[TGSI_PROPERTY_TES_PRIM_MODE]; + rast_prim = sctx->tes_shader.cso->info.properties[TGSI_PROPERTY_TES_PRIM_MODE]; else - sctx->current_rast_prim = info->mode; + rast_prim = info->mode; - if (!si_update_shaders(sctx) || - !si_upload_graphics_shader_descriptors(sctx)) + if (rast_prim != sctx->current_rast_prim) { + sctx->current_rast_prim = rast_prim; + sctx->do_update_shaders = true; + } + + if (sctx->do_update_shaders && !si_update_shaders(sctx)) + return; + + if (!si_upload_graphics_shader_descriptors(sctx)) return; if (info->indexed) { diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 47cf496ae41..87d0b7d9022 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1360,6 +1360,7 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state) sctx->vs_shader.cso = sel; sctx->vs_shader.current = sel ? sel->first_variant : NULL; + sctx->do_update_shaders = true; si_mark_atom_dirty(sctx, &sctx->clip_regs); r600_update_vs_writes_viewport_index(&sctx->b, si_get_vs_info(sctx)); } @@ -1375,6 +1376,7 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state) sctx->gs_shader.cso = sel; sctx->gs_shader.current = sel ? sel->first_variant : NULL; + sctx->do_update_shaders = true; si_mark_atom_dirty(sctx, &sctx->clip_regs); sctx->last_rast_prim = -1; /* reset this so that it gets updated */ @@ -1394,6 +1396,7 @@ static void si_bind_tcs_shader(struct pipe_context *ctx, void *state) sctx->tcs_shader.cso = sel; sctx->tcs_shader.current = sel ? sel->first_variant : NULL; + sctx->do_update_shaders = true; if (enable_changed) sctx->last_tcs = NULL; /* invalidate derived tess state */ @@ -1410,6 +1413,7 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state) sctx->tes_shader.cso = sel; sctx->tes_shader.current = sel ? sel->first_variant : NULL; + sctx->do_update_shaders = true; si_mark_atom_dirty(sctx, &sctx->clip_regs); sctx->last_rast_prim = -1; /* reset this so that it gets updated */ @@ -1431,6 +1435,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state) sctx->ps_shader.cso = sel; sctx->ps_shader.current = sel ? sel->first_variant : NULL; + sctx->do_update_shaders = true; si_mark_atom_dirty(sctx, &sctx->cb_render_state); } @@ -2199,6 +2204,8 @@ bool si_update_shaders(struct si_context *sctx) if (!si_update_spi_tmpring_size(sctx)) return false; } + + sctx->do_update_shaders = false; return true; } |