summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/mesa/mesa-demos/egl-mesa-screen-surface-build-fix.patch
blob: 46a3e98cfe71f910dce23b60d84880324fa8593a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
From ab76f645e29b0a603ff95d88f976bc35ab6301ee Mon Sep 17 00:00:00 2001
From: Frank Binns <frank.binns@imgtec.com>
Date: Fri, 29 Jun 2012 11:26:04 +0100
Subject: [PATCH 1/2] mesa-demos: Fix build when EGL_MESA_screen_surface
 extension isn't present

The EGL demos won't build against EGL implementations that don't support 
the EGL_MESA_screen_surface extension. Fix this, in most cases, by 
wrapping relevant bits of code in #ifdef EGL_MESA_screen_surface.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>

Applied and fixed up in Yocto by...

Integrated-by: Tom Zanussi <tom.zanussi@linux.intel.com>

Upstream-Status: Pending

Index: mesa-demos-8.0.1/src/egl/eglut/eglut.c
===================================================================
--- mesa-demos-8.0.1.orig/src/egl/eglut/eglut.c
+++ mesa-demos-8.0.1/src/egl/eglut/eglut.c
@@ -51,8 +51,9 @@ _eglutNow(void)
 static void
 _eglutDestroyWindow(struct eglut_window *win)
 {
-   if (_eglut->surface_type != EGL_PBUFFER_BIT &&
-       _eglut->surface_type != EGL_SCREEN_BIT_MESA)
+
+   if (_eglut->surface_type == EGL_WINDOW_BIT ||
+       _eglut->surface_type == EGL_PIXMAP_BIT)
       eglDestroySurface(_eglut->dpy, win->surface);
 
    _eglutNativeFiniWindow(win);
@@ -150,7 +151,9 @@ _eglutCreateWindow(const char *title, in
             win->config, win->native.u.pixmap, NULL);
       break;
    case EGL_PBUFFER_BIT:
+#ifdef EGL_MESA_screen_surface
    case EGL_SCREEN_BIT_MESA:
+#endif
       win->surface = win->native.u.surface;
       break;
    default:
@@ -264,8 +267,10 @@ eglutDestroyWindow(int win)
    if (window->index != win)
       return;
 
+#ifdef EGL_MESA_screen_surface
    /* XXX it causes some bug in st/egl KMS backend */
    if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA)
+#endif
       eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
    _eglutDestroyWindow(_eglut->current);
Index: mesa-demos-8.0.1/src/egl/eglut/eglut_screen.c
===================================================================
--- mesa-demos-8.0.1.orig/src/egl/eglut/eglut_screen.c
+++ mesa-demos-8.0.1/src/egl/eglut/eglut_screen.c
@@ -10,26 +10,33 @@
 
 #define MAX_MODES 100
 
+#ifdef EGL_MESA_screen_surface
 static EGLScreenMESA kms_screen;
 static EGLModeMESA kms_mode;
 static EGLint kms_width, kms_height;
+#endif
 
 void
 _eglutNativeInitDisplay(void)
 {
+#ifdef EGL_MESA_screen_surface
    _eglut->native_dpy = EGL_DEFAULT_DISPLAY;
    _eglut->surface_type = EGL_SCREEN_BIT_MESA;
+#endif
 }
 
 void
 _eglutNativeFiniDisplay(void)
 {
+#ifdef EGL_MESA_screen_surface
    kms_screen = 0;
    kms_mode = 0;
    kms_width = 0;
    kms_height = 0;
+#endif
 }
 
+#ifdef EGL_MESA_screen_surface
 static void
 init_kms(void)
 {
@@ -69,19 +76,23 @@ init_kms(void)
    kms_width = width;
    kms_height = height;
 }
+#endif
 
 void
 _eglutNativeInitWindow(struct eglut_window *win, const char *title,
                        int x, int y, int w, int h)
 {
+#ifdef EGL_MESA_screen_surface
    EGLint surf_attribs[16];
    EGLint i;
+#endif
    const char *exts;
 
    exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS);
    if (!exts || !strstr(exts, "EGL_MESA_screen_surface"))
       _eglutFatal("EGL_MESA_screen_surface is not supported\n");
 
+#ifdef EGL_MESA_screen_surface
    init_kms();
 
    i = 0;
@@ -103,14 +114,17 @@ _eglutNativeInitWindow(struct eglut_wind
 
    win->native.width = kms_width;
    win->native.height = kms_height;
+#endif
 }
 
 void
 _eglutNativeFiniWindow(struct eglut_window *win)
 {
+#ifdef EGL_MESA_screen_surface
    eglShowScreenSurfaceMESA(_eglut->dpy,
          kms_screen, EGL_NO_SURFACE, 0);
    eglDestroySurface(_eglut->dpy, win->native.u.surface);
+#endif
 }
 
 void
Index: mesa-demos-8.0.1/src/egl/opengl/demo1.c
===================================================================
--- mesa-demos-8.0.1.orig/src/egl/opengl/demo1.c
+++ mesa-demos-8.0.1/src/egl/opengl/demo1.c
@@ -18,6 +18,7 @@
 static void
 TestScreens(EGLDisplay dpy)
 {
+#ifdef EGL_MESA_screen_surface
 #define MAX 8
    EGLScreenMESA screens[MAX];
    EGLint numScreens;
@@ -28,6 +29,7 @@ TestScreens(EGLDisplay dpy)
    for (i = 0; i < numScreens; i++) {
       printf(" Screen %d handle: %d\n", i, (int) screens[i]);
    }
+#endif
 }
 
 /**
Index: mesa-demos-8.0.1/src/egl/opengl/demo2.c
===================================================================
--- mesa-demos-8.0.1.orig/src/egl/opengl/demo2.c
+++ mesa-demos-8.0.1/src/egl/opengl/demo2.c
@@ -16,6 +16,7 @@
 
 /*#define FRONTBUFFER*/
 
+#ifdef EGL_MESA_screen_surface
 static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
                           GLfloat r, GLfloat g, GLfloat b)
 {
@@ -95,12 +96,13 @@ TestScreens(EGLDisplay dpy)
       printf(" Screen %d handle: %d\n", i, (int) screens[i]);
    }
 }
-
+#endif
 
 int
 main(int argc, char *argv[])
 {
    int maj, min;
+#ifdef EGL_MESA_screen_surface
    EGLContext ctx;
    EGLSurface pbuffer, screen_surf;
    EGLConfig configs[10];
@@ -115,6 +117,7 @@ main(int argc, char *argv[])
    EGLModeMESA mode;
    EGLScreenMESA screen;
    EGLint count;
+#endif
 
    EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    assert(d);
@@ -132,6 +135,7 @@ main(int argc, char *argv[])
       exit(1);
    }
 
+#ifdef EGL_MESA_screen_surface
    eglGetConfigs(d, configs, 10, &numConfigs);
    printf("Got %d EGL configs:\n", numConfigs);
    for (i = 0; i < numConfigs; i++) {
@@ -211,6 +215,7 @@ main(int argc, char *argv[])
    eglDestroySurface(d, pbuffer);
    eglDestroyContext(d, ctx);
    eglTerminate(d);
+#endif
 
    return 0;
 }
Index: mesa-demos-8.0.1/src/egl/opengl/demo3.c
===================================================================
--- mesa-demos-8.0.1.orig/src/egl/opengl/demo3.c
+++ mesa-demos-8.0.1/src/egl/opengl/demo3.c
@@ -46,7 +46,7 @@ GLubyte OpenGL_bits[] = {
    0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00, 
 };
 
-
+#ifdef EGL_MESA_screen_surface
 static void Init(void)
 {
 
@@ -551,11 +551,13 @@ write_ppm(const char *filename, const GL
       fclose(f);
    }
 }
+#endif
 
 int
 main(int argc, char *argv[])
 {
    int maj, min;
+#ifdef EGL_MESA_screen_surface
    EGLContext ctx;
    EGLSurface screen_surf;
    EGLConfig configs[10];
@@ -566,6 +568,7 @@ main(int argc, char *argv[])
    const GLubyte *bitmap;
    EGLint screenAttribs[32];
    EGLint i;
+#endif
 
    EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    assert(d);
@@ -583,6 +586,7 @@ main(int argc, char *argv[])
       exit(1);
    }
 
+#ifdef EGL_MESA_screen_surface
    eglGetConfigs(d, configs, 10, &numConfigs);
    eglGetScreensMESA(d, &screen, 1, &count);
    eglGetModesMESA(d, screen, &mode, 1, &count);
@@ -642,6 +646,7 @@ main(int argc, char *argv[])
    eglDestroySurface(d, screen_surf);
    eglDestroyContext(d, ctx);
    eglTerminate(d);
+#endif
 
    return 0;
 }