intel/disasm: brw_label and support functions
[mesa.git] / src / mesa / main / queryobj.c
index 27086a4b683f9871f6e0d3f46ae42aeb8621a9b1..e54a37b8e890afd3a6db2d319b8ac74d50189b6d 100644 (file)
 #include "context.h"
 #include "enums.h"
 #include "hash.h"
-#include "imports.h"
+
 #include "queryobj.h"
 #include "mtypes.h"
+#include "util/u_memory.h"
 
 
 /**
@@ -120,10 +121,15 @@ _mesa_check_query(struct gl_context *ctx, struct gl_query_object *q)
 
 
 /**
- * Delete a query object.  Called via ctx->Driver.DeleteQuery().
+ * Delete a query object.  Called via ctx->Driver.DeleteQuery(), if not
+ * overwritten by driver.  In the latter case, called from the driver
+ * after all driver-specific clean-up has been done.
  * Not removed from hash table here.
+ *
+ * \param ctx GL context to wich query object belongs.
+ * \param q query object due to be deleted.
  */
-static void
+void
 _mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q)
 {
    free(q->Label);
@@ -163,20 +169,6 @@ 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:
       if (_mesa_has_ARB_occlusion_query(ctx) ||
@@ -204,6 +196,7 @@ get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index)
          return NULL;
    case GL_PRIMITIVES_GENERATED:
       if (_mesa_has_EXT_transform_feedback(ctx) ||
+          _mesa_has_EXT_tessellation_shader(ctx) ||
           _mesa_has_OES_geometry_shader(ctx))
          return &ctx->Query.PrimitivesGenerated[index];
       else
@@ -671,11 +664,21 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, GLenum pname,
     * <pname> is not CURRENT_QUERY_EXT."
     *
     * Same rule is present also in ES 3.2 spec.
+    *
+    * EXT_disjoint_timer_query extends this with GL_QUERY_COUNTER_BITS.
     */
-   if (_mesa_is_gles(ctx) && pname != GL_CURRENT_QUERY) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivEXT(%s)",
-                  _mesa_enum_to_string(pname));
-      return;
+   if (_mesa_is_gles(ctx)) {
+      switch (pname) {
+      case GL_CURRENT_QUERY:
+         break;
+      case GL_QUERY_COUNTER_BITS:
+         if (_mesa_has_EXT_disjoint_timer_query(ctx))
+            break;
+         /* fallthrough */
+      default:
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivEXT(%s)",
+                     _mesa_enum_to_string(pname));
+      }
    }
 
    if (target == GL_TIMESTAMP) {
@@ -823,7 +826,7 @@ get_query_object(struct gl_context *ctx, const char *func,
       return;
    }
 
-   if (buf && buf != ctx->Shared->NullBufferObj) {
+   if (buf) {
       bool is_64bit = ptype == GL_INT64_ARB ||
          ptype == GL_UNSIGNED_INT64_ARB;
       if (!_mesa_has_ARB_query_buffer_object(ctx)) {