summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-04-21 09:50:30 -0400
committerRob Clark <robdclark@gmail.com>2017-04-22 10:03:01 -0400
commitdf63ff4d8248d81ecb8d0f3059bf2c67431e6f2f (patch)
tree6bdc94b7326d0367ebdf6b5579fca13e19997ff4 /src
parent2faf227ec2e22c7a37e0a54783a3f0a0062ac852 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_context.c5
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_query.c7
-rw-r--r--src/gallium/drivers/freedreno/a4xx/fd4_context.c5
-rw-r--r--src/gallium/drivers/freedreno/a4xx/fd4_query.c7
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_emit.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_batch.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_context.c2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_context.h17
-rw-r--r--src/gallium/drivers/freedreno/freedreno_draw.c4
-rw-r--r--src/gallium/drivers/freedreno/freedreno_gmem.c12
-rw-r--r--src/gallium/drivers/freedreno/freedreno_query.c4
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c4
-rw-r--r--src/gallium/drivers/freedreno/freedreno_state.c2
13 files changed, 57 insertions, 16 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
index dac59418df0..b432f593e0f 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_query.c b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
index cce165c0410..cde42c37313 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_query.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
@@ -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);
}
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.c b/src/gallium/drivers/freedreno/a4xx/fd4_context.c
index 291df2d03fc..db292af8be1 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_context.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c
index 3ae3971dc5f..f7b385d552d 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index f2c9a6b85d5..5b25257167b 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -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
diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c
index f97282b3405..17078d425e0 100644
--- a/src/gallium/drivers/freedreno/freedreno_batch.c
+++ b/src/gallium/drivers/freedreno/freedreno_batch.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index 6478e0e7a9c..c8d2138cfea 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -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)
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h
index 733c64b1807..fe685e1767d 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -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);
diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c
index 6243984dc80..dc9effbb7b7 100644
--- a/src/gallium/drivers/freedreno/freedreno_draw.c
+++ b/src/gallium/drivers/freedreno/freedreno_draw.c
@@ -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);
diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c b/src/gallium/drivers/freedreno/freedreno_gmem.c
index d9f707d9c9a..ded23219dc2 100644
--- a/src/gallium/drivers/freedreno/freedreno_gmem.c
+++ b/src/gallium/drivers/freedreno/freedreno_gmem.c
@@ -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++;
}
diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c
index 1e72c6d65f1..a27ddb5c638 100644
--- a/src/gallium/drivers/freedreno/freedreno_query.c
+++ b/src/gallium/drivers/freedreno/freedreno_query.c
@@ -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;
}
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 3b067095523..e4e7aa92a46 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -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;
}
diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c
index 3b02e630646..54bd54898a3 100644
--- a/src/gallium/drivers/freedreno/freedreno_state.c
+++ b/src/gallium/drivers/freedreno/freedreno_state.c
@@ -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);