[Interest] Qt/D3D integration through ANGLE PBuffer

Thomas Sevaldrud thomas at silentwings.no
Thu Sep 24 16:46:10 CEST 2015


Ah, excellent, so I just set up a QQuickWindow with the RenderControl as
parent, right?

Just one more question:

In the QtMultimedia D3D9 example they set up a QOpenGLContext with an
invisble QWindow as current context before creating the EGL Pbuffer. I
suppose this is in order to get the correct EGL Config and surface
parameters? I suppose I could just as well use a QOffscreenSurface as the
hidden QWindow? Is this the best way to do it? It just seems a little
backwards to create an offscreen surface first in order to create the
offscreen surface I actually want... Or maybe I'm not thinking straight
here :-)

- Thomas


On Thu, Sep 24, 2015 at 4:30 PM, Andrew Knight <andrew.knight at intopalo.com>
wrote:

> Hi,
>
> On 09/24/2015 05:15 PM, Thomas Sevaldrud wrote:
>
>> This is great, thanks for very useful info!
>>
>> I'm not sure I understood Andew's part about rendering the Quick Scene
>> graph, or I may have been a bit unclear when describing the problem.
>> Basically I want to render a Qt Quick scene graph and some custom OpenGL
>> graphics into a Direct3D control (D3DImage in WPF). What Andew suggests
>> would be the other way around I think? I.e use a D3D texture in the scene
>> graph? Or did I misunderstand?
>>
>>
> Yes, that's what I was referring to. Sorry for the misunderstanding.
>
> As Laszlo suggests I'll try using QQuickRenderControl to render my scene
>> into the PBuffer/D3D texture, but I must admit I am a bit confused as to
>> how this works too. For instance I'm not sure I understand how to set up
>> the QML Engine so that it is associated with the QQuickRenderControl. In
>> the QuickRenderControl example from Qt 5.5 it appears that they set up the
>> QML Engine in a QQuickWindow with an FBO as render target. In my case I
>> need the EGL PBuffer as render target. How would I go about doing that?
>>
>>
> You don't need the QOpenGLFramebufferObject in this case. As Laszlo said,
> simply bind the pbuffer and it will become the current render target. The
> scene graph will render to the pbuffer and you can use that in your D3D
> scene as a normal texture.
>
> - Thomas
>>
>>
>>
>>
>>
>>
>> On Thu, Sep 24, 2015 at 2:48 PM, Andrew Knight <
>> andrew.knight at intopalo.com <mailto:andrew.knight at intopalo.com>> wrote:
>>
>>     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 <mailto:Interest at qt-project.org>
>>         http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150924/490ce56b/attachment.html>


More information about the Interest mailing list