From b2b0dca4ce1498e2a5db1b31c9f2bc22c6bae1b0 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 3 Aug 2021 18:38:46 -0400 Subject: [PATCH] pan/bi: Add shader equality helper for unit tests Optimizer tests really are global. Signed-off-by: Alyssa Rosenzweig Part-of: --- 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; \