freedreno: push resource tracking down into batch

Signed-off-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:
Rob Clark 2016-05-20 20:05:26 -04:00 committed by Rob Clark
parent 9bbd239a40
commit 9e4561d3c4
7 changed files with 52 additions and 43 deletions

View File

@ -24,10 +24,12 @@
* 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)
@ -54,6 +56,8 @@ 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;
}
@ -76,7 +80,38 @@ __fd_batch_describe(char* buf, const struct fd_batch *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

View File

@ -32,6 +32,8 @@
#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
@ -48,11 +50,16 @@ struct fd_batch {
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: */

View File

@ -45,7 +45,6 @@ void
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);
@ -61,16 +60,6 @@ fd_context_render(struct pipe_context *pctx)
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

View File

@ -185,9 +185,6 @@ struct fd_context {
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:

View File

@ -39,39 +39,20 @@
#include "freedreno_query_hw.h"
#include "freedreno_util.h"
static void
resource_used(struct fd_context *ctx, struct pipe_resource *prsc,
enum fd_resource_status status)
{
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);
if (!prsc)
return;
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
@ -300,8 +281,6 @@ fd_clear_depth_stencil(struct pipe_context *pctx, struct pipe_surface *ps,
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;

View File

@ -109,7 +109,7 @@ realloc_bo(struct fd_resource *rsc, uint32_t size)
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);
}
@ -453,6 +453,7 @@ fd_resource_destroy(struct pipe_screen *pscreen,
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);

View File

@ -33,6 +33,7 @@
#include "util/u_range.h"
#include "util/u_transfer.h"
#include "freedreno_batch.h"
#include "freedreno_util.h"
/* Texture Layout on a3xx:
@ -91,7 +92,7 @@ struct fd_resource {
* in the used_resources list.
*/
struct list_head list;
struct fd_context *pending_ctx;
struct fd_batch *pending_batch;
};
static inline struct fd_resource *