Mesa (main): nir_lower_readonly_images: Clear variable data when changing the type
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 2 04:44:32 UTC 2021
Module: Mesa
Branch: main
Commit: f8f2c3d8353c271412208d94308df6e6f2e37a10
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8f2c3d8353c271412208d94308df6e6f2e37a10
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Wed Jun 30 16:36:51 2021 -0700
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 at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11674>
---
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)
More information about the mesa-commit
mailing list