diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 10 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 4 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2_fallbacks.h | 8 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_android.c | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_x11.c | 29 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 23 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 3 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 2 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 2 |
11 files changed, 84 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index a5f71edb984..f7f2da254e2 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1389,6 +1389,15 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx, } #endif +static EGLBoolean +dri2_get_sync_values_chromium(_EGLDisplay *dpy, _EGLSurface *surf, + EGLuint64KHR *ust, EGLuint64KHR *msc, + EGLuint64KHR *sbc) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); + return dri2_dpy->vtbl->get_sync_values(dpy, surf, ust, msc, sbc); +} + /** * Set the error code after a call to * dri2_egl_image::dri_image::createImageFromTexture. @@ -2182,6 +2191,7 @@ _eglBuiltInDriverDRI2(const char *args) dri2_drv->base.API.UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl; dri2_drv->base.API.QueryWaylandBufferWL = dri2_query_wayland_buffer_wl; #endif + dri2_drv->base.API.GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium; dri2_drv->base.Name = "DRI2"; dri2_drv->base.Unload = dri2_unload; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 44d6d74b948..0dd9d69d08e 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -138,6 +138,10 @@ struct dri2_egl_display_vtbl { struct wl_buffer* (*create_wayland_buffer_from_image)( _EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img); + + EGLBoolean (*get_sync_values)(_EGLDisplay *display, _EGLSurface *surface, + EGLuint64KHR *ust, EGLuint64KHR *msc, + EGLuint64KHR *sbc); }; struct dri2_egl_display diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h b/src/egl/drivers/dri2/egl_dri2_fallbacks.h index a5cf344f5e8..9cba0010ba7 100644 --- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h +++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h @@ -98,3 +98,11 @@ dri2_fallback_create_wayland_buffer_from_image(_EGLDriver *drv, { return NULL; } + +static inline EGLBoolean +dri2_fallback_get_sync_values(_EGLDisplay *dpy, _EGLSurface *surf, + EGLuint64KHR *ust, EGLuint64KHR *msc, + EGLuint64KHR *sbc) +{ + return EGL_FALSE; +} diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 7b1db7677ce..71948bd88fe 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -650,6 +650,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = { .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = dri2_fallback_query_buffer_age, .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, + .get_sync_values = dri2_fallback_get_sync_values, }; EGLBoolean diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 9a7633a070a..52d8b49aa9e 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -472,6 +472,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = { .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = dri2_drm_query_buffer_age, .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, + .get_sync_values = dri2_fallback_get_sync_values, }; EGLBoolean diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 37dcf19f9be..537d26e97b7 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -964,6 +964,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = { .copy_buffers = dri2_fallback_copy_buffers, .query_buffer_age = dri2_wl_query_buffer_age, .create_wayland_buffer_from_image = dri2_wl_create_wayland_buffer_from_image, + .get_sync_values = dri2_fallback_get_sync_values, }; EGLBoolean diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 7b585a21971..874bcc48fe6 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1008,6 +1008,32 @@ dri2_x11_swrast_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, return NULL; } +static EGLBoolean +dri2_x11_get_sync_values(_EGLDisplay *display, _EGLSurface *surface, + EGLuint64KHR *ust, EGLuint64KHR *msc, + EGLuint64KHR *sbc) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(display); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surface); + xcb_dri2_get_msc_cookie_t cookie; + xcb_dri2_get_msc_reply_t *reply; + + cookie = xcb_dri2_get_msc(dri2_dpy->conn, dri2_surf->drawable); + reply = xcb_dri2_get_msc_reply(dri2_dpy->conn, cookie, NULL); + + if (!reply) { + _eglError(EGL_BAD_ACCESS, __func__); + return EGL_FALSE; + } + + *ust = ((EGLuint64KHR) reply->ust_hi << 32) | reply->ust_lo; + *msc = ((EGLuint64KHR) reply->msc_hi << 32) | reply->msc_lo; + *sbc = ((EGLuint64KHR) reply->sbc_hi << 32) | reply->sbc_lo; + free(reply); + + return EGL_TRUE; +} + static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = { .authenticate = NULL, .create_window_surface = dri2_x11_create_window_surface, @@ -1022,6 +1048,7 @@ static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = { .copy_buffers = dri2_x11_copy_buffers, .query_buffer_age = dri2_fallback_query_buffer_age, .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, + .get_sync_values = dri2_fallback_get_sync_values, }; static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { @@ -1039,6 +1066,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = { .copy_buffers = dri2_x11_copy_buffers, .query_buffer_age = dri2_fallback_query_buffer_age, .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image, + .get_sync_values = dri2_x11_get_sync_values, }; static EGLBoolean @@ -1243,6 +1271,7 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp) disp->Extensions.NOK_swap_region = EGL_TRUE; disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE; disp->Extensions.NV_post_sub_buffer = EGL_TRUE; + disp->Extensions.CHROMIUM_sync_control = EGL_TRUE; #ifdef HAVE_WAYLAND_PLATFORM disp->Extensions.WL_bind_wayland_display = EGL_TRUE; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 219d8e61715..27d08027924 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -1086,6 +1086,7 @@ eglGetProcAddress(const char *procname) { "eglGetPlatformDisplayEXT", (_EGLProc) eglGetPlatformDisplayEXT }, { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc) eglCreatePlatformWindowSurfaceEXT }, { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc) eglCreatePlatformPixmapSurfaceEXT }, + { "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM }, { NULL, NULL } }; EGLint i; @@ -1751,3 +1752,25 @@ eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, RETURN_EGL_EVAL(disp, ret); } + +EGLBoolean EGLAPIENTRY +eglGetSyncValuesCHROMIUM(EGLDisplay display, EGLSurface surface, + EGLuint64KHR *ust, EGLuint64KHR *msc, + EGLuint64KHR *sbc) +{ + _EGLDisplay *disp = _eglLockDisplay(display); + _EGLSurface *surf = _eglLookupSurface(surface, disp); + _EGLDriver *drv; + EGLBoolean ret; + + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + if (!disp->Extensions.CHROMIUM_sync_control) + RETURN_EGL_EVAL(disp, EGL_FALSE); + + if (!ust || !msc || !sbc) + RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); + + ret = drv->API.GetSyncValuesCHROMIUM(disp, surf, ust, msc, sbc); + + RETURN_EGL_EVAL(disp, ret); +} diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index f20ce5b701b..cb01cab0c00 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -139,6 +139,8 @@ typedef EGLint (*QueryBufferAge_t)(_EGLDriver *drv, typedef EGLBoolean (*SwapBuffersWithDamageEXT_t) (_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, const EGLint *rects, EGLint n_rects); #endif +typedef EGLBoolean (*GetSyncValuesCHROMIUM_t) (_EGLDisplay *dpy, _EGLSurface *surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); + /** * The API dispatcher jumps through these functions */ @@ -225,6 +227,7 @@ struct _egl_api PostSubBufferNV_t PostSubBufferNV; QueryBufferAge_t QueryBufferAge; + GetSyncValuesCHROMIUM_t GetSyncValuesCHROMIUM; }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 970c21a9289..13b95327bc1 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -113,6 +113,8 @@ struct _egl_extensions EGLBoolean ANDROID_image_native_buffer; + EGLBoolean CHROMIUM_sync_control; + EGLBoolean NV_post_sub_buffer; EGLBoolean EXT_create_context_robustness; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 65669d8830f..388e4b51b7a 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -117,6 +117,8 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); + _EGL_CHECK_EXTENSION(CHROMIUM_sync_control); + _EGL_CHECK_EXTENSION(EXT_create_context_robustness); _EGL_CHECK_EXTENSION(EXT_buffer_age); _EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); |