[Interest] Qt/ANGLE .NET integration stopped working between Qt 5.3 and 5.4

Andrew Knight andrew.knight at intopalo.com
Tue Sep 8 08:59:55 CEST 2015


Hi Eirik,

On 09/07/2015 11:06 PM, Eirik Ulvik wrote:
 > We have an integration between Qt/OpenGL using QML and .NET/WPF that 
worked fine in Qt 5.3.
 > The integration is based on a question asked on this mailing list 
before: 
http://lists.qt-project.org/pipermail/interest/2014-January/010827.html 
and depends the fact that Qt uses ANGLE as the backend renderer.
 >
 > In order to show a OpenGL based rendering from Qt/C++ code in a .NET 
based WPF application we need to get the DirectX buffer pointer. It is a 
requirement that the backend rendering system is DirectX 9. I have 
managed to force Qt to use ANGLE with a DirectX 9 backend. The output 
from the QML scene graph and qt.qpa.gl <http://qt.qpa.gl/> logger:
 >
*snip*
 >
 > System info:
 > Windows 10
 > Installed Qt 5.4 using Visual Studio 2013 compiler.
 >
 > The code that used to work before is this, but now always fails:
 >
 > #include <d3d9.h>
 > #include <dxgi.h>
 > #include <libEGL/Surface.h>
 > #if QT_VERSION >= 0x050400
 >     #include <libGLESv2/renderer/d3d/d3d9/SwapChain9.h>
 > #elif QT_VERSION >= 0x050300
 >     #include <libGLESv2/renderer/d3d9/SwapChain9.h>
 > #else
 >     #include <libGLESv2/renderer/SwapChain9.h>
 > #endif
 > #include <EGL/egl.h>
 > #include <EGL/eglext.h>
 >
 > IDirect3DSurface9* AngleQmlRenderSurface::getD3DSurfaceHandle()
 > {
 >     //Works in Qt 5.3, always NULL in Qt 5.4
 >     EGLDisplay display = eglGetCurrentDisplay();
 >     EGLBoolean result = eglSwapInterval(display, 0);
 >
 >     //Works in Qt 5.3, always NULL in Qt 5.4
 >     EGLSurface sfc = eglGetCurrentSurface(EGL_DRAW);
 >     egl::Surface* surface = static_cast<egl::Surface*>(sfc);
 >     rx::SwapChain *swapChain = surface->getSwapChain();
 >     rx::SwapChain9* swapChainD3D9 = 
dynamic_cast<rx::SwapChain9*>(swapChain);
 >
 >     return swapChainD3D9->getRenderTarget();
 > }
 >
 > Any suggestion to what might be the problem is much appreciated.

You are using private API from ANGLE to get the pointer, so there are no 
guarantees that this behavior is stable. Have you debugged into this to 
see what's going on there? What is NULL anyway - the render target, swap 
chain, or surface?

Have you considered changing your rendering strategy? There are other 
ways to do D3D/OpenGL interop. ANGLE provides 
eglCreatePbufferFromClientBuffer with 
EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 
(https://www.khronos.org/registry/egl/extensions/ANGLE/EGL_ANGLE_surface_d3d_texture_2d_share_handle.txt), 
which allows you to pass a D3D texture to ANGLE for use as a texture 
e.g. within the Scene Graph. There are examples of its usage inside 
QtMultimedia.

 >
 > Best regards,
 > Eirik Ulvik
 >

HTH,
Andrew




More information about the Interest mailing list