mesa: Silence unused parameter warning in compressedteximage_only_format
[mesa.git] / src / mesa / main / queryobj.c
index e4edb519344c6d6a8afc99d562a870b3d0eebb3c..79600d7db19c2d708218598c9be14430893bf010 100644 (file)
@@ -165,6 +165,20 @@ get_pipe_stats_binding_point(struct gl_context *ctx,
 static struct gl_query_object **
 get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index)
 {
+
+   /* From GL_EXT_occlusion_query_boolean spec:
+    *
+    *    "Accepted by the <target> parameter of BeginQueryEXT, EndQueryEXT,
+    *    and GetQueryivEXT:
+    *
+    *   ANY_SAMPLES_PASSED_EXT                         0x8C2F
+    *   ANY_SAMPLES_PASSED_CONSERVATIVE_EXT            0x8D6A"
+    */
+   if ((_mesa_is_gles(ctx) && ctx->Version == 20) &&
+       (target != GL_ANY_SAMPLES_PASSED &&
+        target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE))
+      return NULL;
+
    switch (target) {
    case GL_SAMPLES_PASSED_ARB:
       if (ctx->Extensions.ARB_occlusion_query)
@@ -278,7 +292,7 @@ create_queries(struct gl_context *ctx, GLenum target, GLsizei n, GLuint *ids,
             q->EverBound = GL_TRUE;
          }
          ids[i] = first + i;
-         _mesa_HashInsert(ctx->Query.QueryObjects, first + i, q);
+         _mesa_HashInsertLocked(ctx->Query.QueryObjects, first + i, q);
       }
    }
 }
@@ -345,7 +359,7 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
                q->Active = GL_FALSE;
                ctx->Driver.EndQuery(ctx, q);
             }
-            _mesa_HashRemove(ctx->Query.QueryObjects, ids[i]);
+            _mesa_HashRemoveLocked(ctx->Query.QueryObjects, ids[i]);
             ctx->Driver.DeleteQuery(ctx, q);
          }
       }
@@ -448,7 +462,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQuery{Indexed}");
             return;
          }
-         _mesa_HashInsert(ctx->Query.QueryObjects, id, q);
+         _mesa_HashInsertLocked(ctx->Query.QueryObjects, id, q);
       }
    }
    else {
@@ -590,7 +604,7 @@ _mesa_QueryCounter(GLuint id, GLenum target)
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glQueryCounter");
          return;
       }
-      _mesa_HashInsert(ctx->Query.QueryObjects, id, q);
+      _mesa_HashInsertLocked(ctx->Query.QueryObjects, id, q);
    }
    else {
       if (q->Target && q->Target != GL_TIMESTAMP) {
@@ -649,6 +663,19 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, GLenum pname,
    if (!query_error_check_index(ctx, target, index))
       return;
 
+   /* From the GL_EXT_occlusion_query_boolean spec:
+    *
+    * "The error INVALID_ENUM is generated if GetQueryivEXT is called where
+    * <pname> is not CURRENT_QUERY_EXT."
+    *
+    * Same rule is present also in ES 3.2 spec.
+    */
+   if (_mesa_is_gles(ctx) && pname != GL_CURRENT_QUERY) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivEXT(%s)",
+                  _mesa_enum_to_string(pname));
+      return;
+   }
+
    if (target == GL_TIMESTAMP) {
       if (!ctx->Extensions.ARB_timer_query) {
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)");
@@ -775,10 +802,28 @@ get_query_object(struct gl_context *ctx, const char *func,
       return;
    }
 
+   /* From GL_EXT_occlusion_query_boolean spec:
+    *
+    *    "Accepted by the <pname> parameter of GetQueryObjectivEXT and
+    *    GetQueryObjectuivEXT:
+    *
+    *    QUERY_RESULT_EXT                               0x8866
+    *    QUERY_RESULT_AVAILABLE_EXT                     0x8867"
+    *
+    * Same rule is present also in ES 3.2 spec.
+    */
+   if (_mesa_is_gles(ctx) &&
+       (pname != GL_QUERY_RESULT && pname != GL_QUERY_RESULT_AVAILABLE)) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(%s)", func,
+                  _mesa_enum_to_string(pname));
+      return;
+   }
+
    if (buf && buf != ctx->Shared->NullBufferObj) {
       bool is_64bit = ptype == GL_INT64_ARB ||
          ptype == GL_UNSIGNED_INT64_ARB;
-      if (!ctx->Extensions.ARB_query_buffer_object) {
+      if (!ctx->Extensions.ARB_query_buffer_object &&
+          !ctx->Extensions.EXT_disjoint_timer_query) {
          _mesa_error(ctx, GL_INVALID_OPERATION, "%s(not supported)", func);
          return;
       }