Skip to content

Commit 23b4503

Browse files
alyssarosenzweigMarge Bot
authored andcommitted
asahi: rewrite queries
1. always keep the query in gpu memory, so we can implement qbos properly. 2. use a lightweight data structure for tracking writers to reduce overhead 3. allow many writers per query to eliminate stalls 4. use context-wide occlusion heap, to satisfy #1 without introducing flushes or silly copies. this is what the pvr mesa driver does :-) Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27616>
1 parent ca58bc2 commit 23b4503

File tree

6 files changed

+283
-261
lines changed

6 files changed

+283
-261
lines changed

src/gallium/drivers/asahi/agx_batch.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
agx_msg("[Batch %u] " fmt "\n", agx_batch_idx(batch), ##__VA_ARGS__); \
2525
} while (0)
2626

27-
static unsigned
28-
agx_batch_idx(struct agx_batch *batch)
29-
{
30-
return batch - batch->ctx->batches.slots;
31-
}
32-
3327
bool
3428
agx_batch_is_active(struct agx_batch *batch)
3529
{
@@ -125,9 +119,7 @@ agx_batch_init(struct agx_context *ctx,
125119

126120
util_dynarray_init(&batch->scissor, ctx);
127121
util_dynarray_init(&batch->depth_bias, ctx);
128-
util_dynarray_init(&batch->occlusion_queries, ctx);
129-
util_dynarray_init(&batch->nonocclusion_queries, ctx);
130-
util_dynarray_init(&batch->timestamp_queries, ctx);
122+
util_dynarray_init(&batch->timestamps, ctx);
131123

132124
batch->clear = 0;
133125
batch->draw = 0;
@@ -177,8 +169,6 @@ agx_batch_cleanup(struct agx_context *ctx, struct agx_batch *batch, bool reset)
177169
uint64_t begin_ts = ~0, end_ts = 0;
178170
/* TODO: UAPI pending */
179171
agx_finish_batch_queries(batch, begin_ts, end_ts);
180-
batch->occlusion_buffer.cpu = NULL;
181-
batch->occlusion_buffer.gpu = 0;
182172

183173
if (reset) {
184174
int handle;
@@ -212,9 +202,7 @@ agx_batch_cleanup(struct agx_context *ctx, struct agx_batch *batch, bool reset)
212202

213203
util_dynarray_fini(&batch->scissor);
214204
util_dynarray_fini(&batch->depth_bias);
215-
util_dynarray_fini(&batch->occlusion_queries);
216-
util_dynarray_fini(&batch->nonocclusion_queries);
217-
util_dynarray_fini(&batch->timestamp_queries);
205+
util_dynarray_fini(&batch->timestamps);
218206

219207
if (!(dev->debug & (AGX_DBG_TRACE | AGX_DBG_SYNC))) {
220208
agx_batch_print_stats(dev, batch);
@@ -774,13 +762,6 @@ agx_batch_reset(struct agx_context *ctx, struct agx_batch *batch)
774762
agx_batch_cleanup(ctx, batch, true);
775763
}
776764

777-
void
778-
agx_batch_add_timestamp_query(struct agx_batch *batch, struct agx_query *q)
779-
{
780-
if (q)
781-
util_dynarray_append(&batch->timestamp_queries, struct agx_query *, q);
782-
}
783-
784765
/*
785766
* Timestamp queries record the time after all current work is finished,
786767
* which we handle as the time after all current batches finish (since we're a

src/gallium/drivers/asahi/agx_pipe.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,19 +1333,6 @@ agx_flush_batch(struct agx_context *ctx, struct agx_batch *batch)
13331333
*/
13341334
agx_batch_add_bo(batch, batch->vdm.bo);
13351335

1336-
/* Occlusion queries are allocated as a contiguous pool */
1337-
unsigned oq_count =
1338-
util_dynarray_num_elements(&batch->occlusion_queries, struct agx_query *);
1339-
size_t oq_size = oq_count * sizeof(uint64_t);
1340-
1341-
if (oq_size) {
1342-
batch->occlusion_buffer =
1343-
agx_pool_alloc_aligned(&batch->pool, oq_size, 64);
1344-
memset(batch->occlusion_buffer.cpu, 0, oq_size);
1345-
} else {
1346-
batch->occlusion_buffer.gpu = 0;
1347-
}
1348-
13491336
if (batch->vs_scratch)
13501337
agx_batch_add_bo(batch, ctx->scratch_vs.buf);
13511338
if (batch->fs_scratch)

0 commit comments

Comments
 (0)