Using Vulkan and OpenGL in the same app?

Greetings,

I have a testapp that creates OpenGL based windows with Qt. I would like to extend the application so that you can show an OpenGL window and a Vulkan window side by side for comparison. Is this generally possible/advised or are the platforms that only allow one or the other?

Regards

Hey there,

while it would be possible, I will suggest to do both windows with a Vulkan API backend in the same process. Vulkan was made for advanced usage patterns like this. The major problem I see is that all the advantages of using Vulkan API (low level control over the GPU) are given up by using OpenGL next to it. This could not only decrease performance, but also bring up some strange driver behaviour issues, as OpenGL drivers do a lot more guesswork and it’s much harder to predict what will happen. The worst case would be that your app is running on your machine, but does not run at all on other machines due to these issues.

Vulkan API on the other hand offers you all the low level control you need: If the user has 2 graphics cards, you could use one for each window for example. If not, you could coordinate your rendering much better with Vulkan than with a mixture of Vulkan and OpenGL.

As far as I know, Vulkan was not really made to be coordinated with OpenGL which means it contains no functions which could solve some of these complex driver issues. Correct me if I’m wrong. Same applies for OpenGL: It is not made to be coordinated with Vulkan API.

Best regards,
Johannes

For clarification:

The app should support the conversion of a rendering engine from GLES to Vulkan. What I basically want is to have say a two window view where the left window starts the test scenario with OpenGLES and the right one with Vulkan. I do not need any resource sharing between GLES and Vulkan.

This is possible I think but still you would rely on the individual driver’s implementation of handling such anuse case. Please keep in mind that gpu-specific performance issues could occur.

I think it will be used on Linux with proprietary Nvidia driver most of the time.

The first minor consideration is which Qt version you are using. If by change you are using older than Qt 5.4 (ish) then the answer is very different.

In Qt 5.4+ you can mix and match GPU APIs, but you have to isolate them under a QWindow. Assuming you are using their frameworks then a QOpenGLWindow and QVulkanWindow. Then all the OpenGL QWidgets need to be children of a QOpenGLWindow and Vulkan QWidgets children of the QVulkanWindow.
This is because the GL context and Vulkan Device are part of the Q*Window and not the QWidgets.

1 Like