kms: Use a dummy surface instead of the surfaceless extension
The surfaceless extension that Mesa advertises has been renamed to EGL_KHR_surfaceless_context instead of a separate extension for the GLES, GLES2 and GL APIs and the new extension has been ratified by Khronos. Therefore the KMS backend no longer runs against Mesa master. We could just rename the extension we check for, however Weston (the sample Wayland compositor) has switched to just creating a dummy GBM surface and not using the surfaceless extension at all. We should probably do the same thing. Using the surfaceless extension could be a good idea but we don't really need to rely on it for KMS and we would want to do it for all EGL backends, not just the KMS backend. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit d4f22f8cb013d417c99ba03924538924191c2fe6)
This commit is contained in:
parent
51d94769be
commit
32fbd0ada6
@ -88,18 +88,3 @@ COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglUnbindWaylandDisplay,
|
||||
struct wl_display *wayland_display))
|
||||
COGL_WINSYS_FEATURE_END ()
|
||||
#endif
|
||||
COGL_WINSYS_FEATURE_BEGIN (surfaceless_opengl,
|
||||
"KHR\0",
|
||||
"surfaceless_opengl\0",
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL)
|
||||
COGL_WINSYS_FEATURE_END ()
|
||||
COGL_WINSYS_FEATURE_BEGIN (surfaceless_gles1,
|
||||
"KHR\0",
|
||||
"surfaceless_gles1\0",
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1)
|
||||
COGL_WINSYS_FEATURE_END ()
|
||||
COGL_WINSYS_FEATURE_BEGIN (surfaceless_gles2,
|
||||
"KHR\0",
|
||||
"surfaceless_gles2\0",
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2)
|
||||
COGL_WINSYS_FEATURE_END ()
|
||||
|
@ -79,6 +79,7 @@ typedef struct _CoglDisplayKMS
|
||||
int width, height;
|
||||
CoglBool pending_set_crtc;
|
||||
CoglBool pending_swap_notify;
|
||||
struct gbm_surface *dummy_gbm_surface;
|
||||
} CoglDisplayKMS;
|
||||
|
||||
typedef struct _CoglFlipKMS
|
||||
@ -388,8 +389,6 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
|
||||
CoglDisplayKMS *kms_display;
|
||||
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
||||
CoglRendererKMS *kms_renderer = egl_renderer->platform;
|
||||
CoglEGLWinsysFeature surfaceless_feature = 0;
|
||||
const char *surfaceless_feature_name = "";
|
||||
drmModeRes *resources;
|
||||
CoglOutputKMS *output0, *output1;
|
||||
CoglBool mirror;
|
||||
@ -397,33 +396,6 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
|
||||
kms_display = g_slice_new0 (CoglDisplayKMS);
|
||||
egl_display->platform = kms_display;
|
||||
|
||||
switch (display->renderer->driver)
|
||||
{
|
||||
case COGL_DRIVER_GL:
|
||||
surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL;
|
||||
surfaceless_feature_name = "opengl";
|
||||
break;
|
||||
case COGL_DRIVER_GLES1:
|
||||
surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1;
|
||||
surfaceless_feature_name = "gles1";
|
||||
break;
|
||||
case COGL_DRIVER_GLES2:
|
||||
surfaceless_feature = COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2;
|
||||
surfaceless_feature_name = "gles2";
|
||||
break;
|
||||
case COGL_DRIVER_ANY:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
if (!(egl_renderer->private_features & surfaceless_feature))
|
||||
{
|
||||
g_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_INIT,
|
||||
"EGL_KHR_surfaceless_%s extension not available",
|
||||
surfaceless_feature_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
resources = drmModeGetResources (kms_renderer->fd);
|
||||
if (!resources)
|
||||
{
|
||||
@ -538,10 +510,39 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
CoglDisplayEGL *egl_display = display->winsys;
|
||||
CoglDisplayKMS *kms_display = egl_display->platform;
|
||||
CoglRenderer *renderer = display->renderer;
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
CoglRendererKMS *kms_renderer = egl_renderer->platform;
|
||||
|
||||
kms_display->dummy_gbm_surface = gbm_surface_create (kms_renderer->gbm,
|
||||
16, 16,
|
||||
GBM_FORMAT_XRGB8888,
|
||||
GBM_BO_USE_RENDERING);
|
||||
if (!kms_display->dummy_gbm_surface)
|
||||
{
|
||||
g_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
||||
"Failed to create dummy GBM surface");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
egl_display->dummy_surface =
|
||||
eglCreateWindowSurface (egl_renderer->edpy,
|
||||
egl_display->egl_config,
|
||||
(NativeWindowType) kms_display->dummy_gbm_surface,
|
||||
NULL);
|
||||
if (egl_display->dummy_surface == EGL_NO_SURFACE)
|
||||
{
|
||||
g_set_error (error, COGL_WINSYS_ERROR,
|
||||
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
||||
"Failed to create dummy EGL surface");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_cogl_winsys_egl_make_current (display,
|
||||
EGL_NO_SURFACE,
|
||||
EGL_NO_SURFACE,
|
||||
egl_display->dummy_surface,
|
||||
egl_display->dummy_surface,
|
||||
egl_display->egl_context))
|
||||
{
|
||||
g_set_error (error, COGL_WINSYS_ERROR,
|
||||
@ -556,6 +557,22 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
|
||||
static void
|
||||
_cogl_winsys_egl_cleanup_context (CoglDisplay *display)
|
||||
{
|
||||
CoglDisplayEGL *egl_display = display->winsys;
|
||||
CoglDisplayKMS *kms_display = egl_display->platform;
|
||||
CoglRenderer *renderer = display->renderer;
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
|
||||
if (egl_display->dummy_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface);
|
||||
egl_display->dummy_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
if (kms_display->dummy_gbm_surface != NULL)
|
||||
{
|
||||
gbm_surface_destroy (kms_display->dummy_gbm_surface);
|
||||
kms_display->dummy_gbm_surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -68,10 +68,7 @@ typedef enum _CoglEGLWinsysFeature
|
||||
{
|
||||
COGL_EGL_WINSYS_FEATURE_SWAP_REGION =1L<<0,
|
||||
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP =1L<<1,
|
||||
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2,
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_OPENGL =1L<<3,
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES1 =1L<<4,
|
||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_GLES2 =1L<<5
|
||||
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2
|
||||
} CoglEGLWinsysFeature;
|
||||
|
||||
typedef struct _CoglRendererEGL
|
||||
|
Loading…
Reference in New Issue
Block a user