nir/lower_readonly_images_to_tex: Also rewrite variable modes

Storage images will start using nir_var_mem_image but sampled images
still use nir_var_uniform.  If we're going to rewrite types, we need to
rewrite the modes as well.  Otherwise, nir_validate will get grumpy and
drivers might get confused.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4743>
This commit is contained in:
Jason Ekstrand 2021-09-27 17:08:20 -05:00 committed by Marge Bot
parent 225caf537a
commit 6818811fc4
1 changed files with 2 additions and 0 deletions

View File

@ -49,10 +49,12 @@ replace_image_type_with_sampler(nir_deref_instr *deref)
return;
deref->type = get_sampler_type_for_image(type);
deref->modes = nir_var_uniform;
if (deref->deref_type == nir_deref_type_var) {
type = deref->var->type;
if (!glsl_type_is_sampler(glsl_without_array(type))) {
deref->var->type = get_sampler_type_for_image(type);
deref->var->data.mode = nir_var_uniform;
memset(&deref->var->data.sampler, 0, sizeof(deref->var->data.sampler));
}
} else {