summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/occlude.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-12-07 14:48:19 +0000
committerBrian Paul <[email protected]>2005-12-07 14:48:19 +0000
commit0fa8c59e646b214ea61c077f723e8ffe1cc06733 (patch)
treec55b85a279eba315344d5954452bfda0705c7c1d /src/mesa/main/occlude.c
parent98bebc7212a47f97ef6d15d4fca45a0fa608aea2 (diff)
Updates for GL_EXT_timer_query:
New GLint64EXT and GLuint64EXT types (use C99's long long types). New glGetQueryObject[u]i64vEXT() functions.
Diffstat (limited to 'src/mesa/main/occlude.c')
-rw-r--r--src/mesa/main/occlude.c101
1 files changed, 97 insertions, 4 deletions
diff --git a/src/mesa/main/occlude.c b/src/mesa/main/occlude.c
index 53981d67c39..483ca5d0c41 100644
--- a/src/mesa/main/occlude.c
+++ b/src/mesa/main/occlude.c
@@ -331,7 +331,7 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
if (!q || q->Active) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetQueryObjectivARB(id=%d is active)", id);
+ "glGetQueryObjectivARB(id=%d is invalid or active)", id);
return;
}
@@ -344,7 +344,13 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
*/
ASSERT(ctx->Driver.EndQuery);
}
- *params = q->Result;
+ /* if result is too large for returned type, clamp to max value */
+ if (q->Result > 0x7fffffff) {
+ *params = 0x7fffffff;
+ }
+ else {
+ *params = q->Result;
+ }
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
/* XXX revisit when we have a hardware implementation! */
@@ -369,7 +375,7 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
if (!q || q->Active) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetQueryObjectuivARB(id=%d is active)", id);
+ "glGetQueryObjectuivARB(id=%d is invalid or active)", id);
return;
}
@@ -382,7 +388,13 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
*/
ASSERT(ctx->Driver.EndQuery);
}
- *params = q->Result;
+ /* if result is too large for returned type, clamp to max value */
+ if (q->Result > 0xffffffff) {
+ *params = 0xffffffff;
+ }
+ else {
+ *params = q->Result;
+ }
break;
case GL_QUERY_RESULT_AVAILABLE_ARB:
/* XXX revisit when we have a hardware implementation! */
@@ -395,6 +407,87 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
}
+/**
+ * New with GL_EXT_timer_query
+ */
+void GLAPIENTRY
+_mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)
+{
+ struct gl_query_object *q = NULL;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (id)
+ q = lookup_query_object(ctx, id);
+
+ if (!q || q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetQueryObjectui64vARB(id=%d is invalid or active)", id);
+ return;
+ }
+
+ 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);
+ }
+ *params = q->Result;
+ break;
+ case GL_QUERY_RESULT_AVAILABLE_ARB:
+ /* XXX revisit when we have a hardware implementation! */
+ *params = q->Ready;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)");
+ return;
+ }
+}
+
+
+/**
+ * New with GL_EXT_timer_query
+ */
+void GLAPIENTRY
+_mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
+{
+ struct gl_query_object *q = NULL;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (id)
+ q = lookup_query_object(ctx, id);
+
+ if (!q || q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id);
+ return;
+ }
+
+ 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);
+ }
+ *params = q->Result;
+ break;
+ case GL_QUERY_RESULT_AVAILABLE_ARB:
+ /* XXX revisit when we have a hardware implementation! */
+ *params = q->Ready;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)");
+ return;
+ }
+}
+
/**
* Allocate/init the context state related to query objects.