Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 453353a221de9c64479f4372565d2cd8591b36cc Mon Sep 17 00:00:00 2001 |
| 2 | From: Frank Binns <frank.binns@imgtec.com> |
| 3 | Date: Fri, 29 Jun 2012 11:26:04 +0100 |
| 4 | Subject: [PATCH 5/9] Fix build when EGL_MESA_screen_surface extension isn't |
| 5 | present |
| 6 | |
| 7 | The EGL demos won't build against EGL implementations that don't support |
| 8 | the EGL_MESA_screen_surface extension. Fix this, in most cases, by |
| 9 | wrapping relevant bits of code in #ifdef EGL_MESA_screen_surface. |
| 10 | |
| 11 | Signed-off-by: Frank Binns <frank.binns@imgtec.com> |
| 12 | |
| 13 | Applied and fixed up in Yocto by... |
| 14 | |
| 15 | Integrated-by: Tom Zanussi <tom.zanussi@linux.intel.com> |
| 16 | |
| 17 | Upstream-Status: Pending |
| 18 | --- |
| 19 | src/egl/eglut/eglut.c | 9 +++++++-- |
| 20 | src/egl/eglut/eglut_screen.c | 14 ++++++++++++++ |
| 21 | src/egl/opengl/demo1.c | 2 ++ |
| 22 | src/egl/opengl/demo2.c | 7 ++++++- |
| 23 | src/egl/opengl/demo3.c | 7 ++++++- |
| 24 | 5 files changed, 35 insertions(+), 4 deletions(-) |
| 25 | |
| 26 | diff --git a/src/egl/eglut/eglut.c b/src/egl/eglut/eglut.c |
| 27 | index 2ee6f15..f6a2ad4 100644 |
| 28 | --- a/src/egl/eglut/eglut.c |
| 29 | +++ b/src/egl/eglut/eglut.c |
| 30 | @@ -76,8 +76,9 @@ _eglutNow(void) |
| 31 | static void |
| 32 | _eglutDestroyWindow(struct eglut_window *win) |
| 33 | { |
| 34 | - if (_eglut->surface_type != EGL_PBUFFER_BIT && |
| 35 | - _eglut->surface_type != EGL_SCREEN_BIT_MESA) |
| 36 | + |
| 37 | + if (_eglut->surface_type == EGL_WINDOW_BIT || |
| 38 | + _eglut->surface_type == EGL_PIXMAP_BIT) |
| 39 | eglDestroySurface(_eglut->dpy, win->surface); |
| 40 | |
| 41 | _eglutNativeFiniWindow(win); |
| 42 | @@ -175,7 +176,9 @@ _eglutCreateWindow(const char *title, int x, int y, int w, int h) |
| 43 | win->config, win->native.u.pixmap, NULL); |
| 44 | break; |
| 45 | case EGL_PBUFFER_BIT: |
| 46 | +#ifdef EGL_MESA_screen_surface |
| 47 | case EGL_SCREEN_BIT_MESA: |
| 48 | +#endif |
| 49 | win->surface = win->native.u.surface; |
| 50 | break; |
| 51 | default: |
| 52 | @@ -289,8 +292,10 @@ eglutDestroyWindow(int win) |
| 53 | if (window->index != win) |
| 54 | return; |
| 55 | |
| 56 | +#ifdef EGL_MESA_screen_surface |
| 57 | /* XXX it causes some bug in st/egl KMS backend */ |
| 58 | if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA) |
| 59 | +#endif |
| 60 | eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
| 61 | |
| 62 | _eglutDestroyWindow(_eglut->current); |
| 63 | diff --git a/src/egl/eglut/eglut_screen.c b/src/egl/eglut/eglut_screen.c |
| 64 | index 021a8f1..094a4e2 100644 |
| 65 | --- a/src/egl/eglut/eglut_screen.c |
| 66 | +++ b/src/egl/eglut/eglut_screen.c |
| 67 | @@ -35,26 +35,33 @@ |
| 68 | |
| 69 | #define MAX_MODES 100 |
| 70 | |
| 71 | +#ifdef EGL_MESA_screen_surface |
| 72 | static EGLScreenMESA kms_screen; |
| 73 | static EGLModeMESA kms_mode; |
| 74 | static EGLint kms_width, kms_height; |
| 75 | +#endif |
| 76 | |
| 77 | void |
| 78 | _eglutNativeInitDisplay(void) |
| 79 | { |
| 80 | +#ifdef EGL_MESA_screen_surface |
| 81 | _eglut->native_dpy = EGL_DEFAULT_DISPLAY; |
| 82 | _eglut->surface_type = EGL_SCREEN_BIT_MESA; |
| 83 | +#endif |
| 84 | } |
| 85 | |
| 86 | void |
| 87 | _eglutNativeFiniDisplay(void) |
| 88 | { |
| 89 | +#ifdef EGL_MESA_screen_surface |
| 90 | kms_screen = 0; |
| 91 | kms_mode = 0; |
| 92 | kms_width = 0; |
| 93 | kms_height = 0; |
| 94 | +#endif |
| 95 | } |
| 96 | |
| 97 | +#ifdef EGL_MESA_screen_surface |
| 98 | static void |
| 99 | init_kms(void) |
| 100 | { |
| 101 | @@ -94,19 +101,23 @@ init_kms(void) |
| 102 | kms_width = width; |
| 103 | kms_height = height; |
| 104 | } |
| 105 | +#endif |
| 106 | |
| 107 | void |
| 108 | _eglutNativeInitWindow(struct eglut_window *win, const char *title, |
| 109 | int x, int y, int w, int h) |
| 110 | { |
| 111 | +#ifdef EGL_MESA_screen_surface |
| 112 | EGLint surf_attribs[16]; |
| 113 | EGLint i; |
| 114 | +#endif |
| 115 | const char *exts; |
| 116 | |
| 117 | exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS); |
| 118 | if (!exts || !strstr(exts, "EGL_MESA_screen_surface")) |
| 119 | _eglutFatal("EGL_MESA_screen_surface is not supported\n"); |
| 120 | |
| 121 | +#ifdef EGL_MESA_screen_surface |
| 122 | init_kms(); |
| 123 | |
| 124 | i = 0; |
| 125 | @@ -128,14 +139,17 @@ _eglutNativeInitWindow(struct eglut_window *win, const char *title, |
| 126 | |
| 127 | win->native.width = kms_width; |
| 128 | win->native.height = kms_height; |
| 129 | +#endif |
| 130 | } |
| 131 | |
| 132 | void |
| 133 | _eglutNativeFiniWindow(struct eglut_window *win) |
| 134 | { |
| 135 | +#ifdef EGL_MESA_screen_surface |
| 136 | eglShowScreenSurfaceMESA(_eglut->dpy, |
| 137 | kms_screen, EGL_NO_SURFACE, 0); |
| 138 | eglDestroySurface(_eglut->dpy, win->native.u.surface); |
| 139 | +#endif |
| 140 | } |
| 141 | |
| 142 | void |
| 143 | diff --git a/src/egl/opengl/demo1.c b/src/egl/opengl/demo1.c |
| 144 | index d892734..3a3564c 100644 |
| 145 | --- a/src/egl/opengl/demo1.c |
| 146 | +++ b/src/egl/opengl/demo1.c |
| 147 | @@ -18,6 +18,7 @@ |
| 148 | static void |
| 149 | TestScreens(EGLDisplay dpy) |
| 150 | { |
| 151 | +#ifdef EGL_MESA_screen_surface |
| 152 | #define MAX 8 |
| 153 | EGLScreenMESA screens[MAX]; |
| 154 | EGLint numScreens; |
| 155 | @@ -28,6 +29,7 @@ TestScreens(EGLDisplay dpy) |
| 156 | for (i = 0; i < numScreens; i++) { |
| 157 | printf(" Screen %d handle: %d\n", i, (int) screens[i]); |
| 158 | } |
| 159 | +#endif |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | diff --git a/src/egl/opengl/demo2.c b/src/egl/opengl/demo2.c |
| 164 | index 505b474..bfef59e 100644 |
| 165 | --- a/src/egl/opengl/demo2.c |
| 166 | +++ b/src/egl/opengl/demo2.c |
| 167 | @@ -16,6 +16,7 @@ |
| 168 | |
| 169 | /*#define FRONTBUFFER*/ |
| 170 | |
| 171 | +#ifdef EGL_MESA_screen_surface |
| 172 | static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, |
| 173 | GLfloat r, GLfloat g, GLfloat b) |
| 174 | { |
| 175 | @@ -95,12 +96,13 @@ TestScreens(EGLDisplay dpy) |
| 176 | printf(" Screen %d handle: %d\n", i, (int) screens[i]); |
| 177 | } |
| 178 | } |
| 179 | - |
| 180 | +#endif |
| 181 | |
| 182 | int |
| 183 | main(int argc, char *argv[]) |
| 184 | { |
| 185 | int maj, min; |
| 186 | +#ifdef EGL_MESA_screen_surface |
| 187 | EGLContext ctx; |
| 188 | EGLSurface pbuffer, screen_surf; |
| 189 | EGLConfig configs[10]; |
| 190 | @@ -115,6 +117,7 @@ main(int argc, char *argv[]) |
| 191 | EGLModeMESA mode; |
| 192 | EGLScreenMESA screen; |
| 193 | EGLint count; |
| 194 | +#endif |
| 195 | |
| 196 | EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
| 197 | assert(d); |
| 198 | @@ -132,6 +135,7 @@ main(int argc, char *argv[]) |
| 199 | exit(1); |
| 200 | } |
| 201 | |
| 202 | +#ifdef EGL_MESA_screen_surface |
| 203 | eglGetConfigs(d, configs, 10, &numConfigs); |
| 204 | printf("Got %d EGL configs:\n", numConfigs); |
| 205 | for (i = 0; i < numConfigs; i++) { |
| 206 | @@ -211,6 +215,7 @@ main(int argc, char *argv[]) |
| 207 | eglDestroySurface(d, pbuffer); |
| 208 | eglDestroyContext(d, ctx); |
| 209 | eglTerminate(d); |
| 210 | +#endif |
| 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | diff --git a/src/egl/opengl/demo3.c b/src/egl/opengl/demo3.c |
| 215 | index f84ca23..31b5d8b 100644 |
| 216 | --- a/src/egl/opengl/demo3.c |
| 217 | +++ b/src/egl/opengl/demo3.c |
| 218 | @@ -46,7 +46,7 @@ GLubyte OpenGL_bits[] = { |
| 219 | 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00, |
| 220 | }; |
| 221 | |
| 222 | - |
| 223 | +#ifdef EGL_MESA_screen_surface |
| 224 | static void Init(void) |
| 225 | { |
| 226 | |
| 227 | @@ -551,11 +551,13 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height) |
| 228 | fclose(f); |
| 229 | } |
| 230 | } |
| 231 | +#endif |
| 232 | |
| 233 | int |
| 234 | main(int argc, char *argv[]) |
| 235 | { |
| 236 | int maj, min; |
| 237 | +#ifdef EGL_MESA_screen_surface |
| 238 | EGLContext ctx; |
| 239 | EGLSurface screen_surf; |
| 240 | EGLConfig configs[10]; |
| 241 | @@ -566,6 +568,7 @@ main(int argc, char *argv[]) |
| 242 | const GLubyte *bitmap; |
| 243 | EGLint screenAttribs[32]; |
| 244 | EGLint i; |
| 245 | +#endif |
| 246 | |
| 247 | EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
| 248 | assert(d); |
| 249 | @@ -583,6 +586,7 @@ main(int argc, char *argv[]) |
| 250 | exit(1); |
| 251 | } |
| 252 | |
| 253 | +#ifdef EGL_MESA_screen_surface |
| 254 | eglGetConfigs(d, configs, 10, &numConfigs); |
| 255 | eglGetScreensMESA(d, &screen, 1, &count); |
| 256 | eglGetModesMESA(d, screen, &mode, 1, &count); |
| 257 | @@ -642,6 +646,7 @@ main(int argc, char *argv[]) |
| 258 | eglDestroySurface(d, screen_surf); |
| 259 | eglDestroyContext(d, ctx); |
| 260 | eglTerminate(d); |
| 261 | +#endif |
| 262 | |
| 263 | return 0; |
| 264 | } |
| 265 | -- |
| 266 | 2.0.0 |
| 267 | |