panfrost: Bake the initial tag into the shader pointer
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 19 Aug 2020 14:13:59 +0000 (10:13 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 25 Aug 2020 15:05:34 +0000 (17:05 +0200)
No need to do this at draw-time.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>

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

index 7a7200da425ef03e22038526fdc3e9209ff5b129..461f4b06a10dbf1fb2724bc9087e59a465f76ee5 100644 (file)
@@ -146,7 +146,6 @@ panfrost_shader_compile(struct panfrost_context *ctx,
                         uint64_t *outputs_written)
 {
         struct panfrost_device *dev = pan_device(ctx->base.screen);
-        uint8_t *dst;
 
         nir_shader *s;
 
@@ -172,21 +171,22 @@ panfrost_shader_compile(struct panfrost_context *ctx,
 
         /* Prepare the compiled binary for upload */
         int size = program.compiled.size;
-        dst = program.compiled.data;
-
-        /* Upload the shader. The lookahead tag is ORed on as a tagged pointer.
-         * I bet someone just thought that would be a cute pun. At least,
-         * that's how I'd do it. */
 
         if (size) {
                 state->bo = panfrost_bo_create(dev, size, PAN_BO_EXECUTE);
-                memcpy(state->bo->cpu, dst, size);
+                memcpy(state->bo->cpu, program.compiled.data, size);
+                state->shader = state->bo->gpu;
         }
 
+        /* Midgard needs the first tag on the bottom nibble */
+
         if (!(dev->quirks & IS_BIFROST)) {
-                /* If size = 0, no shader. Use dummy tag to avoid
-                 * INSTR_INVALID_ENC */
-                state->first_tag = size ? program.first_tag : 1;
+                /* If size = 0, we tag as "end-of-shader" */
+
+                if (size)
+                        state->shader |= program.first_tag;
+                else
+                        state->shader = 0x1;
         }
 
         util_dynarray_fini(&program.compiled);
index 155f480f18eca395ff876dec332ba9b4d0b024d4..45465a5413ed0ac6e045e90a3745f4225f55ecda 100644 (file)
@@ -315,7 +315,7 @@ panfrost_shader_meta_init(struct panfrost_context *ctx,
         struct panfrost_shader_state *ss = panfrost_get_shader_state(ctx, st);
 
         memset(meta, 0, sizeof(*meta));
-        meta->shader = (ss->bo ? ss->bo->gpu : 0) | ss->first_tag;
+        meta->shader = ss->shader;
         meta->attribute_count = ss->attribute_count;
         meta->varying_count = ss->varying_count;
         meta->texture_count = ctx->sampler_view_count[st];
index 6e655b3d472c824282fc09b383c7fa0d21617eeb..fee465fb727e701f9c0cfd00dd2f4c674c7d8b52 100644 (file)
@@ -221,7 +221,9 @@ struct panfrost_shader_state {
         /* Should we enable helper invocations */
         bool helper_invocations;
 
-        unsigned first_tag;
+        /* Pointer to GPU-executable memory formatted for the hardware. bo->gpu
+         * on Bifrost, bo->gpu | initial_tag on Midgard */
+        mali_ptr shader;
         struct panfrost_bo *bo;
 
         BITSET_WORD outputs_read;