* Rob Clark <robclark@freedesktop.org>
*/
+#include "util/list.h"
#include "util/u_string.h"
#include "freedreno_batch.h"
#include "freedreno_context.h"
+#include "freedreno_resource.h"
struct fd_batch *
fd_batch_create(struct fd_context *ctx)
fd_ringbuffer_set_parent(batch->draw, batch->gmem);
fd_ringbuffer_set_parent(batch->binning, batch->gmem);
+ list_inithead(&batch->used_resources);
+
return batch;
}
void
fd_batch_flush(struct fd_batch *batch)
{
+ struct fd_resource *rsc, *rsc_tmp;
+
fd_gmem_render_tiles(batch->ctx);
+
+ /* go through all the used resources and clear their reading flag */
+ LIST_FOR_EACH_ENTRY_SAFE(rsc, rsc_tmp, &batch->used_resources, list) {
+ debug_assert(rsc->pending_batch == batch);
+ debug_assert(rsc->status != 0);
+ rsc->status = 0;
+ fd_batch_reference(&rsc->pending_batch, NULL);
+ list_delinit(&rsc->list);
+ }
+
+ assert(LIST_IS_EMPTY(&batch->used_resources));
+}
+
+void
+fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc,
+ enum fd_resource_status status)
+{
+ rsc->status |= status;
+
+ if (rsc->stencil)
+ rsc->stencil->status |= status;
+
+ /* TODO resources can actually be shared across contexts,
+ * so I'm not sure a single list-head will do the trick?
+ */
+ debug_assert((rsc->pending_batch == batch) || !rsc->pending_batch);
+ list_delinit(&rsc->list);
+ list_addtail(&rsc->list, &batch->used_resources);
+ fd_batch_reference(&rsc->pending_batch, batch);
}
void
#include "freedreno_util.h"
struct fd_context;
+struct fd_resource;
+enum fd_resource_status;
/* A batch tracks everything about a cmdstream batch/submit, including the
* ringbuffers used for binning, draw, and gmem cmds, list of associated
struct fd_ringbuffer *binning;
/** tiling/gmem (IB0) cmdstream: */
struct fd_ringbuffer *gmem;
+
+ /** list of resources used by currently-unsubmitted batch */
+ struct list_head used_resources;
};
struct fd_batch * fd_batch_create(struct fd_context *ctx);
void fd_batch_flush(struct fd_batch *batch);
+void fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc,
+ enum fd_resource_status status);
void fd_batch_check_size(struct fd_batch *batch);
/* not called directly: */
fd_context_render(struct pipe_context *pctx)
{
struct fd_context *ctx = fd_context(pctx);
- struct fd_resource *rsc, *rsc_tmp;
DBG("needs_flush: %d", ctx->needs_flush);
ctx->cleared = ctx->partial_cleared = ctx->restore = ctx->resolve = 0;
ctx->gmem_reason = 0;
ctx->num_draws = 0;
-
- /* go through all the used resources and clear their reading flag */
- LIST_FOR_EACH_ENTRY_SAFE(rsc, rsc_tmp, &ctx->used_resources, list) {
- debug_assert(rsc->status != 0);
- rsc->status = 0;
- rsc->pending_ctx = NULL;
- list_delinit(&rsc->list);
- }
-
- assert(LIST_IS_EMPTY(&ctx->used_resources));
}
static void
struct fd_bo *query_bo;
uint32_t query_tile_stride;
- /* list of resources used by currently-unsubmitted renders */
- struct list_head used_resources;
-
/* table with PIPE_PRIM_MAX entries mapping PIPE_PRIM_x to
* DI_PT_x value to use for draw initiator. There are some
* slight differences between generation:
#include "freedreno_util.h"
static void
-resource_used(struct fd_context *ctx, struct pipe_resource *prsc,
- enum fd_resource_status status)
+resource_read(struct fd_context *ctx, struct pipe_resource *prsc)
{
- struct fd_resource *rsc;
-
if (!prsc)
return;
-
- rsc = fd_resource(prsc);
- rsc->status |= status;
- if (rsc->stencil)
- rsc->stencil->status |= status;
-
- /* TODO resources can actually be shared across contexts,
- * so I'm not sure a single list-head will do the trick?
- */
- debug_assert((rsc->pending_ctx == ctx) || !rsc->pending_ctx);
- list_delinit(&rsc->list);
- list_addtail(&rsc->list, &ctx->used_resources);
- rsc->pending_ctx = ctx;
-}
-
-static void
-resource_read(struct fd_context *ctx, struct pipe_resource *prsc)
-{
- resource_used(ctx, prsc, FD_PENDING_READ);
+ fd_batch_resource_used(ctx->batch, fd_resource(prsc), FD_PENDING_READ);
}
static void
resource_written(struct fd_context *ctx, struct pipe_resource *prsc)
{
- resource_used(ctx, prsc, FD_PENDING_WRITE);
+ if (!prsc)
+ return;
+ fd_batch_resource_used(ctx->batch, fd_resource(prsc), FD_PENDING_WRITE);
}
static void
void
fd_draw_init(struct pipe_context *pctx)
{
- list_inithead(&fd_context(pctx)->used_resources);
-
pctx->draw_vbo = fd_draw_vbo;
pctx->clear = fd_clear;
pctx->clear_render_target = fd_clear_render_target;
rsc->bo = fd_bo_new(screen->dev, size, flags);
rsc->timestamp = 0;
rsc->status = 0;
- rsc->pending_ctx = NULL;
+ fd_batch_reference(&rsc->pending_batch, NULL);
list_delinit(&rsc->list);
util_range_set_empty(&rsc->valid_buffer_range);
}
struct fd_resource *rsc = fd_resource(prsc);
if (rsc->bo)
fd_bo_del(rsc->bo);
+ fd_batch_reference(&rsc->pending_batch, NULL);
list_delinit(&rsc->list);
util_range_destroy(&rsc->valid_buffer_range);
FREE(rsc);
#include "util/u_range.h"
#include "util/u_transfer.h"
+#include "freedreno_batch.h"
#include "freedreno_util.h"
/* Texture Layout on a3xx:
* in the used_resources list.
*/
struct list_head list;
- struct fd_context *pending_ctx;
+ struct fd_batch *pending_batch;
};
static inline struct fd_resource *