[Mesa-dev] [PATCH v2] nir: lower_load_const_to_scalar fix for 8/16b types

Jason Ekstrand jason at jlekstrand.net
Tue Mar 13 22:06:56 UTC 2018


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

On Tue, Mar 13, 2018 at 2:39 PM, Rob Clark <robdclark at gmail.com> wrote:

> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
> Now with switch (and also u64<-u64 copy instead of f64<-f64 for 64b)..
>
>  src/compiler/nir/nir_lower_load_const_to_scalar.c | 19
> +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/src/compiler/nir/nir_lower_load_const_to_scalar.c
> b/src/compiler/nir/nir_lower_load_const_to_scalar.c
> index e494facfd21..39447d42c23 100644
> --- a/src/compiler/nir/nir_lower_load_const_to_scalar.c
> +++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c
> @@ -50,11 +50,22 @@ lower_load_const_instr_scalar(nir_load_const_instr
> *lower)
>     for (unsigned i = 0; i < lower->def.num_components; i++) {
>        nir_load_const_instr *load_comp =
>           nir_load_const_instr_create(b.shader, 1, lower->def.bit_size);
> -      if (lower->def.bit_size == 64)
> -         load_comp->value.f64[0] = lower->value.f64[i];
> -      else
> +      switch (lower->def.bit_size) {
> +      case 64:
> +         load_comp->value.u64[0] = lower->value.u64[i];
> +         break;
> +      case 32:
>           load_comp->value.u32[0] = lower->value.u32[i];
> -      assert(lower->def.bit_size == 64 || lower->def.bit_size == 32);
> +         break;
> +      case 16:
> +         load_comp->value.u16[0] = lower->value.u16[i];
> +         break;
> +      case 8:
> +         load_comp->value.u8[0] = lower->value.u8[i];
> +         break;
> +      default:
> +         assert(!"invalid bit size");
> +      }
>        nir_builder_instr_insert(&b, &load_comp->instr);
>        loads[i] = &load_comp->def;
>     }
> --
> 2.14.3
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180313/10ca9f1e/attachment.html>


More information about the mesa-dev mailing list