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

Lionel Landwerlin lionel.g.landwerlin at intel.com
Mon Aug 20 15:59:38 UTC 2018


From: Jason Ekstrand <jason.ekstrand at intel.com>

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"
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
(cherry picked from commit 320dacb0a051cd1736e0976f70467b68281edfbf)
---
 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 ebf1fd9c267..e2b560364bc 100644
--- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
+++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c
@@ -337,18 +337,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 (tex->texture->deref.child) {
       assert(tex->texture->deref.child->deref_type == nir_deref_type_array);
       nir_deref_array *deref_array = nir_deref_as_array(tex->texture->deref.child);
       if (deref_array->deref_array_type != nir_deref_array_type_direct)
          return false;
-      size_t hw_binding_size =
-         anv_descriptor_set_binding_layout_get_hw_size(binding);
-      texture_index += MIN2(deref_array->base_offset, hw_binding_size - 1);
+      array_index = MIN2(deref_array->base_offset, 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.18.0



More information about the mesa-dev mailing list