summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-05-11 10:12:39 -0400
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-07-06 20:39:33 -0400
commitd48367fbad5c0296234bab27587b4701ef8418ea (patch)
tree04e8312d81bad2c8a4c19e3abb966d3d825a87ca
parent4a194b7bbfb31ae0531d1e4f2fb20638d6f6dcf6 (diff)
zink: add a per-stage bind mask for ssbos
Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11747>
-rw-r--r--src/gallium/drivers/zink/zink_context.c12
-rw-r--r--src/gallium/drivers/zink/zink_resource.h1
2 files changed, 8 insertions, 5 deletions
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 3aeacb50b4c..0602d3e13bb 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1083,13 +1083,14 @@ zink_set_constant_buffer(struct pipe_context *pctx,
}
ALWAYS_INLINE static void
-unbind_ssbo(struct zink_context *ctx, struct zink_resource *res, bool is_compute, bool writable)
+unbind_ssbo(struct zink_context *ctx, struct zink_resource *res, enum pipe_shader_type pstage, unsigned slot, bool writable)
{
if (!res)
return;
- update_res_bind_count(ctx, res, is_compute, true);
+ res->ssbo_bind_mask[pstage] &= ~BITFIELD_BIT(slot);
+ update_res_bind_count(ctx, res, pstage == PIPE_SHADER_COMPUTE, true);
if (writable)
- res->write_bind_count[is_compute]--;
+ res->write_bind_count[pstage == PIPE_SHADER_COMPUTE]--;
}
static void
@@ -1115,9 +1116,10 @@ zink_set_shader_buffers(struct pipe_context *pctx,
if (buffers && buffers[i].buffer) {
struct zink_resource *new_res = zink_resource(buffers[i].buffer);
if (new_res != res) {
- unbind_ssbo(ctx, res, p_stage == PIPE_SHADER_COMPUTE, was_writable);
+ unbind_ssbo(ctx, res, p_stage, i, was_writable);
new_res->bind_history |= BITFIELD_BIT(ZINK_DESCRIPTOR_TYPE_SSBO);
new_res->bind_stages |= 1 << p_stage;
+ new_res->ssbo_bind_mask[p_stage] |= BITFIELD_BIT(i);
update_res_bind_count(ctx, new_res, p_stage == PIPE_SHADER_COMPUTE, false);
}
VkAccessFlags access = VK_ACCESS_SHADER_READ_BIT;
@@ -1138,7 +1140,7 @@ zink_set_shader_buffers(struct pipe_context *pctx,
} else {
update = !!res;
if (res)
- unbind_ssbo(ctx, res, p_stage == PIPE_SHADER_COMPUTE, was_writable);
+ unbind_ssbo(ctx, res, p_stage, i, was_writable);
pipe_resource_reference(&ssbo->buffer, NULL);
ssbo->buffer_offset = 0;
ssbo->buffer_size = 0;
diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h
index c5724d5e00e..d92258d8164 100644
--- a/src/gallium/drivers/zink/zink_resource.h
+++ b/src/gallium/drivers/zink/zink_resource.h
@@ -107,6 +107,7 @@ struct zink_resource {
uint16_t vbo_bind_count;
uint8_t ubo_bind_count[2];
uint32_t ubo_bind_mask[PIPE_SHADER_TYPES];
+ uint32_t ssbo_bind_mask[PIPE_SHADER_TYPES];
};
struct {
VkFormat format;