[Mesa-dev] st/mesa: add ARB_pipeline_statistics_query support

Submitted by Ilia Mirkin on Feb. 14, 2015, 7:16 a.m.

Details

Message ID 1423898218-8337-1-git-send-email-imirkin@alum.mit.edu
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Ilia Mirkin Feb. 14, 2015, 7:16 a.m.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---

This applies on top of Ben Widawsky's patch series. Mildly tested on
nvc0 and llvmpipe/softpipe.

 src/mesa/state_tracker/st_cb_queryobj.c | 58 ++++++++++++++++++++++++++++++---
 src/mesa/state_tracker/st_extensions.c  |  1 +
 2 files changed, 55 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index 489f537..71222e8 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -110,6 +110,19 @@  st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
       else
          type = PIPE_QUERY_TIMESTAMP;
       break;
+   case GL_VERTICES_SUBMITTED_ARB:
+   case GL_PRIMITIVES_SUBMITTED_ARB:
+   case GL_VERTEX_SHADER_INVOCATIONS_ARB:
+   case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
+   case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
+   case GL_GEOMETRY_SHADER_INVOCATIONS:
+   case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
+   case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
+   case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
+   case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
+   case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
+      type = PIPE_QUERY_PIPELINE_STATISTICS;
+      break;
    default:
       assert(0 && "unexpected query target in st_BeginQuery()");
       return;
@@ -178,6 +191,8 @@  get_query_result(struct pipe_context *pipe,
                  struct st_query_object *stq,
                  boolean wait)
 {
+   union pipe_query_result data;
+
    if (!stq->pq) {
       /* Only needed in case we failed to allocate the gallium query earlier.
        * Return TRUE so we don't spin on this forever.
@@ -185,11 +200,46 @@  get_query_result(struct pipe_context *pipe,
       return TRUE;
    }
 
-   if (!pipe->get_query_result(pipe,
-                               stq->pq,
-                               wait,
-                               (void *)&stq->base.Result)) {
+   if (!pipe->get_query_result(pipe, stq->pq, wait, &data))
       return FALSE;
+
+   switch (stq->base.Target) {
+   case GL_VERTICES_SUBMITTED_ARB:
+      stq->base.Result = data.pipeline_statistics.ia_vertices;
+      break;
+   case GL_PRIMITIVES_SUBMITTED_ARB:
+      stq->base.Result = data.pipeline_statistics.ia_primitives;
+      break;
+   case GL_VERTEX_SHADER_INVOCATIONS_ARB:
+      stq->base.Result = data.pipeline_statistics.vs_invocations;
+      break;
+   case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
+      stq->base.Result = data.pipeline_statistics.hs_invocations;
+      break;
+   case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
+      stq->base.Result = data.pipeline_statistics.ds_invocations;
+      break;
+   case GL_GEOMETRY_SHADER_INVOCATIONS:
+      stq->base.Result = data.pipeline_statistics.gs_invocations;
+      break;
+   case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
+      stq->base.Result = data.pipeline_statistics.gs_primitives;
+      break;
+   case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
+      stq->base.Result = data.pipeline_statistics.ps_invocations;
+      break;
+   case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
+      stq->base.Result = data.pipeline_statistics.cs_invocations;
+      break;
+   case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
+      stq->base.Result = data.pipeline_statistics.c_invocations;
+      break;
+   case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
+      stq->base.Result = data.pipeline_statistics.c_primitives;
+      break;
+   default:
+      stq->base.Result = data.u64;
+      break;
    }
 
    if (stq->base.Target == GL_TIME_ELAPSED &&
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 2b5cde2..9757b3a 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -426,6 +426,7 @@  void st_init_extensions(struct pipe_screen *screen,
       { o(ARB_instanced_arrays),             PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR  },
       { o(ARB_occlusion_query),              PIPE_CAP_OCCLUSION_QUERY                  },
       { o(ARB_occlusion_query2),             PIPE_CAP_OCCLUSION_QUERY                  },
+      { o(ARB_pipeline_statistics_query),    PIPE_CAP_QUERY_PIPELINE_STATISTICS        },
       { o(ARB_point_sprite),                 PIPE_CAP_POINT_SPRITE                     },
       { o(ARB_seamless_cube_map),            PIPE_CAP_SEAMLESS_CUBE_MAP                },
       { o(ARB_shader_stencil_export),        PIPE_CAP_SHADER_STENCIL_EXPORT            },

Comments

Reviewed-by: Marek Olšák <marek.olsak@amd.com>

Could you please update the release notes as well (mentioning all
drivers supporting it)?

Thanks,

Marek

On Sat, Feb 14, 2015 at 8:16 AM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
>
> This applies on top of Ben Widawsky's patch series. Mildly tested on
> nvc0 and llvmpipe/softpipe.
>
>  src/mesa/state_tracker/st_cb_queryobj.c | 58 ++++++++++++++++++++++++++++++---
>  src/mesa/state_tracker/st_extensions.c  |  1 +
>  2 files changed, 55 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
> index 489f537..71222e8 100644
> --- a/src/mesa/state_tracker/st_cb_queryobj.c
> +++ b/src/mesa/state_tracker/st_cb_queryobj.c
> @@ -110,6 +110,19 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
>        else
>           type = PIPE_QUERY_TIMESTAMP;
>        break;
> +   case GL_VERTICES_SUBMITTED_ARB:
> +   case GL_PRIMITIVES_SUBMITTED_ARB:
> +   case GL_VERTEX_SHADER_INVOCATIONS_ARB:
> +   case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
> +   case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
> +   case GL_GEOMETRY_SHADER_INVOCATIONS:
> +   case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
> +   case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
> +   case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
> +   case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
> +   case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
> +      type = PIPE_QUERY_PIPELINE_STATISTICS;
> +      break;
>     default:
>        assert(0 && "unexpected query target in st_BeginQuery()");
>        return;
> @@ -178,6 +191,8 @@ get_query_result(struct pipe_context *pipe,
>                   struct st_query_object *stq,
>                   boolean wait)
>  {
> +   union pipe_query_result data;
> +
>     if (!stq->pq) {
>        /* Only needed in case we failed to allocate the gallium query earlier.
>         * Return TRUE so we don't spin on this forever.
> @@ -185,11 +200,46 @@ get_query_result(struct pipe_context *pipe,
>        return TRUE;
>     }
>
> -   if (!pipe->get_query_result(pipe,
> -                               stq->pq,
> -                               wait,
> -                               (void *)&stq->base.Result)) {
> +   if (!pipe->get_query_result(pipe, stq->pq, wait, &data))
>        return FALSE;
> +
> +   switch (stq->base.Target) {
> +   case GL_VERTICES_SUBMITTED_ARB:
> +      stq->base.Result = data.pipeline_statistics.ia_vertices;
> +      break;
> +   case GL_PRIMITIVES_SUBMITTED_ARB:
> +      stq->base.Result = data.pipeline_statistics.ia_primitives;
> +      break;
> +   case GL_VERTEX_SHADER_INVOCATIONS_ARB:
> +      stq->base.Result = data.pipeline_statistics.vs_invocations;
> +      break;
> +   case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
> +      stq->base.Result = data.pipeline_statistics.hs_invocations;
> +      break;
> +   case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
> +      stq->base.Result = data.pipeline_statistics.ds_invocations;
> +      break;
> +   case GL_GEOMETRY_SHADER_INVOCATIONS:
> +      stq->base.Result = data.pipeline_statistics.gs_invocations;
> +      break;
> +   case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
> +      stq->base.Result = data.pipeline_statistics.gs_primitives;
> +      break;
> +   case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
> +      stq->base.Result = data.pipeline_statistics.ps_invocations;
> +      break;
> +   case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
> +      stq->base.Result = data.pipeline_statistics.cs_invocations;
> +      break;
> +   case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
> +      stq->base.Result = data.pipeline_statistics.c_invocations;
> +      break;
> +   case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
> +      stq->base.Result = data.pipeline_statistics.c_primitives;
> +      break;
> +   default:
> +      stq->base.Result = data.u64;
> +      break;
>     }
>
>     if (stq->base.Target == GL_TIME_ELAPSED &&
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 2b5cde2..9757b3a 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -426,6 +426,7 @@ void st_init_extensions(struct pipe_screen *screen,
>        { o(ARB_instanced_arrays),             PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR  },
>        { o(ARB_occlusion_query),              PIPE_CAP_OCCLUSION_QUERY                  },
>        { o(ARB_occlusion_query2),             PIPE_CAP_OCCLUSION_QUERY                  },
> +      { o(ARB_pipeline_statistics_query),    PIPE_CAP_QUERY_PIPELINE_STATISTICS        },
>        { o(ARB_point_sprite),                 PIPE_CAP_POINT_SPRITE                     },
>        { o(ARB_seamless_cube_map),            PIPE_CAP_SEAMLESS_CUBE_MAP                },
>        { o(ARB_shader_stencil_export),        PIPE_CAP_SHADER_STENCIL_EXPORT            },
> --
> 2.0.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
On Sat, Feb 14, 2015 at 1:11 PM, Marek Olšák <maraeo@gmail.com> wrote:
> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
>
> Could you please update the release notes as well (mentioning all
> drivers supporting it)?

Will do. By my count, that's

ilo (but usually not mentioned in release notes)
nvc0
r600
radeonsi
softpipe

  -ilia
I only know that it works on r600g and radeonsi. Not sure about the
other drivers.

Marek

On Sat, Feb 14, 2015 at 7:18 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> On Sat, Feb 14, 2015 at 1:11 PM, Marek Olšák <maraeo@gmail.com> wrote:
>> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
>>
>> Could you please update the release notes as well (mentioning all
>> drivers supporting it)?
>
> Will do. By my count, that's
>
> ilo (but usually not mentioned in release notes)
> nvc0
> r600
> radeonsi
> softpipe
>
>   -ilia