v3d: keep track of resources written by transform feedback
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 20 Jun 2019 11:38:56 +0000 (13:38 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Tue, 2 Jul 2019 06:57:20 +0000 (08:57 +0200)
The hardware provides a feature to sync reads from previous transform feedback
writes in the same job so if we use this mechanism we no longer have to flush
the job.

In order to identify this scenario we need a mechanism to identify resources
that are written by transform feedback.

v2: use _mesa_pointer_set_create (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3d_job.c
src/gallium/drivers/v3d/v3dx_emit.c

index 21db999..7c8952e 100644 (file)
@@ -297,6 +297,7 @@ struct v3d_job {
         uint32_t referenced_size;
 
         struct set *write_prscs;
+        struct set *tf_write_prscs;
 
         /* Size of the submit.bo_handles array. */
         uint32_t bo_handles_size;
@@ -589,6 +590,7 @@ struct v3d_job *v3d_get_job(struct v3d_context *v3d,
 struct v3d_job *v3d_get_job_for_fbo(struct v3d_context *v3d);
 void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo);
 void v3d_job_add_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
+void v3d_job_add_tf_write_resource(struct v3d_job *job, struct pipe_resource *prsc);
 void v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job);
 void v3d_flush_jobs_using_bo(struct v3d_context *v3d, struct v3d_bo *bo);
 void v3d_flush_jobs_writing_resource(struct v3d_context *v3d,
index 487f514..6f3fa70 100644 (file)
@@ -158,6 +158,17 @@ v3d_flush_jobs_using_bo(struct v3d_context *v3d, struct v3d_bo *bo)
 }
 
 void
+v3d_job_add_tf_write_resource(struct v3d_job *job, struct pipe_resource *prsc)
+{
+        v3d_job_add_write_resource(job, prsc);
+
+        if (!job->tf_write_prscs)
+                job->tf_write_prscs = _mesa_pointer_set_create(job);
+
+        _mesa_set_add(job->tf_write_prscs, prsc);
+}
+
+void
 v3d_flush_jobs_writing_resource(struct v3d_context *v3d,
                                 struct pipe_resource *prsc)
 {
index c54e63f..a3d32f4 100644 (file)
@@ -766,8 +766,8 @@ v3dX(emit_state)(struct pipe_context *pctx)
                         };
 #endif /* V3D_VERSION < 40 */
                         if (target) {
-                                v3d_job_add_write_resource(v3d->job,
-                                                           target->buffer);
+                                v3d_job_add_tf_write_resource(v3d->job,
+                                                              target->buffer);
                         }
                         /* XXX: buffer_size? */
                 }