<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jul 21, 2017 at 12:15 PM, Pohjolainen, Topi <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"><div class="HOEnZb"><div class="h5">On Fri, Jul 21, 2017 at 11:43:16AM -0700, Jason Ekstrand wrote:<br>
> On Fri, Jul 21, 2017 at 8:01 AM, Topi Pohjolainen <<br>
> <a href="mailto:topi.pohjolainen@gmail.com">topi.pohjolainen@gmail.com</a>> wrote:<br>
><br>
> > 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>Makefile.sources       |   1 -<br>
> >  src/mesa/drivers/dri/i965/brw_<wbr>blorp.c            |   8 +-<br>
> >  src/mesa/drivers/dri/i965/brw_<wbr>tex_layout.c       | 735<br>
> > -----------------------<br>
> >  src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c |  23 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>gen6_depth_state.c     |   8 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c      |   8 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c     |   8 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_blit.c           |  33 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_fbo.c            |  44 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c    | 583 ++----------------<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h    | 241 --------<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_screen.c         |  13 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c      |  29 +-<br>
> >  src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c   |   8 +-<br>
> >  14 files changed, 96 insertions(+), 1646 deletions(-)<br>
> >  delete mode 100644 src/mesa/drivers/dri/i965/brw_<wbr>tex_layout.c<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> > b/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> > index 431712f76e..425c883de8 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>Makefile.sources<br>
> > @@ -51,7 +51,6 @@ i965_FILES = \<br>
> >         brw_tcs_surface_state.c \<br>
> >         brw_tes.c \<br>
> >         brw_tes_surface_state.c \<br>
> > -       brw_tex_layout.c \<br>
> >         brw_urb.c \<br>
> >         brw_util.c \<br>
> >         brw_util.h \<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> > index 474dfc61c1..e50173d442 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
> > @@ -147,13 +147,7 @@ blorp_surf_for_miptree(struct brw_context *brw,<br>
> >           intel_miptree_check_level_<wbr>layer(mt, *level, start_layer + i);<br>
> >     }<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      surf->surf = &mt->surf;<br>
> > -   } else {<br>
> > -      intel_miptree_get_isl_surf(<wbr>brw, mt, &tmp_surfs[0]);<br>
> > -      surf->surf = &tmp_surfs[0];<br>
> > -   }<br>
> > -<br>
> > +   surf->surf = &mt->surf;<br>
> >     surf->addr = (struct blorp_address) {<br>
> >        .buffer = mt->bo,<br>
> >        .offset = mt->offset,<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_tex_layout.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>brw_tex_layout.c<br>
> > deleted file mode 100644<br>
> > index f3b5a17c88..0000000000<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>brw_tex_layout.c<br>
> > +++ /dev/null<br>
> > @@ -1,735 +0,0 @@<br>
> > -/*<br>
> > - * Copyright 2006 VMware, Inc.<br>
> > - * Copyright © 2006 Intel Corporation<br>
> > - *<br>
> > - * Permission is hereby granted, free of charge, to any person obtaining<br>
> > - * a copy of this software and associated documentation files (the<br>
> > - * "Software"), to deal in the Software without restriction, including<br>
> > - * without limitation the rights to use, copy, modify, merge, publish,<br>
> > - * distribute, sublicense, and/or sell copies of the Software, and to<br>
> > - * permit persons to whom the Software is furnished to do so, subject to<br>
> > - * the following conditions:<br>
> > - *<br>
> > - * The above copyright notice and this permission notice (including the<br>
> > - * next paragraph) shall be included in all copies or substantial<br>
> > - * portions of the Software.<br>
> > - *<br>
> > - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> > - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> > - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
> > - * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE<br>
> > - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION<br>
> > - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION<br>
> > - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
> > - */<br>
> > -<br>
> > -/**<br>
> > - * \file brw_tex_layout.cpp<br>
> > - *<br>
> > - * Code to lay out images in a mipmap tree.<br>
> > - *<br>
> > - * \author Keith Whitwell <<a href="mailto:keithw@vmware.com">keithw@vmware.com</a>><br>
> > - * \author Michel Dänzer <<a href="mailto:daenzer@vmware.com">daenzer@vmware.com</a>><br>
> > - */<br>
> > -<br>
> > -#include "intel_mipmap_tree.h"<br>
> > -#include "brw_context.h"<br>
> > -#include "main/macros.h"<br>
> > -#include "main/glformats.h"<br>
> > -<br>
> > -#define FILE_DEBUG_FLAG DEBUG_MIPTREE<br>
> > -<br>
> > -static unsigned int<br>
> > -intel_horizontal_texture_<wbr>alignment_unit(struct brw_context *brw,<br>
> > -                                        struct intel_mipmap_tree *mt,<br>
> > -                                        uint32_t layout_flags)<br>
> > -{<br>
> > -   if (layout_flags & MIPTREE_LAYOUT_FORCE_HALIGN16)<br>
> > -      return 16;<br>
> > -<br>
> > -   /**<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    * |                                        | alignment unit width<br>
> > ("i") |<br>
> > -    * | Surface Property<br>
> >  |-----------------------------<wbr>|<br>
> > -    * |                                        | 915 | 965 | ILK | SNB |<br>
> > IVB |<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    * | YUV 4:2:2 format                       |  8  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * | BC1-5 compressed format (DXTn/S3TC)    |  4  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * | FXT1  compressed format                |  8  |  8  |  8  |  8  |<br>
> > 8  |<br>
> > -    * | Depth Buffer (16-bit)                  |  4  |  4  |  4  |  4  |<br>
> > 8  |<br>
> > -    * | Depth Buffer (other)                   |  4  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * | Separate Stencil Buffer                | N/A | N/A |  8  |  8  |<br>
> > 8  |<br>
> > -    * | All Others                             |  4  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    *<br>
> > -    * On IVB+, non-special cases can be overridden by setting the<br>
> > SURFACE_STATE<br>
> > -    * "Surface Horizontal Alignment" field to HALIGN_4 or HALIGN_8.<br>
> > -    */<br>
> > -<br>
> > -   if (brw->gen >= 7 && mt->format == MESA_FORMAT_Z_UNORM16)<br>
> > -      return 8;<br>
> > -<br>
> > -   return 4;<br>
> > -}<br>
> > -<br>
> > -static unsigned int<br>
> > -intel_vertical_texture_<wbr>alignment_unit(struct brw_context *brw,<br>
> > -                                      const struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   /**<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    * |                                        | alignment unit height<br>
> > ("j") |<br>
> > -    * | Surface Property<br>
> >  |-----------------------------<wbr>|<br>
> > -    * |                                        | 915 | 965 | ILK | SNB |<br>
> > IVB |<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    * | BC1-5 compressed format (DXTn/S3TC)    |  4  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * | FXT1  compressed format                |  4  |  4  |  4  |  4  |<br>
> > 4  |<br>
> > -    * | Depth Buffer                           |  2  |  2  |  2  |  4  |<br>
> > 4  |<br>
> > -    * | Separate Stencil Buffer                | N/A | N/A | N/A |  4  |<br>
> > 8  |<br>
> > -    * | Multisampled (4x or 8x) render target  | N/A | N/A | N/A |  4  |<br>
> > 4  |<br>
> > -    * | All Others                             |  2  |  2  |  2  |  *  |<br>
> > *  |<br>
> > -    * +-----------------------------<wbr>------------------------------<br>
> > -----------+<br>
> > -    *<br>
> > -    * Where "*" means either VALIGN_2 or VALIGN_4 depending on the<br>
> > setting of<br>
> > -    * the SURFACE_STATE "Surface Vertical Alignment" field.<br>
> > -    */<br>
> > -<br>
> > -   /* Broadwell only supports VALIGN of 4, 8, and 16.  The BSpec says 4<br>
> > -    * should always be used, except for stencil buffers, which should be<br>
> > 8.<br>
> > -    */<br>
> > -   if (brw->gen >= 8)<br>
> > -      return 4;<br>
> > -<br>
> > -   if (mt->surf.samples > 1)<br>
> > -      return 4;<br>
> > -<br>
> > -   GLenum base_format = _mesa_get_format_base_format(<wbr>mt->format);<br>
> > -<br>
> > -   if (brw->gen >= 6 &&<br>
> > -       (base_format == GL_DEPTH_COMPONENT ||<br>
> > -       base_format == GL_DEPTH_STENCIL)) {<br>
> > -      return 4;<br>
> > -   }<br>
> > -<br>
> > -   if (brw->gen == 7) {<br>
> > -      /* On Gen7, we prefer a vertical alignment of 4 when possible,<br>
> > because<br>
> > -       * that allows Y tiled render targets.<br>
> > -       *<br>
> > -       * From the Ivy Bridge PRM, Vol4 Part1 2.12.2.1 (SURFACE_STATE for<br>
> > most<br>
> > -       * messages), on p64, under the heading "Surface Vertical<br>
> > Alignment":<br>
> > -       *<br>
> > -       *     Value of 1 [VALIGN_4] is not supported for format<br>
> > YCRCB_NORMAL<br>
> > -       *     (0x182), YCRCB_SWAPUVY (0x183), YCRCB_SWAPUV (0x18f),<br>
> > YCRCB_SWAPY<br>
> > -       *     (0x190)<br>
> > -       *<br>
> > -       *     VALIGN_4 is not supported for surface format R32G32B32_FLOAT.<br>
> > -       */<br>
> > -      if (base_format == GL_YCBCR_MESA || mt->format ==<br>
> > MESA_FORMAT_RGB_FLOAT32)<br>
> > -         return 2;<br>
> > -<br>
> > -      return 4;<br>
> > -   }<br>
> > -<br>
> > -   return 2;<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -gen9_miptree_layout_1d(struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   unsigned x = 0;<br>
> > -   unsigned width = mt->physical_width0;<br>
> > -   unsigned depth = mt->physical_depth0; /* number of array layers. */<br>
> > -<br>
> > -   /* When this layout is used the horizontal alignment is fixed at 64<br>
> > and the<br>
> > -    * hardware ignores the value given in the surface state<br>
> > -    */<br>
> > -   const unsigned int halign = 64;<br>
> > -<br>
> > -   mt->total_height = mt->physical_height0;<br>
> > -   mt->total_width = 0;<br>
> > -<br>
> > -   for (unsigned level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > -      unsigned img_width;<br>
> > -<br>
> > -      intel_miptree_set_level_info(<wbr>mt, level, x, 0, depth);<br>
> > -<br>
> > -      img_width = ALIGN(width, halign);<br>
> > -<br>
> > -      mt->total_width = MAX2(mt->total_width, x + img_width);<br>
> > -<br>
> > -      x += img_width;<br>
> > -<br>
> > -      width = minify(width, 1);<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -brw_miptree_layout_2d(struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   unsigned x = 0;<br>
> > -   unsigned y = 0;<br>
> > -   unsigned width = mt->physical_width0;<br>
> > -   unsigned height = mt->physical_height0;<br>
> > -   /* Number of layers of array texture or slices of 3d texture (gen9+).<br>
> > */<br>
> > -   unsigned depth = mt->physical_depth0;<br>
> > -   unsigned int bw, bh;<br>
> > -<br>
> > -   _mesa_get_format_block_size(<wbr>mt->format, &bw, &bh);<br>
> > -<br>
> > -   mt->total_width = mt->physical_width0;<br>
> > -   mt->total_width = ALIGN_NPOT(mt->total_width, bw);<br>
> > -<br>
> > -   /* May need to adjust width to accommodate the placement of<br>
> > -    * the 2nd mipmap.  This occurs when the alignment<br>
> > -    * constraints of mipmap placement push the right edge of the<br>
> > -    * 2nd mipmap out past the width of its parent.<br>
> > -    */<br>
> > -   if (mt->first_level != mt->last_level) {<br>
> > -       unsigned mip1_width;<br>
> > -<br>
> > -      mip1_width = ALIGN_NPOT(minify(mt-><wbr>physical_width0, 1),<br>
> > mt->halign) +<br>
> > -                   ALIGN_NPOT(minify(mt-><wbr>physical_width0, 2), bw);<br>
> > -<br>
> > -      if (mip1_width > mt->total_width)<br>
> > -         mt->total_width = mip1_width;<br>
> > -   }<br>
> > -<br>
> > -   mt->total_width /= bw;<br>
> > -   mt->total_height = 0;<br>
> > -<br>
> > -   for (unsigned level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > -      unsigned img_height;<br>
> > -<br>
> > -      intel_miptree_set_level_info(<wbr>mt, level, x, y, depth);<br>
> > -<br>
> > -      img_height = ALIGN_NPOT(height, mt->valign);<br>
> > -      img_height /= bh;<br>
> > -<br>
> > -      if (mt->array_layout == ALL_SLICES_AT_EACH_LOD) {<br>
> > -         /* Compact arrays with separated miplevels */<br>
> > -         img_height *= depth;<br>
> > -      }<br>
> > -<br>
> > -      /* Because the images are packed better, the final offset<br>
> > -       * might not be the maximal one:<br>
> > -       */<br>
> > -      mt->total_height = MAX2(mt->total_height, y + img_height);<br>
> > -<br>
> > -      /* Layout_below: step right after second mipmap.<br>
> > -       *<br>
> > -       * For Sandy Bridge HiZ and stencil, we always step down.<br>
> > -       */<br>
> > -      if (level == mt->first_level + 1) {<br>
> > -        x += ALIGN_NPOT(width, mt->halign) / bw;<br>
> > -      } else {<br>
> > -        y += img_height;<br>
> > -      }<br>
> > -<br>
> > -      width  = minify(width, 1);<br>
> > -      height = minify(height, 1);<br>
> > -<br>
> > -      if (mt->target == GL_TEXTURE_3D)<br>
> > -         depth = minify(depth, 1);<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -brw_miptree_layout_gen6_hiz_<wbr>stencil(struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   unsigned x = 0;<br>
> > -   unsigned y = 0;<br>
> > -   unsigned width = mt->physical_width0;<br>
> > -   unsigned height = mt->physical_height0;<br>
> > -   /* Number of layers of array texture. */<br>
> > -   unsigned depth = mt->physical_depth0;<br>
> > -   unsigned tile_width, tile_height, bw, bh;<br>
> > -<br>
> > -   if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > -      bw = bh = 1;<br>
> > -      /* W-tiled */<br>
> > -      tile_width = 64;<br>
> > -      tile_height = 64;<br>
> > -   } else {<br>
> > -      assert(_mesa_get_format_base_<wbr>format(mt->format) ==<br>
> > GL_DEPTH_COMPONENT ||<br>
> > -             _mesa_get_format_base_format(<wbr>mt->format) ==<br>
> > GL_DEPTH_STENCIL);<br>
> > -      /* Each 128-bit HiZ block corresponds to a region of of 8x4 depth<br>
> > -       * samples.  Each cache line in the Y-Tiled HiZ image contains 2x2<br>
> > HiZ<br>
> > -       * blocks.  Therefore, each Y-tiled cache line corresponds to an<br>
> > 16x8<br>
> > -       * region in the depth surface.  Since we're representing it as<br>
> > -       * RGBA_FLOAT32, the miptree calculations will think that each cache<br>
> > -       * line is 1x4 pixels.  Therefore, we need a scale-down factor of<br>
> > 16x2<br>
> > -       * and a vertical alignment of 2.<br>
> > -       */<br>
> > -      mt->cpp = 16;<br>
> > -      bw = 16;<br>
> > -      bh = 2;<br>
> > -      /* Y-tiled */<br>
> > -      tile_width = 128 / mt->cpp;<br>
> > -      tile_height = 32;<br>
> > -   }<br>
> > -<br>
> > -   mt->total_width = 0;<br>
> > -   mt->total_height = 0;<br>
> > -<br>
> > -   for (unsigned level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > -      intel_miptree_set_level_info(<br>
> > -         mt, level, x, y,<br>
> > -         mt->target == GL_TEXTURE_3D ? minify(depth, level) : depth);<br>
> > -<br>
> > -      const unsigned img_width = ALIGN(DIV_ROUND_UP(width, bw),<br>
> > mt->halign);<br>
> > -      const unsigned img_height =<br>
> > -         ALIGN(DIV_ROUND_UP(height, bh), mt->valign) * depth;<br>
> > -<br>
> > -      mt->total_width = MAX2(mt->total_width, x + img_width);<br>
> > -      mt->total_height = MAX2(mt->total_height, y + img_height);<br>
> > -<br>
> > -      if (level == mt->first_level) {<br>
> > -         y += ALIGN(img_height, tile_height);<br>
> > -      } else {<br>
> > -         x += ALIGN(img_width, tile_width);<br>
> > -      }<br>
> > -<br>
> > -      /* We only minify the width.  We want qpitch to match for all<br>
> > miplevels<br>
> > -       * because the hardware doesn't know we aren't on LOD0.<br>
> > -       */<br>
> > -      width = minify(width, 1);<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -unsigned<br>
> > -brw_miptree_get_horizontal_<wbr>slice_pitch(const struct brw_context *brw,<br>
> > -                                       const struct intel_mipmap_tree *mt,<br>
> > -                                       unsigned level)<br>
> > -{<br>
> > -   if ((brw->gen < 9 && mt->target == GL_TEXTURE_3D) ||<br>
> > -       (brw->gen == 4 && mt->target == GL_TEXTURE_CUBE_MAP)) {<br>
> > -      return ALIGN_NPOT(minify(mt-><wbr>physical_width0, level), mt->halign);<br>
> > -   } else {<br>
> > -      return 0;<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -static unsigned<br>
> > -brw_miptree_get_vertical_<wbr>slice_pitch(const struct brw_context *brw,<br>
> > -                                     const struct intel_mipmap_tree *mt,<br>
> > -                                     unsigned level)<br>
> > -{<br>
> > -   assert(mt->array_layout != GEN6_HIZ_STENCIL || brw->gen == 6);<br>
> > -<br>
> > -   if (brw->gen >= 9) {<br>
> > -      /* ALL_SLICES_AT_EACH_LOD isn't supported on Gen8+ but this code<br>
> > will<br>
> > -       * effectively end up with a packed qpitch anyway whenever<br>
> > -       * mt->first_level == mt->last_level.<br>
> > -       */<br>
> > -      assert(mt->array_layout != ALL_SLICES_AT_EACH_LOD);<br>
> > -<br>
> > -      /* On Gen9 we can pick whatever qpitch we like as long as it's<br>
> > aligned<br>
> > -       * to the vertical alignment so we don't need to add any extra rows.<br>
> > -       */<br>
> > -      unsigned qpitch = mt->total_height;<br>
> > -<br>
> > -      /* If the surface might be used as a stencil buffer or HiZ buffer<br>
> > then<br>
> > -       * it needs to be a multiple of 8.<br>
> > -       */<br>
> > -      const GLenum base_format = _mesa_get_format_base_format(<br>
> > mt->format);<br>
> > -      if (_mesa_is_depth_or_stencil_<wbr>format(base_format))<br>
> > -         qpitch = ALIGN(qpitch, 8);<br>
> > -<br>
> > -      /* 3D textures need to be aligned to the tile height. At this point<br>
> > we<br>
> > -       * don't know which tiling will be used so let's just align it to 32<br>
> > -       */<br>
> > -      if (mt->target == GL_TEXTURE_3D)<br>
> > -         qpitch = ALIGN(qpitch, 32);<br>
> > -<br>
> > -      return qpitch;<br>
> > -<br>
> > -   } else if (mt->target == GL_TEXTURE_3D ||<br>
> > -              (brw->gen == 4 && mt->target == GL_TEXTURE_CUBE_MAP) ||<br>
> > -              mt->array_layout == ALL_SLICES_AT_EACH_LOD) {<br>
> > -      return ALIGN_NPOT(minify(mt-><wbr>physical_height0, level), mt->valign);<br>
> > -<br>
> > -   } else if (mt->array_layout == GEN6_HIZ_STENCIL) {<br>
> > -      /* For HiZ and stencil on Sandy Bridge, we don't minify the height.<br>
> > */<br>
> > -      if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > -         return ALIGN(mt->physical_height0, mt->valign);<br>
> > -      } else {<br>
> > -         /* HiZ has a vertical scale factor of 2. */<br>
> > -         return ALIGN(DIV_ROUND_UP(mt-><wbr>physical_height0, 2), mt->valign);<br>
> > -      }<br>
> > -<br>
> > -   } else {<br>
> > -      const unsigned h0 = ALIGN_NPOT(mt->physical_<wbr>height0, mt->valign);<br>
> > -      const unsigned h1 = ALIGN_NPOT(minify(mt-><wbr>physical_height0, 1),<br>
> > mt->valign);<br>
> > -<br>
> > -      return h0 + h1 + (brw->gen >= 7 ? 12 : 11) * mt->valign;<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -align_cube(struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   /* The 965's sampler lays cachelines out according to how accesses<br>
> > -    * in the texture surfaces run, so they may be "vertical" through<br>
> > -    * memory.  As a result, the docs say in Surface Padding Requirements:<br>
> > -    * Sampling Engine Surfaces that two extra rows of padding are<br>
> > required.<br>
> > -    */<br>
> > -   if (mt->target == GL_TEXTURE_CUBE_MAP)<br>
> > -      mt->total_height += 2;<br>
> > -}<br>
> > -<br>
> > -bool<br>
> > -gen9_use_linear_1d_layout(<wbr>const struct brw_context *brw,<br>
> > -                          const struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   /* On Gen9+ the mipmap levels of a 1D surface are all laid out in a<br>
> > -    * horizontal line. This isn't done for depth/stencil buffers however<br>
> > -    * because those will be using a tiled layout<br>
> > -    */<br>
> > -   if (brw->gen >= 9 &&<br>
> > -       (mt->target == GL_TEXTURE_1D ||<br>
> > -        mt->target == GL_TEXTURE_1D_ARRAY)) {<br>
> > -      GLenum base_format = _mesa_get_format_base_format(<wbr>mt->format);<br>
> > -<br>
> > -      if (base_format != GL_DEPTH_COMPONENT &&<br>
> > -          base_format != GL_DEPTH_STENCIL &&<br>
> > -          base_format != GL_STENCIL_INDEX)<br>
> > -         return true;<br>
> > -   }<br>
> > -<br>
> > -   return false;<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -brw_miptree_layout_texture_<wbr>array(struct brw_context *brw,<br>
> > -                                struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   unsigned height = mt->physical_height0;<br>
> > -   bool layout_1d = gen9_use_linear_1d_layout(brw, mt);<br>
> > -   int physical_qpitch;<br>
> > -<br>
> > -   if (layout_1d)<br>
> > -      gen9_miptree_layout_1d(mt);<br>
> > -   else if (mt->array_layout == GEN6_HIZ_STENCIL)<br>
> > -      brw_miptree_layout_gen6_hiz_<wbr>stencil(mt);<br>
> > -   else<br>
> > -      brw_miptree_layout_2d(mt);<br>
> > -<br>
> > -   if (layout_1d) {<br>
> > -      physical_qpitch = 1;<br>
> > -      /* When using the horizontal layout the qpitch specifies the<br>
> > distance in<br>
> > -       * pixels between array slices. The total_width is forced to be a<br>
> > -       * multiple of the horizontal alignment in brw_miptree_layout_1d (in<br>
> > -       * this case it's always 64). The vertical alignment is ignored.<br>
> > -       */<br>
> > -      mt->qpitch = mt->total_width;<br>
> > -   } else {<br>
> > -      mt->qpitch = brw_miptree_get_vertical_<wbr>slice_pitch(brw, mt, 0);<br>
> > -      /* Unlike previous generations the qpitch is a multiple of the<br>
> > -       * compressed block size on Gen9 so physical_qpitch matches<br>
> > mt->qpitch.<br>
> > -       */<br>
> > -      physical_qpitch = (mt->compressed && brw->gen < 9 ? mt->qpitch / 4 :<br>
> > -                         mt->qpitch);<br>
> > -   }<br>
> > -<br>
> > -   for (unsigned level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > -      unsigned img_height;<br>
> > -      img_height = ALIGN_NPOT(height, mt->valign);<br>
> > -      if (mt->compressed)<br>
> > -         img_height /= mt->valign;<br>
> > -<br>
> > -      for (unsigned q = 0; q < mt->level[level].depth; q++) {<br>
> > -         if (mt->array_layout == ALL_SLICES_AT_EACH_LOD) {<br>
> > -            intel_miptree_set_image_<wbr>offset(mt, level, q, 0, q *<br>
> > img_height);<br>
> > -         } else {<br>
> > -            intel_miptree_set_image_<wbr>offset(mt, level, q, 0, q *<br>
> > physical_qpitch);<br>
> > -         }<br>
> > -      }<br>
> > -      height = minify(height, 1);<br>
> > -   }<br>
> > -   if (mt->array_layout == ALL_LOD_IN_EACH_SLICE)<br>
> > -      mt->total_height = physical_qpitch * mt->physical_depth0;<br>
> > -<br>
> > -   align_cube(mt);<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -brw_miptree_layout_texture_<wbr>3d(struct brw_context *brw,<br>
> > -                              struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   mt->total_width = 0;<br>
> > -   mt->total_height = 0;<br>
> > -<br>
> > -   unsigned ysum = 0;<br>
> > -   unsigned bh, bw;<br>
> > -<br>
> > -   _mesa_get_format_block_size(<wbr>mt->format, &bw, &bh);<br>
> > -<br>
> > -   for (unsigned level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > -      unsigned WL = MAX2(mt->physical_width0 >> level, 1);<br>
> > -      unsigned HL = MAX2(mt->physical_height0 >> level, 1);<br>
> > -      unsigned DL = MAX2(mt->physical_depth0 >> level, 1);<br>
> > -      unsigned wL = ALIGN_NPOT(WL, mt->halign);<br>
> > -      unsigned hL = ALIGN_NPOT(HL, mt->valign);<br>
> > -<br>
> > -      if (mt->target == GL_TEXTURE_CUBE_MAP)<br>
> > -         DL = 6;<br>
> > -<br>
> > -      intel_miptree_set_level_info(<wbr>mt, level, 0, 0, DL);<br>
> > -<br>
> > -      for (unsigned q = 0; q < DL; q++) {<br>
> > -         unsigned x = (q % (1 << level)) * wL;<br>
> > -         unsigned y = ysum + (q >> level) * hL;<br>
> > -<br>
> > -         intel_miptree_set_image_<wbr>offset(mt, level, q, x / bw, y / bh);<br>
> > -         mt->total_width = MAX2(mt->total_width, (x + wL) / bw);<br>
> > -         mt->total_height = MAX2(mt->total_height, (y + hL) / bh);<br>
> > -      }<br>
> > -<br>
> > -      ysum += ALIGN(DL, 1 << level) / (1 << level) * hL;<br>
> > -   }<br>
> > -<br>
> > -   align_cube(mt);<br>
> > -}<br>
> > -<br>
> > -/**<br>
> > - * \brief Helper function for intel_miptree_create().<br>
> > - */<br>
> > -static enum isl_tiling<br>
> > -brw_miptree_choose_tiling(<wbr>struct brw_context *brw,<br>
> > -                          const struct intel_mipmap_tree *mt,<br>
> > -                          uint32_t layout_flags)<br>
> > -{<br>
> > -   if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > -      /* The stencil buffer is W tiled. However, we request from the<br>
> > kernel a<br>
> > -       * non-tiled buffer because the GTT is incapable of W fencing.<br>
> > -       */<br>
> > -      return ISL_TILING_LINEAR;<br>
> > -   }<br>
> > -<br>
> > -   /* Do not support changing the tiling for miptrees with pre-allocated<br>
> > BOs. */<br>
> > -   assert((layout_flags & MIPTREE_LAYOUT_FOR_BO) == 0);<br>
> > -<br>
> > -   /* Some usages may want only one type of tiling, like depth miptrees (Y<br>
> > -    * tiled), or temporary BOs for uploading data once (linear).<br>
> > -    */<br>
> > -   switch (layout_flags & MIPTREE_LAYOUT_TILING_ANY) {<br>
> > -   case MIPTREE_LAYOUT_TILING_ANY:<br>
> > -      break;<br>
> > -   case MIPTREE_LAYOUT_TILING_Y:<br>
> > -      return ISL_TILING_Y0;<br>
> > -   case MIPTREE_LAYOUT_TILING_NONE:<br>
> > -      return ISL_TILING_LINEAR;<br>
> > -   }<br>
> > -<br>
> > -   if (mt->surf.samples > 1) {<br>
> > -      /* From p82 of the Sandy Bridge PRM, dw3[1] of SURFACE_STATE ("Tiled<br>
> > -       * Surface"):<br>
> > -       *<br>
> > -       *   [DevSNB+]: For multi-sample render targets, this field must be<br>
> > -       *   1. MSRTs can only be tiled.<br>
> > -       *<br>
> > -       * Our usual reason for preferring X tiling (fast blits using the<br>
> > -       * blitting engine) doesn't apply to MSAA, since we'll generally be<br>
> > -       * downsampling or upsampling when blitting between the MSAA buffer<br>
> > -       * and another buffer, and the blitting engine doesn't support that.<br>
> > -       * So use Y tiling, since it makes better use of the cache.<br>
> > -       */<br>
> > -      return ISL_TILING_Y0;<br>
> > -   }<br>
> > -<br>
> > -   GLenum base_format = _mesa_get_format_base_format(<wbr>mt->format);<br>
> > -   if (base_format == GL_DEPTH_COMPONENT ||<br>
> > -       base_format == GL_DEPTH_STENCIL_EXT)<br>
> > -      return ISL_TILING_Y0;<br>
> > -<br>
> > -   /* 1D textures (and 1D array textures) don't get any benefit from<br>
> > tiling,<br>
> > -    * in fact it leads to a less efficient use of memory space and<br>
> > bandwidth<br>
> > -    * due to tile alignment.<br>
> > -    */<br>
> > -   if (mt->logical_height0 == 1)<br>
> > -      return ISL_TILING_LINEAR;<br>
> > -<br>
> > -   int minimum_pitch = mt->total_width * mt->cpp;<br>
> > -<br>
> > -   /* If the width is much smaller than a tile, don't bother tiling. */<br>
> > -   if (minimum_pitch < 64)<br>
> > -      return ISL_TILING_LINEAR;<br>
> > -<br>
> > -   if (ALIGN(minimum_pitch, 512) >= 32768) {<br>
> > -      perf_debug("%dx%d miptree too large to blit, falling back to<br>
> > untiled",<br>
> > -                 mt->total_width, mt->total_height);<br>
> > -      return ISL_TILING_LINEAR;<br>
> > -   }<br>
> > -<br>
> > -   /* Pre-gen6 doesn't have BLORP to handle Y-tiling, so use X-tiling. */<br>
> > -   if (brw->gen < 6)<br>
> > -      return ISL_TILING_X;<br>
> > -<br>
> > -   /* From the Sandybridge PRM, Volume 1, Part 2, page 32:<br>
> > -    * "NOTE: 128BPE Format Color Buffer ( render target ) MUST be either<br>
> > TileX<br>
> > -    *  or Linear."<br>
> > -    * 128 bits per pixel translates to 16 bytes per pixel. This is<br>
> > necessary<br>
> > -    * all the way back to 965, but is permitted on Gen7+.<br>
> > -    */<br>
> > -   if (brw->gen < 7 && mt->cpp >= 16)<br>
> > -      return ISL_TILING_X;<br>
> > -<br>
> > -   /* From the Ivy Bridge PRM, Vol4 Part1 2.12.2.1 (SURFACE_STATE for most<br>
> > -    * messages), on p64, under the heading "Surface Vertical Alignment":<br>
> > -    *<br>
> > -    *     This field must be set to VALIGN_4 for all tiled Y Render Target<br>
> > -    *     surfaces.<br>
> > -    *<br>
> > -    * So if the surface is renderable and uses a vertical alignment of 2,<br>
> > -    * force it to be X tiled.  This is somewhat conservative (it's<br>
> > possible<br>
> > -    * that the client won't ever render to this surface), but it's<br>
> > difficult<br>
> > -    * to know that ahead of time.  And besides, since we use a vertical<br>
> > -    * alignment of 4 as often as we can, this shouldn't happen very often.<br>
> > -    */<br>
> > -   if (brw->gen == 7 && mt->valign == 2 &&<br>
> > -       brw->mesa_format_supports_<wbr>render[mt->format]) {<br>
> > -      return ISL_TILING_X;<br>
> > -   }<br>
> > -<br>
> > -   return ISL_TILING_Y0;<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -intel_miptree_set_total_<wbr>width_height(struct brw_context *brw,<br>
> > -                                     struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   switch (mt->target) {<br>
> > -   case GL_TEXTURE_CUBE_MAP:<br>
> > -      if (brw->gen == 4) {<br>
> > -         /* Gen4 stores cube maps as 3D textures. */<br>
> > -         assert(mt->physical_depth0 == 6);<br>
> > -         brw_miptree_layout_texture_3d(<wbr>brw, mt);<br>
> > -      } else {<br>
> > -         /* All other hardware stores cube maps as 2D arrays. */<br>
> > -        brw_miptree_layout_texture_<wbr>array(brw, mt);<br>
> > -      }<br>
> > -      break;<br>
> > -<br>
> > -   case GL_TEXTURE_3D:<br>
> > -      if (brw->gen >= 9)<br>
> > -         brw_miptree_layout_texture_<wbr>array(brw, mt);<br>
> > -      else<br>
> > -         brw_miptree_layout_texture_3d(<wbr>brw, mt);<br>
> > -      break;<br>
> > -<br>
> > -   case GL_TEXTURE_1D_ARRAY:<br>
> > -   case GL_TEXTURE_2D_ARRAY:<br>
> > -   case GL_TEXTURE_2D_MULTISAMPLE_<wbr>ARRAY:<br>
> > -   case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
> > -      brw_miptree_layout_texture_<wbr>array(brw, mt);<br>
> > -      break;<br>
> > -<br>
> > -   default:<br>
> > -      switch (mt->surf.msaa_layout) {<br>
> > -      case ISL_MSAA_LAYOUT_ARRAY:<br>
> > -         brw_miptree_layout_texture_<wbr>array(brw, mt);<br>
> > -         break;<br>
> > -      case ISL_MSAA_LAYOUT_NONE:<br>
> > -      case ISL_MSAA_LAYOUT_INTERLEAVED:<br>
> > -         if (gen9_use_linear_1d_layout(<wbr>brw, mt))<br>
> > -            gen9_miptree_layout_1d(mt);<br>
> > -         else if (mt->array_layout == GEN6_HIZ_STENCIL)<br>
> > -            brw_miptree_layout_gen6_hiz_<wbr>stencil(mt);<br>
> > -         else<br>
> > -            brw_miptree_layout_2d(mt);<br>
> > -         break;<br>
> > -      }<br>
> > -      break;<br>
> > -   }<br>
> > -<br>
> > -   DBG("%s: %dx%dx%d\n", __func__,<br>
> > -       mt->total_width, mt->total_height, mt->cpp);<br>
> > -}<br>
> > -<br>
> > -static void<br>
> > -intel_miptree_set_alignment(<wbr>struct brw_context *brw,<br>
> > -                            struct intel_mipmap_tree *mt,<br>
> > -                            uint32_t layout_flags)<br>
> > -{<br>
> > -   /**<br>
> > -    * From the "Alignment Unit Size" section of various specs, namely:<br>
> > -    * - Gen3 Spec: "Memory Data Formats" Volume,         Section 1.20.1.4<br>
> > -    * - i965 and G45 PRMs:             Volume 1,         Section 6.17.3.4.<br>
> > -    * - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4<br>
> > -    * - BSpec (for Ivybridge and slight variations in separate stencil)<br>
> > -    */<br>
> > -<br>
> > -   if (mt->array_layout == GEN6_HIZ_STENCIL) {<br>
> > -      /* On gen6, we use GEN6_HIZ_STENCIL for stencil/hiz because the<br>
> > -       * hardware doesn't support multiple mip levels on stencil/hiz.<br>
> > -       *<br>
> > -       * PRM Vol 2, Part 1, 7.5.3 Hierarchical Depth Buffer:<br>
> > -       * "The hierarchical depth buffer does not support the LOD field"<br>
> > -       *<br>
> > -       * PRM Vol 2, Part 1, 7.5.4.1 Separate Stencil Buffer:<br>
> > -       * "The stencil depth buffer does not support the LOD field"<br>
> > -       */<br>
> > -      if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > -         /* Stencil uses W tiling, so we force W tiling alignment for the<br>
> > -          * ALL_SLICES_AT_EACH_LOD miptree layout.<br>
> > -          */<br>
> > -         mt->halign = 4;<br>
> > -         mt->valign = 2;<br>
> > -         assert((layout_flags & MIPTREE_LAYOUT_FORCE_HALIGN16) == 0);<br>
> > -      } else {<br>
> > -         /* See brw_miptree_layout_gen6_hiz_<wbr>stencil() */<br>
> > -         mt->halign = 1;<br>
> > -         mt->valign = 2;<br>
> > -      }<br>
> > -   } else if (mt->compressed) {<br>
> > -       /* The hardware alignment requirements for compressed textures<br>
> > -        * happen to match the block boundaries.<br>
> > -        */<br>
> > -      _mesa_get_format_block_size(<wbr>mt->format, &mt->halign, &mt->valign);<br>
> > -<br>
> > -      /* On Gen9+ we can pick our own alignment for compressed textures<br>
> > but it<br>
> > -       * has to be a multiple of the block size. The minimum alignment we<br>
> > can<br>
> > -       * pick is 4 so we effectively have to align to 4 times the block<br>
> > -       * size<br>
> > -       */<br>
> > -      if (brw->gen >= 9) {<br>
> > -         mt->halign *= 4;<br>
> > -         mt->valign *= 4;<br>
> > -      }<br>
> > -   } else if (mt->format == MESA_FORMAT_S_UINT8) {<br>
> > -      mt->halign = 8;<br>
> > -      mt->valign = brw->gen >= 7 ? 8 : 4;<br>
> > -   } else {<br>
> > -      mt->halign =<br>
> > -         intel_horizontal_texture_<wbr>alignment_unit(brw, mt, layout_flags);<br>
> > -      mt->valign = intel_vertical_texture_<wbr>alignment_unit(brw, mt);<br>
> > -   }<br>
> > -}<br>
> > -<br>
> > -bool<br>
> > -brw_miptree_layout(struct brw_context *brw,<br>
> > -                   struct intel_mipmap_tree *mt,<br>
> > -                   uint32_t layout_flags)<br>
> > -{<br>
> > -   intel_miptree_set_alignment(<wbr>brw, mt, layout_flags);<br>
> > -   intel_miptree_set_total_width_<wbr>height(brw, mt);<br>
> > -<br>
> > -   if (!mt->total_width || !mt->total_height)<br>
> > -      return false;<br>
> > -<br>
> > -   /* On Gen9+ the alignment values are expressed in multiples of the<br>
> > block<br>
> > -    * size<br>
> > -    */<br>
> > -   if (brw->gen >= 9) {<br>
> > -      unsigned int i, j;<br>
> > -      _mesa_get_format_block_size(<wbr>mt->format, &i, &j);<br>
> > -      mt->halign /= i;<br>
> > -      mt->valign /= j;<br>
> > -   }<br>
> > -<br>
> > -   if ((layout_flags & MIPTREE_LAYOUT_FOR_BO) == 0)<br>
> > -      mt->surf.tiling = brw_miptree_choose_tiling(brw, mt, layout_flags);<br>
> > -<br>
> > -   return true;<br>
> > -}<br>
> > -<br>
> > diff --git 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>
> > index d9daa8ec18..b3f0d73ecc 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>
> > @@ -80,15 +80,7 @@ get_isl_surf(struct brw_context *brw, struct<br>
> > intel_mipmap_tree *mt,<br>
> >               uint32_t *tile_x, uint32_t *tile_y,<br>
> >               uint32_t *offset, struct isl_surf *surf)<br>
> >  {<br>
> > -   if (mt->surf.size > 0) {<br>
> > -      *surf = mt->surf;<br>
> > -   } else {<br>
> > -      intel_miptree_get_isl_surf(<wbr>brw, mt, surf);<br>
> > -<br>
> > -      surf->dim = get_isl_surf_dim(target);<br>
> > -   }<br>
> > -<br>
> > -   assert(mt->array_layout != GEN6_HIZ_STENCIL);<br>
> > +   *surf = mt->surf;<br>
> ><br>
> >     const enum isl_dim_layout dim_layout =<br>
> >        get_isl_dim_layout(&brw-><wbr>screen->devinfo, mt->surf.tiling, target);<br>
> > @@ -561,12 +553,10 @@ brw_update_texture_surface(<wbr>struct gl_context *ctx,<br>
> >        unsigned view_num_layers;<br>
> >        if (obj->Immutable && obj->Target != GL_TEXTURE_3D) {<br>
> >           view_num_layers = obj->NumLayers;<br>
> > -      } else if (mt->surf.size > 0) {<br>
> > +      } else {<br>
> >           view_num_layers = mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> >                                mt->surf.logical_level0_px.<wbr>depth :<br>
> >                                mt->surf.logical_level0_px.<wbr>array_len;<br>
> > -      } else {<br>
> > -         view_num_layers = mt->logical_depth0;<br>
> >        }<br>
> ><br>
> >        /* Handling GL_ALPHA as a surface format override breaks 1.30+ style<br>
> > @@ -1663,14 +1653,9 @@ get_image_num_layers(const struct intel_mipmap_tree<br>
> > *mt, GLenum target,<br>
> >     if (target == GL_TEXTURE_CUBE_MAP)<br>
> >        return 6;<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      return target == GL_TEXTURE_3D ?<br>
> > -         minify(mt->surf.logical_<wbr>level0_px.depth, level) :<br>
> > -         mt->surf.logical_level0_px.<wbr>array_len;<br>
> > -   }<br>
> > -<br>
> >     return target == GL_TEXTURE_3D ?<br>
> > -      minify(mt->logical_depth0, level) : mt->logical_depth0;<br>
> > +      minify(mt->surf.logical_<wbr>level0_px.depth, level) :<br>
> > +      mt->surf.logical_level0_px.<wbr>array_len;<br>
> >  }<br>
> ><br>
> >  static void<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>gen6_depth_state.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>gen6_depth_state.c<br>
> > index 3e3d2c629b..cd0423913c 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>gen6_depth_state.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>gen6_depth_state.c<br>
> > @@ -91,8 +91,7 @@ gen6_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
> >        break;<br>
> >     case GL_TEXTURE_3D:<br>
> >        assert(mt);<br>
> > -      depth = mt->surf.size > 0 ? mt->surf.logical_level0_px.<wbr>depth :<br>
> > -                                  MAX2(mt->logical_depth0, 1);<br>
> > +      depth = mt->surf.logical_level0_px.<wbr>depth;<br>
> >        /* fallthrough */<br>
> >     default:<br>
> >        surftype = translate_tex_target(gl_<wbr>target);<br>
> > @@ -103,12 +102,9 @@ gen6_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 && mt->surf.size > 0) {<br>
> > +   if (mt) {<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>
> ><br>
> >     BEGIN_BATCH(7);<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>gen7_misc_state.c<br>
> > index c0cb7470bf..1a9e645084 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,8 +83,7 @@ gen7_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
> >        break;<br>
> >     case GL_TEXTURE_3D:<br>
> >        assert(mt);<br>
> > -      depth = mt->surf.size > 0 ? mt->surf.logical_level0_px.<wbr>depth :<br>
> > -                                  MAX2(mt->logical_depth0, 1);<br>
> > +      depth = mt->surf.logical_level0_px.<wbr>depth;<br>
> >        /* fallthrough */<br>
> >     default:<br>
> >        surftype = translate_tex_target(gl_<wbr>target);<br>
> > @@ -95,12 +94,9 @@ 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 && mt->surf.size > 0) {<br>
> > +   if (mt) {<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>
> ><br>
> >     /* _NEW_DEPTH, _NEW_STENCIL, _NEW_BUFFERS */<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>gen8_depth_state.c<br>
> > index 5cee93ade0..429c4b074b 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>
> > @@ -176,8 +176,7 @@ gen8_emit_depth_stencil_hiz(<wbr>struct brw_context *brw,<br>
> >        break;<br>
> >     case GL_TEXTURE_3D:<br>
> >        assert(mt);<br>
> > -      depth = mt->surf.size > 0 ? mt->surf.logical_level0_px.<wbr>depth :<br>
> > -                                  MAX2(mt->logical_depth0, 1);<br>
> > +      depth = mt->surf.logical_level0_px.<wbr>depth;<br>
> >        surftype = translate_tex_target(gl_<wbr>target);<br>
> >        break;<br>
> >     case GL_TEXTURE_1D_ARRAY:<br>
> > @@ -200,12 +199,9 @@ 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 && mt->surf.size > 0) {<br>
> > +   if (mt) {<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>
> ><br>
> >     emit_depth_packets(brw, depth_mt, brw_depthbuffer_format(brw),<br>
> > surftype,<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> > index 68e9c1ad16..eca8736804 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>intel_blit.c<br>
> > @@ -171,12 +171,12 @@ get_blit_intratile_offset_el(<wbr>const struct<br>
> > brw_context *brw,<br>
> >                               uint32_t *x_offset_el,<br>
> >                               uint32_t *y_offset_el)<br>
> >  {<br>
> > -   enum isl_tiling tiling = intel_miptree_get_isl_tiling(<wbr>mt);<br>
> > -   isl_tiling_get_intratile_<wbr>offset_el(tiling, mt->cpp * 8,<br>
> > mt->surf.row_pitch,<br>
> > +   isl_tiling_get_intratile_<wbr>offset_el(mt->surf.tiling,<br>
> > +                                      mt->cpp * 8, mt->surf.row_pitch,<br>
> >                                        total_x_offset_el,<br>
> > total_y_offset_el,<br>
> >                                        base_address_offset,<br>
> >                                        x_offset_el, y_offset_el);<br>
> > -   if (tiling == ISL_TILING_LINEAR) {<br>
> > +   if (mt->surf.tiling == ISL_TILING_LINEAR) {<br>
> >        /* From the Broadwell PRM docs for XY_SRC_COPY_BLT::<br>
> > SourceBaseAddress:<br>
> >         *<br>
> >         *    "Base address of the destination surface: X=0, Y=0. Lower<br>
> > 32bits<br>
> > @@ -329,14 +329,12 @@ intel_miptree_blit(struct brw_context *brw,<br>
> >     intel_miptree_access_raw(brw, dst_mt, dst_level, dst_slice, true);<br>
> ><br>
> >     if (src_flip) {<br>
> > -      const unsigned h0 = src_mt->surf.size > 0 ?<br>
> > -         src_mt->surf.phys_level0_sa.<wbr>height : src_mt->physical_height0;<br>
> > +      const unsigned h0 = src_mt->surf.phys_level0_sa.<wbr>height;<br>
> >        src_y = minify(h0, src_level - src_mt->first_level) - src_y -<br>
> > height;<br>
> >     }<br>
> ><br>
> >     if (dst_flip) {<br>
> > -      const unsigned h0 = dst_mt->surf.size > 0 ?<br>
> > -         dst_mt->surf.phys_level0_sa.<wbr>height : dst_mt->physical_height0;<br>
> > +      const unsigned h0 = dst_mt->surf.phys_level0_sa.<wbr>height;<br>
> >        dst_y = minify(h0, dst_level - dst_mt->first_level) - dst_y -<br>
> > height;<br>
> >     }<br>
> ><br>
> > @@ -407,21 +405,12 @@ intel_miptree_copy(struct brw_context *brw,<br>
> >        assert(src_x % bw == 0);<br>
> >        assert(src_y % bh == 0);<br>
> ><br>
> > -      if (src_mt->surf.size > 0) {<br>
> > -         assert(src_width % bw == 0 ||<br>
> > -                src_x + src_width ==<br>
> > -                minify(src_mt->surf.logical_<wbr>level0_px.width, src_level));<br>
> > -         assert(src_height % bh == 0 ||<br>
> > -                src_y + src_height ==<br>
> > -                minify(src_mt->surf.logical_<wbr>level0_px.height,<br>
> > src_level));<br>
> > -      } else {<br>
> > -         assert(src_width % bw == 0 ||<br>
> > -                src_x + src_width ==<br>
> > -                minify(src_mt->logical_width0, src_level));<br>
> > -         assert(src_height % bh == 0 ||<br>
> > -                src_y + src_height ==<br>
> > -                minify(src_mt->logical_<wbr>height0, src_level));<br>
> > -      }<br>
> > +      assert(src_width % bw == 0 ||<br>
> > +             src_x + src_width ==<br>
> > +             minify(src_mt->surf.logical_<wbr>level0_px.width, src_level));<br>
> > +      assert(src_height % bh == 0 ||<br>
> > +             src_y + src_height ==<br>
> > +             minify(src_mt->surf.logical_<wbr>level0_px.height, src_level));<br>
> ><br>
> >        src_x /= (int)bw;<br>
> >        src_y /= (int)bh;<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
> > index bcb8d8039d..9e27593c0c 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
> > @@ -532,19 +532,14 @@ intel_renderbuffer_update_<wbr>wrapper(struct<br>
> > brw_context *brw,<br>
> >     irb->mt_level = level;<br>
> >     irb->mt_layer = layer;<br>
> ><br>
> > -   const unsigned layer_multiplier =<br>
> > -      mt->surf.msaa_layout == ISL_MSAA_LAYOUT_ARRAY ? mt->surf.samples :<br>
> > 1;<br>
> > -<br>
> >     if (!layered) {<br>
> >        irb->layer_count = 1;<br>
> >     } else if (mt->target != GL_TEXTURE_3D && image->TexObject->NumLayers<br>
> > > 0) {<br>
> >        irb->layer_count = image->TexObject->NumLayers;<br>
> > -   } else if (mt->surf.size > 0) {<br>
> > +   } else {<br>
> >        irb->layer_count = mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> >                              minify(mt->surf.logical_<wbr>level0_px.depth,<br>
> > level) :<br>
> >                              mt->surf.logical_level0_px.<wbr>array_len;<br>
> > -   } else {<br>
> > -      irb->layer_count = mt->level[level].depth / layer_multiplier;<br>
> >     }<br>
> ><br>
> >     intel_miptree_reference(&irb-><wbr>mt, mt);<br>
> > @@ -660,32 +655,17 @@ intel_validate_framebuffer(<wbr>struct gl_context *ctx,<br>
> > struct gl_framebuffer *fb)<br>
> ><br>
> >     if (depth_mt && stencil_mt) {<br>
> >        if (brw->gen >= 6) {<br>
> > -         unsigned d_width, d_height, d_depth;<br>
> > -         unsigned s_width, s_height, s_depth;<br>
> > -<br>
> > -         if (depth_mt->surf.size > 0) {<br>
> > -             d_width = depth_mt->surf.phys_level0_sa.<wbr>width;<br>
> > -             d_height = depth_mt->surf.phys_level0_sa.<wbr>height;<br>
> > -             d_depth = depth_mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> > -                          depth_mt->surf.phys_level0_sa.<wbr>depth :<br>
> > -                          depth_mt->surf.phys_level0_sa.<wbr>array_len;<br>
> > -         } else {<br>
> > -             d_width = depth_mt->physical_width0;<br>
> > -             d_height = depth_mt->physical_height0;<br>
> > -             d_depth = depth_mt->physical_depth0;<br>
> > -         }<br>
> > -<br>
> > -         if (stencil_mt->surf.size > 0) {<br>
> > -             s_width = stencil_mt->surf.phys_level0_<wbr>sa.width;<br>
> > -             s_height = stencil_mt->surf.phys_level0_<wbr>sa.height;<br>
> > -             s_depth = stencil_mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> > -                          stencil_mt->surf.phys_level0_<wbr>sa.depth :<br>
> > -                          stencil_mt->surf.phys_level0_<wbr>sa.array_len;<br>
> > -         } else {<br>
> > -             s_width = stencil_mt->physical_width0;<br>
> > -             s_height = stencil_mt->physical_height0;<br>
> > -             s_depth = stencil_mt->physical_depth0;<br>
> > -         }<br>
> > +         const unsigned d_width = depth_mt->surf.phys_level0_sa.<wbr>width;<br>
> > +         const unsigned d_height = depth_mt->surf.phys_level0_sa.<wbr>height;<br>
> > +         const unsigned d_depth = depth_mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> > +                                     depth_mt->surf.phys_level0_sa.<wbr>depth<br>
> > :<br>
> > +                                     depth_mt->surf.phys_level0_sa.<br>
> > array_len;<br>
> > +<br>
> > +         const unsigned s_width = stencil_mt->surf.phys_level0_<wbr>sa.width;<br>
> > +         const unsigned s_height = stencil_mt->surf.phys_level0_<br>
> > sa.height;<br>
> > +         const unsigned s_depth = stencil_mt->surf.dim == ISL_SURF_DIM_3D<br>
> > ?<br>
> > +                                     stencil_mt->surf.phys_level0_<wbr>sa.depth<br>
> > :<br>
> > +                                     stencil_mt->surf.phys_level0_<br>
> > sa.array_len;<br>
> ><br>
> >           /* For gen >= 6, we are using the lod/minimum-array-element<br>
> > fields<br>
> >            * and supporting layered rendering. This means that we must<br>
> > restrict<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > index af5d37bc47..3ab86e31f4 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>
> > @@ -97,29 +97,6 @@ is_mcs_supported(const struct brw_context *brw,<br>
> > mesa_format format,<br>
> >     }<br>
> >  }<br>
> ><br>
> > -/**<br>
> > - * Determine which MSAA layout should be used by the MSAA surface being<br>
> > - * created, based on the chip generation and the surface type.<br>
> > - */<br>
> > -static enum isl_msaa_layout<br>
> > -compute_msaa_layout(struct brw_context *brw, mesa_format format,<br>
> > -                    uint32_t layout_flags)<br>
> > -{<br>
> > -   /* Prior to Gen7, all MSAA surfaces used IMS layout. */<br>
> > -   if (brw->gen < 7)<br>
> > -      return ISL_MSAA_LAYOUT_INTERLEAVED;<br>
> > -<br>
> > -   /* In Gen7, IMS layout is only used for depth and stencil buffers. */<br>
> > -   switch (_mesa_get_format_base_format(<wbr>format)) {<br>
> > -   case GL_DEPTH_COMPONENT:<br>
> > -   case GL_STENCIL_INDEX:<br>
> > -   case GL_DEPTH_STENCIL:<br>
> > -      return ISL_MSAA_LAYOUT_INTERLEAVED;<br>
> > -   default:<br>
> > -      return ISL_MSAA_LAYOUT_ARRAY;<br>
> > -   }<br>
> > -}<br>
> > -<br>
> >  static bool<br>
> >  intel_tiling_supports_ccs(<wbr>const struct brw_context *brw,<br>
> >                            enum isl_tiling tiling)<br>
> > @@ -345,222 +322,6 @@ needs_separate_stencil(const struct brw_context *brw,<br>
> >  }<br>
> ><br>
> >  /**<br>
> > - * @param for_bo Indicates that the caller is<br>
> > - *        intel_miptree_create_for_bo(). If true, then do not create<br>
> > - *        \c stencil_mt.<br>
> > - */<br>
> > -static struct intel_mipmap_tree *<br>
> > -intel_miptree_create_layout(<wbr>struct brw_context *brw,<br>
> > -                            GLenum target,<br>
> > -                            mesa_format format,<br>
> > -                            GLuint first_level,<br>
> > -                            GLuint last_level,<br>
> > -                            GLuint width0,<br>
> > -                            GLuint height0,<br>
> > -                            GLuint depth0,<br>
> > -                            GLuint num_samples,<br>
> > -                            uint32_t layout_flags)<br>
> > -{<br>
> > -   assert(num_samples > 0);<br>
> > -<br>
> > -   struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);<br>
> > -   if (!mt)<br>
> > -      return NULL;<br>
> > -<br>
> > -   DBG("%s target %s format %s level %d..%d slices %d <-- %p\n", __func__,<br>
> > -       _mesa_enum_to_string(target),<br>
> > -       _mesa_get_format_name(format),<br>
> > -       first_level, last_level, depth0, mt);<br>
> > -<br>
> > -   if (target == GL_TEXTURE_1D_ARRAY)<br>
> > -      assert(height0 == 1);<br>
> > -<br>
> > -   mt->target = target;<br>
> > -   mt->format = format;<br>
> > -   mt->first_level = first_level;<br>
> > -   mt->last_level = last_level;<br>
> > -   mt->logical_width0 = width0;<br>
> > -   mt->logical_height0 = height0;<br>
> > -   mt->logical_depth0 = depth0;<br>
> > -   mt->is_scanout = (layout_flags & MIPTREE_LAYOUT_FOR_SCANOUT) != 0;<br>
> > -   mt->aux_usage = ISL_AUX_USAGE_NONE;<br>
> > -   mt->supports_fast_clear = false;<br>
> > -   mt->aux_state = NULL;<br>
> > -   mt->cpp = _mesa_get_format_bytes(format)<wbr>;<br>
> > -   mt->surf.samples = num_samples;<br>
> > -   mt->compressed = _mesa_is_format_compressed(<wbr>format);<br>
> > -   mt->surf.msaa_layout = ISL_MSAA_LAYOUT_NONE;<br>
> > -   mt->refcount = 1;<br>
> > -<br>
> > -   if (brw->gen == 6 && format == MESA_FORMAT_S_UINT8)<br>
> > -      layout_flags |= MIPTREE_LAYOUT_GEN6_HIZ_<wbr>STENCIL;<br>
> > -<br>
> > -   int depth_multiply = 1;<br>
> > -   if (num_samples > 1) {<br>
> > -      /* Adjust width/height/depth for MSAA */<br>
> > -      mt->surf.msaa_layout = compute_msaa_layout(brw, format,<br>
> > layout_flags);<br>
> > -      if (mt->surf.msaa_layout == ISL_MSAA_LAYOUT_INTERLEAVED) {<br>
> > -         /* From the Ivybridge PRM, Volume 1, Part 1, page 108:<br>
> > -          * "If the surface is multisampled and it is a depth or stencil<br>
> > -          *  surface or Multisampled Surface StorageFormat in<br>
> > SURFACE_STATE is<br>
> > -          *  MSFMT_DEPTH_STENCIL, WL and HL must be adjusted as follows<br>
> > before<br>
> > -          *  proceeding:<br>
> > -          *<br>
> > -          *  +-----------------------------<wbr>------------------------------<br>
> > -----+<br>
> > -          *  | Num Multisamples |        W_l =         |        H_l =<br>
> >      |<br>
> > -          *  +-----------------------------<wbr>------------------------------<br>
> > -----+<br>
> > -          *  |         2        | ceiling(W_l / 2) * 4 | H_l (no<br>
> > adjustment)  |<br>
> > -          *  |         4        | ceiling(W_l / 2) * 4 | ceiling(H_l / 2)<br>
> > * 4 |<br>
> > -          *  |         8        | ceiling(W_l / 2) * 8 | ceiling(H_l / 2)<br>
> > * 4 |<br>
> > -          *  |        16        | ceiling(W_l / 2) * 8 | ceiling(H_l / 2)<br>
> > * 8 |<br>
> > -          *  +-----------------------------<wbr>------------------------------<br>
> > -----+<br>
> > -          * "<br>
> > -          *<br>
> > -          * Note that MSFMT_DEPTH_STENCIL just means the IMS (interleaved)<br>
> > -          * format rather than UMS/CMS (array slices).  The Sandybridge<br>
> > PRM,<br>
> > -          * Volume 1, Part 1, Page 111 has the same formula for 4x MSAA.<br>
> > -          *<br>
> > -          * Another more complicated explanation for these adjustments<br>
> > comes<br>
> > -          * from the Sandybridge PRM, volume 4, part 1, page 31:<br>
> > -          *<br>
> > -          *     "Any of the other messages (sample*, LOD, load4) used<br>
> > with a<br>
> > -          *      (4x) multisampled surface will in-effect sample a<br>
> > surface with<br>
> > -          *      double the height and width as that indicated in the<br>
> > surface<br>
> > -          *      state. Each pixel position on the original-sized surface<br>
> > is<br>
> > -          *      replaced with a 2x2 of samples with the following<br>
> > arrangement:<br>
> > -          *<br>
> > -          *         sample 0 sample 2<br>
> > -          *         sample 1 sample 3"<br>
> > -          *<br>
> > -          * Thus, when sampling from a multisampled texture, it behaves as<br>
> > -          * though the layout in memory for (x,y,sample) is:<br>
> > -          *<br>
> > -          *      (0,0,0) (0,0,2)   (1,0,0) (1,0,2)<br>
> > -          *      (0,0,1) (0,0,3)   (1,0,1) (1,0,3)<br>
> > -          *<br>
> > -          *      (0,1,0) (0,1,2)   (1,1,0) (1,1,2)<br>
> > -          *      (0,1,1) (0,1,3)   (1,1,1) (1,1,3)<br>
> > -          *<br>
> > -          * However, the actual layout of multisampled data in memory is:<br>
> > -          *<br>
> > -          *      (0,0,0) (1,0,0)   (0,0,1) (1,0,1)<br>
> > -          *      (0,1,0) (1,1,0)   (0,1,1) (1,1,1)<br>
> > -          *<br>
> > -          *      (0,0,2) (1,0,2)   (0,0,3) (1,0,3)<br>
> > -          *      (0,1,2) (1,1,2)   (0,1,3) (1,1,3)<br>
> > -          *<br>
> > -          * This pattern repeats for each 2x2 pixel block.<br>
> > -          *<br>
> > -          * As a result, when calculating the size of our 4-sample buffer<br>
> > for<br>
> > -          * an odd width or height, we have to align before scaling up<br>
> > because<br>
> > -          * sample 3 is in that bottom right 2x2 block.<br>
> > -          */<br>
> > -         switch (num_samples) {<br>
> > -         case 2:<br>
> > -            assert(brw->gen >= 8);<br>
> > -            width0 = ALIGN(width0, 2) * 2;<br>
> > -            height0 = ALIGN(height0, 2);<br>
> > -            break;<br>
> > -         case 4:<br>
> > -            width0 = ALIGN(width0, 2) * 2;<br>
> > -            height0 = ALIGN(height0, 2) * 2;<br>
> > -            break;<br>
> > -         case 8:<br>
> > -            width0 = ALIGN(width0, 2) * 4;<br>
> > -            height0 = ALIGN(height0, 2) * 2;<br>
> > -            break;<br>
> > -         case 16:<br>
> > -            width0 = ALIGN(width0, 2) * 4;<br>
> > -            height0 = ALIGN(height0, 2) * 4;<br>
> > -            break;<br>
> > -         default:<br>
> > -            /* num_samples should already have been quantized to 0, 1, 2,<br>
> > 4, 8<br>
> > -             * or 16.<br>
> > -             */<br>
> > -            unreachable("not reached");<br>
> > -         }<br>
> > -      } else {<br>
> > -         /* Non-interleaved */<br>
> > -         depth_multiply = num_samples;<br>
> > -         depth0 *= depth_multiply;<br>
> > -      }<br>
> > -   }<br>
> > -<br>
> > -   if (!create_mapping_table(target, first_level, last_level, depth0,<br>
> > -                             mt->level)) {<br>
> > -      free(mt);<br>
> > -      return NULL;<br>
> > -   }<br>
> > -<br>
> > -   /* Set array_layout to ALL_SLICES_AT_EACH_LOD when array_spacing_lod0<br>
> > can<br>
> > -    * be used. array_spacing_lod0 is only used for non-IMS MSAA surfaces<br>
> > on<br>
> > -    * Gen 7 and 8. On Gen 8 and 9 this layout is not available but it is<br>
> > still<br>
> > -    * used on Gen8 to make it pick a qpitch value which doesn't include<br>
> > space<br>
> > -    * for the mipmaps. On Gen9 this is not necessary because it will<br>
> > -    * automatically pick a packed qpitch value whenever mt->first_level ==<br>
> > -    * mt->last_level.<br>
> > -    * TODO: can we use it elsewhere?<br>
> > -    * TODO: also disable this on Gen8 and pick the qpitch value like Gen9<br>
> > -    */<br>
> > -   if (brw->gen >= 9) {<br>
> > -      mt->array_layout = ALL_LOD_IN_EACH_SLICE;<br>
> > -   } else {<br>
> > -      switch (mt->surf.msaa_layout) {<br>
> > -      case ISL_MSAA_LAYOUT_NONE:<br>
> > -      case ISL_MSAA_LAYOUT_INTERLEAVED:<br>
> > -         mt->array_layout = ALL_LOD_IN_EACH_SLICE;<br>
> > -         break;<br>
> > -      case ISL_MSAA_LAYOUT_ARRAY:<br>
> > -         mt->array_layout = ALL_SLICES_AT_EACH_LOD;<br>
> > -         break;<br>
> > -      }<br>
> > -   }<br>
> > -<br>
> > -   if (target == GL_TEXTURE_CUBE_MAP)<br>
> > -      assert(depth0 == 6 * depth_multiply);<br>
> > -<br>
> > -   mt->physical_width0 = width0;<br>
> > -   mt->physical_height0 = height0;<br>
> > -   mt->physical_depth0 = depth0;<br>
> > -<br>
> > -   assert(!needs_separate_<wbr>stencil(brw, mt, format, layout_flags));<br>
> > -<br>
> > -   /*<br>
> > -    * Obey HALIGN_16 constraints for Gen8 and Gen9 buffers which are<br>
> > -    * multisampled or have an AUX buffer attached to it.<br>
> > -    *<br>
> > -    * GEN  |    MSRT        | AUX_CCS_* or AUX_MCS<br>
> > -    *  ------------------------------<wbr>-------------<br>
> > -    *  9   |  HALIGN_16     |    HALIGN_16<br>
> > -    *  8   |  HALIGN_ANY    |    HALIGN_16<br>
> > -    *  7   |      ?         |        ?<br>
> > -    *  6   |      ?         |        ?<br>
> > -    */<br>
> > -   if (intel_miptree_supports_ccs(<wbr>brw, mt)) {<br>
> > -      if (brw->gen >= 9 || (brw->gen == 8 && num_samples == 1))<br>
> > -         layout_flags |= MIPTREE_LAYOUT_FORCE_HALIGN16;<br>
> > -   } else if (brw->gen >= 9 && num_samples > 1) {<br>
> > -      layout_flags |= MIPTREE_LAYOUT_FORCE_HALIGN16;<br>
> > -   } else {<br>
> > -      const UNUSED bool is_lossless_compressed_aux =<br>
> > -         brw->gen >= 9 && num_samples == 1 &&<br>
> > -         mt->format == MESA_FORMAT_R_UINT32;<br>
> > -<br>
> > -      /* For now, nothing else has this requirement */<br>
> > -      assert(is_lossless_compressed_<wbr>aux ||<br>
> > -             (layout_flags & MIPTREE_LAYOUT_FORCE_HALIGN16) == 0);<br>
> > -   }<br>
> > -<br>
> > -   if (!brw_miptree_layout(brw, mt, layout_flags)) {<br>
> > -      intel_miptree_release(&mt);<br>
> > -      return NULL;<br>
> > -   }<br>
> > -<br>
> > -   return mt;<br>
> > -}<br>
> > -<br>
> > -<br>
> > -/**<br>
> >   * Choose the aux usage for this miptree.  This function must be called<br>
> > fairly<br>
> >   * late in the miptree create process after we have a tiling.<br>
> >   */<br>
> > @@ -662,11 +423,7 @@ intel_miptree_check_level_<wbr>layer(const struct<br>
> > intel_mipmap_tree *mt,<br>
> ><br>
> >     assert(level >= mt->first_level);<br>
> >     assert(level <= mt->last_level);<br>
> > -<br>
> > -   if (mt->surf.size > 0)<br>
> > -      assert(layer < get_num_phys_layers(&mt->surf, level));<br>
> > -   else<br>
> > -      assert(layer < mt->level[level].depth);<br>
> > +   assert(layer < get_num_phys_layers(&mt->surf, level));<br>
> >  }<br>
> ><br>
> >  static enum isl_aux_state **<br>
> > @@ -676,12 +433,8 @@ create_aux_state_map(struct intel_mipmap_tree *mt,<br>
> >     const uint32_t levels = mt->last_level + 1;<br>
> ><br>
> >     uint32_t total_slices = 0;<br>
> > -   for (uint32_t level = 0; level < levels; level++) {<br>
> > -      if (mt->surf.size > 0)<br>
> > -         total_slices += get_num_phys_layers(&mt->surf, level);<br>
> > -      else<br>
> > -         total_slices += mt->level[level].depth;<br>
> > -   }<br>
> > +   for (uint32_t level = 0; level < levels; level++)<br>
> > +      total_slices += get_num_phys_layers(&mt->surf, level);<br>
> ><br>
> >     const size_t per_level_array_size = levels * sizeof(enum isl_aux_state<br>
> > *);<br>
> ><br>
> > @@ -700,11 +453,7 @@ create_aux_state_map(struct intel_mipmap_tree *mt,<br>
> >     for (uint32_t level = 0; level < levels; level++) {<br>
> >        per_level_arr[level] = s;<br>
> ><br>
> > -      unsigned level_depth;<br>
> > -      if (mt->surf.size > 0)<br>
> > -         level_depth = get_num_phys_layers(&mt->surf, level);<br>
> > -      else<br>
> > -         level_depth = mt->level[level].depth;<br>
> > +      const unsigned level_depth = get_num_phys_layers(&mt->surf, level);<br>
> ><br>
> >        for (uint32_t a = 0; a < level_depth; a++)<br>
> >           *(s++) = initial;<br>
> > @@ -1212,8 +961,6 @@ intel_miptree_create_for_dri_<wbr>image(struct<br>
> > brw_context *brw,<br>
> >     mt->target = target;<br>
> >     mt->level[0].level_x = image->tile_x;<br>
> >     mt->level[0].level_y = image->tile_y;<br>
> > -   mt->level[0].slice[0].x_offset = image->tile_x;<br>
> > -   mt->level[0].slice[0].y_offset = image->tile_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<br>
> > which has<br>
> > @@ -1456,79 +1203,18 @@ intel_miptree_match_image(<wbr>struct<br>
> > intel_mipmap_tree *mt,<br>
> >     if (mt->target == GL_TEXTURE_CUBE_MAP)<br>
> >        depth = 6;<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      if (level >= mt->surf.levels)<br>
> > -         return false;<br>
> > -<br>
> > -      const unsigned level_depth =<br>
> > -         mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> > -            minify(mt->surf.logical_<wbr>level0_px.depth, level) :<br>
> > -            mt->surf.logical_level0_px.<wbr>array_len;<br>
> > -<br>
> > -      return width == minify(mt->surf.logical_<wbr>level0_px.width, level) &&<br>
> > -             height == minify(mt->surf.logical_<wbr>level0_px.height, level)<br>
> > &&<br>
> > -             depth == level_depth &&<br>
> > -             MAX2(image->NumSamples, 1) == mt->surf.samples;<br>
> > -   }<br>
> > -<br>
> > -   int level_depth = mt->level[level].depth;<br>
> > -   if (mt->surf.samples > 1 && mt->surf.msaa_layout ==<br>
> > ISL_MSAA_LAYOUT_ARRAY)<br>
> > -      level_depth /= mt->surf.samples;<br>
> > -<br>
> > -   /* Test image dimensions against the base level image adjusted for<br>
> > -    * minification.  This will also catch images not present in the<br>
> > -    * tree, changed targets, etc.<br>
> > -    */<br>
> > -   if (width != minify(mt->logical_width0, level - mt->first_level) ||<br>
> > -       height != minify(mt->logical_height0, level - mt->first_level) ||<br>
> > -       depth != level_depth) {<br>
> > -      return false;<br>
> > -   }<br>
> > -<br>
> > -   /* Core uses sample number of zero to indicate single-sampled. */<br>
> > -   if (MAX2(image->NumSamples, 1) != mt->surf.samples)<br>
> > +   if (level >= mt->surf.levels)<br>
> >        return false;<br>
> ><br>
> > -   return true;<br>
> > -}<br>
> > -<br>
> > -<br>
> > -void<br>
> > -intel_miptree_set_level_info(<wbr>struct intel_mipmap_tree *mt,<br>
> > -                            GLuint level,<br>
> > -                            GLuint x, GLuint y, GLuint d)<br>
> > -{<br>
> > -   mt->level[level].depth = d;<br>
> > -   mt->level[level].level_x = x;<br>
> > -   mt->level[level].level_y = y;<br>
> > -<br>
> > -   DBG("%s level %d, depth %d, offset %d,%d\n", __func__,<br>
> > -       level, d, x, y);<br>
> > -<br>
> > -   assert(mt->level[level].slice)<wbr>;<br>
> > +   const unsigned level_depth =<br>
> > +      mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> > +         minify(mt->surf.logical_<wbr>level0_px.depth, level) :<br>
> > +         mt->surf.logical_level0_px.<wbr>array_len;<br>
> ><br>
> > -   mt->level[level].slice[0].x_<wbr>offset = mt->level[level].level_x;<br>
> > -   mt->level[level].slice[0].y_<wbr>offset = mt->level[level].level_y;<br>
> > -}<br>
> > -<br>
> > -<br>
> > -void<br>
> > -intel_miptree_set_image_<wbr>offset(struct intel_mipmap_tree *mt,<br>
> > -                              GLuint level, GLuint img,<br>
> > -                              GLuint x, GLuint y)<br>
> > -{<br>
> ><br>
><br>
> You delete miptree_set_level_info and set_image_offsets so mt->level is<br>
> basically uninitialized but you don't actually delete the level field from<br>
> intel_mipmap_tree.  Am I missing something?<br>
<br>
</div></div>Miptree is allocated via calloc() so all "level[MAX_TEXTURE_LEVELS]" get<br>
initialised to zero. Like you asked further down, they are only used for<br>
level zero and set by intel_miptree_create_for_dri_<wbr>image().<br>
<br>
This is on my todo list as follow-up work. There are a couple of things that<br>
can be cleaned up even further - this is one of them.<br>
</blockquote><div> <br></div><div>I think that's fine.  I'd like if cleaning this up could be on the top of that list. :)<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
><br>
><br>
> > -   if (img == 0 && level == 0)<br>
> > -      assert(x == 0 && y == 0);<br>
> > -<br>
> > -   assert(img < mt->level[level].depth);<br>
> > -<br>
> > -   mt->level[level].slice[img].x_<wbr>offset = mt->level[level].level_x + x;<br>
> > -   mt->level[level].slice[img].y_<wbr>offset = mt->level[level].level_y + y;<br>
> > -<br>
> > -   DBG("%s level %d img %d pos %d,%d\n",<br>
> > -       __func__, level, img,<br>
> > -       mt->level[level].slice[img].x_<wbr>offset,<br>
> > -       mt->level[level].slice[img].y_<wbr>offset);<br>
> > +   return width == minify(mt->surf.logical_<wbr>level0_px.width, level) &&<br>
> > +          height == minify(mt->surf.logical_<wbr>level0_px.height, level) &&<br>
> > +          depth == level_depth &&<br>
> > +          MAX2(image->NumSamples, 1) == mt->surf.samples;<br>
> >  }<br>
> ><br>
> >  void<br>
> > @@ -1542,36 +1228,28 @@ intel_miptree_get_image_<wbr>offset(const struct<br>
> > intel_mipmap_tree *mt,<br>
> >        return;<br>
> >     }<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      uint32_t x_offset_sa, y_offset_sa;<br>
> > -<br>
> > -      /* Miptree itself can have an offset only if it represents a single<br>
> > -       * slice in an imported buffer object.<br>
> > -       * See intel_miptree_create_for_dri_<wbr>image().<br>
> > -       */<br>
> > -      assert(mt->level[0].level_x == 0);<br>
> > -      assert(mt->level[0].level_y == 0);<br>
> > -<br>
> > -      /* Given level is relative to level zero while the miptree may be<br>
> > -       * represent just a subset of all levels starting from<br>
> > 'first_level'.<br>
> > -       */<br>
> > -      assert(level >= mt->first_level);<br>
> > -      level -= mt->first_level;<br>
> > +   uint32_t x_offset_sa, y_offset_sa;<br>
> ><br>
> > -      const unsigned z = mt->surf.dim == ISL_SURF_DIM_3D ? slice : 0;<br>
> > -      slice = mt->surf.dim == ISL_SURF_DIM_3D ? 0 : slice;<br>
> > -      isl_surf_get_image_offset_el(&<wbr>mt->surf, level, slice, z,<br>
> > -                                   &x_offset_sa, &y_offset_sa);<br>
> > +   /* Miptree itself can have an offset only if it represents a single<br>
> > +    * slice in an imported buffer object.<br>
> > +    * See intel_miptree_create_for_dri_<wbr>image().<br>
> > +    */<br>
> > +   assert(mt->level[0].level_x == 0);<br>
> > +   assert(mt->level[0].level_y == 0);<br>
> ><br>
><br>
> Except we usel level_x and level_y here.  Is this now only used for<br>
> external images?<br>
<br>
</div></div>Yes, only set by intel_miptree_create_for_dri_<wbr>image() for level zero.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> ><br>
> > -      *x = x_offset_sa;<br>
> > -      *y = y_offset_sa;<br>
> > -      return;<br>
> > -   }<br>
> > +   /* Given level is relative to level zero while the miptree may be<br>
> > +    * represent just a subset of all levels starting from 'first_level'.<br>
> > +    */<br>
> > +   assert(level >= mt->first_level);<br>
> > +   level -= mt->first_level;<br>
> ><br>
> > -   assert(slice < mt->level[level].depth);<br>
> > +   const unsigned z = mt->surf.dim == ISL_SURF_DIM_3D ? slice : 0;<br>
> > +   slice = mt->surf.dim == ISL_SURF_DIM_3D ? 0 : slice;<br>
> > +   isl_surf_get_image_offset_el(&<wbr>mt->surf, level, slice, z,<br>
> > +                                &x_offset_sa, &y_offset_sa);<br>
> ><br>
> > -   *x = mt->level[level].slice[slice].<wbr>x_offset;<br>
> > -   *y = mt->level[level].slice[slice].<wbr>y_offset;<br>
> > +   *x = x_offset_sa;<br>
> > +   *y = y_offset_sa;<br>
> >  }<br>
> ><br>
> ><br>
> > @@ -1686,8 +1364,7 @@ intel_miptree_copy_slice_sw(<wbr>struct brw_context *brw,<br>
> >  {<br>
> >     void *src, *dst;<br>
> >     ptrdiff_t src_stride, dst_stride;<br>
> > -   const unsigned cpp = dst_mt->surf.size > 0 ?<br>
> > -      (isl_format_get_layout(dst_mt-<wbr>>surf.format)->bpb / 8) :<br>
> > dst_mt->cpp;<br>
> > +   const unsigned cpp = (isl_format_get_layout(dst_mt-<wbr>>surf.format)->bpb<br>
> > / 8);<br>
> ><br>
> >     intel_miptree_map(brw, src_mt,<br>
> >                       src_level, src_layer,<br>
> > @@ -1749,24 +1426,13 @@ intel_miptree_copy_slice(<wbr>struct brw_context *brw,<br>
> ><br>
> >  {<br>
> >     mesa_format format = src_mt->format;<br>
> > -   uint32_t width, height;<br>
> > -<br>
> > -   if (src_mt->surf.size > 0) {<br>
> > -      width = minify(src_mt->surf.phys_<wbr>level0_sa.width,<br>
> > -                     src_level - src_mt->first_level);<br>
> > -      height = minify(src_mt->surf.phys_<wbr>level0_sa.height,<br>
> > -                      src_level - src_mt->first_level);<br>
> > +   unsigned width = minify(src_mt->surf.phys_<wbr>level0_sa.width,<br>
> > +                           src_level - src_mt->first_level);<br>
> > +   unsigned height = minify(src_mt->surf.phys_<wbr>level0_sa.height,<br>
> > +                            src_level - src_mt->first_level);<br>
> ><br>
> > -      assert(src_layer <<br>
> > -             get_num_phys_layers(&src_mt-><wbr>surf,<br>
> > -                                 src_level - src_mt->first_level));<br>
> > -   } else {<br>
> > -      width = minify(src_mt->physical_<wbr>width0,<br>
> > -                     src_level - src_mt->first_level);<br>
> > -      height = minify(src_mt->physical_<wbr>height0,<br>
> > -                      src_level - src_mt->first_level);<br>
> > -      assert(src_layer < src_mt->level[src_level].<wbr>depth);<br>
> > -   }<br>
> > +   assert(src_layer < get_num_phys_layers(&src_mt-><wbr>surf,<br>
> > +                                          src_level -<br>
> > src_mt->first_level));<br>
> ><br>
> >     assert(src_mt->format == dst_mt->format);<br>
> ><br>
> > @@ -2200,8 +1866,7 @@ intel_miptree_has_color_<wbr>unresolved(const struct<br>
> > intel_mipmap_tree *mt,<br>
> >     num_levels = last_level - start_level + 1;<br>
> ><br>
> >     for (uint32_t level = start_level; level <= last_level; level++) {<br>
> > -      uint32_t level_layers = mt->surf.size > 0 ?<br>
> > -         get_num_phys_layers(&mt->surf, level) : mt->level[level].depth;<br>
> > +      uint32_t level_layers = get_num_phys_layers(&mt->surf, level);<br>
> ><br>
> >        level_layers = MIN2(num_layers, level_layers);<br>
> ><br>
> > @@ -2542,12 +2207,7 @@ miptree_layer_range_length(<wbr>const struct<br>
> > intel_mipmap_tree *mt, uint32_t level,<br>
> >                             uint32_t start_layer, uint32_t num_layers)<br>
> >  {<br>
> >     assert(level <= mt->last_level);<br>
> > -   uint32_t total_num_layers;<br>
> > -<br>
> > -   if (mt->surf.size > 0)<br>
> > -      total_num_layers = get_num_phys_layers(&mt->surf, level);<br>
> > -   else<br>
> > -      total_num_layers = mt->level[level].depth;<br>
> > +   const uint32_t total_num_layers = get_num_phys_layers(&mt->surf,<br>
> > level);<br>
> ><br>
> >     assert(start_layer < total_num_layers);<br>
> >     if (num_layers == INTEL_REMAINING_LAYERS)<br>
> > @@ -2958,23 +2618,10 @@ intel_miptree_updownsample(<wbr>struct brw_context<br>
> > *brw,<br>
> >                             struct intel_mipmap_tree *src,<br>
> >                             struct intel_mipmap_tree *dst)<br>
> >  {<br>
> > -   unsigned src_w, src_h, dst_w, dst_h;<br>
> > -<br>
> > -   if (src->surf.size > 0) {<br>
> > -      src_w = src->surf.logical_level0_px.<wbr>width;<br>
> > -      src_h = src->surf.logical_level0_px.<wbr>height;<br>
> > -   } else {<br>
> > -      src_w = src->logical_width0;<br>
> > -      src_h = src->logical_height0;<br>
> > -   }<br>
> > -<br>
> > -   if (dst->surf.size > 0) {<br>
> > -      dst_w = dst->surf.logical_level0_px.<wbr>width;<br>
> > -      dst_h = dst->surf.logical_level0_px.<wbr>height;<br>
> > -   } else {<br>
> > -      dst_w = dst->logical_width0;<br>
> > -      dst_h = dst->logical_height0;<br>
> > -   }<br>
> > +   unsigned src_w = src->surf.logical_level0_px.<wbr>width;<br>
> > +   unsigned src_h = src->surf.logical_level0_px.<wbr>height;<br>
> > +   unsigned dst_w = dst->surf.logical_level0_px.<wbr>width;<br>
> > +   unsigned dst_h = dst->surf.logical_level0_px.<wbr>height;<br>
> ><br>
> >     brw_blorp_blit_miptrees(brw,<br>
> >                             src, 0 /* level */, 0 /* layer */,<br>
> > @@ -2986,21 +2633,10 @@ intel_miptree_updownsample(<wbr>struct brw_context<br>
> > *brw,<br>
> >                             false, false);<br>
> ><br>
> >     if (src->stencil_mt) {<br>
> > -      if (src->stencil_mt->surf.size > 0) {<br>
> > -         src_w = src->stencil_mt->surf.logical_<wbr>level0_px.width;<br>
> > -         src_h = src->stencil_mt->surf.logical_<wbr>level0_px.height;<br>
> > -      } else {<br>
> > -         src_w = src->stencil_mt->logical_<wbr>width0;<br>
> > -         src_h = src->stencil_mt->logical_<wbr>height0;<br>
> > -      }<br>
> > -<br>
> > -      if (dst->stencil_mt->surf.size > 0) {<br>
> > -         dst_w = dst->stencil_mt->surf.logical_<wbr>level0_px.width;<br>
> > -         dst_h = dst->stencil_mt->surf.logical_<wbr>level0_px.height;<br>
> > -      } else {<br>
> > -         dst_w = dst->stencil_mt->logical_<wbr>width0;<br>
> > -         dst_h = dst->stencil_mt->logical_<wbr>height0;<br>
> > -      }<br>
> > +      src_w = src->stencil_mt->surf.logical_<wbr>level0_px.width;<br>
> > +      src_h = src->stencil_mt->surf.logical_<wbr>level0_px.height;<br>
> > +      dst_w = dst->stencil_mt->surf.logical_<wbr>level0_px.width;<br>
> > +      dst_h = dst->stencil_mt->surf.logical_<wbr>level0_px.height;<br>
> ><br>
> >        brw_blorp_blit_miptrees(brw,<br>
> >                                src->stencil_mt, 0 /* level */, 0 /* layer<br>
> > */,<br>
> > @@ -3798,129 +3434,6 @@ get_isl_dim_layout(const struct gen_device_info<br>
> > *devinfo,<br>
> >     unreachable("Invalid texture target");<br>
> >  }<br>
> ><br>
> > -enum isl_tiling<br>
> > -intel_miptree_get_isl_tiling(<wbr>const struct intel_mipmap_tree *mt)<br>
> > -{<br>
> > -   if (mt->format == MESA_FORMAT_S_UINT8)<br>
> > -      return ISL_TILING_W;<br>
> > -   return mt->surf.tiling;<br>
> > -}<br>
> > -<br>
> > -void<br>
> > -intel_miptree_get_isl_surf(<wbr>struct brw_context *brw,<br>
> > -                           const struct intel_mipmap_tree *mt,<br>
> > -                           struct isl_surf *surf)<br>
> > -{<br>
> > -   assert(mt->array_layout != GEN6_HIZ_STENCIL);<br>
> > -<br>
> > -   surf->dim = get_isl_surf_dim(mt->target);<br>
> > -   surf->dim_layout = get_isl_dim_layout(&brw-><wbr>screen->devinfo,<br>
> > -                                         mt->surf.tiling, mt->target);<br>
> > -   surf->msaa_layout = mt->surf.msaa_layout;<br>
> > -   surf->tiling = intel_miptree_get_isl_tiling(<wbr>mt);<br>
> > -   surf->row_pitch = mt->surf.row_pitch;<br>
> > -   surf->format = translate_tex_format(brw, mt->format, false);<br>
> > -<br>
> > -   if (brw->gen >= 9) {<br>
> > -      if (surf->dim == ISL_SURF_DIM_1D && surf->tiling ==<br>
> > ISL_TILING_LINEAR) {<br>
> > -         /* For gen9 1-D surfaces, intel_mipmap_tree has a bogus<br>
> > alignment. */<br>
> > -         surf->image_alignment_el = isl_extent3d(64, 1, 1);<br>
> > -      } else {<br>
> > -         /* On gen9+, intel_mipmap_tree stores the horizontal and vertical<br>
> > -          * alignment in terms of surface elements like we want.<br>
> > -          */<br>
> > -         surf->image_alignment_el = isl_extent3d(mt->halign, mt->valign,<br>
> > 1);<br>
> > -      }<br>
> > -   } else {<br>
> > -      /* On earlier gens it's stored in pixels. */<br>
> > -      unsigned bw, bh;<br>
> > -      _mesa_get_format_block_size(<wbr>mt->format, &bw, &bh);<br>
> > -      surf->image_alignment_el =<br>
> > -         isl_extent3d(mt->halign / bw, mt->valign / bh, 1);<br>
> > -   }<br>
> > -<br>
> > -   surf->logical_level0_px.width = mt->logical_width0;<br>
> > -   surf->logical_level0_px.height = mt->logical_height0;<br>
> > -   if (surf->dim == ISL_SURF_DIM_3D) {<br>
> > -      surf->logical_level0_px.depth = mt->logical_depth0;<br>
> > -      surf->logical_level0_px.array_<wbr>len = 1;<br>
> > -   } else {<br>
> > -      surf->logical_level0_px.depth = 1;<br>
> > -      surf->logical_level0_px.array_<wbr>len = mt->logical_depth0;<br>
> > -   }<br>
> > -<br>
> > -   surf->phys_level0_sa.width = mt->physical_width0;<br>
> > -   surf->phys_level0_sa.height = mt->physical_height0;<br>
> > -   if (surf->dim == ISL_SURF_DIM_3D) {<br>
> > -      surf->phys_level0_sa.depth = mt->physical_depth0;<br>
> > -      surf->phys_level0_sa.array_len = 1;<br>
> > -   } else {<br>
> > -      surf->phys_level0_sa.depth = 1;<br>
> > -      surf->phys_level0_sa.array_len = mt->physical_depth0;<br>
> > -   }<br>
> > -<br>
> > -   surf->levels = mt->last_level - mt->first_level + 1;<br>
> > -   surf->samples = mt->surf.samples;<br>
> > -<br>
> > -   surf->size = 0; /* TODO */<br>
> > -   surf->alignment = 0; /* TODO */<br>
> > -<br>
> > -   switch (surf->dim_layout) {<br>
> > -   case ISL_DIM_LAYOUT_GEN4_2D:<br>
> > -   case ISL_DIM_LAYOUT_GEN4_3D:<br>
> > -   case ISL_DIM_LAYOUT_GEN6_STENCIL_<wbr>HIZ:<br>
> > -      if (brw->gen >= 9) {<br>
> > -         surf->array_pitch_el_rows = mt->qpitch;<br>
> > -      } else {<br>
> > -         unsigned bw, bh;<br>
> > -         _mesa_get_format_block_size(<wbr>mt->format, &bw, &bh);<br>
> > -         assert(mt->qpitch % bh == 0);<br>
> > -         surf->array_pitch_el_rows = mt->qpitch / bh;<br>
> > -      }<br>
> > -      break;<br>
> > -   case ISL_DIM_LAYOUT_GEN9_1D:<br>
> > -      surf->array_pitch_el_rows = 1;<br>
> > -      break;<br>
> > -   }<br>
> > -<br>
> > -   switch (mt->array_layout) {<br>
> > -   case ALL_LOD_IN_EACH_SLICE:<br>
> > -      surf->array_pitch_span = ISL_ARRAY_PITCH_SPAN_FULL;<br>
> > -      break;<br>
> > -   case ALL_SLICES_AT_EACH_LOD:<br>
> > -   case GEN6_HIZ_STENCIL:<br>
> > -      surf->array_pitch_span = ISL_ARRAY_PITCH_SPAN_COMPACT;<br>
> > -      break;<br>
> > -   default:<br>
> > -      unreachable("Invalid array layout");<br>
> > -   }<br>
> > -<br>
> > -   GLenum base_format = _mesa_get_format_base_format(<wbr>mt->format);<br>
> > -   switch (base_format) {<br>
> > -   case GL_DEPTH_COMPONENT:<br>
> > -      surf->usage = ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_TEXTURE_BIT;<br>
> > -      break;<br>
> > -   case GL_STENCIL_INDEX:<br>
> > -      surf->usage = ISL_SURF_USAGE_STENCIL_BIT;<br>
> > -      if (brw->gen >= 8)<br>
> > -         surf->usage |= ISL_SURF_USAGE_TEXTURE_BIT;<br>
> > -      break;<br>
> > -   case GL_DEPTH_STENCIL:<br>
> > -      /* In this case we only texture from the depth part */<br>
> > -      surf->usage = ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_STENCIL_BIT<br>
> > |<br>
> > -                    ISL_SURF_USAGE_TEXTURE_BIT;<br>
> > -      break;<br>
> > -   default:<br>
> > -      surf->usage = ISL_SURF_USAGE_TEXTURE_BIT;<br>
> > -      if (brw->mesa_format_supports_<wbr>render[mt->format])<br>
> > -         surf->usage = ISL_SURF_USAGE_RENDER_TARGET_<wbr>BIT;<br>
> > -      break;<br>
> > -   }<br>
> > -<br>
> > -   if (_mesa_is_cube_map_texture(mt-<wbr>>target))<br>
> > -      surf->usage |= ISL_SURF_USAGE_CUBE_BIT;<br>
> > -}<br>
> > -<br>
> >  enum isl_aux_usage<br>
> >  intel_miptree_get_aux_isl_<wbr>usage(const struct brw_context *brw,<br>
> >                                  const struct intel_mipmap_tree *mt)<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
> > index 7de7f86eee..756a1ee0bd 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>
> > @@ -100,21 +100,6 @@ struct intel_mipmap_level<br>
> >     GLuint level_y;<br>
> ><br>
> >     /**<br>
> > -    * \brief Number of 2D slices in this miplevel.<br>
> > -    *<br>
> > -    * The exact semantics of depth varies according to the texture target:<br>
> > -    *    - For GL_TEXTURE_CUBE_MAP, depth is 6.<br>
> > -    *    - For GL_TEXTURE_2D_ARRAY, depth is the number of array slices.<br>
> > It is<br>
> > -    *      identical for all miplevels in the texture.<br>
> > -    *    - For GL_TEXTURE_3D, it is the texture's depth at this miplevel.<br>
> > Its<br>
> > -    *      value, like width and height, varies with miplevel.<br>
> > -    *    - For other texture types, depth is 1.<br>
> > -    *    - Additionally, for UMS and CMS miptrees, depth is multiplied by<br>
> > -    *      sample count.<br>
> > -    */<br>
> > -   GLuint depth;<br>
> > -<br>
> > -   /**<br>
> >      * \brief Is HiZ enabled for this level?<br>
> >      *<br>
> >      * If \c mt->level[l].has_hiz is set, then (1) \c mt->hiz_mt has been<br>
> > @@ -131,26 +116,6 @@ struct intel_mipmap_level<br>
> >      */<br>
> >     struct intel_mipmap_slice {<br>
> >        /**<br>
> > -       * \name Offset to slice<br>
> > -       * \{<br>
> > -       *<br>
> > -       * Hardware formats are so diverse that that there is no unified<br>
> > way to<br>
> > -       * compute the slice offsets, so we store them in this table.<br>
> > -       *<br>
> > -       * The (x, y) offset to slice \c s at level \c l relative the<br>
> > miptrees<br>
> > -       * base address is<br>
> > -       * \code<br>
> > -       *     x = mt->level[l].slice[s].x_offset<br>
> > -       *     y = mt->level[l].slice[s].y_offset<br>
> > -       *<br>
> > -       * On some hardware generations, we program these offsets into<br>
> > -       * RENDER_SURFACE_STATE.XOffset and RENDER_SURFACE_STATE.YOffset.<br>
> > -       */<br>
> > -      GLuint x_offset;<br>
> > -      GLuint y_offset;<br>
> > -      /** \} */<br>
> > -<br>
> > -      /**<br>
> >         * Mapping information. Persistent for the duration of<br>
> >         * intel_miptree_map/unmap on this slice.<br>
> >         */<br>
> > @@ -158,93 +123,6 @@ struct intel_mipmap_level<br>
> >     } *slice;<br>
> >  };<br>
> ><br>
> > -enum miptree_array_layout {<br>
> > -   /* Each array slice contains all miplevels packed together.<br>
> > -    *<br>
> > -    * Gen hardware usually wants multilevel miptrees configured this way.<br>
> > -    *<br>
> > -    * A 2D Array texture with 2 slices and multiple LODs using<br>
> > -    * ALL_LOD_IN_EACH_SLICE would look somewhat like this:<br>
> > -    *<br>
> > -    *   +----------+<br>
> > -    *   |          |<br>
> > -    *   |          |<br>
> > -    *   +----------+<br>
> > -    *   +---+ +-+<br>
> > -    *   |   | +-+<br>
> > -    *   +---+ *<br>
> > -    *   +----------+<br>
> > -    *   |          |<br>
> > -    *   |          |<br>
> > -    *   +----------+<br>
> > -    *   +---+ +-+<br>
> > -    *   |   | +-+<br>
> > -    *   +---+ *<br>
> > -    */<br>
> > -   ALL_LOD_IN_EACH_SLICE,<br>
> > -<br>
> > -   /* Each LOD contains all slices of that LOD packed together.<br>
> > -    *<br>
> > -    * In some situations, Gen7+ hardware can use the array_spacing_lod0<br>
> > -    * feature to save space when the surface only contains LOD 0.<br>
> > -    *<br>
> > -    * Gen6 uses this for separate stencil and hiz since gen6 does not<br>
> > support<br>
> > -    * multiple LODs for separate stencil and hiz.<br>
> > -    *<br>
> > -    * A 2D Array texture with 2 slices and multiple LODs using<br>
> > -    * ALL_SLICES_AT_EACH_LOD would look somewhat like this:<br>
> > -    *<br>
> > -    *   +----------+<br>
> > -    *   |          |<br>
> > -    *   |          |<br>
> > -    *   +----------+<br>
> > -    *   |          |<br>
> > -    *   |          |<br>
> > -    *   +----------+<br>
> > -    *   +---+ +-+<br>
> > -    *   |   | +-+<br>
> > -    *   +---+ +-+<br>
> > -    *   |   | :<br>
> > -    *   +---+<br>
> > -    */<br>
> > -   ALL_SLICES_AT_EACH_LOD,<br>
> > -<br>
> > -   /* On Sandy Bridge, HiZ and stencil buffers work the same as on Ivy<br>
> > Bridge<br>
> > -    * except that they don't technically support mipmapping.  That does<br>
> > not,<br>
> > -    * however, stop us from doing it.  As far as Sandy Bridge hardware is<br>
> > -    * concerned, HiZ and stencil always operates on a single miplevel 2D<br>
> > -    * (possibly array) image.  The dimensions of that image are NOT<br>
> > minified.<br>
> > -    *<br>
> > -    * In order to implement HiZ and stencil on Sandy Bridge, we create one<br>
> > -    * full-sized 2D (possibly array) image for every LOD with every image<br>
> > -    * aligned to a page boundary.  In order to save memory, we pretend<br>
> > that<br>
> > -    * the width of each miplevel is minified and we place LOD1 and above<br>
> > below<br>
> > -    * LOD0 but horizontally adjacent to each other.  When considered as<br>
> > -    * full-sized images, LOD1 and above technically overlap.  However,<br>
> > since<br>
> > -    * we only write to part of that image, the hardware will never notice<br>
> > the<br>
> > -    * overlap.<br>
> > -    *<br>
> > -    * This layout looks something like this:<br>
> > -    *<br>
> > -    *   +---------+<br>
> > -    *   |         |<br>
> > -    *   |         |<br>
> > -    *   +---------+<br>
> > -    *   |         |<br>
> > -    *   |         |<br>
> > -    *   +---------+<br>
> > -    *<br>
> > -    *   +----+ +-+ .<br>
> > -    *   |    | +-+<br>
> > -    *   +----+<br>
> > -    *<br>
> > -    *   +----+ +-+ .<br>
> > -    *   |    | +-+<br>
> > -    *   +----+<br>
> > -    */<br>
> > -   GEN6_HIZ_STENCIL,<br>
> > -};<br>
> > -<br>
> >  /**<br>
> >   * Miptree aux buffer. These buffers are associated with a miptree, but<br>
> > the<br>
> >   * format is managed by the hardware.<br>
> > @@ -354,108 +232,14 @@ struct intel_mipmap_tree<br>
> >      */<br>
> >     mesa_format etc_format;<br>
> ><br>
> > -   /**<br>
> > -    * @name Surface Alignment<br>
> > -    * @{<br>
> > -    *<br>
> > -    * This defines the alignment of the upperleft pixel of each "slice"<br>
> > in the<br>
> > -    * surface. The alignment is in pixel coordinates relative to the<br>
> > surface's<br>
> > -    * most upperleft pixel, which is the pixel at (x=0, y=0, layer=0,<br>
> > -    * level=0).<br>
> > -    *<br>
> > -    * The hardware docs do not use the term "slice".  We use "slice" to<br>
> > mean<br>
> > -    * the pixels at a given miplevel and layer. For 2D surfaces, the<br>
> > layer is<br>
> > -    * the array slice; for 3D surfaces, the layer is the z offset.<br>
> > -    *<br>
> > -    * In the surface layout equations found in the hardware docs, the<br>
> > -    * horizontal and vertical surface alignments often appear as<br>
> > variables 'i'<br>
> > -    * and 'j'.<br>
> > -    */<br>
> > -<br>
> > -   /** @see RENDER_SURFACE_STATE.<wbr>SurfaceHorizontalAlignment */<br>
> > -   uint32_t halign;<br>
> > -<br>
> > -   /** @see RENDER_SURFACE_STATE.<wbr>SurfaceVerticalAlignment */<br>
> > -   uint32_t valign;<br>
> > -   /** @} */<br>
> > -<br>
> >     GLuint first_level;<br>
> >     GLuint last_level;<br>
> ><br>
> > -   /**<br>
> > -    * Level zero image dimensions.  These dimensions correspond to the<br>
> > -    * physical layout of data in memory.  Accordingly, they account for<br>
> > the<br>
> > -    * extra width, height, and or depth that must be allocated in order to<br>
> > -    * accommodate multisample formats, and they account for the extra<br>
> > factor<br>
> > -    * of 6 in depth that must be allocated in order to accommodate cubemap<br>
> > -    * textures.<br>
> > -    */<br>
> > -   GLuint physical_width0, physical_height0, physical_depth0;<br>
> > -<br>
> >     /** Bytes per pixel (or bytes per block if compressed) */<br>
> >     GLuint cpp;<br>
> ><br>
> >     bool compressed;<br>
> ><br>
> > -   /**<br>
> > -    * @name Level zero image dimensions<br>
> > -    * @{<br>
> > -    *<br>
> > -    * These dimensions correspond to the<br>
> > -    * logical width, height, and depth of the texture as seen by client<br>
> > code.<br>
> > -    * Accordingly, they do not account for the extra width, height, and/or<br>
> > -    * depth that must be allocated in order to accommodate multisample<br>
> > -    * formats, nor do they account for the extra factor of 6 in depth that<br>
> > -    * must be allocated in order to accommodate cubemap textures.<br>
> > -    */<br>
> > -<br>
> > -   /**<br>
> > -    * @see RENDER_SURFACE_STATE.Width<br>
> > -    * @see 3DSTATE_DEPTH_BUFFER.Width<br>
> > -    */<br>
> > -   uint32_t logical_width0;<br>
> > -<br>
> > -   /**<br>
> > -    * @see RENDER_SURFACE_STATE.Height<br>
> > -    * @see 3DSTATE_DEPTH_BUFFER.Height<br>
> > -    */<br>
> > -   uint32_t logical_height0;<br>
> > -<br>
> > -   /**<br>
> > -    * @see RENDER_SURFACE_STATE.Depth<br>
> > -    * @see 3DSTATE_DEPTH_BUFFER.Depth<br>
> > -    */<br>
> > -   uint32_t logical_depth0;<br>
> > -   /** @} */<br>
> > -<br>
> > -   /**<br>
> > -    * Indicates if we use the standard miptree layout<br>
> > (ALL_LOD_IN_EACH_SLICE),<br>
> > -    * or if we tightly pack array slices at each LOD<br>
> > (ALL_SLICES_AT_EACH_LOD).<br>
> > -    */<br>
> > -   enum miptree_array_layout array_layout;<br>
> > -<br>
> > -   /**<br>
> > -    * The distance in between array slices.<br>
> > -    *<br>
> > -    * The value is the one that is sent in the surface state. The actual<br>
> > -    * meaning depends on certain criteria. Usually it is simply the<br>
> > number of<br>
> > -    * uncompressed rows between each slice. However on Gen9+ for<br>
> > compressed<br>
> > -    * surfaces it is the number of blocks. For 1D array surfaces that<br>
> > have the<br>
> > -    * mipmap tree stored horizontally it is the number of pixels between<br>
> > each<br>
> > -    * slice.<br>
> > -    *<br>
> > -    * @see RENDER_SURFACE_STATE.<wbr>SurfaceQPitch<br>
> > -    * @see 3DSTATE_DEPTH_BUFFER.<wbr>SurfaceQPitch<br>
> > -    * @see 3DSTATE_HIER_DEPTH_BUFFER.<wbr>SurfaceQPitch<br>
> > -    * @see 3DSTATE_STENCIL_BUFFER.<wbr>SurfaceQPitch<br>
> > -    */<br>
> > -   uint32_t qpitch;<br>
> > -<br>
> > -   /* Derived from the above:<br>
> > -    */<br>
> > -   GLuint total_width;<br>
> > -   GLuint total_height;<br>
> > -<br>
> >     /* Includes image offset tables: */<br>
> >     struct intel_mipmap_level level[MAX_TEXTURE_LEVELS];<br>
> ><br>
> > @@ -670,14 +454,6 @@ enum isl_dim_layout<br>
> >  get_isl_dim_layout(const struct gen_device_info *devinfo,<br>
> >                     enum isl_tiling tiling, GLenum target);<br>
> ><br>
> > -enum isl_tiling<br>
> > -intel_miptree_get_isl_tiling(<wbr>const struct intel_mipmap_tree *mt);<br>
> > -<br>
> > -void<br>
> > -intel_miptree_get_isl_surf(<wbr>struct brw_context *brw,<br>
> > -                           const struct intel_mipmap_tree *mt,<br>
> > -                           struct isl_surf *surf);<br>
> > -<br>
> >  enum isl_aux_usage<br>
> >  intel_miptree_get_aux_isl_<wbr>usage(const struct brw_context *brw,<br>
> >                                  const struct intel_mipmap_tree *mt);<br>
> > @@ -703,14 +479,6 @@ uint32_t<br>
> >  intel_miptree_get_aligned_<wbr>offset(const struct intel_mipmap_tree *mt,<br>
> >                                   uint32_t x, uint32_t y);<br>
> ><br>
> > -void intel_miptree_set_level_info(<wbr>struct intel_mipmap_tree *mt,<br>
> > -                                  GLuint level,<br>
> > -                                  GLuint x, GLuint y, GLuint d);<br>
> > -<br>
> > -void intel_miptree_set_image_<wbr>offset(struct intel_mipmap_tree *mt,<br>
> > -                                    GLuint level,<br>
> > -                                    GLuint img, GLuint x, GLuint y);<br>
> > -<br>
> >  void<br>
> >  intel_miptree_copy_slice(<wbr>struct brw_context *brw,<br>
> >                           struct intel_mipmap_tree *src_mt,<br>
> > @@ -893,15 +661,6 @@ void<br>
> >  intel_update_r8stencil(struct brw_context *brw,<br>
> >                         struct intel_mipmap_tree *mt);<br>
> ><br>
> > -/**<br>
> > - * Horizontal distance from one slice to the next in the two-dimensional<br>
> > - * miptree layout.<br>
> > - */<br>
> > -unsigned<br>
> > -brw_miptree_get_horizontal_<wbr>slice_pitch(const struct brw_context *brw,<br>
> > -                                       const struct intel_mipmap_tree *mt,<br>
> > -                                       unsigned level);<br>
> > -<br>
> >  bool<br>
> >  brw_miptree_layout(struct brw_context *brw,<br>
> >                     struct intel_mipmap_tree *mt,<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
> > index 44ea6a4562..994513189b 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>intel_screen.c<br>
> > @@ -410,15 +410,10 @@ intel_setup_image_from_mipmap_<wbr>tree(struct<br>
> > brw_context *brw, __DRIimage *image,<br>
> ><br>
> >     intel_miptree_check_level_<wbr>layer(mt, level, zoffset);<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      image->width = minify(mt->surf.phys_level0_<wbr>sa.width,<br>
> > -                            level - mt->first_level);<br>
> > -      image->height = minify(mt->surf.phys_level0_<wbr>sa.height,<br>
> > -                             level - mt->first_level);<br>
> > -   } else {<br>
> > -      image->width = minify(mt->physical_width0, level - mt->first_level);<br>
> > -      image->height = minify(mt->physical_height0, level -<br>
> > mt->first_level);<br>
> > -   }<br>
> > +   image->width = minify(mt->surf.phys_level0_<wbr>sa.width,<br>
> > +                         level - mt->first_level);<br>
> > +   image->height = minify(mt->surf.phys_level0_<wbr>sa.height,<br>
> > +                          level - mt->first_level);<br>
> >     image->pitch = mt->surf.row_pitch;<br>
> ><br>
> >     image->offset = intel_miptree_get_tile_<wbr>offsets(mt, level, zoffset,<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
> > index b042b23d9f..beed1609bd 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>
> > @@ -62,16 +62,12 @@ intel_miptree_create_for_<wbr>teximage(struct brw_context<br>
> > *brw,<br>
> ><br>
> >     intel_get_image_dims(&<wbr>intelImage->base.Base, &width, &height, &depth);<br>
> ><br>
> > -   if (old_mt && old_mt->surf.size > 0) {<br>
> > +   if (old_mt) {<br>
> >        old_width = old_mt->surf.logical_level0_<wbr>px.width;<br>
> >        old_height = old_mt->surf.logical_level0_<wbr>px.height;<br>
> >        old_depth = old_mt->surf.dim == ISL_SURF_DIM_3D ?<br>
> >                       old_mt->surf.logical_level0_<wbr>px.depth :<br>
> >                       old_mt->surf.logical_level0_<wbr>px.array_len;<br>
> > -   } else if (old_mt) {<br>
> > -      old_width = old_mt->logical_width0;<br>
> > -      old_height = old_mt->logical_height0;<br>
> > -      old_depth = old_mt->logical_depth0;<br>
> >     }<br>
> ><br>
> >     DBG("%s\n", __func__);<br>
> > @@ -198,16 +194,10 @@ intel_set_texture_image_mt(<wbr>struct brw_context *brw,<br>
> >     struct intel_texture_object *intel_texobj =<br>
> > intel_texture_object(texobj);<br>
> >     struct intel_texture_image *intel_image = intel_texture_image(image);<br>
> ><br>
> > -   if (mt->surf.size > 0) {<br>
> > -      _mesa_init_teximage_fields(&<wbr>brw->ctx, image,<br>
> > -                                 mt->surf.logical_level0_px.<wbr>width,<br>
> > -                                 mt->surf.logical_level0_px.<wbr>height, 1,<br>
> > -                                 0, internal_format, mt->format);<br>
> > -   } else {<br>
> > -      _mesa_init_teximage_fields(&<wbr>brw->ctx, image,<br>
> > -                                 mt->logical_width0, mt->logical_height0,<br>
> > 1,<br>
> > -                                 0, internal_format, mt->format);<br>
> > -   }<br>
> > +   _mesa_init_teximage_fields(&<wbr>brw->ctx, image,<br>
</div></div><div class="HOEnZb"><div class="h5">> > +                              mt->surf.logical_level0_px.<wbr>width,<br>
> > +                              mt->surf.logical_level0_px.<wbr>height, 1,<br>
> > +                              0, internal_format, mt->format);<br>
> ><br>
> >     brw->ctx.Driver.<wbr>FreeTextureImageBuffer(&brw-><wbr>ctx, image);<br>
> ><br>
> > @@ -462,12 +452,9 @@ intel_gettexsubimage_tiled_<wbr>memcpy(struct gl_context<br>
> > *ctx,<br>
> >     /* Since we are going to write raw data to the miptree, we need to<br>
> > resolve<br>
> >      * any pending fast color clears before we start.<br>
> >      */<br>
> > -   if (image->mt->surf.size > 0) {<br>
> > -      assert(image->mt->surf.<wbr>logical_level0_px.depth == 1);<br>
> > -      assert(image->mt->surf.<wbr>logical_level0_px.array_len == 1);<br>
> > -   } else {<br>
> > -      assert(image->mt->logical_<wbr>depth0 == 1);<br>
> > -   }<br>
> > +   assert(image->mt->surf.<wbr>logical_level0_px.depth == 1);<br>
> > +   assert(image->mt->surf.<wbr>logical_level0_px.array_len == 1);<br>
> > +<br>
> >     intel_miptree_access_raw(brw, image->mt, level, 0, true);<br>
> ><br>
> >     bo = image->mt->bo;<br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> > index 88cfa814a3..5953e61ec2 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>intel_tex_subimage.c<br>
> > @@ -150,12 +150,8 @@ intel_texsubimage_tiled_<wbr>memcpy(struct gl_context *<br>
> > ctx,<br>
> >     /* Since we are going to write raw data to the miptree, we need to<br>
> > resolve<br>
> >      * any pending fast color clears before we start.<br>
> >      */<br>
> > -   if (image->mt->surf.size > 0) {<br>
> > -      assert(image->mt->surf.<wbr>logical_level0_px.depth == 1);<br>
> > -      assert(image->mt->surf.<wbr>logical_level0_px.array_len == 1);<br>
> > -   } else {<br>
> > -      assert(image->mt->logical_<wbr>depth0 == 1);<br>
> > -   }<br>
> > +   assert(image->mt->surf.<wbr>logical_level0_px.depth == 1);<br>
> > +   assert(image->mt->surf.<wbr>logical_level0_px.array_len == 1);<br>
> ><br>
> >     intel_miptree_access_raw(brw, image->mt, level, 0, true);<br>
> ><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>
> ><br>
</div></div></blockquote></div><br></div></div>