* This helps avoid flushing the command buffers when unnecessary.
*/
bool
-vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo)
+vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo,
+ bool include_reads)
{
struct vc4_context *vc4 = vc4_context(pctx);
/* Walk all the referenced BOs in the drawing command list to see if
* they match.
*/
- struct vc4_bo **referenced_bos = vc4->bo_pointers.base;
- for (int i = 0; i < cl_offset(&vc4->bo_handles) / 4; i++) {
- if (referenced_bos[i] == bo) {
- return true;
+ if (include_reads) {
+ struct vc4_bo **referenced_bos = vc4->bo_pointers.base;
+ for (int i = 0; i < cl_offset(&vc4->bo_handles) / 4; i++) {
+ if (referenced_bos[i] == bo) {
+ return true;
+ }
}
}
void vc4_job_init(struct vc4_context *vc4);
void vc4_job_submit(struct vc4_context *vc4);
void vc4_job_reset(struct vc4_context *vc4);
-bool vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo);
+bool vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo,
+ bool include_reads);
void vc4_emit_state(struct pipe_context *pctx);
void vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c);
struct qpu_reg *vc4_register_allocate(struct vc4_context *vc4, struct vc4_compile *c);
vc4_flush(pctx);
}
} else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
- if (vc4_cl_references_bo(pctx, rsc->bo)) {
+ /* If we're writing and the buffer is being used by the CL, we
+ * have to flush the CL first. If we're only reading, we need
+ * to flush if the CL has written our buffer.
+ */
+ if (vc4_cl_references_bo(pctx, rsc->bo,
+ usage & PIPE_TRANSFER_WRITE)) {
if ((usage & PIPE_TRANSFER_DISCARD_RANGE) &&
prsc->last_level == 0 &&
prsc->width0 == box->width &&