diff options
Diffstat (limited to 'mesalib/src')
-rw-r--r-- | mesalib/src/mapi/glapi/gen/gl_API.xml | 22 | ||||
-rw-r--r-- | mesalib/src/mesa/main/dd.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/dlist.c | 24 | ||||
-rw-r--r-- | mesalib/src/mesa/main/extensions.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/get.c | 15 | ||||
-rw-r--r-- | mesalib/src/mesa/main/queryobj.c | 78 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texcompress_etc.h | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_queryobj.c | 14 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 5 |
9 files changed, 159 insertions, 10 deletions
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml index bcc2f5c2c..01460b49b 100644 --- a/mesalib/src/mapi/glapi/gen/gl_API.xml +++ b/mesalib/src/mapi/glapi/gen/gl_API.xml @@ -7981,7 +7981,27 @@ <xi:include href="ARB_texture_rgb10_a2ui.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <!-- 84. GL_ARB_texture_swizzle --> -<!-- 85. GL_ARB_timer_query --> + +<category name="GL_ARB_timer_query" number="85"> + <enum name="TIME_ELAPSED" value="0x88BF"/> + <enum name="TIMESTAMP" value="0x8E28"/> + <type name="int64" size="8"/> + <type name="uint64" unsigned="true" size="8"/> + <function name="GetQueryObjecti64v" alias="GetQueryObjecti64vEXT" static_dispatch="false"> + <param name="id" type="GLuint"/> + <param name="pname" type="GLenum"/> + <param name="params" type="GLint64 *"/> + </function> + <function name="GetQueryObjectui64v" alias="GetQueryObjectui64vEXT" static_dispatch="false"> + <param name="id" type="GLuint"/> + <param name="pname" type="GLenum"/> + <param name="params" type="GLuint64 *"/> + </function> + <function name="QueryCounter" offset="assign" static_dispatch="false"> + <param name="id" type="GLuint"/> + <param name="target" type="GLenum"/> + </function> +</category> <xi:include href="ARB_vertex_type_2_10_10_10_rev.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 687a38f44..c8a765f47 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -820,6 +820,12 @@ struct dd_function_table { GLuint name); void (*DeleteSamplerObject)(struct gl_context *ctx, struct gl_sampler_object *samp); + + /** + * \name Return a timestamp in nanoseconds as defined by GL_ARB_timer_query. + * This should be equivalent to glGetInteger64v(GL_TIMESTAMP); + */ + uint64_t (*GetTimestamp)(struct gl_context *ctx); }; diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index a0d84cfdc..a827d132d 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -469,6 +469,9 @@ typedef enum OPCODE_BEGIN_CONDITIONAL_RENDER, OPCODE_END_CONDITIONAL_RENDER, + /* ARB_timer_query */ + OPCODE_QUERY_COUNTER, + /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_CONTINUE, @@ -5351,6 +5354,23 @@ save_EndQueryARB(GLenum target) } } + +static void GLAPIENTRY +save_QueryCounter(GLuint id, GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = alloc_instruction(ctx, OPCODE_QUERY_COUNTER, 2); + if (n) { + n[1].ui = id; + n[2].e = target; + } + if (ctx->ExecuteFlag) { + CALL_QueryCounter(ctx->Exec, (id, target)); + } +} + #endif /* FEATURE_queryobj */ @@ -8345,6 +8365,9 @@ execute_list(struct gl_context *ctx, GLuint list) case OPCODE_END_QUERY_ARB: CALL_EndQueryARB(ctx->Exec, (n[1].e)); break; + case OPCODE_QUERY_COUNTER: + CALL_QueryCounter(ctx->Exec, (n[1].ui, n[2].e)); + break; #endif case OPCODE_DRAW_BUFFERS_ARB: { @@ -10309,6 +10332,7 @@ _mesa_create_save_table(void) _mesa_init_queryobj_dispatch(table); /* glGetQuery, etc */ SET_BeginQueryARB(table, save_BeginQueryARB); SET_EndQueryARB(table, save_EndQueryARB); + SET_QueryCounter(table, save_QueryCounter); #endif SET_DrawBuffersARB(table, save_DrawBuffersARB); diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 793cc4e24..dbc2813f2 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -139,6 +139,7 @@ static const struct extension extension_table[] = { { "GL_ARB_texture_rg", o(ARB_texture_rg), GL, 2008 }, { "GL_ARB_texture_storage", o(ARB_texture_storage), GL, 2011 }, { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL, 2008 }, + { "GL_ARB_timer_query", o(ARB_timer_query), GL, 2010 }, { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL, 2010 }, { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL, 1999 }, { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL, 2009 }, diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index a83d36721..cff4cf394 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -342,6 +342,7 @@ EXTRA_EXT(ARB_texture_buffer_object); EXTRA_EXT(OES_EGL_image_external); EXTRA_EXT(ARB_blend_func_extended); EXTRA_EXT(ARB_uniform_buffer_object); +EXTRA_EXT(ARB_timer_query); static const int extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { @@ -1353,6 +1354,9 @@ static const struct value_desc values[] = { { GL_UNIFORM_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_uniform_buffer_object }, + /* GL_ARB_timer_query */ + { GL_TIMESTAMP, LOC_CUSTOM, TYPE_INT64, 0, extra_ARB_timer_query } + #endif /* FEATURE_GL */ }; @@ -1807,7 +1811,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu case GL_UNIFORM_BUFFER_BINDING: v->value_int = ctx->UniformBuffer->Name; break; - } + /* GL_ARB_timer_query */ + case GL_TIMESTAMP: + if (ctx->Driver.GetTimestamp) { + v->value_int64 = ctx->Driver.GetTimestamp(ctx); + } + else { + _mesa_problem(ctx, "driver doesn't implement GetTimestamp"); + } + break; + } } /** diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index bae5dad1e..805c031ae 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -353,9 +353,66 @@ _mesa_EndQueryARB(GLenum target) static void GLAPIENTRY +_mesa_QueryCounter(GLuint id, GLenum target) +{ + struct gl_query_object *q; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glQueryCounter(%u, %s)\n", id, + _mesa_lookup_enum_by_nr(target)); + + /* error checking */ + if (target != GL_TIMESTAMP) { + _mesa_error(ctx, GL_INVALID_ENUM, "glQueryCounter(target)"); + return; + } + + if (id == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glQueryCounter(id==0)"); + return; + } + + q = _mesa_lookup_query_object(ctx, id); + if (!q) { + /* XXX the Core profile should throw INVALID_OPERATION here */ + + /* create new object */ + q = ctx->Driver.NewQueryObject(ctx, id); + if (!q) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glQueryCounter"); + return; + } + _mesa_HashInsert(ctx->Query.QueryObjects, id, q); + } + else { + if (q->Target && q->Target != GL_TIMESTAMP) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glQueryCounter(id has an invalid target)"); + return; + } + } + + if (q->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glQueryCounter(id is active)"); + return; + } + + q->Target = target; + q->Result = 0; + q->Ready = GL_FALSE; + + /* QueryCounter is implemented using EndQuery without BeginQuery + * in drivers. This is actually Direct3D and Gallium convention. */ + ctx->Driver.EndQuery(ctx, q); +} + + +static void GLAPIENTRY _mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) { - struct gl_query_object *q, **bindpt; + struct gl_query_object *q = NULL, **bindpt = NULL; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -364,13 +421,21 @@ _mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params) _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)"); - return; + if (target == GL_TIMESTAMP) { + if (!ctx->Extensions.ARB_timer_query) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); + return; + } } + else { + bindpt = get_query_binding_point(ctx, target); + if (!bindpt) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)"); + return; + } - q = *bindpt; + q = *bindpt; + } switch (pname) { case GL_QUERY_COUNTER_BITS_ARB: @@ -581,6 +646,7 @@ _mesa_init_queryobj_dispatch(struct _glapi_table *disp) SET_GetQueryivARB(disp, _mesa_GetQueryivARB); SET_GetQueryObjectivARB(disp, _mesa_GetQueryObjectivARB); SET_GetQueryObjectuivARB(disp, _mesa_GetQueryObjectuivARB); + SET_QueryCounter(disp, _mesa_QueryCounter); SET_GetQueryObjecti64vEXT(disp, _mesa_GetQueryObjecti64vEXT); SET_GetQueryObjectui64vEXT(disp, _mesa_GetQueryObjectui64vEXT); diff --git a/mesalib/src/mesa/main/texcompress_etc.h b/mesalib/src/mesa/main/texcompress_etc.h index 4e166b2b1..8e8427f8f 100644 --- a/mesalib/src/mesa/main/texcompress_etc.h +++ b/mesalib/src/mesa/main/texcompress_etc.h @@ -30,10 +30,10 @@ struct swrast_texture_image; -extern GLboolean +GLboolean _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS); -extern void +void _mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel); diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c index b6a236e8d..e5e4a81dc 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c @@ -39,6 +39,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" +#include "pipe/p_screen.h" #include "st_context.h" #include "st_cb_queryobj.h" #include "st_cb_bitmap.h" @@ -133,6 +134,11 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q) st_flush_bitmap_cache(st_context(ctx)); + if (q->Target == GL_TIMESTAMP && !stq->pq) { + stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP); + stq->type = PIPE_QUERY_TIMESTAMP; + } + pipe->end_query(pipe, stq->pq); } @@ -169,6 +175,13 @@ st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q) } +static uint64_t +st_GetTimestamp(struct gl_context *ctx) +{ + struct pipe_screen *screen = st_context(ctx)->pipe->screen; + + return screen->get_timestamp(screen); +} void st_init_query_functions(struct dd_function_table *functions) @@ -179,6 +192,7 @@ void st_init_query_functions(struct dd_function_table *functions) functions->EndQuery = st_EndQuery; functions->WaitQuery = st_WaitQuery; functions->CheckQuery = st_CheckQuery; + functions->GetTimestamp = st_GetTimestamp; } #endif /* FEATURE_queryobj */ diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index fd9507536..5b333ad2c 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -636,4 +636,9 @@ void st_init_extensions(struct st_context *st) if (ctx->Const.MaxDualSourceDrawBuffers > 0) ctx->Extensions.ARB_blend_func_extended = GL_TRUE; + + if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY) && + screen->get_param(screen, PIPE_CAP_QUERY_TIMESTAMP)) { + ctx->Extensions.ARB_timer_query = GL_TRUE; + } } |