From 73449f9a6237fb54d339db08a9912c26cdbb8e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Thu, 15 Oct 2020 18:18:21 +0200 Subject: [PATCH] aco: Add a few assertions about LDS usage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_instruction_selection_setup.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index a59af50e9b8..f218d278fe2 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -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