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

Jason Ekstrand jason at jlekstrand.net
Tue Mar 13 20:24:11 UTC 2018


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

> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
>  src/compiler/nir/nir_lower_load_const_to_scalar.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 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..9d37e3fecef 100644
> --- a/src/compiler/nir/nir_lower_load_const_to_scalar.c
> +++ b/src/compiler/nir/nir_lower_load_const_to_scalar.c
> @@ -52,9 +52,14 @@ lower_load_const_instr_scalar(nir_load_const_instr
> *lower)
>           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
> +      else if (lower->def.bit_size == 32)
>           load_comp->value.u32[0] = lower->value.u32[i];
> -      assert(lower->def.bit_size == 64 || lower->def.bit_size == 32);
> +      else if (lower->def.bit_size == 16)
> +         load_comp->value.u16[0] = lower->value.u16[i];
> +      else if (lower->def.bit_size == 8)
> +         load_comp->value.u8[0] = lower->value.u8[i];
> +      else
> +         assert(!"invalid bit size");
>

Let's make it a switch since we have 4 cases which are all == constant.


>        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/406fee2a/attachment.html>


More information about the mesa-dev mailing list