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.
This commit is contained in:
Kenneth Graunke
2019-04-16 22:54:40 -07:00
parent e9c5e13344
commit 1566054459
2 changed files with 16 additions and 1 deletions
+6
View File
@@ -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;
};
/**
+10 -1
View File
@@ -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;