zink: delete a lot of descriptor code

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18051>
This commit is contained in:
Mike Blumenkrantz 2022-08-04 08:27:03 -04:00
parent 58e6480ee0
commit 8b0447eec7
9 changed files with 0 additions and 1685 deletions

View file

@ -59,14 +59,6 @@
#define XXH_INLINE_ALL
#include "util/xxhash.h"
static void
calc_descriptor_hash_sampler_state(struct zink_sampler_state *sampler_state)
{
void *hash_data = &sampler_state->sampler;
size_t data_size = sizeof(VkSampler);
sampler_state->hash = XXH32(hash_data, data_size, 0);
}
void
debug_describe_zink_buffer_view(char *buf, const struct zink_buffer_view *ptr)
{
@ -467,8 +459,6 @@ zink_create_sampler_state(struct pipe_context *pctx,
return NULL;
}
}
util_dynarray_init(&sampler->desc_set_refs.refs, NULL);
calc_descriptor_hash_sampler_state(sampler);
sampler->custom_border_color = need_custom;
if (!screen->info.have_EXT_non_seamless_cube_map)
sampler->emulate_nonseamless = !state->seamless_cube_map;
@ -738,7 +728,6 @@ zink_delete_sampler_state(struct pipe_context *pctx,
{
struct zink_sampler_state *sampler = sampler_state;
struct zink_batch *batch = &zink_context(pctx)->batch;
zink_descriptor_set_refs_clear(&sampler->desc_set_refs, sampler_state);
/* may be called if context_create fails */
if (batch->state) {
util_dynarray_append(&batch->state->zombie_samplers, VkSampler,
@ -830,7 +819,6 @@ get_buffer_view(struct zink_context *ctx, struct zink_resource *res, VkBufferVie
}
pipe_reference_init(&buffer_view->reference, 1);
pipe_resource_reference(&buffer_view->pres, &res->base.b);
util_dynarray_init(&buffer_view->desc_set_refs.refs, NULL);
buffer_view->bvci = *bvci;
buffer_view->buffer_view = view;
buffer_view->hash = hash;
@ -1033,7 +1021,6 @@ zink_destroy_buffer_view(struct zink_screen *screen, struct zink_buffer_view *bu
simple_mtx_unlock(&res->bufferview_mtx);
pipe_resource_reference(&buffer_view->pres, NULL);
VKSCR(DestroyBufferView)(screen->dev, buffer_view->buffer_view, NULL);
zink_descriptor_set_refs_clear(&buffer_view->desc_set_refs, buffer_view);
FREE(buffer_view);
}
@ -3886,7 +3873,6 @@ rebind_ibo(struct zink_context *ctx, enum pipe_shader_type shader, unsigned slot
struct zink_resource *res = zink_resource(image_view->base.resource);
if (!res || res->base.b.target != PIPE_BUFFER)
return NULL;
zink_descriptor_set_refs_clear(&image_view->buffer_view->desc_set_refs, image_view->buffer_view);
if (zink_batch_usage_exists(image_view->buffer_view->batch_uses))
zink_batch_reference_bufferview(&ctx->batch, image_view->buffer_view);
VkBufferViewCreateInfo bvci = image_view->buffer_view->bvci;
@ -4397,7 +4383,6 @@ zink_context_replace_buffer_storage(struct pipe_context *pctx, struct pipe_resou
assert(d->obj);
assert(s->obj);
util_idalloc_mt_free(&screen->buffer_ids, delete_buffer_id);
zink_descriptor_set_refs_clear(&d->obj->desc_set_refs, d->obj);
/* add a ref just like check_resource_for_batch_ref() would've */
if (zink_resource_has_binds(d) && zink_resource_has_usage(d))
zink_batch_reference_resource(&ctx->batch, d);

View file

@ -84,8 +84,6 @@ enum zink_blit_flags {
struct zink_sampler_state {
VkSampler sampler;
VkSampler sampler_clamped;
uint32_t hash;
struct zink_descriptor_refs desc_set_refs;
struct zink_batch_usage *batch_uses;
bool custom_border_color;
bool emulate_nonseamless;
@ -98,7 +96,6 @@ struct zink_buffer_view {
VkBufferView buffer_view;
uint32_t hash;
struct zink_batch_usage *batch_uses;
struct zink_descriptor_refs desc_set_refs;
};
struct zink_sampler_view {

File diff suppressed because it is too large Load diff

View file

@ -55,17 +55,6 @@ enum zink_descriptor_type {
#define ZINK_BINDLESS_IS_BUFFER(HANDLE) (HANDLE >= ZINK_MAX_BINDLESS_HANDLES)
struct zink_descriptor_refs {
struct util_dynarray refs;
};
/* hashes of all the named types in a given state */
struct zink_descriptor_state {
bool valid[ZINK_DESCRIPTOR_TYPES];
uint32_t state[ZINK_DESCRIPTOR_TYPES];
};
enum zink_descriptor_size_index {
ZDS_INDEX_UBO,
ZDS_INDEX_COMBINED_SAMPLER,
@ -96,11 +85,6 @@ struct zink_shader;
struct zink_screen;
struct zink_descriptor_state_key {
bool exists[ZINK_SHADER_COUNT];
uint32_t state[ZINK_SHADER_COUNT];
};
struct zink_descriptor_layout_key {
unsigned num_bindings;
VkDescriptorSetLayoutBinding *bindings;
@ -117,18 +101,7 @@ struct zink_descriptor_pool_key {
VkDescriptorPoolSize sizes[4];
};
struct zink_descriptor_reference {
void **ref;
bool *invalid;
};
struct zink_descriptor_data {
struct zink_descriptor_state gfx_descriptor_states[ZINK_SHADER_COUNT]; // keep incremental hashes here
struct zink_descriptor_state descriptor_states[2]; // gfx, compute
struct zink_descriptor_state compact_gfx_descriptor_states[ZINK_SHADER_COUNT]; // keep incremental hashes here
struct zink_descriptor_state compact_descriptor_states[2]; // gfx, compute
struct hash_table *descriptor_pools[ZINK_DESCRIPTOR_TYPES];
struct zink_descriptor_layout_key *push_layout_keys[2]; //gfx, compute
struct zink_descriptor_pool *push_pool[2]; //gfx, compute
struct zink_descriptor_layout *push_dsl[2]; //gfx, compute
@ -251,10 +224,6 @@ zink_descriptor_layouts_init(struct zink_context *ctx);
void
zink_descriptor_layouts_deinit(struct zink_context *ctx);
uint32_t
zink_get_sampler_view_hash(struct zink_context *ctx, struct zink_sampler_view *sampler_view, bool is_buffer);
uint32_t
zink_get_image_view_hash(struct zink_context *ctx, struct zink_image_view *image_view, bool is_buffer);
bool
zink_descriptor_util_alloc_sets(struct zink_screen *screen, VkDescriptorSetLayout dsl, VkDescriptorPool pool, VkDescriptorSet *sets, unsigned num_sets);
struct zink_descriptor_layout *
@ -277,49 +246,11 @@ void
zink_descriptors_deinit_bindless(struct zink_context *ctx);
void
zink_descriptors_update_bindless(struct zink_context *ctx);
/* these two can't be called in lazy mode */
void
zink_descriptor_set_refs_clear(struct zink_descriptor_refs *refs, void *ptr);
void
zink_descriptor_set_recycle(struct zink_descriptor_set *zds);
bool
zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg);
void
zink_descriptor_program_deinit(struct zink_context *ctx, struct zink_program *pg);
void
zink_descriptors_update(struct zink_context *ctx, bool is_compute);
void
zink_context_invalidate_descriptor_state(struct zink_context *ctx, enum pipe_shader_type shader, enum zink_descriptor_type type, unsigned, unsigned);
uint32_t
zink_get_sampler_view_hash(struct zink_context *ctx, struct zink_sampler_view *sampler_view, bool is_buffer);
uint32_t
zink_get_image_view_hash(struct zink_context *ctx, struct zink_image_view *image_view, bool is_buffer);
struct zink_resource *
zink_get_resource_for_descriptor(struct zink_context *ctx, enum zink_descriptor_type type, enum pipe_shader_type shader, int idx);
void
zink_batch_descriptor_deinit(struct zink_screen *screen, struct zink_batch_state *bs);
void
zink_batch_descriptor_reset(struct zink_screen *screen, struct zink_batch_state *bs);
bool
zink_batch_descriptor_init(struct zink_screen *screen, struct zink_batch_state *bs);
bool
zink_descriptors_init(struct zink_context *ctx);
void
zink_descriptors_deinit(struct zink_context *ctx);
//LAZY
bool
zink_descriptor_program_init_lazy(struct zink_context *ctx, struct zink_program *pg);
@ -351,8 +282,6 @@ void
zink_descriptor_set_update_lazy(struct zink_context *ctx, struct zink_program *pg, enum zink_descriptor_type type, VkDescriptorSet set);
void
zink_descriptors_update_lazy_masked(struct zink_context *ctx, bool is_compute, uint8_t changed_sets, uint8_t bind_sets);
VkDescriptorSet
zink_descriptors_alloc_lazy_push(struct zink_context *ctx);
#ifdef __cplusplus
}
#endif

View file

@ -546,25 +546,6 @@ zink_descriptors_update_lazy_masked(struct zink_context *ctx, bool is_compute, u
}
}
/* only called by cached manager for fbfetch handling */
VkDescriptorSet
zink_descriptors_alloc_lazy_push(struct zink_context *ctx)
{
struct zink_batch_state *bs = ctx->batch.state;
struct zink_batch_descriptor_data_lazy *bdd = bdd_lazy(bs);
struct zink_screen *screen = zink_screen(ctx->base.screen);
VkDescriptorSet push_set = VK_NULL_HANDLE;
if (!bdd->push_pool[0]) {
bdd->push_pool[0] = create_push_pool(screen, bdd, false, true);
bdd->has_fbfetch = true;
}
struct zink_descriptor_pool *pool = check_push_pool_alloc(ctx, bdd->push_pool[0], bdd, false);
push_set = get_descriptor_set_lazy(pool);
if (!push_set)
mesa_loge("ZINK: failed to get push descriptor set!");
return push_set;
}
void
zink_descriptors_update_lazy(struct zink_context *ctx, bool is_compute)
{

View file

@ -111,7 +111,6 @@ zink_destroy_resource_object(struct zink_screen *screen, struct zink_resource_ob
#endif
}
zink_descriptor_set_refs_clear(&obj->desc_set_refs, obj);
if (obj->dt) {
FREE(obj->bo); //this is a dummy struct
} else
@ -603,7 +602,6 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
export_types |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
pipe_reference_init(&obj->reference, 1);
util_dynarray_init(&obj->desc_set_refs.refs, NULL);
if (loader_private) {
obj->bo = CALLOC_STRUCT(zink_bo);
obj->transfer_dst = true;
@ -1250,7 +1248,6 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
needs_unref = false;
}
res->obj = new_obj;
zink_descriptor_set_refs_clear(&old_obj->desc_set_refs, old_obj);
for (unsigned i = 0; i <= res->base.b.last_level; i++) {
struct pipe_box box = {0, 0, 0,
u_minify(res->base.b.width0, i),
@ -1580,7 +1577,6 @@ invalidate_buffer(struct zink_context *ctx, struct zink_resource *res)
if (!zink_resource_has_usage(res))
return false;
struct zink_resource_object *old_obj = res->obj;
struct zink_resource_object *new_obj = resource_object_create(screen, &res->base.b, NULL, NULL, NULL, 0, NULL);
if (!new_obj) {
debug_printf("new backing resource alloc failed!");
@ -1590,7 +1586,6 @@ invalidate_buffer(struct zink_context *ctx, struct zink_resource *res)
zink_batch_reference_resource_move(&ctx->batch, res);
res->obj = new_obj;
zink_resource_rebind(ctx, res);
zink_descriptor_set_refs_clear(&old_obj->desc_set_refs, old_obj);
return true;
}

View file

@ -64,7 +64,6 @@ struct zink_resource_object {
bool unordered_write;
unsigned persistent_maps; //if nonzero, requires vkFlushMappedMemoryRanges during batch use
struct zink_descriptor_refs desc_set_refs;
VkBuffer storage_buffer;

View file

@ -173,7 +173,6 @@ create_surface(struct pipe_context *pctx,
surface->base.u.tex.first_layer = templ->u.tex.first_layer;
surface->base.u.tex.last_layer = templ->u.tex.last_layer;
surface->obj = zink_resource(pres)->obj;
util_dynarray_init(&surface->desc_set_refs.refs, NULL);
init_surface_info(surface, res, ivci);
@ -317,7 +316,6 @@ zink_destroy_surface(struct zink_screen *screen, struct pipe_surface *psurface)
_mesa_hash_table_remove(&res->surface_cache, he);
simple_mtx_unlock(&res->surface_mtx);
}
zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
if (surface->simage_view)
VKSCR(DestroyImageView)(screen->dev, surface->simage_view, NULL);
if (surface->is_swapchain) {
@ -359,7 +357,6 @@ zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface)
struct hash_entry *new_entry = _mesa_hash_table_search_pre_hashed(&res->surface_cache, hash, &ivci);
if (zink_batch_usage_exists(surface->batch_uses))
zink_batch_reference_surface(&ctx->batch, surface);
zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
if (new_entry) {
/* reuse existing surface; old one will be cleaned up naturally */
struct zink_surface *new_surface = new_entry->data;

View file

@ -55,7 +55,6 @@ struct zink_surface {
void *obj; //backing resource object
uint32_t hash;
struct zink_batch_usage *batch_uses;
struct zink_descriptor_refs desc_set_refs;
};
/* wrapper object that preserves the gallium expectation of having