panfrost: Dissociate shader meta patching from the desc emission
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 5 Mar 2020 10:02:56 +0000 (11:02 +0100)
committerBoris Brezillon <boris.brezillon@collabora.com>
Tue, 10 Mar 2020 11:47:33 +0000 (12:47 +0100)
Right now we emit two shader descriptors for the fragment shader, one
when panfrost_patch_shader_state() is called, and the final one
including both the shader_meta and the blend RT descriptors.
The first generated fragment shader descriptor is never used, since the
second one overrides the postfix.shader pointer.

Let's dissociate the state patching logic from the descriptor emission
so we don't upload descriptors that are never used.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>

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

index 7f723b699a42cf4d68a7c62f14eeccfcd264f9a7..18a47b0854e38449bdb561c40e9a570363352aa3 100644 (file)
 #include "pan_context.h"
 #include "pan_job.h"
 
+void
+panfrost_emit_shader_meta(struct panfrost_batch *batch,
+                          enum pipe_shader_type st,
+                          struct midgard_payload_vertex_tiler *vtp)
+{
+        struct panfrost_context *ctx = batch->ctx;
+        struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, st);
+
+        if (!ss) {
+                vtp->postfix.shader = 0;
+                return;
+        }
+
+        /* Add the shader BO to the batch. */
+        panfrost_batch_add_bo(batch, ss->bo,
+                              PAN_BO_ACCESS_PRIVATE |
+                              PAN_BO_ACCESS_READ |
+                              panfrost_bo_access_for_stage(st));
+
+        vtp->postfix.shader = panfrost_upload_transient(batch, ss->tripipe,
+                                                        sizeof(*ss->tripipe));
+}
+
 static void
 panfrost_mali_viewport_init(struct panfrost_context *ctx,
                             struct mali_viewport *mvp)
index 8ad9a8282d752fea9fd0e42a43ebf68e88110893..326e4b2efe5d313b66165480efa26aa8786b315c 100644 (file)
 
 #include "pan_job.h"
 
+void
+panfrost_emit_shader_meta(struct panfrost_batch *batch,
+                          enum pipe_shader_type st,
+                          struct midgard_payload_vertex_tiler *vtp);
+
 void
 panfrost_emit_viewport(struct panfrost_batch *batch,
                        struct midgard_payload_vertex_tiler *tp);
index a79da05603ff662d43cfaf167b956731fa45ece5..1f595919faa05ee577795a6cc38d7405a6541f58 100644 (file)
@@ -538,10 +538,8 @@ panfrost_patch_shader_state(struct panfrost_context *ctx,
 {
         struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, stage);
 
-        if (!ss) {
-                ctx->payloads[stage].postfix.shader = 0;
+        if (!ss)
                 return;
-        }
 
         ss->tripipe->texture_count = ctx->sampler_view_count[stage];
         ss->tripipe->sampler_count = ctx->sampler_count[stage];
@@ -550,18 +548,6 @@ panfrost_patch_shader_state(struct panfrost_context *ctx,
 
         unsigned ubo_count = panfrost_ubo_count(ctx, stage);
         ss->tripipe->midgard1.uniform_buffer_count = ubo_count;
-
-        struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-
-        /* Add the shader BO to the batch. */
-        panfrost_batch_add_bo(batch, ss->bo,
-                              PAN_BO_ACCESS_PRIVATE |
-                              PAN_BO_ACCESS_READ |
-                             panfrost_bo_access_for_stage(stage));
-
-        ctx->payloads[stage].postfix.shader = panfrost_upload_transient(batch,
-                                        ss->tripipe,
-                                        sizeof(struct mali_shader_meta));
 }
 
 /* Go through dirty flags and actualise them in the cmdstream. */
@@ -601,7 +587,11 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
         }
 
         panfrost_patch_shader_state(ctx, PIPE_SHADER_VERTEX);
+        panfrost_emit_shader_meta(batch, PIPE_SHADER_VERTEX,
+                                  &ctx->payloads[PIPE_SHADER_VERTEX]);
         panfrost_patch_shader_state(ctx, PIPE_SHADER_COMPUTE);
+        panfrost_emit_shader_meta(batch, PIPE_SHADER_COMPUTE,
+                                  &ctx->payloads[PIPE_SHADER_COMPUTE]);
 
         if (ctx->shader[PIPE_SHADER_VERTEX] && ctx->shader[PIPE_SHADER_FRAGMENT]) {
                 /* Check if we need to link the gl_PointSize varying */