From bff1f299d14e37c8d7f281c209756de25f10374b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 20 Oct 2022 10:35:14 -0400 Subject: [PATCH] zink: add more zink_descriptor_type enum values to improve readability the values are still the same, but now enum names can be used to more accurately reflect their actual meaning Part-of: --- src/gallium/drivers/zink/zink_descriptors.c | 24 ++++++++++++------------ src/gallium/drivers/zink/zink_screen.c | 4 ++-- src/gallium/drivers/zink/zink_types.h | 16 ++++++++++------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index 4dcd163..de21a9e 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -45,7 +45,7 @@ descriptor_layout_create(struct zink_screen *screen, enum zink_descriptor_type t VkDescriptorSetLayoutBindingFlagsCreateInfo fci = {0}; VkDescriptorBindingFlags flags[ZINK_MAX_DESCRIPTORS_PER_TYPE]; dcslci.pNext = &fci; - if (t == ZINK_DESCRIPTOR_BASE_TYPES) + if (t == ZINK_DESCRIPTOR_TYPE_UNIFORMS) dcslci.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR; fci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO; fci.bindingCount = num_bindings; @@ -128,7 +128,7 @@ descriptor_util_layout_get(struct zink_screen *screen, enum zink_descriptor_type .bindings = bindings, }; - if (type != ZINK_DESCRIPTOR_BASE_TYPES) { + if (type != ZINK_DESCRIPTOR_TYPE_UNIFORMS) { hash = hash_descriptor_layout(&key); simple_mtx_lock(&screen->desc_set_layouts_lock); struct hash_entry *he = _mesa_hash_table_search_pre_hashed(&screen->desc_set_layouts[type], hash, &key); @@ -140,7 +140,7 @@ descriptor_util_layout_get(struct zink_screen *screen, enum zink_descriptor_type } struct zink_descriptor_layout *layout = create_layout(screen, type, bindings, num_bindings, layout_key); - if (layout && type != ZINK_DESCRIPTOR_BASE_TYPES) { + if (layout && type != ZINK_DESCRIPTOR_TYPE_UNIFORMS) { simple_mtx_lock(&screen->desc_set_layouts_lock); _mesa_hash_table_insert_pre_hashed(&screen->desc_set_layouts[type], hash, *layout_key, layout); simple_mtx_unlock(&screen->desc_set_layouts_lock); @@ -182,7 +182,7 @@ descriptor_util_pool_key_get(struct zink_context *ctx, enum zink_descriptor_type uint32_t hash = 0; struct zink_descriptor_pool_key key; key.num_type_sizes = num_type_sizes; - if (type != ZINK_DESCRIPTOR_BASE_TYPES) { + if (type != ZINK_DESCRIPTOR_TYPE_UNIFORMS) { key.layout = layout_key; memcpy(key.sizes, sizes, num_type_sizes * sizeof(VkDescriptorPoolSize)); hash = hash_descriptor_pool_key(&key); @@ -198,7 +198,7 @@ descriptor_util_pool_key_get(struct zink_context *ctx, enum zink_descriptor_type pool_key->num_type_sizes = num_type_sizes; assert(pool_key->num_type_sizes); memcpy(pool_key->sizes, sizes, num_type_sizes * sizeof(VkDescriptorPoolSize)); - if (type != ZINK_DESCRIPTOR_BASE_TYPES) { + if (type != ZINK_DESCRIPTOR_TYPE_UNIFORMS) { simple_mtx_lock(&screen->desc_pool_keys_lock); _mesa_set_add_pre_hashed(&screen->desc_pool_keys[type], hash, pool_key); pool_key->id = screen->desc_pool_keys[type].entries - 1; @@ -220,7 +220,7 @@ init_push_binding(VkDescriptorSetLayoutBinding *binding, unsigned i, VkDescripto static VkDescriptorType get_push_types(struct zink_screen *screen, enum zink_descriptor_type *dsl_type) { - *dsl_type = screen->info.have_KHR_push_descriptor ? ZINK_DESCRIPTOR_BASE_TYPES : ZINK_DESCRIPTOR_TYPE_UBO; + *dsl_type = screen->info.have_KHR_push_descriptor ? ZINK_DESCRIPTOR_TYPE_UNIFORMS : ZINK_DESCRIPTOR_TYPE_UBO; return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; } @@ -505,7 +505,7 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg) if (!pg->dsl[i]) { /* inject a null dsl */ pg->dsl[i] = ctx->dd.dummy_dsl->layout; - if (i != screen->desc_set_id[ZINK_DESCRIPTOR_BASE_TYPES]) + if (i != screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_UNIFORMS]) pg->dd.binding_usage |= BITFIELD_BIT(i); } } @@ -516,14 +516,14 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg) if (!pg->layout) return false; - VkDescriptorUpdateTemplateCreateInfo template[ZINK_DESCRIPTOR_BASE_TYPES + 1] = {0}; + VkDescriptorUpdateTemplateCreateInfo template[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES] = {0}; /* type of template */ - VkDescriptorUpdateTemplateType types[ZINK_DESCRIPTOR_BASE_TYPES + 1] = {VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET}; + VkDescriptorUpdateTemplateType types[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES] = {VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET}; if (have_push) types[0] = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR; /* number of descriptors in template */ - unsigned wd_count[ZINK_DESCRIPTOR_BASE_TYPES + 1]; + unsigned wd_count[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES]; if (push_count) wd_count[0] = pg->is_compute ? 1 : (ZINK_GFX_SHADER_COUNT + !!ctx->dd.has_fbfetch); for (unsigned i = 0; i < ZINK_DESCRIPTOR_BASE_TYPES; i++) @@ -626,7 +626,7 @@ get_descriptor_pool(struct zink_context *ctx, struct zink_program *pg, enum zink static bool set_pool(struct zink_batch_state *bs, struct zink_program *pg, struct zink_descriptor_pool_multi *mpool, enum zink_descriptor_type type) { - assert(type != ZINK_DESCRIPTOR_BASE_TYPES); + assert(type != ZINK_DESCRIPTOR_TYPE_UNIFORMS); assert(mpool); const struct zink_descriptor_pool_key *pool_key = pg->dd.pool_key[type]; size_t size = bs->dd.pools[type].capacity; @@ -880,7 +880,7 @@ zink_descriptors_update(struct zink_context *ctx, bool is_compute) bool batch_changed = !bs->dd.pg[is_compute]; if (batch_changed) { /* update all sets and bind null sets */ - ctx->dd.state_changed[is_compute] = pg->dd.binding_usage & BITFIELD_MASK(ZINK_DESCRIPTOR_BASE_TYPES); + ctx->dd.state_changed[is_compute] = pg->dd.binding_usage & BITFIELD_MASK(ZINK_DESCRIPTOR_TYPE_UNIFORMS); ctx->dd.push_state_changed[is_compute] = !!pg->dd.push_usage; } diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 4249985..cdc4146 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -2435,7 +2435,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config) if ((zink_debug & ZINK_DEBUG_COMPACT) || screen->info.props.limits.maxBoundDescriptorSets < ZINK_MAX_DESCRIPTOR_SETS) { - screen->desc_set_id[ZINK_DESCRIPTOR_BASE_TYPES] = 0; + screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_UNIFORMS] = 0; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_UBO] = 1; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_SSBO] = 1; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW] = 2; @@ -2443,7 +2443,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config) screen->desc_set_id[ZINK_DESCRIPTOR_BINDLESS] = 3; screen->compact_descriptors = true; } else { - screen->desc_set_id[ZINK_DESCRIPTOR_BASE_TYPES] = 0; + screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_UNIFORMS] = 0; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_UBO] = 1; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW] = 2; screen->desc_set_id[ZINK_DESCRIPTOR_TYPE_SSBO] = 3; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index d171001..b52578e 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -131,15 +131,19 @@ enum zink_blit_flags { }; /* descriptor types; also the ordering of the sets - * ...except that ZINK_DESCRIPTOR_BASE_TYPES is actually set 0, which is the uniform data (UBO0) for all stages + * ...except that ZINK_DESCRIPTOR_BASE_TYPES is actually ZINK_DESCRIPTOR_TYPE_UNIFORMS, + * and all base type values are thus +1 to get the set id (using screen->desc_set_id[idx]) */ enum zink_descriptor_type { ZINK_DESCRIPTOR_TYPE_UBO, ZINK_DESCRIPTOR_TYPE_SAMPLER_VIEW, ZINK_DESCRIPTOR_TYPE_SSBO, ZINK_DESCRIPTOR_TYPE_IMAGE, - ZINK_DESCRIPTOR_BASE_TYPES, + ZINK_DESCRIPTOR_BASE_TYPES, /**< the count/iterator for basic descriptor types */ ZINK_DESCRIPTOR_BINDLESS, + ZINK_DESCRIPTOR_ALL_TYPES, + ZINK_DESCRIPTOR_TYPE_UNIFORMS = ZINK_DESCRIPTOR_BASE_TYPES, /**< this is aliased for convenience */ + ZINK_DESCRIPTOR_NON_BINDLESS_TYPES = ZINK_DESCRIPTOR_BASE_TYPES + 1, /**< for struct sizing */ }; enum zink_descriptor_mode { @@ -387,9 +391,9 @@ struct zink_program_descriptor_data { /* all the pool keys for the program */ struct zink_descriptor_pool_key *pool_key[ZINK_DESCRIPTOR_BASE_TYPES]; //push set doesn't need one /* all the layouts for the program */ - struct zink_descriptor_layout *layouts[ZINK_DESCRIPTOR_BASE_TYPES + 1]; + struct zink_descriptor_layout *layouts[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES]; /* all the templates for the program */ - VkDescriptorUpdateTemplate templates[ZINK_DESCRIPTOR_BASE_TYPES + 1]; + VkDescriptorUpdateTemplate templates[ZINK_DESCRIPTOR_NON_BINDLESS_TYPES]; }; struct zink_descriptor_pool { @@ -432,7 +436,7 @@ struct zink_batch_descriptor_data { /* the current set layout */ VkDescriptorSetLayout dsl[2][ZINK_DESCRIPTOR_BASE_TYPES]; //gfx, compute /* the current set for a given type; used for rebinding if pipeline compat id changes and current set must be rebound */ - VkDescriptorSet sets[2][ZINK_DESCRIPTOR_BASE_TYPES + 1]; //gfx, compute + VkDescriptorSet sets[2][ZINK_DESCRIPTOR_NON_BINDLESS_TYPES]; //gfx, compute /* mask of push descriptor usage */ unsigned push_usage[2]; //gfx, compute }; @@ -824,7 +828,7 @@ struct zink_program { uint32_t compat_id; VkPipelineLayout layout; - VkDescriptorSetLayout dsl[ZINK_DESCRIPTOR_BASE_TYPES + 2]; // one for each type + push + bindless + VkDescriptorSetLayout dsl[ZINK_DESCRIPTOR_ALL_TYPES]; // one for each type + push + bindless unsigned num_dsl; bool removed; -- 2.7.4