DBG("%p: flush: flags=%x\n", ctx->batch, flags);
+ /* In some sequence of events, we can end up with a last_fence that is
+ * not an "fd" fence, which results in eglDupNativeFenceFDANDROID()
+ * errors.
+ *
+ */
+ if (flags & PIPE_FLUSH_FENCE_FD)
+ fd_fence_ref(&ctx->last_fence, NULL);
+
/* if no rendering since last flush, ie. app just decided it needed
* a fence, re-use the last one:
*/
/* Take a ref to the batch's fence (batch can be unref'd when flushed: */
fd_fence_ref(&fence, batch->fence);
- /* TODO is it worth trying to figure out if app is using fence-fd's, to
- * avoid requesting one every batch?
- */
- batch->needs_out_fence_fd = true;
+ if (flags & PIPE_FLUSH_FENCE_FD)
+ batch->needs_out_fence_fd = true;
if (!ctx->screen->reorder) {
fd_batch_flush(batch, true);