From 6ecce71f71bb4206d2e4c1d5e29c0454032d2f79 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Thu, 28 Jan 2021 21:41:10 +1300 Subject: [PATCH] pan/bi: Fix shader prefetch size The prefetch buffer size is larger than first thought, but includes the final clause, so subtract the size of the final clause from the prefetch size. Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index b300b7d32ca..26961abc3b8 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -48,9 +48,9 @@ static const struct debug_named_value bifrost_debug_options[] = { DEBUG_GET_ONCE_FLAGS_OPTION(bifrost_debug, "BIFROST_MESA_DEBUG", bifrost_debug_options, 0) -/* How many bytes are prefetched by the Bifrost shader core. Past the end of - * the shader, this range must contain valid instructions or zero. */ -#define BIFROST_SHADER_PREFETCH 96 +/* How many bytes are prefetched by the Bifrost shader core. From the final + * clause of the shader, this range must be valid instructions or zero. */ +#define BIFROST_SHADER_PREFETCH 128 /* TODO: This is not thread safe!! */ static unsigned SHADER_DB_COUNT = 0; @@ -2610,7 +2610,7 @@ bifrost_compile_shader_nir(void *mem_ctx, nir_shader *nir, bi_print_shader(ctx, stdout); util_dynarray_init(&program->compiled, NULL); - bi_pack(ctx, &program->compiled); + unsigned final_clause = bi_pack(ctx, &program->compiled); /* If we need to wait for ATEST or BLEND in the first clause, pass the * corresponding bits through to the renderer state descriptor */ @@ -2630,8 +2630,10 @@ bifrost_compile_shader_nir(void *mem_ctx, nir_shader *nir, } /* Pad the shader with enough zero bytes to trick the prefetcher */ - memset(util_dynarray_grow(&program->compiled, uint8_t, BIFROST_SHADER_PREFETCH), - 0, BIFROST_SHADER_PREFETCH); + unsigned prefetch_size = BIFROST_SHADER_PREFETCH - final_clause; + + memset(util_dynarray_grow(&program->compiled, uint8_t, prefetch_size), + 0, prefetch_size); program->tls_size = ctx->tls_size;