aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/common/driverfuncs.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c4
-rw-r--r--src/mesa/drivers/x11/xm_dd.c8
-rw-r--r--src/mesa/main/dd.h8
-rw-r--r--src/mesa/main/mtypes.h9
-rw-r--r--src/mesa/main/queryobj.c117
-rw-r--r--src/mesa/main/queryobj.h17
7 files changed, 100 insertions, 69 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index f6411f303b0..9e2cce5bbed 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -228,8 +228,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
/* query objects */
driver->NewQueryObject = _mesa_new_query_object;
- driver->BeginQuery = NULL;
- driver->EndQuery = NULL;
+ driver->DeleteQuery = _mesa_delete_query;
+ driver->BeginQuery = _mesa_begin_query;
+ driver->EndQuery = _mesa_end_query;
+ driver->WaitQuery = _mesa_wait_query;
/* APPLE_vertex_array_object */
driver->NewArrayObject = _mesa_new_array_object;
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index eee03d022ba..57e574447a6 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -550,7 +550,7 @@ intelFinish(GLcontext * ctx)
#ifdef I915_MMIO_READ
static void
-intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+intelBeginQuery(GLcontext *ctx, struct gl_query_object *q)
{
struct intel_context *intel = intel_context( ctx );
struct drm_i915_mmio io = {
@@ -564,7 +564,7 @@ intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
}
static void
-intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+intelEndQuery(GLcontext *ctx, struct gl_query_object *q)
{
struct intel_context *intel = intel_context( ctx );
GLuint64EXT tmp;
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 0a978e5cf7e..305df548fa2 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -1086,9 +1086,9 @@ xmesa_new_query_object(GLcontext *ctx, GLuint id)
static void
-xmesa_begin_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+xmesa_begin_query(GLcontext *ctx, struct gl_query_object *q)
{
- if (target == GL_TIME_ELAPSED_EXT) {
+ if (q->Target == GL_TIME_ELAPSED_EXT) {
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
(void) gettimeofday(&xq->StartTime, NULL);
}
@@ -1113,9 +1113,9 @@ time_diff(const struct timeval *t0, const struct timeval *t1)
static void
-xmesa_end_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+xmesa_end_query(GLcontext *ctx, struct gl_query_object *q)
{
- if (target == GL_TIME_ELAPSED_EXT) {
+ if (q->Target == GL_TIME_ELAPSED_EXT) {
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
struct timeval endTime;
(void) gettimeofday(&endTime, NULL);
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 8edcfaf8c6e..fc9a77d9fd6 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -817,9 +817,11 @@ struct dd_function_table {
*/
/*@{*/
struct gl_query_object * (*NewQueryObject)(GLcontext *ctx, GLuint id);
- void (*BeginQuery)(GLcontext *ctx, GLenum target,
- struct gl_query_object *q);
- void (*EndQuery)(GLcontext *ctx, GLenum target, struct gl_query_object *q);
+ void (*DeleteQuery)(GLcontext *ctx, struct gl_query_object *q);
+ void (*BeginQuery)(GLcontext *ctx, struct gl_query_object *q);
+ void (*EndQuery)(GLcontext *ctx, struct gl_query_object *q);
+ void (*CheckQuery)(GLcontext *ctx, struct gl_query_object *q);
+ void (*WaitQuery)(GLcontext *ctx, struct gl_query_object *q);
/*@}*/
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f06e4a446c8..e1abcf4db7d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2074,10 +2074,11 @@ struct gl_ati_fragment_shader_state
*/
struct gl_query_object
{
- GLuint Id;
- GLuint64EXT Result; /* the counter */
- GLboolean Active; /* inside Begin/EndQuery */
- GLboolean Ready; /* result is ready */
+ GLenum Target; /**< The query target, when active */
+ GLuint Id; /**< hash table ID/name */
+ GLuint64EXT Result; /**< the counter */
+ GLboolean Active; /**< inside Begin/EndQuery */
+ GLboolean Ready; /**< result is ready? */
};
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 0e59ba615a7..a1e32e70ba9 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -54,14 +54,50 @@ _mesa_new_query_object(GLcontext *ctx, GLuint id)
/**
+ * Begin a query. Software driver fallback.
+ * Called via ctx->Driver.BeginQuery().
+ */
+void
+_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q)
+{
+ /* no-op */
+}
+
+
+/**
+ * End a query. Software driver fallback.
+ * Called via ctx->Driver.EndQuery().
+ */
+void
+_mesa_end_query(GLcontext *ctx, struct gl_query_object *q)
+{
+ q->Ready = GL_TRUE;
+}
+
+
+/**
+ * Wait for query to complete. Software driver fallback.
+ * Called via ctx->Driver.WaitQuery().
+ */
+void
+_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q)
+{
+ /* For software drivers, _mesa_end_query() should have completed the query.
+ * For real hardware, implement a proper WaitQuery() driver function.
+ */
+ assert(q->Ready);
+}
+
+
+/**
* Delete an occlusion query object.
* Not removed from hash table here.
* XXX maybe add Delete() method to gl_query_object class and call that instead
*/
-static void
-delete_query_object(struct gl_query_object *q)
+void
+_mesa_delete_query(struct gl_query_object *q)
{
- FREE(q);
+ _mesa_free(q);
}
@@ -135,7 +171,7 @@ _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
if (q) {
ASSERT(!q->Active); /* should be caught earlier */
_mesa_HashRemove(ctx->Query.QueryObjects, ids[i]);
- delete_query_object(q);
+ ctx->Driver.DeleteQuery(ctx, q);
}
}
}
@@ -216,6 +252,7 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
}
}
+ q->Target = target;
q->Active = GL_TRUE;
q->Result = 0;
q->Ready = GL_FALSE;
@@ -229,9 +266,7 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
}
#endif
- if (ctx->Driver.BeginQuery) {
- ctx->Driver.BeginQuery(ctx, target, q);
- }
+ ctx->Driver.BeginQuery(ctx, q);
}
@@ -275,13 +310,7 @@ _mesa_EndQueryARB(GLenum target)
}
q->Active = GL_FALSE;
- if (ctx->Driver.EndQuery) {
- ctx->Driver.EndQuery(ctx, target, q);
- }
- else {
- /* if we're using software rendering/querying */
- q->Ready = GL_TRUE;
- }
+ ctx->Driver.EndQuery(ctx, q);
}
@@ -346,23 +375,19 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
switch (pname) {
case GL_QUERY_RESULT_ARB:
- while (!q->Ready) {
- /* Wait for the query to finish! */
- /* If using software rendering, the result will always be ready
- * by time we get here. Otherwise, we must be using hardware!
- */
- ASSERT(ctx->Driver.EndQuery);
- }
+ if (!q->Ready)
+ ctx->Driver.WaitQuery(ctx, q);
/* if result is too large for returned type, clamp to max value */
if (q->Result > 0x7fffffff) {
*params = 0x7fffffff;
}
else {
- *params = q->Result;
+ *params = (GLint)q->Result;
}
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
- /* XXX revisit when we have a hardware implementation! */
+ if (!q->Ready)
+ ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
default:
@@ -390,23 +415,19 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
switch (pname) {
case GL_QUERY_RESULT_ARB:
- while (!q->Ready) {
- /* Wait for the query to finish! */
- /* If using software rendering, the result will always be ready
- * by time we get here. Otherwise, we must be using hardware!
- */
- ASSERT(ctx->Driver.EndQuery);
- }
+ if (!q->Ready)
+ ctx->Driver.WaitQuery(ctx, q);
/* if result is too large for returned type, clamp to max value */
if (q->Result > 0xffffffff) {
*params = 0xffffffff;
}
else {
- *params = q->Result;
+ *params = (GLuint)q->Result;
}
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
- /* XXX revisit when we have a hardware implementation! */
+ if (!q->Ready)
+ ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
default:
@@ -439,17 +460,13 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)
switch (pname) {
case GL_QUERY_RESULT_ARB:
- while (!q->Ready) {
- /* Wait for the query to finish! */
- /* If using software rendering, the result will always be ready
- * by time we get here. Otherwise, we must be using hardware!
- */
- ASSERT(ctx->Driver.EndQuery);
- }
+ if (!q->Ready)
+ ctx->Driver.WaitQuery(ctx, q);
*params = q->Result;
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
- /* XXX revisit when we have a hardware implementation! */
+ if (!q->Ready)
+ ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
default:
@@ -480,17 +497,13 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
switch (pname) {
case GL_QUERY_RESULT_ARB:
- while (!q->Ready) {
- /* Wait for the query to finish! */
- /* If using software rendering, the result will always be ready
- * by time we get here. Otherwise, we must be using hardware!
- */
- ASSERT(ctx->Driver.EndQuery);
- }
+ if (!q->Ready)
+ ctx->Driver.WaitQuery(ctx, q);
*params = q->Result;
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
- /* XXX revisit when we have a hardware implementation! */
+ if (!q->Ready)
+ ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
default:
@@ -522,8 +535,8 @@ static void
delete_queryobj_cb(GLuint id, void *data, void *userData)
{
struct gl_query_object *q= (struct gl_query_object *) data;
- (void) userData;
- delete_query_object(q);
+ GLcontext *ctx = (GLcontext *)userData;
+ ctx->Driver.DeleteQuery(ctx, q);
}
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h
index ada8cf83560..c05a1f3da82 100644
--- a/src/mesa/main/queryobj.h
+++ b/src/mesa/main/queryobj.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.1
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -36,6 +36,19 @@ _mesa_init_query(GLcontext *ctx);
extern void
_mesa_free_query_data(GLcontext *ctx);
+extern void
+_mesa_delete_query(struct gl_query_object *q);
+
+extern void
+_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q);
+
+extern void
+_mesa_end_query(GLcontext *ctx, struct gl_query_object *q);
+
+extern void
+_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q);
+
+
extern void GLAPIENTRY
_mesa_GenQueriesARB(GLsizei n, GLuint *ids);