summaryrefslogtreecommitdiff
path: root/src/video/kmsdrm
diff options
context:
space:
mode:
authorManuel Alfayate Corchete <redwindwanderer@gmail.com>2021-01-08 22:00:28 +0100
committerManuel Alfayate Corchete <redwindwanderer@gmail.com>2021-01-08 22:00:28 +0100
commitc94438a218955d10b13579746714e0fa76545446 (patch)
tree873d093d94d4e180b38930d2b0cb8d56d725137e /src/video/kmsdrm
parent59ab17646e89fb6c58ca974fc645e7021484c13b (diff)
downloadsdl-c94438a218955d10b13579746714e0fa76545446.tar.gz
[KMS/DRM] Fix vkQuake3 in OpenGL mode.
Diffstat (limited to 'src/video/kmsdrm')
-rw-r--r--src/video/kmsdrm/SDL_kmsdrmopengles.c20
-rw-r--r--src/video/kmsdrm/SDL_kmsdrmvideo.c28
-rw-r--r--src/video/kmsdrm/SDL_kmsdrmvideo.h1
3 files changed, 35 insertions, 14 deletions
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 8b090b86f..859b786bc 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -91,11 +91,6 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
KMSDRM_FBInfo *fb_info;
int ret, timeout;
- /* Recreate the GBM / EGL surfaces if the display mode has changed */
- if (windata->egl_surface_dirty) {
- KMSDRM_CreateSurfaces(_this, window);
- }
-
/* Wait for confirmation that the next front buffer has been flipped, at which
point the previous front buffer can be released */
timeout = 0;
@@ -135,6 +130,21 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
return 0;
}
+ /* Do we have a modeset pending? If so, configure the new mode on the CRTC.
+ Has to be done before the upcoming pageflip issue, so the buffer with the
+ new size is big enough so the CRTC doesn't read out of bounds. */
+ if (dispdata->modeset_pending) {
+ ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd,
+ dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0,
+ &dispdata->connector->connector_id, 1, &dispdata->mode);
+
+ if (ret) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set videomode on CRTC");
+ }
+
+ return 0;
+ }
+
/* Issue pageflip on the next front buffer.
The pageflip will be done during the next vblank. */
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index cef790d29..e13f105fa 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -49,9 +49,7 @@
#include <poll.h>
#ifdef __OpenBSD__
-eeefine KMSDRM_DRI_PATH "/dev/"
-ce
-
+#define KMSDRM_DRI_PATH "/dev/"
#define KMSDRM_DRI_DEVFMT "%sdrm%d"
#define KMSDRM_DRI_DEVNAME "drm"
#define KMSDRM_DRI_DEVNAMESIZE 3
@@ -889,27 +887,39 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
int
KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
+ /* Set the dispdata->mode to the new mode and leave actual modesetting
+ pending to be done on SwapWindow() via drmModeSetCrtc() */
+
SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata;
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata;
drmModeConnector *conn = dispdata->connector;
int i;
+ /* Don't do anything if we are in Vulkan mode. */
+ if (viddata->vulkan_mode) {
+ return 0;
+ }
+
if (!modedata) {
return SDL_SetError("Mode doesn't have an associated index");
}
+ /* Take note of the new mode to be set. */
dispdata->mode = conn->modes[modedata->mode_index];
+ /* Take note that we have to change mode in SwapWindow(). We have to do it there
+ because we need a buffer of the new size so the drmModeSetCrtc() call succeeds. */
+ dispdata->modeset_pending = SDL_TRUE;
+
for (i = 0; i < viddata->num_windows; i++) {
SDL_Window *window = viddata->windows[i];
- SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
- /* Can't recreate EGL surfaces right now, need to wait until SwapWindow
- so the correct thread-local surface and context state are available */
- windata->egl_surface_dirty = 1;
+ if (KMSDRM_CreateSurfaces(_this, window)) {
+ return -1;
+ }
- /* Tell app about the resize */
+ /* Tell app about the window resize */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h);
}
@@ -1102,6 +1112,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
/* LEGACY-only hardware, so never use drmModeSetPlane(). */
/***************************************************************************/
+#if 1
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
/*fb_info->fb_id*/ -1, 0, 0, &dispdata->connector->connector_id, 1,
&dispdata->mode);
@@ -1110,6 +1121,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set CRTC");
goto cleanup;
}
+#endif
}
/* Add window to the internal list of tracked windows. Note, while it may
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index 9e66cb1e7..1995bb0d7 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -94,7 +94,6 @@ typedef struct SDL_WindowData
SDL_bool waiting_for_flip;
SDL_bool double_buffer;
- int egl_surface_dirty;
EGLSurface egl_surface;
/* For scaling and AR correction. */