[Mesa-dev] [PATCH] glx/dri2: print FPS when env var MESA_SHOW_FPS is 1

Michel Dänzer michel at daenzer.net
Tue Jan 3 23:40:53 PST 2012


On Mit, 2012-01-04 at 06:05 +0100, Marek Olšák wrote: 
> This is useful for apps which don't print FPS.
> Only enabled in SwapBuffers.
> ---
>  src/glx/dri2_glx.c |   36 +++++++++++++++++++++++++++++++++++-
>  1 files changed, 35 insertions(+), 1 deletions(-)
> 
> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
> index a9bcebf..394823a 100644
> --- a/src/glx/dri2_glx.c
> +++ b/src/glx/dri2_glx.c
> @@ -576,6 +582,26 @@ unsigned dri2GetSwapEventType(Display* dpy, XID drawable)
>        return glx_dpy->codes->first_event + GLX_BufferSwapComplete;
>  }
>  
> +static void show_fps()
> +{
> +   struct glx_context *gc = __glXGetCurrentContext();
> +   struct dri2_context *ctx = (struct dri2_context *)gc;

glXSwapBuffers doesn't require a current context (or that the drawable
being swapped is bound to the current context). The information should
probably be tracked per drawable instead.


> @@ -611,9 +637,14 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
>  
>         DRI2SwapBuffers(psc->base.dpy, pdraw->xDrawable,
>  		       target_msc, divisor, remainder, &ret);
> +

Spurious whitespace-only change.


> #endif
>      }
>  
> +    if (psc->show_fps) {
> +       show_fps();
> +    }
> +
>      /* Old servers don't send invalidate events */
>      if (!pdp->invalidateAvailable)
>         dri2InvalidateBuffers(dpyPriv->dpy, pdraw->xDrawable);

This really measures how quickly requests are sent to the X server. When
possible, it might be more accurate to use the information from the
completion events instead. Not a blocker though.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the mesa-dev mailing list