Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRM platform (through DRM+EGL+GBM backend) to dolphin-nogui #9015

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ddedd9b
Add support for EGL/DRM on dolphin-nogui
rtissera Aug 6, 2020
0f2be8f
Fix missing Cmake modules and code required to properly detect and li…
rtissera Aug 6, 2020
1fa6fbc
Tidy up EGLDRM
rtissera Aug 7, 2020
bd31596
Use Dolphin logging system
rtissera Aug 7, 2020
0a05a52
Remove hardcoded video mode, try to match native game rate
rtissera Aug 7, 2020
56b39ef
Fix lint checks
rtissera Aug 7, 2020
0c52361
Update Source/Core/Common/GL/GLInterface/EGLDRM.h
rtissera Aug 7, 2020
0404543
Update Source/Core/Common/GL/GLInterface/EGLDRM.cpp
rtissera Aug 7, 2020
b66346b
Update Source/Core/DolphinNoGUI/PlatformDRM.cpp
rtissera Aug 7, 2020
8a6e26d
Run clang-format on EGLDRM
rtissera Aug 7, 2020
414cb0e
Indent properly Source/Core/Common/CMakeLists.txt
rtissera Aug 7, 2020
c55dc59
Fix headers order / C++ compliance and move to EGLContextData struct
rtissera Aug 7, 2020
02575c2
Move gfx_ctx_drm_data_t to GFXContextDRMData
rtissera Aug 7, 2020
67cb422
Remove useless "private:" declaration in PlatformDRM.cpp
rtissera Aug 7, 2020
dcabf7a
Harmonize NULL to nullptr in EGLDRM.cpp
rtissera Aug 7, 2020
810f224
Fix build following PR changes
rtissera Aug 7, 2020
c72d6fe
Fix warnings and unused stuff
rtissera Aug 7, 2020
de60407
Refactor #1
rtissera Aug 7, 2020
32ac53b
Refactor (2)
rtissera Aug 7, 2020
c6a374b
Refactor (3)
rtissera Aug 7, 2020
c9c4e43
Move helper functions to static
rtissera Aug 7, 2020
d6fbe00
Better conditional compilation support for EGL/DRM (should pass Dolph…
rtissera Aug 7, 2020
b9eaa05
Fix missing #ifdef
rtissera Aug 7, 2020
1eea311
Fix lint checks
rtissera Aug 7, 2020
1294d4d
Fix crash following refactoring
rtissera Aug 8, 2020
0b160db
Refactor/rework EGLDRM as C++
rtissera Aug 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CMake/FindLibdrm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#.rst:
# FindLibDRM
# ----------
# Finds the LibDRM library
#
# This will define the following variables::
#
# LIBDRM_FOUND - system has LibDRM
# LIBDRM_INCLUDE_DIRS - the LibDRM include directory
# LIBDRM_LIBRARIES - the LibDRM libraries
#
# and the following imported targets::
#
# LibDRM::LibDRM - The LibDRM library

if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBDRM libdrm>=2.4.82 QUIET)
endif()

find_path(LIBDRM_INCLUDE_DIR NAMES drm.h
PATH_SUFFIXES libdrm drm
PATHS ${PC_LIBDRM_INCLUDEDIR})
find_library(LIBDRM_LIBRARY NAMES drm
PATHS ${PC_LIBDRM_LIBDIR})

set(LIBDRM_VERSION ${PC_LIBDRM_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibDRM
REQUIRED_VARS LIBDRM_LIBRARY LIBDRM_INCLUDE_DIR
VERSION_VAR LIBDRM_VERSION)

if(LIBDRM_FOUND)
set(LIBDRM_LIBRARIES ${LIBDRM_LIBRARY})
set(LIBDRM_INCLUDE_DIRS ${LIBDRM_INCLUDE_DIR})

if(NOT TARGET LIBDRM::LIBDRM)
add_library(LIBDRM::LIBDRM UNKNOWN IMPORTED)
set_target_properties(LIBDRM::LIBDRM PROPERTIES
IMPORTED_LOCATION "${LIBDRM_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBDRM_INCLUDE_DIR}")
endif()
endif()

mark_as_advanced(LIBDRM_INCLUDE_DIR LIBDRM_LIBRARY)
46 changes: 46 additions & 0 deletions CMake/FindLibgbm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# - Try to find gbm.
# Once done, this will define
#
# LIBGBM_INCLUDE_DIRS - the gbm include directories
# LIBGBM_LIBRARIES - link these to use gbm.
#
# Copyright (C) 2015 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_package(PkgConfig)
pkg_check_modules(PC_LIBGBM gbm)

find_path(LIBGBM_INCLUDE_DIRS
NAMES gbm.h
HINTS ${PC_LIBGBM_INCLUDE_DIRS} ${PC_LIBGBM_INCUDEDIR}
)

find_library(LIBGBM_LIBRARIES
NAMES gbm
HINTS ${PC_LIBGBM_LIBRARY_DIRS} ${PC_LIBGBM_LIBDIR}
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGBM DEFAULT_MSG LIBGBM_LIBRARIES)

mark_as_advanced(LIBGBM_INCLUDE_DIRS LIBGBM_LIBRARIES)
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ if(ENABLE_EGL)
if(EGL_FOUND)
add_definitions(-DHAVE_EGL=1)
message(STATUS "EGL OpenGL interface enabled")
find_package(Libdrm)
find_package(Libgbm)
if(LIBDRM_FOUND AND LIBGBM_FOUND)
add_definitions(-DHAVE_DRM=1)
message(STATUS "EGL/DRM/GBM support enabled")
endif()
else()
message(WARNING "EGL support enabled but not found. This build will not support EGL.")
endif()
Expand Down
26 changes: 20 additions & 6 deletions Source/Core/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,19 @@ target_sources(common PRIVATE
)

if(ENABLE_EGL AND EGL_FOUND)
target_sources(common PRIVATE
GL/GLInterface/EGL.cpp
GL/GLInterface/EGL.h
)
if (LIBDRM_FOUND AND LIBGBM_FOUND)
target_sources(common PRIVATE
lioncash marked this conversation as resolved.
Show resolved Hide resolved
GL/GLInterface/EGL.cpp
GL/GLInterface/EGL.h
GL/GLInterface/EGLDRM.cpp
GL/GLInterface/EGLDRM.h
)
else()
target_sources(common PRIVATE
GL/GLInterface/EGL.cpp
GL/GLInterface/EGL.h
)
endif()
if(ANDROID)
target_sources(common PRIVATE
GL/GLInterface/EGLAndroid.cpp
Expand All @@ -237,8 +246,13 @@ if(ENABLE_EGL AND EGL_FOUND)
GL/GLInterface/EGLX11.h
)
endif()
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
if (LIBDRM_FOUND AND LIBGBM_FOUND)
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS} ${LIBDRM_INCLUDE_DIRS} ${LIBGBM_INCLUDE_DIRS})
target_link_libraries(common PUBLIC ${EGL_LIBRARIES} ${LIBDRM_LIBRARIES} ${LIBGBM_LIBRARIES})
else()
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
endif()
endif()

if(WIN32)
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Common/GL/GLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#endif
#if HAVE_EGL
#include "Common/GL/GLInterface/EGL.h"
#if HAVE_DRM
#include "Common/GL/GLInterface/EGLDRM.h"
#endif
#if HAVE_X11
#include "Common/GL/GLInterface/EGLX11.h"
#endif
Expand Down Expand Up @@ -110,6 +113,10 @@ std::unique_ptr<GLContext> GLContext::Create(const WindowSystemInfo& wsi, bool s
#if HAVE_EGL
if (wsi.type == WindowSystemType::Headless || wsi.type == WindowSystemType::FBDev)
context = std::make_unique<GLContextEGL>();
#if HAVE_DRM
else if (wsi.type == WindowSystemType::DRM)
context = std::make_unique<GLContextEGLDRM>();
#endif
#endif

if (!context)
Expand Down
Loading