Commit graph

525 commits

Author SHA1 Message Date
Martin Gräßlin
d76f08e359 Render effect frame with shader trait API 2016-01-25 14:11:54 +01:00
Martin Gräßlin
0d1da1c583 Always set mvp on shader in SceneOpenGL2Window::performPaint
Makes it possible to pass in a shader with a custom fragment shader,
but a normal vertex shader which needs the mvp matrix to be set.
2016-01-25 14:11:54 +01:00
Martin Gräßlin
f284ef814c Pass projection matrix to ScreenPaintData
With this change a new ctor overload is added to ScreenPaintData
which allows passing a projection matrix through the effects. This
allows effects to put up custom shaders with a shared projection matrix
and without having to calculate it themselves.

The projection matrix is a read-only information for the effects. There
is no way to change or overwrite it.
2016-01-25 14:11:54 +01:00
Martin Gräßlin
5657405d32 Use ShaderTraits based shader for paint background
Little bit less usage of old Shader API.
2016-01-25 14:11:54 +01:00
Martin Gräßlin
ad7246e010 Create the new projection matrix at start of frame rendering
For both simple and generic rendering the projection is actually the
same. So let's create it at the start of the frame rendering which
allows us to also pass it through the effects.
2016-01-25 14:11:54 +01:00
Martin Gräßlin
401efc28a8 SceneOpenGL::Window::getDecorationTexture() operates on AbstractClient 2015-12-18 16:41:49 +01:00
Martin Gräßlin
1758db337f DecoratedClientImpl::client returns AbstractClient* instead of Client* 2015-12-18 16:41:49 +01:00
Martin Gräßlin
03909b9d58 Allow rendering of input method windows also if screen is locked and OpenGL is used
Needed to get maliit keyboard above the greeter window.

Reviewed-By: Bhushan Shah
2015-12-04 16:37:54 +01:00
Martin Gräßlin
b1914b4b2c Add pure virtual OpenGLBackend::init() method
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.
2015-11-26 08:33:07 +01:00
Martin Gräßlin
38cde38edf Ensure Scene doesn't render non lock screen windows while screen is locked
The last stage for window rendering is triggered by
Scene::finalDrawWindow. Adding a security check there if screen is locked
no non-lock screen window should be rendered.

Unfortunately this method is virtual so the check needs to be done in the
base and all implementing child methods (currently only OpenGL).

REVIEW: 126144
2015-11-26 08:30:57 +01:00
Martin Gräßlin
416d8060cf Don't query for GL_CONTEXT_FLAGS if not at least OpenGL 3.0
Patch by Thomas Lübking.

BUG: 355522
2015-11-19 11:20:33 +01:00
Martin Gräßlin
01451eea36 Revert "Handle conflicts between epoxy and manually resolved function pointers"
This reverts commit ac1dbac8b1.
2015-11-17 14:58:59 +01:00
Martin Gräßlin
5d416a0f69 Introduce additional safety checks for init debug output in SceneOpenGL
There are slight differences between GL_ARB_debug_output and GL_KHR_debug
affecting how it works on GLES. With GL_KHR_debug the context should be
created with a debug flag. With the ARB extension there is no such
requirement. Empirical data (Mali) shows that it doesn't work if the
context is not created with the flag, although the spec seems to allows
it.

So:
* if we have GL_ARB_debug_output we assume it works
* if we only have GL_KHR_debug we check whether the context is created
  with debug support (which we don't do yet, but maybe should?)
* on GLES we can only query with version 3.2 (which we don't request yet)
* with anything older we just assume it's not enabled (which is correct
  given that we don't enable the debug flag)

REVIEW: 126053
2015-11-16 09:09:34 +01:00
Martin Gräßlin
ac1dbac8b1 Handle conflicts between epoxy and manually resolved function pointers
For the functions from GL_FOO_robustness we want to resolve it by
ourselves in order to add a custom implementation if it's not available.
Unfortunately once epoxy.h is included this breaks as epoxy defines the
names and so through the preprocessor epoxy always wins.

So we need different names: all functions from robustness get a "kwin"
prefix and the usage is changed everywhere in kwin source code.

REVIEW: 125883
2015-11-11 08:04:29 +01:00
Nick Shaforostoff
3a8d7d866a optimize string operations
-use qstringliteral only when necessary (i.e. not in concat or comparison)
-use qbytearray instead of qstring when dealing with latin1 input and output (glplatform)
-use qstringref to extract numbers from strings (glplatform)
-define qt_use_qstringbuilder to optimize all string concatenations
-anidata: use ctor init lists, add windowType member initialization

REVIEW: 125933
2015-11-05 14:14:06 +00:00
Martin Gräßlin
c50da5bdee Fix compile with libepoxy < 1.3
Compile failure on KDE CI:
error: ‘GL_GUILTY_CONTEXT_RESET’ was not declared in this scope

It's not defined in libepoxy 1.2, so let's define it to the values
it has in 1.3.
2015-11-03 10:12:55 +01:00
Martin Gräßlin
f2ad98aa3a Add O2ES as possible value for KWIN_COMPOSE
If KWIN_COMPOSE is set to O2ES, an OpenGL ES context is tried to
be created instead of an OpenGL context.

REVIEW: 125919
2015-11-03 09:30:12 +01:00
Martin Gräßlin
4f64b32aba Runtime depend on GLES in SceneOpenGL
Thanks to epoxy for allowing us to get rid of some additional GL/GLES
specific defines.
2015-11-03 09:29:31 +01:00
Martin Gräßlin
03231942bb Bind building of glx support on whether epoxy has a glx header
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.
2015-11-03 09:29:31 +01:00
Martin Gräßlin
0fc1142ca2 Allow OpenGLBackend to hold a surfaceless context
For a virtual rendering backend a surfaceless context is needed. Such
a context may not call glDrawBuffer as that results in a GL error.

This change allows the OpenGLBackend to announce that it's context is
surfaceless.
2015-10-08 15:54:24 +02:00
Martin Gräßlin
f84b4758f2 Fix incorrect static_casts to Client
Replace by better dynamic_casts to AbstractClient.
2015-09-16 13:54:48 +02:00
Martin Gräßlin
3139dcd3b9 Drop cmakedefine HAVE_WAYLAND
Now a required build dependency.
2015-08-12 11:39:20 +02:00
Martin Gräßlin
c24e315a9b Drop build option KWIN_BUILD_EGL
It doesn't make much sense any more as we do no longer link EGL since the
switch to epoxy. And epoxy pulls it in at runtime if needed.
Even more on Wayland it's just plain stupid to have EGL disabled. So
removing the option just simplifies our code base without any
disadvantages.

REVIEW: 124695
2015-08-11 11:15:25 +02:00
Martin Gräßlin
53004b95ff Port left over qDebug to qCDebug 2015-07-31 13:25:51 +02:00
Aleix Pol
6f345f4915 Clean debug output
Removes endl in the end of qDebug.
Removes the \n in the end of opengl output.

REVIEW: 124320
2015-07-20 13:36:27 +02:00
Rohan Garg
c22fdcf146 Return unless glDebugMessageCallback resolves on GLES
REVIEW: 124135
2015-06-26 12:43:08 +02:00
Thomas Lübking
ff2590ac52 fix compilation on older gcc (at least 4.8.3)
thanks to Hrvoje Senjan for bringing this up
REVIEW: 123936
2015-06-10 08:50:17 +02:00
Thomas Lübking
9f13e9b260 WORKAROUND for nvidia VBO failures
When switching virtual terminals,
suspending to ram and resizing the
screen (GL viewport) at least the
nvidia driver moves VBO data between
the video RAM and the system heap -
and something about this isn't reliable:

An often perceived resulted are scattered
windows but it may also be the cause for
entirely black screens reported for same
occasions.

As a workaround, we hook into the GL debug
messages and filter them for the suspicious
message, then re-init VBOs

TODO:
figure whether that's our fault or nvidias

REVIEW: 123936
CCBUG: 344326

Patch applies to KWin 5.4
2015-06-03 21:38:55 +02:00
Martin Gräßlin
2a64755b76 Improve the rendering per output in SceneOpenGL/EglGbmBackend
The complete rendering is now splitted per output including present which
means that we only need to make the context per output current once per
rendering.

Unfortunately our architecture does not properly support gathering the
damage for multiple outputs. In fact the damage information is lost after
the first output got rendered. Thus we currently only support buffer age
for the first output, on other outputs full repaints are caused.
2015-04-24 12:03:20 +02:00
Martin Gräßlin
7c8c1dac0a [SceneOpenGL] Render per DrmOutput in EglGbmBackend
For each DrmOutput a gbm_surface and EglSurface is created. When
rendering per screen the context is made current on each of the
surfaces.

Note: viewport handling needs to be improved by e.g. passing through
the scene to restore to correct viewport after dropping an FBO.

Furthermore it seems like buffer age is not working correctly in this
setup (not overly surprising).

Dynamic changes are not yet supported.
2015-04-24 12:03:20 +02:00
Martin Gräßlin
e1ae0b8bc4 [wayland] Create OpenGLBackend through the AbstractBackend
Replaces casting logic in the SceneOpenGL. Now the create is delegated
to the backend allowing also to move the ifdef logic to where it belongs.
2015-04-01 11:05:45 +02:00
Martin Gräßlin
219946edce Fix build with HAVE_WAYLAND and HAVE_X11_XCB but no HAVE_WAYLAND_EGL
Let's try again.
2015-03-24 10:50:46 +01:00
Martin Gräßlin
2d1622ea09 Fix build without Wayland, but with HAVE_X11_XCB
Build error in SceneOpenGL.
2015-03-24 10:43:48 +01:00
Martin Gräßlin
49f58059c6 [wayland] Backends are no longer singletons
They are installed in the WaylandServer, thus we don't need an explicit
singleton accessor. If we need to differentiate we can cast.
2015-03-23 14:29:07 +01:00
Simeon Bird
1de1e80d50 Fix hang on nvidia hardware when deleting sync objects
When a sync object is deleted, the fence it is connected to must already
be signalled, or the driver will busy-wait forever.
Signal fences before deleting syncs to avoid this.

BUG: 343551
FIXED-IN: 5.3
REVIEW: 123090
2015-03-22 23:55:48 -04:00
Martin Gräßlin
a1642a85d3 Allow using EGLOnXBackend with X11WindowedBackend
Mostly refactoring to not take the global X11 information (connection,
display, etc.). Adds a dedicated ctor overload which takes the
X11WindowedBackend.

SceneOpenGL is adjusted to create an EGLOnXBackend instead of Wayland one
if the X11WindowedBackend is used.
2015-03-20 14:08:54 +01:00
Martin Gräßlin
147af71f8a Drop Workspace dependency from Scene
Only used for one connect which can also be done outside of Scene.
Subclasses got the singleton pointer and just passed to the parent.
2015-03-17 10:20:19 +01:00
Martin Gräßlin
a0b2a938aa [wayland] Support creating Texture from Wayland shm buffer
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.
2015-03-17 10:08:27 +01:00
Martin Gräßlin
7bbb68aad6 Check GL version and/or extension for using texture format GL_R8
BUG: 344301
FIXED-IN: 5.2.1
REVIEW: 122615
2015-02-18 09:09:50 +01:00
Tobias C. Berner
ef3f0f753b Add <array> include where needed, to make it build on FreeBSD.
REVIEW: 122090
2015-01-17 15:22:11 +02:00
Fredrik Höglund
2cebf523aa Store shadows in GL_R8 textures when possible 2014-12-30 21:22:04 +01:00
Fredrik Höglund
4d738b86ea Add an internalFormat parameter to the GLTexture ctor
This parameter is ignored on GLES.
2014-12-30 21:19:49 +01:00
Fredrik Höglund
5ac159d47e Fix cross-fading
We have to bind a modulation shader when we're cross-fading.

BUG: 341715
2014-12-14 18:33:52 +01:00
Martin Gräßlin
5ceb1b4f75 Merge branch 'Plasma/5.1'
Conflicts:
	CMakeLists.txt
	geometry.cpp
	kcmkwin/kwincompositing/kcmkwineffects.desktop
	kcmkwin/kwincompositing/kwincompositing.desktop
	kcmkwin/kwindecoration/kwindecoration.desktop
	kcmkwin/kwindesktop/desktop.desktop
	kcmkwin/kwinoptions/kwinactions.desktop
	kcmkwin/kwinoptions/kwinadvanced.desktop
	kcmkwin/kwinoptions/kwinfocus.desktop
	kcmkwin/kwinoptions/kwinmoving.desktop
	kcmkwin/kwinoptions/kwinoptions.desktop
	kcmkwin/kwinrules/kwinrules.desktop
	kcmkwin/kwinscreenedges/kwinscreenedges.desktop
	kcmkwin/kwintabbox/kwintabbox.desktop
	scripts/enforcedeco/metadata.desktop
2014-12-10 13:52:27 +01:00
Daniel Pastushchak
0d997b1093 Introduce categorized logging for kwin core
Done by Daniel Pastushchak for KDE during GCI-2014.
2014-12-05 14:27:15 +01:00
Fredrik Höglund
f8d1a0868a Test the generated shaders on startup
Compile and bind each shader in turn and render a textured quad.
2014-12-04 19:19:30 +01:00
Fredrik Höglund
99f9d613e9 Change the default shader in SceneOpenGL2
Push a shader that just does texture lookups. This shader is the one
most likely to be used.
2014-12-04 19:19:30 +01:00
Fredrik Höglund
d2cb9f9bf6 Add a model-view and a projection matrix in WindowPaintData
Effects currently modify the matrices by reading back the uniform
values from the shader they assume will be used to paint the window,
set new values for the uniforms, call paintWindow(), and then restore
the uniforms to their previous values.

This is both slow and unreliable, and will not work with dynamically
generated shaders.

This patch solves the problem by putting the matrices in
WindowPaintData and making it the responsibility of the paintWindow()
implementation to set the uniforms.
2014-12-04 19:19:30 +01:00
Fredrik Höglund
0d2b2bc8b3 Use the new ShaderManager API in SceneOpenGL2 2014-12-04 19:19:29 +01:00
Martin Gräßlin
b5a626c2d7 Introduce a texture cache for DecorationShadows in SceneOpenGLShadow
The DecorationShadow supports the concept of sharing shadows between
multiple Decorations and this is supported by our Shadow class. But
still the created GLTextures were not shared.

This change introduces a sharing mechanismn for all GLTextures created
for a DecorationShadow. Thus if two decorations share the same
DecorationShadow they will also share the same GLTexture.
2014-12-04 10:36:19 +01:00