[Mesa-dev] [PATCH 03/13] anv/lower_ycbcr: make sure to set 0s on all components

Jason Ekstrand jason at jlekstrand.net
Thu Nov 8 22:33:48 UTC 2018


On Mon, Nov 5, 2018 at 9:36 AM Lionel Landwerlin <
lionel.g.landwerlin at intel.com> 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 <lionel.g.landwerlin at intel.com>
> ---
>  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
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181108/6766548c/attachment-0001.html>


More information about the mesa-dev mailing list