Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi support #23

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Port glmark2 to Raspberry Pi's dispmanx.

  • Loading branch information...
anholt committed Sep 1, 2016
commit 97451860dbee23e925cda8924ee576805603bd8a
@@ -42,6 +42,8 @@
#include "native-state-mir.h"
#elif GLMARK2_USE_WAYLAND
#include "native-state-wayland.h"
#elif GLMARK2_USE_DISPMANX
#include "native-state-dispmanx.h"
#endif

#if GLMARK2_USE_EGL
@@ -168,6 +170,8 @@ main(int argc, char *argv[])
NativeStateMir native_state;
#elif GLMARK2_USE_WAYLAND
NativeStateWayland native_state;
#elif GLMARK2_USE_DISPMANX
NativeStateDispmanx native_state;
#endif

#if GLMARK2_USE_EGL
@@ -0,0 +1,132 @@
/*
* Copyright © 2013 Rafal Mielniczuk
*
* This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
*
* glmark2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* glmark2. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
*/

#include "native-state-dispmanx.h"
#include "log.h"

#include <cstring>
#include <csignal>

NativeStateDispmanx::NativeStateDispmanx()
{
memset(&properties_, 0, sizeof(properties_));
memset(&egl_dispmanx_window, 0, sizeof(egl_dispmanx_window));
}

NativeStateDispmanx::~NativeStateDispmanx()
{
}

bool
NativeStateDispmanx::init_display()
{
bcm_host_init();

return true;
}

void*
NativeStateDispmanx::display()
{
return EGL_DEFAULT_DISPLAY;
}

bool
NativeStateDispmanx::create_window(WindowProperties const& properties)
{
int dispmanx_output = 0; /* LCD */

if (!properties.fullscreen) {
Log::error("Error: Dispmanx only supports full screen rendering.\n");
return false;
}

unsigned screen_width, screen_height;
if (graphics_get_display_size(dispmanx_output,
&screen_width, &screen_height) < 0) {
Log::error("Error: Couldn't get screen width/height.\n");
return false;
}

properties_.fullscreen = properties.fullscreen;
properties_.visual_id = properties.visual_id;
properties_.width = screen_width;
properties_.height = screen_height;

dispmanx_display = vc_dispmanx_display_open(dispmanx_output);

VC_RECT_T dst_rect;
VC_RECT_T src_rect;
dst_rect.x = 0;
dst_rect.y = 0;
dst_rect.width = screen_width;
dst_rect.height = screen_height;

src_rect.x = 0;
src_rect.y = 0;
src_rect.width = screen_width << 16;
src_rect.height = screen_height << 16;

dispmanx_update = vc_dispmanx_update_start(0);

dispmanx_element = vc_dispmanx_element_add(dispmanx_update,
dispmanx_display,
0 /*layer*/,
&dst_rect,
0 /*src*/,
&src_rect,
DISPMANX_PROTECTION_NONE,
0 /*alpha*/,
0 /*clamp*/,
DISPMANX_NO_ROTATE);

egl_dispmanx_window.element = dispmanx_element;
egl_dispmanx_window.width = dst_rect.width;
egl_dispmanx_window.height = dst_rect.height;
vc_dispmanx_update_submit_sync(dispmanx_update);

return true;
}

void*
NativeStateDispmanx::window(WindowProperties &properties)
{
properties = properties_;
return &egl_dispmanx_window;
}

void
NativeStateDispmanx::visible(bool /*v*/)
{
}

bool
NativeStateDispmanx::should_quit()
{
return false;
}

void
NativeStateDispmanx::flip()
{
}

@@ -0,0 +1,56 @@
/*
* Copyright © 2013 Rafal Mielniczuk
*
* This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
*
* glmark2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* glmark2. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
*/

#ifndef GLMARK2_NATIVE_STATE_DISPMANX_H_
#define GLMARK2_NATIVE_STATE_DISPMANX_H_

#include <vector>
#include "bcm_host.h"
#include "GLES/gl.h"
#include "EGL/egl.h"
#include "EGL/eglext.h"

#include "native-state.h"

class NativeStateDispmanx : public NativeState
{
public:
NativeStateDispmanx();
~NativeStateDispmanx();

bool init_display();
void* display();
bool create_window(WindowProperties const& properties);
void* window(WindowProperties& properties);
void visible(bool v);
bool should_quit();
void flip();

private:
DISPMANX_DISPLAY_HANDLE_T dispmanx_display;
DISPMANX_UPDATE_HANDLE_T dispmanx_update;
DISPMANX_ELEMENT_HANDLE_T dispmanx_element;
EGL_DISPMANX_WINDOW_T egl_dispmanx_window;
WindowProperties properties_;
};

#endif /* GLMARK2_NATIVE_STATE_DISPMANX_H_ */
@@ -15,6 +15,7 @@ common_flavor_sources = ['main.cpp', 'canvas-generic.cpp']
flavor_sources = {
'x11-gl' : common_flavor_sources + ['native-state-x11.cpp', 'gl-state-glx.cpp'],
'x11-glesv2' : common_flavor_sources + ['native-state-x11.cpp', 'gl-state-egl.cpp'],
'dispmanx-glesv2' : common_flavor_sources + ['native-state-dispmanx.cpp', 'gl-state-egl.cpp'],
'drm-gl' : common_flavor_sources + ['native-state-drm.cpp', 'gl-state-egl.cpp'],
'drm-glesv2' : common_flavor_sources + ['native-state-drm.cpp', 'gl-state-egl.cpp'],
'mir-gl' : common_flavor_sources + ['native-state-mir.cpp', 'gl-state-egl.cpp'],
@@ -25,6 +26,7 @@ flavor_sources = {
flavor_uselibs = {
'x11-gl' : ['x11', 'gl', 'matrix-gl', 'common-gl'],
'x11-glesv2' : ['x11', 'egl', 'glesv2', 'matrix-glesv2', 'common-glesv2'],
'dispmanx-glesv2' : ['egl', 'glesv2', 'matrix-glesv2', 'common-glesv2', 'dispmanx'],
'drm-gl' : ['drm', 'gbm', 'udev', 'egl', 'gl', 'matrix-gl', 'common-gl'],
'drm-glesv2' : ['drm', 'gbm', 'udev', 'egl', 'glesv2', 'matrix-glesv2', 'common-glesv2'],
'mir-gl' : ['mirclient', 'egl', 'gl', 'matrix-gl', 'common-gl'],
@@ -40,7 +42,8 @@ flavor_defines = {
'mir-gl' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL'],
'mir-glesv2' : ['GLMARK2_USE_MIR', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
'wayland-gl' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GL', 'GLMARK2_USE_EGL'],
'wayland-glesv2' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL']
'wayland-glesv2' : ['GLMARK2_USE_WAYLAND', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
'dispmanx-glesv2' : ['GLMARK2_USE_DISPMANX', 'GLMARK2_USE_GLESv2', 'GLMARK2_USE_EGL'],
}

includes = ['.', 'scene-ideas', 'scene-terrain']
22 wscript
@@ -15,7 +15,8 @@ FLAVORS = {
'mir-gl' : 'glmark2-mir',
'mir-glesv2' : 'glmark2-es2-mir',
'wayland-gl' : 'glmark2-wayland',
'wayland-glesv2' : 'glmark2-es2-wayland'
'wayland-glesv2' : 'glmark2-es2-wayland',
'dispmanx-glesv2' : 'glmark2-es2-dispmanx',
}
FLAVORS_STR = ", ".join(FLAVORS.keys())

@@ -105,11 +106,24 @@ def configure(ctx):
if not have_png:
ctx.fatal('You need to install a supported version of libpng: ' + str(supp_png_pkgs))

dispmanx = 'dispmanx-glesv2' in ctx.options.flavors
if dispmanx:
# dispmanx uses custom Broadcom libraries that don't follow standard
# Linux packaging. Just force the library setup here.
if len(ctx.options.flavors) != 1:
ctx.fatal("dispmanx can't be built with any other flavor")

ctx.env.append_value('CXXFLAGS', '-I/opt/vc/include')

ctx.check_cxx(lib = 'brcmGLESv2', uselib_store = 'glesv2', libpath='/opt/vc/lib')
ctx.check_cxx(lib = ['brcmEGL', 'brcmGLESv2'], uselib_store = 'egl', libpath='/opt/vc/lib')
ctx.check_cxx(lib = ['bcm_host', 'vcos', 'vchiq_arm'], uselib_store = 'dispmanx', libpath='/opt/vc/lib')

# Check optional packages
opt_pkgs = [('x11', 'x11', None, list_contains(ctx.options.flavors, 'x11')),
('gl', 'gl', None, list_contains(ctx.options.flavors, 'gl$')),
('egl', 'egl', None, list_contains(ctx.options.flavors, 'glesv2$')),
('glesv2', 'glesv2', None, list_contains(ctx.options.flavors, 'glesv2$')),
('gl', 'gl', None, list_contains(ctx.options.flavors, 'gl$') and not dispmanx),
('egl', 'egl', None, list_contains(ctx.options.flavors, 'glesv2$') and not dispmanx),
('glesv2', 'glesv2', None, list_contains(ctx.options.flavors, 'glesv2$') and not dispmanx),
('libdrm','drm', None, list_contains(ctx.options.flavors, 'drm')),
('gbm','gbm', None, list_contains(ctx.options.flavors, 'drm')),
('libudev', 'udev', None, list_contains(ctx.options.flavors, 'drm')),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.