pan/bi: Fix shader prefetch size
authorIcecream95 <ixn@disroot.org>
Thu, 28 Jan 2021 08:41:10 +0000 (21:41 +1300)
committerMarge Bot <eric+marge@anholt.net>
Mon, 8 Feb 2021 14:07:29 +0000 (14:07 +0000)
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 <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8354>

src/panfrost/bifrost/bifrost_compile.c

index b300b7d32caf7da20f04db210e32425ccc707d06..26961abc3b8057ca1bb2fdc2f51a4318410da870 100644 (file)
@@ -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;