#include "util/u_dump.h"
#include "freedreno_blitter.h"
+#include "freedreno_fence.h"
#include "freedreno_resource.h"
#include "fd6_blitter.h"
return;
}
+ fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
+
batch = fd_bc_alloc_batch(&ctx->screen->batch_cache, ctx, true);
fd6_emit_restore(batch, batch->draw);
DBG("%p: flush: flags=%x\n", ctx->batch, flags);
+ /* if no rendering since last flush, ie. app just decided it needed
+ * a fence, re-use the last one:
+ */
+ if (ctx->last_fence) {
+ fd_fence_ref(pctx->screen, &fence, ctx->last_fence);
+ goto out;
+ }
+
if (!batch)
return;
/* Take a ref to the batch's fence (batch can be unref'd when flushed: */
fd_fence_ref(pctx->screen, &fence, batch->fence);
- if (flags & PIPE_FLUSH_FENCE_FD)
- batch->needs_out_fence_fd = true;
+ /* 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 (!ctx->screen->reorder) {
fd_batch_flush(batch, true, false);
fd_bc_flush(&ctx->screen->batch_cache, ctx);
}
+out:
if (fencep)
fd_fence_ref(pctx->screen, fencep, fence);
+ fd_fence_ref(pctx->screen, &ctx->last_fence, fence);
+
fd_fence_ref(pctx->screen, &fence, NULL);
}
DBG("");
+ fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
+
if (ctx->screen->reorder && util_queue_is_initialized(&ctx->flush_queue))
util_queue_destroy(&ctx->flush_queue);
*/
struct fd_batch *batch;
+ /* NULL if there has been rendering since last flush. Otherwise
+ * keeps a reference to the last fence so we can re-use it rather
+ * than having to flush no-op batch.
+ */
+ struct pipe_fence_handle *last_fence;
+
/* Are we in process of shadowing a resource? Used to detect recursion
* in transfer_map, and skip unneeded synchronization.
*/
#include "freedreno_draw.h"
#include "freedreno_context.h"
+#include "freedreno_fence.h"
#include "freedreno_state.h"
#include "freedreno_resource.h"
#include "freedreno_query_acc.h"
return;
}
+ fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
+
/* Upload a user index buffer. */
struct pipe_resource *indexbuf = NULL;
unsigned index_offset = 0;
if (!fd_render_condition_check(pctx))
return;
+ fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
+
if (ctx->in_blit) {
fd_batch_reset(batch);
fd_context_all_dirty(ctx);
#include "freedreno_resource.h"
#include "freedreno_batch_cache.h"
+#include "freedreno_fence.h"
#include "freedreno_screen.h"
#include "freedreno_surface.h"
#include "freedreno_context.h"
fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard,
enum fd_render_stage stage)
{
+ fd_fence_ref(ctx->base.screen, &ctx->last_fence, NULL);
+
util_blitter_save_fragment_constant_buffer_slot(ctx->blitter,
ctx->constbuf[PIPE_SHADER_FRAGMENT].cb);
util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vtx.vertexbuf.vb);