diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index ced4badca32..125dbe8f062 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1385,7 +1385,7 @@ zink_set_inlinable_constants(struct pipe_context *pctx, ALWAYS_INLINE static void unbind_descriptor_stage(struct zink_resource *res, gl_shader_stage pstage) { - if (!res->sampler_binds[pstage] && !res->image_binds[pstage]) + if (!res->sampler_binds[pstage] && !res->image_binds[pstage] && !res->all_bindless) res->gfx_barrier &= ~zink_pipeline_flags_from_pipe_stage(pstage); } @@ -1506,14 +1506,14 @@ zink_set_constant_buffer(struct pipe_context *pctx, ALWAYS_INLINE static void unbind_descriptor_reads(struct zink_resource *res, bool is_compute) { - if (!res->sampler_bind_count[is_compute] && !res->image_bind_count[is_compute]) + if (!res->sampler_bind_count[is_compute] && !res->image_bind_count[is_compute] && !res->all_bindless) res->barrier_access[is_compute] &= ~VK_ACCESS_SHADER_READ_BIT; } ALWAYS_INLINE static void unbind_buffer_descriptor_reads(struct zink_resource *res, bool is_compute) { - if (!res->ssbo_bind_count[is_compute]) + if (!res->ssbo_bind_count[is_compute] && !res->all_bindless) unbind_descriptor_reads(res, is_compute); } @@ -2172,6 +2172,33 @@ zero_bindless_descriptor(struct zink_context *ctx, uint32_t handle, bool is_buff } } +static void +unbind_bindless_descriptor(struct zink_context *ctx, struct zink_resource *res) +{ + if (!res->bindless[1]) { + /* check to remove write access */ + for (unsigned i = 0; i < 2; i++) { + if (!res->write_bind_count[i]) + res->barrier_access[i] &= ~VK_ACCESS_SHADER_WRITE_BIT; + } + } + bool is_buffer = res->base.b.target == PIPE_BUFFER; + if (!res->all_bindless) { + /* check to remove read access */ + if (is_buffer) { + for (unsigned i = 0; i < 2; i++) + unbind_buffer_descriptor_reads(res, i); + } else { + for (unsigned i = 0; i < 2; i++) + unbind_descriptor_reads(res, i); + } + } + for (unsigned i = 0; i < 2; i++) { + if (!res->image_bind_count[i]) + check_for_layout_update(ctx, res, i); + } +} + static void zink_make_texture_handle_resident(struct pipe_context *pctx, uint64_t handle, bool resident) { @@ -2212,6 +2239,9 @@ zink_make_texture_handle_resident(struct pipe_context *pctx, uint64_t handle, bo zink_batch_resource_usage_set(&ctx->batch, res, false, false); res->obj->unordered_write = false; } + res->gfx_barrier |= VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + res->barrier_access[0] |= VK_ACCESS_SHADER_READ_BIT; + res->barrier_access[1] |= VK_ACCESS_SHADER_READ_BIT; util_dynarray_append(&ctx->di.bindless[0].resident, struct zink_bindless_descriptor *, bd); uint32_t h = is_buffer ? handle + ZINK_MAX_BINDLESS_HANDLES : handle; util_dynarray_append(&ctx->di.bindless[0].updates, uint32_t, h); @@ -2222,10 +2252,7 @@ zink_make_texture_handle_resident(struct pipe_context *pctx, uint64_t handle, bo update_res_bind_count(ctx, res, false, true); update_res_bind_count(ctx, res, true, true); res->bindless[0]--; - for (unsigned i = 0; i < 2; i++) { - if (!res->image_bind_count[i]) - check_for_layout_update(ctx, res, i); - } + unbind_bindless_descriptor(ctx, res); } ctx->di.bindless_dirty[0] = true; } @@ -2345,6 +2372,9 @@ zink_make_image_handle_resident(struct pipe_context *pctx, uint64_t handle, unsi zink_batch_resource_usage_set(&ctx->batch, res, zink_resource_access_is_write(access), false); res->obj->unordered_write = false; } + res->gfx_barrier |= VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + res->barrier_access[0] |= access; + res->barrier_access[1] |= access; util_dynarray_append(&ctx->di.bindless[1].resident, struct zink_bindless_descriptor *, bd); uint32_t h = is_buffer ? handle + ZINK_MAX_BINDLESS_HANDLES : handle; util_dynarray_append(&ctx->di.bindless[1].updates, uint32_t, h); @@ -2358,10 +2388,7 @@ zink_make_image_handle_resident(struct pipe_context *pctx, uint64_t handle, unsi unbind_shader_image_counts(ctx, res, false, false); unbind_shader_image_counts(ctx, res, true, false); res->bindless[1]--; - for (unsigned i = 0; i < 2; i++) { - if (!res->image_bind_count[i]) - check_for_layout_update(ctx, res, i); - } + unbind_bindless_descriptor(ctx, res); } ctx->di.bindless_dirty[1] = true; } diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index bb31859bf4b..de2629878bb 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1208,7 +1208,10 @@ struct zink_resource { uint16_t sampler_bind_count[2]; //gfx, compute uint16_t image_bind_count[2]; //gfx, compute uint16_t write_bind_count[2]; //gfx, compute - uint16_t bindless[2]; //tex, img + union { + uint16_t bindless[2]; //tex, img + uint32_t all_bindless; + }; union { uint16_t bind_count[2]; //gfx, compute uint32_t all_binds;