Skip to content

plugins/screencast: Preserve modifier order

The SPA_FORMAT_VIDEO_modifier property has the following format:

preferred_value,alternative1,alternative2,...

The preferred value is usually the same as the first alternative value. It can also happen that the modifier list the compositor has supplied is not good either and it contains duplicate entries, specifically DRM_FORMAT_MOD_INVALID to indicate that modifier-less buffers are supported.

In order to deal with that, the screencast plugin removes the duplicates by sorting the modifier list and then using std::unique().

That is not good, there is no written rule that the order of the modifiers passed to the graphics buffer allocator matters but it typically does, some drivers in mesa assume that the modifiers are sorted in the preference order. The graphics buffer allocator might be also very lazy and just look at the first supplied modifier instead of wisely choosing the best modifier.

This change makes the ScreenCastStream remove the duplicate modifiers in a more conservative fashion preserving the relative order of the modifiers. It also removes an extra {DRM_FORMAT_MOD_INVALID} because this kind of thing should be dictated by the render backend.

Edited by Vlad Zahorodnii

Merge request reports

Loading