X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fqueryobj.c;h=f0a9a7922b224068a54ab3344b2e69cffe528222;hb=ab9136ef750a1209db26d6c9dffe299f4134682e;hp=a907dac836b736202318825e0b5deedf04e37334;hpb=8f3bdeaad610d7d5a5c6e73e1e9c721219595754;p=mesa.git diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index a907dac836b..f0a9a7922b2 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -25,9 +25,11 @@ #include "glheader.h" #include "context.h" +#include "enums.h" #include "hash.h" #include "imports.h" #include "queryobj.h" +#include "mfeatures.h" #include "mtypes.h" #include "main/dispatch.h" @@ -43,7 +45,7 @@ * \return pointer to new query_object object or NULL if out of memory. */ static struct gl_query_object * -_mesa_new_query_object(GLcontext *ctx, GLuint id) +_mesa_new_query_object(struct gl_context *ctx, GLuint id) { struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); (void) ctx; @@ -62,7 +64,7 @@ _mesa_new_query_object(GLcontext *ctx, GLuint id) * Called via ctx->Driver.BeginQuery(). */ static void -_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q) +_mesa_begin_query(struct gl_context *ctx, struct gl_query_object *q) { /* no-op */ } @@ -73,7 +75,7 @@ _mesa_begin_query(GLcontext *ctx, struct gl_query_object *q) * Called via ctx->Driver.EndQuery(). */ static void -_mesa_end_query(GLcontext *ctx, struct gl_query_object *q) +_mesa_end_query(struct gl_context *ctx, struct gl_query_object *q) { q->Ready = GL_TRUE; } @@ -84,7 +86,7 @@ _mesa_end_query(GLcontext *ctx, struct gl_query_object *q) * Called via ctx->Driver.WaitQuery(). */ static void -_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) +_mesa_wait_query(struct gl_context *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, @@ -99,7 +101,7 @@ _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q) * Called via ctx->Driver.CheckQuery(). */ static void -_mesa_check_query(GLcontext *ctx, struct gl_query_object *q) +_mesa_check_query(struct gl_context *ctx, struct gl_query_object *q) { /* No-op for sw rendering. * HW drivers may need to flush at this time. @@ -112,7 +114,7 @@ _mesa_check_query(GLcontext *ctx, struct gl_query_object *q) * Not removed from hash table here. */ static void -_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) +_mesa_delete_query(struct gl_context *ctx, struct gl_query_object *q) { free(q); } @@ -135,7 +137,7 @@ _mesa_init_query_object_functions(struct dd_function_table *driver) * \return NULL if invalid target, else the address of binding point */ static struct gl_query_object ** -get_query_binding_point(GLcontext *ctx, GLenum target) +get_query_binding_point(struct gl_context *ctx, GLenum target) { switch (target) { case GL_SAMPLES_PASSED_ARB: @@ -143,6 +145,11 @@ get_query_binding_point(GLcontext *ctx, GLenum target) return &ctx->Query.CurrentOcclusionObject; else return NULL; + case GL_ANY_SAMPLES_PASSED: + if (ctx->Extensions.ARB_occlusion_query2) + return &ctx->Query.CurrentOcclusionObject; + else + return NULL; case GL_TIME_ELAPSED_EXT: if (ctx->Extensions.EXT_timer_query) return &ctx->Query.CurrentTimerObject; @@ -166,13 +173,16 @@ get_query_binding_point(GLcontext *ctx, GLenum target) } -void GLAPIENTRY +static void GLAPIENTRY _mesa_GenQueriesARB(GLsizei n, GLuint *ids) { GLuint first; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGenQueries(%d)\n", n); + if (n < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)"); return; @@ -202,12 +212,16 @@ _mesa_GenQueriesARB(GLsizei n, GLuint *ids) } -void GLAPIENTRY +static void GLAPIENTRY _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) { GLint i; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + FLUSH_VERTICES(ctx, 0); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glDeleeteQueries(%d)\n", n); if (n < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)"); @@ -234,12 +248,15 @@ _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids) } -GLboolean GLAPIENTRY +static GLboolean GLAPIENTRY _mesa_IsQueryARB(GLuint id) { 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 @@ -254,6 +271,10 @@ _mesa_BeginQueryARB(GLenum target, GLuint id) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBeginQuery(%s, %u)\n", + _mesa_lookup_enum_by_nr(target), id); + FLUSH_VERTICES(ctx, _NEW_DEPTH); bindpt = get_query_binding_point(ctx, target); @@ -305,6 +326,9 @@ _mesa_EndQueryARB(GLenum target) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glEndQuery(%s)\n", _mesa_lookup_enum_by_nr(target)); + FLUSH_VERTICES(ctx, _NEW_DEPTH); bindpt = get_query_binding_point(ctx, target); @@ -328,13 +352,18 @@ _mesa_EndQueryARB(GLenum target) } -void GLAPIENTRY +static void GLAPIENTRY _mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) { struct gl_query_object *q, **bindpt; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryiv(%s, %s)\n", + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(pname)); + bindpt = get_query_binding_point(ctx, target); if (!bindpt) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); @@ -357,13 +386,17 @@ _mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) } -void GLAPIENTRY +static void GLAPIENTRY _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) { struct gl_query_object *q = NULL; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectiv(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + if (id) q = _mesa_lookup_query_object(ctx, id); @@ -378,11 +411,18 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) 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 = (GLint)q->Result; + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0x7fffffff) { + *params = 0x7fffffff; + } + else { + *params = (GLint)q->Result; + } } break; case GL_QUERY_RESULT_AVAILABLE_ARB: @@ -397,13 +437,17 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) } -void GLAPIENTRY +static void GLAPIENTRY _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) { struct gl_query_object *q = NULL; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectuiv(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + if (id) q = _mesa_lookup_query_object(ctx, id); @@ -418,11 +462,18 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) 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 = (GLuint)q->Result; + if (q->Target == GL_ANY_SAMPLES_PASSED) { + if (q->Result) + *params = GL_TRUE; + else + *params = GL_FALSE; + } else { + if (q->Result > 0xffffffff) { + *params = 0xffffffff; + } + else { + *params = (GLuint)q->Result; + } } break; case GL_QUERY_RESULT_AVAILABLE_ARB: @@ -447,6 +498,10 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjecti64v(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + if (id) q = _mesa_lookup_query_object(ctx, id); @@ -484,6 +539,10 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glGetQueryObjectui64v(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(pname)); + if (id) q = _mesa_lookup_query_object(ctx, id); @@ -535,7 +594,7 @@ _mesa_init_queryobj_dispatch(struct _glapi_table *disp) * Allocate/init the context state related to query objects. */ void -_mesa_init_queryobj(GLcontext *ctx) +_mesa_init_queryobj(struct gl_context *ctx) { ctx->Query.QueryObjects = _mesa_NewHashTable(); ctx->Query.CurrentOcclusionObject = NULL; @@ -549,7 +608,7 @@ static void delete_queryobj_cb(GLuint id, void *data, void *userData) { struct gl_query_object *q= (struct gl_query_object *) data; - GLcontext *ctx = (GLcontext *)userData; + struct gl_context *ctx = (struct gl_context *)userData; ctx->Driver.DeleteQuery(ctx, q); } @@ -558,7 +617,7 @@ delete_queryobj_cb(GLuint id, void *data, void *userData) * Free the context state related to query objects. */ void -_mesa_free_queryobj_data(GLcontext *ctx) +_mesa_free_queryobj_data(struct gl_context *ctx) { _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx); _mesa_DeleteHashTable(ctx->Query.QueryObjects);