summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-04-16 22:54:40 -0700
committerKenneth Graunke <[email protected]>2019-04-22 11:31:14 -0700
commit15660544597e97db7a4ccc8ee109bb0d0f2b86e8 (patch)
treef25c4a8a493f222a15d7bb3206ddac2a33f2a2e7
parente9c5e13344c1e798204028a94546b9565dd01c8e (diff)
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.
-rw-r--r--src/gallium/drivers/iris/iris_context.h6
-rw-r--r--src/gallium/drivers/iris/iris_state.c11
2 files changed, 16 insertions, 1 deletions
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;