<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 7, 2017 at 12:13 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">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>
</span>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).<span class=""><br></span></blockquote><div><br></div><div>I guess that is technically true.  I meant "it doesn't have a disableStencilWrites like it does for depth".  Maybe something like:<br><br></div><div>Vulkan doesn't have a stencilWriteEnable bit like it does for depth.  Instead, you have a stencil mask.  Since the stencil mask is...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> the stencil write mask to 0.  Since that is dynamic state, we have to move<br>
</span>                                                                        ^<br>
                                                                extra word?<br>
<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.<span class=""><br></span></blockquote><div><br></div><div>Maybe?  I guess it depends on whether you take "dynamic state" to mean "state the client set at runtime vs. set in the pipeline" or if you just consider it to mean the bucket of states that *may* be set at runtime.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> handle it late during command buffer builder.  This helps Dota2 by a couple<br>
> percent because it allows the hardware to move the depth and stencil writes<br>
> to early in more cases.<br>
<br>
</span>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></blockquote><div><br></div><div>For one thing, it was on my BDW gt3 desktop.  Maybe SKL is impacted less?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Nanley<br>
<div><div class="h5"><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_<wbr>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 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 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>
> +            pipeline->writes_stencil,<br>
>        };<br>
>        GENX(DEPTH_STENCIL_STATE_pack)<wbr>(NULL, depth_stencil_dw, &depth_stencil);<br>
><br>
> diff --git a/src/intel/vulkan/gen8_cmd_<wbr>buffer.c 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 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>
> +            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 anv_cmd_buffer *cmd_buffer)<br>
><br>
>           .StencilReferenceValue = d->stencil_reference.front & 0xff,<br>
>           .BackfaceStencilReferenceValue = d->stencil_reference.back & 0xff,<br>
> +<br>
> +         .StencilBufferWriteEnable =<br>
> +            (d->stencil_write_mask.front || d->stencil_write_mask.back) &&<br>
> +            pipeline->writes_stencil,<br>
>        };<br>
>        GEN9_3DSTATE_WM_DEPTH_STENCIL_<wbr>pack(NULL, dwords, &wm_depth_stencil);<br>
><br>
> diff --git a/src/intel/vulkan/genX_<wbr>pipeline.c b/src/intel/vulkan/genX_<wbr>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 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-><wbr>front.passOp],<br>
>        .StencilPassDepthFailOp = vk_to_gen_stencil_op[info-><wbr>front.depthFailOp],<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<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>
</blockquote></div><br></div></div>