/*
* 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"),
}
+/**
+ * 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);
}
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);
}
}
}
}
}
+ q->Target = target;
q->Active = GL_TRUE;
q->Result = 0;
q->Ready = GL_FALSE;
}
#endif
- if (ctx->Driver.BeginQuery) {
- ctx->Driver.BeginQuery(ctx, target, q);
- }
+ ctx->Driver.BeginQuery(ctx, q);
}
}
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);
}
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:
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:
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:
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:
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);
}