v3d: Always emit a TF disable at the start of drawing on V3D 4.x.
authorEric Anholt <eric@anholt.net>
Thu, 13 Sep 2018 19:54:26 +0000 (12:54 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 17 Sep 2018 23:35:45 +0000 (16:35 -0700)
The HW's FLUSH_ALL_STATE is not validated, so we probably shouldn't use
it, meaning that we need to reset state at the start.  By doing this, we
also make ourselves more resilient to another client leaving the TF state
enabled at the end of their batch (as we now do, ourselves).

However, we still need to emit a single TF disable at the end of the
frame, for SWVC5-718.

src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3dx_emit.c
src/gallium/drivers/v3d/v3dx_job.c

index f6720e2..20f357a 100644 (file)
@@ -308,8 +308,7 @@ struct v3d_job {
         bool oq_enabled;
 
         /**
-         * Set when a packet enabling TF on all further primitives has been
-         * emitted.
+         * Set if a packet enabling TF has been emitted in the job (V3D 4.x).
          */
         bool tf_enabled;
 
index 537dd1f..50f9f60 100644 (file)
@@ -701,13 +701,14 @@ v3dX(emit_state)(struct pipe_context *pctx)
                                               v3d->prog.bind_vs->tf_specs);
 
 #if V3D_VERSION >= 40
-                        job->tf_enabled = (v3d->prog.bind_vs->num_tf_specs != 0 &&
+                        bool tf_enabled = (v3d->prog.bind_vs->num_tf_specs != 0 &&
                                            v3d->active_queries);
+                        job->tf_enabled |= tf_enabled;
 
                         cl_emit(&job->bcl, TRANSFORM_FEEDBACK_SPECS, tfe) {
                                 tfe.number_of_16_bit_output_data_specs_following =
                                         v3d->prog.bind_vs->num_tf_specs;
-                                tfe.enable = job->tf_enabled;
+                                tfe.enable = tf_enabled;
                         };
 #else /* V3D_VERSION < 40 */
                         cl_emit(&job->bcl, TRANSFORM_FEEDBACK_ENABLE, tfe) {
@@ -720,12 +721,11 @@ v3dX(emit_state)(struct pipe_context *pctx)
                         for (int i = 0; i < v3d->prog.bind_vs->num_tf_specs; i++) {
                                 cl_emit_prepacked(&job->bcl, &tf_specs[i]);
                         }
-                } else if (job->tf_enabled) {
+                } else {
 #if V3D_VERSION >= 40
                         cl_emit(&job->bcl, TRANSFORM_FEEDBACK_SPECS, tfe) {
                                 tfe.enable = false;
                         };
-                        job->tf_enabled = false;
 #endif /* V3D_VERSION >= 40 */
                 }
         }
index d87dcea..e0bd71f 100644 (file)
@@ -47,10 +47,9 @@ void v3dX(bcl_epilogue)(struct v3d_context *v3d, struct v3d_job *job)
                         cl_emit(&job->bcl, OCCLUSION_QUERY_COUNTER, counter);
                 }
 
-                /* Disable TF at the end of the CL, so that the next job to be
-                 * run doesn't start out trying to write TF primitives.  On
-                 * V3D 3.x, it's only the TF primitive mode that triggers TF
-                 * writes.
+                /* Disable TF at the end of the CL, so that the TF block
+                 * cleans up and finishes before it gets reset by the next
+                 * frame's tile binning mode cfg packet. (SWVC5-718).
                  */
 #if V3D_VERSION >= 41
                 if (job->tf_enabled) {