Mesa (master): iris: Track bound and writable SSBOs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 22 18:31:44 UTC 2019


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Apr 16 22:54:40 2019 -0700

iris: Track bound and writable SSBOs

Marek recently extended pipe->set_shader_buffers() to take an extra
writable_bitmask parameter, indicating which SSBOs are writable (some
may be bound read-only).  We can use this to decide whether to set
EXEC_OBJECT_WRITE when pinning.  Avoiding the write flag can save us
some cross-batch flushing if the SSBO is used for reading in both the
render and compute engines.

---

 src/gallium/drivers/iris/iris_context.h |  6 ++++++
 src/gallium/drivers/iris/iris_state.c   | 11 ++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index 4465eef40dd..f539ab36196 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -327,6 +327,12 @@ struct iris_shader_state {
 
    /** Bitfield of which sampler views are bound (non-null). */
    uint32_t bound_sampler_views;
+
+   /** Bitfield of which shader storage buffers are bound (non-null). */
+   uint32_t bound_ssbos;
+
+   /** Bitfield of which shader storage buffers are writable. */
+   uint32_t writable_ssbos;
 };
 
 /**
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 12059fbcd3d..3c3861b7827 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -2581,12 +2581,20 @@ iris_set_shader_buffers(struct pipe_context *ctx,
    gl_shader_stage stage = stage_from_pipe(p_stage);
    struct iris_shader_state *shs = &ice->state.shaders[stage];
 
+   unsigned modified_bits = u_bit_consecutive(start_slot, count);
+
+   shs->bound_ssbos &= ~modified_bits;
+   shs->writable_ssbos &= ~modified_bits;
+   shs->writable_ssbos |= writable_bitmask << start_slot;
+
    for (unsigned i = 0; i < count; i++) {
       if (buffers && buffers[i].buffer) {
          const struct pipe_shader_buffer *buffer = &buffers[i];
          struct iris_resource *res = (void *) buffer->buffer;
          pipe_resource_reference(&shs->ssbo[start_slot + i], &res->base);
 
+         shs->bound_ssbos |= 1 << (start_slot + i);
+
          res->bind_history |= PIPE_BIND_SHADER_BUFFER;
 
          // XXX: these are not retained forever, use a separate uploader?
@@ -3926,7 +3934,8 @@ use_ssbo(struct iris_batch *batch, struct iris_context *ice,
 
    struct iris_state_ref *surf_state = &shs->ssbo_surface_state[i];
 
-   iris_use_pinned_bo(batch, iris_resource_bo(shs->ssbo[i]), true);
+   iris_use_pinned_bo(batch, iris_resource_bo(shs->ssbo[i]),
+                      shs->writable_ssbos & (1 << i));
    iris_use_pinned_bo(batch, iris_resource_bo(surf_state->res), false);
 
    return surf_state->offset;




More information about the mesa-commit mailing list