From 63d0fbb07b31f916a855af4b7a8cfd779b42f547 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: (cherry picked from commit 9bf8bfe3c8db1a0e10eb0471fa6916f924e06e1c) Conflicts: src/panfrost/bifrost/bifrost_compile.c --- .pick_status.json | 2 +- src/panfrost/bifrost/bifrost_compile.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c23f5aa2cdb..00a96fef97d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3298,7 +3298,7 @@ "description": "pan/bi: Fix empty shader handling", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "bfcdc8f1747eabad57449a309be7160dd27605ac" }, diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index f4ad2950039..d8be3efb954 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -2267,9 +2267,13 @@ 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 */ - memset(util_dynarray_grow(&program->compiled, uint8_t, BIFROST_SHADER_PREFETCH), - 0, BIFROST_SHADER_PREFETCH); + /* 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) */ + if (program->compiled.size) { + memset(util_dynarray_grow(&program->compiled, uint8_t, BIFROST_SHADER_PREFETCH), + 0, BIFROST_SHADER_PREFETCH); + } program->tls_size = ctx->tls_size;