pan/mdg: Fix spilling when scratch memory is used
authorIcecream95 <ixn@disroot.org>
Sun, 3 Jan 2021 09:03:57 +0000 (22:03 +1300)
committerMarge Bot <eric+marge@anholt.net>
Mon, 18 Jan 2021 20:49:45 +0000 (20:49 +0000)
Add the tls_size from NIR before spilling so that it doesn't alias
with spill slots.

Fixes: 152bc5d15e1 ("pan/mdg: Support loads and stores to scratch memory")
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8358>

src/panfrost/midgard/midgard_ra.c

index 04be27d..72c06ad 100644 (file)
@@ -1011,7 +1011,7 @@ mir_ra(compiler_context *ctx)
         int iter_count = 1000; /* max iterations */
 
         /* Number of 128-bit slots in memory we've spilled into */
-        unsigned spill_count = 0;
+        unsigned spill_count = DIV_ROUND_UP(ctx->tls_size, 16);
 
 
         mir_create_pipeline_registers(ctx);
@@ -1054,7 +1054,7 @@ mir_ra(compiler_context *ctx)
         /* Report spilling information. spill_count is in 128-bit slots (vec4 x
          * fp32), but tls_size is in bytes, so multiply by 16 */
 
-        ctx->tls_size += spill_count * 16;
+        ctx->tls_size = spill_count * 16;
 
         install_registers(ctx, l);