I'm going to want to make some other decisions here before flushing.
*
* This helps avoid flushing the command buffers when unnecessary.
*/
-void
-vc4_flush_for_bo(struct pipe_context *pctx, struct vc4_bo *bo)
+bool
+vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo)
{
struct vc4_context *vc4 = vc4_context(pctx);
if (!vc4->needs_flush)
- return;
+ return false;
/* Walk all the referenced BOs in the drawing command list to see if
* they match.
for (int i = 0; i < (vc4->bo_handles.next -
vc4->bo_handles.base) / 4; i++) {
if (referenced_bos[i] == bo) {
- vc4_flush(pctx);
- return;
+ return true;
}
}
if (csurf) {
struct vc4_resource *ctex = vc4_resource(csurf->base.texture);
if (ctex->bo == bo) {
- vc4_flush(pctx);
- return;
+ return true;
}
}
struct vc4_resource *ztex =
vc4_resource(zsurf->base.texture);
if (ztex->bo == bo) {
- vc4_flush(pctx);
- return;
+ return true;
}
}
+
+ return false;
}
static void
struct vc4_texture_stateobj *texstate);
void vc4_flush(struct pipe_context *pctx);
-void vc4_flush_for_bo(struct pipe_context *pctx, struct vc4_bo *bo);
+bool vc4_cl_references_bo(struct pipe_context *pctx, struct vc4_bo *bo);
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);
rsc->bo = vc4_bo_alloc(vc4->screen, size, "resource");
}
- if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED))
- vc4_flush_for_bo(pctx, rsc->bo);
+ if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+ if (vc4_cl_references_bo(pctx, rsc->bo))
+ vc4_flush(pctx);
+ }
if (usage & PIPE_TRANSFER_WRITE)
rsc->writes++;