From f597ac3966405934e13a9aaa18c73211b5a40c7c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 8 Sep 2016 12:56:11 -0700 Subject: vc4: Implement job shuffling Track rendering to each FBO independently and flush rendering only when necessary. This lets us avoid the overhead of storing and loading the frame when an application momentarily switches to rendering to some other texture in order to continue rendering the main scene. Improves glmark -b desktop:effect=shadow:windows=4 by 27% Improves glmark -b desktop:blur-radius=5:effect=blur:passes=1:separable=true:windows=4 by 17% While I haven't tested other apps, this should help X rendering a lot, and I've heard GLBenchmark needed it too. --- src/gallium/drivers/vc4/vc4_draw.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/gallium/drivers/vc4/vc4_draw.c') diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index 52a53db9a29..bbdb02010f6 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -116,9 +116,11 @@ vc4_start_draw(struct vc4_context *vc4, int vert_count) } static void -vc4_update_shadow_textures(struct pipe_context *pctx, +vc4_predraw_check_textures(struct pipe_context *pctx, struct vc4_texture_stateobj *stage_tex) { + struct vc4_context *vc4 = vc4_context(pctx); + for (int i = 0; i < stage_tex->num_textures; i++) { struct pipe_sampler_view *view = stage_tex->textures[i]; if (!view) @@ -126,6 +128,8 @@ vc4_update_shadow_textures(struct pipe_context *pctx, struct vc4_resource *rsc = vc4_resource(view->texture); if (rsc->shadow_parent) vc4_update_shadow_baselevel_texture(pctx, view); + + vc4_flush_jobs_writing_resource(vc4, view->texture); } } @@ -263,12 +267,12 @@ static void vc4_hw_2116_workaround(struct pipe_context *pctx) { struct vc4_context *vc4 = vc4_context(pctx); - struct vc4_job *job = vc4->job; + struct vc4_job *job = vc4_get_job_for_fbo(vc4); if (job->draw_calls_queued == 0x1ef0) { perf_debug("Flushing batch due to HW-2116 workaround " "(too many draw calls per scene\n"); - vc4_flush(pctx); + vc4_job_submit(vc4, job); } } @@ -276,7 +280,6 @@ static void vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) { struct vc4_context *vc4 = vc4_context(pctx); - struct vc4_job *job = vc4->job; if (info->mode >= PIPE_PRIM_QUADS) { util_primconvert_save_index_buffer(vc4->primconvert, &vc4->indexbuf); @@ -288,11 +291,13 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) } /* Before setting up the draw, do any fixup blits necessary. */ - vc4_update_shadow_textures(pctx, &vc4->verttex); - vc4_update_shadow_textures(pctx, &vc4->fragtex); + vc4_predraw_check_textures(pctx, &vc4->verttex); + vc4_predraw_check_textures(pctx, &vc4->fragtex); vc4_hw_2116_workaround(pctx); + struct vc4_job *job = vc4_get_job_for_fbo(vc4); + vc4_get_draw_cl_space(job, info->count); if (vc4->prim_mode != info->mode) { @@ -466,14 +471,15 @@ vc4_clear(struct pipe_context *pctx, unsigned buffers, const union pipe_color_union *color, double depth, unsigned stencil) { struct vc4_context *vc4 = vc4_context(pctx); - struct vc4_job *job = vc4->job; + struct vc4_job *job = vc4_get_job_for_fbo(vc4); /* We can't flag new buffers for clearing once we've queued draws. We * could avoid this by using the 3d engine to clear. */ if (job->draw_calls_queued) { perf_debug("Flushing rendering to process new clear.\n"); - vc4_flush(pctx); + vc4_job_submit(vc4, job); + job = vc4_get_job_for_fbo(vc4); } /* Clearing ZS will clear both Z and stencil, so if we're trying to -- cgit v1.2.3