crocus/blt: add pitch/offset checks to fix blt corruption
authorDave Airlie <airlied@gmail.com>
Wed, 11 Aug 2021 17:32:41 +0000 (13:32 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Aug 2021 19:21:01 +0000 (19:21 +0000)
I lost these in my conversion from i965 but they are necessary.

This should fix corruption in qt fonts at seen in the minecraft
launcher.

Fixes: f3630548f1da ("crocus: initial gallium driver for Intel gfx 4-7")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12329>

src/gallium/drivers/crocus/crocus_blt.c

index fd318a8..fb19465 100644 (file)
@@ -188,6 +188,13 @@ static bool emit_copy_blt(struct crocus_batch *batch,
       }
    }
 
+   /* Blit pitch must be dword-aligned.  Otherwise, the hardware appears to drop
+    * the low bits.  Offsets must be naturally aligned.
+    */
+   if (src_pitch % 4 != 0 || src_offset % cpp != 0 ||
+       dst_pitch % 4 != 0 || dst_offset % cpp != 0)
+     return false;
+
    /* For tiled source and destination, pitch value should be specified
     * as a number of Dwords.
     */