Mesa (main): nir/deref: Also optimize samplerND -> textureND casts
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Oct 16 06:15:09 UTC 2021
Module: Mesa
Branch: main
Commit: b8a0bf2343da8bbc3fc1a2afd3c493c6d2362089
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8a0bf2343da8bbc3fc1a2afd3c493c6d2362089
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Fri Oct 15 14:53:19 2021 -0500
nir/deref: Also optimize samplerND -> textureND casts
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13389>
---
src/compiler/nir/nir_deref.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c
index 1d559a7f117..39d7b71ca41 100644
--- a/src/compiler/nir/nir_deref.c
+++ b/src/compiler/nir/nir_deref.c
@@ -1012,14 +1012,17 @@ opt_remove_sampler_cast(nir_deref_instr *cast)
cast_type = glsl_get_array_element(cast_type);
}
- if (glsl_type_is_array(parent_type) || glsl_type_is_array(cast_type))
+ if (!glsl_type_is_sampler(parent_type))
return false;
- if (!glsl_type_is_sampler(parent_type) ||
- cast_type != glsl_bare_sampler_type())
+ if (cast_type != glsl_bare_sampler_type() &&
+ (glsl_type_is_bare_sampler(parent_type) ||
+ cast_type != glsl_sampler_type_to_texture(parent_type)))
return false;
- /* We're a cast from a more detailed sampler type to a bare sampler */
+ /* We're a cast from a more detailed sampler type to a bare sampler or a
+ * texture type with the same dimensionality.
+ */
nir_ssa_def_rewrite_uses(&cast->dest.ssa,
&parent->dest.ssa);
nir_instr_remove(&cast->instr);
More information about the mesa-commit
mailing list