On Mon, Nov 5, 2018 at 9:36 AM Lionel Landwerlin <
[email protected]> wrote:

> To play around with debugging, we might want to disable one or the
> other component. Having 0s as default values makes this work.
> Otherwise we might have NULL components, leading to crashes.
>
> Signed-off-by: Lionel Landwerlin <[email protected]>
> ---
>  src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> index 71e511f34b7..29e5de481bb 100644
> --- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> +++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> @@ -373,7 +373,9 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
>     uint8_t y_bpc = y_isl_layout->channels_array[0].bits;
>
>     /* |ycbcr_comp| holds components in the order : Cr-Y-Cb */
> -   nir_ssa_def *ycbcr_comp[5] = { NULL, NULL, NULL,
> +   nir_ssa_def *ycbcr_comp[5] = { nir_imm_float(builder, 0.0f),
> +                                  nir_imm_float(builder, 0.0f),
> +                                  nir_imm_float(builder, 0.0f),
>

If we wanted to avoid emitting extra instructions, we could do

nir_ssa_def *zero = nir_imm_float(builder, 0.0f);
nir_ssa_def *one = nir_imm_float(builder, 1.0f);
nir_ssa_def *ycbcr_comp[5] = { zero, zero, zero, one, zero };

It would also save a couple of lines. :)

--Jason


>                                    /* Use extra 2 channels for following
> swizzle */
>                                    nir_imm_float(builder, 1.0f),
>                                    nir_imm_float(builder, 0.0f),
> --
> 2.19.1
>
> _______________________________________________
> mesa-dev mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to