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>
This commit is contained in:
Alyssa Rosenzweig 2023-02-03 15:24:05 -05:00 committed by Marge Bot
parent f54739396c
commit 78c9344a4d
2 changed files with 20 additions and 1 deletions

View file

@ -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)
{

View file

@ -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 */