<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEEDINFO "
   title="NEEDINFO - [SNB] INTEL_DEBUG=nohiz is likely broken for depth/stencil buffers"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=109985#c13">Comment # 13</a>
              on <a class="bz_bug_link 
          bz_status_NEEDINFO "
   title="NEEDINFO - [SNB] INTEL_DEBUG=nohiz is likely broken for depth/stencil buffers"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=109985">bug 109985</a>
              from <span class="vcard"><a class="email" href="mailto:nanleychery@gmail.com" title="Nanley Chery <nanleychery@gmail.com>"> <span class="fn">Nanley Chery</span></a>
</span></b>
        <pre>(In reply to asimiklit from <a href="show_bug.cgi?id=109985#c12">comment #12</a>)
<span class="quote">> (In reply to Nanley Chery from <a href="show_bug.cgi?id=109985#c0">comment #0</a>)
> > For SNB, INTEL_DEBUG=nohiz seems to be broken in two places:
> > 
> > 1. In miptree_create() in intel_mipmap_tree.c. Trying to create a
> > depth/stencil buffer will cause a depth miptree to be created without
> > stencil.

> As far as found this code disallows us to create combined depth/stencil on
> SNB:
>    mesa_format mt_fmt = format;
>    if (!_mesa_is_format_color_format(format) && devinfo->gen >= 6) {
>       /* Fix up the Z miptree format for how we're splitting out separate
>        * stencil. Gen7 expects there to be no stencil bits in its depth
> buffer.
>        */
>       mt_fmt = intel_depth_format_for_depthstencil_format(format);
>    }

>    Note: This code just replaces MESA_FORMAT_Z24_UNORM_S8_UINT by
> MESA_FORMAT_Z24_UNORM_X8_UINT
>          but in this case 'mt_surf_usage' does not return a
> ISL_SURF_USAGE_STENCIL_BIT and that leads to
>          an assertion: assert(src_surf->surf->usage &
> ISL_SURF_USAGE_STENCIL_BIT); in a blorp_blit function.
>          PS: Actually I didn't check if this assertion actually matter.

> But just avoiding of this code doesn't make us happy too (
> Because we fail a choosing of a surf tiling method and
> "isl_surf_choose_tiling" always returns false.

> Now I am investigates a SNB PRM for the valid combinations of tiling methods
> with combined depth/stencil.

> Any advices or suggestions are welcome :)
> </span >

The cause of this problem is that we have two non-equivalent conditions for
selecting the main miptree format and creating a separate stencil miptree: The
condition you mentioned above and the call to needs_separate_stencil(). One
solution is to refactor and reuse needs_separate_stencil() for the format
selection.

<span class="quote">> > 
> > 2. In isl_genX(emit_depth_stencil_hiz_s) in isl_emit_depth_stencil.c.
> > Emitting a depth/stencil buffer instruction will unconditionally force HiZ
> > on.

> It happens because we create a separate stencil here regardless "nohiz" flag
> (under SNB we always jump into 'true' branch in the following code):

>    if (screen->devinfo.has_hiz_and_separate_stencil) {
>       rb = intel_create_private_renderbuffer(screen,
>                                              MESA_FORMAT_Z24_UNORM_X8_UINT,
>                                              num_samples);
>       _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
>       rb = intel_create_private_renderbuffer(screen, MESA_FORMAT_S_UINT8,
>                                              num_samples);
>       _mesa_attach_and_own_rb(fb, BUFFER_STENCIL, &rb->Base.Base);
>    } else {
>       /*
>        * Use combined depth/stencil. Note that the renderbuffer is
>        * attached to two attachment points.
>        */
>       rb = intel_create_private_renderbuffer(screen,
>                                              MESA_FORMAT_Z24_UNORM_S8_UINT,
>                                              num_samples);
>       _mesa_attach_and_own_rb(fb, BUFFER_DEPTH, &rb->Base.Base);
>       _mesa_attach_and_reference_rb(fb, BUFFER_STENCIL, &rb->Base.Base);
>    }

> A separate stencil forces us to emit a "Hierarchical Depth Buffer Enable" as
> a TRUE because of:
>    SNB PRM Vol 2 Part 1 about field 'Separate Stencil Buffer Enable':
>    [DevSNB]: This field must be set to the same value (enabled or disabled)
> as Hierarchical Depth Buffer Enable
> </span >

I see.

<span class="quote">> So looks like we need to create a combined depth/stencil there for
> has_separate_stencil = false
> case but as you mentioned above we unable to create combined depth/stencil
> due to issue 1.
> </span >

I'm not very familiar with this section of code. My understanding of it is that
we create object(s) to represent the depth-stencil portion of the default
framebuffer here. Sometime later we create a miptree for each object. If that's
true, we can get rid of the true branch. The miptree creation code will create
a separate stencil buffer internally.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>