qt: improve startup speed on Windows by probing rhi asynchronously and caching the result
We currently check on Windows if the default graphics backend is supported and do cross-graphics api fallback. Qt uses Direct3D 11.2 by default, and does not fallback to others (OpenGL, Vulkan, Software, ...). If I remember correctly, Qt 6.8 may fallback to Direct3D 11.2 WARP (software rasterizer) if swapchain creation fails, which we would not prefer but rather use OpenGL
. This is currently the case for Windows 7, as Qt RHI's d3d11 abstraction is not supported on Windows 7.
QRhi::probe()
can be really expensive, so what we are doing now (synchronous probing at each start) is not ideal as that causes delaying playing the initial item.
Startup time is defined as the time it takes to start playing the initial item when the application is opened.
Currently probing is done synchronously each time the interface starts. This is not ideal, as we don't expect the system to suddenly start supporting a particular graphics api. Obviously, due to hardware change or driver update or any reason this may change, so we still need to check that each time.
In this case, the worst can happen is that QQuickWindow
emits error and terminates the application (usually with an
error message box) when the api is no longer supported.
However, since the cached api is checked each time asynchronously,
the next startup would be fine.
This basically improves the startup performance, at the expense of causing an error and terminating the application (in the worst case) if the system suddenly starts not supporting once valid api. The worst case is a rare case, so I believe that this would be a good optimization.
Request review @chub.