[Mesa-dev] [PATCH 1/5] anv/lower_ycbcr: Use the binding array size for bounds checks

Dylan Baker dylan at pnwbakers.com
Mon Aug 20 15:33:28 UTC 2018


Quoting Jason Ekstrand (2018-08-08 01:12:49)
> Because lower_ycbcr gets called before apply_pipeline_layout, the
> indices are all logical and the binding layout HW size is actually too
> big for the bounds check.  We should just use the regular logical array
> size instead.
> 
> Fixes: f3e91e78a33 "anv: add nir lowering pass for ycbcr textures"
> ---
>  src/intel/vulkan/anv_nir_lower_ycbcr_textures.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> index 5a971d9be39..71e511f34b7 100644
> --- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> +++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
> @@ -340,18 +340,16 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
>     if (binding->immutable_samplers == NULL)
>        return false;
>  
> -   unsigned texture_index = tex->texture_index;
> +   assert(tex->texture_index == 0);
> +   unsigned array_index = 0;
>     if (deref->deref_type != nir_deref_type_var) {
>        assert(deref->deref_type == nir_deref_type_array);
>        nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
>        if (!const_index)
>           return false;
> -      size_t hw_binding_size =
> -         anv_descriptor_set_binding_layout_get_hw_size(binding);
> -      texture_index += MIN2(const_index->u32[0], hw_binding_size - 1);
> +      array_index = MIN2(const_index->u32[0], binding->array_size - 1);
>     }
> -   const struct anv_sampler *sampler =
> -      binding->immutable_samplers[texture_index];
> +   const struct anv_sampler *sampler = binding->immutable_samplers[array_index];
>  
>     if (sampler->conversion == NULL)
>        return false;
> -- 
> 2.17.1
> 

Hi Jason,

f3e91e78a33 is present in 18.1, but this patch doesn't apply cleanly due to (I
think) your rework of how derefs work in NIR. Do you want to backport this patch
to 18.1, or just drop it?

Thanks,
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180820/ba64ce72/attachment.sig>


More information about the mesa-dev mailing list