diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 1e44904..d146ddf 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -221,8 +221,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver) /* query objects */ driver->NewQueryObject = _mesa_new_query_object; + driver->DeleteQueryObject = _mesa_delete_query_object; driver->BeginQuery = NULL; driver->EndQuery = NULL; + driver->UpdateQuery = _mesa_update_query; /* APPLE_vertex_array_object */ driver->NewArrayObject = _mesa_new_array_object; diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 1de2542..fd97b3e 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -806,9 +806,11 @@ struct dd_function_table { */ /*@{*/ struct gl_query_object * (*NewQueryObject)(GLcontext *ctx, GLuint id); + void (*DeleteQueryObject)(GLcontext *ctx, struct gl_query_object *q); void (*BeginQuery)(GLcontext *ctx, GLenum target, struct gl_query_object *q); void (*EndQuery)(GLcontext *ctx, GLenum target, struct gl_query_object *q); + void (*UpdateQuery)(GLcontext *ctx, struct gl_query_object *q); /*@}*/ diff --git a/src/mesa/main/occlude.c b/src/mesa/main/occlude.c index 5fef4a8..ddcf47b 100644 --- a/src/mesa/main/occlude.c +++ b/src/mesa/main/occlude.c @@ -54,16 +54,30 @@ _mesa_new_query_object(GLcontext *ctx, GLuint id) /** - * Delete an occlusion query object. + * Delete an occlusion query object. This is a fallback routine called + * via ctx->Driver.DeleteQueryObject(). + * \param ctx - rendering context + * \param q - pointer to the query_object to destroy + * * 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_object(GLcontext *ctx, struct gl_query_object *q) { FREE(q); } +/** + * Update the completion status of a query object. + * This is a fallback function called via ctx->Driver.UpdateQueryObject(). + * \param ctx - rendering context + * \param q - pointer to the query_object to update + */ +void +_mesa_update_query(GLcontext *ctx, struct gl_query_object *q) +{ + q->Ready = GL_TRUE; +} static struct gl_query_object * lookup_query_object(GLcontext *ctx, GLuint id) @@ -135,7 +149,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.DeleteQueryObject(ctx, q); } } } @@ -344,6 +358,8 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) return; } + ASSERT(ctx->Driver.UpdateQuery); + switch (pname) { case GL_QUERY_RESULT_ARB: while (!q->Ready) { @@ -351,7 +367,7 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) /* 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); + ctx->Driver.UpdateQuery(ctx, q); } /* if result is too large for returned type, clamp to max value */ if (q->Result > 0x7fffffff) { @@ -362,7 +378,7 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) } break; case GL_QUERY_RESULT_AVAILABLE_ARB: - /* XXX revisit when we have a hardware implementation! */ + ctx->Driver.UpdateQuery(ctx, q); *params = q->Ready; break; default: @@ -388,6 +404,8 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) return; } + ASSERT(ctx->Driver.UpdateQuery); + switch (pname) { case GL_QUERY_RESULT_ARB: while (!q->Ready) { @@ -395,7 +413,7 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) /* 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); + ctx->Driver.UpdateQuery(ctx, q); } /* if result is too large for returned type, clamp to max value */ if (q->Result > 0xffffffff) { @@ -406,7 +424,7 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) } break; case GL_QUERY_RESULT_AVAILABLE_ARB: - /* XXX revisit when we have a hardware implementation! */ + ctx->Driver.UpdateQuery(ctx, q); *params = q->Ready; break; default: @@ -437,6 +455,8 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) return; } + ASSERT(ctx->Driver.UpdateQuery); + switch (pname) { case GL_QUERY_RESULT_ARB: while (!q->Ready) { @@ -444,12 +464,12 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) /* 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); + ctx->Driver.UpdateQuery(ctx, q); } *params = q->Result; break; case GL_QUERY_RESULT_AVAILABLE_ARB: - /* XXX revisit when we have a hardware implementation! */ + ctx->Driver.UpdateQuery(ctx, q); *params = q->Ready; break; default: @@ -478,6 +498,8 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) return; } + ASSERT(ctx->Driver.UpdateQuery); + switch (pname) { case GL_QUERY_RESULT_ARB: while (!q->Ready) { @@ -485,12 +507,12 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) /* 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); + ctx->Driver.UpdateQuery(ctx, q); } *params = q->Result; break; case GL_QUERY_RESULT_AVAILABLE_ARB: - /* XXX revisit when we have a hardware implementation! */ + ctx->Driver.UpdateQuery(ctx, q); *params = q->Ready; break; default: @@ -521,9 +543,10 @@ _mesa_init_query(GLcontext *ctx) static void delete_queryobj_cb(GLuint id, void *data, void *userData) { + GET_CURRENT_CONTEXT(ctx); struct gl_query_object *q= (struct gl_query_object *) data; (void) userData; - delete_query_object(q); + ctx->Driver.DeleteQueryObject(ctx, q); } diff --git a/src/mesa/main/occlude.h b/src/mesa/main/occlude.h index ada8cf8..01fccc3 100644 --- a/src/mesa/main/occlude.h +++ b/src/mesa/main/occlude.h @@ -31,6 +31,12 @@ extern struct gl_query_object * _mesa_new_query_object(GLcontext *ctx, GLuint id); extern void +_mesa_delete_query_object(GLcontext *ctx, struct gl_query_object *q); + +extern void +_mesa_update_query(GLcontext *ctx, struct gl_query_object *q); + +extern void _mesa_init_query(GLcontext *ctx); extern void