zink: split out uniform decriptor bindings in shader data
this is both more usable and fixes some descriptor util functionality Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19306>
This commit is contained in:
committed by
Marge Bot
parent
9b420f7704
commit
2b40170d63
@@ -3207,12 +3207,16 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
||||
VkDescriptorType vktype = !var->data.driver_location ? VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC : VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
int binding = var->data.binding;
|
||||
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].index = var->data.driver_location;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].binding = binding;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].type = vktype;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].size = glsl_get_length(var->type);
|
||||
assert(ret->bindings[ztype][ret->num_bindings[ztype]].size);
|
||||
ret->num_bindings[ztype]++;
|
||||
if (!var->data.driver_location) {
|
||||
ret->has_uniforms = true;
|
||||
} else {
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].index = var->data.driver_location;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].binding = binding;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].type = vktype;
|
||||
ret->bindings[ztype][ret->num_bindings[ztype]].size = glsl_get_length(var->type);
|
||||
assert(ret->bindings[ztype][ret->num_bindings[ztype]].size);
|
||||
ret->num_bindings[ztype]++;
|
||||
}
|
||||
} else if (var->data.mode == nir_var_mem_ssbo) {
|
||||
ztype = ZINK_DESCRIPTOR_TYPE_SSBO;
|
||||
var->data.descriptor_set = screen->desc_set_id[ztype];
|
||||
|
||||
@@ -425,17 +425,14 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
|
||||
|
||||
gl_shader_stage stage = shader->nir->info.stage;
|
||||
VkShaderStageFlagBits stage_flags = mesa_to_vk_shader_stage(stage);
|
||||
/* uniform ubos handled in push */
|
||||
if (shader->has_uniforms) {
|
||||
pg->dd.push_usage |= BITFIELD64_BIT(stage);
|
||||
push_count++;
|
||||
}
|
||||
for (int j = 0; j < ZINK_DESCRIPTOR_BASE_TYPES; j++) {
|
||||
unsigned desc_type = screen->desc_set_id[j] - 1;
|
||||
for (int k = 0; k < shader->num_bindings[j]; k++) {
|
||||
/* dynamic ubos handled in push */
|
||||
if (shader->bindings[j][k].type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
|
||||
pg->dd.push_usage |= BITFIELD64_BIT(stage);
|
||||
|
||||
push_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(num_bindings[desc_type] < ARRAY_SIZE(bindings[desc_type]));
|
||||
VkDescriptorSetLayoutBinding *binding = &bindings[desc_type][num_bindings[desc_type]];
|
||||
binding->binding = shader->bindings[j][k].binding;
|
||||
|
||||
@@ -1103,6 +1103,8 @@ static unsigned
|
||||
get_num_bindings(struct zink_shader *zs, enum zink_descriptor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case ZINK_DESCRIPTOR_TYPE_UNIFORMS:
|
||||
return !!zs->has_uniforms;
|
||||
case ZINK_DESCRIPTOR_TYPE_UBO:
|
||||
case ZINK_DESCRIPTOR_TYPE_SSBO:
|
||||
return zs->num_bindings[type];
|
||||
|
||||
@@ -676,6 +676,7 @@ struct zink_shader {
|
||||
uint32_t ssbos_used; // bitfield of which ssbo indices are used
|
||||
bool bindless;
|
||||
bool can_inline;
|
||||
bool has_uniforms;
|
||||
struct spirv_shader *spirv;
|
||||
|
||||
simple_mtx_t lock;
|
||||
|
||||
Reference in New Issue
Block a user