diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-09-06 20:51:00 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-09-06 21:08:13 -0400 |
commit | 2bc5e8eaf89967f55b63c31f58f8e3a8d7f8810e (patch) | |
tree | e6f7e92b439c41d0a4aaafd52498c976662f1d0b | |
parent | fa1be023a2923cd581abdaf20bab95dac80153c8 (diff) |
compositor: Create outputs before initializing GLES2 state
This way we can just use the first weston_output EGLSurface to make a
context current.
-rw-r--r-- | src/compositor-drm.c | 37 | ||||
-rw-r--r-- | src/compositor-wayland.c | 24 | ||||
-rw-r--r-- | src/compositor-x11.c | 28 | ||||
-rw-r--r-- | src/gles2-renderer.c | 12 |
4 files changed, 23 insertions, 78 deletions
diff --git a/src/compositor-drm.c b/src/compositor-drm.c index cbb3253d..d3101942 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -88,9 +88,6 @@ struct drm_compositor { uint32_t connector_allocator; struct tty *tty; - struct gbm_surface *dummy_surface; - EGLSurface dummy_egl_surface; - /* we need these parameters in order to not fail drmModeAddFB2() * due to out of bounds dimensions, and then mistakenly set * sprites_are_broken: @@ -1112,30 +1109,6 @@ init_egl(struct drm_compositor *ec, struct udev_device *device) return -1; } - ec->dummy_surface = gbm_surface_create(ec->gbm, 10, 10, - GBM_FORMAT_XRGB8888, - GBM_BO_USE_RENDERING); - if (!ec->dummy_surface) { - weston_log("failed to create dummy gbm surface\n"); - return -1; - } - - ec->dummy_egl_surface = - eglCreateWindowSurface(ec->base.egl_display, - ec->base.egl_config, - ec->dummy_surface, - NULL); - if (ec->dummy_egl_surface == EGL_NO_SURFACE) { - weston_log("failed to create egl surface\n"); - return -1; - } - - if (!eglMakeCurrent(ec->base.egl_display, ec->dummy_egl_surface, - ec->dummy_egl_surface, ec->base.egl_context)) { - weston_log("failed to make context current\n"); - return -1; - } - return 0; } @@ -2265,9 +2238,6 @@ drm_compositor_create(struct wl_display *display, ec->prev_state = WESTON_COMPOSITOR_ACTIVE; - if (gles2_renderer_init(&ec->base) < 0) - goto err_egl; - for (key = KEY_F1; key < KEY_F9; key++) weston_compositor_add_key_binding(&ec->base, key, MODIFIER_CTRL | MODIFIER_ALT, @@ -2281,6 +2251,9 @@ drm_compositor_create(struct wl_display *display, goto err_sprite; } + if (gles2_renderer_init(&ec->base) < 0) + goto err_egl; + path = NULL; evdev_input_create(&ec->base, ec->udev, seat); @@ -2319,14 +2292,14 @@ err_drm_source: wl_event_source_remove(ec->drm_source); wl_list_for_each_safe(weston_seat, next, &ec->base.seat_list, link) evdev_input_destroy(weston_seat); -err_sprite: - destroy_sprites(ec); err_egl: eglMakeCurrent(ec->base.egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglTerminate(ec->base.egl_display); eglReleaseThread(); gbm_device_destroy(ec->gbm); +err_sprite: + destroy_sprites(ec); err_udev_dev: udev_device_unref(drm_device); err_udev_enum: diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index 49087982..8136bffe 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -46,9 +46,6 @@ struct wayland_compositor { struct weston_compositor base; - struct wl_egl_pixmap *dummy_pixmap; - EGLSurface dummy_egl_surface; - struct { struct wl_display *wl_display; struct wl_compositor *compositor; @@ -296,21 +293,6 @@ wayland_compositor_init_egl(struct wayland_compositor *c) return -1; } - c->dummy_pixmap = wl_egl_pixmap_create(10, 10, 0); - if (!c->dummy_pixmap) { - weston_log("failure to create dummy_pixmap\n"); - return -1; - } - - c->dummy_egl_surface = - eglCreatePixmapSurface(c->base.egl_display, c->base.egl_config, - c->dummy_pixmap, NULL); - if (!eglMakeCurrent(c->base.egl_display, c->dummy_egl_surface, - c->dummy_egl_surface, c->base.egl_context)) { - weston_log("failed to make context current\n"); - return -1; - } - return 0; } @@ -884,13 +866,13 @@ wayland_compositor_create(struct wl_display *display, c->base.destroy = wayland_destroy; c->base.restore = wayland_restore; - if (gles2_renderer_init(&c->base) < 0) - goto err_display; - create_border(c); if (wayland_compositor_create_output(c, width, height) < 0) goto err_display; + if (gles2_renderer_init(&c->base) < 0) + goto err_display; + loop = wl_display_get_event_loop(c->base.wl_display); fd = wl_display_get_fd(c->parent.wl_display, update_event_mask, c); diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 22f228e9..3b161d4b 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -68,8 +68,6 @@ struct x11_configured_output { struct x11_compositor { struct weston_compositor base; - EGLSurface dummy_pbuffer; - Display *dpy; xcb_connection_t *conn; xcb_screen_t *screen; @@ -256,12 +254,6 @@ x11_compositor_init_egl(struct x11_compositor *c) EGL_NONE }; - static const EGLint pbuffer_attribs[] = { - EGL_WIDTH, 10, - EGL_HEIGHT, 10, - EGL_NONE - }; - c->base.egl_display = eglGetDisplay(c->dpy); if (c->base.egl_display == NULL) { weston_log("failed to create display\n"); @@ -291,20 +283,6 @@ x11_compositor_init_egl(struct x11_compositor *c) return -1; } - c->dummy_pbuffer = eglCreatePbufferSurface(c->base.egl_display, - c->base.egl_config, - pbuffer_attribs); - if (c->dummy_pbuffer == NULL) { - weston_log("failed to create dummy pbuffer\n"); - return -1; - } - - if (!eglMakeCurrent(c->base.egl_display, c->dummy_pbuffer, - c->dummy_pbuffer, c->base.egl_context)) { - weston_log("failed to make context current\n"); - return -1; - } - return 0; } @@ -1175,9 +1153,6 @@ x11_compositor_create(struct wl_display *display, c->base.destroy = x11_destroy; c->base.restore = x11_restore; - if (gles2_renderer_init(&c->base) < 0) - goto err_egl; - if (x11_input_create(c, no_input) < 0) goto err_egl; @@ -1212,6 +1187,9 @@ x11_compositor_create(struct wl_display *display, x = pixman_region32_extents(&output->base.region)->x2; } + if (gles2_renderer_init(&c->base) < 0) + goto err_egl; + c->xcb_source = wl_event_loop_add_fd(c->base.input_loop, xcb_get_file_descriptor(c->conn), diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c index 241b5bb2..ff099d68 100644 --- a/src/gles2-renderer.c +++ b/src/gles2-renderer.c @@ -1045,11 +1045,23 @@ gles2_renderer_init(struct weston_compositor *ec) struct gles2_renderer *renderer; const char *extensions; int has_egl_image_external = 0; + struct weston_output *output; + EGLBoolean ret; renderer = malloc(sizeof *renderer); if (renderer == NULL) return -1; + output = container_of(ec->output_list.next, + struct weston_output, link); + ret = eglMakeCurrent(ec->egl_display, output->egl_surface, + output->egl_surface, ec->egl_context); + if (ret == EGL_FALSE) { + weston_log("Failed to make EGL context current.\n"); + print_egl_error_state(); + return -1; + } + log_egl_gl_info(ec->egl_display); ec->image_target_texture_2d = |