agx: Check that we don't push too much
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 25 Sep 2022 23:26:58 +0000 (19:26 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 22 Oct 2022 18:59:32 +0000 (14:59 -0400)
Currently we don't have a good mechanism for this other than being
careful... assert() at least. The long term plan is to lift the
UBO/VBO lowerings into NIR, making the sysval requirements visible in
the NIR. (And possibly moving to a descriptor set model to better match
Vulkan? I need to talk to jekstrand about what we want to do here long
term.)

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18813>

src/asahi/compiler/agx_uniforms.c

index 3c072a4..7a29f25 100644 (file)
@@ -52,6 +52,7 @@ agx_indexed_sysval(agx_context *ctx, enum agx_push_type type,
 
    unsigned base = ctx->push_base;
    ctx->push_base += length;
+   assert(ctx->push_base <= AGX_NUM_UNIFORMS);
 
    ctx->out->push[ctx->out->push_ranges++] = (struct agx_push) {
       .type = type,
@@ -82,6 +83,7 @@ agx_vbo_base(agx_context *ctx, unsigned vbo)
 
    unsigned base = ctx->push_base;
    ctx->push_base += 4;
+   assert(ctx->push_base <= AGX_NUM_UNIFORMS);
 
    ctx->out->push[ctx->out->push_ranges++] = (struct agx_push) {
       .type = AGX_PUSH_VBO_BASE,