nir: don't count samplers and images in interface blocks

Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5209>
This commit is contained in:
Marek Olšák 2020-05-26 04:36:33 -04:00 committed by Marge Bot
parent c6c8a9bd55
commit f8ef15c061
2 changed files with 13 additions and 4 deletions

View file

@ -600,8 +600,11 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
shader->info.last_msaa_image = -1;
nir_foreach_variable(var, &shader->uniforms) {
/* Bindless textures and images don't use non-bindless slots. */
if (var->data.bindless)
/* Bindless textures and images don't use non-bindless slots.
* Interface blocks imply inputs, outputs, UBO, or SSBO, which can only
* mean bindless.
*/
if (var->data.bindless || var->interface_type)
continue;
shader->info.num_textures += glsl_type_get_sampler_count(var->type);

View file

@ -756,7 +756,10 @@ glsl_type_get_sampler_count(const struct glsl_type *type)
glsl_type_get_sampler_count(glsl_without_array(type)));
}
if (glsl_type_is_struct_or_ifc(type)) {
/* Ignore interface blocks - they can only contain bindless samplers,
* which we shouldn't count.
*/
if (glsl_type_is_struct(type)) {
unsigned count = 0;
for (unsigned i = 0; i < glsl_get_length(type); i++)
count += glsl_type_get_sampler_count(glsl_get_struct_field(type, i));
@ -777,7 +780,10 @@ glsl_type_get_image_count(const struct glsl_type *type)
glsl_type_get_image_count(glsl_without_array(type)));
}
if (glsl_type_is_struct_or_ifc(type)) {
/* Ignore interface blocks - they can only contain bindless images,
* which we shouldn't count.
*/
if (glsl_type_is_struct(type)) {
unsigned count = 0;
for (unsigned i = 0; i < glsl_get_length(type); i++)
count += glsl_type_get_image_count(glsl_get_struct_field(type, i));