KMSDRM: fix unsupported modifiers

(cherry picked from commit 9548bba63a)
(cherry picked from commit a2215ff81c)
This commit is contained in:
Substring 2024-07-10 20:23:06 +02:00 committed by Sam Lantinga
parent 802351be25
commit 4635f8597d
3 changed files with 20 additions and 2 deletions

View File

@ -133,6 +133,7 @@ SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane);)
#undef SDL_KMSDRM_MODULE
#undef SDL_KMSDRM_SYM

View File

@ -368,16 +368,29 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; i++) {
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
modifiers[i] = modifiers[0];
}
if (modifiers[0]) {
if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) {
flags = DRM_MODE_FB_MODIFIERS;
}
ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
if (ret) {
handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32;
strides[0] = KMSDRM_gbm_bo_get_stride(bo);
offsets[0] = 0;
for (int i = 1; i<4; i++) {
handles[i] = 0;
strides[i] = 0;
offsets[i] = 0;
}
ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, w, h, format, handles, strides, offsets, &fb_info->fb_id, 0);
}
if (ret) {
SDL_free(fb_info);
return NULL;

View File

@ -33,6 +33,10 @@
#include <gbm.h>
#include <EGL/egl.h>
#ifndef DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
#endif
#ifndef DRM_MODE_FB_MODIFIERS
#define DRM_MODE_FB_MODIFIERS 2
#endif