Mesa (main): pan/bi: Add shader equality helper for unit tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 19:19:59 UTC 2021


Module: Mesa
Branch: main
Commit: b2b0dca4ce1498e2a5db1b31c9f2bc22c6bae1b0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2b0dca4ce1498e2a5db1b31c9f2bc22c6bae1b0

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Aug  3 18:38:46 2021 -0400

pan/bi: Add shader equality helper for unit tests

Optimizer tests really are global.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12205>

---

 src/panfrost/bifrost/bi_test.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/panfrost/bifrost/bi_test.h b/src/panfrost/bifrost/bi_test.h
index 4d93eeafd0c..4fbaafdb265 100644
--- a/src/panfrost/bifrost/bi_test.h
+++ b/src/panfrost/bifrost/bi_test.h
@@ -68,6 +68,36 @@ bit_instr_equal(bi_instr *A, bi_instr *B)
                  sizeof(bi_instr) - sizeof(struct list_head)) == 0;
 }
 
+static inline bool
+bit_block_equal(bi_block *A, bi_block *B)
+{
+   if (list_length(&A->instructions) != list_length(&B->instructions))
+      return false;
+
+   list_pair_for_each_entry(bi_instr, insA, insB,
+                            &A->instructions, &B->instructions, link) {
+      if (!bit_instr_equal(insA, insB))
+         return false;
+   }
+
+   return true;
+}
+
+static inline bool
+bit_shader_equal(bi_context *A, bi_context *B)
+{
+   if (list_length(&A->blocks) != list_length(&B->blocks))
+      return false;
+
+   list_pair_for_each_entry(bi_block, blockA, blockB,
+                            &A->blocks, &B->blocks, link) {
+      if (!bit_block_equal(blockA, blockB))
+         return false;
+   }
+
+   return true;
+}
+
 #define INSTRUCTION_CASE(instr, expected, CB) do { \
    bi_instr *left = instr; \
    bi_instr *right = expected; \



More information about the mesa-commit mailing list