<div dir="ltr"><div><div>Here's the new commit message:<br><br>    Vulkan doesn't have a stencilWriteEnable bit like it does for depth.<br>    Instead, you have a stencil mask.  Since the stencil mask is handled as<br>    dynamic state, we have to handle it later during command buffer<br>    construction.  This helps Dota2 by a couple percent because it allows<br>    the hardware to move the depth and stencil writes to early in more<br>    cases.<br><br></div>I'm double-checking benchmark results for the whole series.<br><br></div>--Jason<br><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 7, 2017 at 2:28 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Tue, Feb 07, 2017 at 12:25:18PM -0800, Jason Ekstrand wrote:<br>
> On Tue, Feb 7, 2017 at 12:13 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
><br>
> > On Wed, Feb 01, 2017 at 08:07:22PM -0800, Jason Ekstrand wrote:<br>
> > > The only mechanism Vulkan provides for disabling stencil writes is to set<br>
> ><br>
> > This isn't the only mechanism for explicitly disabling stencil writes.<br>
> > Stencil writes can also be disabled by disabling stencil testing (as can<br>
> > be seen in this patch).<br>
> ><br>
><br>
> I guess that is technically true.  I meant "it doesn't have a<br>
> disableStencilWrites like it does for depth".  Maybe something like:<br>
><br>
> Vulkan doesn't have a stencilWriteEnable bit like it does for depth.<br>
> Instead, you have a stencil mask.  Since the stencil mask is...<br>
><br>
><br>
<br>
</span>This is better.<br>
<span class="gmail-"><br>
> > > the stencil write mask to 0.  Since that is dynamic state, we have to<br>
> > move<br>
> >                                                                         ^<br>
> >                                                                 extra word?<br>
> ><br>
<br>
</span>Ping?<br>
<span class="gmail-"><br>
> > Users can actually set the write masks at pipeline creation time. For<br>
> > that reason, I think it's clearer to say that it "may be" dynamic state<br>
> > instead of saying that it "is" dynamic state.<br>
> ><br>
><br>
> Maybe?  I guess it depends on whether you take "dynamic state" to mean<br>
> "state the client set at runtime vs. set in the pipeline" or if you just<br>
> consider it to mean the bucket of states that *may* be set at runtime.<br>
><br>
<br>
</span>You're right. anv takes the position of "may," whereas the spec takes<br>
the position of "is." It isn't necessarily clearer to default to the<br>
spec's definitions when writing commit messages for driver code.<br>
<span class="gmail-"><br>
><br>
> > > handle it late during command buffer builder.  This helps Dota2 by a<br>
> > couple<br>
> > > percent because it allows the hardware to move the depth and stencil<br>
> > writes<br>
> > > to early in more cases.<br>
> ><br>
> > I was only able to reproduce a 0.1% performance improvement with this<br>
> > patch. Could show me how you're measuring the performance changes (on or<br>
> > offline)?<br>
> ><br>
><br>
> For one thing, it was on my BDW gt3 desktop.  Maybe SKL is impacted less?<br>
><br>
<br>
</span>Ah, okay.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
><br>
> > -Nanley<br>
> ><br>
> > ><br>
> > > v2 (Jason Ekstrand): Always initialize the new pipeline variable<br>
> > > ---<br>
> > >  src/intel/vulkan/anv_private.h     | 1 +<br>
> > >  src/intel/vulkan/gen7_cmd_<wbr>buffer.c | 4 ++++<br>
> > >  src/intel/vulkan/gen8_cmd_<wbr>buffer.c | 8 ++++++++<br>
> > >  src/intel/vulkan/genX_<wbr>pipeline.c   | 4 +++-<br>
> > >  4 files changed, 16 insertions(+), 1 deletion(-)<br>
> > ><br>
> > > diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<br>
> > private.h<br>
> > > index a0cb35c..4fe3ebc 100644<br>
> > > --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> > > +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> > > @@ -1465,6 +1465,7 @@ struct anv_pipeline {<br>
> > ><br>
> > >     uint32_t                                     cs_right_mask;<br>
> > ><br>
> > > +   bool                                         writes_stencil;<br>
> > >     bool                                         depth_clamp_enable;<br>
> > ><br>
> > >     struct {<br>
> > > diff --git a/src/intel/vulkan/gen7_cmd_<wbr>buffer.c<br>
> > b/src/intel/vulkan/gen7_cmd_<wbr>buffer.c<br>
> > > index 8d68aba..013ed87 100644<br>
> > > --- a/src/intel/vulkan/gen7_cmd_<wbr>buffer.c<br>
> > > +++ b/src/intel/vulkan/gen7_cmd_<wbr>buffer.c<br>
> > > @@ -212,6 +212,10 @@ genX(cmd_buffer_flush_dynamic_<wbr>state)(struct<br>
> > anv_cmd_buffer *cmd_buffer)<br>
> > ><br>
> > >           .BackfaceStencilTestMask = d->stencil_compare_mask.back & 0xff,<br>
> > >           .BackfaceStencilWriteMask = d->stencil_write_mask.back & 0xff,<br>
> > > +<br>
> > > +         .StencilBufferWriteEnable =<br>
> > > +            (d->stencil_write_mask.front || d->stencil_write_mask.back)<br>
> > &&<br>
> > > +            pipeline->writes_stencil,<br>
> > >        };<br>
> > >        GENX(DEPTH_STENCIL_STATE_pack)<wbr>(NULL, depth_stencil_dw,<br>
> > &depth_stencil);<br>
> > ><br>
> > > diff --git a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
> > b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
> > > index ab68872..8c8de62 100644<br>
> > > --- a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
> > > +++ b/src/intel/vulkan/gen8_cmd_<wbr>buffer.c<br>
> > > @@ -224,6 +224,10 @@ genX(cmd_buffer_flush_dynamic_<wbr>state)(struct<br>
> > anv_cmd_buffer *cmd_buffer)<br>
> > ><br>
> > >           .BackfaceStencilTestMask = d->stencil_compare_mask.back & 0xff,<br>
> > >           .BackfaceStencilWriteMask = d->stencil_write_mask.back & 0xff,<br>
> > > +<br>
> > > +         .StencilBufferWriteEnable =<br>
> > > +            (d->stencil_write_mask.front || d->stencil_write_mask.back)<br>
> > &&<br>
> > > +            pipeline->writes_stencil,<br>
> > >        };<br>
> > >        GENX(3DSTATE_WM_DEPTH_STENCIL_<wbr>pack)(NULL, wm_depth_stencil_dw,<br>
> > >                                            &wm_depth_stencil);<br>
> > > @@ -271,6 +275,10 @@ genX(cmd_buffer_flush_dynamic_<wbr>state)(struct<br>
> > anv_cmd_buffer *cmd_buffer)<br>
> > ><br>
> > >           .StencilReferenceValue = d->stencil_reference.front & 0xff,<br>
> > >           .BackfaceStencilReferenceValue = d->stencil_reference.back &<br>
> > 0xff,<br>
> > > +<br>
> > > +         .StencilBufferWriteEnable =<br>
> > > +            (d->stencil_write_mask.front || d->stencil_write_mask.back)<br>
> > &&<br>
> > > +            pipeline->writes_stencil,<br>
> > >        };<br>
> > >        GEN9_3DSTATE_WM_DEPTH_STENCIL_<wbr>pack(NULL, dwords,<br>
> > &wm_depth_stencil);<br>
> > ><br>
> > > diff --git a/src/intel/vulkan/genX_<wbr>pipeline.c b/src/intel/vulkan/genX_<br>
> > pipeline.c<br>
> > > index 9d28466..18fe48c 100644<br>
> > > --- a/src/intel/vulkan/genX_<wbr>pipeline.c<br>
> > > +++ b/src/intel/vulkan/genX_<wbr>pipeline.c<br>
> > > @@ -652,12 +652,15 @@ emit_ds_state(struct anv_pipeline *pipeline,<br>
> > >        /* We're going to OR this together with the dynamic state.  We<br>
> > need<br>
> > >         * to make sure it's initialized to something useful.<br>
> > >         */<br>
> > > +      pipeline->writes_stencil = false;<br>
> > >        memset(depth_stencil_dw, 0, sizeof(depth_stencil_dw));<br>
> > >        return;<br>
> > >     }<br>
> > ><br>
> > >     /* VkBool32 depthBoundsTestEnable; // optional (depth_bounds_test) */<br>
> > ><br>
> > > +   pipeline->writes_stencil = info->stencilTestEnable;<br>
> > > +<br>
> > >  #if GEN_GEN <= 7<br>
> > >     struct GENX(DEPTH_STENCIL_STATE) depth_stencil = {<br>
> > >  #else<br>
> > > @@ -669,7 +672,6 @@ emit_ds_state(struct anv_pipeline *pipeline,<br>
> > >        .DoubleSidedStencilEnable = true,<br>
> > ><br>
> > >        .StencilTestEnable = info->stencilTestEnable,<br>
> > > -      .StencilBufferWriteEnable = info->stencilTestEnable,<br>
> > >        .StencilFailOp = vk_to_gen_stencil_op[info-><wbr>front.failOp],<br>
> > >        .StencilPassDepthPassOp = vk_to_gen_stencil_op[info-><br>
> > front.passOp],<br>
> > >        .StencilPassDepthFailOp = vk_to_gen_stencil_op[info-><br>
> > front.depthFailOp],<br>
> > > --<br>
> > > 2.5.0.400.gff86faf<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></div></div></div>