Module: Mesa
Branch: main
Commit: 7682a5de0449658f17bdcf4e591df523208528df
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7682a5de0449658f17bdcf4e591df523208528df

Author: Italo Nicola <[email protected]>
Date:   Mon Sep 20 07:18:56 2021 +0000

panfrost: fix null deref when no color buffer is attached

Do not dereference color buffer #0 in the SFBD code path if no color buffer is
attached, as with depth-only attachments. Fixes a crash running glmark2 -b
shadow on Mali T720.

Signed-off-by: Italo Nicola <[email protected]>
Fixes: c746747cb82 ("panfrost: fix GL_EXT_multisampled_render_to_texture 
regression")
Reviewed-by: Boris Brezillon <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12927>

---

 src/panfrost/lib/pan_cs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/lib/pan_cs.c b/src/panfrost/lib/pan_cs.c
index 5eb37a25099..33461361412 100644
--- a/src/panfrost/lib/pan_cs.c
+++ b/src/panfrost/lib/pan_cs.c
@@ -793,8 +793,8 @@ pan_emit_sfbd(const struct panfrost_device *dev,
 
                 cfg.sample_count = fb->nr_samples;
 
-                /* XXX: different behaviour from MFBD and probably wrong... */
-                cfg.msaa = mali_sampling_mode(fb->rts[0].view);
+                if (fb->rt_count)
+                        cfg.msaa = mali_sampling_mode(fb->rts[0].view);
         }
         pan_emit_sfbd_tiler(dev, fb, tiler_ctx, fbd);
         pan_section_pack(fbd, SINGLE_TARGET_FRAMEBUFFER, PADDING_2, padding);

Reply via email to