[Mesa-dev] [PATCH 2/2] radeonsi: use u_blitter for mipmap generation
Marek Olšák
maraeo at gmail.com
Mon Jun 13 17:30:56 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
This reduces time spend in glGenerateMipmap by a half.
---
src/gallium/drivers/radeonsi/si_blit.c | 37 +++++++++++++++++++++++++++++-----
src/gallium/drivers/radeonsi/si_pipe.c | 2 +-
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index f2f1ef5..25d531b 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -690,7 +690,8 @@ static void si_clear_depth_stencil(struct pipe_context *ctx,
* rendering. */
static void si_decompress_subresource(struct pipe_context *ctx,
struct pipe_resource *tex,
- unsigned planes, unsigned level,
+ unsigned planes,
+ unsigned first_level, unsigned last_level,
unsigned first_layer, unsigned last_layer)
{
struct si_context *sctx = (struct si_context *)ctx;
@@ -703,10 +704,10 @@ static void si_decompress_subresource(struct pipe_context *ctx,
planes &= ~PIPE_MASK_S;
si_blit_decompress_zs_in_place(sctx, rtex, planes,
- level, level,
+ first_level, last_level,
first_layer, last_layer);
} else if (rtex->fmask.size || rtex->cmask.size || rtex->dcc_offset) {
- si_blit_decompress_color(ctx, rtex, level, level,
+ si_blit_decompress_color(ctx, rtex, first_level, last_level,
first_layer, last_layer, false);
}
}
@@ -746,7 +747,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
/* The driver doesn't decompress resources automatically while
* u_blitter is rendering. */
- si_decompress_subresource(ctx, src, PIPE_MASK_RGBAZS, src_level,
+ si_decompress_subresource(ctx, src, PIPE_MASK_RGBAZS, src_level, src_level,
src_box->z, src_box->z + src_box->depth - 1);
dst_width = u_minify(dst->width0, dst_level);
@@ -1005,7 +1006,7 @@ static void si_blit(struct pipe_context *ctx,
/* The driver doesn't decompress resources automatically while
* u_blitter is rendering. */
si_decompress_subresource(ctx, info->src.resource, info->mask,
- info->src.level,
+ info->src.level, info->src.level,
info->src.box.z,
info->src.box.z + info->src.box.depth - 1);
@@ -1019,6 +1020,31 @@ static void si_blit(struct pipe_context *ctx,
si_blitter_end(ctx);
}
+static boolean si_generate_mipmap(struct pipe_context *ctx,
+ struct pipe_resource *tex,
+ enum pipe_format format,
+ unsigned base_level, unsigned last_level,
+ unsigned first_layer, unsigned last_layer)
+{
+ struct si_context *sctx = (struct si_context*)ctx;
+
+ if (!util_blitter_is_copy_supported(sctx->blitter, tex, tex))
+ return false;
+
+ /* The driver doesn't decompress resources automatically while
+ * u_blitter is rendering. */
+ si_decompress_subresource(ctx, tex, PIPE_MASK_RGBAZS,
+ base_level, last_level,
+ first_layer, last_layer);
+
+ si_blitter_begin(ctx, SI_BLIT | SI_DISABLE_RENDER_COND);
+ util_blitter_generate_mipmap(sctx->blitter, tex, format,
+ base_level, last_level,
+ first_layer, last_layer);
+ si_blitter_end(ctx);
+ return true;
+}
+
static void si_flush_resource(struct pipe_context *ctx,
struct pipe_resource *res)
{
@@ -1113,6 +1139,7 @@ void si_init_blit_functions(struct si_context *sctx)
sctx->b.b.resource_copy_region = si_resource_copy_region;
sctx->b.b.blit = si_blit;
sctx->b.b.flush_resource = si_flush_resource;
+ sctx->b.b.generate_mipmap = si_generate_mipmap;
sctx->b.blit_decompress_depth = si_blit_decompress_depth;
sctx->b.decompress_dcc = si_decompress_dcc;
}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 0c601da..1ee1877 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -357,6 +357,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
+ case PIPE_CAP_GENERATE_MIPMAP:
return 1;
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -409,7 +410,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_DRAW_PARAMETERS:
case PIPE_CAP_MULTI_DRAW_INDIRECT:
case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
- case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
case PIPE_CAP_QUERY_BUFFER_OBJECT:
case PIPE_CAP_CULL_DISTANCE:
--
2.7.4
More information about the mesa-dev
mailing list