<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 3, 2016 at 12:50 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@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, Aug 31, 2016 at 02:22:40PM -0700, Jason Ekstrand wrote:<br>
> ---<br>
>  src/intel/vulkan/anv_pipeline.<wbr>c       | 142 ------------------------------<wbr>---<br>
>  src/intel/vulkan/anv_private.h        |   3 -<br>
>  src/intel/vulkan/genX_<wbr>pipeline_util.h | 146 ++++++++++++++++++++++++++++++<wbr>++--<br>
>  3 files changed, 138 insertions(+), 153 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_<wbr>pipeline.c b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
> index 35acc4a..750f2fa 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>pipeline.c<br>
> +++ b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
> @@ -803,147 +803,6 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,<br>
>     return VK_SUCCESS;<br>
>  }<br>
><br>
> -void<br>
> -anv_compute_urb_partition(<wbr>struct anv_pipeline *pipeline)<br>
<br>
</span>There was no separate declaration for this function that would need to be<br>
removed?<br></blockquote><div><br></div><div>Good catch!  Fixed locally.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> -{<br>
> -   const struct gen_device_info *devinfo = &pipeline->device->info;<br>
> -<br>
> -   bool vs_present = pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT;<br>
> -   unsigned vs_size = vs_present ?<br>
> -      get_vs_prog_data(pipeline)-><wbr>base.urb_entry_size : 1;<br>
> -   unsigned vs_entry_size_bytes = vs_size * 64;<br>
> -   bool gs_present = pipeline->active_stages & VK_SHADER_STAGE_GEOMETRY_BIT;<br>
> -   unsigned gs_size = gs_present ?<br>
> -      get_gs_prog_data(pipeline)-><wbr>base.urb_entry_size : 1;<br>
> -   unsigned gs_entry_size_bytes = gs_size * 64;<br>
> -<br>
> -   /* From p35 of the Ivy Bridge PRM (section 1.7.1: 3DSTATE_URB_GS):<br>
> -    *<br>
> -    *     VS Number of URB Entries must be divisible by 8 if the VS URB Entry<br>
> -    *     Allocation Size is less than 9 512-bit URB entries.<br>
> -    *<br>
> -    * Similar text exists for GS.<br>
> -    */<br>
> -   unsigned vs_granularity = (vs_size < 9) ? 8 : 1;<br>
> -   unsigned gs_granularity = (gs_size < 9) ? 8 : 1;<br>
> -<br>
> -   /* URB allocations must be done in 8k chunks. */<br>
> -   unsigned chunk_size_bytes = 8192;<br>
> -<br>
> -   /* Determine the size of the URB in chunks. */<br>
> -   unsigned urb_chunks = pipeline->urb.total_size * 1024 / chunk_size_bytes;<br>
> -<br>
> -   /* Reserve space for push constants */<br>
> -   unsigned push_constant_kb;<br>
> -   if (pipeline->device->info.gen >= 8)<br>
> -      push_constant_kb = 32;<br>
> -   else if (pipeline->device->info.is_<wbr>haswell)<br>
> -      push_constant_kb = pipeline->device-><a href="http://info.gt" rel="noreferrer" target="_blank">info.gt</a> == 3 ? 32 : 16;<br>
> -   else<br>
> -      push_constant_kb = 16;<br>
> -<br>
> -   unsigned push_constant_bytes = push_constant_kb * 1024;<br>
> -   unsigned push_constant_chunks =<br>
> -      push_constant_bytes / chunk_size_bytes;<br>
> -<br>
> -   /* Initially, assign each stage the minimum amount of URB space it needs,<br>
> -    * and make a note of how much additional space it "wants" (the amount of<br>
> -    * additional space it could actually make use of).<br>
> -    */<br>
> -<br>
> -   /* VS has a lower limit on the number of URB entries */<br>
> -   unsigned vs_chunks =<br>
> -      ALIGN(devinfo->urb.min_vs_<wbr>entries * vs_entry_size_bytes,<br>
> -            chunk_size_bytes) / chunk_size_bytes;<br>
> -   unsigned vs_wants =<br>
> -      ALIGN(devinfo->urb.max_vs_<wbr>entries * vs_entry_size_bytes,<br>
> -            chunk_size_bytes) / chunk_size_bytes - vs_chunks;<br>
> -<br>
> -   unsigned gs_chunks = 0;<br>
> -   unsigned gs_wants = 0;<br>
> -   if (gs_present) {<br>
> -      /* There are two constraints on the minimum amount of URB space we can<br>
> -       * allocate:<br>
> -       *<br>
> -       * (1) We need room for at least 2 URB entries, since we always operate<br>
> -       * the GS in DUAL_OBJECT mode.<br>
> -       *<br>
> -       * (2) We can't allocate less than nr_gs_entries_granularity.<br>
> -       */<br>
> -      gs_chunks = ALIGN(MAX2(gs_granularity, 2) * gs_entry_size_bytes,<br>
> -                        chunk_size_bytes) / chunk_size_bytes;<br>
> -      gs_wants =<br>
> -         ALIGN(devinfo->urb.max_gs_<wbr>entries * gs_entry_size_bytes,<br>
> -               chunk_size_bytes) / chunk_size_bytes - gs_chunks;<br>
> -   }<br>
> -<br>
> -   /* There should always be enough URB space to satisfy the minimum<br>
> -    * requirements of each stage.<br>
> -    */<br>
> -   unsigned total_needs = push_constant_chunks + vs_chunks + gs_chunks;<br>
> -   assert(total_needs <= urb_chunks);<br>
> -<br>
> -   /* Mete out remaining space (if any) in proportion to "wants". */<br>
> -   unsigned total_wants = vs_wants + gs_wants;<br>
> -   unsigned remaining_space = urb_chunks - total_needs;<br>
> -   if (remaining_space > total_wants)<br>
> -      remaining_space = total_wants;<br>
> -   if (remaining_space > 0) {<br>
> -      unsigned vs_additional = (unsigned)<br>
> -         round(vs_wants * (((double) remaining_space) / total_wants));<br>
> -      vs_chunks += vs_additional;<br>
> -      remaining_space -= vs_additional;<br>
> -      gs_chunks += remaining_space;<br>
> -   }<br>
> -<br>
> -   /* Sanity check that we haven't over-allocated. */<br>
> -   assert(push_constant_chunks + vs_chunks + gs_chunks <= urb_chunks);<br>
> -<br>
> -   /* Finally, compute the number of entries that can fit in the space<br>
> -    * allocated to each stage.<br>
> -    */<br>
> -   unsigned nr_vs_entries = vs_chunks * chunk_size_bytes / vs_entry_size_bytes;<br>
> -   unsigned nr_gs_entries = gs_chunks * chunk_size_bytes / gs_entry_size_bytes;<br>
> -<br>
> -   /* Since we rounded up when computing *_wants, this may be slightly more<br>
> -    * than the maximum allowed amount, so correct for that.<br>
> -    */<br>
> -   nr_vs_entries = MIN2(nr_vs_entries, devinfo->urb.max_vs_entries);<br>
> -   nr_gs_entries = MIN2(nr_gs_entries, devinfo->urb.max_gs_entries);<br>
> -<br>
> -   /* Ensure that we program a multiple of the granularity. */<br>
> -   nr_vs_entries = ROUND_DOWN_TO(nr_vs_entries, vs_granularity);<br>
> -   nr_gs_entries = ROUND_DOWN_TO(nr_gs_entries, gs_granularity);<br>
> -<br>
> -   /* Finally, sanity check to make sure we have at least the minimum number<br>
> -    * of entries needed for each stage.<br>
> -    */<br>
> -   assert(nr_vs_entries >= devinfo->urb.min_vs_entries);<br>
> -   if (gs_present)<br>
> -      assert(nr_gs_entries >= 2);<br>
> -<br>
> -   /* Lay out the URB in the following order:<br>
> -    * - push constants<br>
> -    * - VS<br>
> -    * - GS<br>
> -    */<br>
> -   pipeline->urb.start[MESA_<wbr>SHADER_VERTEX] = push_constant_chunks;<br>
> -   pipeline->urb.size[MESA_<wbr>SHADER_VERTEX] = vs_size;<br>
> -   pipeline->urb.entries[MESA_<wbr>SHADER_VERTEX] = nr_vs_entries;<br>
> -<br>
> -   pipeline->urb.start[MESA_<wbr>SHADER_GEOMETRY] = push_constant_chunks + vs_chunks;<br>
> -   pipeline->urb.size[MESA_<wbr>SHADER_GEOMETRY] = gs_size;<br>
> -   pipeline->urb.entries[MESA_<wbr>SHADER_GEOMETRY] = nr_gs_entries;<br>
> -<br>
> -   pipeline->urb.start[MESA_<wbr>SHADER_TESS_CTRL] = push_constant_chunks;<br>
> -   pipeline->urb.size[MESA_<wbr>SHADER_TESS_CTRL] = 1;<br>
> -   pipeline->urb.entries[MESA_<wbr>SHADER_TESS_CTRL] = 0;<br>
> -<br>
> -   pipeline->urb.start[MESA_<wbr>SHADER_TESS_EVAL] = push_constant_chunks;<br>
> -   pipeline->urb.size[MESA_<wbr>SHADER_TESS_EVAL] = 1;<br>
> -   pipeline->urb.entries[MESA_<wbr>SHADER_TESS_EVAL] = 0;<br>
> -}<br>
> -<br>
>  /**<br>
>   * Copy pipeline state not marked as dynamic.<br>
>   * Dynamic state is pipeline state which hasn't been provided at pipeline<br>
> @@ -1242,7 +1101,6 @@ anv_pipeline_init(struct anv_pipeline *pipeline,<br>
>     }<br>
><br>
>     anv_pipeline_setup_l3_config(<wbr>pipeline, false);<br>
> -   anv_compute_urb_partition(<wbr>pipeline);<br>
><br>
>     const VkPipelineVertexInputStateCrea<wbr>teInfo *vi_info =<br>
>        pCreateInfo-><wbr>pVertexInputState;<br>
> diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
> index f32806c..805b3aa 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> @@ -1521,9 +1521,6 @@ struct anv_pipeline {<br>
>     struct anv_shader_bin *                      shaders[MESA_SHADER_STAGES];<br>
><br>
>     struct {<br>
> -      uint32_t                                  start[MESA_SHADER_GEOMETRY + 1];<br>
> -      uint32_t                                  size[MESA_SHADER_GEOMETRY + 1];<br>
> -      uint32_t                                  entries[MESA_SHADER_GEOMETRY + 1];<br>
>        const struct gen_l3_config *              l3_config;<br>
>        uint32_t                                  total_size;<br>
>     } urb;<br>
> diff --git a/src/intel/vulkan/genX_<wbr>pipeline_util.h b/src/intel/vulkan/genX_<wbr>pipeline_util.h<br>
> index 6518fae..b23a421 100644<br>
> --- a/src/intel/vulkan/genX_<wbr>pipeline_util.h<br>
> +++ b/src/intel/vulkan/genX_<wbr>pipeline_util.h<br>
> @@ -190,9 +190,123 @@ emit_vertex_input(struct anv_pipeline *pipeline,<br>
>  static inline void<br>
>  emit_urb_setup(struct anv_pipeline *pipeline)<br>
>  {<br>
> -#if GEN_GEN == 7 && !GEN_IS_HASWELL<br>
>     struct anv_device *device = pipeline->device;<br>
><br>
> +   bool vs_present = pipeline->active_stages & VK_SHADER_STAGE_VERTEX_BIT;<br>
> +   unsigned vs_size = vs_present ?<br>
> +      get_vs_prog_data(pipeline)-><wbr>base.urb_entry_size : 1;<br>
> +   unsigned vs_entry_size_bytes = vs_size * 64;<br>
> +   bool gs_present = pipeline->active_stages & VK_SHADER_STAGE_GEOMETRY_BIT;<br>
> +   unsigned gs_size = gs_present ?<br>
> +      get_gs_prog_data(pipeline)-><wbr>base.urb_entry_size : 1;<br>
> +   unsigned gs_entry_size_bytes = gs_size * 64;<br>
> +<br>
> +   /* From p35 of the Ivy Bridge PRM (section 1.7.1: 3DSTATE_URB_GS):<br>
> +    *<br>
> +    *     VS Number of URB Entries must be divisible by 8 if the VS URB Entry<br>
> +    *     Allocation Size is less than 9 512-bit URB entries.<br>
> +    *<br>
> +    * Similar text exists for GS.<br>
> +    */<br>
> +   unsigned vs_granularity = (vs_size < 9) ? 8 : 1;<br>
> +   unsigned gs_granularity = (gs_size < 9) ? 8 : 1;<br>
> +<br>
> +   /* URB allocations must be done in 8k chunks. */<br>
> +   unsigned chunk_size_bytes = 8192;<br>
> +<br>
> +   /* Determine the size of the URB in chunks. */<br>
> +   unsigned urb_chunks = pipeline->urb.total_size * 1024 / chunk_size_bytes;<br>
> +<br>
> +   /* Reserve space for push constants */<br>
> +   unsigned push_constant_kb;<br>
> +   if (pipeline->device->info.gen >= 8)<br>
> +      push_constant_kb = 32;<br>
> +   else if (pipeline->device->info.is_<wbr>haswell)<br>
> +      push_constant_kb = pipeline->device-><a href="http://info.gt" rel="noreferrer" target="_blank">info.gt</a> == 3 ? 32 : 16;<br>
> +   else<br>
> +      push_constant_kb = 16;<br>
> +<br>
> +   unsigned push_constant_bytes = push_constant_kb * 1024;<br>
> +   unsigned push_constant_chunks =<br>
> +      push_constant_bytes / chunk_size_bytes;<br>
> +<br>
> +   /* Initially, assign each stage the minimum amount of URB space it needs,<br>
> +    * and make a note of how much additional space it "wants" (the amount of<br>
> +    * additional space it could actually make use of).<br>
> +    */<br>
> +<br>
> +   /* VS has a lower limit on the number of URB entries */<br>
> +   unsigned vs_chunks =<br>
> +      ALIGN(device->info.urb.min_vs_<wbr>entries * vs_entry_size_bytes,<br>
> +            chunk_size_bytes) / chunk_size_bytes;<br>
> +   unsigned vs_wants =<br>
> +      ALIGN(device->info.urb.max_vs_<wbr>entries * vs_entry_size_bytes,<br>
> +            chunk_size_bytes) / chunk_size_bytes - vs_chunks;<br>
> +<br>
> +   unsigned gs_chunks = 0;<br>
> +   unsigned gs_wants = 0;<br>
> +   if (gs_present) {<br>
> +      /* There are two constraints on the minimum amount of URB space we can<br>
> +       * allocate:<br>
> +       *<br>
> +       * (1) We need room for at least 2 URB entries, since we always operate<br>
> +       * the GS in DUAL_OBJECT mode.<br>
> +       *<br>
> +       * (2) We can't allocate less than nr_gs_entries_granularity.<br>
> +       */<br>
> +      gs_chunks = ALIGN(MAX2(gs_granularity, 2) * gs_entry_size_bytes,<br>
> +                        chunk_size_bytes) / chunk_size_bytes;<br>
> +      gs_wants =<br>
> +         ALIGN(device->info.urb.max_gs_<wbr>entries * gs_entry_size_bytes,<br>
> +               chunk_size_bytes) / chunk_size_bytes - gs_chunks;<br>
> +   }<br>
> +<br>
> +   /* There should always be enough URB space to satisfy the minimum<br>
> +    * requirements of each stage.<br>
> +    */<br>
> +   unsigned total_needs = push_constant_chunks + vs_chunks + gs_chunks;<br>
> +   assert(total_needs <= urb_chunks);<br>
> +<br>
> +   /* Mete out remaining space (if any) in proportion to "wants". */<br>
> +   unsigned total_wants = vs_wants + gs_wants;<br>
> +   unsigned remaining_space = urb_chunks - total_needs;<br>
> +   if (remaining_space > total_wants)<br>
> +      remaining_space = total_wants;<br>
> +   if (remaining_space > 0) {<br>
> +      unsigned vs_additional = (unsigned)<br>
> +         round(vs_wants * (((double) remaining_space) / total_wants));<br>
> +      vs_chunks += vs_additional;<br>
> +      remaining_space -= vs_additional;<br>
> +      gs_chunks += remaining_space;<br>
> +   }<br>
> +<br>
> +   /* Sanity check that we haven't over-allocated. */<br>
> +   assert(push_constant_chunks + vs_chunks + gs_chunks <= urb_chunks);<br>
> +<br>
> +   /* Finally, compute the number of entries that can fit in the space<br>
> +    * allocated to each stage.<br>
> +    */<br>
> +   unsigned nr_vs_entries = vs_chunks * chunk_size_bytes / vs_entry_size_bytes;<br>
> +   unsigned nr_gs_entries = gs_chunks * chunk_size_bytes / gs_entry_size_bytes;<br>
> +<br>
> +   /* Since we rounded up when computing *_wants, this may be slightly more<br>
> +    * than the maximum allowed amount, so correct for that.<br>
> +    */<br>
> +   nr_vs_entries = MIN2(nr_vs_entries, device->info.urb.max_vs_<wbr>entries);<br>
> +   nr_gs_entries = MIN2(nr_gs_entries, device->info.urb.max_gs_<wbr>entries);<br>
> +<br>
> +   /* Ensure that we program a multiple of the granularity. */<br>
> +   nr_vs_entries = ROUND_DOWN_TO(nr_vs_entries, vs_granularity);<br>
> +   nr_gs_entries = ROUND_DOWN_TO(nr_gs_entries, gs_granularity);<br>
> +<br>
> +   /* Finally, sanity check to make sure we have at least the minimum number<br>
> +    * of entries needed for each stage.<br>
> +    */<br>
> +   assert(nr_vs_entries >= device->info.urb.min_vs_<wbr>entries);<br>
> +   if (gs_present)<br>
> +      assert(nr_gs_entries >= 2);<br>
> +<br>
> +#if GEN_GEN == 7 && !GEN_IS_HASWELL<br>
>     /* From the IVB PRM Vol. 2, Part 1, Section 3.2.1:<br>
>      *<br>
>      *    "A PIPE_CONTROL with Post-Sync Operation set to 1h and a depth stall<br>
> @@ -208,13 +322,29 @@ emit_urb_setup(struct anv_pipeline *pipeline)<br>
>     }<br>
>  #endif<br>
><br>
> -   for (int i = MESA_SHADER_VERTEX; i <= MESA_SHADER_GEOMETRY; i++) {<br>
> -      anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_URB_VS), urb) {<br>
> -         urb._3DCommandSubOpcode       = 48 + i;<br>
> -         urb.VSURBStartingAddress      = pipeline->urb.start[i];<br>
> -         urb.VSURBEntryAllocationSize  = pipeline->urb.size[i] - 1;<br>
> -         urb.VSNumberofURBEntries      = pipeline->urb.entries[i];<br>
> -      }<br>
> +   /* Lay out the URB in the following order:<br>
> +    * - push constants<br>
> +    * - VS<br>
> +    * - GS<br>
> +    */<br>
> +   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_URB_VS), urb) {<br>
> +      urb.VSURBStartingAddress      = push_constant_chunks;<br>
> +      urb.VSURBEntryAllocationSize  = vs_size - 1;<br>
> +      urb.VSNumberofURBEntries      = nr_vs_entries;<br>
> +   }<br>
> +<br>
> +   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_URB_HS), urb) {<br>
> +      urb.HSURBStartingAddress      = push_constant_chunks;<br>
> +   }<br>
> +<br>
> +   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_URB_DS), urb) {<br>
> +      urb.DSURBStartingAddress      = push_constant_chunks;<br>
> +   }<br>
> +<br>
> +   anv_batch_emit(&pipeline-><wbr>batch, GENX(3DSTATE_URB_GS), urb) {<br>
> +      urb.GSURBStartingAddress      = push_constant_chunks + vs_chunks;<br>
> +      urb.GSURBEntryAllocationSize  = gs_size - 1;<br>
> +      urb.GSNumberofURBEntries      = nr_gs_entries;<br>
>     }<br>
>  }<br>
><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>