nir_lower_readonly_images: Clear variable data when changing the type

For images, variable data includes the format. For samplers, variable
data is used for OpenCL inline samplers. When converting a variable
from one to the other, zero out the data so we don't accidentally
interpret a converted image as an inline sampler.

Fixes: fa677c86 ("nir_lower_readonly_images_to_tex: Support non-CL semantics")
Acked-by: Enrico Galli <enrico.galli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11674>
This commit is contained in:
Jesse Natalie 2021-06-30 16:36:51 -07:00 committed by Marge Bot
parent 25ad69968b
commit f8f2c3d835
1 changed files with 3 additions and 1 deletions

View File

@ -51,8 +51,10 @@ replace_image_type_with_sampler(nir_deref_instr *deref)
deref->type = get_sampler_type_for_image(type);
if (deref->deref_type == nir_deref_type_var) {
type = deref->var->type;
if (!glsl_type_is_sampler(glsl_without_array(type)))
if (!glsl_type_is_sampler(glsl_without_array(type))) {
deref->var->type = get_sampler_type_for_image(type);
memset(&deref->var->data.sampler, 0, sizeof(deref->var->data.sampler));
}
} else {
nir_deref_instr *parent = nir_deref_instr_parent(deref);
if (parent)