]> git.cworth.org Git - fips/commitdiff
Simplify metrics interface by dropping metrics_counter_new
authorCarl Worth <cworth@cworth.org>
Tue, 15 Oct 2013 20:20:33 +0000 (13:20 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 15 Oct 2013 20:20:33 +0000 (13:20 -0700)
None of the callers of this function were doing anything with the
returned value other than passing it directly to
metrics_counter_start. So it's simpler to just fold the contents of
the metrics_counter_new function into the body of
metrics_counter_start itself.

glwrap.c
metrics.c
metrics.h

index 3c751cc4e19832aa49d55516b8b38b00aea9033b..ebe7e54ca67386d1e51d648dde3ba5fcc8b39f1d 100644 (file)
--- a/glwrap.c
+++ b/glwrap.c
@@ -111,9 +111,7 @@ glwrap_lookup (char *name)
 /* Execute an OpenGL call and time it with a GPU metrics counter. */
 #define TIMED_DEFER(function,...) do {                                 \
        if (! inside_new_list) {                                        \
-               unsigned counter;                                       \
-               counter = metrics_counter_new ();                       \
-               metrics_counter_start (counter);                        \
+               metrics_counter_start ();                               \
        }                                                               \
        GLWRAP_DEFER(function, __VA_ARGS__);                            \
        if (! inside_new_list) {                                        \
@@ -386,11 +384,7 @@ void
 glBegin (GLenum mode)
 {
        if (! inside_new_list)
-       {
-               unsigned counter;
-               counter = metrics_counter_new ();
-               metrics_counter_start (counter);
-       }
+               metrics_counter_start ();
 
        GLWRAP_DEFER (glBegin, mode);
 }
@@ -400,9 +394,8 @@ glEnd (void)
 {
        GLWRAP_DEFER (glEnd);
 
-       if (! inside_new_list) {
+       if (! inside_new_list)
                metrics_counter_stop ();
-       }
 }
 
 /* And we need to track display lists to avoid inserting queries
index e00bb6348851adb9a9a1d0033e0b59c23f1d3195..39c90ad1145547846da59dac480a6e711e4a846c 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -65,8 +65,8 @@ context_t current_context;
 int frames;
 int verbose;
 
-unsigned
-metrics_counter_new (void)
+void
+metrics_counter_start (void)
 {
        counter_t *counter;
 
@@ -89,13 +89,7 @@ metrics_counter_new (void)
                current_context.counter_head = counter;
        }
 
-       return counter->id;
-}
-
-void
-metrics_counter_start (unsigned counter)
-{
-       glBeginQuery (GL_TIME_ELAPSED, counter);
+       glBeginQuery (GL_TIME_ELAPSED, counter->id);
 }
 
 void
index 2d93d908d39026cf1fd4b0b8fda9bd199d24f0ef..8b688678d2f5601d1471d67289418ff13f5fc8a4 100644 (file)
--- a/metrics.h
+++ b/metrics.h
 #ifndef METRICS_H
 #define METRICS_H
 
-/* Add a new counter to the metrics tracking state.
+/* Start accumulating GPU time.
  *
- * The value accumulated in this counter be accounted against the
+ * The time accumulated will be accounted against the
  * current program (as set with metrics_set_current_program).
- *
- * Returns: A counter ID suitable for use with metrics_counter_start
- * and metrics_counter_stop.
  */
-unsigned
-metrics_counter_new (void);
-
-/* Start accumulating GPU time spent into the given counter. */
 void
-metrics_counter_start (unsigned counter);
+metrics_counter_start (void);
 
 /* Stop accumulating GPU time (stops the most-recently started counter) */
 void