[v2] i965: Fix calculation of layers array length for isl_view

Submitted by Danylo Piliaiev on Sept. 7, 2018, 3:39 p.m.

Details

Message ID 20180907153940.23093-1-danylo.piliaiev@globallogic.com
State New
Headers show
Series "i965: Fix calculation of layers array length for isl_view" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Danylo Piliaiev Sept. 7, 2018, 3:39 p.m.
Comment for array_len field states:
 "Indicates the number of array elements starting at
   Base Array Layer."

And most usages of array_len expect it to be equal or less than
 total layers - base layer

v2: Do not subtract base layer if image unit is not layered (Ilia Mirkin)

Fixes: 5a8c8903
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107856

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 42af41aca3..54f62f0396 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1539,14 +1539,16 @@  update_image_surface(struct brw_context *brw,
       } else {
          struct intel_texture_object *intel_obj = intel_texture_object(obj);
          struct intel_mipmap_tree *mt = intel_obj->mt;
+
+         const unsigned base_layer = obj->MinLayer + u->_Layer;
          const unsigned num_layers = u->Layered ?
-            get_image_num_layers(mt, obj->Target, u->Level) : 1;
+            (get_image_num_layers(mt, obj->Target, u->Level) - base_layer) : 1;
 
          struct isl_view view = {
             .format = format,
             .base_level = obj->MinLevel + u->Level,
             .levels = 1,
-            .base_array_layer = obj->MinLayer + u->_Layer,
+            .base_array_layer = base_layer,
             .array_len = num_layers,
             .swizzle = ISL_SWIZZLE_IDENTITY,
             .usage = ISL_SURF_USAGE_STORAGE_BIT,

Comments

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>

On Fri, Sep 7, 2018 at 10:39 AM Danylo Piliaiev <danylo.piliaiev@gmail.com>
wrote:

> Comment for array_len field states:
>  "Indicates the number of array elements starting at
>    Base Array Layer."
>
> And most usages of array_len expect it to be equal or less than
>  total layers - base layer
>
> v2: Do not subtract base layer if image unit is not layered (Ilia Mirkin)
>
> Fixes: 5a8c8903
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107856
>
> Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 42af41aca3..54f62f0396 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -1539,14 +1539,16 @@ update_image_surface(struct brw_context *brw,
>        } else {
>           struct intel_texture_object *intel_obj =
> intel_texture_object(obj);
>           struct intel_mipmap_tree *mt = intel_obj->mt;
> +
> +         const unsigned base_layer = obj->MinLayer + u->_Layer;
>           const unsigned num_layers = u->Layered ?
> -            get_image_num_layers(mt, obj->Target, u->Level) : 1;
> +            (get_image_num_layers(mt, obj->Target, u->Level) -
> base_layer) : 1;
>
>           struct isl_view view = {
>              .format = format,
>              .base_level = obj->MinLevel + u->Level,
>              .levels = 1,
> -            .base_array_layer = obj->MinLayer + u->_Layer,
> +            .base_array_layer = base_layer,
>              .array_len = num_layers,
>              .swizzle = ISL_SWIZZLE_IDENTITY,
>              .usage = ISL_SURF_USAGE_STORAGE_BIT,
> --
> 2.18.0
>
>
FWIW, this looks right.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>

On Fri, Sep 7, 2018 at 11:39 AM, Danylo Piliaiev
<danylo.piliaiev@gmail.com> wrote:
> Comment for array_len field states:
>  "Indicates the number of array elements starting at
>    Base Array Layer."
>
> And most usages of array_len expect it to be equal or less than
>  total layers - base layer
>
> v2: Do not subtract base layer if image unit is not layered (Ilia Mirkin)
>
> Fixes: 5a8c8903
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107856
>
> Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 42af41aca3..54f62f0396 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -1539,14 +1539,16 @@ update_image_surface(struct brw_context *brw,
>        } else {
>           struct intel_texture_object *intel_obj = intel_texture_object(obj);
>           struct intel_mipmap_tree *mt = intel_obj->mt;
> +
> +         const unsigned base_layer = obj->MinLayer + u->_Layer;
>           const unsigned num_layers = u->Layered ?
> -            get_image_num_layers(mt, obj->Target, u->Level) : 1;
> +            (get_image_num_layers(mt, obj->Target, u->Level) - base_layer) : 1;
>
>           struct isl_view view = {
>              .format = format,
>              .base_level = obj->MinLevel + u->Level,
>              .levels = 1,
> -            .base_array_layer = obj->MinLayer + u->_Layer,
> +            .base_array_layer = base_layer,
>              .array_len = num_layers,
>              .swizzle = ISL_SWIZZLE_IDENTITY,
>              .usage = ISL_SURF_USAGE_STORAGE_BIT,
> --
> 2.18.0
>