[Mesa-dev] [PATCH] radv: flush pending query reset caches before copying results

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Mon Jun 3 13:26:25 UTC 2019


r-b

On Fri, May 24, 2019 at 10:06 AM Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
>
> From the Vulkan spec 1.1.108:
>    "vkCmdCopyQueryPoolResults is guaranteed to see the effect of
>     previous uses of vkCmdResetQueryPool in the same queue, without any
>     additional synchronization."
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/amd/vulkan/radv_query.c | 40 +++++++++++++++++++++++--------------
>  1 file changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c
> index 0bc7f8390b6..be1cf589d63 100644
> --- a/src/amd/vulkan/radv_query.c
> +++ b/src/amd/vulkan/radv_query.c
> @@ -1274,6 +1274,21 @@ VkResult radv_GetQueryPoolResults(
>         return result;
>  }
>
> +static void emit_query_flush(struct radv_cmd_buffer *cmd_buffer,
> +                            struct radv_query_pool *pool)
> +{
> +       if (cmd_buffer->pending_reset_query) {
> +               if (pool->size >= RADV_BUFFER_OPS_CS_THRESHOLD) {
> +                       /* Only need to flush caches if the query pool size is
> +                        * large enough to be resetted using the compute shader
> +                        * path. Small pools don't need any cache flushes
> +                        * because we use a CP dma clear.
> +                        */
> +                       si_emit_cache_flush(cmd_buffer);
> +               }
> +       }
> +}
> +
>  void radv_CmdCopyQueryPoolResults(
>      VkCommandBuffer                             commandBuffer,
>      VkQueryPool                                 queryPool,
> @@ -1296,6 +1311,16 @@ void radv_CmdCopyQueryPoolResults(
>         radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, pool->bo);
>         radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, dst_buffer->bo);
>
> +       /* From the Vulkan spec 1.1.108:
> +        *
> +        * "vkCmdCopyQueryPoolResults is guaranteed to see the effect of
> +        *  previous uses of vkCmdResetQueryPool in the same queue, without any
> +        *  additional synchronization."
> +        *
> +        * So, we have to flush the caches if the compute shader path was used.
> +        */
> +       emit_query_flush(cmd_buffer, pool);
> +
>         switch (pool->type) {
>         case VK_QUERY_TYPE_OCCLUSION:
>                 if (flags & VK_QUERY_RESULT_WAIT_BIT) {
> @@ -1471,21 +1496,6 @@ static unsigned event_type_for_stream(unsigned stream)
>         }
>  }
>
> -static void emit_query_flush(struct radv_cmd_buffer *cmd_buffer,
> -                            struct radv_query_pool *pool)
> -{
> -       if (cmd_buffer->pending_reset_query) {
> -               if (pool->size >= RADV_BUFFER_OPS_CS_THRESHOLD) {
> -                       /* Only need to flush caches if the query pool size is
> -                        * large enough to be resetted using the compute shader
> -                        * path. Small pools don't need any cache flushes
> -                        * because we use a CP dma clear.
> -                        */
> -                       si_emit_cache_flush(cmd_buffer);
> -               }
> -       }
> -}
> -
>  static void emit_begin_query(struct radv_cmd_buffer *cmd_buffer,
>                              uint64_t va,
>                              VkQueryType query_type,
> --
> 2.21.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