From fafc305600cb8d54ce18494e2b0d961d694b63c8 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Fri, 12 Jun 2020 20:14:02 +1200 Subject: [PATCH] panfrost: Create a new sampler view bo when the layout changes Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 21 +++++++++++++++++--- src/gallium/drivers/panfrost/pan_context.c | 2 ++ src/gallium/drivers/panfrost/pan_context.h | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 60ab6439cbc..8a8ba10e3a3 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1382,6 +1382,17 @@ panfrost_get_tex_desc(struct panfrost_batch *batch, return view->midgard_bo->gpu; } +static void +panfrost_update_sampler_view(struct panfrost_sampler_view *view, + struct pipe_context *pctx) +{ + struct panfrost_resource *rsrc = pan_resource(view->base.texture); + if (view->layout != rsrc->layout) { + panfrost_bo_unreference(view->midgard_bo); + panfrost_create_sampler_view_bo(view, pctx, &rsrc->base); + } +} + void panfrost_emit_texture_descriptors(struct panfrost_batch *batch, enum pipe_shader_type stage, @@ -1426,9 +1437,13 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch, } else { uint64_t trampolines[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) - trampolines[i] = panfrost_get_tex_desc(batch, stage, - ctx->sampler_views[stage][i]); + for (int i = 0; i < ctx->sampler_view_count[stage]; ++i) { + struct panfrost_sampler_view *view = ctx->sampler_views[stage][i]; + + panfrost_update_sampler_view(view, &ctx->base); + + trampolines[i] = panfrost_get_tex_desc(batch, stage, view); + } postfix->textures = panfrost_upload_transient(batch, trampolines, diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index da683bafdc7..436fae30577 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -918,6 +918,8 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so, struct panfrost_resource *prsrc = (struct panfrost_resource *)texture; assert(prsrc->bo); + so->layout = prsrc->layout; + unsigned char user_swizzle[4] = { so->base.swizzle_r, so->base.swizzle_g, diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index c34b666170f..30642964890 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -266,6 +266,7 @@ struct panfrost_sampler_view { struct panfrost_bo *midgard_bo; struct panfrost_bo *bifrost_bo; struct bifrost_texture_descriptor *bifrost_descriptor; + enum mali_texture_layout layout; }; static inline struct panfrost_context * -- 2.30.2