From 6caa558ca677941f9a2f0570563b51fbe88cd1b9 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 2 Dec 2016 03:34:07 +0100 Subject: radeonsi: check for sampler state CSO corruption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It really happens. v2: declare "magic" in debug builds only Reviewed-by: Nicolai Hähnle (v1) --- src/gallium/drivers/radeonsi/si_descriptors.c | 3 +++ src/gallium/drivers/radeonsi/si_pipe.h | 5 +++++ src/gallium/drivers/radeonsi/si_state.c | 9 +++++++++ 3 files changed, 17 insertions(+) (limited to 'src/gallium/drivers/radeonsi') diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 8b6e0bbb3a7..7ffd7fa609d 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -803,6 +803,9 @@ static void si_bind_sampler_states(struct pipe_context *ctx, sstates[i] == samplers->views.sampler_states[slot]) continue; +#ifdef DEBUG + assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC); +#endif samplers->views.sampler_states[slot] = sstates[i]; /* If FMASK is bound, don't overwrite it. diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 42cbecbf13e..31b7985fef9 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -137,7 +137,12 @@ struct si_sampler_view { bool is_stencil_sampler; }; +#define SI_SAMPLER_STATE_MAGIC 0x34f1c35a + struct si_sampler_state { +#ifdef DEBUG + unsigned magic; +#endif uint32_t val[4]; }; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 1ccf5b6b214..04c1a9f4c66 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -3247,6 +3247,9 @@ static void *si_create_sampler_state(struct pipe_context *ctx, } } +#ifdef DEBUG + rstate->magic = SI_SAMPLER_STATE_MAGIC; +#endif rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) | S_008F30_CLAMP_Y(si_tex_wrap(state->wrap_t)) | S_008F30_CLAMP_Z(si_tex_wrap(state->wrap_r)) | @@ -3303,6 +3306,12 @@ static void si_emit_sample_mask(struct si_context *sctx, struct r600_atom *atom) static void si_delete_sampler_state(struct pipe_context *ctx, void *state) { + struct si_sampler_state *s = state; + +#ifdef DEBUG + assert(s->magic == SI_SAMPLER_STATE_MAGIC); + s->magic = 0; +#endif free(state); } -- cgit v1.2.3