mesa: Add PrimitiveRestartFixedIndex to gl_constants
[mesa.git] / src / mesa / main / performance_query.c
index b9e7cf9961b5b362f934dbd728886ecd0798b800..c5825a7da3a533548288efcd3ac8cc1b4aa668d7 100644 (file)
@@ -48,6 +48,12 @@ free_performance_query(GLuint key, void *data, void *user)
    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);
 }
 
@@ -611,6 +617,15 @@ _mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags,
     */
    *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