<div dir="ltr"><div><div><div><div>I *think* most of this patch goes away if we have a new ISL_DIM_LAYOUT_GEN6_BACK_TO_BACK because we won't be pushing the isl_dev in everywhere.<br><br></div>That said, it'd be nice if you would split out the bit which adds the isl_surf with a commit message something like this:<br><br></div>i965: Add an isl_surf to intel_mipmap_tree<br><br></div>This new struct field is initialized to zero when the intel_mipmap_tree struct is allocated so users of intel_mipmap_tree can easily know whether or not the mt->surf struct contains valid data by checking intel_mipmap_tree::surf > 0.<br><br></div>--Jason<br><div><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 3, 2017 at 2:22 AM, Topi Pohjolainen <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>misc_state.c       |  12 +--<br>
 src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c |  11 ++-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_blit.c           |   8 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_fbo.c            |   9 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_fbo.h            |   9 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c    | 102 +++++++++++++++++------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h    |   8 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_screen.c         |   3 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c      |   2 +-<br>
 9 files changed, 115 insertions(+), 49 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
index 9dd6ab8..2911739 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
@@ -313,7 +313,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
              stencil_irb != depth_irb &&<br>
              stencil_irb->mt == depth_mt) {<br>
             intel_miptree_reference(&<wbr>stencil_irb->mt, depth_irb->mt);<br>
-            intel_renderbuffer_set_draw_<wbr>offset(stencil_irb);<br>
+            intel_renderbuffer_set_draw_<wbr>offset(&brw->isl_dev, stencil_irb);<br>
          }<br>
<br>
          stencil_mt = get_stencil_miptree(stencil_<wbr>irb);<br>
@@ -324,7 +324,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
<br>
       if (stencil_irb) {<br>
          stencil_mt = get_stencil_miptree(stencil_<wbr>irb);<br>
-         intel_miptree_get_image_<wbr>offset(stencil_mt,<br>
+         intel_miptree_get_image_<wbr>offset(&brw->isl_dev, stencil_mt,<br>
                                         stencil_irb->mt_level,<br>
                                         stencil_irb->mt_layer,<br>
                                         &stencil_draw_x, &stencil_draw_y);<br>
@@ -345,7 +345,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
<br>
    /* If we have (just) stencil, check it for ignored low bits as well */<br>
    if (stencil_irb) {<br>
-      intel_miptree_get_image_<wbr>offset(stencil_mt,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, stencil_mt,<br>
                                      stencil_irb->mt_level,<br>
                                      stencil_irb->mt_layer,<br>
                                      &stencil_draw_x, &stencil_draw_y);<br>
@@ -369,7 +369,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
       intel_renderbuffer_move_to_<wbr>temp(brw, stencil_irb, invalidate_stencil);<br>
       stencil_mt = get_stencil_miptree(stencil_<wbr>irb);<br>
<br>
-      intel_miptree_get_image_<wbr>offset(stencil_mt,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, stencil_mt,<br>
                                      stencil_irb->mt_level,<br>
                                      stencil_irb->mt_layer,<br>
                                      &stencil_draw_x, &stencil_draw_y);<br>
@@ -378,7 +378,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
<br>
       if (depth_irb && depth_irb->mt == stencil_irb->mt) {<br>
          intel_miptree_reference(&<wbr>depth_irb->mt, stencil_irb->mt);<br>
-         intel_renderbuffer_set_draw_<wbr>offset(depth_irb);<br>
+         intel_renderbuffer_set_draw_<wbr>offset(&brw->isl_dev, depth_irb);<br>
       } else if (depth_irb && !rebase_depth) {<br>
          if (tile_x != stencil_tile_x ||<br>
              tile_y != stencil_tile_y) {<br>
@@ -397,7 +397,7 @@ brw_workaround_depthstencil_<wbr>alignment(struct brw_context *brw,<br>
<br>
             if (stencil_irb && stencil_irb->mt == depth_mt) {<br>
                intel_miptree_reference(&<wbr>stencil_irb->mt, depth_irb->mt);<br>
-               intel_renderbuffer_set_draw_<wbr>offset(stencil_irb);<br>
+               intel_renderbuffer_set_draw_<wbr>offset(&brw->isl_dev, stencil_irb);<br>
             }<br>
<br>
             WARN_ONCE(stencil_tile_x != tile_x ||<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
index b2eca07..b3d9382 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_wm_surface_state.c<br>
@@ -105,7 +105,8 @@ brw_emit_surface_state(struct brw_context *brw,<br>
       assert(view.levels == 1 && view.array_len == 1);<br>
       assert(tile_x == 0 && tile_y == 0);<br>
<br>
-      offset += intel_miptree_get_tile_<wbr>offsets(mt, view.base_level,<br>
+      offset += intel_miptree_get_tile_<wbr>offsets(&brw->isl_dev, mt,<br>
+                                               view.base_level,<br>
                                                view.base_array_layer,<br>
                                                &tile_x, &tile_y);<br>
<br>
@@ -999,7 +1000,8 @@ gen4_update_renderbuffer_<wbr>surface(struct brw_context *brw,<br>
    assert(!(flags & INTEL_AUX_BUFFER_DISABLED));<br>
<br>
    if (rb->TexImage && !brw->has_surface_tile_offset) {<br>
-      intel_renderbuffer_get_tile_<wbr>offsets(irb, &tile_x, &tile_y);<br>
+      intel_renderbuffer_get_tile_<wbr>offsets(&brw->isl_dev, irb,<br>
+                                          &tile_x, &tile_y);<br>
<br>
       if (tile_x != 0 || tile_y != 0) {<br>
         /* Original gen4 hardware couldn't draw to a non-tile-aligned<br>
@@ -1026,7 +1028,8 @@ gen4_update_renderbuffer_<wbr>surface(struct brw_context *brw,<br>
<br>
    /* reloc */<br>
    assert(mt->offset % mt->cpp == 0);<br>
-   surf[1] = (intel_renderbuffer_get_tile_<wbr>offsets(irb, &tile_x, &tile_y) +<br>
+   surf[1] = (intel_renderbuffer_get_tile_<wbr>offsets(&brw->isl_dev, irb,<br>
+                                                  &tile_x, &tile_y) +<br>
              mt->bo->offset64 + mt->offset);<br>
<br>
    surf[2] = ((rb->Width - 1) << BRW_SURFACE_WIDTH_SHIFT |<br>
@@ -1655,7 +1658,7 @@ update_texture_image_param(<wbr>struct brw_context *brw,<br>
                      minify(mt->logical_depth0, u->Level) :<br>
                      mt->logical_depth0);<br>
<br>
-   intel_miptree_get_image_<wbr>offset(mt, u->Level, u->_Layer,<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev, mt, u->Level, u->_Layer,<br>
                                   &param->offset[0],<br>
                                   &param->offset[1]);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
index 568ed54..4cd86dd 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
@@ -337,9 +337,9 @@ intel_miptree_blit(struct brw_context *brw,<br>
       dst_y = minify(dst_mt->physical_<wbr>height0, dst_level - dst_mt->first_level) - dst_y - height;<br>
<br>
    uint32_t src_image_x, src_image_y, dst_image_x, dst_image_y;<br>
-   intel_miptree_get_image_<wbr>offset(src_mt, src_level, src_slice,<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev, src_mt, src_level, src_slice,<br>
                                   &src_image_x, &src_image_y);<br>
-   intel_miptree_get_image_<wbr>offset(dst_mt, dst_level, dst_slice,<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev, dst_mt, dst_level, dst_slice,<br>
                                   &dst_image_x, &dst_image_y);<br>
    src_x += src_image_x;<br>
    src_y += src_image_y;<br>
@@ -389,7 +389,7 @@ intel_miptree_copy(struct brw_context *brw,<br>
    intel_miptree_resolve_color(<wbr>brw, dst_mt, dst_level, dst_slice, 1, 0);<br>
<br>
    uint32_t src_image_x, src_image_y;<br>
-   intel_miptree_get_image_<wbr>offset(src_mt, src_level, src_slice,<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev, src_mt, src_level, src_slice,<br>
                                   &src_image_x, &src_image_y);<br>
<br>
    if (_mesa_is_format_compressed(<wbr>src_mt->format)) {<br>
@@ -418,7 +418,7 @@ intel_miptree_copy(struct brw_context *brw,<br>
    src_y += src_image_y;<br>
<br>
    uint32_t dst_image_x, dst_image_y;<br>
-   intel_miptree_get_image_<wbr>offset(dst_mt, dst_level, dst_slice,<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev, dst_mt, dst_level, dst_slice,<br>
                                   &dst_image_x, &dst_image_y);<br>
<br>
    if (_mesa_is_format_compressed(<wbr>dst_mt->format)) {<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
index 21e8e86..27446cc 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
@@ -559,7 +559,7 @@ intel_renderbuffer_update_<wbr>wrapper(struct brw_context *brw,<br>
<br>
    intel_miptree_reference(&irb-><wbr>mt, mt);<br>
<br>
-   intel_renderbuffer_set_draw_<wbr>offset(irb);<br>
+   intel_renderbuffer_set_draw_<wbr>offset(&brw->isl_dev, irb);<br>
<br>
    if (intel_miptree_wants_hiz_<wbr>buffer(brw, mt)) {<br>
       intel_miptree_alloc_hiz(brw, mt);<br>
@@ -571,12 +571,13 @@ intel_renderbuffer_update_<wbr>wrapper(struct brw_context *brw,<br>
 }<br>
<br>
 void<br>
-intel_renderbuffer_set_draw_<wbr>offset(struct intel_renderbuffer *irb)<br>
+intel_renderbuffer_set_draw_<wbr>offset(const struct isl_device *isl_dev,<br>
+                                   struct intel_renderbuffer *irb)<br>
 {<br>
    unsigned int dst_x, dst_y;<br>
<br>
    /* compute offset of the particular 2D image within the texture region */<br>
-   intel_miptree_get_image_<wbr>offset(irb->mt,<br>
+   intel_miptree_get_image_<wbr>offset(isl_dev, irb->mt,<br>
                                  irb->mt_level,<br>
                                  irb->mt_layer,<br>
                                  &dst_x, &dst_y);<br>
@@ -1043,7 +1044,7 @@ intel_renderbuffer_move_to_<wbr>temp(struct brw_context *brw,<br>
    intel_miptree_copy_teximage(<wbr>brw, intel_image, new_mt, invalidate);<br>
<br>
    intel_miptree_reference(&irb-><wbr>mt, intel_image->mt);<br>
-   intel_renderbuffer_set_draw_<wbr>offset(irb);<br>
+   intel_renderbuffer_set_draw_<wbr>offset(&brw->isl_dev, irb);<br>
    intel_miptree_release(&new_mt)<wbr>;<br>
 }<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.h b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.h<br>
index 08b82e8..a9c4546 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.h<br>
@@ -181,14 +181,17 @@ extern void<br>
 intel_fbo_init(struct brw_context *brw);<br>
<br>
 void<br>
-intel_renderbuffer_set_draw_<wbr>offset(struct intel_renderbuffer *irb);<br>
+intel_renderbuffer_set_draw_<wbr>offset(const struct isl_device *isl_dev,<br>
+                                   struct intel_renderbuffer *irb);<br>
<br>
 static inline uint32_t<br>
-intel_renderbuffer_get_tile_<wbr>offsets(struct intel_renderbuffer *irb,<br>
+intel_renderbuffer_get_tile_<wbr>offsets(const struct isl_device *isl_dev,<br>
+                                    struct intel_renderbuffer *irb,<br>
                                     uint32_t *tile_x,<br>
                                     uint32_t *tile_y)<br>
 {<br>
-   return intel_miptree_get_tile_<wbr>offsets(irb->mt, irb->mt_level, irb->mt_layer,<br>
+   return intel_miptree_get_tile_<wbr>offsets(isl_dev, irb->mt,<br>
+                                         irb->mt_level, irb->mt_layer,<br>
                                          tile_x, tile_y);<br>
 }<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
index d80a1b6..e91992c 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
@@ -1082,10 +1082,25 @@ intel_miptree_set_image_<wbr>offset(struct intel_mipmap_tree *mt,<br>
 }<br>
<br>
 void<br>
-intel_miptree_get_image_<wbr>offset(const struct intel_mipmap_tree *mt,<br>
+intel_miptree_get_image_<wbr>offset(const struct isl_device *isl_dev,<br>
+                               const struct intel_mipmap_tree *mt,<br>
                               GLuint level, GLuint slice,<br>
                               GLuint *x, GLuint *y)<br>
 {<br>
+   if (mt->surf.size > 0) {<br>
+      uint32_t x_offset_sa, y_offset_sa;<br>
+      const unsigned z = mt->surf.dim_layout == ISL_DIM_LAYOUT_GEN4_3D ?<br>
+                         slice : 0;<br>
+      slice = mt->surf.dim_layout == ISL_DIM_LAYOUT_GEN4_3D ?<br>
+              0 : slice;<br>
+      isl_surf_get_image_offset_sa(<wbr>isl_dev, &mt->surf, level, slice, z,<br>
+                                   &x_offset_sa, &y_offset_sa);<br>
+<br>
+      *x = x_offset_sa;<br>
+      *y = y_offset_sa;<br>
+      return;<br>
+   }<br>
+<br>
    assert(slice < mt->level[level].depth);<br>
<br>
    *x = mt->level[level].slice[slice].<wbr>x_offset;<br>
@@ -1178,7 +1193,8 @@ intel_miptree_get_aligned_<wbr>offset(const struct intel_mipmap_tree *mt,<br>
  * from there.<br>
  */<br>
 uint32_t<br>
-intel_miptree_get_tile_<wbr>offsets(const struct intel_mipmap_tree *mt,<br>
+intel_miptree_get_tile_<wbr>offsets(const struct isl_device *isl_dev,<br>
+                               const struct intel_mipmap_tree *mt,<br>
                                GLuint level, GLuint slice,<br>
                                uint32_t *tile_x,<br>
                                uint32_t *tile_y)<br>
@@ -1187,7 +1203,7 @@ intel_miptree_get_tile_<wbr>offsets(const struct intel_mipmap_tree *mt,<br>
    uint32_t mask_x, mask_y;<br>
<br>
    intel_get_tile_masks(mt-><wbr>tiling, mt->cpp, &mask_x, &mask_y);<br>
-   intel_miptree_get_image_<wbr>offset(mt, level, slice, &x, &y);<br>
+   intel_miptree_get_image_<wbr>offset(isl_dev, mt, level, slice, &x, &y);<br>
<br>
    *tile_x = x & mask_x;<br>
    *tile_y = y & mask_y;<br>
@@ -1206,7 +1222,8 @@ intel_miptree_copy_slice_sw(<wbr>struct brw_context *brw,<br>
 {<br>
    void *src, *dst;<br>
    ptrdiff_t src_stride, dst_stride;<br>
-   int cpp = dst_mt->cpp;<br>
+   const int cpp = dst_mt->surf.size > 0 ?<br>
+      (isl_format_get_layout(dst_mt-<wbr>>surf.format)->bpb / 8) : dst_mt->cpp;<br>
<br>
    intel_miptree_map(brw, src_mt,<br>
                      level, slice,<br>
@@ -1299,8 +1316,10 @@ intel_miptree_copy_slice(<wbr>struct brw_context *brw,<br>
    }<br>
<br>
    uint32_t dst_x, dst_y, src_x, src_y;<br>
-   intel_miptree_get_image_<wbr>offset(dst_mt, level, slice, &dst_x, &dst_y);<br>
-   intel_miptree_get_image_<wbr>offset(src_mt, level, slice, &src_x, &src_y);<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                  dst_mt, level, slice, &dst_x, &dst_y);<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                  src_mt, level, slice, &src_x, &src_y);<br>
<br>
    DBG("validate blit mt %s %p %d,%d/%d -> mt %s %p %d,%d/%d (%dx%d)\n",<br>
        _mesa_get_format_name(src_mt-><wbr>format),<br>
@@ -2236,11 +2255,12 @@ intel_miptree_map_gtt(struct brw_context *brw,<br>
       /* Note that in the case of cube maps, the caller must have passed the<br>
        * slice number referencing the face.<br>
       */<br>
-      intel_miptree_get_image_<wbr>offset(mt, level, slice, &image_x, &image_y);<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                     mt, level, slice, &image_x, &image_y);<br>
       x += image_x;<br>
       y += image_y;<br>
<br>
-      map->stride = mt->pitch;<br>
+      map->stride = mt->surf.size > 0 ? mt->surf.row_pitch : mt->pitch;<br>
       map->ptr = base + y * map->stride + x * mt->cpp;<br>
    }<br>
<br>
@@ -2274,7 +2294,8 @@ intel_miptree_map_blit(struct brw_context *brw,<br>
       fprintf(stderr, "Failed to allocate blit temporary\n");<br>
       goto fail;<br>
    }<br>
-   map->stride = map->linear_mt->pitch;<br>
+   map->stride = map->linear_mt->surf.size > 0 ?<br>
+                    map->linear_mt->surf.row_pitch : map->linear_mt->pitch;<br>
<br>
    /* One of either READ_BIT or WRITE_BIT or both is set.  READ_BIT implies no<br>
     * INVALIDATE_RANGE_BIT.  WRITE_BIT needs the original values read in unless<br>
@@ -2349,7 +2370,8 @@ intel_miptree_map_movntdqa(<wbr>struct brw_context *brw,<br>
    /* Map the original image */<br>
    uint32_t image_x;<br>
    uint32_t image_y;<br>
-   intel_miptree_get_image_<wbr>offset(mt, level, slice, &image_x, &image_y);<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                  mt, level, slice, &image_x, &image_y);<br>
    image_x += map->x;<br>
    image_y += map->y;<br>
<br>
@@ -2359,15 +2381,20 @@ intel_miptree_map_movntdqa(<wbr>struct brw_context *brw,<br>
<br>
    src += mt->offset;<br>
<br>
-   src += image_y * mt->pitch;<br>
-   src += image_x * mt->cpp;<br>
+   if (mt->surf.size > 0) {<br>
+      src += image_y * mt->surf.row_pitch;<br>
+      src += image_x * (isl_format_get_layout(mt-><wbr>surf.format)->bpb / 8);<br>
+   } else {<br>
+      src += image_y * mt->pitch;<br>
+      src += image_x * mt->cpp;<br>
+   }<br>
<br>
    /* Due to the pixel offsets for the particular image being mapped, our<br>
     * src pointer may not be 16-byte aligned.  However, if the pitch is<br>
     * divisible by 16, then the amount by which it's misaligned will remain<br>
     * consistent from row to row.<br>
     */<br>
-   assert((mt->pitch % 16) == 0);<br>
+   assert(((mt->surf.size > 0 ? mt->surf.row_pitch : mt->pitch) % 16) == 0);<br>
    const int misalignment = ((uintptr_t) src) & 15;<br>
<br>
    /* Create an untiled temporary buffer for the mapping. */<br>
@@ -2421,15 +2448,22 @@ intel_miptree_map_s8(struct brw_context *brw,<br>
     * temporary buffer back out.<br>
     */<br>
    if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {<br>
+      /* ISL uses a stencil pitch value that is expected by hardware whereas<br>
+       * traditional miptree uses half of that. Below the value gets supplied<br>
+       * to intel_offset_S8() which expects the legacy interpretation.<br>
+       */<br>
+      const unsigned pitch = mt->surf.size > 0 ?<br>
+                             mt->surf.row_pitch / 2 : mt->pitch;<br>
       uint8_t *untiled_s8_map = map->ptr;<br>
       uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt);<br>
       unsigned int image_x, image_y;<br>
<br>
-      intel_miptree_get_image_<wbr>offset(mt, level, slice, &image_x, &image_y);<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                     mt, level, slice, &image_x, &image_y);<br>
<br>
       for (uint32_t y = 0; y < map->h; y++) {<br>
         for (uint32_t x = 0; x < map->w; x++) {<br>
-           ptrdiff_t offset = intel_offset_S8(mt->pitch,<br>
+           ptrdiff_t offset = intel_offset_S8(pitch,<br>
                                               x + image_x + map->x,<br>
                                               y + image_y + map->y,<br>
                                               brw->has_swizzling);<br>
@@ -2457,15 +2491,22 @@ intel_miptree_unmap_s8(struct brw_context *brw,<br>
                       unsigned int slice)<br>
 {<br>
    if (map->mode & GL_MAP_WRITE_BIT) {<br>
+      /* ISL uses a stencil pitch value that is expected by hardware whereas<br>
+       * traditional miptree uses half of that. Below the value gets supplied<br>
+       * to intel_offset_S8() which expects the legacy interpretation.<br>
+       */<br>
+      const unsigned pitch = mt->surf.size > 0 ?<br>
+                             mt->surf.row_pitch / 2: mt->pitch;<br>
       unsigned int image_x, image_y;<br>
       uint8_t *untiled_s8_map = map->ptr;<br>
       uint8_t *tiled_s8_map = intel_miptree_map_raw(brw, mt);<br>
<br>
-      intel_miptree_get_image_<wbr>offset(mt, level, slice, &image_x, &image_y);<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                     mt, level, slice, &image_x, &image_y);<br>
<br>
       for (uint32_t y = 0; y < map->h; y++) {<br>
         for (uint32_t x = 0; x < map->w; x++) {<br>
-           ptrdiff_t offset = intel_offset_S8(mt->pitch,<br>
+           ptrdiff_t offset = intel_offset_S8(pitch,<br>
                                               image_x + x + map->x,<br>
                                               image_y + y + map->y,<br>
                                               brw->has_swizzling);<br>
@@ -2509,7 +2550,8 @@ intel_miptree_unmap_etc(struct brw_context *brw,<br>
 {<br>
    uint32_t image_x;<br>
    uint32_t image_y;<br>
-   intel_miptree_get_image_<wbr>offset(mt, level, slice, &image_x, &image_y);<br>
+   intel_miptree_get_image_<wbr>offset(&brw->isl_dev,<br>
+                                  mt, level, slice, &image_x, &image_y);<br>
<br>
    image_x += map->x;<br>
    image_y += map->y;<br>
@@ -2564,21 +2606,27 @@ intel_miptree_map_<wbr>depthstencil(struct brw_context *brw,<br>
     * temporary buffer back out.<br>
     */<br>
    if (!(map->mode & GL_MAP_INVALIDATE_RANGE_BIT)) {<br>
+      /* ISL uses a stencil pitch value that is expected by hardware whereas<br>
+       * traditional miptree uses half of that. Below the value gets supplied<br>
+       * to intel_offset_S8() which expects the legacy interpretation.<br>
+       */<br>
+      const unsigned s_pitch = s_mt->surf.size > 0 ?<br>
+                               s_mt->surf.row_pitch / 2 : s_mt->pitch;<br>
       uint32_t *packed_map = map->ptr;<br>
       uint8_t *s_map = intel_miptree_map_raw(brw, s_mt);<br>
       uint32_t *z_map = intel_miptree_map_raw(brw, z_mt);<br>
       unsigned int s_image_x, s_image_y;<br>
       unsigned int z_image_x, z_image_y;<br>
<br>
-      intel_miptree_get_image_<wbr>offset(s_mt, level, slice,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, s_mt, level, slice,<br>
                                     &s_image_x, &s_image_y);<br>
-      intel_miptree_get_image_<wbr>offset(z_mt, level, slice,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, z_mt, level, slice,<br>
                                     &z_image_x, &z_image_y);<br>
<br>
       for (uint32_t y = 0; y < map->h; y++) {<br>
         for (uint32_t x = 0; x < map->w; x++) {<br>
            int map_x = map->x + x, map_y = map->y + y;<br>
-           ptrdiff_t s_offset = intel_offset_S8(s_mt->pitch,<br>
+           ptrdiff_t s_offset = intel_offset_S8(s_pitch,<br>
                                                 map_x + s_image_x,<br>
                                                 map_y + s_image_y,<br>
                                                 brw->has_swizzling);<br>
@@ -2625,20 +2673,26 @@ intel_miptree_unmap_<wbr>depthstencil(struct brw_context *brw,<br>
    bool map_z32f_x24s8 = mt->format == MESA_FORMAT_Z_FLOAT32;<br>
<br>
    if (map->mode & GL_MAP_WRITE_BIT) {<br>
+      /* ISL uses a stencil pitch value that is expected by hardware whereas<br>
+       * traditional miptree uses half of that. Below the value gets supplied<br>
+       * to intel_offset_S8() which expects the legacy interpretation.<br>
+       */<br>
+      const unsigned s_pitch = s_mt->surf.size > 0 ?<br>
+                               s_mt->surf.row_pitch / 2 : s_mt->pitch;<br>
       uint32_t *packed_map = map->ptr;<br>
       uint8_t *s_map = intel_miptree_map_raw(brw, s_mt);<br>
       uint32_t *z_map = intel_miptree_map_raw(brw, z_mt);<br>
       unsigned int s_image_x, s_image_y;<br>
       unsigned int z_image_x, z_image_y;<br>
<br>
-      intel_miptree_get_image_<wbr>offset(s_mt, level, slice,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, s_mt, level, slice,<br>
                                     &s_image_x, &s_image_y);<br>
-      intel_miptree_get_image_<wbr>offset(z_mt, level, slice,<br>
+      intel_miptree_get_image_<wbr>offset(&brw->isl_dev, z_mt, level, slice,<br>
                                     &z_image_x, &z_image_y);<br>
<br>
       for (uint32_t y = 0; y < map->h; y++) {<br>
         for (uint32_t x = 0; x < map->w; x++) {<br>
-           ptrdiff_t s_offset = intel_offset_S8(s_mt->pitch,<br>
+           ptrdiff_t s_offset = intel_offset_S8(s_pitch,<br>
                                                 x + s_image_x + map->x,<br>
                                                 y + s_image_y + map->y,<br>
                                                 brw->has_swizzling);<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
index 913fb4c..672b5f4 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
@@ -323,6 +323,8 @@ struct intel_miptree_aux_buffer<br>
<br>
 struct intel_mipmap_tree<br>
 {<br>
+   struct isl_surf surf;<br>
+<br>
    /**<br>
     * Buffer object containing the surface.<br>
     *<br>
@@ -748,7 +750,8 @@ bool intel_miptree_match_image(<wbr>struct intel_mipmap_tree *mt,<br>
                                     struct gl_texture_image *image);<br>
<br>
 void<br>
-intel_miptree_get_image_<wbr>offset(const struct intel_mipmap_tree *mt,<br>
+intel_miptree_get_image_<wbr>offset(const struct isl_device *isl_dev,<br>
+                               const struct intel_mipmap_tree *mt,<br>
                               GLuint level, GLuint slice,<br>
                               GLuint *x, GLuint *y);<br>
<br>
@@ -788,7 +791,8 @@ intel_get_tile_dims(uint32_t tiling, uint32_t cpp,<br>
                     uint32_t *tile_w, uint32_t *tile_h);<br>
<br>
 uint32_t<br>
-intel_miptree_get_tile_<wbr>offsets(const struct intel_mipmap_tree *mt,<br>
+intel_miptree_get_tile_<wbr>offsets(const struct isl_device *isl_dev,<br>
+                               const struct intel_mipmap_tree *mt,<br>
                                GLuint level, GLuint slice,<br>
                                uint32_t *tile_x,<br>
                                uint32_t *tile_y);<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
index 34a5f18..c08192a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
@@ -371,7 +371,8 @@ intel_setup_image_from_mipmap_<wbr>tree(struct brw_context *brw, __DRIimage *image,<br>
    image->height = minify(mt->physical_height0, level - mt->first_level);<br>
    image->pitch = mt->pitch;<br>
<br>
-   image->offset = intel_miptree_get_tile_<wbr>offsets(mt, level, zoffset,<br>
+   image->offset = intel_miptree_get_tile_<wbr>offsets(&brw->isl_dev,<br>
+                                                  mt, level, zoffset,<br>
                                                   &image->tile_x,<br>
                                                   &image->tile_y);<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
index 7208d8e..9aa2f70 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
@@ -272,7 +272,7 @@ create_mt_for_dri_image(struct brw_context *brw,<br>
    mt->level[0].slice[0].x_offset = image->tile_x;<br>
    mt->level[0].slice[0].y_offset = image->tile_y;<br>
<br>
-   intel_miptree_get_tile_<wbr>offsets(mt, 0, 0, &draw_x, &draw_y);<br>
+   intel_miptree_get_tile_<wbr>offsets(&brw->isl_dev, mt, 0, 0, &draw_x, &draw_y);<br>
<br>
    /* From "OES_EGL_image" error reporting. We report GL_INVALID_OPERATION<br>
     * for EGL images from non-tile aligned sufaces in gen4 hw and earlier which has<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div></div></div></div></div></div>