I'm working on an application using Qt 5.15.11 and ANGLE, which needs to play nice with another application out of my control. With a lot of experimentation with a small DirectX test app I determined that the problem can be fixed by using the Flip Model for the swap chain, e.g. like this:
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
Using PIX, I am relatively sure that my application is currently not using this SwapEffect, which is why it won't play nice.
I tried digging through the angle code, it seems that I need to set the attribute EGL_DIRECT_COMPOSITION_ANGLE to EGL_TRUE in order to enable this. That's where I'm stuck: I have no idea how to achieve this.
Can I get Qt and ANGLE to use this SwapEffect (or FLIP_SEQUENTIAL; I presume both work)? Will I need to recompile Qt or can it be done with an environment variable or other configuration method? I am currently stuck with Qt 5.15 but it's not entirely out of the question to upgrade to Qt 6 in the future.
It's taken some time but we've gotten around to test this approach: Our problem was solved this way.
To answer this question, I'll provide what exactly I changed in Qt in order to enable this swap effect:
In /src/plugins/platforms/windows/qwindowseglcontext.cpp line I made the following change:
void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
{
*err = 0;
EGLint attribs[3] = {
EGL_DIRECT_COMPOSITION_ANGLE, EGL_TRUE,
EGL_NONE
};
EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
static_cast<EGLNativeWindowType>(nativeWindow), attribs); //attribs was nullptr before