Mesa (master): nir: Add a 16-bit bool type

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 20 14:38:27 UTC 2019


Module: Mesa
Branch: master
Commit: 0f5640c57741fe1122aa218b678eddaa6ae94601
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f5640c57741fe1122aa218b678eddaa6ae94601

Author: Neil Roberts <nroberts at igalia.com>
Date:   Wed Jan 30 11:02:39 2019 +0100

nir: Add a 16-bit bool type

Adds nir_type_bool16 as well as 16-bit versions of all the bool
opcodes.

Reviewed-by: Rob Clark <robdclark at gmail.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>

---

 src/compiler/nir/nir.h          |  1 +
 src/compiler/nir/nir_opcodes.py | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 9bd1d321e03..e0e2b5a27d2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -889,6 +889,7 @@ typedef enum {
    nir_type_bool =      6,
    nir_type_float =     128,
    nir_type_bool1 =     1  | nir_type_bool,
+   nir_type_bool16 =    16 | nir_type_bool,
    nir_type_bool32 =    32 | nir_type_bool,
    nir_type_int1 =      1  | nir_type_int,
    nir_type_int8 =      8  | nir_type_int,
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index fd8b56063f0..01b5e2bef6c 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -95,6 +95,7 @@ tfloat = "float"
 tint = "int"
 tbool = "bool"
 tbool1 = "bool1"
+tbool16 = "bool16"
 tbool32 = "bool32"
 tuint = "uint"
 tuint16 = "uint16"
@@ -123,7 +124,7 @@ def type_sizes(type_):
     if type_has_size(type_):
         return [type_size(type_)]
     elif type_ == 'bool':
-        return [1, 32]
+        return [1, 16, 32]
     elif type_ == 'float':
         return [16, 32, 64]
     else:
@@ -495,11 +496,15 @@ def binop(name, ty, alg_props, const_expr):
 def binop_compare(name, ty, alg_props, const_expr):
    binop_convert(name, tbool1, ty, alg_props, const_expr)
 
+def binop_compare16(name, ty, alg_props, const_expr):
+   binop_convert(name, tbool16, ty, alg_props, const_expr)
+
 def binop_compare32(name, ty, alg_props, const_expr):
    binop_convert(name, tbool32, ty, alg_props, const_expr)
 
 def binop_compare_all_sizes(name, ty, alg_props, const_expr):
    binop_compare(name, ty, alg_props, const_expr)
+   binop_compare16(name + "16", ty, alg_props, const_expr)
    binop_compare32(name + "32", ty, alg_props, const_expr)
 
 def binop_horiz(name, out_size, out_type, src1_size, src1_type, src2_size,
@@ -533,6 +538,8 @@ def binop_reduce_all_sizes(name, output_size, src_type, prereduce_expr,
                            reduce_expr, final_expr):
    binop_reduce(name, output_size, tbool1, src_type,
                 prereduce_expr, reduce_expr, final_expr)
+   binop_reduce("b16" + name[1:], output_size, tbool16, src_type,
+                prereduce_expr, reduce_expr, final_expr)
    binop_reduce("b32" + name[1:], output_size, tbool32, src_type,
                 prereduce_expr, reduce_expr, final_expr)
 
@@ -928,6 +935,8 @@ triop("umed3", tuint, "", "MAX2(MIN2(MAX2(src0, src1), src2), MIN2(src0, src1))"
 
 opcode("bcsel", 0, tuint, [0, 0, 0],
       [tbool1, tuint, tuint], False, "", "src0 ? src1 : src2")
+opcode("b16csel", 0, tuint, [0, 0, 0],
+       [tbool16, tuint, tuint], False, "", "src0 ? src1 : src2")
 opcode("b32csel", 0, tuint, [0, 0, 0],
        [tbool32, tuint, tuint], False, "", "src0 ? src1 : src2")
 




More information about the mesa-commit mailing list