<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 13, 2017 at 7:50 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/<wbr>intel_mipmap_tree.c | 32 +++++++++++++++++++++++----<br>
 1 file changed, 28 insertions(+), 4 deletions(-)<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 0854b4eb5d..ecb9186715 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>
@@ -3262,6 +3262,12 @@ 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, GL_MAP_READ_BIT);<br>
       unsigned int image_x, image_y;<br>
@@ -3270,7 +3276,7 @@ intel_miptree_map_s8(struct brw_context *brw,<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></blockquote><div><br></div><div>Once this is all over, intel_offset_S8 should be updated to just use the ISL convention.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                               x + image_x + map->x,<br>
                                               y + image_y + map->y,<br>
                                               brw->has_swizzling);<br>
@@ -3298,6 +3304,12 @@ 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, GL_MAP_WRITE_BIT);<br>
@@ -3306,7 +3318,7 @@ intel_miptree_unmap_s8(struct brw_context *brw,<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>
@@ -3405,6 +3417,12 @@ 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, GL_MAP_READ_BIT);<br>
       uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_READ_BIT);<br>
@@ -3419,7 +3437,7 @@ intel_miptree_map_<wbr>depthstencil(struct brw_context *brw,<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>
@@ -3466,6 +3484,12 @@ 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, GL_MAP_WRITE_BIT);<br>
       uint32_t *z_map = intel_miptree_map_raw(brw, z_mt, GL_MAP_WRITE_BIT);<br>
@@ -3479,7 +3503,7 @@ intel_miptree_unmap_<wbr>depthstencil(struct brw_context *brw,<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>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<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>