mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-22 12:50:35 +01:00
freedreno: make hw-query a helper
For a5xx (and actually some queries on a4xx) we can accumulate results in the cmdstream, so we don't need this elaborate mechanism of tracking per-tile query results. So make it into vfuncs so generation specific backend can use it when it makes sense. Signed-off-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:
parent
2faf227ec2
commit
df63ff4d82
13 changed files with 57 additions and 16 deletions
|
|
@ -26,6 +26,7 @@
|
|||
* Rob Clark <robclark@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "freedreno_query_hw.h"
|
||||
|
||||
#include "fd3_context.h"
|
||||
#include "fd3_blend.h"
|
||||
|
|
@ -51,6 +52,8 @@ fd3_context_destroy(struct pipe_context *pctx)
|
|||
|
||||
u_upload_destroy(fd3_ctx->border_color_uploader);
|
||||
|
||||
fd_hw_query_fini(pctx);
|
||||
|
||||
fd_context_destroy(pctx);
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +98,8 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
if (!pctx)
|
||||
return NULL;
|
||||
|
||||
fd_hw_query_init(pctx);
|
||||
|
||||
fd3_ctx->vs_pvt_mem = fd_bo_new(screen->dev, 0x2000,
|
||||
DRM_FREEDRENO_GEM_TYPE_KMEM);
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,13 @@ static const struct fd_hw_sample_provider occlusion_predicate = {
|
|||
|
||||
void fd3_query_context_init(struct pipe_context *pctx)
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
|
||||
ctx->create_query = fd_hw_create_query;
|
||||
ctx->query_prepare = fd_hw_query_prepare;
|
||||
ctx->query_prepare_tile = fd_hw_query_prepare_tile;
|
||||
ctx->query_set_stage = fd_hw_query_set_stage;
|
||||
|
||||
fd_hw_query_register_provider(pctx, &occlusion_counter);
|
||||
fd_hw_query_register_provider(pctx, &occlusion_predicate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
* Rob Clark <robclark@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "freedreno_query_hw.h"
|
||||
|
||||
#include "fd4_context.h"
|
||||
#include "fd4_blend.h"
|
||||
|
|
@ -51,6 +52,8 @@ fd4_context_destroy(struct pipe_context *pctx)
|
|||
|
||||
u_upload_destroy(fd4_ctx->border_color_uploader);
|
||||
|
||||
fd_hw_query_fini(pctx);
|
||||
|
||||
fd_context_destroy(pctx);
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +98,8 @@ fd4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
if (!pctx)
|
||||
return NULL;
|
||||
|
||||
fd_hw_query_init(pctx);
|
||||
|
||||
fd4_ctx->vs_pvt_mem = fd_bo_new(screen->dev, 0x2000,
|
||||
DRM_FREEDRENO_GEM_TYPE_KMEM);
|
||||
|
||||
|
|
|
|||
|
|
@ -275,6 +275,13 @@ static const struct fd_hw_sample_provider timestamp = {
|
|||
|
||||
void fd4_query_context_init(struct pipe_context *pctx)
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
|
||||
ctx->create_query = fd_hw_create_query;
|
||||
ctx->query_prepare = fd_hw_query_prepare;
|
||||
ctx->query_prepare_tile = fd_hw_query_prepare_tile;
|
||||
ctx->query_set_stage = fd_hw_query_set_stage;
|
||||
|
||||
fd_hw_query_register_provider(pctx, &occlusion_counter);
|
||||
fd_hw_query_register_provider(pctx, &occlusion_predicate);
|
||||
fd_hw_query_register_provider(pctx, &time_elapsed);
|
||||
|
|
|
|||
|
|
@ -909,8 +909,6 @@ t7 opcode: CP_WAIT_FOR_IDLE (26) (1 dwords)
|
|||
// TODO hacks.. these should not be hardcoded:
|
||||
OUT_PKT4(ring, REG_A5XX_GRAS_SC_CNTL, 1);
|
||||
OUT_RING(ring, 0x00000008); /* GRAS_SC_CNTL */
|
||||
|
||||
fd_hw_query_enable(batch, ring);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ batch_flush(struct fd_batch *batch)
|
|||
/* close out the draw cmds by making sure any active queries are
|
||||
* paused:
|
||||
*/
|
||||
fd_hw_query_set_stage(batch, batch->draw, FD_STAGE_NULL);
|
||||
fd_batch_set_stage(batch, batch->draw, FD_STAGE_NULL);
|
||||
|
||||
fd_context_all_dirty(batch->ctx);
|
||||
batch_flush_reset_dependencies(batch, true);
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ fd_context_destroy(struct pipe_context *pctx)
|
|||
fd_fence_ref(pctx->screen, &ctx->last_fence, NULL);
|
||||
|
||||
fd_prog_fini(pctx);
|
||||
fd_hw_query_fini(pctx);
|
||||
|
||||
if (ctx->blitter)
|
||||
util_blitter_destroy(ctx->blitter);
|
||||
|
|
@ -293,7 +292,6 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
|
|||
fd_query_context_init(pctx);
|
||||
fd_texture_init(pctx);
|
||||
fd_state_init(pctx);
|
||||
fd_hw_query_init(pctx);
|
||||
|
||||
ctx->blitter = util_blitter_create(pctx);
|
||||
if (!ctx->blitter)
|
||||
|
|
|
|||
|
|
@ -291,6 +291,14 @@ struct fd_context {
|
|||
/* indirect-branch emit: */
|
||||
void (*emit_ib)(struct fd_ringbuffer *ring, struct fd_ringbuffer *target);
|
||||
|
||||
/* query: */
|
||||
struct fd_query * (*create_query)(struct fd_context *ctx, unsigned query_type);
|
||||
void (*query_prepare)(struct fd_batch *batch, uint32_t num_tiles);
|
||||
void (*query_prepare_tile)(struct fd_batch *batch, uint32_t n,
|
||||
struct fd_ringbuffer *ring);
|
||||
void (*query_set_stage)(struct fd_batch *batch,
|
||||
struct fd_ringbuffer *ring, enum fd_render_stage stage);
|
||||
|
||||
/*
|
||||
* Common pre-cooked VBO state (used for a3xx and later):
|
||||
*/
|
||||
|
|
@ -368,6 +376,15 @@ fd_supported_prim(struct fd_context *ctx, unsigned prim)
|
|||
return (1 << prim) & ctx->primtype_mask;
|
||||
}
|
||||
|
||||
static inline void
|
||||
fd_batch_set_stage(struct fd_batch *batch,
|
||||
struct fd_ringbuffer *ring, enum fd_render_stage stage)
|
||||
{
|
||||
struct fd_context *ctx = batch->ctx;
|
||||
if (ctx->query_set_stage)
|
||||
ctx->query_set_stage(batch, ring, stage);
|
||||
}
|
||||
|
||||
void fd_context_setup_common_vbos(struct fd_context *ctx);
|
||||
void fd_context_cleanup_common_vbos(struct fd_context *ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
|
|||
/* NOTE: needs to be before resource_written(batch->query_buf), otherwise
|
||||
* query_buf may not be created yet.
|
||||
*/
|
||||
fd_hw_query_set_stage(batch, batch->draw, FD_STAGE_DRAW);
|
||||
fd_batch_set_stage(batch, batch->draw, FD_STAGE_DRAW);
|
||||
|
||||
/*
|
||||
* Figure out the buffers/features we need:
|
||||
|
|
@ -368,7 +368,7 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
|
|||
return;
|
||||
}
|
||||
|
||||
fd_hw_query_set_stage(batch, batch->draw, FD_STAGE_CLEAR);
|
||||
fd_batch_set_stage(batch, batch->draw, FD_STAGE_CLEAR);
|
||||
|
||||
ctx->clear(ctx, buffers, color, depth, stencil);
|
||||
|
||||
|
|
|
|||
|
|
@ -332,7 +332,8 @@ render_tiles(struct fd_batch *batch)
|
|||
|
||||
ctx->emit_tile_renderprep(batch, tile);
|
||||
|
||||
fd_hw_query_prepare_tile(batch, i, batch->gmem);
|
||||
if (ctx->query_prepare_tile)
|
||||
ctx->query_prepare_tile(batch, i, batch->gmem);
|
||||
|
||||
/* emit IB to drawcmds: */
|
||||
ctx->emit_ib(batch->gmem, batch->draw);
|
||||
|
|
@ -353,7 +354,8 @@ render_sysmem(struct fd_batch *batch)
|
|||
|
||||
ctx->emit_sysmem_prep(batch);
|
||||
|
||||
fd_hw_query_prepare_tile(batch, 0, batch->gmem);
|
||||
if (ctx->query_prepare_tile)
|
||||
ctx->query_prepare_tile(batch, 0, batch->gmem);
|
||||
|
||||
/* emit IB to drawcmds: */
|
||||
ctx->emit_ib(batch->gmem, batch->draw);
|
||||
|
|
@ -402,7 +404,8 @@ fd_gmem_render_tiles(struct fd_batch *batch)
|
|||
batch, pfb->width, pfb->height,
|
||||
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
|
||||
util_format_short_name(pipe_surface_format(pfb->zsbuf)));
|
||||
fd_hw_query_prepare(batch, 1);
|
||||
if (ctx->query_prepare)
|
||||
ctx->query_prepare(batch, 1);
|
||||
render_sysmem(batch);
|
||||
ctx->stats.batch_sysmem++;
|
||||
} else {
|
||||
|
|
@ -412,7 +415,8 @@ fd_gmem_render_tiles(struct fd_batch *batch)
|
|||
batch, pfb->width, pfb->height, gmem->nbins_x, gmem->nbins_y,
|
||||
util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
|
||||
util_format_short_name(pipe_surface_format(pfb->zsbuf)));
|
||||
fd_hw_query_prepare(batch, gmem->nbins_x * gmem->nbins_y);
|
||||
if (ctx->query_prepare)
|
||||
ctx->query_prepare(batch, gmem->nbins_x * gmem->nbins_y);
|
||||
render_tiles(batch);
|
||||
ctx->stats.batch_gmem++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ fd_create_query(struct pipe_context *pctx, unsigned query_type, unsigned index)
|
|||
struct fd_query *q;
|
||||
|
||||
q = fd_sw_create_query(ctx, query_type);
|
||||
if (!q)
|
||||
q = fd_hw_create_query(ctx, query_type);
|
||||
if (!q && ctx->create_query)
|
||||
q = ctx->create_query(ctx, query_type);
|
||||
|
||||
return (struct pipe_query *) q;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1091,7 +1091,7 @@ fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard,
|
|||
ctx->cond_query, ctx->cond_cond, ctx->cond_mode);
|
||||
|
||||
if (ctx->batch)
|
||||
fd_hw_query_set_stage(ctx->batch, ctx->batch->draw, stage);
|
||||
fd_batch_set_stage(ctx->batch, ctx->batch->draw, stage);
|
||||
|
||||
ctx->in_blit = discard;
|
||||
}
|
||||
|
|
@ -1100,7 +1100,7 @@ void
|
|||
fd_blitter_pipe_end(struct fd_context *ctx)
|
||||
{
|
||||
if (ctx->batch)
|
||||
fd_hw_query_set_stage(ctx->batch, ctx->batch->draw, FD_STAGE_NULL);
|
||||
fd_batch_set_stage(ctx->batch, ctx->batch->draw, FD_STAGE_NULL);
|
||||
ctx->in_blit = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ fd_set_framebuffer_state(struct pipe_context *pctx,
|
|||
fd_batch_reference(&old_batch, ctx->batch);
|
||||
|
||||
if (likely(old_batch))
|
||||
fd_hw_query_set_stage(old_batch, old_batch->draw, FD_STAGE_NULL);
|
||||
fd_batch_set_stage(old_batch, old_batch->draw, FD_STAGE_NULL);
|
||||
|
||||
batch = fd_batch_from_fb(&ctx->screen->batch_cache, ctx, framebuffer);
|
||||
fd_batch_reference(&ctx->batch, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue