[Mesa-dev] [PATCH 3/3] radv: prefetch VBO descriptors at the right place

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Sun Nov 12 22:13:48 UTC 2017


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

for the series.

On Wed, Nov 8, 2017 at 12:12 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Just after the vertex shader.
>
> This seems to give a minor boost for, at least, Serious Sam
> Fusion 2017 and Dawn of War 3. I don't see any real impacts
> with The Talos Principle.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/amd/vulkan/radv_cmd_buffer.c | 16 ++++++++++++++++
>  src/amd/vulkan/radv_private.h    |  5 +++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index b7f101eabb..a27d380eb7 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -668,6 +668,17 @@ radv_emit_prefetch_TC_L2_async(struct radv_cmd_buffer *cmd_buffer, uint64_t va,
>                 si_cp_dma_prefetch(cmd_buffer, va, size);
>  }
>
> +static void
> +radv_emit_VBO_descriptors_prefetch(struct radv_cmd_buffer *cmd_buffer)
> +{
> +       if (cmd_buffer->state.vb_prefetch_dirty) {
> +               radv_emit_prefetch_TC_L2_async(cmd_buffer,
> +                                              cmd_buffer->state.vb_va,
> +                                              cmd_buffer->state.vb_size);
> +               cmd_buffer->state.vb_prefetch_dirty = false;
> +       }
> +}
> +
>  static void
>  radv_emit_shader_prefetch(struct radv_cmd_buffer *cmd_buffer,
>                           struct radv_shader_variant *shader)
> @@ -691,6 +702,7 @@ radv_emit_prefetch(struct radv_cmd_buffer *cmd_buffer,
>  {
>         radv_emit_shader_prefetch(cmd_buffer,
>                                   pipeline->shaders[MESA_SHADER_VERTEX]);
> +       radv_emit_VBO_descriptors_prefetch(cmd_buffer);
>         radv_emit_shader_prefetch(cmd_buffer,
>                                   pipeline->shaders[MESA_SHADER_TESS_CTRL]);
>         radv_emit_shader_prefetch(cmd_buffer,
> @@ -1827,6 +1839,10 @@ radv_cmd_buffer_update_vertex_descriptors(struct radv_cmd_buffer *cmd_buffer, bo
>
>                 radv_emit_userdata_address(cmd_buffer, cmd_buffer->state.pipeline, MESA_SHADER_VERTEX,
>                                            AC_UD_VS_VERTEX_BUFFERS, va);
> +
> +               cmd_buffer->state.vb_va = va;
> +               cmd_buffer->state.vb_size = count * 16;
> +               cmd_buffer->state.vb_prefetch_dirty = true;
>         }
>         cmd_buffer->state.vb_dirty = false;
>
> diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
> index 0f48681c94..83cc01ede7 100644
> --- a/src/amd/vulkan/radv_private.h
> +++ b/src/amd/vulkan/radv_private.h
> @@ -809,7 +809,12 @@ struct radv_attachment_state {
>  };
>
>  struct radv_cmd_state {
> +       /* Vertex descriptors */
>         bool                                          vb_dirty;
> +       bool                                          vb_prefetch_dirty;
> +       uint64_t                                      vb_va;
> +       unsigned                                      vb_size;
> +
>         bool                                          push_descriptors_dirty;
>         bool predicating;
>         radv_cmd_dirty_mask_t                         dirty;
> --
> 2.15.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list