aco: Add a few assertions about LDS usage.
authorTimur Kristóf <timur.kristof@gmail.com>
Thu, 15 Oct 2020 16:18:21 +0000 (18:18 +0200)
committerTimur Kristóf <timur.kristof@gmail.com>
Wed, 28 Oct 2020 20:47:22 +0000 (21:47 +0100)
This is to make sure we don't compile a shader which doesn't
fit the available LDS space.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7232>

src/amd/compiler/aco_instruction_selection_setup.cpp

index a59af50..f218d27 100644 (file)
@@ -471,6 +471,8 @@ void setup_gs_variables(isel_context *ctx, nir_shader *nir)
       ctx->ngg_gs_scratch_addr = ctx->ngg_gs_emit_addr + ngg_emit_bytes;
 
       unsigned total_lds_bytes = esgs_ring_bytes + ngg_emit_bytes + ngg_gs_scratch_bytes;
+      assert(total_lds_bytes >= ctx->ngg_gs_emit_addr);
+      assert(total_lds_bytes >= ctx->ngg_gs_scratch_addr);
       ctx->program->config->lds_size = (total_lds_bytes + ctx->program->lds_alloc_granule - 1) / ctx->program->lds_alloc_granule;
 
       /* Make sure we have enough room for emitted GS vertices */
@@ -588,6 +590,9 @@ setup_variables(isel_context *ctx, nir_shader *nir)
    default:
       unreachable("Unhandled shader stage.");
    }
+
+   /* Make sure we fit the available LDS space. */
+   assert((ctx->program->config->lds_size * ctx->program->lds_alloc_granule) <= ctx->program->lds_limit);
 }
 
 void