[Interest] Qt/D3D integration through ANGLE PBuffer

Andrew Knight andrew.knight at intopalo.com
Thu Sep 24 14:48:45 CEST 2015


Hi Thomas,

On 09/24/2015 03:11 PM, Thomas Sevaldrud wrote:
> Hi,
>
> I have earlier made an implementation of Qt/D3D integration by hacking 
> into the ANGLE D3D SwapChain and extracting the D3DSurface directly there.
>
> However, this is a bit flakey, and I have had to change this code 
> several times when new versions of Qt and ANGLE are released.
>
> So, now I want to do this the supported way through the 
> EGL_ANGLE_surface_d3d_texture_2d_share_handle extension. If I 
> understand this correctly I can set up a PBuffer-based render target 
> which I can query for a D3D texture sharing handle using the 
> eglQuerySurfacePointerANGLE extension.

Yes, this is possible.

> Now, before I start coding, I wonder if anyone has an example of using 
> this extension for rendering to a D3D Texture? Someone mentioned on 
> the list earlier that there should be an example of this in 
> QtMultimedia, but I haven't been able to find it.

The two places this extension is used are at:
(D3D11) 
http://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/winrt/qwinrtabstractvideorenderercontrol.cpp#n372

This one creates a shared texture using D3D and shares it with ANGLE. 
This texture is updated when a video player or camera queues a frame. It 
is bound to the pipeline with a QOpenGLTexture object and eglBindTexImage().

(D3D9)
http://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/wmf/evrd3dpresentengine.cpp#n451

This one first creates a pbuffer using EGL, gets the shared texture 
handle from it, and then opens up the texture in D3D.

Both cases are therefore covered, as well as both major D3D versions.

> Also, for the PBuffer implementation, should I create a PBuffer 
> directly through EGL, or can I use QOffsceenSurface? If I understand 
> correctly, QOffscreenSurface will be implemented with a PBuffer on 
> Windows?
> To complicate matters even more I want to include a Quick scene graph 
> in this as well, but I suppose I can use the new QQuickRenderControl 
> class for this when I have the PBuffer render target sorted out?

I would just render to your D3D texture (by creating it via one of the 
ways described above) and use it in the scene graph by binding its 
content to the currently bound QOpenGLTexture object with 
eglBindTexImage(). You can create a QSGTexture from a QOpenGLTexture by 
passing the texture id to QSGEngine::createTextureFromId().

> Best regards,
> Thomas
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list