[Mesa-dev] [PATCH] glx/dri2: print FPS when env var MESA_SHOW_FPS is 1
Marek Olšák
maraeo at gmail.com
Wed Jan 4 06:04:49 PST 2012
2012/1/4 Michel Dänzer <michel at daenzer.net>:
> 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.
Okay, I'll make the state per drawable, but dri2Throttle calls
__glXGetCurrentContext() too.
>
>
>> @@ -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.
Sorry, I am adding something to glx/dri2 for the first time. What
completion events? It doesn't matter if the measuring is done before
or after SwapBuffers. The only requirement is that it must be done
once per frame.
Marek
More information about the mesa-dev
mailing list