mesa: Silence GCC warning 'comparison between signed and unsigned integer expressions'
[mesa.git] / src / mesa / main / queryobj.c
index 7121b61b4e2f0f60e1fc83e74cc3ddeee1e5b1fa..a1801336968dd29253236f7c377586672b5c8b3a 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 
@@ -29,7 +29,6 @@
 #include "hash.h"
 #include "imports.h"
 #include "queryobj.h"
-#include "mfeatures.h"
 #include "mtypes.h"
 #include "main/dispatch.h"
 
@@ -44,7 +43,7 @@
 static struct gl_query_object *
 _mesa_new_query_object(struct gl_context *ctx, GLuint id)
 {
-   struct gl_query_object *q = MALLOC_STRUCT(gl_query_object);
+   struct gl_query_object *q = CALLOC_STRUCT(gl_query_object);
    (void) ctx;
    if (q) {
       q->Id = id;
@@ -76,7 +75,7 @@ _mesa_new_query_object(struct gl_context *ctx, GLuint id)
 static void
 _mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q)
 {
-   /* no-op */
+   ctx->NewState |= _NEW_DEPTH; /* for swrast */
 }
 
 
@@ -87,6 +86,7 @@ _mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q)
 static void
 _mesa_end_query(struct gl_context *ctx, struct gl_query_object *q)
 {
+   ctx->NewState |= _NEW_DEPTH; /* for swrast */
    q->Ready = GL_TRUE;
 }
 
@@ -126,6 +126,7 @@ _mesa_check_query(struct gl_context *ctx, struct gl_query_object *q)
 static void
 _mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q)
 {
+   free(q->Label);
    free(q);
 }
 
@@ -315,7 +316,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
    if (!query_error_check_index(ctx, target, index))
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_DEPTH);
+   FLUSH_VERTICES(ctx, 0);
 
    bindpt = get_query_binding_point(ctx, target);
    if (!bindpt) {
@@ -392,7 +393,7 @@ _mesa_EndQueryIndexed(GLenum target, GLuint index)
    if (!query_error_check_index(ctx, target, index))
       return;
 
-   FLUSH_VERTICES(ctx, _NEW_DEPTH);
+   FLUSH_VERTICES(ctx, 0);
 
    bindpt = get_query_binding_point(ctx, target);
    if (!bindpt) {
@@ -485,10 +486,16 @@ _mesa_QueryCounter(GLuint id, GLenum target)
    q->Target = target;
    q->Result = 0;
    q->Ready = GL_FALSE;
+   q->EverBound = GL_TRUE;
 
-   /* QueryCounter is implemented using EndQuery without BeginQuery
-    * in drivers. This is actually Direct3D and Gallium convention. */
-   ctx->Driver.EndQuery(ctx, q);
+   if (ctx->Driver.QueryCounter) {
+      ctx->Driver.QueryCounter(ctx, q);
+   } else {
+      /* QueryCounter is implemented using EndQuery without BeginQuery
+       * in drivers. This is actually Direct3D and Gallium convention.
+       */
+      ctx->Driver.EndQuery(ctx, q);
+   }
 }
 
 
@@ -753,33 +760,6 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params)
    }
 }
 
-
-void
-_mesa_init_queryobj_dispatch(const struct gl_context *ctx,
-                             struct _glapi_table *disp)
-{
-   SET_GenQueries(disp, _mesa_GenQueries);
-   SET_DeleteQueries(disp, _mesa_DeleteQueries);
-   SET_IsQuery(disp, _mesa_IsQuery);
-   SET_BeginQuery(disp, _mesa_BeginQuery);
-   SET_EndQuery(disp, _mesa_EndQuery);
-   SET_GetQueryiv(disp, _mesa_GetQueryiv);
-   SET_GetQueryObjectuiv(disp, _mesa_GetQueryObjectuiv);
-
-   if (_mesa_is_desktop_gl(ctx)) {
-      SET_GetQueryObjectiv(disp, _mesa_GetQueryObjectiv);
-      SET_QueryCounter(disp, _mesa_QueryCounter);
-
-      SET_GetQueryObjecti64v(disp, _mesa_GetQueryObjecti64v);
-      SET_GetQueryObjectui64v(disp, _mesa_GetQueryObjectui64v);
-
-      SET_BeginQueryIndexed(disp, _mesa_BeginQueryIndexed);
-      SET_EndQueryIndexed(disp, _mesa_EndQueryIndexed);
-      SET_GetQueryIndexediv(disp, _mesa_GetQueryIndexediv);
-   }
-}
-
-
 /**
  * Allocate/init the context state related to query objects.
  */