mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
backend/drm: fix GBM format mismatch
We create the EGL config with GBM_FORMAT_ARGB8888, but then initialize GBM BOs with GBM_FORMAT_XRGB8888. This mismatch confuses Mesa. Instead, we can always use GBM_FORMAT_ARGB8888, and use DRM_FORMAT_XRGB8888 when calling drmModeAddFB2. Fixes https://github.com/swaywm/wlroots/issues/1438
This commit is contained in:
parent
018727b1fc
commit
ee293fab58
7 changed files with 46 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#include <assert.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <drm_mode.h>
|
||||
#include <drm.h>
|
||||
#include <gbm.h>
|
||||
|
|
@ -176,12 +178,16 @@ static void free_fb(struct gbm_bo *bo, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t get_fb_for_bo(struct gbm_bo *bo) {
|
||||
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format) {
|
||||
uint32_t id = (uintptr_t)gbm_bo_get_user_data(bo);
|
||||
if (id) {
|
||||
return id;
|
||||
}
|
||||
|
||||
assert(gbm_bo_get_format(bo) == GBM_FORMAT_ARGB8888);
|
||||
assert(drm_format == DRM_FORMAT_ARGB8888 ||
|
||||
drm_format == DRM_FORMAT_XRGB8888);
|
||||
|
||||
struct gbm_device *gbm = gbm_bo_get_device(bo);
|
||||
|
||||
int fd = gbm_device_get_fd(gbm);
|
||||
|
|
@ -190,9 +196,9 @@ uint32_t get_fb_for_bo(struct gbm_bo *bo) {
|
|||
uint32_t handles[4] = {gbm_bo_get_handle(bo).u32};
|
||||
uint32_t pitches[4] = {gbm_bo_get_stride(bo)};
|
||||
uint32_t offsets[4] = {gbm_bo_get_offset(bo, 0)};
|
||||
uint32_t format = gbm_bo_get_format(bo);
|
||||
|
||||
if (drmModeAddFB2(fd, width, height, format, handles, pitches, offsets, &id, 0)) {
|
||||
if (drmModeAddFB2(fd, width, height, drm_format,
|
||||
handles, pitches, offsets, &id, 0)) {
|
||||
wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue