From df34fa14bb872447fed9076e06ffc504d85e2d1c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 17 Jan 2020 21:24:14 -0500 Subject: [PATCH] radeonsi: don't invoke decompression inside internal launch_grid Decompress resources properly but don't do it inside launch_grid to prevent recursion. Reviewed-by: Pierre-Eric Pelloux-Prayer Cc: 19.3 --- src/gallium/drivers/radeonsi/si_blit.c | 8 ++++---- src/gallium/drivers/radeonsi/si_compute_blit.c | 14 ++++++++++++++ src/gallium/drivers/radeonsi/si_pipe.h | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index 5ac68406f7f..e662de16127 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -825,10 +825,10 @@ void si_decompress_textures(struct si_context *sctx, unsigned shader_mask) * blitting if any decompression is needed. * The driver doesn't decompress resources automatically while u_blitter is * rendering. */ -static void si_decompress_subresource(struct pipe_context *ctx, - struct pipe_resource *tex, - unsigned planes, unsigned level, - unsigned first_layer, unsigned last_layer) +void si_decompress_subresource(struct pipe_context *ctx, + struct pipe_resource *tex, + unsigned planes, unsigned level, + unsigned first_layer, unsigned last_layer) { struct si_context *sctx = (struct si_context *)ctx; struct si_texture *stex = (struct si_texture*)tex; diff --git a/src/gallium/drivers/radeonsi/si_compute_blit.c b/src/gallium/drivers/radeonsi/si_compute_blit.c index ce25c3e4d8f..3e544d68500 100644 --- a/src/gallium/drivers/radeonsi/si_compute_blit.c +++ b/src/gallium/drivers/radeonsi/si_compute_blit.c @@ -66,6 +66,8 @@ static void si_launch_grid_internal(struct si_context *sctx, sctx->flags &= ~SI_CONTEXT_START_PIPELINE_STATS; sctx->flags |= SI_CONTEXT_STOP_PIPELINE_STATS; sctx->render_cond_force_off = true; + /* Skip decompression to prevent infinite recursion. */ + sctx->blitter->running = true; /* Dispatch compute. */ sctx->b.launch_grid(&sctx->b, info); @@ -74,6 +76,7 @@ static void si_launch_grid_internal(struct si_context *sctx, sctx->flags &= ~SI_CONTEXT_STOP_PIPELINE_STATS; sctx->flags |= SI_CONTEXT_START_PIPELINE_STATS; sctx->render_cond_force_off = false; + sctx->blitter->running = false; } static void si_compute_clear_12bytes_buffer(struct si_context *sctx, @@ -398,6 +401,12 @@ void si_compute_copy_image(struct si_context *sctx, sctx->flags |= SI_CONTEXT_CS_PARTIAL_FLUSH | si_get_flush_flags(sctx, SI_COHERENCY_SHADER, L2_STREAM); + /* The driver doesn't decompress resources automatically here. */ + si_decompress_subresource(ctx, dst, PIPE_MASK_RGBAZS, dst_level, + dstz, dstz + src_box->depth - 1); + si_decompress_subresource(ctx, src, PIPE_MASK_RGBAZS, src_level, + src_box->z, src_box->z + src_box->depth - 1); + /* src and dst have the same number of samples. */ si_make_CB_shader_coherent(sctx, src->nr_samples, true, /* Only src can have DCC.*/ @@ -676,6 +685,11 @@ void si_compute_clear_render_target(struct pipe_context *ctx, if (width == 0 || height == 0) return; + /* The driver doesn't decompress resources automatically here. */ + si_decompress_subresource(ctx, dstsurf->texture, PIPE_MASK_RGBA, + dstsurf->u.tex.level, dstsurf->u.tex.first_layer, + dstsurf->u.tex.last_layer); + if (util_format_is_srgb(dstsurf->format)) { union pipe_color_union color_srgb; for (int i = 0; i < 3; i++) diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index c75b131f8c6..563a201ec33 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1257,6 +1257,10 @@ void si_blitter_begin(struct si_context *sctx, enum si_blitter_op op); void si_blitter_end(struct si_context *sctx); void si_init_blit_functions(struct si_context *sctx); void si_decompress_textures(struct si_context *sctx, unsigned shader_mask); +void si_decompress_subresource(struct pipe_context *ctx, + struct pipe_resource *tex, + unsigned planes, unsigned level, + unsigned first_layer, unsigned last_layer); void si_resource_copy_region(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dst_level, -- 2.30.2