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

Submitted by Lionel Landwerlin on Nov. 5, 2018, 3:35 p.m.

Details

Message ID 20181105153607.7506-4-lionel.g.landwerlin@intel.com
State New
Headers show
Series "anv: support new formats with multiple views" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Lionel Landwerlin Nov. 5, 2018, 3:35 p.m.
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@intel.com>
---
 src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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),
                                   /* Use extra 2 channels for following swizzle */
                                   nir_imm_float(builder, 1.0f),
                                   nir_imm_float(builder, 0.0f),

Comments

On Mon, Nov 5, 2018 at 9:36 AM Lionel Landwerlin <
lionel.g.landwerlin@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@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@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>