panfrost: Create a new sampler view bo when the layout changes
authorIcecream95 <ixn@keemail.me>
Fri, 12 Jun 2020 08:14:02 +0000 (20:14 +1200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 12 Jun 2020 19:15:46 +0000 (19:15 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4628>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h

index 60ab6439cbcd3f251c92aabba304a2e862b34813..8a8ba10e3a38a3b9807be3ab677949f8a1b6fda4 100644 (file)
@@ -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,
index da683bafdc7ce6579f0ce62dbdad276518379096..436fae30577a631d8430849224283ce6c448299a 100644 (file)
@@ -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,
index c34b666170f06aa44d381f66b8f4661959aff34c..306429648904fa257476c43da8ff9d85a0ecc20e 100644 (file)
@@ -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 *