From cb52aa58d6ba15ef1ddb1522c0316a526c98b296 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 22 Apr 2025 14:31:46 -0400 Subject: [PATCH] agx/nir_lower_gs: bound static topologies don't bloat up shader info. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Mary Guillemard Part-of: --- src/asahi/lib/agx_nir_lower_gs.c | 11 ++++++----- src/asahi/lib/agx_nir_lower_gs.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/asahi/lib/agx_nir_lower_gs.c b/src/asahi/lib/agx_nir_lower_gs.c index dc5c6485558..da3718945de 100644 --- a/src/asahi/lib/agx_nir_lower_gs.c +++ b/src/asahi/lib/agx_nir_lower_gs.c @@ -1361,12 +1361,13 @@ optimize_static_topology(struct agx_gs_info *info, nir_shader *gs) * to bound this, but we want small serialized shader info structs. We assume * that large static index buffers are rare and hence fall back to dynamic. */ - for (unsigned i = 0; i < info->max_indices; ++i) { - if (ctx.topology[i] != ~0 && ctx.topology[i] >= 0xFF) { - info->shape = AGX_GS_SHAPE_DYNAMIC_INDEXED; - return; - } + if (info->max_indices >= ARRAY_SIZE(info->topology)) { + info->shape = AGX_GS_SHAPE_DYNAMIC_INDEXED; + return; + } + for (unsigned i = 0; i < info->max_indices; ++i) { + assert((ctx.topology[i] < 0xFF || ctx.topology[i] == ~0) && "small"); info->topology[i] = ctx.topology[i]; } diff --git a/src/asahi/lib/agx_nir_lower_gs.h b/src/asahi/lib/agx_nir_lower_gs.h index b9124b042f1..fc3080f1e6d 100644 --- a/src/asahi/lib/agx_nir_lower_gs.h +++ b/src/asahi/lib/agx_nir_lower_gs.h @@ -42,7 +42,7 @@ struct agx_gs_info { enum agx_gs_shape shape; /* Static topology used if shape = AGX_GS_SHAPE_STATIC_INDEXED */ - uint8_t topology[384]; + uint8_t topology[64]; }; bool agx_nir_lower_gs(struct nir_shader *gs, bool rasterizer_discard,