spirv: Count variables *after* unused ones are removed
Previous code was counting more variables than those used by the entry point. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8456>
This commit is contained in:

committed by
Marge Bot

parent
cc98ba2eaf
commit
e3abbe7a24
@@ -5991,6 +5991,22 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
b->vars_used_indirectly ? &dead_opts : NULL);
|
b->vars_used_indirectly ? &dead_opts : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nir_foreach_variable_in_shader(var, b->shader) {
|
||||||
|
switch (var->data.mode) {
|
||||||
|
case nir_var_mem_ubo:
|
||||||
|
b->shader->info.num_ubos++;
|
||||||
|
break;
|
||||||
|
case nir_var_mem_ssbo:
|
||||||
|
b->shader->info.num_ssbos++;
|
||||||
|
break;
|
||||||
|
case nir_var_mem_push_const:
|
||||||
|
vtn_assert(b->shader->num_uniforms == 0);
|
||||||
|
b->shader->num_uniforms =
|
||||||
|
glsl_get_explicit_size(glsl_without_array(var->type), false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* We sometimes generate bogus derefs that, while never used, give the
|
/* We sometimes generate bogus derefs that, while never used, give the
|
||||||
* validator a bit of heartburn. Run dead code to get rid of them.
|
* validator a bit of heartburn. Run dead code to get rid of them.
|
||||||
*/
|
*/
|
||||||
|
@@ -1767,7 +1767,6 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
|
|||||||
case vtn_variable_mode_ubo:
|
case vtn_variable_mode_ubo:
|
||||||
/* There's no other way to get vtn_variable_mode_ubo */
|
/* There's no other way to get vtn_variable_mode_ubo */
|
||||||
vtn_assert(without_array->block);
|
vtn_assert(without_array->block);
|
||||||
b->shader->info.num_ubos++;
|
|
||||||
break;
|
break;
|
||||||
case vtn_variable_mode_ssbo:
|
case vtn_variable_mode_ssbo:
|
||||||
if (storage_class == SpvStorageClassStorageBuffer &&
|
if (storage_class == SpvStorageClassStorageBuffer &&
|
||||||
@@ -1785,11 +1784,6 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
|
|||||||
"have a struct type with the Block decoration");
|
"have a struct type with the Block decoration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b->shader->info.num_ssbos++;
|
|
||||||
break;
|
|
||||||
case vtn_variable_mode_push_constant:
|
|
||||||
b->shader->num_uniforms =
|
|
||||||
glsl_get_explicit_size(without_array->type, false);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vtn_variable_mode_generic:
|
case vtn_variable_mode_generic:
|
||||||
|
Reference in New Issue
Block a user