panfrost: Fix blend_cso if nr_cbufs == 0
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 14:08:15 +0000 (07:08 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 15:03:35 +0000 (08:03 -0700)
Fixes: 46396af1ec4b69ca4a ("panfrost: Refactor blend infrastructure")
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_blend_cso.c

index fa5f954c3a867509d4ecf12a0b1bbd83500fff78..cf26d7366eeb9534e258645cd943adcc31e7cafa 100644 (file)
@@ -206,10 +206,13 @@ panfrost_blend_constant(float *out, float *in, unsigned mask)
 struct panfrost_blend_final
 panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
 {
-        /* Grab the format */
+        /* Grab the format, falling back gracefully if called invalidly (which
+         * has to happen for no-color-attachment FBOs, for instance)  */
         struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer;
-        assert(fb->nr_cbufs > rti);
-        enum pipe_format fmt = fb->cbufs[rti]->format;
+        enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
+
+        if (fb->nr_cbufs > rti)
+                fmt = fb->cbufs[rti]->format;
 
         /* Grab the blend state */
         struct panfrost_blend_state *blend = ctx->blend;