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

Author: Matt Turner <[email protected]>
Date:   Thu Jul  6 18:48:03 2017 -0700

mesa: Don't compare unsigned for < 0

The INTEL_performance_query spec says

   "Performance counter id 0 is reserved as an invalid counter."

GLuint counterid_to_index(GLuint counterid) just returns counterid - 1,
so with unsigned overflow rules, it will generate 0xFFFFFFFF given an
input of 0. 0xFFFFFFFF will trigger the counterIndex >= queryNumCounters
check, so the code worked as is. It just contained a useless comparison.

Reviewed-by: Jordan Justen <[email protected]>

---

 src/mesa/main/performance_query.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/performance_query.c 
b/src/mesa/main/performance_query.c
index 56f6a7da8b..b9e7cf9961 100644
--- a/src/mesa/main/performance_query.c
+++ b/src/mesa/main/performance_query.c
@@ -349,7 +349,7 @@ _mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint 
counterId,
 
    counterIndex = counterid_to_index(counterId);
 
-   if (counterIndex < 0 || counterIndex >= queryNumCounters) {
+   if (counterIndex >= queryNumCounters) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "glGetPerfCounterInfoINTEL(invalid counterId)");
       return;

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

Reply via email to