[Mesa-users] Give A directFB surface to EGL

Albert Freeman albertwdfreeman at gmail.com
Thu Oct 22 05:01:07 PDT 2015


On 22 October 2015 at 11:39, 刘涛 <liutao586 at 163.com> wrote:
> Thanks a lot, I will try.  By the way I found Qt source code use DirectFB to
> EGL like below:
>
> void QDirectFbWindowEGL::createDirectFBWindow()
> {
>     // Use the default for the raster surface.
>     if (window()->surfaceType() == QSurface::RasterSurface)
>         return QDirectFbWindow::createDirectFBWindow();
>
>     Q_ASSERT(!m_dfbWindow.data());
>
>     DFBWindowDescription description;
>     memset(&description, 0, sizeof(DFBWindowDescription));
>     description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH |
> DWDESC_HEIGHT|
>                                                   DWDESC_POSX | DWDESC_POSY|
>                                                   DWDESC_PIXELFORMAT |
> DWDESC_SURFACE_CAPS);
>     description.width = qMax(1, window()->width());
>     description.height = qMax(1, window()->height());
>     description.posx = window()->x();
>     description.posy = window()->y();
>
>     description.surface_caps = DSCAPS_GL;
>     description.pixelformat = DSPF_RGB16;
>
>     IDirectFBDisplayLayer *layer;
>     layer = toDfbScreen(window())->dfbLayer();
>     DFBResult result = layer->CreateWindow(layer, &description,
> m_dfbWindow.outPtr());
>     if (result != DFB_OK)
>         DirectFBError("QDirectFbWindow: failed to create window", result);
>
>     m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
>     m_inputHandler->addWindow(m_dfbWindow.data(), window());
> }
>
> EGLSurface QDirectFbWindowEGL::eglSurface()
> {
>     if (m_eglSurface == EGL_NO_SURFACE) {
>         QDirectFbScreenEGL *dfbScreen = static_cast<QDirectFbScreenEGL
> *>(screen());
>         EGLConfig config = q_configFromGLFormat(dfbScreen->eglDisplay(),
> format(), true);
>         m_eglSurface = eglCreateWindowSurface(dfbScreen->eglDisplay(),
> config, dfbSurface(), NULL);
>
>         if (m_eglSurface == EGL_NO_SURFACE)
>             eglGetError();
>     }
>
>     return m_eglSurface;
> }
>
> But it doesn't work for me. May be it out of date.
>
> 在 2015-10-22 19:27:16,"Albert Freeman" <albertwdfreeman at gmail.com> 写道:
>>On 22 October 2015 at 21:22, 刘涛 <liutao586 at 163.com> wrote:
>>> The RAM on my board is too small to debug my program. So I want to debug
>>> my
>>> program on my PC to ensure my code is correct, then port it to my board.
>>>
>>> 在 2015-10-22 18:39:11,"Albert Freeman" <albertwdfreeman at gmail.com> 写道:
>>>>On 22 October 2015 at 19:19, 刘涛 <liutao586 at 163.com> wrote:
>>>>> Thank you very much.  My board is only support DirectFB, EGL and GLES2,
>>>>> and
>>>>> the route "DirectFB->EGL->GLES2" works good on it, but it is hard to
>>>>> debug
>>>>> on my board. So I want to program and debug the route on my PC.  Is it
>>>>> noway?
>>>>>
>>>>> 在 2015-10-22 16:32:58,"Albert Freeman" <albertwdfreeman at gmail.com> 写道:
>>>>>>On 22 October 2015 at 15:35, 刘涛 <liutao586 at 163.com> wrote:
>>>>>>> Hi
>>>>>>>    I‘m trying to give a directFB surface to eglCreateWindowSurface(),
>>>>>>> like
>>>>>>> below:
>>>>>>>     //1 create Directfb Surface
>>>>>>>     DFBDisplayLayerConfig dlc;
>>>>>>>     DFBSurfaceDescription dsc;
>>>>>>>     DFBWindowDescription dsc_w;
>>>>>>>     DirectFBInit(0, NULL);
>>>>>>>     DirectFBCreate(&_pDFB);
>>>>>>>     _pDFB->SetCooperativeLevel(_pDFB, DFSCL_FULLSCREEN);
>>>>>>>     memset(&dsc, 0, sizeof(dsc));
>>>>>>>     dsc.flags  = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS);
>>>>>>>     dsc.caps   = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY |
>>>>>>> DSCAPS_DOUBLE|DSCAPS_GL);
>>>>>>>     DFBCHECK(_pDFB->CreateSurface(_pDFB, &dsc, &_pDFB_surface));
>>>>>>>
>>>>>>>     //2 create egl surface
>>>>>>>     EGLDisplay eglDisplay = EGL_NO_DISPLAY;
>>>>>>>     EGLint iMajorVersion, iMinorVersion;
>>>>>>>      EGLint configAttribs[] =
>>>>>>>     {
>>>>>>>         EGL_RED_SIZE,          8,
>>>>>>>         EGL_GREEN_SIZE,      8,
>>>>>>>         EGL_BLUE_SIZE,          8,
>>>>>>>         EGL_ALPHA_SIZE,      8,
>>>>>>>         EGL_DEPTH_SIZE,      24,
>>>>>>>         EGL_STENCIL_SIZE,      8,
>>>>>>>         EGL_SAMPLES,          0,
>>>>>>>         EGL_SURFACE_TYPE,     EGL_WINDOW_BIT,
>>>>>>>         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
>>>>>>>         EGL_NONE
>>>>>>>     };
>>>>>>>     EGLConfig  eglConfig  = 0;
>>>>>>>     EGLint iConfigs = 0;
>>>>>>>
>>>>>>>     eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
>>>>>>>     eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion);
>>>>>>>     eglBindAPI(EGL_OPENGL_ES_API);
>>>>>>>     eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1,
>>>>>>> &iConfigs);
>>>>>>>     eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig,
>>>>>>> (EGLNativeWindowType)_pDFB_surface, NULL);
>>>>>>>
>>>>>>>    But it failed and got 0x3003 error code.
>>>>>>>     Any idea about that?
>>>>>>> Env:
>>>>>>>     Ubuntu 14..04.3, Mesa-10.1.3, DirectFB-1.7.6(use system x11)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> mesa-users mailing list
>>>>>>> mesa-users at lists.freedesktop.org
>>>>>>> http://lists.freedesktop.org/mailman/listinfo/mesa-users
>>>>>>>
>>>>>>You can't use EGL with DirectFB.
>>>>>>DirectFB had a DirectFBGL "extension" for 3D with DirectFB that has
>>>>>>apparently died.
>>>>>>So you can't get 3D hardware acceleration with DirectFB.
>>>>>>DirectFB uses the older fbdev legacy kernel stuff (which the
>>>>>>replacement drm at least partially emulates). Although fbdev supports
>>>>>>more hardware than the drm. If you are on hardware that doesn't
>>>>>>support drm then the best approach I can think of is to software
>>>>>>render OpenGL and then somehow obtain the texture rendered to and
>>>>>>somehow send that as a 2D image with something that can draw to a
>>>>>>fbdev framebuffer (such as DirectFB) (don't ask me how, ask someone
>>>>>>else (best to ask on #dri-devel irc channel)). For someone like you it
>>>>>>is best to use the latest git (not stable) version of mesa.
>>>>>>If your hardware supports drm, your choices for 3D are:
>>>>>>1. Use GL (optionally ES) & EGL & drm & gbm with mesa and without
>>>>>>DirectFB (see eglkms.c demo in mesa demos and "man -k drm" and maybe
>>>>>>http://events.linuxfoundation.org/sites/events/files/slides/brezillon-drm-kms.pdf)
>>>>>>(this runs without a window system and works much like DirectFB but I
>>>>>>believe you must use OpenGL (optionally ES) for 2D too (although you
>>>>>>MIGHT be able to setup a hardware overlay for video)). If you are not
>>>>>>using a relatively modern radeon, intel or nvidia card software
>>>>>>rendering is probably the best way to go here (using softpipe (or if
>>>>>>you are on x86 only: llvmpipe)).
>>>>>>2. Use Wayland with EGL and mesa and without DirectFB.
>>>>>>3. Use X and without DirectFB with (mesa OR proprietary drivers).
>>>>>>
>>>>>>How to force softpipe:
>>>>>>"export GALLIUM_DRIVER=softpipe" and
>>>>>>"export LIBGL_ALWAYS_SOFTWARE=1". You will need to add swrast to the
>>>>>>gallium (NOT dri) mesa compile option (e.g.
>>>>>>--with-gallium-drivers=swrast) and
>>>>>>recompile mesa.
>>>>>>
>>>>>>You can also force llvmpipe with "export GALLIUM_DRIVER=llvmpipe".
>>>>>>Actually "export LIBGL_ALWAYS_SOFTWARE=1" is only required if you have
>>>>>>a non gallium mesa driver installed (such as the i965 intel driver).
>>>>>>
>>>>>>I hope I didn't forget anything.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>Oh sorry, it does seem DirectFB can be used with EGL (I have never
>>>>used DirectFB before and the information I found implied that it would
>>>>be tricky to interface with EGL).
>>>>What do you mean by debug? Display the framebuffer (drawn on your
>>>>embedded board) on your PC?
>>>
>>>
>>>
>>>
>>On 22 October 2015 at 20:39, Albert Freeman <albertwdfreeman at gmail.com>
>> wrote:
>>> On 22 October 2015 at 19:19, 刘涛 <liutao586 at 163.com> wrote:
>>>> Thank you very much.  My board is only support DirectFB, EGL and GLES2,
>>>> and
>>>> the route "DirectFB->EGL->GLES2" works good on it, but it is hard to
>>>> debug
>>>> on my board. So I want to program and debug the route on my PC.  Is it
>>>> noway?
>>>>
>>>> 在 2015-10-22 16:32:58,"Albert Freeman" <albertwdfreeman at gmail.com> 写道:
>>>>>On 22 October 2015 at 15:35, 刘涛 <liutao586 at 163.com> wrote:
>>>>>> Hi
>>>>>>    I‘m trying to give a directFB surface to eglCreateWindowSurface(),
>>>>>> like
>>>>>> below:
>>>>>>     //1 create Directfb Surface
>>>>>>     DFBDisplayLayerConfig dlc;
>>>>>>     DFBSurfaceDescription dsc;
>>>>>>     DFBWindowDescription dsc_w;
>>>>>>     DirectFBInit(0, NULL);
>>>>>>     DirectFBCreate(&_pDFB);
>>>>>>     _pDFB->SetCooperativeLevel(_pDFB, DFSCL_FULLSCREEN);
>>>>>>     memset(&dsc, 0, sizeof(dsc));
>>>>>>     dsc.flags  = (DFBSurfaceDescriptionFlags)(DSDESC_CAPS);
>>>>>>     dsc.caps   = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY |
>>>>>> DSCAPS_DOUBLE|DSCAPS_GL);
>>>>>>     DFBCHECK(_pDFB->CreateSurface(_pDFB, &dsc, &_pDFB_surface));
>>>>>>
>>>>>>     //2 create egl surface
>>>>>>     EGLDisplay eglDisplay = EGL_NO_DISPLAY;
>>>>>>     EGLint iMajorVersion, iMinorVersion;
>>>>>>      EGLint configAttribs[] =
>>>>>>     {
>>>>>>         EGL_RED_SIZE,          8,
>>>>>>         EGL_GREEN_SIZE,      8,
>>>>>>         EGL_BLUE_SIZE,          8,
>>>>>>         EGL_ALPHA_SIZE,      8,
>>>>>>         EGL_DEPTH_SIZE,      24,
>>>>>>         EGL_STENCIL_SIZE,      8,
>>>>>>         EGL_SAMPLES,          0,
>>>>>>         EGL_SURFACE_TYPE,     EGL_WINDOW_BIT,
>>>>>>         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
>>>>>>         EGL_NONE
>>>>>>     };
>>>>>>     EGLConfig  eglConfig  = 0;
>>>>>>     EGLint iConfigs = 0;
>>>>>>
>>>>>>     eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
>>>>>>     eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion);
>>>>>>     eglBindAPI(EGL_OPENGL_ES_API);
>>>>>>     eglChooseConfig(eglDisplay, configAttribs, &eglConfig, 1,
>>>>>> &iConfigs);
>>>>>>     eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig,
>>>>>> (EGLNativeWindowType)_pDFB_surface, NULL);
>>>>>>
>>>>>>    But it failed and got 0x3003 error code.
>>>>>>     Any idea about that?
>>>>>> Env:
>>>>>>     Ubuntu 14..04.3, Mesa-10.1.3, DirectFB-1.7.6(use system x11)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> mesa-users mailing list
>>>>>> mesa-users at lists.freedesktop.org
>>>>>> http://lists.freedesktop.org/mailman/listinfo/mesa-users
>>>>>>
>>>>>You can't use EGL with DirectFB.
>>>>>DirectFB had a DirectFBGL "extension" for 3D with DirectFB that has
>>>>>apparently died.
>>>>>So you can't get 3D hardware acceleration with DirectFB.
>>>>>DirectFB uses the older fbdev legacy kernel stuff (which the
>>>>>replacement drm at least partially emulates). Although fbdev supports
>>>>>more hardware than the drm. If you are on hardware that doesn't
>>>>>support drm then the best approach I can think of is to software
>>>>>render OpenGL and then somehow obtain the texture rendered to and
>>>>>somehow send that as a 2D image with something that can draw to a
>>>>>fbdev framebuffer (such as DirectFB) (don't ask me how, ask someone
>>>>>else (best to ask on #dri-devel irc channel)). For someone like you it
>>>>>is best to use the latest git (not stable) version of mesa.
>>>>>If your hardware supports drm, your choices for 3D are:
>>>>>1. Use GL (optionally ES) & EGL & drm & gbm with mesa and without
>>>>>DirectFB (see eglkms.c demo in mesa demos and "man -k drm" and maybe
>>>>>http://events.linuxfoundation.org/sites/events/files/slides/brezillon-drm-kms.pdf)
>>>>>(this runs without a window system and works much like DirectFB but I
>>>>>believe you must use OpenGL (optionally ES) for 2D too (although you
>>>>>MIGHT be able to setup a hardware overlay for video)). If you are not
>>>>>using a relatively modern radeon, intel or nvidia card software
>>>>>rendering is probably the best way to go here (using softpipe (or if
>>>>>you are on x86 only: llvmpipe)).
>>>>>2. Use Wayland with EGL and mesa and without DirectFB.
>>>>>3. Use X and without DirectFB with (mesa OR proprietary drivers).
>>>>>
>>>>>How to force softpipe:
>>>>>"export GALLIUM_DRIVER=softpipe" and
>>>>>"export LIBGL_ALWAYS_SOFTWARE=1". You will need to add swrast to the
>>>>>gallium (NOT dri) mesa compile option (e.g.
>>>>>--with-gallium-drivers=swrast) and
>>>>>recompile mesa.
>>>>>
>>>>>You can also force llvmpipe with "export GALLIUM_DRIVER=llvmpipe".
>>>>>Actually "export LIBGL_ALWAYS_SOFTWARE=1" is only required if you have
>>>>>a non gallium mesa driver installed (such as the i965 intel driver).
>>>>>
>>>>>I hope I didn't forget anything.
>>>>
>>>>
>>>>
>>>>
>>> Oh sorry, it does seem DirectFB can be used with EGL (I have never
>>> used DirectFB before and the information I found implied that it would
>>> be tricky to interface with EGL).
>>> What do you mean by debug? Display the framebuffer (drawn on your
>>> embedded board) on your PC?
>>Oh, you mean use DirectFB with latest mesa 3D drivers.
>>You won't be able to use hardware acceleration with DirectFB, although
>>someone wrote a DirectFB "backend" for softpipe/llvmpipe a while ago
>>(2013):
>>http://lists.freedesktop.org/archives/mesa-dev/2013-April/037768.html
>>You may have to download an older revision of mesa and then apply the
>>patch (as there is no DirectFB backend in the latest revision of
>>mesa). And maybe they didn't develop all the infrastructure required,
>>so it might not be possible.
>>I will try to get DirectFB working on my system, I will need to
>>compile a custom kernel, so it will take a little bit of time.
>>Hardware acceleration (using modern versions of radeon, nvidia, intel
>>cards) seems out of the question though.
>
>
>
>
Can you give me your DirectFB compile flags (for X11)?


More information about the mesa-users mailing list