panfrost: Create a new sampler view bo when the layout changes
[mesa.git] / src / gallium / drivers / panfrost / pan_cmdstream.c
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,