Possible solution for scheduling repaints on NVIDIA
Needs ReviewPublic

Authored by fredrik on Wed, Sep 11, 5:06 PM.


Group Reviewers

We keep setting __GL_MaxFramesAllowed to 1, but move the blocking glXSwapBuffers() call to a separate thread and synthesize a swap event by emitting a signal when the call returns.

This way we can call glXSwapBuffers() at any point within the swap interval without blocking the main thread, and we can use the same scheduling code with all drivers.

Test Plan

Compile tested only.

Diff Detail

R108 KWin
Lint Skipped
Unit Tests Skipped
fredrik created this revision.Wed, Sep 11, 5:06 PM
Restricted Application added a project: KWin. · View Herald TranscriptWed, Sep 11, 5:06 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
fredrik requested review of this revision.Wed, Sep 11, 5:06 PM
fredrik edited reviewers, added: romangg; removed: ngraham.Wed, Sep 11, 5:27 PM

Also, apart from the above two comments, any thoughts to how this relates to Roman's pending re-work of a lot of the GLX code https://phabricator.kde.org/D23105?


Is this necessary? If the swap thread isn't rendering anything I don't think it actually needs a current context, right?


I'm not 100% sure this is sufficient to ensure all rendering is complete before the swap. It only guarantees that any commands have been submitted to the GPU, but not necessarily that they've all finished executing. Furthermore, glXSwapBuffers should cause an implicit glFlush anyway.

For instance, the glXSwapBuffers spec mentions glFinish for this purpose:

All GLX rendering contexts share the same notion of which are front buffers and which are back buffers. One consequence is that when multiple clients are rendering to the same double-buffered window, all of them should finish rendering before one of them issues the command to swap buffers. The clients are responsible for implementing this synchronization. Typically this is accomplished by executing glFinish and then using a semaphore in shared memory to rendezvous before swapping.