<div dir="ltr">Over-all, this looks fine.  However, I'd like to see a reply to my comments on patch 4 before I give it a review.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 1:46 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>gen7_misc_state.c   | 20 +++++---------<br>
 src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c  | 26 ++++++------------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 38 ++++++++++++++++-----------<br>
 3 files changed, 38 insertions(+), 46 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c b/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c<br>
index 43422900e2..c0cb7470bf 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c<br>
@@ -83,7 +83,8 @@ gen7_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
       break;<br>
    case GL_TEXTURE_3D:<br>
       assert(mt);<br>
-      depth = MAX2(mt->logical_depth0, 1);<br>
+      depth = mt->surf.size > 0 ? mt->surf.logical_level0_px.<wbr>depth :<br>
+                                  MAX2(mt->logical_depth0, 1);<br>
       /* fallthrough */<br>
    default:<br>
       surftype = translate_tex_target(gl_<wbr>target);<br>
@@ -94,7 +95,10 @@ gen7_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
<br>
    lod = irb ? irb->mt_level - irb->mt->first_level : 0;<br>
<br>
-   if (mt) {<br>
+   if (mt && mt->surf.size > 0) {<br>
+      width = mt->surf.logical_level0_px.<wbr>width;<br>
+      height = mt->surf.logical_level0_px.<wbr>height;<br>
+   } else if (mt) {<br>
       width = mt->logical_width0;<br>
       height = mt->logical_height0;<br>
    }<br>
@@ -170,19 +174,9 @@ gen7_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
<br>
       BEGIN_BATCH(3);<br>
       OUT_BATCH(GEN7_3DSTATE_<wbr>STENCIL_BUFFER << 16 | (3 - 2));<br>
-      /* The stencil buffer has quirky pitch requirements.  From the<br>
-       * Sandybridge PRM, Volume 2 Part 1, page 329 (3DSTATE_STENCIL_BUFFER<br>
-       * dword 1 bits 16:0 - Surface Pitch):<br>
-       *<br>
-       *    The pitch must be set to 2x the value computed based on width, as<br>
-       *    the stencil buffer is stored with two rows interleaved.<br>
-       *<br>
-       * While the Ivybridge PRM lacks this comment, the BSpec contains the<br>
-       * same text, and experiments indicate that this is necessary.<br>
-       */<br>
       OUT_BATCH(enabled |<br>
                 mocs << 25 |<br>
-               (2 * stencil_mt->surf.row_pitch - 1));<br>
+               (stencil_mt->surf.row_pitch - 1));<br>
       OUT_RELOC(stencil_mt->bo,<br>
                I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
                0);<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c b/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
index 9cb0d07688..c934d0d21a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
@@ -111,25 +111,11 @@ emit_depth_packets(struct brw_context *brw,<br>
    } else {<br>
       BEGIN_BATCH(5);<br>
       OUT_BATCH(GEN7_3DSTATE_<wbr>STENCIL_BUFFER << 16 | (5 - 2));<br>
-      /* The stencil buffer has quirky pitch requirements.  From the Graphics<br>
-       * BSpec: vol2a.11 3D Pipeline Windower > Early Depth/Stencil Processing<br>
-       * > Depth/Stencil Buffer State > 3DSTATE_STENCIL_BUFFER [DevIVB+],<br>
-       * field "Surface Pitch":<br>
-       *<br>
-       *    The pitch must be set to 2x the value computed based on width, as<br>
-       *    the stencil buffer is stored with two rows interleaved.<br>
-       *<br>
-       * (Note that it is not 100% clear whether this intended to apply to<br>
-       * Gen7; the BSpec flags this comment as "DevILK,DevSNB" (which would<br>
-       * imply that it doesn't), however the comment appears on a "DevIVB+"<br>
-       * page (which would imply that it does).  Experiments with the hardware<br>
-       * indicate that it does.<br>
-       */<br>
       OUT_BATCH(HSW_STENCIL_ENABLED | mocs_wb << 22 |<br>
-                (2 * stencil_mt->surf.row_pitch - 1));<br>
+                (stencil_mt->surf.row_pitch - 1));<br>
       OUT_RELOC64(stencil_mt->bo,<br>
                   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);<br>
-      OUT_BATCH(stencil_mt ? stencil_mt->qpitch >> 2 : 0);<br>
+      OUT_BATCH(stencil_mt->surf.<wbr>array_pitch_el_rows >> 2);<br>
       ADVANCE_BATCH();<br>
    }<br>
<br>
@@ -189,7 +175,8 @@ gen8_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
       break;<br>
    case GL_TEXTURE_3D:<br>
       assert(mt);<br>
-      depth = MAX2(mt->logical_depth0, 1);<br>
+      depth = mt->surf.size > 0 ? mt->surf.logical_level0_px.<wbr>depth :<br>
+                                  MAX2(mt->logical_depth0, 1);<br>
       surftype = translate_tex_target(gl_<wbr>target);<br>
       break;<br>
    case GL_TEXTURE_1D_ARRAY:<br>
@@ -212,7 +199,10 @@ gen8_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
<br>
    lod = irb ? irb->mt_level - irb->mt->first_level : 0;<br>
<br>
-   if (mt) {<br>
+   if (mt && mt->surf.size > 0) {<br>
+      width = mt->surf.logical_level0_px.<wbr>width;<br>
+      height = mt->surf.logical_level0_px.<wbr>height;<br>
+   } else if (mt) {<br>
       width = mt->logical_width0;<br>
       height = mt->logical_height0;<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 1b8c0da80d..adaa6a94ab 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>
@@ -817,7 +817,7 @@ miptree_create(struct brw_context *brw,<br>
                GLuint num_samples,<br>
                uint32_t layout_flags)<br>
 {<br>
-   if (brw->gen == 6 && format == MESA_FORMAT_S_UINT8)<br>
+   if (format == MESA_FORMAT_S_UINT8)<br>
       return make_surface(brw, target, format, first_level, last_level,<br>
                           width0, height0, depth0, num_samples,<br>
                           ISL_TILING_W_BIT,<br>
@@ -947,7 +947,7 @@ intel_miptree_create_for_bo(<wbr>struct brw_context *brw,<br>
    uint32_t tiling, swizzle;<br>
    const GLenum target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;<br>
<br>
-   if (brw->gen == 6 && format == MESA_FORMAT_S_UINT8) {<br>
+   if (format == MESA_FORMAT_S_UINT8) {<br>
       mt = make_surface(brw, target, MESA_FORMAT_S_UINT8,<br>
                         0, 0, width, height, depth, 1,<br>
                         ISL_TILING_W_BIT,<br>
@@ -2941,36 +2941,44 @@ intel_update_r8stencil(struct brw_context *brw,<br>
    if (!src || brw->gen >= 8 || !src->r8stencil_needs_update)<br>
       return;<br>
<br>
+   assert(src->surf.size > 0);<br>
+<br>
    if (!mt->r8stencil_mt) {<br>
       const uint32_t r8stencil_flags =<br>
          MIPTREE_LAYOUT_ACCELERATED_<wbr>UPLOAD | MIPTREE_LAYOUT_TILING_Y |<br>
          MIPTREE_LAYOUT_DISABLE_AUX;<br>
       assert(brw->gen > 6); /* Handle MIPTREE_LAYOUT_GEN6_HIZ_<wbr>STENCIL */<br>
-      mt->r8stencil_mt = intel_miptree_create(brw,<br>
-                                              src->target,<br>
-                                              MESA_FORMAT_R_UINT8,<br>
-                                              src->first_level,<br>
-                                              src->last_level,<br>
-                                              src->logical_width0,<br>
-                                              src->logical_height0,<br>
-                                              src->logical_depth0,<br>
-                                              src->surf.samples,<br>
-                                              r8stencil_flags);<br>
+      mt->r8stencil_mt = intel_miptree_create(<br>
+                            brw,<br>
+                            src->target,<br>
+                            MESA_FORMAT_R_UINT8,<br>
+                            src->first_level, src->last_level,<br>
+                            src->surf.logical_level0_px.<wbr>width,<br>
+                            src->surf.logical_level0_px.<wbr>height,<br>
+                            src->surf.dim == ISL_SURF_DIM_3D ?<br>
+                               src->surf.logical_level0_px.<wbr>depth :<br>
+                               src->surf.logical_level0_px.<wbr>array_len,<br>
+                            src->surf.samples,<br>
+                            r8stencil_flags);<br>
       assert(mt->r8stencil_mt);<br>
    }<br>
<br>
    struct intel_mipmap_tree *dst = mt->r8stencil_mt;<br>
<br>
    for (int level = src->first_level; level <= src->last_level; level++) {<br>
-      const unsigned depth = src->level[level].depth;<br>
+      const unsigned depth = src->surf.dim == ISL_SURF_DIM_3D ?<br>
+         minify(src->surf.phys_level0_<wbr>sa.depth, level) :<br>
+         src->surf.phys_level0_sa.<wbr>array_len;<br>
<br>
       for (unsigned layer = 0; layer < depth; layer++) {<br>
          brw_blorp_copy_miptrees(brw,<br>
                                  src, level, layer,<br>
                                  dst, level, layer,<br>
                                  0, 0, 0, 0,<br>
-                                 minify(src->logical_width0, level),<br>
-                                 minify(src->logical_height0, level));<br>
+                                 minify(src->surf.logical_<wbr>level0_px.width,<br>
+                                        level),<br>
+                                 minify(src->surf.logical_<wbr>level0_px.height,<br>
+                                        level));<br>
       }<br>
    }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<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>