r600g: properly unbind a DSA state being deleted in r600_delete_dsa_state
authorMarek Olšák <marek.olsak@amd.com>
Sun, 3 Nov 2013 19:27:28 +0000 (20:27 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 4 Nov 2013 18:07:57 +0000 (19:07 +0100)
Tested-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c

index 6aa944c54a0e4d2063746520200ee30d4e9a3ae0..d7af618064164fb645f6ef8b26506753827acab8 100644 (file)
@@ -538,7 +538,7 @@ static INLINE void r600_set_cso_state_with_cb(struct r600_cso_state *state, void
                                              struct r600_command_buffer *cb)
 {
        state->cb = cb;
-       state->atom.num_dw = cb->num_dw;
+       state->atom.num_dw = cb ? cb->num_dw : 0;
        r600_set_cso_state(state, cso);
 }
 
index 8f164bf18918f6807f9acf7dc8fdbb91d922a3ea..7d3c5bc20a782f4aeeeb690624a3a560b1aaa751 100644 (file)
@@ -269,8 +269,10 @@ static void r600_bind_dsa_state(struct pipe_context *ctx, void *state)
        struct r600_dsa_state *dsa = state;
        struct r600_stencil_ref ref;
 
-       if (state == NULL)
+       if (state == NULL) {
+               r600_set_cso_state_with_cb(&rctx->dsa_state, NULL, NULL);
                return;
+       }
 
        r600_set_cso_state_with_cb(&rctx->dsa_state, dsa, &dsa->buffer);
 
@@ -458,8 +460,13 @@ static void r600_delete_blend_state(struct pipe_context *ctx, void *state)
 
 static void r600_delete_dsa_state(struct pipe_context *ctx, void *state)
 {
+       struct r600_context *rctx = (struct r600_context *)ctx;
        struct r600_dsa_state *dsa = (struct r600_dsa_state *)state;
 
+       if (rctx->dsa_state.cso == state) {
+               ctx->bind_depth_stencil_alpha_state(ctx, NULL);
+       }
+
        r600_release_command_buffer(&dsa->buffer);
        free(dsa);
 }