1
0
Fork 0

cogl: Merge FEATURE_ID_GET_GPU_TIME into FEATURE_ID_TIMESTAMP_QUERY

Because both code paths require the existence of `GL_TIMESTAMP[_EXT]`
which is only guaranteed if `ARB_timer_query` (included in GL core 3.3)
is implemented.

We know when that is true because `context->glGenQueries` and
`context->glQueryCounter` are non-NULL. So that is the minimum
requirement for any use of `GL_TIMESTAMP`, even when it is used in
`glGetInteger64v`.

Until now, Raspberry Pi (OpenGL 2.1) would find a working implementation
of `glGetInteger64v` but failed to check whether the driver understands
`GL_TIMESTAMP` (it doesn't).

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2107
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2253>
This commit is contained in:
Daniel van Vugt 2022-01-21 15:25:53 +08:00 committed by Marge Bot
parent 264e1a9066
commit c970bb3e6c
7 changed files with 7 additions and 14 deletions

View file

@ -519,7 +519,7 @@ int64_t
cogl_context_get_gpu_time_ns (CoglContext *context)
{
g_return_val_if_fail (cogl_has_feature (context,
COGL_FEATURE_ID_GET_GPU_TIME),
COGL_FEATURE_ID_TIMESTAMP_QUERY),
0);
return context->driver_vtable->get_gpu_time_ns (context);

View file

@ -210,7 +210,6 @@ typedef enum _CoglFeatureID
COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL,
COGL_FEATURE_ID_BLIT_FRAMEBUFFER,
COGL_FEATURE_ID_TIMESTAMP_QUERY,
COGL_FEATURE_ID_GET_GPU_TIME,
/*< private >*/
_COGL_N_FEATURE_IDS /*< skip >*/
@ -385,7 +384,7 @@ cogl_context_timestamp_query_get_time_ns (CoglContext *context,
* cogl_context_get_gpu_time_ns:
* @context: a #CoglContext pointer
*
* This function should only be called if the COGL_FEATURE_ID_GET_GPU_TIME
* This function should only be called if the COGL_FEATURE_ID_TIMESTAMP_QUERY
* feature is advertised.
*
* Return value: Current GPU time in nanoseconds

View file

@ -558,7 +558,7 @@ cogl_gl_get_gpu_time_ns (CoglContext *context)
int64_t gpu_time_ns;
g_return_val_if_fail (cogl_has_feature (context,
COGL_FEATURE_ID_GET_GPU_TIME),
COGL_FEATURE_ID_TIMESTAMP_QUERY),
0);
GE (context, glGetInteger64v (GL_TIMESTAMP, &gpu_time_ns));

View file

@ -543,12 +543,9 @@ _cogl_driver_update_features (CoglContext *ctx,
COGL_PRIVATE_FEATURE_TEXTURE_FORMAT_HALF_FLOAT,
TRUE);
if (ctx->glGenQueries && ctx->glQueryCounter)
if (ctx->glGenQueries && ctx->glQueryCounter && ctx->glGetInteger64v)
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TIMESTAMP_QUERY, TRUE);
if (ctx->glGetInteger64v)
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_GET_GPU_TIME, TRUE);
/* Cache features */
for (i = 0; i < G_N_ELEMENTS (private_features); i++)
ctx->private_features[i] |= private_features[i];

View file

@ -437,12 +437,9 @@ _cogl_driver_update_features (CoglContext *context,
COGL_FEATURE_ID_TEXTURE_RG,
TRUE);
if (context->glGenQueries && context->glQueryCounter)
if (context->glGenQueries && context->glQueryCounter && context->glGetInteger64v)
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TIMESTAMP_QUERY, TRUE);
if (context->glGetInteger64v)
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_GET_GPU_TIME, TRUE);
/* Cache features */
for (i = 0; i < G_N_ELEMENTS (private_features); i++)
context->private_features[i] |= private_features[i];

View file

@ -295,7 +295,7 @@ cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
COGL_FRAMEBUFFER (onscreen),
COGL_FRAMEBUFFER_STATE_BIND);
if (cogl_has_feature (context, COGL_FEATURE_ID_GET_GPU_TIME))
if (cogl_has_feature (context, COGL_FEATURE_ID_TIMESTAMP_QUERY))
{
info->gpu_time_before_buffer_swap_ns =
cogl_context_get_gpu_time_ns (context);

View file

@ -324,7 +324,7 @@ meta_drm_buffer_gbm_fill_timings (MetaDrmBuffer *buffer,
cogl_fbo = cogl_offscreen_new_with_texture (COGL_TEXTURE (cogl_tex));
cogl_object_unref (cogl_tex);
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_GET_GPU_TIME))
if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_TIMESTAMP_QUERY))
{
info->gpu_time_before_buffer_swap_ns =
cogl_context_get_gpu_time_ns (cogl_context);