[Mesa-dev] [PATCH] mesa: Fix performance query id check
Robert Bragg
robert at sixbynine.org
Fri Feb 24 16:46:04 UTC 2017
In queryid_valid() index is unsigned so checking if it is less
than zero is useless. On queryid_to_index() is comment
saying 0 is reserved to be invalid thus rule it out.
This is a v2 of a fix for an issue identified by Juha-Pekka (thanks)
and the commit message is gratuitously stolen.
Cc: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Signed-off-by: Robert Bragg <robert at sixbynine.org>
---
src/mesa/main/performance_query.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/performance_query.c b/src/mesa/main/performance_query.c
index aa103516a5..56f6a7da8b 100644
--- a/src/mesa/main/performance_query.c
+++ b/src/mesa/main/performance_query.c
@@ -90,8 +90,12 @@ index_to_queryid(unsigned index)
static inline bool
queryid_valid(const struct gl_context *ctx, unsigned numQueries, GLuint queryid)
{
- GLuint index = queryid_to_index(queryid);
- return index >= 0 && index < numQueries;
+ /* The GL_INTEL_performance_query spec says:
+ *
+ * "Performance counter ids values start with 1. Performance counter id 0
+ * is reserved as an invalid counter."
+ */
+ return queryid != 0 && queryid_to_index(queryid) < numQueries;
}
static inline GLuint
--
2.11.1
More information about the mesa-dev
mailing list