4 ms·
These days, a game has at least double buffering. This means one frame is currently displayed on the monitor (front buffer) and one frame is being drawn by the
by heftig 5y ago
These days, a game has at least double buffering. This means one frame is currently displayed on the monitor (front buffer) and one frame is being drawn by the game (back buffer).
In a classic "fullscreen game" situation, whenever a back buffer is finished, the game would configure the GPU's CRTC (the hardware that generates the data stream that goes to the monitor) to read from this back buffer instead. This turns the back buffer into the current front buffer and releases the old front buffer to act as the next back buffer ("page flipping").
When this happens without any synchronization with the monitor, the buffer can be changed in the middle of the frame, causing the characteristic tearing. With VSync, the game delays the swap until the monitor is between frames.
With Wayland, the game swaps buffers with the compositor instead. Direct scanout means that the compositor will configure the CRTC to read from the game's front buffer. So this is really similar to the "classic" situation, except it involves a bit of inter-process communication.
Otherwise, the compositor has its own set of front and back buffer, and the game's front buffer is copied (composited) into the compositor's back buffer first. So we have another buffer swap that has to be done, and this is what causes the composition lag.
Whether direct scanout happens or not is transparent to the game, which does not need to care.
Wayland enforces VSync by default, though there's a protocol being designed (`zwp_tearing_control_unstable_v1`) so a game can request asynchronous flipping.
- voldacar 5y agoThanks for the explantion. I already knew about double buffering but for whatever reason my brain didn't make the connection.
- vbphprubyjsgo 5y agoAh, so this "direct scanout" is just an improvement over the previous bad situation, not an improvement over the classic double buffered vsync, and not a way to give the application the choice to write directly to the active framebuffer during scanout.