Module: Mesa
Branch: master
Commit: da33347131ff88a3b7979aea2031ce6f34319ed0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=da33347131ff88a3b7979aea2031ce6f34319ed0

Author: Chia-I Wu <olva...@gmail.com>
Date:   Wed Aug 28 11:40:05 2013 +0800

glx: make the interval of LIBGL_SHOW_FPS adjustable

LIBGL_SHOW_FPS=1 makes GLX print FPS every second while other values do
nothing.  Extend it so that LIBGL_SHOW_FPS=N will print the FPS every N
seconds.

Signed-off-by: Chia-I Wu <olva...@gmail.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/glx/dri2_glx.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index c54edac..54fc21c 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -95,7 +95,7 @@ struct dri2_screen {
    void *driver;
    int fd;
 
-   Bool show_fps;
+   int show_fps_interval;
 };
 
 struct dri2_context
@@ -764,6 +764,8 @@ unsigned dri2GetSwapEventType(Display* dpy, XID drawable)
 
 static void show_fps(struct dri2_drawable *draw)
 {
+   const int interval =
+      ((struct dri2_screen *) draw->base.psc)->show_fps_interval;
    struct timeval tv;
    uint64_t current_time;
 
@@ -772,7 +774,7 @@ static void show_fps(struct dri2_drawable *draw)
 
    draw->frames++;
 
-   if (draw->previous_time + 1000000 <= current_time) {
+   if (draw->previous_time + interval * 1000000 <= current_time) {
       if (draw->previous_time) {
          fprintf(stderr, "libGL: FPS = %.1f\n",
                  ((uint64_t)draw->frames * 1000000) /
@@ -859,7 +861,7 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t 
target_msc, int64_t divisor,
                                 target_msc, divisor, remainder);
     }
 
-    if (psc->show_fps) {
+    if (psc->show_fps_interval) {
        show_fps(priv);
     }
 
@@ -1283,7 +1285,9 @@ dri2CreateScreen(int screen, struct glx_display * priv)
    free(deviceName);
 
    tmp = getenv("LIBGL_SHOW_FPS");
-   psc->show_fps = tmp && strcmp(tmp, "1") == 0;
+   psc->show_fps_interval = (tmp) ? atoi(tmp) : 0;
+   if (psc->show_fps_interval < 0)
+      psc->show_fps_interval = 0;
 
    return &psc->base;
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to