[Mesa-dev] [PATCH 05/10] radeonsi: check for sampler state CSO corruption

Marek Olšák maraeo at gmail.com
Wed Dec 7 20:28:40 UTC 2016


On Fri, Dec 2, 2016 at 9:52 PM, Gustaw Smolarczyk <wielkiegie at gmail.com> wrote:
> 2016-12-02 21:39 GMT+01:00 Marek Olšák <maraeo at gmail.com>:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> It really happens.
>> ---
>>  src/gallium/drivers/radeonsi/si_descriptors.c | 1 +
>>  src/gallium/drivers/radeonsi/si_pipe.h        | 3 +++
>>  src/gallium/drivers/radeonsi/si_state.c       | 5 +++++
>>  3 files changed, 9 insertions(+)
>>
>> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c
>> b/src/gallium/drivers/radeonsi/si_descriptors.c
>> index 8b6e0bb..4f78b1a 100644
>> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
>> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
>> @@ -796,20 +796,21 @@ static void si_bind_sampler_states(struct
>> pipe_context *ctx,
>>         if (!count || shader >= SI_NUM_SHADERS)
>>                 return;
>>
>>         for (i = 0; i < count; i++) {
>>                 unsigned slot = start + i;
>>
>>                 if (!sstates[i] ||
>>                     sstates[i] == samplers->views.sampler_states[slot])
>>                         continue;
>>
>> +               assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC);
>>                 samplers->views.sampler_states[slot] = sstates[i];
>>
>>                 /* If FMASK is bound, don't overwrite it.
>>                  * The sampler state will be set after FMASK is unbound.
>>                  */
>>                 if (samplers->views.views[slot] &&
>>                     samplers->views.views[slot]->texture &&
>>                     samplers->views.views[slot]->texture->target !=
>> PIPE_BUFFER &&
>>                     ((struct
>> r600_texture*)samplers->views.views[slot]->texture)->fmask.size)
>>                         continue;
>> diff --git a/src/gallium/drivers/radeonsi/si_pipe.h
>> b/src/gallium/drivers/radeonsi/si_pipe.h
>> index 42cbecb..a7985e7 100644
>> --- a/src/gallium/drivers/radeonsi/si_pipe.h
>> +++ b/src/gallium/drivers/radeonsi/si_pipe.h
>> @@ -130,21 +130,24 @@ struct si_sampler_view {
>>          /* [0..7] = image descriptor
>>           * [4..7] = buffer descriptor */
>>         uint32_t                        state[8];
>>         uint32_t                        fmask_state[8];
>>         const struct radeon_surf_level  *base_level_info;
>>         unsigned                        base_level;
>>         unsigned                        block_width;
>>         bool is_stencil_sampler;
>>  };
>>
>> +#define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
>> +
>>  struct si_sampler_state {
>> +       unsigned                        magic;
>
>
> How about wrapping it in #ifndef NDEBUG/#endif? Here and the other places.

Yes, I'll add that.

Marek


More information about the mesa-dev mailing list