Mesa (master): pan/midgard: Fix quadword_count handling

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 4 21:00:31 UTC 2019


Module: Mesa
Branch: master
Commit: 45ac8ea8bd8541d0a6d861dc84a66fa8fa69fb09
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=45ac8ea8bd8541d0a6d861dc84a66fa8fa69fb09

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon Nov  4 10:32:49 2019 -0500

pan/midgard: Fix quadword_count handling

Spilling can mess with this considerably.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>

---

 src/panfrost/midgard/midgard_compile.c  | 6 +++---
 src/panfrost/midgard/midgard_schedule.c | 4 +++-
 src/panfrost/midgard/mir.c              | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 2604bbe980a..22c0d44c759 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2359,10 +2359,10 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx)
         unsigned first_tag = 0;
 
         mir_foreach_block_from(ctx, initial_block, v) {
-                midgard_bundle *initial_bundle =
-                        util_dynarray_element(&v->bundles, midgard_bundle, 0);
+                if (v->quadword_count) {
+                        midgard_bundle *initial_bundle =
+                                util_dynarray_element(&v->bundles, midgard_bundle, 0);
 
-                if (initial_bundle) {
                         first_tag = initial_bundle->tag;
                         break;
                 }
diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c
index acfc5754480..0c93f3ed32b 100644
--- a/src/panfrost/midgard/midgard_schedule.c
+++ b/src/panfrost/midgard/midgard_schedule.c
@@ -1072,7 +1072,9 @@ schedule_block(compiler_context *ctx, midgard_block *block)
 
         /* Blend constant was backwards as well. blend_offset if set is
          * strictly positive, as an offset of zero would imply constants before
-         * any instructions which is invalid in Midgard */
+         * any instructions which is invalid in Midgard. TODO: blend constants
+         * are broken if you spill since then quadword_count becomes invalid
+         * XXX */
 
         if (blend_offset)
                 ctx->blend_constant_offset = ((ctx->quadword_count + block->quadword_count) - blend_offset - 1) * 0x10;
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index fef2fd8e0f8..609cd5c1db4 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -547,6 +547,7 @@ mir_insert_instruction_before_scheduled(
         memcpy(bundles + before, &new, sizeof(new));
 
         list_addtail(&new.instructions[0]->link, &before_bundle->instructions[0]->link);
+        block->quadword_count += quadword_size(new.tag);
 }
 
 void
@@ -571,6 +572,7 @@ mir_insert_instruction_after_scheduled(
         midgard_bundle new = mir_bundle_for_op(ctx, ins);
         memcpy(bundles + after + 1, &new, sizeof(new));
         list_add(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link);
+        block->quadword_count += quadword_size(new.tag);
 }
 
 /* Flip the first-two arguments of a (binary) op. Currently ALU




More information about the mesa-commit mailing list