broadcom/vc5: Flush the job when mapping a transform feedback buffer.
authorEric Anholt <eric@anholt.net>
Sat, 30 Sep 2017 23:48:44 +0000 (16:48 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 10 Oct 2017 18:42:05 +0000 (11:42 -0700)
We will want something fancier for reusing a TF output within the same
frame, but we at least need this in order for piglit tests to work.

src/gallium/drivers/vc5/vc5_context.h
src/gallium/drivers/vc5/vc5_emit.c
src/gallium/drivers/vc5/vc5_job.c

index 472f039859661ffdd71f9fd41e27405dac562019..96b21b8fa09815c0f93d4d13ead62d0eb4fb32c4 100644 (file)
@@ -199,6 +199,9 @@ struct vc5_job {
          * execute our job.
          */
         struct set *bos;
+
+        struct set *write_prscs;
+
         /* Size of the submit.bo_handles array. */
         uint32_t bo_handles_size;
 
@@ -437,6 +440,7 @@ struct vc5_job *vc5_get_job(struct vc5_context *vc5,
                             struct pipe_surface *zsbuf);
 struct vc5_job *vc5_get_job_for_fbo(struct vc5_context *vc5);
 void vc5_job_add_bo(struct vc5_job *job, struct vc5_bo *bo);
+void vc5_job_add_write_resource(struct vc5_job *job, struct pipe_resource *prsc);
 void vc5_job_submit(struct vc5_context *vc5, struct vc5_job *job);
 void vc5_flush_jobs_writing_resource(struct vc5_context *vc5,
                                      struct pipe_resource *prsc);
index 60883d96d4be90391bb68f7f162137afbcd6aae5..7f78817bf91b2a629305a5f74773656fe65ac806 100644 (file)
@@ -440,6 +440,9 @@ vc5_emit_state(struct pipe_context *pctx)
                                                 cl_address(rsc->bo,
                                                            target->buffer_offset);
                                 };
+
+                                vc5_job_add_write_resource(vc5->job,
+                                                           target->buffer);
                                 /* XXX: buffer_size? */
                         }
                 } else {
index f90b449aca7c74fab84b0d5960f9419f3980a381..5b97e6bf72f6f1fbe0807d05f35998eeebb4e892 100644 (file)
@@ -53,6 +53,16 @@ vc5_job_free(struct vc5_context *vc5, struct vc5_job *job)
 
         remove_from_ht(vc5->jobs, &job->key);
 
+        if (job->write_prscs) {
+                struct set_entry *entry;
+
+                set_foreach(job->write_prscs, entry) {
+                        const struct pipe_resource *prsc = entry->key;
+
+                        remove_from_ht(vc5->write_jobs, (void *)prsc);
+                }
+        }
+
         for (int i = 0; i < VC5_MAX_DRAW_BUFFERS; i++) {
                 if (job->cbufs[i]) {
                         remove_from_ht(vc5->write_jobs, job->cbufs[i]->texture);
@@ -120,6 +130,21 @@ vc5_job_add_bo(struct vc5_job *job, struct vc5_bo *bo)
         bo_handles[job->submit.bo_handle_count++] = bo->handle;
 }
 
+void
+vc5_job_add_write_resource(struct vc5_job *job, struct pipe_resource *prsc)
+{
+        struct vc5_context *vc5 = job->vc5;
+
+        if (!job->write_prscs) {
+                job->write_prscs = _mesa_set_create(job,
+                                                    _mesa_hash_pointer,
+                                                    _mesa_key_pointer_equal);
+        }
+
+        _mesa_set_add(job->write_prscs, prsc);
+        _mesa_hash_table_insert(vc5->write_jobs, prsc, job);
+}
+
 void
 vc5_flush_jobs_writing_resource(struct vc5_context *vc5,
                                 struct pipe_resource *prsc)