Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render Qml using Vulkan

I have a Qt application that draws using Open GL. At some point I'm using a QQuickWindow associated to a QQuickRenderControl to draw a QML scene into a texture to later compose it in the final image.

Now, I'm considering porting OpenGL to Vulkan and I'm not sure if it is possible to do the same with this QML layer.

Reading Qt docs I found that

QQuickWindow uses a scene graph on top of OpenGL to render.

Do you think it is possible to port it to Vulkan? Perhaps overriding QQuickWindow and QQuickRenderControl? I'm not a Qt expert so perhaps someone can give me a better insight of the problem.

like image 837
gabocalero Avatar asked Jan 13 '17 15:01

gabocalero


People also ask

Does Qt use Vulkan?

Each Qt application using Vulkan will have to have a Vulkan instance which encapsulates application-level state and initializes a Vulkan library. A QVulkanWindow must always be associated with a QVulkanInstance and hence the example performs instance creation before the window.

What is rendering in Qt?

The Qt Rendering Hardware Interface (RHI) translates 3D graphics call from Qt applications to the available graphics APIs on the target platform. The supported graphics APIs are: OpenGL (version 3 and higher) OpenGL ES (version 2 and higher)


1 Answers

As of June 2019 and Qt 5.13, Qt Quick 2 supports the following backends:

  1. OpenGL 2.0
  2. OpenGL ES 2.0
  3. Direct3D 12 (support is still experimental)
  4. OpenVG
  5. Software rendering

However, only OpenGL and OpenGL ES are fully functional. For instance some effects (like particles) do not work with the other banckends.

For more information about how to select a backend and what are the limitations of each backend I suggest to read the documentation: https://doc.qt.io/qt-5/qtquick-visualcanvas-adaptations.html

Regarding Vulkan specifically, Qt has added support to it since Qt 5.10. However, the support is still very limited and does not cover Qt Quick.

Change will come in the future; quoting an email from Qt development mailing list:

A very early preview of Qt Quick for Vulkan, Metal, and D3D11 may come already in Qt 5.14, then evolve in 5.15 and beyond, with 6.0 as its final destination.

So rendering Qt Quick with Vulkan should be possible when Qt 6 will be out. The planned release date for Qt 6 is currently November 2020. In the mean time technical previews might be available starting with Qt 5.14.

I would not be too optimistic for anything before Qt 6 as (1) it will just be technical previews and (2) as far as I know, current official Qt binaries are not linked with Vulkan at all and you need to build Qt from source if you want to use Vulkan.

like image 162
Benjamin T Avatar answered Sep 28 '22 11:09

Benjamin T