radeonsi: fix a crash if a stencil ref state is set before a DSA state
authorMarek Olšák <marek.olsak@amd.com>
Sun, 15 Feb 2015 17:12:06 +0000 (18:12 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 17 Feb 2015 16:41:00 +0000 (17:41 +0100)
+ minor indentation fixes

Discovered by Axel Davy.

This can't be reproduced with any app, because all state trackers set a DSA
state first.

Cc: 10.5 10.4 10.3 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
src/gallium/drivers/radeonsi/si_state.c

index fb353ad..3eea0b6 100644 (file)
@@ -735,12 +735,16 @@ static void si_delete_rs_state(struct pipe_context *ctx, void *state)
  */
 static void si_update_dsa_stencil_ref(struct si_context *sctx)
 {
-       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+       struct si_pm4_state *pm4;
        struct pipe_stencil_ref *ref = &sctx->stencil_ref;
-        struct si_state_dsa *dsa = sctx->queued.named.dsa;
+       struct si_state_dsa *dsa = sctx->queued.named.dsa;
 
-        if (pm4 == NULL)
-                return;
+       if (!dsa)
+               return;
+
+       pm4 = CALLOC_STRUCT(si_pm4_state);
+       if (pm4 == NULL)
+               return;
 
        si_pm4_set_reg(pm4, R_028430_DB_STENCILREFMASK,
                       S_028430_STENCILTESTVAL(ref->ref_value[0]) |