<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-12-02 21:39 GMT+01:00 Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
It really happens.<br>
---<br>
 src/gallium/drivers/radeonsi/<wbr>si_descriptors.c | 1 +<br>
 src/gallium/drivers/radeonsi/<wbr>si_pipe.h        | 3 +++<br>
 src/gallium/drivers/radeonsi/<wbr>si_state.c       | 5 +++++<br>
 3 files changed, 9 insertions(+)<br>
<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_descriptors.c b/src/gallium/drivers/<wbr>radeonsi/si_descriptors.c<br>
index 8b6e0bb..4f78b1a 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_descriptors.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_descriptors.c<br>
@@ -796,20 +796,21 @@ static void si_bind_sampler_states(struct pipe_context *ctx,<br>
        if (!count || shader >= SI_NUM_SHADERS)<br>
                return;<br>
<br>
        for (i = 0; i < count; i++) {<br>
                unsigned slot = start + i;<br>
<br>
                if (!sstates[i] ||<br>
                    sstates[i] == samplers->views.sampler_<wbr>states[slot])<br>
                        continue;<br>
<br>
+               assert(sstates[i]->magic == SI_SAMPLER_STATE_MAGIC);<br>
                samplers->views.sampler_<wbr>states[slot] = sstates[i];<br>
<br>
                /* If FMASK is bound, don't overwrite it.<br>
                 * The sampler state will be set after FMASK is unbound.<br>
                 */<br>
                if (samplers->views.views[slot] &&<br>
                    samplers->views.views[slot]-><wbr>texture &&<br>
                    samplers->views.views[slot]-><wbr>texture->target != PIPE_BUFFER &&<br>
                    ((struct r600_texture*)samplers->views.<wbr>views[slot]->texture)->fmask.<wbr>size)<br>
                        continue;<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
index 42cbecb..a7985e7 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_pipe.h<br>
@@ -130,21 +130,24 @@ struct si_sampler_view {<br>
         /* [0..7] = image descriptor<br>
          * [4..7] = buffer descriptor */<br>
        uint32_t                        state[8];<br>
        uint32_t                        fmask_state[8];<br>
        const struct radeon_surf_level  *base_level_info;<br>
        unsigned                        base_level;<br>
        unsigned                        block_width;<br>
        bool is_stencil_sampler;<br>
 };<br>
<br>
+#define SI_SAMPLER_STATE_MAGIC 0x34f1c35a<br>
+<br>
 struct si_sampler_state {<br>
+       unsigned                        magic;<br></blockquote><div><br></div><div>How about wrapping it in #ifndef NDEBUG/#endif? Here and the other places.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        uint32_t                        val[4];<br>
 };<br>
<br>
 struct si_cs_shader_state {<br>
        struct si_compute               *program;<br>
        struct si_compute               *emitted_program;<br>
        unsigned                        offset;<br>
        bool                            initialized;<br>
        bool                            uses_scratch;<br>
 };<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_state.c b/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
index 1ccf5b6..7ff9f8c 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_state.c<br>
@@ -3240,20 +3240,21 @@ static void *si_create_sampler_state(<wbr>struct pipe_context *ctx,<br>
                                util_memcpy_cpu_to_le32(&sctx-<wbr>>border_color_map[i],<br>
                                                        &state->border_color,<br>
                                                        sizeof(state->border_color));<br>
                                sctx->border_color_count++;<br>
                        }<br>
<br>
                        border_color_index = i;<br>
                }<br>
        }<br>
<br>
+       rstate->magic = SI_SAMPLER_STATE_MAGIC;<br>
        rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(<wbr>state->wrap_s)) |<br>
                          S_008F30_CLAMP_Y(si_tex_wrap(<wbr>state->wrap_t)) |<br>
                          S_008F30_CLAMP_Z(si_tex_wrap(<wbr>state->wrap_r)) |<br>
                          S_008F30_MAX_ANISO_RATIO(max_<wbr>aniso_ratio) |<br>
                          S_008F30_DEPTH_COMPARE_FUNC(<wbr>si_tex_compare(state->compare_<wbr>func)) |<br>
                          S_008F30_FORCE_UNNORMALIZED(!<wbr>state->normalized_coords) |<br>
                          S_008F30_ANISO_THRESHOLD(max_<wbr>aniso_ratio >> 1) |<br>
                          S_008F30_ANISO_BIAS(max_aniso_<wbr>ratio) |<br>
                          S_008F30_DISABLE_CUBE_WRAP(!<wbr>state->seamless_cube_map) |<br>
                          S_008F30_COMPAT_MODE(sctx->b.<wbr>chip_class >= VI));<br>
@@ -3296,20 +3297,24 @@ static void si_emit_sample_mask(struct si_context *sctx, struct r600_atom *atom)<br>
        assert(mask == 0xffff || sctx->framebuffer.nr_samples > 1 ||<br>
               (mask & 1 && sctx->blitter->running));<br>
<br>
        radeon_set_context_reg_seq(cs, R_028C38_PA_SC_AA_MASK_X0Y0_<wbr>X1Y0, 2);<br>
        radeon_emit(cs, mask | (mask << 16));<br>
        radeon_emit(cs, mask | (mask << 16));<br>
 }<br>
<br>
 static void si_delete_sampler_state(struct pipe_context *ctx, void *state)<br>
 {<br>
+       struct si_sampler_state *s = state;<br>
+<br>
+       assert(s->magic == SI_SAMPLER_STATE_MAGIC);<br>
+       s->magic = 0;<br>
        free(state);<br>
 }<br>
<br>
 /*<br>
  * Vertex elements & buffers<br>
  */<br>
<br>
 static void *si_create_vertex_elements(<wbr>struct pipe_context *ctx,<br>
                                       unsigned count,<br>
                                       const struct pipe_vertex_element *elements)<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>