<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jan 8, 2017 at 9:26 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/intel/vulkan/anv_private.h   |  2 +<br>
 src/intel/vulkan/genX_<wbr>pipeline.c | 87 ++++++++++++++++++++++++++++++<wbr>++++++++++<br>
 src/intel/vulkan/genX_state.c    |  4 --<br>
 3 files changed, 89 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index 9e3b72e77bd..47b9eb3e94d 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -1476,6 +1476,8 @@ get_##prefix##_prog_data(<wbr>struct anv_pipeline *pipeline)              \<br>
 }<br>
<br>
 ANV_DECL_GET_PROG_DATA_FUNC(<wbr>vs, MESA_SHADER_VERTEX)<br>
+ANV_DECL_GET_PROG_DATA_FUNC(<wbr>tcs, MESA_SHADER_TESS_CTRL)<br>
+ANV_DECL_GET_PROG_DATA_FUNC(<wbr>tes, MESA_SHADER_TESS_EVAL)<br>
 ANV_DECL_GET_PROG_DATA_FUNC(<wbr>gs, MESA_SHADER_GEOMETRY)<br>
 ANV_DECL_GET_PROG_DATA_FUNC(<wbr>wm, MESA_SHADER_FRAGMENT)<br>
 ANV_DECL_GET_PROG_DATA_FUNC(<wbr>cs, MESA_SHADER_COMPUTE)<br>
diff --git a/src/intel/vulkan/genX_<wbr>pipeline.c b/src/intel/vulkan/genX_<wbr>pipeline.c<br>
index 9ff84cd2921..80b7c75a47c 100644<br>
--- a/src/intel/vulkan/genX_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/genX_<wbr>pipeline.c<br>
@@ -965,6 +965,92 @@ emit_3dstate_vs(struct anv_pipeline *pipeline)<br>
 }<br>
<br>
 static void<br>
+emit_3dstate_hs_te_ds(struct anv_pipeline *pipeline)<br>
+{<br>
+   if (!anv_pipeline_has_stage(<wbr>pipeline, MESA_SHADER_TESS_EVAL)) {<br>
+      anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_HS), hs);<br>
+      anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_TE), te);<br>
+      anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_DS), ds);<br>
+      return;<br>
+   }<br>
+<br>
+   const struct gen_device_info *devinfo = &pipeline->device->info;<br>
+   const struct anv_shader_bin *tcs_bin =<br>
+      pipeline->shaders[MESA_SHADER_<wbr>TESS_CTRL];<br>
+   const struct anv_shader_bin *tes_bin =<br>
+      pipeline->shaders[MESA_SHADER_<wbr>TESS_EVAL];<br>
+<br>
+   const struct brw_tcs_prog_data *tcs_prog_data = get_tcs_prog_data(pipeline);<br>
+   const struct brw_tes_prog_data *tes_prog_data = get_tes_prog_data(pipeline);<br>
+<br>
+   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_HS), hs) {<br>
+      hs.Enable = true;<br></blockquote><div><br></div><div>Mind whacking the XML to rename this to "FunctionEnable" to match VS, GS, and DS?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      hs.StatisticsEnable = true;<br>
+      hs.SamplerCount = get_sampler_count(tcs_bin);<br>
+      hs.BindingTableEntryCount = get_binding_table_entry_count(<wbr>tcs_bin);<br>
+      hs.MaximumNumberofThreads = devinfo->max_tcs_threads - 1;<br>
+      hs.InstanceCount = tcs_prog_data->instances - 1;<br>
+      hs.KernelStartPointer = tcs_bin->kernel.offset;<br>
+<br>
+      hs.PerThreadScratchSpace = get_scratch_space(tcs_bin);<br>
+      hs.ScratchSpaceBasePointer =<br>
+         get_scratch_address(pipeline, MESA_SHADER_TESS_CTRL, tcs_bin);<br></blockquote><div><br></div><div>When I went through and unified stuff across gens, I tried to put things in more-or-less the same order in the different packets.  Specifically,<br><br></div><div>enable<br></div><div>stats enable<br></div><div>kernel pointer<br></div><div>various other enables and bits of info<br></div><div>URB<br></div><div>scratch<br><br></div><div>I would prefer to try and be somewhat consistent there if it's ok with you.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+      hs.IncludeVertexHandles = true;<br>
+      hs.<wbr>DispatchGRFStartRegisterForURB<wbr>Data =<br>
+         tcs_prog_data->base.base.<wbr>dispatch_grf_start_reg;<br>
+      hs.VertexURBEntryReadLength = 0;<br>
+      hs.VertexURBEntryReadOffset = 0;<br>
+   }<br>
+<br>
+   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_TE), te) {<br>
+      te.Partitioning = tes_prog_data->partitioning;<br>
+      te.OutputTopology = tes_prog_data->output_<wbr>topology;<br>
+      te.TEDomain = tes_prog_data->domain;<br>
+      te.TEEnable = true;<br>
+      te.<wbr>MaximumTessellationFactorOdd = 63.0;<br>
+      te.<wbr>MaximumTessellationFactorNotOd<wbr>d = 64.0;<br>
+   }<br>
+<br>
+   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_DS), ds) {<br>
+      ds.KernelStartPointer = tes_bin->kernel.offset;<br>
+      ds.SamplerCount = get_sampler_count(tes_bin);<br>
+      ds.BindingTableEntryCount = get_binding_table_entry_count(<wbr>tes_bin);<br>
+<br>
+      ds.PerThreadScratchSpace = get_scratch_space(tes_bin);<br>
+      ds.ScratchSpaceBasePointer =<br>
+         get_scratch_address(pipeline, MESA_SHADER_TESS_EVAL, tes_bin);<br>
+<br>
+      ds.<wbr>DispatchGRFStartRegisterForURB<wbr>Data =<br>
+         tes_prog_data->base.base.<wbr>dispatch_grf_start_reg;<br>
+      ds.PatchURBEntryReadLength = tes_prog_data->base.urb_read_<wbr>length;<br>
+      ds.PatchURBEntryReadOffset = 0;<br>
+      ds.MaximumNumberofThreads = devinfo->max_tes_threads - 1;<br>
+      ds.StatisticsEnable = true;<br>
+<br>
+      ds.ComputeWCoordinateEnable =<br>
+         tes_prog_data->domain == BRW_TESS_DOMAIN_TRI;<br>
+      ds.FunctionEnable = true;<br>
+<br>
+#if GEN_GEN >= 8<br>
+      ds.DispatchMode =<br>
+         tes_prog_data->base.dispatch_<wbr>mode == DISPATCH_MODE_SIMD8 ?<br>
+            DISPATCH_MODE_SIMD8_SINGLE_<wbr>PATCH :<br>
+            DISPATCH_MODE_SIMD4X2;<br>
+<br>
+      ds.<wbr>UserClipDistanceClipTestEnable<wbr>Bitmask =<br>
+         tes_prog_data->base.clip_<wbr>distance_mask;<br>
+      ds.<wbr>UserClipDistanceCullTestEnable<wbr>Bitmask =<br>
+         tes_prog_data->base.cull_<wbr>distance_mask;<br>
+<br>
+      ds.<wbr>VertexURBEntryOutputReadOffset = 1;<br>
+      ds.VertexURBEntryOutputLength =<br>
+         (tes_prog_data->base.vue_map.<wbr>num_slots + 1) / 2 - 1;<br>
+#endif<br>
+   }<br>
+}<br>
+<br>
+static void<br>
 emit_3dstate_gs(struct anv_pipeline *pipeline)<br>
 {<br>
    const struct gen_device_info *devinfo = &pipeline->device->info;<br>
@@ -1315,6 +1401,7 @@ genX(graphics_pipeline_create)<wbr>(<br>
 #endif<br>
<br>
    emit_3dstate_vs(pipeline);<br>
+   emit_3dstate_hs_te_ds(<wbr>pipeline);<br>
    emit_3dstate_gs(pipeline);<br>
    emit_3dstate_sbe(pipeline);<br>
    emit_3dstate_wm(pipeline, subpass, pCreateInfo-><wbr>pMultisampleState);<br>
diff --git a/src/intel/vulkan/genX_state.<wbr>c b/src/intel/vulkan/genX_state.<wbr>c<br>
index 0f621f9a275..fd8f8ac9ce0 100644<br>
--- a/src/intel/vulkan/genX_state.<wbr>c<br>
+++ b/src/intel/vulkan/genX_state.<wbr>c<br>
@@ -55,10 +55,6 @@ genX(init_device_state)(struct anv_device *device)<br>
    anv_batch_emit(&batch, GENX(3DSTATE_VF_STATISTICS), vfs)<br>
       vfs.StatisticsEnable = true;<br>
<br>
-   anv_batch_emit(&batch, GENX(3DSTATE_HS), hs);<br>
-   anv_batch_emit(&batch, GENX(3DSTATE_TE), ts);<br>
-   anv_batch_emit(&batch, GENX(3DSTATE_DS), ds);<br>
-<br>
    anv_batch_emit(&batch, GENX(3DSTATE_AA_LINE_<wbr>PARAMETERS), aa);<br>
<br>
    anv_batch_emit(&batch, GENX(3DSTATE_DRAWING_<wbr>RECTANGLE), rect) {<br>
<span class="HOEnZb"><font color="#888888">--<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>
</font></span></blockquote></div><br></div></div>