freedreno: a2xx: fix crash on first clear
authorJonathan Marek <jonathan@marek.ca>
Thu, 21 Jun 2018 21:06:28 +0000 (17:06 -0400)
committerRob Clark <robdclark@gmail.com>
Fri, 22 Jun 2018 12:23:10 +0000 (08:23 -0400)
blend can be NULL, so check for that

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a2xx/fd2_emit.c

index 4bf41b2c678007e04b38b101bd87ace66841f5dd..dcf7ed10b545220f82fcf2a83f157cd618f56041 100644 (file)
@@ -295,7 +295,7 @@ fd2_emit_state(struct fd_context *ctx, const enum fd_dirty_3d_state dirty)
        if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_ZSA)) {
                OUT_PKT3(ring, CP_SET_CONSTANT, 2);
                OUT_RING(ring, CP_REG(REG_A2XX_RB_COLORCONTROL));
-               OUT_RING(ring, zsa->rb_colorcontrol | blend->rb_colorcontrol);
+               OUT_RING(ring, blend ? zsa->rb_colorcontrol | blend->rb_colorcontrol : 0);
        }
 
        if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_FRAMEBUFFER)) {
@@ -305,13 +305,13 @@ fd2_emit_state(struct fd_context *ctx, const enum fd_dirty_3d_state dirty)
 
                OUT_PKT3(ring, CP_SET_CONSTANT, 2);
                OUT_RING(ring, CP_REG(REG_A2XX_RB_BLEND_CONTROL));
-               OUT_RING(ring, blend->rb_blendcontrol_alpha |
+               OUT_RING(ring, blend ? blend->rb_blendcontrol_alpha |
                        COND(has_alpha, blend->rb_blendcontrol_rgb) |
-                       COND(!has_alpha, blend->rb_blendcontrol_no_alpha_rgb));
+                       COND(!has_alpha, blend->rb_blendcontrol_no_alpha_rgb) : 0);
 
                OUT_PKT3(ring, CP_SET_CONSTANT, 2);
                OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_MASK));
-               OUT_RING(ring, blend->rb_colormask);
+               OUT_RING(ring, blend ? blend->rb_colormask : 0xf);
        }
 
        if (dirty & FD_DIRTY_BLEND_COLOR) {