Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drm_prime: fix use of formats with modifiers #14508

Merged
merged 2 commits into from
Aug 11, 2024

Conversation

Kwiboo
Copy link
Contributor

@Kwiboo Kwiboo commented Jul 9, 2024

Similar to handles the modifiers must be supplied for each plane of the format or a framebuffer cannot be created.

Use the format_modifier tied to the object used for the plane to fix use of formats with modifiers.

Also fix the improper use of the DRM_MODE_FB_MODIFIERS-flag for formats without modifiers.

This changes to always use drmModeAddFB2WithModifiers for all formats and with proper use of the DRM_MODE_FB_MODIFIERS-flag all formats with or without modifiers should be supported. The fallback to use drmModeAddFB2 is kept just in case.

This fixes playback of videos decoded by e.g. rpivid into NV12 format with SAND128 modifer on RPi5 using the drmprime-overlay interop.

Copy link

github-actions bot commented Jul 9, 2024

Download the artifacts for this pull request:

Windows
macOS

Similar to handles the modifiers must be supplied for each plane of the
format or a framebuffer cannot be created.

Use the format_modifier tied to the object used for the plane to fix use
of formats with modifiers.

Also fix the improper use of the DRM_MODE_FB_MODIFIERS-flag for formats
without modifiers.

This fixes playback of videos decoded by e.g. rpivid into a NV12 format
using SAND128 modifer on RPi using the drmprime-overlay interop.

Signed-off-by: Jonas Karlman <[email protected]>
Change to always use drmModeAddFB2WithModifiers for all formats and fall
back on using drmModeAddFB2 if drmModeAddFB2WithModifiers fail.

With the DRM_MODE_FB_MODIFIERS-flag now only being used for formats with
modifiers all formats without modifiers should also work.

Signed-off-by: Jonas Karlman <[email protected]>
@Kwiboo
Copy link
Contributor Author

Kwiboo commented Jul 9, 2024

Updated to always use drmModeAddFB2WithModifiers for all formats and also include a similar DRM_MODE_FB_MODIFIERS-flag fix in context_drm_egl.c.

The change to always use gbm_bo_get_plane_count should be safe, it was added in mesa/libgbm 17.1 and that is the minimum version required for libgbm.

video/out/drm_prime.c Show resolved Hide resolved
video/out/drm_prime.c Show resolved Hide resolved
@Kwiboo
Copy link
Contributor Author

Kwiboo commented Aug 11, 2024

Also fix the improper use of the DRM_MODE_FB_MODIFIERS-flag for formats without modifiers.

This changes to always use drmModeAddFB2WithModifiers for all formats and with proper use of the DRM_MODE_FB_MODIFIERS-flag all formats with or without modifiers should be supported. The fallback to use drmModeAddFB2 is kept just in case.

This statement is not fully true, the use of DRM_MODE_FB_MODIFIERS should be used when a display driver expose modifiers capability.

The use of modifiers in a format is a good indicator that driver will support modifiers. The only possible downside to not fully checking for this capability is that display drivers that support modifiers may choose to use a format with modifier when the DRM_FORMAT_MOD_LINEAR=0 modifier is used. This should not really matter as the drmModeAddFB2WithModifiers treat the call same as if drmModeAddFB2 would have been called when flags=0.

@philipl philipl merged commit ea01b04 into mpv-player:master Aug 11, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants