[Mesa-dev] [RFC 08/27] i965/fs: Configure w-tiled stencil surfaces as y-tiled on gen6/7

Eric Anholt eric at anholt.net
Mon Feb 24 10:59:03 PST 2014


Topi Pohjolainen <topi.pohjolainen at intel.com> writes:

> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 28 ++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 6f23cec..2e841d9 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -194,12 +194,36 @@ const struct intel_mipmap_tree *
>  brw_get_texture_surface(const struct gl_texture_object *tex_obj,
>                          struct brw_wm_surface *surface)
>  {
> -   const struct intel_texture_object *intel_tex = intel_texture_object(tex_obj);
> +   const struct intel_texture_object *intel_tex =
> +      (const struct intel_texture_object *)tex_obj;
>     const struct gl_texture_image *first = tex_obj->Image[0][tex_obj->BaseLevel];
>     const struct intel_mipmap_tree *mt = intel_tex->mt;
>  
>     if (tex_obj->StencilSampling && first->_BaseFormat == GL_DEPTH_STENCIL) {
> -      assert(!"Stencil indexing shouldn't be enabled yet");
> +      const unsigned level = tex_obj->BaseLevel - mt->first_level;
> +
> +      mt = mt->stencil_mt;
> +
> +      /* Stencil is really W-tiled but as the hardware does not support
> +       * sampling from it, it needs to be treated as Y-tiled with adjusted
> +       * dimensions instead. Y-tiles are twice as wide and half as high as W.
> +       * Also one needs to take into account that both tilings consist of
> +       * 8x4 subtiles.
> +       */
> +      const unsigned x_align = 8, y_align = 4;
> +
> +      surface->tiling = I915_TILING_Y;
> +      surface->width = ALIGN(minify(mt->physical_width0, level), x_align) * 2;
> +      surface->height = ALIGN(minify(mt->physical_height0, level), y_align) / 2;
> +      surface->pitch = 2 * mt->region->pitch;
> +      surface->min_lod = 0;
> +      surface->mip_count = 0;
> +      surface->depth = 1;
> +
> +      /* Texture surfaces are always resolved to the layer zero. */
> +      surface->page_offset = intel_miptree_get_tile_offsets(
> +                                mt, level, 0, true,
> +                                &surface->tile_x, &surface->tile_y);

I'm skeptical of this getter -- if you're not just dereferencing the
miptree, something is probably wrong, and Ken's changes for
stencil_texturing looked much more like what I was expecting.  In
particular, it looks like in yours, multiple-miplevel information is
dropped, and the width/height adjustments you're doing mean that you
couldn't sample from multiple miplevels anyway.

Also, all these 2 * mt->region->pitches I'm seeing related to stencil
make me wonder if we can't just change the region pitch to be that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140224/7b6fdff9/attachment.pgp>


More information about the mesa-dev mailing list