I've just stumbled upon the packages libkwinnvidiahack4 Install libkwinnvidiahack4 (and also libkwinactivenvidiahack4 Install libkwinactivenvidiahack4). From the description I understand it provides some "hacks" for the KDE window manager in combination with an Nvidia binary graphics driver.

This package contains a library used by nvidia cards for the KDE window manager.

This package is part of the KDE workspace module.

However, this description lacks what it actually does. I use KDE/Kubuntu and I have the Nvidia graphics driver installed. What are the benefits of installing these packages? What do they do?

I've got the libkwinnvidiahack4 package installed (probably automatically), but I'm not sure what it is responsible for.

Running through the changelogs (apt-get changelog libkwinnvidiahack4) give me the kde-workspace changelog with an entry (several snippets taken from it):

  • Move libkwinnvidiahack4 to its own package
  • Add the packages

    • kde-window-manager-active
    • kde-window-manager-active-gles
    • libkwinactiveglutils1
    • libkwinactiveglesutils1
    • libkwinactiveeffects1abi3
    • libkwinactivenvidiahack4
  • kde-window-manager/-gles depends on libkwinnvidiahack4

  • Don't install /usr/lib/libkwinnvidiahack.so. No one is supposed to link against libkwinnvidiahack. Make kdebase-workspace-dev depend on libkdecorations4 and libkwineffects1 instead of kde-window-manager now that kde-window-manager contains nothing one can link against.

which also does not explain why these packages are added and what they do.


After a serious bit of Googling I came across this post:

The only purpose of this file is to be later in the link order than (nvidia's) libGL, thus being initialized by the dynamic linker before it, allowing it to set __GL_YIELD=NOTHING soon enough for libGL to notice it.

Given that the quote is from a certain M-Graesslin, Martin is the chief maintainer in this area, so is a sure-fire source.

Indeed, looking at the source-code

apt-get source libkwinnvidiahack4

This is actually the kde workspace module.

kwin/nvidiahack.cpp is the source module in question - its a small module in itself

Since this hack is still in 13.04 - and is part of the core build, yes its still needed and its purpose is to ensure library linking for the OpenGL component of KDE is done in the correct functional order.

In terms of what the module does - it looks like it defines a runtime environment variable __GL_YIELD

From the freedesktop spec

OpenGL yield behavior

There are several cases where the NVIDIA OpenGL driver needs to wait for external state to change before continuing. To avoid consuming too much CPU time in these cases, the driver will sometimes yield so the kernel can schedule other processes to run while the driver waits. For example, when waiting for free space in a command buffer, if the free space has not become available after a certain number of iterations, the driver will yield before it continues to loop.

By default, the driver calls sched_yield() to do this. However, this can cause the calling process to be scheduled out for a relatively long period of time if there are other, same-priority processes competing for time on the CPU. One example of this is when an OpenGL-based composite manager is moving and repainting a window and the X server is trying to update the window as it moves, which are both CPU-intensive operations.

You can use the __GL_YIELD environment variable to work around these scheduling problems. This variable allows the user to specify what the driver should do when it wants to yield.

Thus the hack is to never wait and always paint on the OpenGL composite surface - most probably to stop graphical artifacts from appearing.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.