From d814711155a4ce17f49428bde72b15367202c076 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 22 May 2022 16:51:44 -0400 Subject: [PATCH] asahi: Guard against encoder overflows We don't seem to hit this yet, but it's possible so add an assert to rule it out for failing tests. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_state.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index e10a5843fd1..0d0afb7b36e 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -1626,6 +1626,9 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, (info->mode == PIPE_PRIM_LINE_STRIP) || (info->mode == PIPE_PRIM_LINE_LOOP); + ptrdiff_t encoder_use = batch->encoder_current - (uint8_t *) batch->encoder->ptr.cpu; + assert((encoder_use + 1024) < batch->encoder->size && "todo: how to expand encoder?"); + uint8_t *out = agx_encode_state(ctx, batch->encoder_current, agx_build_pipeline(ctx, ctx->vs, PIPE_SHADER_VERTEX), agx_build_pipeline(ctx, ctx->fs, PIPE_SHADER_FRAGMENT),