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

Author: Rob Clark <[email protected]>
Date:   Mon Jul  2 10:40:36 2018 -0400

mesa: don't double incr/decr ActiveCounters

Frameretrace ends up w/ excess calls to SelectPerfMonitorCountersAMD()
which ends up re-enabling already enabled counters.  Which causes
ActiveCounters[group] to be double incremented for the same counter.
This causes BeginPerfMonitorAMD() to fail.

The AMD_performance_monitor spec doesn't say that an error should be
generated in this case.  So I think the safe thing to do is just safe-
guard against excess increments/decrements.

Signed-off-by: Rob Clark <[email protected]>

---

 src/mesa/main/performance_monitor.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/performance_monitor.c 
b/src/mesa/main/performance_monitor.c
index 359727777f..253d42d989 100644
--- a/src/mesa/main/performance_monitor.c
+++ b/src/mesa/main/performance_monitor.c
@@ -480,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]);
+         }
       }
    }
 }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to