From 9bf8bfe3c8db1a0e10eb0471fa6916f924e06e1c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 12 Feb 2021 08:21:45 -0500 Subject: [PATCH] pan/bi: Fix empty shader handling Fixes INSTR_INVALID_ENC fault on dEQP-GLES31.functional.compute.basic.empty Fixes: bfcdc8f1747 ("pan/bi: Add some zero bytes after shaders on Bifrost") Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 39b8eeacfc5..949aa51b5db 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -2577,11 +2577,15 @@ bifrost_compile_shader_nir(void *mem_ctx, nir_shader *nir, bifrost_debug & BIFROST_DBG_VERBOSE); } - /* Pad the shader with enough zero bytes to trick the prefetcher */ + /* Pad the shader with enough zero bytes to trick the prefetcher, + * unless we're compiling an empty shader (in which case we don't pad + * so the size remains 0) */ unsigned prefetch_size = BIFROST_SHADER_PREFETCH - final_clause; - memset(util_dynarray_grow(&program->compiled, uint8_t, prefetch_size), - 0, prefetch_size); + if (program->compiled.size) { + memset(util_dynarray_grow(&program->compiled, uint8_t, prefetch_size), + 0, prefetch_size); + } program->tls_size = ctx->tls_size;