diff options
author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2023-02-03 15:24:05 -0500 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-02-04 17:10:15 +0000 |
commit | 78c9344a4d43862c355afa8e48648754ddb3f76f (patch) | |
tree | f555e7482750a5070fbc97ad459c4305b677e41e /src | |
parent | f54739396c685a54b723ebe6d53b64879b02fcf0 (diff) |
asahi: Add compute batches
Add a specialized agx_batch for compute commands (queued to the CDM instead of
the VDM for graphics). This uses a sentinel value for the width.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21062>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/asahi/agx_batch.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/asahi/agx_state.h | 8 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/gallium/drivers/asahi/agx_batch.c b/src/gallium/drivers/asahi/agx_batch.c index 01eaf0ef8a2..40374b79688 100644 --- a/src/gallium/drivers/asahi/agx_batch.c +++ b/src/gallium/drivers/asahi/agx_batch.c @@ -76,7 +76,8 @@ agx_batch_init(struct agx_context *ctx, unsigned batch_idx = agx_batch_idx(batch); BITSET_SET(ctx->batches.active, batch_idx); - agx_batch_init_state(batch); + if (key->width != AGX_COMPUTE_BATCH_WIDTH) + agx_batch_init_state(batch); } void @@ -172,6 +173,16 @@ agx_get_batch(struct agx_context *ctx) return ctx->batch; } +struct agx_batch * +agx_get_compute_batch(struct agx_context *ctx) +{ + agx_dirty_all(ctx); + + struct pipe_framebuffer_state key = {.width = AGX_COMPUTE_BATCH_WIDTH}; + ctx->batch = agx_get_batch_for_framebuffer(ctx, &key); + return ctx->batch; +} + void agx_flush_all(struct agx_context *ctx, const char *reason) { diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index 9c8b14fd401..3d728ea8a40 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -551,7 +551,15 @@ void agx_batch_writes(struct agx_batch *batch, struct agx_resource *rsrc); bool agx_any_batch_uses_resource(struct agx_context *ctx, struct agx_resource *rsrc); +/* 16384 is the maximum framebuffer dimension, so we use a larger width (the + * maximum uint16_t) as a sentinel to identify the compute batch. This ensures + * compute batches don't mix with graphics. This is a bit of a hack but it + * works. + */ +#define AGX_COMPUTE_BATCH_WIDTH 0xFFFF + struct agx_batch *agx_get_batch(struct agx_context *ctx); +struct agx_batch *agx_get_compute_batch(struct agx_context *ctx); void agx_batch_cleanup(struct agx_context *ctx, struct agx_batch *batch); /* Blit shaders */ |