Merge lp:~spenser-gilliland/glmark2/mali-fbdev into lp:glmark2/2011.11

Proposed by Spenser Gilliland
Status: Needs review
Proposed branch: lp:~spenser-gilliland/glmark2/mali-fbdev
Merge into: lp:glmark2/2011.11
Diff against target: 352 lines (+236/-9)
7 files modified
src/gl-state-egl.cpp (+5/-2)
src/libmatrix/program.cc (+2/-0)
src/main.cpp (+4/-0)
src/native-state-fbdev.cpp (+145/-0)
src/native-state-fbdev.h (+64/-0)
src/wscript_build (+10/-5)
wscript (+6/-2)
To merge this branch: bzr merge lp:~spenser-gilliland/glmark2/mali-fbdev
Reviewer Review Type Date Requested Status
Jesse Barker Pending
Review via email: mp+182970@code.launchpad.net

Description of the change

These changes add mali support to glmark2.

To post a comment you must log in.

Unmerged revisions

282. By Spenser Gilliland

add Mali GPU support

281. By Spenser Gilliland

do not require gl if using gles version

280. By Spenser Gilliland

GLchar not defined change to char

279. By Wladimir J. van der Laan

Add fbdev-glesv2 flavor

This exercises Mesa with the EGL 'fbdev' platform.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/gl-state-egl.cpp'
2--- src/gl-state-egl.cpp 2013-03-04 19:07:07 +0000
3+++ src/gl-state-egl.cpp 2013-08-29 17:40:29 +0000
4@@ -414,9 +414,12 @@
5 {
6 if (egl_display_)
7 return true;
8-
9+#ifdef HAS_MALI
10+ egl_display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
11+#else
12 egl_display_ = eglGetDisplay(native_display_);
13- if (!egl_display_) {
14+#endif
15+ if (egl_display_ == EGL_NO_DISPLAY) {
16 Log::error("eglGetDisplay() failed with error: 0x%x\n", eglGetError());
17 return false;
18 }
19
20=== modified file 'src/libmatrix/program.cc'
21--- src/libmatrix/program.cc 2012-04-30 16:31:04 +0000
22+++ src/libmatrix/program.cc 2013-08-29 17:40:29 +0000
23@@ -17,6 +17,8 @@
24 #include "gl-if.h"
25 #include "program.h"
26
27+typedef char GLchar;
28+
29 using std::string;
30 using LibMatrix::mat4;
31 using LibMatrix::mat3;
32
33=== modified file 'src/main.cpp'
34--- src/main.cpp 2013-06-21 18:46:01 +0000
35+++ src/main.cpp 2013-08-29 17:40:29 +0000
36@@ -42,6 +42,8 @@
37 #include "native-state-mir.h"
38 #elif GLMARK2_USE_WAYLAND
39 #include "native-state-wayland.h"
40+#elif GLMARK2_USE_FBDEV
41+#include "native-state-fbdev.h"
42 #endif
43
44 #if GLMARK2_USE_EGL
45@@ -168,6 +170,8 @@
46 NativeStateMir native_state;
47 #elif GLMARK2_USE_WAYLAND
48 NativeStateWayland native_state;
49+#elif GLMARK2_USE_FBDEV
50+ NativeStateFBDEV native_state;
51 #endif
52
53 #if GLMARK2_USE_EGL
54
55=== added file 'src/native-state-fbdev.cpp'
56--- src/native-state-fbdev.cpp 1970-01-01 00:00:00 +0000
57+++ src/native-state-fbdev.cpp 2013-08-29 17:40:29 +0000
58@@ -0,0 +1,145 @@
59+/*
60+ * Copyright © 2012 Linaro Limited
61+ * Copyright © 2013 Canonical Ltd
62+ *
63+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
64+ *
65+ * glmark2 is free software: you can redistribute it and/or modify it under the
66+ * terms of the GNU General Public License as published by the Free Software
67+ * Foundation, either version 3 of the License, or (at your option) any later
68+ * version.
69+ *
70+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
71+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
72+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
73+ * details.
74+ *
75+ * You should have received a copy of the GNU General Public License along with
76+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
77+ *
78+ * Authors:
79+ * Simon Que
80+ * Jesse Barker
81+ * Alexandros Frantzis
82+ * Wladimir J. van der Laan
83+ */
84+#include "native-state-fbdev.h"
85+#include "log.h"
86+#include "util.h"
87+
88+#include <fcntl.h>
89+#include <unistd.h>
90+#include <sys/ioctl.h>
91+#include <linux/fb.h>
92+#if HAS_MALI
93+#include <EGL/egl.h>
94+#endif
95+#ifdef ANDROID
96+#define FBDEV_DEV "/dev/graphics/fb"
97+#else
98+#define FBDEV_DEV "/dev/fb"
99+#endif
100+
101+/******************
102+ * Public methods *
103+ ******************/
104+
105+bool
106+NativeStateFBDEV::init_display()
107+{
108+ if (fd == -1)
109+ return init();
110+ return true;
111+}
112+
113+void*
114+NativeStateFBDEV::display()
115+{
116+ return reinterpret_cast<void*>(fd);
117+}
118+
119+bool
120+NativeStateFBDEV::create_window(WindowProperties const& /*properties*/)
121+{
122+ struct fb_var_screeninfo fb_var;
123+ if (fd == -1) {
124+ Log::error("Error: display has not been initialized!\n");
125+ return false;
126+ }
127+ if (ioctl(fd, FBIOGET_VSCREENINFO, &fb_var))
128+ {
129+ Log::error("Error: cannot get variable frame buffer info\n");
130+ return false;
131+ }
132+ winprops.width = fb_var.xres;
133+ winprops.height = fb_var.yres;
134+ winprops.fullscreen = true;
135+ return true;
136+}
137+
138+void*
139+NativeStateFBDEV::window(WindowProperties& properties)
140+{
141+ properties = winprops;
142+#ifdef HAS_MALI
143+ native_window.height = winprops.height;
144+ native_window.width = winprops.width;
145+ return reinterpret_cast<void*>(&native_window);
146+#else
147+ return NULL;
148+#endif
149+}
150+
151+void
152+NativeStateFBDEV::visible(bool /*visible*/)
153+{
154+}
155+
156+bool
157+NativeStateFBDEV::should_quit()
158+{
159+ return should_quit_;
160+}
161+
162+void
163+NativeStateFBDEV::flip()
164+{
165+}
166+
167+/*******************
168+ * Private methods *
169+ *******************/
170+
171+bool
172+NativeStateFBDEV::init()
173+{
174+ std::string devname;
175+ int num = 0; /* always fb0 for now */
176+
177+ devname = std::string(FBDEV_DEV) + Util::toString(num);
178+ fd = open(devname.c_str(), O_RDWR);
179+ if(fd == -1)
180+ {
181+ Log::error("Error: Cannot open framebuffer device %s\n", devname.c_str());
182+ return false;
183+ }
184+
185+ signal(SIGINT, &NativeStateFBDEV::quit_handler);
186+
187+ return true;
188+}
189+
190+volatile std::sig_atomic_t NativeStateFBDEV::should_quit_(false);
191+
192+void
193+NativeStateFBDEV::quit_handler(int /*signo*/)
194+{
195+ should_quit_ = true;
196+}
197+
198+void
199+NativeStateFBDEV::cleanup()
200+{
201+ close(fd);
202+ fd = -1;
203+}
204
205=== added file 'src/native-state-fbdev.h'
206--- src/native-state-fbdev.h 1970-01-01 00:00:00 +0000
207+++ src/native-state-fbdev.h 2013-08-29 17:40:29 +0000
208@@ -0,0 +1,64 @@
209+/*
210+ * Copyright © 2012 Linaro Limited
211+ * Copyright © 2013 Canonical Ltd
212+ *
213+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
214+ *
215+ * glmark2 is free software: you can redistribute it and/or modify it under the
216+ * terms of the GNU General Public License as published by the Free Software
217+ * Foundation, either version 3 of the License, or (at your option) any later
218+ * version.
219+ *
220+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
221+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
222+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
223+ * details.
224+ *
225+ * You should have received a copy of the GNU General Public License along with
226+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
227+ *
228+ * Authors:
229+ * Simon Que
230+ * Jesse Barker
231+ * Alexandros Frantzis
232+ * Wladimir J. van der Laan
233+ */
234+#ifndef GLMARK2_NATIVE_STATE_FBDEV_H_
235+#define GLMARK2_NATIVE_STATE_FBDEV_H_
236+
237+#include "native-state.h"
238+#include <csignal>
239+#include <cstring>
240+
241+#ifdef HAS_MALI
242+#include <EGL/egl.h>
243+#endif
244+
245+class NativeStateFBDEV : public NativeState
246+{
247+public:
248+ NativeStateFBDEV() :
249+ fd(-1) {}
250+ ~NativeStateFBDEV() { cleanup(); }
251+
252+ bool init_display();
253+ void* display();
254+ bool create_window(WindowProperties const& properties);
255+ void* window(WindowProperties& properties);
256+ void visible(bool v);
257+ bool should_quit();
258+ void flip();
259+
260+private:
261+ static void quit_handler(int signum);
262+ static volatile std::sig_atomic_t should_quit_;
263+ int fd;
264+ WindowProperties winprops;
265+#ifdef HAS_MALI
266+ struct mali_native_window native_window;
267+#endif
268+ bool init();
269+ void cleanup();
270+};
271+
272+#endif /* GLMARK2_NATIVE_STATE_FBDEV_H_ */
273
274=== modified file 'src/wscript_build'
275--- src/wscript_build 2013-05-05 16:23:53 +0000
276+++ src/wscript_build 2013-08-29 17:40:29 +0000
277@@ -16,17 +16,20 @@
278 'mir-gl' : ['canvas-generic.cpp', 'native-state-mir.cpp', 'gl-state-egl.cpp'],
279 'mir-glesv2' : ['canvas-generic.cpp', 'native-state-mir.cpp', 'gl-state-egl.cpp'],
280 'wayland-gl' : ['canvas-generic.cpp', 'native-state-wayland.cpp', 'gl-state-egl.cpp'],
281- 'wayland-glesv2' : ['canvas-generic.cpp', 'native-state-wayland.cpp', 'gl-state-egl.cpp']
282+ 'wayland-glesv2' : ['canvas-generic.cpp', 'native-state-wayland.cpp', 'gl-state-egl.cpp'],
283+ 'fbdev-glesv2' : ['canvas-generic.cpp', 'native-state-fbdev.cpp', 'gl-state-egl.cpp']
284 }
285 flavor_uselibs = {
286 'x11-gl' : ['x11', 'gl', 'matrix-gl'],
287 'x11-glesv2' : ['x11', 'egl', 'glesv2', 'matrix-glesv2'],
288 'drm-gl' : ['drm', 'gbm', 'egl', 'gl', 'matrix-gl'],
289- 'drm-glesv2' : ['drm', 'gbm', 'egl', 'glesv2', 'matrix-gl'],
290+ 'drm-glesv2' : ['drm', 'gbm', 'egl', 'glesv2', 'matrix-glesv2'],
291 'mir-gl' : ['mirclient', 'egl', 'gl', 'matrix-gl'],
292- 'mir-glesv2' : ['mirclient', 'egl', 'glesv2', 'matrix-gl'],
293+ 'mir-glesv2' : ['mirclient', 'egl', 'glesv2', 'matrix-glesv2'],
294 'wayland-gl' : ['wayland-client', 'wayland-egl', 'egl', 'gl', 'matrix-gl'],
295- 'wayland-glesv2' : ['wayland-client', 'wayland-egl', 'egl', 'glesv2', 'matrix-gl']
296+ 'wayland-glesv2' : ['wayland-client', 'wayland-egl', 'egl', 'glesv2',
297+ 'matrix-glesv2'],
298+ 'fbdev-glesv2' : ['egl', 'glesv2', 'matrix-glesv2']
299 }
300 flavor_defines = {
301 'x11-gl' : ['GLMARK2_USE_X11', 'GLMARK2_USE_GL', 'GLMARK2_USE_GLX'],
302@@ -36,7 +39,8 @@
303 'mir-gl' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL'],
304 'mir-glesv2' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
305 'wayland-gl' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL'],
306- 'wayland-glesv2' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL']
307+ 'wayland-glesv2' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
308+ 'fbdev-glesv2' : ['GLMARK2_USE_FBDEV', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL', 'MESA_EGL_NO_X11_HEADERS']
309 }
310
311 includes = ['.', 'scene-ideas', 'scene-terrain']
312@@ -74,6 +78,7 @@
313 features = ['cxx', 'cxxstlib'],
314 source = libmatrix_sources,
315 target = 'matrix-glesv2',
316+ use = ['glesv2'], # for gles header
317 lib = ['m'],
318 includes = ['.'],
319 export_includes = 'libmatrix',
320
321=== modified file 'wscript'
322--- wscript 2013-05-05 16:23:53 +0000
323+++ wscript 2013-08-29 17:40:29 +0000
324@@ -19,7 +19,8 @@
325 'mir-gl' : 'glmark2-mir',
326 'mir-glesv2' : 'glmark2-es2-mir',
327 'wayland-gl' : 'glmark2-wayland',
328- 'wayland-glesv2' : 'glmark2-es2-wayland'
329+ 'wayland-glesv2' : 'glmark2-es2-wayland',
330+ 'fbdev-glesv2' : 'glmark2-es2'
331 }
332 FLAVORS_STR = ", ".join(FLAVORS.keys())
333
334@@ -45,7 +46,8 @@
335 dest = 'flavors',
336 help = "a list of flavors to build (%s, all)" % FLAVORS_STR)
337 opt.parser.set_default('flavors', [])
338-
339+ opt.add_option('--for-mali', action='store_true', dest = 'mali',
340+ default = False, help='enable ARM Mali GPU support')
341 opt.add_option('--no-debug', action='store_false', dest = 'debug',
342 default = True, help='disable compiler debug information')
343 opt.add_option('--no-opt', action='store_false', dest = 'opt',
344@@ -131,6 +133,8 @@
345 ctx.env.prepend_value('CXXFLAGS', '-O2')
346 if Options.options.debug:
347 ctx.env.prepend_value('CXXFLAGS', '-g')
348+ if Options.options.mali:
349+ ctx.env.append_unique('DEFINES','HAS_MALI=1')
350
351 ctx.env.HAVE_EXTRAS = False
352 if Options.options.extras_path is not None:

Subscribers

People subscribed via source and target branches