kdrive/modesetting: pass the gbm device to glamor

Don't have it open another one

This fixes a segfault when the render card is different from
the scanout card, and glamor uses the fast gbm import path.

If https://github.com/X11Libre/xserver/issues/2645
applies to Xmodesetting, this probably fixes it.

This is also a resource usage optimization,
since glamor doesn't allocate another gbm device
when Xmodesetting already allocates a perfectly usable one.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
This commit is contained in:
stefan11111 2026-10-14 23:14:09 +03:00 • committed by Enrico Weigelt
commit 29a6b17197
3 changed files with 4 additions and 0 deletions

View file

@ -129,6 +129,8 @@ msGlamorInit(ScreenPtr pScreen)
uint32_t format;
int write_pos = 0;
config->glamor_info.gbm = priv->gbm;
if (!config->glamor_info.dri_path) {
config->glamor_info.dri_fd = dup(gbm_device_get_fd(priv->gbm));
if (config->glamor_info.dri_fd >= 0) {

View file

@ -78,6 +78,7 @@ KdGlamorInit(ScreenPtr pScreen, KdGlamorInfo *info, int *caps)
.glvnd_vendor = info->glvnd,
.fd = -1,
.gbm_forbidden = !info->use_gbm,
.gbm = info->gbm,
.direct_dri3_only = info->direct_dri3,
.auto_dri = FALSE, /* deprecated */
.partial_dri_allowed = FALSE, /* deprecated */

View file

@ -12,6 +12,7 @@ typedef struct {
/* Passed to glamor_egl */
const char* glvnd; /* glvnd vendor library or driver name */
const char* dri_path; /* /dev/dri/[cardxx|renderDxxx] */
void* gbm; /* Optional gbm device to pass to glamor */
Bool use_gbm; /* If glamor should try to use libgbm */
Bool direct_dri3; /* If glamor should only use the direct DRI3 implementation */
Bool force_gl; /* If glamor should only create desktop gl contexts */