pan/blit: Fix a NULL dereference in the preload path
authorBoris Brezillon <boris.brezillon@collabora.com>
Wed, 19 May 2021 08:56:49 +0000 (10:56 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Tue, 21 Sep 2021 12:59:44 +0000 (14:59 +0200)
The ZS view can be NULL if a stencil-only buffer is attached to the FB.

Fixes: 1de393fec539 ("panfrost: Fix ZS reloading on Bifrost v6")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12095>

src/panfrost/lib/pan_blitter.c

index a17fab7..23ba411 100644 (file)
@@ -1132,7 +1132,9 @@ pan_preload_emit_pre_frame_dcd(struct pan_pool *desc_pool,
 
         pan_preload_emit_dcd(desc_pool, fb, zs, coords, tsd, rsd, dcd, always_write);
         if (zs) {
-                enum pipe_format fmt = fb->zs.view.zs->image->layout.format;
+                enum pipe_format fmt = fb->zs.view.zs ?
+                                       fb->zs.view.zs->image->layout.format :
+                                       fb->zs.view.s->image->layout.format;
                 bool always = false;
 
                 /* If we're dealing with a combined ZS resource and only one