src/video/kmsdrm/SDL_kmsdrmopengles.c


Log

Author Commit Date CI Message
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Anthony Pesch fc508eab 2021-05-23T15:59:20 kmsdrm: remove redundant modeset_pending flag this variable was added in commit 2067a7db8e4a36ba40ab34a55b3166ca28638a60 and ultimately tracks if this is a surface's first present. checking if the current bo is NULL provides the same functionality and cuts down on a redundant piece of state potentially getting out of sync in the future
Anthony Pesch 4c965b7a 2021-05-23T16:09:27 kmsdrm: fix SetDisplayMode binding the the wrong surface / context SetDisplayMode needs to recreate the EGL surfaces, which then need to be bound along with the correct context in each rendering thread commit 3a1d7d9c9ac670bf35cfa8ebf3706a1e2a3e5de4 removed this behavior which has broken using SetDisplayMode when rendering with multiple contexts the commit message was rather vague, but if the surfaces do need to be created immediately, this process probably needs to be split such that surface is created immediately, but the binding is deferred
Vanfanel 8638674a 2021-03-18T13:55:58 [KMSDRM] Correct comment typo.
Manuel Alfayate Corchete 6ee53258 2021-02-06T14:03:53 [KMS/DRM] Replace indent tabs with spaces, as intended.
Manuel Alfayate Corchete bfa51c38 2021-01-31T03:48:29 [KMS/DRM] Fix for bug #5518: only do async pageflips when hardware supports them.
Manuel Alfayate Corchete 03665004 2021-01-15T15:00:17 [KMS/DRM] Small fix to KMSDRM_Waitpageflip(). More comments on how it works.
Manuel Alfayate Corchete 1adadc77 2021-01-14T10:18:40 [KMS/DRM] Adjust come return values. Improve comments.
Manuel Alfayate Corchete ead3c406 2021-01-13T20:11:01 [KMS/DRM] Refactor, improve and re-comment async pageflips code.
Manuel Alfayate Corchete aac74db6 2021-01-13T15:54:26 [KMS/DRM] Enable async pageflips.
Manuel Alfayate Corchete 85e8adf7 2021-01-11T22:28:27 [KMS/DRM] Unused code cleaning.
Manuel Alfayate Corchete 2067a7db 2021-01-11T20:29:09 [KMS/DRM] Fix fullscreen to windowed transition. Fix aspect ratio correction without using planes.
Manuel Alfayate Corchete 850d9c8c 2021-01-09T02:25:13 [KMS/DRM] Cleanup remainings from plane/scaling usage.
Manuel Alfayate Corchete 2aeb3177 2021-01-08T22:00:28 [KMS/DRM] Fix vkQuake3 in OpenGL mode.
Manuel Alfayate Corchete b2449473 2021-01-08T18:57:12 [KMS/DRM] Go back to the LEGACY interface only because using planes breaks compatibility with HW, so no advantage on using ATOMIC.
Manuel Alfayate Corchete cef1bd06 2021-01-08T13:14:42 [KMS/DRM] Prevent creating another default cursor everytime a window is created. Other fixes and cleanups.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Manuel Alfayate Corchete 21003b7d 2020-12-31T14:31:29 [KMS/DRM] Small refactoring on the SwapWindow function.
Manuel Alfayate Corchete e34caa97 2020-12-31T01:31:57 [KMS/DRM] Correct EGL/GL library loading on window creation, thus saving window re-creation.
Manuel Alfayate Corchete 427c96ec 2020-12-29T14:24:38 [KMS/DRM] Rework some functions.
Manuel Alfayate Corchete 0feaf7d1 2020-12-28T14:37:58 [KMS/DRM][Vulkan] Correct non-existing property. Remove hacky surface destruction code (TTY buffer isn't there after a Vulkan window is created).
Manuel Alfayate Corchete 2fc987c2 2020-12-22T14:15:33 [Buildsystem] Add guards for not building with KMSDRM support if EGL is not available.
Manuel Alfayate Corchete f60f8d5d 2020-12-18T22:53:51 [Video/KMSDRM]: Add Vulkan support to the KMSDRM backend.
Manuel Alfayate Corchete 87a86675 2020-10-22T16:01:51 kmsdrm: Always use spaces for indentation. Always use SDL_calloc() for calloc.
Manuel Alfayate Corchete 0cb9bfa5 2020-09-12T15:58:47 kmsdrm: less excessive error checkhing
Manuel Alfayate Corchete 5bed30dd 2020-09-12T04:56:55 kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered().
Manuel Alfayate Corchete 9e9227ad 2020-09-12T04:52:56 kmsdrm: reimplement modesetting for fullscreen window scaling and AR-correction.
Manuel Alfayate Corchete a6d182d3 2020-09-11T23:47:26 kmsdrm: no need to reconnect/reactivate things in SwapWindowDoubleBuffered().
Manuel Alfayate Corchete 47e2d030 2020-09-10T23:26:02 kmsdrm: greatly improve comments in SwapBuffersFenced() for future reference.
Ryan C. Gordon 3c6004fe 2020-09-10T15:07:23 kmsdrm: Choose how to swap buffers based on EGL extension availability.
Ryan C. Gordon c7e761f8 2020-09-10T15:05:55 kmsdrm: Patched to compile if EGL headers lack EGL_ANDROID_native_fence_sync.
Ryan C. Gordon 224aa45b 2020-09-10T15:04:35 kmsdrm: Implement GL_DefaultProfileConfig for Raspberry Pi compatibility. If we think this might be a Raspberry Pi device, default to ES2. Otherwise, accept SDL's higher-level defaults.
Manuel Alfayate Corchete 055cad49 2020-09-10T02:15:53 kmsdrm: no need to re-connect/reactivate things in SwapWindow() anymore because we use a dumb buffer on KMS buffers destruction now.
Manuel Alfayate Corchete daa752b1 2020-09-06T23:19:54 kmsdrm: fix first frame display: no need to wait for SwapWindow() for EGL surface creation.
Manuel Alfayate Corchete 68ac9349 2020-09-06T12:48:39 kmsdrm: more coherent returns for SwapWindow.
Manuel Alfayate Corchete d3d9d432 2020-09-06T12:17:27 kmsdrm: Remove debug printfs in SwapWindow.
Manuel Alfayate Corchete d7aebbd5 2020-09-06T12:08:22 kmsdrm: Don't create surfaces until EGL context is available.
Manuel Alfayate Corchete f4e02a5c 2020-08-31T19:17:17 kmsdrm: Do NOT modify window size manually from the backend: doing so caused renderer scaling params miscalculation.
Manuel Alfayate Corchete 31b17945 2020-08-28T22:38:26 kmsdrm: use PLANE and CRTC to do hardware-driven window scaling and AR-correction.
Manuel Alfayate Corchete 9b43464d 2020-08-25T16:30:23 kmsdrm: Add programmer credits to the Atomic KMSDRM driver.
Manuel Alfayate Corchete 9316a8d9 2020-08-25T16:18:49 kmsdrm: move FENCE FD props setting to SwapWindow(), where it belongs.
Manuel Alfayate Corchete d43e666e 2020-08-25T04:05:36 kmsdrm: Buffer management refactoring. Fixes for compatibility with more video drivers.
Manuel Alfayate Corchete 0d593d7e 2020-08-23T23:44:07 kmsdrm: Add error control to plane prop setting function. Do most plane prop setting with a single function.
Manuel Alfayate Corchete 0b7b7721 2020-08-23T03:13:50 kmsdrm: remove redundant function, use drm_atomic_setbuffers() for disconnecting planes instead.
Manuel Alfayate Corchete 16c04f26 2020-08-23T02:58:57 kmsdrm: Init cursor surface on SetCursor() ONLY. Removal of dynamic modeset because it causes A LOT of problems with some kernel video drivers. Some refactoring and cleanups.
Manuel Alfayate Corchete 5d32eda9 2020-08-19T01:31:22 kmsdrm: implement smarter surface recreation function to be used in videomode changes. Other minor arrangements.
Manuel Alfayate Corchete 92cb9192 2020-08-17T18:35:04 kmsdrm: move hardware cursor functionality to the ATOMIC interface. Disconnect the display plane from the GBM surface buffers before destroying the GBM surface.
Manuel Alfayate Corchete c437729b 2020-08-08T14:27:55 kmsdrm: separate requests in different functions so we only need one atomic commit for everything, as expected by atomic design.
Manuel Alfayate Corchete 3b9f1073 2020-08-07T11:53:04 kmsdrm: wait for possible pending atomic commits before destroying surfaces, and before restoring video on quit. Move messages to the SDL_Log* functions.
Manuel Alfayate Corchete 96c99693 2020-08-06T01:36:56 kmsdrm: wait for pending atomic commits before restoring videomode and crtc->buffer on VideoQuit, and simplify double-buffer SwapWindow() implementation.
Manuel Alfayate Corchete 09692b61 2020-08-05T18:55:22 kmsdrm: move videomode restoration on VideoQuit() to using the atomic interface instead of the legacy drmModeSetCrtc() function. Refactoring of get_plane_id().
Manuel Alfayate Corchete 2d69ce08 2020-08-05T02:06:59 kmsdrm: double and triple buffered versions of SwapWindow() are now both reimplemented in atomic pageflipping versions, and can be selected via SDL_VIDEO_DOUBLE_BUFFER env variable.
Manuel Alfayate Corchete 8996ee17 2020-08-03T22:24:49 kmsdrm: update SwapWindow fn, moving it to triple-buffer.
Manuel Alfayate Corchete b131661c 2020-08-01T18:23:34 kmsdrm: rewrite the new SwapWindow() fn to avoid tearing. Double-buffer only for now.
Manuel Alfayate Corchete 1a5503ce 2020-07-28T21:11:25 kmsdrm: Moved to the ATOMIC KMS/DRM interface for buffer swapping, leaving DRM-legacy behind.
Manuel Alfayate Corchete 412b21b0 2020-07-20T11:42:23 Rename the gbm device struct from gbm to gbm_dev for better readabilty.
Manuel Alfayate Corchete b6a818b6 2020-07-19T18:45:29 Fix SDL_Window recreation: drmModeSetCrtc() has to be called everytime the EGL and GBM surfaces are recreated.
Sam Lantinga 1df0a1e4 2020-05-26T16:27:00 Fixed bug 5140 - KMSDRM: Dynamic vsync toggle does not work Manuel Alfayate Corchete The KMSDRM backend was doing things wrong because of some small (but important) misconceptions on how KMS/DRM works: to implement a largely broken non-vsync refresh mechanism, the SwapWindow() function was issuing new pageflips before previous ones had completed, thus causing EBUSY returns, buffer mismanagement, etc... resulting in general breakage on vsync disabling from apps, that would not allow vsync to work again without KMSDRM video re-initialization. To further clarify, on most DRM drivers async pageflips are NOT working nowadays, so all issued pageflips will complete on next VBLANK, NOT ASAP (calling drmModePageFlip() with the DRM_MODE_PAGE_FLIP_ASYNC flag will return error). The old code was assuming that can just issue a synchronous (=on VBLANK) pageflip and then pass a 0 timeout to the pull() function so we do not wait for the pageflip event, thinking that this will lead to correct non-vsynced screen updates from the program: That is plain wrong. Each pageflip has to be waite before issuing a new one, ALWAYS. And if we do not support ASYNC pageflips on the DRM driver level, then we are forced to wait for the next VBLANK. There is no way around it. I have also added many comments on the KMSDRM code. This is needed for future reference for me or others who may need to look at this code: KMS/DRM terminology regarding what SYNC and ASYNC mean in pageflip terms, and where to do certain things and why, is not trivial. It is not desirable or possible to invest time on researching the same concepts every time there is need to dive into this code. So please leave all these comments in the patch.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga 9013c916 2020-02-27T08:20:34 Fixed bug 5005 - warnings in kmsdrm Malte Kie?ling At the moment i get following warnings from kmsdrm: * in SDL_kmsdrmvideo.c KMSDRM_DestroySurfaces is return type int, but thats never returned or checked against * in SDL_kmsdrmvideo.c KMSDRM_DestroySurfaces the variable viddata is not used * in SDL_kmsdrmopengles.c KMSDRM_GLES_LoadLibrary a cast to NativeDisplayType is missing I attached a patch for them :)
Sam Lantinga 35704c98 2020-02-14T16:17:17 Fixed bug 4980 - Build fails for SDL_kmsdrm*.c Malte Kie?ling Since https://hg.libsdl.org/SDL/rev/f908bd722523 / bug 4966 i cannot build SDL anymore. The error i get is, essentially, caused by -Werror=declaration-after-statement in SDL_kmsdrmvideo.c and SDL_kmsdrmopengles.c
Sam Lantinga 3e935aec 2020-02-09T11:44:22 Fixed bug 4966 - KMSDRM: Add dynamic modeset support Anthony Pesch * Remove triple buffering support. As far as I can tell, this goes against the libdrm API; the EGL implementations themselves control the buffering. Removing it isn't absolutely necessary as it seemingly works on the Pi at least, but I noticed this while doing my work and explained my reasoning in the commit. * Replace the crtc_ready logic which allocates an extra bo to perform the initial CRTC configuration (which is required before calling drmModePageFlip) with a call to drmModeSetCrtc after the front and back buffers are allocated, avoiding this allocation. * Standardized the SDL_*Data variable names and null checks to improve readability. Given that there were duplicate fields in each SDL_*Data structure, having generic names such as "data" at times was very confusing. * Removed unused fields from the SDL_*Data structures and moves all display related fields out of SDL_VideoData and into SDL_DisplayData. Not required since the code only supports a single display right now, but this was helpful in reading and understanding the code initially. * Implement KMSDRM_GetDisplayModes / KMSDRM_SetDisplayMode to provide dynamic modeset support. These changes have been tested on a Raspberry Pi 4 and a Dell XPS laptop with an HD 520. As an update, I went back over the triple buffer changes and left them in. I didn't entirely get the code originally, I had just seen it calling KMSDRM_gbm_surface_lock_front_buffer twice for a single swap and had removed it because I was paranoid of bugs stemming from it while working on the modeset changes. I've made a few small changes to the logic that had thrown me off originally and rebased the changes: * The condition wrapping the call to release buffer was incorrect. * The first call to KMSDRM_gbm_surface_lock_front_buffer has been removed. I don't understand why it existed. * Added additional comments describing what was going on in the code (as it does fix the buffer release pattern of the original code before it).
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Conn O'Griofa 2d37d291 2019-09-06T08:44:46 KMSDRM_GLES_SwapWindow: fix non-vsync case If KMSDRM_drmModeSetCrtc is called when the swap interval is set to 0, the driver behaves as though vertical sync is engaged by limiting framerate to the refresh rate, but performance is much worse than with vertical sync enabled. Resolve this issue by ensuring that the Crtc is only set up once, and KMSDRM_drmModePageFlip is called, albeit without any followup queueing or waiting for flips.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 3ac9e2aa 2018-10-05T17:06:05 Fixed bug 4296 - kmsdrm video driver leaks 1 bo in KMSDRM_GLES_SetupCrtc() Icenowy Zheng One front buffer is locked in GLES_SetupCrtc() and overrides the next_bo just locked in KMSDRM_GLES_SwapWindow, then the next_bo gets lost and is not released even when quitting the video. It may leads to problems with GLES drivers that doesn't clean up GBM correctly if there's any bo left (e.g. the Mali Utgard r6p2 blob). In the case of Mali Utgard r6p2 blob, the DRM device file is still hold by the blob, and if you try to SDL_Quit to let another program to run (this is done by EmulationStation), the new program will fail to open DRM device.
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Brandon Schaefer 2ac567b7 2017-10-26T16:37:20 Fixed bug 3902 - Add a specific KMSDRM hint for low latency video
Sam Lantinga 10376eb9 2017-10-21T04:20:57 Fixed bug 3901 - Fix vsync-ed pageflips on the KMSDRM video driver Manuel I noticed that, at least on Intel GPU hardware, passing SDL_RENDERER_PRESENTVSYNC would result on a static console instead of the program graphics. That was due to the fact that calling drmModePageFlip() only works if we have previously set up CRTC to one of the GBM buffers with a drmModeSetCrtc() call, so now it's done and things work as expected. The KMSDRM_GLES_SetupCrtc() call is done only one time, only when needed (when egl_swapinterval is not 0: when it's 0, there's no need for it because we flip by calling drmModePageFlip() anyway). The place where KMSDRM_GLES_SetupCrtc() call is done may look strange, but it's right: it needs EGL completely ready because it needs to call eglSwapBuffers() internally to work (see more comments about it in the code).
Brandon Schaefer 11717184 2017-08-21T17:20:50 kmsdrm: Cleanup unused headers, rename SDL_kmsdrmevents_c.h -> SDL_kmsdrmevents.h
Philipp Wiesemann f216b446 2017-08-05T22:10:36 kmsdrm: Fixed crashes if allocating memory failed.
Brandon Schaefer 86e95a60 2017-08-02T17:45:15 kmsdrm: Fix tearing in neverputt/ball https://gfycat.com/FatalFarawayHeron
Sam Lantinga 56363ebf 2017-08-02T10:22:48 Fixed bug 3690 - SDL2 KMS/DRM render context support Manuel The attached patch adds support for KMS/DRM context graphics. It builds with no problem on X86_64 GNU/Linux systems, provided the needed libraries are present, and on ARM GNU/Linux systems that have KMS/DRM support and a GLES2 implementation. Tested on Raspberry Pi: KMS/DRM is what the Raspberry Pi will use as default in the near future, once the propietary DispmanX API by Broadcom is overtaken by open graphics stack, it's possible to boot current Raspbian system in KMS mode by adding "dtoverlay=vc4-kms-v3d" to config.txt on Raspbian's boot partition. X86 systems use KMS right away in every current GNU/Linux system. Simple build instructions: $./autogen.sh $./configure --enable-video-kmsdrm $make