[cogl] kms: Fix GLES2 support
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] kms: Fix GLES2 support
- Date: Thu, 8 Dec 2011 12:59:38 +0000 (UTC)
commit 7adf7c5e389578612612cd93db829fca59d31bf8
Author: Neil Roberts <neil linux intel com>
Date: Thu Dec 8 11:40:58 2011 +0000
kms: Fix GLES2 support
There were two problems stopping the KMS winsys from working with a
GLES2 driver:
â When creating the EGL context, it was missing the attribute to
select the client version so it would end up with the GLES1 API.
â When creating the depth buffer for the framebuffer it was using
GL_DEPTH_COMPONENT but only GL_DEPTH_COMPONENT16 is supported on
GLES. cogl-framebuffer already unconditionally uses this so it
probably makes sense to do the same here.
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/winsys/cogl-winsys-egl.c | 6 +++---
cogl/winsys/cogl-winsys-kms.c | 37 ++++++++++++++++++++++++++++---------
cogl/winsys/cogl-winsys-kms.h | 6 +++---
3 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 7d0435f..7fc3268 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -578,8 +578,8 @@ try_create_context (CoglDisplay *display,
CoglXlibDisplay *xlib_display = display->winsys;
CoglXlibRenderer *xlib_renderer = display->renderer->winsys;
#endif
- CoglRendererEGL *egl_renderer = display->renderer->winsys;
#ifndef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
+ CoglRendererEGL *egl_renderer = display->renderer->winsys;
EGLDisplay edpy;
EGLConfig config;
EGLint config_count = 0;
@@ -849,8 +849,8 @@ try_create_context (CoglDisplay *display,
&egl_display->egl_surface_height);
#elif defined (COGL_HAS_EGL_PLATFORM_KMS_SUPPORT)
- if (!_cogl_winsys_kms_create_context (&egl_renderer->kms_renderer,
- &egl_display->kms_display,
+ if (!_cogl_winsys_kms_create_context (display->renderer,
+ display,
error))
return FALSE;
diff --git a/cogl/winsys/cogl-winsys-kms.c b/cogl/winsys/cogl-winsys-kms.c
index cad666d..4271788 100644
--- a/cogl/winsys/cogl-winsys-kms.c
+++ b/cogl/winsys/cogl-winsys-kms.c
@@ -185,11 +185,29 @@ _cogl_winsys_kms_display_setup (CoglDisplay *display, GError **error)
}
gboolean
-_cogl_winsys_kms_create_context (CoglRendererKMS *kms_renderer,
- CoglDisplayKMS *kms_display,
- GError **error)
+_cogl_winsys_kms_create_context (CoglRenderer *renderer,
+ CoglDisplay *display,
+ GError **error)
{
- kms_display->egl_context = eglCreateContext (kms_renderer->dpy, NULL, EGL_NO_CONTEXT, NULL);
+ CoglRendererEGL *egl_renderer = renderer->winsys;
+ CoglDisplayEGL *egl_display = display->winsys;
+ CoglRendererKMS *kms_renderer = &egl_renderer->kms_renderer;
+ CoglDisplayKMS *kms_display = &egl_display->kms_display;
+ EGLint attribs[3];
+
+ if (renderer->driver == COGL_DRIVER_GLES2)
+ {
+ attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
+ attribs[1] = 2;
+ attribs[2] = EGL_NONE;
+ }
+ else
+ attribs[0] = EGL_NONE;
+
+ kms_display->egl_context = eglCreateContext (kms_renderer->dpy,
+ NULL,
+ EGL_NO_CONTEXT,
+ attribs);
if (kms_display->egl_context == NULL)
{
@@ -277,11 +295,12 @@ _cogl_winsys_kms_onscreen_init (CoglContext *context,
context->glGenFramebuffers (1, &kms_onscreen->fb);
context->glBindFramebuffer (GL_FRAMEBUFFER_EXT, kms_onscreen->fb);
- context->glGenRenderbuffers(1, &kms_onscreen->depth_rb);
- context->glBindRenderbuffer(GL_RENDERBUFFER_EXT, kms_onscreen->depth_rb);
- context->glRenderbufferStorage(GL_RENDERBUFFER_EXT,
- GL_DEPTH_COMPONENT,
- kms_display->mode.hdisplay, kms_display->mode.vdisplay);
+ context->glGenRenderbuffers (1, &kms_onscreen->depth_rb);
+ context->glBindRenderbuffer (GL_RENDERBUFFER_EXT, kms_onscreen->depth_rb);
+ context->glRenderbufferStorage (GL_RENDERBUFFER_EXT,
+ GL_DEPTH_COMPONENT16,
+ kms_display->mode.hdisplay,
+ kms_display->mode.vdisplay);
context->glBindRenderbuffer (GL_RENDERBUFFER_EXT, 0);
context->glFramebufferRenderbuffer (GL_FRAMEBUFFER_EXT,
diff --git a/cogl/winsys/cogl-winsys-kms.h b/cogl/winsys/cogl-winsys-kms.h
index bda0d40..4aba087 100644
--- a/cogl/winsys/cogl-winsys-kms.h
+++ b/cogl/winsys/cogl-winsys-kms.h
@@ -91,9 +91,9 @@ _cogl_winsys_kms_bind (CoglRendererKMS *kms_renderer,
CoglDisplayKMS *kms_display);
gboolean
-_cogl_winsys_kms_create_context (CoglRendererKMS *kms_renderer,
- CoglDisplayKMS *kms_display,
- GError **error);
+_cogl_winsys_kms_create_context (CoglRenderer *renderer,
+ CoglDisplay *display,
+ GError **error);
gboolean
_cogl_winsys_kms_destroy_context (CoglRendererKMS *kms_renderer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]