blob: d7d411f6331b0ff6afabf473bfe5e5a69e04b19a [file] [log] [blame]
Andrew Geissler84ad7c52020-06-27 00:00:16 -05001From 7cc76d50bddd6ff1eb5fb19712415f385f5d3f49 Mon Sep 17 00:00:00 2001
2From: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
3Date: Mon, 3 Feb 2020 14:26:21 -0800
4Subject: [PATCH] gl-renderer.c: Use gr->egl_config to create pbuffer surface
5
6The original implementation always chose first egl config for pbuffer
7surface type, however the returned configs are implementation specific
8and egl config may not always match between ctx and surface. Hence,
9use gr->egl_config which already has the matching config but ensure that
10windows and pbuffer bit are set for the surface type.
11
12Signed-off-by: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
13Upstream-status: Pending
14---
15 libweston/renderer-gl/gl-renderer.c | 28 ++++++++++++++--------------
16 1 file changed, 14 insertions(+), 14 deletions(-)
17
18diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
19index 54f8b1c..f50c959 100644
20--- a/libweston/renderer-gl/gl-renderer.c
21+++ b/libweston/renderer-gl/gl-renderer.c
22@@ -3567,7 +3567,7 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
23 }
24
25 static const EGLint gl_renderer_opaque_attribs[] = {
26- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
27+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
28 EGL_RED_SIZE, 1,
29 EGL_GREEN_SIZE, 1,
30 EGL_BLUE_SIZE, 1,
31@@ -3577,7 +3577,7 @@ static const EGLint gl_renderer_opaque_attribs[] = {
32 };
33
34 static const EGLint gl_renderer_alpha_attribs[] = {
35- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
36+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
37 EGL_RED_SIZE, 1,
38 EGL_GREEN_SIZE, 1,
39 EGL_BLUE_SIZE, 1,
40@@ -3682,15 +3682,7 @@ static int
41 gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) {
42 EGLConfig pbuffer_config;
43
44- static const EGLint pbuffer_config_attribs[] = {
45- EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
46- EGL_RED_SIZE, 1,
47- EGL_GREEN_SIZE, 1,
48- EGL_BLUE_SIZE, 1,
49- EGL_ALPHA_SIZE, 0,
50- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
51- EGL_NONE
52- };
53+ EGLint surface_type;
54
55 static const EGLint pbuffer_attribs[] = {
56 EGL_WIDTH, 10,
57@@ -3698,13 +3690,21 @@ gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) {
58 EGL_NONE
59 };
60
61- if (egl_choose_config(gr, pbuffer_config_attribs, NULL, 0, &pbuffer_config) < 0) {
62- weston_log("failed to choose EGL config for PbufferSurface\n");
63+ if(!eglGetConfigAttrib(gr->egl_display, gr->egl_config, EGL_SURFACE_TYPE, &surface_type)) {
64+ weston_log("failed to get surface type for PbufferSurface\n");
65+ return -1;
66+ }
67+
68+ if (!((surface_type & EGL_WINDOW_BIT) && (surface_type & EGL_PBUFFER_BIT)) &&
69+ !gr->has_configless_context) {
70+ weston_log("attempted to use a different EGL config for an "
71+ "output but EGL_KHR_no_config_context or "
72+ "EGL_MESA_configless_context is not supported\n");
73 return -1;
74 }
75
76 gr->dummy_surface = eglCreatePbufferSurface(gr->egl_display,
77- pbuffer_config,
78+ gr->egl_config,
79 pbuffer_attribs);
80
81 if (gr->dummy_surface == EGL_NO_SURFACE) {
82--
832.7.4
84