d3709293025cae88c1213b379aa0a3f1368bc5e2
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / mesa3d-demos / 0001-demos-non-mesa-impl.patch
1 This makes it possible to build the demos against opengl
2 implementations other than Mesa 
3
4 Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
5 ---
6 Index: mesa3d-demos-8.1.0/src/egl/eglut/eglut.c
7 ===================================================================
8 --- mesa3d-demos-8.1.0.orig/src/egl/eglut/eglut.c
9 +++ mesa3d-demos-8.1.0/src/egl/eglut/eglut.c
10 @@ -76,8 +76,9 @@ _eglutNow(void)
11  static void
12  _eglutDestroyWindow(struct eglut_window *win)
13  {
14 -   if (_eglut->surface_type != EGL_PBUFFER_BIT &&
15 -       _eglut->surface_type != EGL_SCREEN_BIT_MESA)
16 +
17 +   if (_eglut->surface_type == EGL_WINDOW_BIT ||
18 +       _eglut->surface_type == EGL_PIXMAP_BIT)
19        eglDestroySurface(_eglut->dpy, win->surface);
20  
21     _eglutNativeFiniWindow(win);
22 @@ -175,7 +176,9 @@ _eglutCreateWindow(const char *title, in
23              win->config, win->native.u.pixmap, NULL);
24        break;
25     case EGL_PBUFFER_BIT:
26 +#ifdef EGL_MESA_screen_surface
27     case EGL_SCREEN_BIT_MESA:
28 +#endif
29        win->surface = win->native.u.surface;
30        break;
31     default:
32 @@ -289,8 +292,10 @@ eglutDestroyWindow(int win)
33     if (window->index != win)
34        return;
35  
36 +#ifdef EGL_MESA_screen_surface
37     /* XXX it causes some bug in st/egl KMS backend */
38     if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA)
39 +#endif
40        eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
41  
42     _eglutDestroyWindow(_eglut->current);
43 Index: mesa3d-demos-8.1.0/src/egl/eglut/eglut_screen.c
44 ===================================================================
45 --- mesa3d-demos-8.1.0.orig/src/egl/eglut/eglut_screen.c
46 +++ mesa3d-demos-8.1.0/src/egl/eglut/eglut_screen.c
47 @@ -35,26 +35,33 @@
48  
49  #define MAX_MODES 100
50  
51 +#ifdef EGL_MESA_screen_surface
52  static EGLScreenMESA kms_screen;
53  static EGLModeMESA kms_mode;
54  static EGLint kms_width, kms_height;
55 +#endif
56  
57  void
58  _eglutNativeInitDisplay(void)
59  {
60 +#ifdef EGL_MESA_screen_surface
61     _eglut->native_dpy = EGL_DEFAULT_DISPLAY;
62     _eglut->surface_type = EGL_SCREEN_BIT_MESA;
63 +#endif
64  }
65  
66  void
67  _eglutNativeFiniDisplay(void)
68  {
69 +#ifdef EGL_MESA_screen_surface
70     kms_screen = 0;
71     kms_mode = 0;
72     kms_width = 0;
73     kms_height = 0;
74 +#endif
75  }
76  
77 +#ifdef EGL_MESA_screen_surface
78  static void
79  init_kms(void)
80  {
81 @@ -94,19 +101,23 @@ init_kms(void)
82     kms_width = width;
83     kms_height = height;
84  }
85 +#endif
86  
87  void
88  _eglutNativeInitWindow(struct eglut_window *win, const char *title,
89                         int x, int y, int w, int h)
90  {
91 +#ifdef EGL_MESA_screen_surface
92     EGLint surf_attribs[16];
93     EGLint i;
94 +#endif
95     const char *exts;
96  
97     exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS);
98     if (!exts || !strstr(exts, "EGL_MESA_screen_surface"))
99        _eglutFatal("EGL_MESA_screen_surface is not supported\n");
100  
101 +#ifdef EGL_MESA_screen_surface
102     init_kms();
103  
104     i = 0;
105 @@ -128,14 +139,17 @@ _eglutNativeInitWindow(struct eglut_wind
106  
107     win->native.width = kms_width;
108     win->native.height = kms_height;
109 +#endif
110  }
111  
112  void
113  _eglutNativeFiniWindow(struct eglut_window *win)
114  {
115 +#ifdef EGL_MESA_screen_surface
116     eglShowScreenSurfaceMESA(_eglut->dpy,
117           kms_screen, EGL_NO_SURFACE, 0);
118     eglDestroySurface(_eglut->dpy, win->native.u.surface);
119 +#endif
120  }
121  
122  void
123 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo1.c
124 ===================================================================
125 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo1.c
126 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo1.c
127 @@ -18,6 +18,7 @@
128  static void
129  TestScreens(EGLDisplay dpy)
130  {
131 +#ifdef EGL_MESA_screen_surface
132  #define MAX 8
133     EGLScreenMESA screens[MAX];
134     EGLint numScreens;
135 @@ -28,6 +29,7 @@ TestScreens(EGLDisplay dpy)
136     for (i = 0; i < numScreens; i++) {
137        printf(" Screen %d handle: %d\n", i, (int) screens[i]);
138     }
139 +#endif
140  }
141  
142  /**
143 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo2.c
144 ===================================================================
145 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo2.c
146 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo2.c
147 @@ -16,6 +16,7 @@
148  
149  /*#define FRONTBUFFER*/
150  
151 +#ifdef EGL_MESA_screen_surface
152  static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
153                            GLfloat r, GLfloat g, GLfloat b)
154  {
155 @@ -95,12 +96,13 @@ TestScreens(EGLDisplay dpy)
156        printf(" Screen %d handle: %d\n", i, (int) screens[i]);
157     }
158  }
159 -
160 +#endif
161  
162  int
163  main(int argc, char *argv[])
164  {
165     int maj, min;
166 +#ifdef EGL_MESA_screen_surface
167     EGLContext ctx;
168     EGLSurface pbuffer, screen_surf;
169     EGLConfig configs[10];
170 @@ -115,6 +117,7 @@ main(int argc, char *argv[])
171     EGLModeMESA mode;
172     EGLScreenMESA screen;
173     EGLint count;
174 +#endif
175  
176     EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
177     assert(d);
178 @@ -132,6 +135,7 @@ main(int argc, char *argv[])
179        exit(1);
180     }
181  
182 +#ifdef EGL_MESA_screen_surface
183     eglGetConfigs(d, configs, 10, &numConfigs);
184     printf("Got %d EGL configs:\n", numConfigs);
185     for (i = 0; i < numConfigs; i++) {
186 @@ -211,6 +215,7 @@ main(int argc, char *argv[])
187     eglDestroySurface(d, pbuffer);
188     eglDestroyContext(d, ctx);
189     eglTerminate(d);
190 +#endif
191  
192     return 0;
193  }
194 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo3.c
195 ===================================================================
196 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo3.c
197 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo3.c
198 @@ -46,7 +46,7 @@ GLubyte OpenGL_bits[] = {
199     0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00, 
200  };
201  
202 -
203 +#ifdef EGL_MESA_screen_surface
204  static void Init(void)
205  {
206  
207 @@ -551,11 +551,13 @@ write_ppm(const char *filename, const GL
208        fclose(f);
209     }
210  }
211 +#endif
212  
213  int
214  main(int argc, char *argv[])
215  {
216     int maj, min;
217 +#ifdef EGL_MESA_screen_surface
218     EGLContext ctx;
219     EGLSurface screen_surf;
220     EGLConfig configs[10];
221 @@ -566,6 +568,7 @@ main(int argc, char *argv[])
222     const GLubyte *bitmap;
223     EGLint screenAttribs[32];
224     EGLint i;
225 +#endif
226  
227     EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
228     assert(d);
229 @@ -583,6 +586,7 @@ main(int argc, char *argv[])
230        exit(1);
231     }
232  
233 +#ifdef EGL_MESA_screen_surface
234     eglGetConfigs(d, configs, 10, &numConfigs);
235     eglGetScreensMESA(d, &screen, 1, &count);
236     eglGetModesMESA(d, screen, &mode, 1, &count);
237 @@ -642,6 +646,7 @@ main(int argc, char *argv[])
238     eglDestroySurface(d, screen_surf);
239     eglDestroyContext(d, ctx);
240     eglTerminate(d);
241 +#endif
242  
243     return 0;
244  }