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 21db9997c90de7d3aa38226977d89138bf26ab16..7c8952ebb74f4265c11f097fb336d94c3e86a7d9 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 487f514a055c51d54533c845247819453b162a50..6f3fa709616222b5fa7d5dfb32e12f4f7d733afb 100644 (file)
@@ -157,6 +157,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 c54e63f7efe7c214c713a42cf7d83d26b7c0673c..a3d32f4b7d7bb1e35a360eff66d5d432012680f8 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? */
                 }