Rudis 发表于 2017-11-20 10:24:16

Qt+eglf on X11 配置

花了不少时间,终于在ubuntu x11下搞定了qt+opengl es2,虽然回过头来看,其实结论很简单。

这块开发板加上rk给的libmali.so 的库是可以正常在x11桌面下运行opengles2程序的,之前编译一直通不过 eglfs on x11。这里稍微总结一下处理办法。

建议使用qt5.8+的版本,之前用的qt5.6在很多情况下不是很好用,5.6的opengl es2测试文件时,没有加 #define GL_GLEXT_PROTOTYPES
opengles2 测试无法通过,自己手工加不知道有多少坑,所以建议使用qt5.8。本人就是在 qt5.8下面测试的。

本人是利用开发板直接编译的qt,需要交叉编译的,仿照我的工作,修改systemroot下的文件即可。

首先把xcb相关的动态库补充完整,这类文章很多,就不重复了

配置命令:
./configure -v -nomake examples -opengl es2直接这样配置,可以看到 eglf on x11 是失败的,这样编译的qt无法使用 opengl es2 也无法使用gpu 加速。进入 text文件,打开

5.8/Src/qtbase/config.tests/qpa/egl-x11 文件,或者观察 congiure 的测试报告

#include <EGL/egl.h>
#include <xcb/xcb.h>
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>

int main(int, char **)
{
    Display *dpy = EGL_DEFAULT_DISPLAY;
    EGLNativeDisplayType egldpy = XOpenDisplay("");
    dpy = egldpy;
    EGLNativeWindowType w = XCreateWindow(dpy, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    XDestroyWindow(dpy, w);
    XCloseDisplay(dpy);
    return 0;
}

可以看到是类型转换过程中出现的问题,由于类型转化错误,导致编译不通过,所以qt认为egl on x11是不支持的。但是我在使用opengl-es3的范例程序,在

rk3399上是可以正常运行的,此例子的窗口创建程序如下
static Display *x_display = NULL;
EGLBoolean WinCreate(ESContext *esContext, const char *title)
{
Window win;
win = XCreateWindow(

               x_display, root,

               0, 0, esContext->width, esContext->height, 0,

               CopyFromParent, InputOutput,

               CopyFromParent, CWEventMask,

               &swa );

esContext->eglNativeWindow = (EGLNativeWindowType) win;

    esContext->eglNativeDisplay = (EGLNativeDisplayType) x_display;

}


opengles3 的范例程序跟qt的测试代码用的是同样的方式创建窗口,缺可以正常工作,证明eglfs on x11 是支持的,只是由于某些问题,导致qt配置测试通过

不了。

打开/usr/include/EGL/eglplatform.h
struct gbm_device;
struct gbm_surface;

typedef struct gbm_device * EGLNativeDisplayType;
typedef struct gbm_surface * EGLNativeWindowType;
typedef void * EGLNativePixmapType;

/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapTypeNativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
里面的内容就只有短短这几句话,和虚拟机上ubuntu比较就会发现,rk的egl头文件并没有添加egl在x11上面的支持。事实上,他们的驱动已经支持egl on

x11了,所以,我们的工作,只要把这个头文件补充完整。

struct gbm_device;
struct gbm_surface;

#if defined(__GBM__)
typedef struct gbm_device * EGLNativeDisplayType;
typedef struct gbm_surface * EGLNativeWindowType;
typedef void * EGLNativePixmapType;
#elif defined(__unix__)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#endif

typedef EGLNativeWindowType NativeWindowType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeDisplayType NativeDisplayType;
这里增加了 __unix__ 环境下对x11的类型的支持,保存之后重新配置qt,可以看到egl on x11 通过,编译qt。





mouqilng 发表于 2017-11-23 16:21:15

你编译的qt能用webengin吗

baisetuzi 发表于 2017-11-23 22:06:23

您好,能加您qq吗?想请教几个问题,我也在学习RK3399(qq794513669)

Rudis 发表于 2017-11-24 11:48:50

mouqilng 发表于 2017-11-23 16:21
你编译的qt能用webengin吗

我没有编译这个模块,理论上这个模块应该是没问题的

mouqilng 发表于 2017-11-24 14:13:21

Rudis 发表于 2017-11-24 11:48
我没有编译这个模块,理论上这个模块应该是没问题的

我编译的webengin一直报错,主要是opengl相关的,方便分享下你的环境配置步骤和参数吗?谢谢!

mouqilng 发表于 2017-11-24 14:13:45

Rudis 发表于 2017-11-24 11:48
我没有编译这个模块,理论上这个模块应该是没问题的

我编译的webengin一直报错,主要是opengl相关的,方便分享下你的环境配置步骤和参数吗?谢谢!

mouqilng 发表于 2017-11-24 14:46:41

Rudis 发表于 2017-11-24 11:48
我没有编译这个模块,理论上这个模块应该是没问题的

大神,方便qq给我不,我qq:395668693

mouqilng 发表于 2017-11-24 18:12:42

能不能再详细点,按照你的步骤做了,还是没有通过

Rudis 发表于 2017-11-28 09:07:45

mouqilng 发表于 2017-11-24 18:12
能不能再详细点,按照你的步骤做了,还是没有通过

我这个是为了在rk3399上支持gpu的qt3d,webengine我没有去尝试

无非是少什么装什么,rk3399本身也支持opengl,具体要看configure中测试失败详细信息

mouqilng 发表于 2017-11-28 20:41:22

Rudis 发表于 2017-11-28 09:07
我这个是为了在rk3399上支持gpu的qt3d,webengine我没有去尝试

无非是少什么装什么,rk3399本身也支持 ...

configure 感觉能过,但是log中报了一堆错{:4_115:}

firefly@firefly:~/qt-everywhere-opensource-src-5.8.0$ ./configure -v -opengl es2 -xplatform linux-rk3399-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -qt-xcb -qpa xcb -confirm-license -optimized-qmake -reduce-exports -release -qt-pcre -make libs
+ cd qtbase
+ /home/firefly/qt-everywhere-opensource-src-5.8.0/qtbase/configure -top-level -v -opengl es2 -xplatform linux-rk3399-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -qt-xcb -qpa xcb -confirm-license -optimized-qmake -reduce-exports -release -qt-pcre -make libs

This is the Qt Open Source Edition.

You are licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) version 3.
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) version 2.

You have already accepted the terms of the Open Source license.

Creating qmake...
make: Nothing to be done for 'first'.

Running configuration tests...
Done running configuration tests.

Configure summary:

Building on:arm64
Building for: arm64
Configuration: use_gold_linker cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared rpath accessibility release c++11 c++14 c++1z concurrent dbus no-pkg-config mremap reduce_exports release_tools stl
Build options:
Mode ................................... release; optimized tools
Building shared libraries .............. yes
Using C++ standard ..................... C++1z
Using gold linker ...................... yes
Using new DTAGS ........................ yes
Using precompiled headers .............. yes
Using LTCG ............................. no
Target compiler supports:
    NEON ................................. yes
Build parts ............................ libs
Qt modules and options:
Qt Concurrent .......................... yes
Qt D-Bus ............................... yes
Qt D-Bus directly linked to libdbus .... no
Qt Gui ................................. yes
Qt Widgets ............................. yes
Support enabled for:
Accessibility .......................... yes
Using pkg-config ....................... no
QML debugging .......................... yes
udev ................................... no
Using system zlib ...................... yes
Qt Core:
DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
GLib ................................... no
iconv .................................. yes
ICU .................................... no
Logging backends:
    journald ............................. no
    syslog ............................... no
Using system PCRE ...................... no
Qt Network:
getaddrinfo() .......................... yes
getifaddrs() ........................... yes
IPv6 ifname ............................ yes
libproxy ............................... no
OpenSSL ................................ no
    Qt directly linked to OpenSSL ........ no
SCTP ................................... no
Use system proxies ..................... yes
Qt Sql:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
    Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt Gui:
FreeType ............................... yes
    Using system FreeType ................ no
HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
Fontconfig ............................. no
Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... no
    PNG .................................. yes
      Using system libpng ................ yes
OpenGL:
    EGL .................................. yes
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ no
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. yes
libinput ............................... no
mtdev .................................. no
tslib .................................. no
xkbcommon-evdev ........................ no
QPA backends:
DirectFB ............................... no
EGLFS .................................. yes
EGLFS details:
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS EGLDevice ...................... no
    EGLFS GBM ............................ no
    EGLFS Mali ........................... no
    EGLFS Rasberry Pi .................... no
    EGL on X11 ........................... yes
LinuxFB ................................ yes
Mir client ............................. no
X11:
    Using system provided XCB libraries .. no
    EGL on X11 ........................... yes
    Xinput2 .............................. no
    XCB XKB .............................. no
    XLib ................................. yes
    Xrender .............................. yes
    XCB GLX .............................. yes
    XCB Xlib ............................. yes
    Using system-provided xkbcommon ...... no
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt SerialBus:
Socket CAN ............................. yes
Socket CAN FD .......................... yes
QtXmlPatterns:
XML schema support ..................... yes
Qt QML:
QML interpreter ........................ yes
QML network support .................... yes
Qt Quick:
Direct3D 12 ............................ no
AnimatedImage item ..................... yes
Canvas item ............................ yes
Support for Quick Designer ............. yes
Flipable item .......................... yes
GridView item .......................... yes
ListView item .......................... yes
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
Qt Gamepad:
SDL2 ................................... no
Qt 3D:
System Assimp .......................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
BlueZ .................................. no
BlueZ Low Energy ....................... no
Linux Crypto API ....................... no
Qt Multimedia:
ALSA ................................... no
GStreamer 1.0 .......................... no
GStreamer 0.10 ......................... no
Video for Linux ........................ yes
OpenAL ................................. no
PulseAudio ............................. no
Resource Policy (libresourceqt5) ....... no
DirectShow ............................. no
Windows Media Foundation ............... no
Qt Location:
Gypsy GPS Daemon ....................... no
WinRT Geolocation API .................. no
Qt Sensors:
sensorfw ............................... no
Qt WebEngine:
Proprietary Codecs ..................... no
Spellchecker ........................... yes
ALSA ................................... no
PulseAudio ............................. no

Note: -optimized-tools is not useful in -release mode.

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.


Platform notes:

            - Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx
      

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Qt-5.8.0

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
页: [1] 2
查看完整版本: Qt+eglf on X11 配置