All backends already have an init method so far called from the ctor.
This change moves the call to init out of the OpenGL backends and makes
it the responsibility of the creating code to also call init on the
backend.
This change makes it easier to have virtual methods being called during
the initialization.
So far it was bound to whether we build for GLES. But this is
semantically wrong. It might be possible that even on desktop gl
epoxy is built without GLX support, thus we need to reflect this.
This change ensures that epoxy/glx.h is only included if available,
that relevant code is bound to it and that checks are in place to
enforce EGL if not build with glx support.
In addtion the glxbackend.cpp is now only included in the build set
if available.
EglWaylandBackend gains support for creating textures from a
BufferInterface. At the same time it loses the possibility to use
the Xcb shm extension to load the texture. That is Xwayland is
required.
In order to support it in a better way the WindowPixmap is passed
to the Texture for loading and updating. Which is then passed to the
backend specific implementation.
The drawable field is set to the X drawable ID when the swap event is
synthesized by DRI2WireToEvent(), and the GLX drawable ID when the
event is received over the wire. The latter being the case with DRI3.
__glXWireToEvent() fixes this for Xlib clients by changing the field
to the X drawable ID. This doesn't work for xcb clients however,
so we have to expect the field to be set to either the X or the GLX
drawable ID.
BUG: 342582
Not all RGBA 8888 fbconfigs in the NVIDIA driver have an associated
X visual with a 32 bit depth.
This fixes a regression from 88f8078073.
Tested-by: Eike Hein <hein@kde.org>
This adds a SceneOpenGL::Texture::load(..., xcb_visualid_t) overload,
and uses it to bind window pixmaps to textures.
By taking the RGBA masks in the visual into account when choosing an
FBConfig for the GLXPixmap, we are able to disambiguate formats that
have the same depth, such as GL_RGB10_A2 and GL_RGBA8.
Remove the manually written GL dispatch code, and use libepoxy
to resolve functions.
The only exceptions are GLX_MESA_swap_control, which is not in
the XML API registry, and GL_ARB_robustness/GL_EXT_robustness.
For the latter we want to resolve the functions to the same names
on both GLES and desktop GL, and plug in our own implementations
when the extension is not supported.
Only the X based Scenes need an overlay window, so the Compositor doesn't
need to check for it in the Wayland case.
OverlayWindow is moved from OpenGLBackend to the sub classes which need
to provide it.
Allow prepareRenderingFrame() to return a region that will be
repainted in addition to the damaged region.
Pass both the damaged region and the repainted region, which
may be larger, as parameters to endRenderingFrame().
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
Remove support for OpenGL compositing without using a composite
overlay window. With this change kwin now also requires a
double-buffered framebuffer configuration.
Use glXChooseFBConfig() instead of glXGetFBConfigs(), and prefer
the first usable configuration instead of the last.
Also rename initBufferConfigs() to initFbConfig().
The handling for creating and managing the OpenGL context is
split out of the SceneOpenGL into the abstract OpenGLBackend
and it's two subclasses GlxBackend and EglOnXBackend.
The backends take care of creating the OpenGL context on the
windowing system, e.g. on glx an OpenGL context on the overlay
window is created and in the egl case an EGL context is created.
This means that the SceneOpenGL itself does not have to care
about the specific underlying infrastructure.
Furthermore the backend provides the Textures for the specific
texture from pixmap operations. For that in each of the backend
files an additional subclass of the TexturePrivate is defined.
These subclasses hold the EglImage and GLXPixmap respectively.
The backend is able to create such a private texture and for
that the ctor of the Texture is changed to take the backend as
a parameter and the Scene provides a factory method for
creating Textures. To make this work inside Window the Textures
are now hold as pointers which seems a better choice anyway as
to the member functions pointers are passed.