GL/Context: Support fbdev

This commit is contained in:
Connor McLaughlin 2021-02-14 02:51:26 +10:00
parent f5d7fec914
commit f7426b0988
4 changed files with 25 additions and 3 deletions

View File

@ -37,7 +37,8 @@ if(LINUX OR ANDROID)
option(USE_EGL "Support EGL OpenGL context creation" ON) option(USE_EGL "Support EGL OpenGL context creation" ON)
endif() endif()
if(LINUX AND NOT ANDROID) if(LINUX AND NOT ANDROID)
option(USE_DRMKMS "Support DRM/KMS display and contexts" OFF) option(USE_DRMKMS "Support DRM/KMS OpenGL contexts" OFF)
option(USE_FBDEV "Support FBDev OpenGL contexts" OFF)
endif() endif()
# Force EGL when using Wayland # Force EGL when using Wayland
@ -115,11 +116,17 @@ if(USE_WAYLAND)
find_package(Wayland REQUIRED Egl) find_package(Wayland REQUIRED Egl)
message(STATUS "Wayland support enabled") message(STATUS "Wayland support enabled")
endif() endif()
if(USE_DRMKMS AND USE_FBDEV)
message(FATAL_ERROR "Only one of DRM/KMS and FBDev can be enabled")
endif()
if(USE_DRMKMS) if(USE_DRMKMS)
find_package(GBM REQUIRED) find_package(GBM REQUIRED)
find_package(Libdrm REQUIRED) find_package(Libdrm REQUIRED)
message(STATUS "DRM/KMS support enabled") message(STATUS "DRM/KMS support enabled")
endif() endif()
if(USE_FBDEV)
message(STATUS "FBDev Support enabled")
endif()
# Set _DEBUG macro for Debug builds. # Set _DEBUG macro for Debug builds.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")

View File

@ -182,6 +182,13 @@ if(USE_EGL)
) )
target_link_libraries(common PUBLIC GBM::GBM) target_link_libraries(common PUBLIC GBM::GBM)
endif() endif()
if(USE_FBDEV)
target_compile_definitions(common PRIVATE "-DUSE_FBDEV=1")
target_sources(common PRIVATE
gl/context_egl_fbdev.cpp
gl/context_egl_fbdev.h
)
endif()
endif() endif()
if(USE_X11) if(USE_X11)

View File

@ -16,13 +16,16 @@ Log_SetChannel(GL::Context);
#endif #endif
#ifdef USE_EGL #ifdef USE_EGL
#if defined(USE_WAYLAND) || defined(USE_GBM) || defined(USE_X11) #if defined(USE_WAYLAND) || defined(USE_GBM) || defined(USE_FBDEV) || defined(USE_X11)
#if defined(USE_WAYLAND) #if defined(USE_WAYLAND)
#include "context_egl_wayland.h" #include "context_egl_wayland.h"
#endif #endif
#if defined(USE_GBM) #if defined(USE_GBM)
#include "context_egl_gbm.h" #include "context_egl_gbm.h"
#endif #endif
#if defined(USE_FBDEV)
#include "context_egl_fbdev.h"
#endif
#if defined(USE_X11) #if defined(USE_X11)
#include "context_egl_x11.h" #include "context_egl_x11.h"
#endif #endif
@ -129,6 +132,11 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version
context = ContextEGLGBM::Create(wi, versions_to_try, num_versions_to_try); context = ContextEGLGBM::Create(wi, versions_to_try, num_versions_to_try);
#endif #endif
#if defined(USE_FBDEV)
if (wi.type == WindowInfo::Type::Display)
context = ContextEGLFBDev::Create(wi, versions_to_try, num_versions_to_try);
#endif
if (!context) if (!context)
return nullptr; return nullptr;

View File

@ -18,7 +18,7 @@ if(USE_SDL2)
target_link_libraries(duckstation-nogui PRIVATE ${SDL2_LIBRARIES}) target_link_libraries(duckstation-nogui PRIVATE ${SDL2_LIBRARIES})
endif() endif()
if(USE_DRMKMS) if(USE_DRMKMS OR USE_FBDEV)
find_package(LIBEVDEV REQUIRED) find_package(LIBEVDEV REQUIRED)
target_sources(duckstation-nogui PRIVATE target_sources(duckstation-nogui PRIVATE