0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

context_drm_egl: always use drmModeAddFB2WithModifiers

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 <jonas@kwiboo.se>
This commit is contained in:
Jonas Karlman 2024-07-09 20:23:29 +00:00 committed by Philip Langdale
parent 84c18f6b96
commit ea01b042c2

View File

@ -278,36 +278,32 @@ static void update_framebuffer_from_bo(struct ra_ctx *ctx, struct gbm_bo *bo)
fb->height = gbm_bo_get_height(bo); fb->height = gbm_bo_get_height(bo);
uint64_t modifier = gbm_bo_get_modifier(bo); uint64_t modifier = gbm_bo_get_modifier(bo);
int ret; uint32_t handles[4] = {0};
if (p->num_gbm_modifiers == 0 || modifier == DRM_FORMAT_MOD_INVALID) { uint32_t strides[4] = {0};
uint32_t stride = gbm_bo_get_stride(bo); uint32_t offsets[4] = {0};
uint32_t handle = gbm_bo_get_handle(bo).u32; uint64_t modifiers[4] = {0};
ret = drmModeAddFB2(fb->fd, fb->width, fb->height, uint32_t flags = 0;
p->gbm_format,
(uint32_t[4]){handle, 0, 0, 0}, const int num_planes = gbm_bo_get_plane_count(bo);
(uint32_t[4]){stride, 0, 0, 0}, for (int i = 0; i < num_planes; ++i) {
(uint32_t[4]){0, 0, 0, 0}, handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32;
&fb->id, 0); strides[i] = gbm_bo_get_stride_for_plane(bo, i);
} else { offsets[i] = gbm_bo_get_offset(bo, i);
modifiers[i] = modifier;
}
if (modifier && modifier != DRM_FORMAT_MOD_INVALID) {
MP_VERBOSE(ctx, "GBM surface using modifier 0x%"PRIX64"\n", modifier); MP_VERBOSE(ctx, "GBM surface using modifier 0x%"PRIX64"\n", modifier);
flags = DRM_MODE_FB_MODIFIERS;
}
uint32_t handles[4] = {0}; int ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height,
uint32_t strides[4] = {0};
uint32_t offsets[4] = {0};
uint64_t modifiers[4] = {0};
const int num_planes = gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; ++i) {
handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32;
strides[i] = gbm_bo_get_stride_for_plane(bo, i);
offsets[i] = gbm_bo_get_offset(bo, i);
modifiers[i] = modifier;
}
ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height,
p->gbm_format, p->gbm_format,
handles, strides, offsets, modifiers, handles, strides, offsets, modifiers,
&fb->id, DRM_MODE_FB_MODIFIERS); &fb->id, flags);
if (ret) {
ret = drmModeAddFB2(fb->fd, fb->width, fb->height, p->gbm_format,
handles, strides, offsets, &fb->id, 0);
} }
if (ret) { if (ret) {
MP_ERR(ctx->vo, "Failed to create framebuffer: %s\n", mp_strerror(errno)); MP_ERR(ctx->vo, "Failed to create framebuffer: %s\n", mp_strerror(errno));