pan/mdg: Handle tilebuffer wait loops
authorIcecream95 <ixn@keemail.me>
Sun, 5 Jul 2020 12:22:22 +0000 (00:22 +1200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 13 Jul 2020 13:35:10 +0000 (13:35 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>

src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c

index fb3dff1c8d0f1f96d93056da4ecb96d44b516003..09b18c898956c4196e8e66332b5c90caa97b0a0a 100644 (file)
@@ -51,6 +51,7 @@ struct midgard_block;
 #define TARGET_BREAK 1
 #define TARGET_CONTINUE 2
 #define TARGET_DISCARD 3
+#define TARGET_TILEBUF_WAIT 4
 
 typedef struct midgard_branch {
         /* If conditional, the condition is specified in r31.w */
index 9f365d0c69a709bc7f95e4282d093d1962d97514..7da75d63f191f6b8b8130d44ea5408f5acf74244 100644 (file)
@@ -2851,13 +2851,17 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
                                 bool is_conditional = ins->branch.conditional;
                                 bool is_inverted = ins->branch.invert_conditional;
                                 bool is_discard = ins->branch.target_type == TARGET_DISCARD;
+                                bool is_tilebuf_wait = ins->branch.target_type == TARGET_TILEBUF_WAIT;
+                                bool is_special = is_discard || is_tilebuf_wait;
                                 bool is_writeout = ins->writeout;
 
                                 /* Determine the block we're jumping to */
                                 int target_number = ins->branch.target_block;
 
                                 /* Report the destination tag */
-                                int dest_tag = is_discard ? 0 : midgard_get_first_tag_from_block(ctx, target_number);
+                                int dest_tag = is_discard ? 0 :
+                                        is_tilebuf_wait ? bundle->tag :
+                                        midgard_get_first_tag_from_block(ctx, target_number);
 
                                 /* Count up the number of quadwords we're
                                  * jumping over = number of quadwords until
@@ -2867,6 +2871,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
 
                                 if (is_discard) {
                                         /* Ignored */
+                                } else if (is_tilebuf_wait) {
+                                        quadword_offset = -1;
                                 } else if (target_number > br_block_idx) {
                                         /* Jump forward */
 
@@ -2901,6 +2907,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
 
                                 midgard_jmp_writeout_op op =
                                         is_discard ? midgard_jmp_writeout_op_discard :
+                                        is_tilebuf_wait ? midgard_jmp_writeout_op_tilebuffer_pending :
                                         is_writeout ? midgard_jmp_writeout_op_writeout :
                                         (is_compact && !is_conditional) ? midgard_jmp_writeout_op_branch_uncond :
                                         midgard_jmp_writeout_op_branch_cond;
@@ -2913,7 +2920,7 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
                                                         quadword_offset);
 
                                         memcpy(&ins->branch_extended, &branch, sizeof(branch));
-                                } else if (is_conditional || is_discard) {
+                                } else if (is_conditional || is_special) {
                                         midgard_branch_cond branch = {
                                                 .op = op,
                                                 .dest_tag = dest_tag,