mesa: Use SATURATE
[mesa.git] / src / mesa / main / performance_monitor.c
index a4a2f9e5970411153ee67bf21bbcd260fb37409d..3273f156368ed6468c2c2b9db8c50f9b8418a47f 100644 (file)
@@ -144,33 +144,6 @@ get_counter(const struct gl_perf_monitor_group *group_obj, GLuint id)
    return &group_obj->Counters[id];
 }
 
-/* For INTEL_performance_query, query id 0 is reserved to be invalid. We use
- * index to Groups array + 1 as the query id. Same applies to counter id.
- */
-static inline GLuint
-queryid_to_index(GLuint queryid)
-{
-   return queryid - 1;
-}
-
-static inline GLuint
-index_to_queryid(GLuint index)
-{
-   return index + 1;
-}
-
-static inline bool
-queryid_valid(const struct gl_context *ctx, GLuint queryid)
-{
-   return get_group(ctx, queryid_to_index(queryid)) != NULL;
-}
-
-static inline GLuint
-counterid_to_index(GLuint counterid)
-{
-   return counterid - 1;
-}
-
 /*****************************************************************************/
 
 void GLAPIENTRY
@@ -507,14 +480,18 @@ _mesa_SelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable,
    if (enable) {
       /* Enable the counters */
       for (i = 0; i < numCounters; i++) {
-         ++m->ActiveGroups[group];
-         BITSET_SET(m->ActiveCounters[group], counterList[i]);
+         if (!BITSET_TEST(m->ActiveCounters[group], counterList[i])) {
+            ++m->ActiveGroups[group];
+            BITSET_SET(m->ActiveCounters[group], counterList[i]);
+         }
       }
    } else {
       /* Disable the counters */
       for (i = 0; i < numCounters; i++) {
-         --m->ActiveGroups[group];
-         BITSET_CLEAR(m->ActiveCounters[group], counterList[i]);
+         if (BITSET_TEST(m->ActiveCounters[group], counterList[i])) {
+            --m->ActiveGroups[group];
+            BITSET_CLEAR(m->ActiveCounters[group], counterList[i]);
+         }
       }
    }
 }
@@ -569,7 +546,7 @@ _mesa_EndPerfMonitorAMD(GLuint monitor)
     *  when a performance monitor is not currently started."
     */
    if (!m->Active) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginPerfMonitor(not active)");
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glEndPerfMonitor(not active)");
       return;
    }
 
@@ -591,9 +568,8 @@ perf_monitor_result_size(const struct gl_context *ctx,
 
    for (group = 0; group < ctx->PerfMonitor.NumGroups; group++) {
       const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[group];
-      BITSET_WORD tmp;
 
-      BITSET_FOREACH_SET(counter, tmp, m->ActiveCounters[group], g->NumCounters) {
+      BITSET_FOREACH_SET(counter, m->ActiveCounters[group], g->NumCounters) {
          const struct gl_perf_monitor_counter *c = &g->Counters[counter];
 
          size += sizeof(uint32_t); /* Group ID */