Skip to content

Commit 180b454

Browse files
committed
kmsdrm: fixed creating GBM surfaces on NVIDIA cards
(cherry picked from commit fc1c061)
1 parent 6ce7ae7 commit 180b454

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/video/kmsdrm/SDL_kmsdrmvideo.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,9 +1368,14 @@ bool KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window)
13681368
windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev,
13691369
dispdata->mode.hdisplay, dispdata->mode.vdisplay,
13701370
surface_fmt, surface_flags);
1371-
1371+
if (!windata->gs && errno == ENOSYS) {
1372+
// Try again without the scanout flags, needed on NVIDIA drivers
1373+
windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev,
1374+
dispdata->mode.hdisplay, dispdata->mode.vdisplay,
1375+
surface_fmt, 0);
1376+
}
13721377
if (!windata->gs) {
1373-
return SDL_SetError("Could not create GBM surface");
1378+
return SDL_SetError("Could not create GBM surface: %s", strerror(errno));
13741379
}
13751380

13761381
/* We can't get the EGL context yet because SDL_CreateRenderer has not been called,
@@ -1731,7 +1736,7 @@ bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
17311736
/* Create the window surfaces with the size we have just chosen.
17321737
Needs the window driverdata in place. */
17331738
if (!KMSDRM_CreateSurfaces(_this, window)) {
1734-
return SDL_SetError("Can't create GBM/EGL surfaces on window creation.");
1739+
return false;
17351740
}
17361741
} // NON-Vulkan block ends.
17371742

0 commit comments

Comments
 (0)