Mesa (master): radeonsi: clear per-context buffers at the end of si_create_context

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 26 07:16:57 UTC 2020


Module: Mesa
Branch: master
Commit: 0cdec11d9533b9d77dd2433483fbe5b69c28a272
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0cdec11d9533b9d77dd2433483fbe5b69c28a272

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Jun 19 21:40:18 2020 -0400

radeonsi: clear per-context buffers at the end of si_create_context

We don't want any packets before CONTEXT_CONTROL.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5603>

---

 src/gallium/drivers/radeonsi/si_pipe.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 91913c7aceb..4352def038e 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -605,10 +605,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
                                     sscreen->info.tcc_cache_line_size);
       if (!sctx->wait_mem_scratch)
          goto fail;
-
-      /* Initialize the memory. */
-      si_cp_write_data(sctx, sctx->wait_mem_scratch, 0, 4, V_370_MEM, V_370_ME,
-                       &sctx->wait_mem_number);
    }
 
    /* GFX7 cannot unbind a constant buffer (S_BUFFER_LOAD doesn't skip loads
@@ -669,8 +665,16 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
    pipe_buffer_write(&sctx->b, sctx->sample_pos_buffer, 0, sizeof(sctx->sample_positions),
                      &sctx->sample_positions);
 
-   /* this must be last */
+   /* The remainder of this function initializes the gfx CS and must be last. */
+   assert(sctx->gfx_cs->current.cdw == 0);
    si_begin_new_gfx_cs(sctx);
+   assert(sctx->gfx_cs->current.cdw == sctx->initial_gfx_cs_size);
+
+   /* Initialize per-context buffers. */
+   if (sctx->wait_mem_scratch) {
+      si_cp_write_data(sctx, sctx->wait_mem_scratch, 0, 4, V_370_MEM, V_370_ME,
+                       &sctx->wait_mem_number);
+   }
 
    if (sctx->chip_class == GFX7) {
       /* Clear the NULL constant buffer, because loads should return zeros.
@@ -681,6 +685,8 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
       si_clear_buffer(sctx, sctx->null_const_buf.buffer, 0, sctx->null_const_buf.buffer->width0,
                       &clear_value, 4, SI_COHERENCY_SHADER, true);
    }
+
+   sctx->initial_gfx_cs_size = sctx->gfx_cs->current.cdw;
    return &sctx->b;
 fail:
    fprintf(stderr, "radeonsi: Failed to create a context.\n");



More information about the mesa-commit mailing list