<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 6:06 PM Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10/22/2018 03:13 PM, Jason Ekstrand wrote:<br>
> ---<br>
> src/compiler/nir/nir_lower_alu_to_scalar.c | 8 ++--<br>
> src/compiler/nir/nir_opcodes.py | 46 +++++++++++-----------<br>
> src/compiler/nir/nir_opcodes_c.py | 8 ++--<br>
> 3 files changed, 31 insertions(+), 31 deletions(-)<br>
> <br>
> diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c b/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
> index 0be3aba9456..e424dff25c4 100644<br>
> --- a/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
> +++ b/src/compiler/nir/nir_lower_alu_to_scalar.c<br>
> @@ -197,10 +197,10 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b)<br>
> return false;<br>
> <br>
> LOWER_REDUCTION(nir_op_fdot, nir_op_fmul, nir_op_fadd);<br>
> - LOWER_REDUCTION(nir_op_ball_fequal, nir_op_feq, nir_op_iand);<br>
> - LOWER_REDUCTION(nir_op_ball_iequal, nir_op_ieq, nir_op_iand);<br>
> - LOWER_REDUCTION(nir_op_bany_fnequal, nir_op_fne, nir_op_ior);<br>
> - LOWER_REDUCTION(nir_op_bany_inequal, nir_op_ine, nir_op_ior);<br>
> + LOWER_REDUCTION(nir_op_b32all_fequal, nir_op_feq32, nir_op_iand);<br>
> + LOWER_REDUCTION(nir_op_b32all_iequal, nir_op_ieq32, nir_op_iand);<br>
> + LOWER_REDUCTION(nir_op_b32any_fnequal, nir_op_fne32, nir_op_ior);<br>
> + LOWER_REDUCTION(nir_op_b32any_inequal, nir_op_ine32, nir_op_ior);<br>
> LOWER_REDUCTION(nir_op_fall_equal, nir_op_seq, nir_op_fand);<br>
> LOWER_REDUCTION(nir_op_fany_nequal, nir_op_sne, nir_op_for);<br>
> <br>
> diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py<br>
> index 4ef4ecc6f22..d349f74ed2a 100644<br>
> --- a/src/compiler/nir/nir_opcodes.py<br>
> +++ b/src/compiler/nir/nir_opcodes.py<br>
> @@ -89,7 +89,7 @@ class Opcode(object):<br>
> # helper variables for strings<br>
> tfloat = "float"<br>
> tint = "int"<br>
> -tbool = "bool32"<br>
> +tbool32 = "bool32"<br>
> tuint = "uint"<br>
> tuint16 = "uint16"<br>
> tfloat32 = "float32"<br>
> @@ -192,10 +192,10 @@ for src_t in [tint, tuint, tfloat]:<br>
> <br>
> # We'll hand-code the to/from bool conversion opcodes. Because bool doesn't<br>
> # have multiple bit-sizes, we can always infer the size from the other type.<br>
> -unop_convert("f2b", tbool, tfloat, "src0 != 0.0")<br>
> -unop_convert("i2b", tbool, tint, "src0 != 0")<br>
> -unop_convert("b2f", tfloat, tbool, "src0 ? 1.0 : 0.0")<br>
> -unop_convert("b2i", tint, tbool, "src0 ? 1 : 0")<br>
> +unop_convert("f2b32", tbool32, tfloat, "src0 != 0.0")<br>
> +unop_convert("i2b32", tbool32, tint, "src0 != 0")<br>
> +unop_convert("b322f", tfloat, tbool32, "src0 ? 1.0 : 0.0")<br>
> +unop_convert("b322i", tint, tbool32, "src0 ? 1 : 0")<br>
<br>
Yeee-uck. b332i is hard to type and hard for my brain to parse. None<br>
of the other *2* opcodes have the size on the left side of the 2. The<br>
all infer the size from the source operand.<br>
<br>
I'd really like the sized Boolean types to work like the other sized<br>
types. I doubt we'll have have a using for a uint1 type, but I've been<br>
thinking about adding a bool8 or bool16 type for some time. There are<br>
quite a few cases where we carry Boolean values for a long, long time in<br>
some of the very large shaders. Those same shaders also often face<br>
register pressure. Being able to store those long lived values in a<br>
smaller type could be very helpful.<br></blockquote><div><br></div><div>I was afraid someone was going to say that. :-/ I guess it wouldn't be too difficult to have a pre-patch that reworks b2i and b2f though that is going to touch ALL the drivers. I agree that it'd be the better more consistent thing to do. I'll look into it.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> <br>
> <br>
> # Unary floating-point rounding operations.<br>
> @@ -405,8 +405,8 @@ def binop_convert(name, out_type, in_type, alg_props, const_expr):<br>
> def binop(name, ty, alg_props, const_expr):<br>
> binop_convert(name, ty, ty, alg_props, const_expr)<br>
> <br>
> -def binop_compare(name, ty, alg_props, const_expr):<br>
> - binop_convert(name, tbool, ty, alg_props, const_expr)<br>
> +def binop_compare32(name, ty, alg_props, const_expr):<br>
> + binop_convert(name, tbool32, ty, alg_props, const_expr)<br>
> <br>
> def binop_horiz(name, out_size, out_type, src1_size, src1_type, src2_size,<br>
> src2_type, const_expr):<br>
> @@ -488,26 +488,26 @@ binop("frem", tfloat, "", "src0 - src1 * truncf(src0 / src1)")<br>
> <br>
> # these integer-aware comparisons return a boolean (0 or ~0)<br>
> <br>
> -binop_compare("flt", tfloat, "", "src0 < src1")<br>
> -binop_compare("fge", tfloat, "", "src0 >= src1")<br>
> -binop_compare("feq", tfloat, commutative, "src0 == src1")<br>
> -binop_compare("fne", tfloat, commutative, "src0 != src1")<br>
> -binop_compare("ilt", tint, "", "src0 < src1")<br>
> -binop_compare("ige", tint, "", "src0 >= src1")<br>
> -binop_compare("ieq", tint, commutative, "src0 == src1")<br>
> -binop_compare("ine", tint, commutative, "src0 != src1")<br>
> -binop_compare("ult", tuint, "", "src0 < src1")<br>
> -binop_compare("uge", tuint, "", "src0 >= src1")<br>
> +binop_compare32("flt32", tfloat, "", "src0 < src1")<br>
> +binop_compare32("fge32", tfloat, "", "src0 >= src1")<br>
> +binop_compare32("feq32", tfloat, commutative, "src0 == src1")<br>
> +binop_compare32("fne32", tfloat, commutative, "src0 != src1")<br>
> +binop_compare32("ilt32", tint, "", "src0 < src1")<br>
> +binop_compare32("ige32", tint, "", "src0 >= src1")<br>
> +binop_compare32("ieq32", tint, commutative, "src0 == src1")<br>
> +binop_compare32("ine32", tint, commutative, "src0 != src1")<br>
> +binop_compare32("ult32", tuint, "", "src0 < src1")<br>
> +binop_compare32("uge32", tuint, "", "src0 >= src1")<br>
> <br>
> # integer-aware GLSL-style comparisons that compare floats and ints<br>
> <br>
> -binop_reduce("ball_fequal", 1, tbool, tfloat, "{src0} == {src1}",<br>
> +binop_reduce("b32all_fequal", 1, tbool32, tfloat, "{src0} == {src1}",<br>
> "{src0} && {src1}", "{src}")<br>
> -binop_reduce("bany_fnequal", 1, tbool, tfloat, "{src0} != {src1}",<br>
> +binop_reduce("b32any_fnequal", 1, tbool32, tfloat, "{src0} != {src1}",<br>
> "{src0} || {src1}", "{src}")<br>
> -binop_reduce("ball_iequal", 1, tbool, tint, "{src0} == {src1}",<br>
> +binop_reduce("b32all_iequal", 1, tbool32, tint, "{src0} == {src1}",<br>
> "{src0} && {src1}", "{src}")<br>
> -binop_reduce("bany_inequal", 1, tbool, tint, "{src0} != {src1}",<br>
> +binop_reduce("b32any_inequal", 1, tbool32, tint, "{src0} != {src1}",<br>
> "{src0} || {src1}", "{src}")<br>
> <br>
> # non-integer-aware GLSL-style comparisons that return 0.0 or 1.0<br>
> @@ -694,8 +694,8 @@ triop("fmed3", tfloat, "fmaxf(fminf(fmaxf(src0, src1), src2), fminf(src0, src1))<br>
> triop("imed3", tint, "MAX2(MIN2(MAX2(src0, src1), src2), MIN2(src0, src1))")<br>
> triop("umed3", tuint, "MAX2(MIN2(MAX2(src0, src1), src2), MIN2(src0, src1))")<br>
> <br>
> -opcode("bcsel", 0, tuint, [0, 0, 0],<br>
> - [tbool, tuint, tuint], "", "src0 ? src1 : src2")<br>
> +opcode("b32csel", 0, tuint, [0, 0, 0],<br>
> + [tbool32, tuint, tuint], "", "src0 ? src1 : src2")<br>
> <br>
> # SM5 bfi assembly<br>
> triop("bfi", tuint32, """<br>
> diff --git a/src/compiler/nir/nir_opcodes_c.py b/src/compiler/nir/nir_opcodes_c.py<br>
> index 8bfcda6d719..fe3fcd4c677 100644<br>
> --- a/src/compiler/nir/nir_opcodes_c.py<br>
> +++ b/src/compiler/nir/nir_opcodes_c.py<br>
> @@ -92,9 +92,9 @@ nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd<br>
> % endfor<br>
> case nir_type_bool:<br>
> % if src_t == 'float':<br>
> - return nir_op_f2b;<br>
> + return nir_op_f2b32;<br>
> % else:<br>
> - return nir_op_i2b;<br>
> + return nir_op_i2b32;<br>
> % endif<br>
> default:<br>
> unreachable("Invalid nir alu base type");<br>
> @@ -104,9 +104,9 @@ nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd<br>
> switch (dst_base) {<br>
> case nir_type_int:<br>
> case nir_type_uint:<br>
> - return nir_op_b2i;<br>
> + return nir_op_b322i;<br>
> case nir_type_float:<br>
> - return nir_op_b2f;<br>
> + return nir_op_b322f;<br>
> default:<br>
> unreachable("Invalid nir alu base type");<br>
> }<br>
> <br>
<br>
</blockquote></div></div>