From f8f2c3d8353c271412208d94308df6e6f2e37a10 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Wed, 30 Jun 2021 16:36:51 -0700 Subject: [PATCH] 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 Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir_lower_readonly_images_to_tex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_readonly_images_to_tex.c b/src/compiler/nir/nir_lower_readonly_images_to_tex.c index 8b0b1156596..484f074e301 100644 --- a/src/compiler/nir/nir_lower_readonly_images_to_tex.c +++ b/src/compiler/nir/nir_lower_readonly_images_to_tex.c @@ -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)