summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorCarl Worth <[email protected]>2012-12-13 12:47:56 -0800
committerCarl Worth <[email protected]>2013-01-15 13:34:01 -0800
commit3dd76f7168bba6123c9ac5e2442b8c811f40399f (patch)
tree1a404f69a4ca4c5b9b9085bad4a5b9af4872e41d /src/mesa/main
parentc7df9c0e12e000f3d2fd57ebb3072f4afbda8579 (diff)
queryobj: Add EverBound flag, making ISQuery() return false before BeginQuery()
This flag allows for the specified behavior that GenQueries reserves a name, but does not associate an object with it until BeginQuery. We allocate the object immediately with the new EverBound flag set to false, and then set the flag to true at the time of BeginQuery. This allows us to implement a conformant IsQuery function by checking the state of the new EverBound flag. This fixes the following es3conform tests: occlusion_query_genqueries occlusion_query_is_query_nonzero and the following piglit test: occlusion_query_lifetime Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/queryobj.c21
2 files changed, 19 insertions, 3 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8904b13d984..8a3b2a4ffa2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2523,6 +2523,7 @@ struct gl_query_object
GLuint64EXT Result; /**< the counter */
GLboolean Active; /**< inside Begin/EndQuery */
GLboolean Ready; /**< result is ready? */
+ GLboolean EverBound;/**< has query object ever been bound */
};
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index b482b1518de..c48ba5be621 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -56,6 +56,14 @@ _mesa_new_query_object(struct gl_context *ctx, GLuint id)
* 2.13).
*/
q->Ready = GL_TRUE;
+
+ /* OpenGL 3.1 ยง 2.13 says about GenQueries, "These names are marked as
+ * used, but no object is associated with them until the first time they
+ * are used by BeginQuery." Since our implementation actually does
+ * allocate an object at this point, use a flag to indicate that this
+ * object has not yet been bound so should not be considered a query.
+ */
+ q->EverBound = GL_FALSE;
}
return q;
}
@@ -257,16 +265,22 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
GLboolean GLAPIENTRY
_mesa_IsQuery(GLuint id)
{
+ struct gl_query_object *q;
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glIsQuery(%u)\n", id);
- if (id && _mesa_lookup_query_object(ctx, id))
- return GL_TRUE;
- else
+ if (id == 0)
return GL_FALSE;
+
+ q = _mesa_lookup_query_object(ctx, id);
+ if (q == NULL)
+ return GL_FALSE;
+
+ return q->EverBound;
}
static GLboolean
@@ -359,6 +373,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
q->Active = GL_TRUE;
q->Result = 0;
q->Ready = GL_FALSE;
+ q->EverBound = GL_TRUE;
/* XXX should probably refcount query objects */
*bindpt = q;