struct gl_perf_query_object *m = data;
struct gl_context *ctx = user;
+ /* Don't confuse the implementation by deleting an active query. We can
+ * toggle Active/Used to false because we're tearing down the GL context
+ * and it's already idle (see _mesa_free_context_data).
+ */
+ m->Active = false;
+ m->Used = false;
ctx->Driver.DeletePerfQuery(ctx, m);
}
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
counterIndex = counterid_to_index(counterId);
- if (counterIndex < 0 || counterIndex >= queryNumCounters) {
+ if (counterIndex >= queryNumCounters) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetPerfCounterInfoINTEL(invalid counterId)");
return;
*/
*bytesWritten = 0;
+ /* Not explicitly covered in the spec but a query that was never started
+ * cannot return any data.
+ */
+ if (!obj->Used) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPerfQueryDataINTEL(query never began)");
+ return;
+ }
+
/* Not explicitly covered in the spec but to be consistent with
* EndPerfQuery which validates that an application only ends an
* active query we also validate that an application doesn't try