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,