Mesa (main): nir/lower_blend: Support SNORM and integer formats for logic ops

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 11 15:40:22 UTC 2022


Module: Mesa
Branch: main
Commit: 244b654de675fa0ea4732d8b4cade63d8ccb5c86
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=244b654de675fa0ea4732d8b4cade63d8ccb5c86

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Tue May  3 10:55:24 2022 -0500

nir/lower_blend: Support SNORM and integer formats for logic ops

This fixes 158 of the dEQP-VK.pipeline.logic_op.* tests, once we turn
the feature on.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16309>

---

 src/compiler/nir/nir_lower_blend.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_lower_blend.c b/src/compiler/nir/nir_lower_blend.c
index a0e10c3306b..b16f7e21611 100644
--- a/src/compiler/nir/nir_lower_blend.c
+++ b/src/compiler/nir/nir_lower_blend.c
@@ -211,8 +211,10 @@ nir_blend_logicop(
    nir_ssa_def *src, nir_ssa_def *dst)
 {
    unsigned bit_size = src->bit_size;
+
+   enum pipe_format format = options->format[rt];
    const struct util_format_description *format_desc =
-      util_format_description(options->format[rt]);
+      util_format_description(format);
 
    if (bit_size != 32) {
       src = nir_f2f32(b, src);
@@ -226,8 +228,15 @@ nir_blend_logicop(
    for (int i = 0; i < 4; ++i)
        bits[i] = format_desc->channel[i].size;
 
-   src = nir_format_float_to_unorm(b, src, bits);
-   dst = nir_format_float_to_unorm(b, dst, bits);
+   if (util_format_is_unorm(format)) {
+      src = nir_format_float_to_unorm(b, src, bits);
+      dst = nir_format_float_to_unorm(b, dst, bits);
+   } else if (util_format_is_snorm(format)) {
+      src = nir_format_float_to_snorm(b, src, bits);
+      dst = nir_format_float_to_snorm(b, dst, bits);
+   } else {
+      assert(util_format_is_pure_integer(format));
+   }
 
    nir_ssa_def *out = nir_logicop_func(b, options->logicop_func, src, dst);
 
@@ -239,7 +248,13 @@ nir_blend_logicop(
        out = nir_iand(b, out, nir_build_imm(b, 4, 32, mask));
    }
 
-   out = nir_format_unorm_to_float(b, out, bits);
+   if (util_format_is_unorm(format)) {
+      out = nir_format_unorm_to_float(b, out, bits);
+   } else if (util_format_is_snorm(format)) {
+      out = nir_format_snorm_to_float(b, out, bits);
+   } else {
+      assert(util_format_is_pure_integer(format));
+   }
 
    if (bit_size == 16)
       out = nir_f2f16(b, out);



More information about the mesa-commit mailing list