[v3,31/42] intel/compiler: ask for an integer type if requesting an 8-bit type

Submitted by Iago Toral Quiroga on Jan. 15, 2019, 1:54 p.m.

Details

Message ID 20190115135414.2313-32-itoral@igalia.com
State New
Headers show
Series "intel: VK_KHR_shader_float16_int8 implementation" ( rev: 5 4 ) in Mesa

Not browsing as part of any series.

Commit Message

Iago Toral Quiroga Jan. 15, 2019, 1:54 p.m.
---
 src/intel/compiler/brw_fs_nir.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index a3d193b8a44..ccf1891b925 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -346,7 +346,9 @@  fs_visitor::nir_emit_impl(nir_function_impl *impl)
          reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
       unsigned size = array_elems * reg->num_components;
       const brw_reg_type reg_type =
-         brw_reg_type_from_bit_size(reg->bit_size, BRW_REGISTER_TYPE_F);
+         brw_reg_type_from_bit_size(reg->bit_size,
+                                    reg->bit_size == 8 ? BRW_REGISTER_TYPE_D :
+                                                         BRW_REGISTER_TYPE_F);
       nir_locals[reg->index] = bld.vgrf(reg_type, size);
    }
 
@@ -4281,7 +4283,10 @@  fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
       fs_reg value = get_nir_src(instr->src[0]);
       if (instr->intrinsic == nir_intrinsic_vote_feq) {
          const unsigned bit_size = nir_src_bit_size(instr->src[0]);
-         value.type = brw_reg_type_from_bit_size(bit_size, BRW_REGISTER_TYPE_F);
+         value.type =
+            brw_reg_type_from_bit_size(bit_size,
+                                       bit_size == 8 ? BRW_REGISTER_TYPE_D :
+                                                       BRW_REGISTER_TYPE_F);
       }
 
       fs_reg uniformized = bld.emit_uniformize(value);

Comments

On Tue, Jan 15, 2019 at 7:55 AM Iago Toral Quiroga <itoral@igalia.com>
wrote:

> ---
>  src/intel/compiler/brw_fs_nir.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/intel/compiler/brw_fs_nir.cpp
> b/src/intel/compiler/brw_fs_nir.cpp
> index a3d193b8a44..ccf1891b925 100644
> --- a/src/intel/compiler/brw_fs_nir.cpp
> +++ b/src/intel/compiler/brw_fs_nir.cpp
> @@ -346,7 +346,9 @@ fs_visitor::nir_emit_impl(nir_function_impl *impl)
>           reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
>        unsigned size = array_elems * reg->num_components;
>        const brw_reg_type reg_type =
> -         brw_reg_type_from_bit_size(reg->bit_size, BRW_REGISTER_TYPE_F);
> +         brw_reg_type_from_bit_size(reg->bit_size,
> +                                    reg->bit_size == 8 ?
> BRW_REGISTER_TYPE_D :
> +
>  BRW_REGISTER_TYPE_F);
>

If it were me, I'd do

const brw_reg_type reg_type = reg->bit_size == 8 ? BRW_REGISTER_TYPE_B :
   brw_reg_type_for_bit_size(reg->bit_size, BRW_REGISTER_TYPE_F);

I just find that a tiny bit easier to parse.  Either way is fine though.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>


>        nir_locals[reg->index] = bld.vgrf(reg_type, size);
>     }
>
> @@ -4281,7 +4283,10 @@ fs_visitor::nir_emit_intrinsic(const fs_builder
> &bld, nir_intrinsic_instr *instr
>        fs_reg value = get_nir_src(instr->src[0]);
>        if (instr->intrinsic == nir_intrinsic_vote_feq) {
>           const unsigned bit_size = nir_src_bit_size(instr->src[0]);
> -         value.type = brw_reg_type_from_bit_size(bit_size,
> BRW_REGISTER_TYPE_F);
> +         value.type =
> +            brw_reg_type_from_bit_size(bit_size,
> +                                       bit_size == 8 ?
> BRW_REGISTER_TYPE_D :
> +
>  BRW_REGISTER_TYPE_F);
>        }
>
>        fs_reg uniformized = bld.emit_uniformize(value);
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>