From c63d94483b1e52817ca01ca82a867a78ebd39fa6 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 24 Mar 2018 18:30:28 -0400 Subject: Redesign wlr_texture - Textures are now immutable (apart from those created from raw pixels), no more invalid textures - Move all wl_drm stuff in wlr_renderer - Most of wlr_texture fields are now private - Remove some duplicated DMA-BUF code in the DRM backend - Add more assertions - Stride is now always given as bytes rather than pixels - Drop wl_shm functions Fun fact: this patch has been written 10,000 meters up in the air. --- include/wlr/render/egl.h | 16 ++-------- include/wlr/render/interface.h | 41 +++++++++++-------------- include/wlr/render/wlr_renderer.h | 15 +++++----- include/wlr/render/wlr_texture.h | 63 ++++++++++++++++----------------------- 4 files changed, 51 insertions(+), 84 deletions(-) (limited to 'include/wlr/render') diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index aa429e8e..c214f127 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -46,37 +46,25 @@ void wlr_egl_finish(struct wlr_egl *egl); */ bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display); -/** - * Refer to the eglQueryWaylandBufferWL extension function. - */ -bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf, - EGLint attrib, EGLint *value); - /** * Returns a surface for the given native window * The window must match the remote display the wlr_egl was created with. */ EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window); -/** - * Creates an egl image from the given client buffer and attributes. - */ -EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl, - EGLenum target, EGLClientBuffer buffer, const EGLint *attribs); - /** * Creates an egl image from the given dmabuf attributes. Check usability * of the dmabuf with wlr_egl_check_import_dmabuf once first. */ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer_attribs *attributes); + struct wlr_dmabuf_buffer_attribs *attributes); /** * Try to import the given dmabuf. On success return true false otherwise. * If this succeeds the dmabuf can be used for rendering on a texture */ bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer *dmabuf); + struct wlr_dmabuf_buffer *dmabuf); /** * Get the available dmabuf formats diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 7f25c0ff..212e4f7a 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -23,7 +23,6 @@ struct wlr_renderer_impl { void (*end)(struct wlr_renderer *renderer); void (*clear)(struct wlr_renderer *renderer, const float color[static 4]); void (*scissor)(struct wlr_renderer *renderer, struct wlr_box *box); - struct wlr_texture *(*texture_create)(struct wlr_renderer *renderer); bool (*render_texture_with_matrix)(struct wlr_renderer *renderer, struct wlr_texture *texture, const float matrix[static 9], float alpha); @@ -33,45 +32,39 @@ struct wlr_renderer_impl { const float color[static 4], const float matrix[static 9]); const enum wl_shm_format *(*formats)( struct wlr_renderer *renderer, size_t *len); - bool (*buffer_is_drm)(struct wlr_renderer *renderer, - struct wl_resource *buffer); + bool (*resource_is_wl_drm_buffer)(struct wlr_renderer *renderer, + struct wl_resource *resource); + void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer, + struct wl_resource *buffer, int *width, int *height); bool (*read_pixels)(struct wlr_renderer *renderer, enum wl_shm_format fmt, uint32_t stride, uint32_t width, uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, void *data); bool (*format_supported)(struct wlr_renderer *renderer, enum wl_shm_format fmt); + struct wlr_texture *(*texture_from_pixels)(struct wlr_renderer *renderer, + enum wl_shm_format fmt, uint32_t stride, uint32_t width, + uint32_t height, const void *data); + struct wlr_texture *(*texture_from_wl_drm)(struct wlr_renderer *renderer, + struct wl_resource *data); + struct wlr_texture *(*texture_from_dmabuf)(struct wlr_renderer *renderer, + struct wlr_dmabuf_buffer_attribs *attribs); void (*destroy)(struct wlr_renderer *renderer); }; void wlr_renderer_init(struct wlr_renderer *renderer, - const struct wlr_renderer_impl *impl); + const struct wlr_renderer_impl *impl); struct wlr_texture_impl { - bool (*upload_pixels)(struct wlr_texture *texture, - enum wl_shm_format format, int stride, int width, int height, - const unsigned char *pixels); - bool (*update_pixels)(struct wlr_texture *texture, - enum wl_shm_format format, int stride, int x, int y, - int width, int height, const unsigned char *pixels); - bool (*upload_shm)(struct wlr_texture *texture, uint32_t format, - struct wl_shm_buffer *shm); - bool (*update_shm)(struct wlr_texture *texture, uint32_t format, - int x, int y, int width, int height, struct wl_shm_buffer *shm); - bool (*upload_drm)(struct wlr_texture *texture, - struct wl_resource *drm_buf); - bool (*upload_eglimage)(struct wlr_texture *texture, EGLImageKHR image, - uint32_t width, uint32_t height); - bool (*upload_dmabuf)(struct wlr_texture *texture, - struct wl_resource *dmabuf_resource); - void (*get_buffer_size)(struct wlr_texture *texture, - struct wl_resource *resource, int *width, int *height); + void (*get_size)(struct wlr_texture *texture, int *width, int *height); + bool (*write_pixels)(struct wlr_texture *texture, + enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, + uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x, + uint32_t dst_y, const void *data); void (*destroy)(struct wlr_texture *texture); }; void wlr_texture_init(struct wlr_texture *texture, const struct wlr_texture_impl *impl); -void wlr_texture_get_buffer_size(struct wlr_texture *texture, - struct wl_resource *resource, int *width, int *height); #endif diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index 6f0d2ecc..decd14f5 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -1,8 +1,6 @@ #ifndef WLR_RENDER_WLR_RENDERER_H #define WLR_RENDER_WLR_RENDERER_H -#include -#include #include #include #include @@ -21,10 +19,6 @@ void wlr_renderer_clear(struct wlr_renderer *r, const float color[static 4]); * box. */ void wlr_renderer_scissor(struct wlr_renderer *r, struct wlr_box *box); -/** - * Requests a texture handle from this renderer. - */ -struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r); /** * Renders the requested texture. */ @@ -51,10 +45,15 @@ void wlr_render_colored_ellipse(struct wlr_renderer *r, const enum wl_shm_format *wlr_renderer_get_formats(struct wlr_renderer *r, size_t *len); /** - * Returns true if this wl_buffer is a DRM buffer. + * Returns true if this wl_buffer is a wl_drm buffer. */ -bool wlr_renderer_buffer_is_drm(struct wlr_renderer *renderer, +bool wlr_renderer_resource_is_wl_drm_buffer(struct wlr_renderer *renderer, struct wl_resource *buffer); +/** + * Gets the width and height of a wl_drm buffer. + */ +void wlr_renderer_wl_drm_buffer_get_size(struct wlr_renderer *renderer, + struct wl_resource *buffer, int *width, int *height); /** * Reads out of pixels of the currently bound surface into data. `stride` is in * bytes. diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h index 095097e6..ab361298 100644 --- a/include/wlr/render/wlr_texture.h +++ b/include/wlr/render/wlr_texture.h @@ -5,62 +5,49 @@ #include #include #include +#include +struct wlr_renderer; struct wlr_texture_impl; struct wlr_texture { const struct wlr_texture_impl *impl; - - bool valid; - uint32_t format; - int width, height; - bool inverted_y; - struct wl_signal destroy_signal; - struct wl_resource *resource; }; /** - * Copies pixels to this texture. The buffer is not accessed after this function - * returns. + * Create a new texture from raw pixel data. `stride` is in bytes. The returned + * texture is mutable. */ -bool wlr_texture_upload_pixels(struct wlr_texture *tex, - enum wl_shm_format format, int stride, int width, int height, - const unsigned char *pixels); +struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer, + enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height, + const void *data); + /** - * Copies pixels to this texture. The buffer is not accessed after this function - * returns. Under some circumstances, this function may re-upload the entire - * buffer - therefore, the entire buffer must be valid. + * Create a new texture from a wayland DRM resource. The returned texture is + * immutable. */ -bool wlr_texture_update_pixels(struct wlr_texture *surf, - enum wl_shm_format format, int stride, int x, int y, - int width, int height, const unsigned char *pixels); +struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer, + struct wl_resource *data); + /** - * Copies pixels from a wl_shm_buffer into this texture. The buffer is not - * accessed after this function returns. + * Create a new texture from a DMA-BUF. The returned texture is immutable. */ -bool wlr_texture_upload_shm(struct wlr_texture *tex, uint32_t format, - struct wl_shm_buffer *shm); +struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, + struct wlr_dmabuf_buffer_attribs *attribs); + /** - * Attaches the contents from the given wl_drm wl_buffer resource onto the - * texture. The wl_resource is not used after this call. - * Will fail (return false) if the given resource is no drm buffer. + * Get the texture width and height. */ -bool wlr_texture_upload_drm(struct wlr_texture *tex, - struct wl_resource *drm_buffer); - -bool wlr_texture_upload_eglimage(struct wlr_texture *tex, - EGLImageKHR image, uint32_t width, uint32_t height); +void wlr_texture_get_size(struct wlr_texture *texture, int *width, int *height); -bool wlr_texture_upload_dmabuf(struct wlr_texture *tex, - struct wl_resource *dmabuf_resource); /** - * Copies a rectangle of pixels from a wl_shm_buffer onto the texture. The - * buffer is not accessed after this function returns. Under some circumstances, - * this function may re-upload the entire buffer - therefore, the entire buffer - * must be valid. + * Update a texture with raw pixels. The texture must be mutable. */ -bool wlr_texture_update_shm(struct wlr_texture *surf, uint32_t format, - int x, int y, int width, int height, struct wl_shm_buffer *shm); +bool wlr_texture_write_pixels(struct wlr_texture *texture, + enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width, uint32_t height, + uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, + const void *data); + /** * Destroys this wlr_texture. */ -- cgit v1.2.3 From 793c3b30473bcad488eae9266b67ccfdf3106231 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 26 Mar 2018 12:41:51 -0400 Subject: render: add simple functions to render rectangles and ellipses --- examples/tablet.c | 18 ++++++++--------- include/wlr/render/interface.h | 4 ++-- include/wlr/render/wlr_renderer.h | 16 ++++++++++++--- render/gles2/renderer.c | 8 ++++---- render/wlr_renderer.c | 41 +++++++++++++++++++++++++++++---------- rootston/output.c | 2 +- 6 files changed, 60 insertions(+), 29 deletions(-) (limited to 'include/wlr/render') diff --git a/examples/tablet.c b/examples/tablet.c index 65c559cb..9379fac3 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -49,7 +49,6 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts wlr_renderer_begin(sample->renderer, wlr_output->width, wlr_output->height); wlr_renderer_clear(sample->renderer, (float[]){0.25f, 0.25f, 0.25f, 1}); - float matrix[9]; float distance = 0.8f * (1 - sample->distance); float tool_color[4] = { distance, distance, distance, 1 }; for (size_t i = 0; sample->button && i < 4; ++i) { @@ -61,12 +60,12 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts float pad_height = sample->height_mm * scale; float left = width / 2.0f - pad_width / 2.0f; float top = height / 2.0f - pad_height / 2.0f; - struct wlr_box box = { + const struct wlr_box box = { .x = left, .y = top, .width = pad_width, .height = pad_height, }; - wlr_matrix_project_box(matrix, &box, 0, 0, wlr_output->transform_matrix); - wlr_render_colored_quad(sample->renderer, sample->pad_color, matrix); + wlr_render_rect(sample->renderer, &box, sample->pad_color, + wlr_output->transform_matrix); if (sample->proximity) { struct wlr_box box = { @@ -75,16 +74,17 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts .width = 16 * (sample->pressure + 1), .height = 16 * (sample->pressure + 1), }; - wlr_matrix_project_box(matrix, &box, 0, sample->ring, - wlr_output->transform_matrix); - wlr_render_colored_quad(sample->renderer, tool_color, matrix); + float matrix[9]; + wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, + sample->ring, wlr_output->transform_matrix); + wlr_render_quad_with_matrix(sample->renderer, tool_color, matrix); + box.x += sample->x_tilt; box.y += sample->y_tilt; box.width /= 2; box.height /= 2; - wlr_matrix_project_box(matrix, &box, 0, 0, + wlr_render_rect(sample->renderer, &box, tool_color, wlr_output->transform_matrix); - wlr_render_colored_quad(sample->renderer, tool_color, matrix); } wlr_renderer_end(sample->renderer); diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 7f25c0ff..d4cd35f8 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -27,9 +27,9 @@ struct wlr_renderer_impl { bool (*render_texture_with_matrix)(struct wlr_renderer *renderer, struct wlr_texture *texture, const float matrix[static 9], float alpha); - void (*render_quad)(struct wlr_renderer *renderer, + void (*render_quad_with_matrix)(struct wlr_renderer *renderer, const float color[static 4], const float matrix[static 9]); - void (*render_ellipse)(struct wlr_renderer *renderer, + void (*render_ellipse_with_matrix)(struct wlr_renderer *renderer, const float color[static 4], const float matrix[static 9]); const enum wl_shm_format *(*formats)( struct wlr_renderer *renderer, size_t *len); diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index 6f0d2ecc..5c78089e 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -36,14 +36,24 @@ bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture, bool wlr_render_texture_with_matrix(struct wlr_renderer *r, struct wlr_texture *texture, const float matrix[static 9], float alpha); /** - * Renders a solid quad in the specified color. + * Renders a solid rectangle in the specified color. */ -void wlr_render_colored_quad(struct wlr_renderer *r, +void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box, + const float color[static 4], const float projection[static 9]); +/** + * Renders a solid quadrangle in the specified color with the specified matrix. + */ +void wlr_render_quad_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]); /** * Renders a solid ellipse in the specified color. */ -void wlr_render_colored_ellipse(struct wlr_renderer *r, +void wlr_render_ellipse(struct wlr_renderer *r, const struct wlr_box *box, + const float color[static 4], const float projection[static 9]); +/** + * Renders a solid ellipse in the specified color with the specified matrix. + */ +void wlr_render_ellipse_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]); /** * Returns a list of pixel formats supported by this renderer. diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 9403c0ed..61665a07 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -144,7 +144,7 @@ static bool gles2_render_texture_with_matrix( } -static void gles2_render_quad(struct wlr_renderer *wlr_renderer, +static void gles2_render_quad_with_matrix(struct wlr_renderer *wlr_renderer, const float color[static 4], const float matrix[static 9]) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); @@ -161,7 +161,7 @@ static void gles2_render_quad(struct wlr_renderer *wlr_renderer, GLES2_DEBUG_POP; } -static void gles2_render_ellipse(struct wlr_renderer *wlr_renderer, +static void gles2_render_ellipse_with_matrix(struct wlr_renderer *wlr_renderer, const float color[static 4], const float matrix[static 9]) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); @@ -256,8 +256,8 @@ static const struct wlr_renderer_impl renderer_impl = { .scissor = gles2_scissor, .texture_create = gles2_renderer_texture_create, .render_texture_with_matrix = gles2_render_texture_with_matrix, - .render_quad = gles2_render_quad, - .render_ellipse = gles2_render_ellipse, + .render_quad_with_matrix = gles2_render_quad_with_matrix, + .render_ellipse_with_matrix = gles2_render_ellipse_with_matrix, .formats = gles2_renderer_formats, .buffer_is_drm = gles2_buffer_is_drm, .read_pixels = gles2_read_pixels, diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 622aa1dd..5598a0e7 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -39,13 +39,16 @@ struct wlr_texture *wlr_render_texture_create(struct wlr_renderer *r) { bool wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture, const float projection[static 9], int x, int y, float alpha) { - float mat[9]; - wlr_matrix_identity(mat); - wlr_matrix_translate(mat, x, y); - wlr_matrix_scale(mat, texture->width, texture->height); - wlr_matrix_multiply(mat, projection, mat); + const struct wlr_box box = { + .x = x, .y = y, + .width = texture->width, .height = texture->height, + }; - return wlr_render_texture_with_matrix(r, texture, mat, alpha); + float matrix[9]; + wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, + projection); + + return wlr_render_texture_with_matrix(r, texture, matrix, alpha); } bool wlr_render_texture_with_matrix(struct wlr_renderer *r, @@ -54,14 +57,32 @@ bool wlr_render_texture_with_matrix(struct wlr_renderer *r, return r->impl->render_texture_with_matrix(r, texture, matrix, alpha); } -void wlr_render_colored_quad(struct wlr_renderer *r, +void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box, + const float color[static 4], const float projection[static 9]) { + float matrix[9]; + wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0, + projection); + + wlr_render_quad_with_matrix(r, color, matrix); +} + +void wlr_render_quad_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]) { - r->impl->render_quad(r, color, matrix); + r->impl->render_quad_with_matrix(r, color, matrix); +} + +void wlr_render_ellipse(struct wlr_renderer *r, const struct wlr_box *box, + const float color[static 4], const float projection[static 9]) { + float matrix[9]; + wlr_matrix_project_box(matrix, box, WL_OUTPUT_TRANSFORM_NORMAL, 0, + projection); + + wlr_render_ellipse_with_matrix(r, color, matrix); } -void wlr_render_colored_ellipse(struct wlr_renderer *r, +void wlr_render_ellipse_with_matrix(struct wlr_renderer *r, const float color[static 4], const float matrix[static 9]) { - r->impl->render_ellipse(r, color, matrix); + r->impl->render_ellipse_with_matrix(r, color, matrix); } const enum wl_shm_format *wlr_renderer_get_formats( diff --git a/rootston/output.c b/rootston/output.c index 1284c928..c75935af 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -363,7 +363,7 @@ static void render_decorations(struct roots_view *view, pixman_region32_rectangles(&damage, &nrects); for (int i = 0; i < nrects; ++i) { scissor_output(output, &rects[i]); - wlr_render_colored_quad(renderer, color, matrix); + wlr_render_quad_with_matrix(renderer, color, matrix); } damage_finish: -- cgit v1.2.3 From c42fd1018b037f20c5045fb3cbf39ac35ec980c6 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 27 Mar 2018 17:02:48 -0400 Subject: render: remove GL calls from wlr_egl --- include/render/gles2.h | 1 + include/wlr/render/egl.h | 3 +-- render/egl.c | 23 +++++++++-------------- render/gles2/renderer.c | 5 +++++ 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include/wlr/render') diff --git a/include/render/gles2.h b/include/render/gles2.h index 43a8d648..33ad9a48 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -28,6 +28,7 @@ struct wlr_gles2_renderer { struct wlr_renderer wlr_renderer; struct wlr_egl *egl; + const char *exts_str; struct { GLuint quad; diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index aa429e8e..9f4c0334 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -13,8 +13,7 @@ struct wlr_egl { EGLConfig config; EGLContext context; - const char *egl_exts_str; - const char *gl_exts_str; + const char *exts_str; struct { bool buffer_age; diff --git a/render/egl.c b/render/egl.c index e582b6d3..f2966774 100644 --- a/render/egl.c +++ b/render/egl.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -155,32 +154,28 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, } eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl->context); - egl->egl_exts_str = eglQueryString(egl->display, EGL_EXTENSIONS); - egl->gl_exts_str = (const char*) glGetString(GL_EXTENSIONS); + egl->exts_str = eglQueryString(egl->display, EGL_EXTENSIONS); wlr_log(L_INFO, "Using EGL %d.%d", (int)major, (int)minor); - wlr_log(L_INFO, "Supported EGL extensions: %s", egl->egl_exts_str); + wlr_log(L_INFO, "Supported EGL extensions: %s", egl->exts_str); wlr_log(L_INFO, "EGL vendor: %s", eglQueryString(egl->display, EGL_VENDOR)); - wlr_log(L_INFO, "Using %s", glGetString(GL_VERSION)); - wlr_log(L_INFO, "GL vendor: %s", glGetString(GL_VENDOR)); - wlr_log(L_INFO, "Supported OpenGL ES extensions: %s", egl->gl_exts_str); - if (!check_egl_ext(egl->egl_exts_str, "EGL_WL_bind_wayland_display") || - !check_egl_ext(egl->egl_exts_str, "EGL_KHR_image_base")) { + if (!check_egl_ext(egl->exts_str, "EGL_WL_bind_wayland_display") || + !check_egl_ext(egl->exts_str, "EGL_KHR_image_base")) { wlr_log(L_ERROR, "Required egl extensions not supported"); goto error; } egl->egl_exts.buffer_age = - check_egl_ext(egl->egl_exts_str, "EGL_EXT_buffer_age"); + check_egl_ext(egl->exts_str, "EGL_EXT_buffer_age"); egl->egl_exts.swap_buffers_with_damage = - check_egl_ext(egl->egl_exts_str, "EGL_EXT_swap_buffers_with_damage") || - check_egl_ext(egl->egl_exts_str, "EGL_KHR_swap_buffers_with_damage"); + check_egl_ext(egl->exts_str, "EGL_EXT_swap_buffers_with_damage") || + check_egl_ext(egl->exts_str, "EGL_KHR_swap_buffers_with_damage"); egl->egl_exts.dmabuf_import = - check_egl_ext(egl->egl_exts_str, "EGL_EXT_image_dma_buf_import"); + check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import"); egl->egl_exts.dmabuf_import_modifiers = - check_egl_ext(egl->egl_exts_str, "EGL_EXT_image_dma_buf_import_modifiers") + check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import_modifiers") && eglQueryDmaBufFormatsEXT && eglQueryDmaBufModifiersEXT; print_dmabuf_formats(egl); diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 61665a07..36a62aa7 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -377,6 +377,11 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) { renderer->egl = wlr_backend_get_egl(backend); wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL); + renderer->exts_str = (const char*) glGetString(GL_EXTENSIONS); + wlr_log(L_INFO, "Using %s", glGetString(GL_VERSION)); + wlr_log(L_INFO, "GL vendor: %s", glGetString(GL_VENDOR)); + wlr_log(L_INFO, "Supported GLES2 extensions: %s", renderer->exts_str); + if (glDebugMessageCallbackKHR && glDebugMessageControlKHR) { glEnable(GL_DEBUG_OUTPUT_KHR); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR); -- cgit v1.2.3 From 13edb19a6ca89da3fcbafd3be01d89251658178d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 27 Mar 2018 15:49:44 -0400 Subject: Fix issue starting up client EGL on X11 backend --- examples/layer-shell.c | 1 - include/wlr/render/egl.h | 1 + render/egl.c | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include/wlr/render') diff --git a/examples/layer-shell.c b/examples/layer-shell.c index e559121e..70407888 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -247,7 +247,6 @@ int main(int argc, char **argv) { struct wl_registry *registry = wl_display_get_registry(display); wl_registry_add_listener(registry, ®istry_listener, NULL); - wl_display_dispatch(display); wl_display_roundtrip(display); if (compositor == NULL) { diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 9f4c0334..b5f2d67c 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -20,6 +20,7 @@ struct wlr_egl { bool swap_buffers_with_damage; bool dmabuf_import; bool dmabuf_import_modifiers; + bool bind_wayland_display; } egl_exts; struct wl_display *wl_display; diff --git a/render/egl.c b/render/egl.c index 315eb098..7201ac9f 100644 --- a/render/egl.c +++ b/render/egl.c @@ -160,8 +160,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, wlr_log(L_INFO, "Supported EGL extensions: %s", egl->exts_str); wlr_log(L_INFO, "EGL vendor: %s", eglQueryString(egl->display, EGL_VENDOR)); - if (!check_egl_ext(egl->exts_str, "EGL_WL_bind_wayland_display") || - !check_egl_ext(egl->exts_str, "EGL_KHR_image_base")) { + if (!check_egl_ext(egl->exts_str, "EGL_KHR_image_base")) { wlr_log(L_ERROR, "Required egl extensions not supported"); goto error; } @@ -177,6 +176,9 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, egl->egl_exts.dmabuf_import_modifiers = check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import_modifiers") && eglQueryDmaBufFormatsEXT && eglQueryDmaBufModifiersEXT; + + egl->egl_exts.bind_wayland_display = + check_egl_ext(egl->exts_str, "EGL_WL_bind_wayland_display"); print_dmabuf_formats(egl); return true; -- cgit v1.2.3