{
struct fd_context *ctx = fd_context(pctx);
struct pipe_framebuffer_state *pfb = &ctx->framebuffer;
+ struct fd_resource *rsc, *rsc_tmp;
int i;
DBG("needs_flush: %d", ctx->needs_flush);
fd_resource(pfb->cbufs[i]->texture)->dirty = false;
if (pfb->zsbuf)
fd_resource(pfb->zsbuf->texture)->dirty = false;
+
+ /* go through all the used resources and clear their reading flag */
+ LIST_FOR_EACH_ENTRY_SAFE(rsc, rsc_tmp, &ctx->used_resources, list) {
+ assert(rsc->reading);
+ rsc->reading = false;
+ list_delinit(&rsc->list);
+ }
+
+ assert(LIST_IS_EMPTY(&ctx->used_resources));
}
static void
#include "freedreno_query_hw.h"
#include "freedreno_util.h"
+static void
+resource_reading(struct fd_context *ctx, struct pipe_resource *prsc)
+{
+ struct fd_resource *rsc;
+
+ if (!prsc)
+ return;
+
+ rsc = fd_resource(prsc);
+ rsc->reading = true;
+ list_delinit(&rsc->list);
+ list_addtail(&rsc->list, &ctx->used_resources);
+}
static void
fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
ctx->gmem_reason |= FD_GMEM_BLEND_ENABLED;
}
+ /* Skip over buffer 0, that is sent along with the command stream */
+ for (i = 1; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
+ resource_reading(ctx, ctx->constbuf[PIPE_SHADER_VERTEX].cb[i].buffer);
+ resource_reading(ctx, ctx->constbuf[PIPE_SHADER_FRAGMENT].cb[i].buffer);
+ }
+
+ /* Mark VBOs as being read */
+ for (i = 0; i < ctx->vtx.vertexbuf.count; i++) {
+ assert(!ctx->vtx.vertexbuf.vb[i].user_buffer);
+ resource_reading(ctx, ctx->vtx.vertexbuf.vb[i].buffer);
+ }
+
+ /* Mark index buffer as being read */
+ resource_reading(ctx, ctx->indexbuf.buffer);
+
+ /* Mark textures as being read */
+ for (i = 0; i < ctx->verttex.num_textures; i++)
+ if (ctx->verttex.textures[i])
+ resource_reading(ctx, ctx->verttex.textures[i]->texture);
+ for (i = 0; i < ctx->fragtex.num_textures; i++)
+ if (ctx->fragtex.textures[i])
+ resource_reading(ctx, ctx->fragtex.textures[i]->texture);
+
ctx->num_draws++;
ctx->stats.draw_calls++;
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->dirty = false;
+ rsc->dirty = rsc->reading = false;
+ list_delinit(&rsc->list);
}
static void fd_resource_transfer_flush_region(struct pipe_context *pctx,
struct fd_resource *rsc = fd_resource(prsc);
if (rsc->bo)
fd_bo_del(rsc->bo);
+ list_delinit(&rsc->list);
FREE(rsc);
}
*prsc = *tmpl;
pipe_reference_init(&prsc->reference, 1);
+ list_inithead(&rsc->list);
prsc->screen = pscreen;
rsc->base.vtbl = &fd_resource_vtbl;
*prsc = *tmpl;
pipe_reference_init(&prsc->reference, 1);
+ list_inithead(&rsc->list);
prsc->screen = pscreen;
rsc->bo = fd_screen_bo_from_handle(pscreen, handle, &slice->pitch);