diff --git a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c index 3e6c6f183e9..c19ad256bd6 100644 --- a/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c +++ b/src/compiler/glsl/gl_nir_lower_samplers_as_deref.c @@ -131,6 +131,13 @@ record_images_used(struct shader_info *info, unsigned mask = ((1ull << MAX2(size, 1)) - 1) << var->data.binding; info->images_used |= mask; + + enum glsl_sampler_dim sampler_dim = + glsl_get_sampler_dim(glsl_without_array(var->type)); + if (sampler_dim == GLSL_SAMPLER_DIM_BUF) + info->image_buffers |= mask; + if (sampler_dim == GLSL_SAMPLER_DIM_MS) + info->msaa_images |= mask; } diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index f0bdd13634d..7f16abda517 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -877,8 +877,6 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) { shader->info.num_textures = 0; shader->info.num_images = 0; - shader->info.image_buffers = 0; - shader->info.msaa_images = 0; shader->info.bit_sizes_float = 0; shader->info.bit_sizes_int = 0; @@ -891,21 +889,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) continue; shader->info.num_textures += glsl_type_get_sampler_count(var->type); - - unsigned num_image_slots = glsl_type_get_image_count(var->type); - if (num_image_slots) { - const struct glsl_type *image_type = glsl_without_array(var->type); - - if (glsl_get_sampler_dim(image_type) == GLSL_SAMPLER_DIM_BUF) { - shader->info.image_buffers |= - BITFIELD_RANGE(shader->info.num_images, num_image_slots); - } - if (glsl_get_sampler_dim(image_type) == GLSL_SAMPLER_DIM_MS) { - shader->info.msaa_images |= - BITFIELD_RANGE(shader->info.num_images, num_image_slots); - } - shader->info.num_images += num_image_slots; - } + shader->info.num_images += glsl_type_get_image_count(var->type); } shader->info.inputs_read = 0; diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index bc187fee66e..a701894985a 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -991,6 +991,8 @@ st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir, BITSET_COPY(prog->info.textures_used, nir->info.textures_used); BITSET_COPY(prog->info.textures_used_by_txf, nir->info.textures_used_by_txf); prog->info.images_used = nir->info.images_used; + prog->info.image_buffers = nir->info.image_buffers; + prog->info.msaa_images = nir->info.msaa_images; } }