radeonsi: check for sampler state CSO corruption

It really happens.

v2: declare "magic" in debug builds only

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
This commit is contained in:
Marek Olšák 2016-12-02 03:34:07 +01:00
parent f2b0c66c3c
commit 6caa558ca6
3 changed files with 17 additions and 0 deletions

View file

@ -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.

View file

@ -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];
};

View file

@ -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);
}