v3d: Add a function to describe what the c->execute.file check means.
authorEric Anholt <eric@anholt.net>
Thu, 14 Feb 2019 17:34:33 +0000 (09:34 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 19 Feb 2019 02:09:07 +0000 (18:09 -0800)
This is what pointed out that we were misusing the check for last_thrsw in
the previous commit.

src/broadcom/compiler/nir_to_vir.c
src/broadcom/compiler/v3d_compiler.h

index 7ab3b4f60ce0af87401b2fab22821fb04e49062d..331fc5d73c6b0a96c70596e4e55cf4a83099552e 100644 (file)
@@ -283,7 +283,7 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
                            instr->num_components - 2);
         }
 
-        if (c->execute.file != QFILE_NULL) {
+        if (vir_in_nonuniform_control_flow(c)) {
                 vir_set_pf(vir_MOV_dest(c, vir_nop_reg(), c->execute),
                            V3D_QPU_PF_PUSHZ);
         }
@@ -309,7 +309,7 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
                         vir_uniform_ui(c, config);
         }
 
-        if (c->execute.file != QFILE_NULL)
+        if (vir_in_nonuniform_control_flow(c))
                 vir_set_cond(tmu, V3D_QPU_COND_IFA);
 
         vir_emit_thrsw(c);
@@ -394,7 +394,7 @@ ntq_store_dest(struct v3d_compile *c, nir_dest *dest, int chan,
                 /* If we're in control flow, then make this update of the reg
                  * conditional on the execution mask.
                  */
-                if (c->execute.file != QFILE_NULL) {
+                if (vir_in_nonuniform_control_flow(c)) {
                         last_inst->dst.index = qregs[chan].index;
 
                         /* Set the flags to the current exec mask.
@@ -1897,7 +1897,7 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr)
                 break;
 
         case nir_intrinsic_discard:
-                if (c->execute.file != QFILE_NULL) {
+                if (vir_in_nonuniform_control_flow(c)) {
                         vir_set_pf(vir_MOV_dest(c, vir_nop_reg(), c->execute),
                                    V3D_QPU_PF_PUSHZ);
                         vir_set_cond(vir_SETMSF_dest(c, vir_nop_reg(),
@@ -1912,7 +1912,7 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr)
         case nir_intrinsic_discard_if: {
                 enum v3d_qpu_cond cond = ntq_emit_bool_to_cond(c, instr->src[0]);
 
-                if (c->execute.file != QFILE_NULL) {
+                if (vir_in_nonuniform_control_flow(c)) {
                         struct qinst *exec_flag = vir_MOV_dest(c, vir_nop_reg(),
                                                                c->execute);
                         if (cond == V3D_QPU_COND_IFA) {
@@ -2086,7 +2086,7 @@ ntq_emit_nonuniform_if(struct v3d_compile *c, nir_if *if_stmt)
                 else_block = vir_new_block(c);
 
         bool was_uniform_control_flow = false;
-        if (c->execute.file == QFILE_NULL) {
+        if (!vir_in_nonuniform_control_flow(c)) {
                 c->execute = vir_MOV(c, vir_uniform_ui(c, 0));
                 was_uniform_control_flow = true;
         }
@@ -2163,7 +2163,7 @@ ntq_emit_if(struct v3d_compile *c, nir_if *nif)
 {
         bool was_in_control_flow = c->in_control_flow;
         c->in_control_flow = true;
-        if (c->execute.file == QFILE_NULL &&
+        if (!vir_in_nonuniform_control_flow(c) &&
             nir_src_is_dynamically_uniform(nif->condition)) {
                 ntq_emit_uniform_if(c, nif);
         } else {
@@ -2252,7 +2252,7 @@ ntq_emit_loop(struct v3d_compile *c, nir_loop *loop)
         c->in_control_flow = true;
 
         bool was_uniform_control_flow = false;
-        if (c->execute.file == QFILE_NULL) {
+        if (!vir_in_nonuniform_control_flow(c)) {
                 c->execute = vir_MOV(c, vir_uniform_ui(c, 0));
                 was_uniform_control_flow = true;
         }
index 3817afe5ce653e0ad6b0aacfb617371c5e546604..cb55e2bb51818dba18d1283a514cbb501b5d6852 100644 (file)
@@ -846,6 +846,12 @@ quniform_contents_is_texture_p0(enum quniform_contents contents)
                             V3D_MAX_TEXTURE_SAMPLERS));
 }
 
+static inline bool
+vir_in_nonuniform_control_flow(struct v3d_compile *c)
+{
+        return c->execute.file != QFILE_NULL;
+}
+
 static inline struct qreg
 vir_uniform_ui(struct v3d_compile *c, uint32_t ui)
 {