Permalink
Browse files

Merge pull request #7450 from stenzek/glcontext

GLInterface refactoring/cleanup and runtime platform selection
  • Loading branch information...
stenzek committed Oct 24, 2018
2 parents 9c9d598 + 2c6d964 commit c4d1e4adffcd380cc87b841069ce2fe8b62d7b60
Showing with 1,298 additions and 1,337 deletions.
  1. +54 −0 CMake/FindEGL.cmake
  2. +26 −50 CMakeLists.txt
  3. +3 −7 Source/Android/jni/MainAndroid.cpp
  4. +13 −19 Source/Core/Common/CMakeLists.txt
  5. +3 −3 Source/Core/Common/Common.vcxproj
  6. +7 −7 Source/Core/Common/Common.vcxproj.filters
  7. +126 −0 Source/Core/Common/GL/GLContext.cpp
  8. +67 −0 Source/Core/Common/GL/GLContext.h
  9. +47 −49 Source/Core/Common/GL/GLExtensions/GLExtensions.cpp
  10. +4 −2 Source/Core/Common/GL/GLExtensions/GLExtensions.h
  11. +14 −8 Source/Core/Common/GL/GLInterface/AGL.h
  12. +49 −42 Source/Core/Common/GL/GLInterface/AGL.mm
  13. +0 −70 Source/Core/Common/GL/GLInterface/BGL.cpp
  14. +0 −27 Source/Core/Common/GL/GLInterface/BGL.h
  15. +121 −160 Source/Core/Common/GL/GLInterface/EGL.cpp
  16. +34 −32 Source/Core/Common/GL/GLInterface/EGL.h
  17. +8 −15 Source/Core/Common/GL/GLInterface/EGLAndroid.cpp
  18. +3 −6 Source/Core/Common/GL/GLInterface/EGLAndroid.h
  19. +0 −30 Source/Core/Common/GL/GLInterface/EGLHaiku.cpp
  20. +0 −16 Source/Core/Common/GL/GLInterface/EGLHaiku.h
  21. +30 −25 Source/Core/Common/GL/GLInterface/EGLX11.cpp
  22. +10 −9 Source/Core/Common/GL/GLInterface/EGLX11.h
  23. +0 −50 Source/Core/Common/GL/GLInterface/GLInterface.cpp
  24. +99 −110 Source/Core/Common/GL/GLInterface/GLX.cpp
  25. +30 −24 Source/Core/Common/GL/GLInterface/GLX.h
  26. +74 −95 Source/Core/Common/GL/GLInterface/WGL.cpp
  27. +15 −11 Source/Core/Common/GL/GLInterface/WGL.h
  28. +0 −72 Source/Core/Common/GL/GLInterface/X11_Util.cpp
  29. +0 −27 Source/Core/Common/GL/GLInterface/X11_Util.h
  30. +0 −61 Source/Core/Common/GL/GLInterfaceBase.h
  31. +4 −11 Source/Core/Common/GL/GLUtil.cpp
  32. +4 −3 Source/Core/Common/GL/GLUtil.h
  33. +53 −0 Source/Core/Common/GL/GLX11Window.cpp
  34. +39 −0 Source/Core/Common/GL/GLX11Window.h
  35. +35 −0 Source/Core/Common/WindowSystemInfo.h
  36. +8 −6 Source/Core/Core/BootManager.cpp
  37. +3 −2 Source/Core/Core/BootManager.h
  38. +7 −10 Source/Core/Core/Core.cpp
  39. +3 −2 Source/Core/Core/Core.h
  40. +0 −3 Source/Core/Core/Host.h
  41. +14 −19 Source/Core/DolphinNoGUI/MainNoGUI.cpp
  42. +3 −12 Source/Core/DolphinQt/Host.cpp
  43. +0 −1 Source/Core/DolphinQt/Host.h
  44. +52 −3 Source/Core/DolphinQt/MainWindow.cpp
  45. +4 −3 Source/Core/DolphinQt/RenderWidget.cpp
  46. +3 −1 Source/Core/UICommon/CMakeLists.txt
  47. +7 −4 Source/Core/VideoBackends/D3D/D3DBase.cpp
  48. +8 −6 Source/Core/VideoBackends/D3D/Render.cpp
  49. +3 −0 Source/Core/VideoBackends/D3D/Render.h
  50. +2 −2 Source/Core/VideoBackends/D3D/VideoBackend.h
  51. +3 −6 Source/Core/VideoBackends/D3D/main.cpp
  52. +2 −2 Source/Core/VideoBackends/Null/NullBackend.cpp
  53. +5 −0 Source/Core/VideoBackends/Null/Render.cpp
  54. +2 −0 Source/Core/VideoBackends/Null/Render.h
  55. +2 −2 Source/Core/VideoBackends/Null/VideoBackend.h
  56. +1 −2 Source/Core/VideoBackends/OGL/FramebufferManager.cpp
  57. +0 −1 Source/Core/VideoBackends/OGL/OGLTexture.cpp
  58. +8 −10 Source/Core/VideoBackends/OGL/PerfQuery.cpp
  59. +6 −5 Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
  60. +29 −26 Source/Core/VideoBackends/OGL/Render.cpp
  61. +11 −3 Source/Core/VideoBackends/OGL/Render.h
  62. +3 −3 Source/Core/VideoBackends/OGL/SamplerCache.cpp
  63. +0 −1 Source/Core/VideoBackends/OGL/TextureCache.cpp
  64. +5 −3 Source/Core/VideoBackends/OGL/VideoBackend.h
  65. +14 −15 Source/Core/VideoBackends/OGL/main.cpp
  66. +27 −33 Source/Core/VideoBackends/Software/SWOGLWindow.cpp
  67. +16 −9 Source/Core/VideoBackends/Software/SWOGLWindow.h
  68. +11 −4 Source/Core/VideoBackends/Software/SWRenderer.cpp
  69. +10 −1 Source/Core/VideoBackends/Software/SWRenderer.h
  70. +7 −9 Source/Core/VideoBackends/Software/SWmain.cpp
  71. +2 −2 Source/Core/VideoBackends/Software/VideoBackend.h
  72. +10 −38 Source/Core/VideoBackends/Vulkan/Renderer.cpp
  73. +2 −0 Source/Core/VideoBackends/Vulkan/Renderer.h
  74. +12 −14 Source/Core/VideoBackends/Vulkan/SwapChain.cpp
  75. +6 −3 Source/Core/VideoBackends/Vulkan/SwapChain.h
  76. +2 −2 Source/Core/VideoBackends/Vulkan/VideoBackend.h
  77. +6 −5 Source/Core/VideoBackends/Vulkan/main.cpp
  78. +0 −2 Source/Core/VideoCommon/DriverDetails.cpp
  79. +0 −1 Source/Core/VideoCommon/DriverDetails.h
  80. +2 −5 Source/Core/VideoCommon/RenderBase.cpp
  81. +3 −5 Source/Core/VideoCommon/RenderBase.h
  82. +2 −1 Source/Core/VideoCommon/VideoBackendBase.h
  83. +0 −9 Source/UnitTests/StubHost.cpp
@@ -0,0 +1,54 @@
# from https://raw.githubusercontent.com/WebKit/webkit/master/Source/cmake/FindEGL.cmake
# - Try to Find EGL
# Once done, this will define
#
# EGL_FOUND - system has EGL installed.
# EGL_INCLUDE_DIRS - directories which contain the EGL headers.
# EGL_LIBRARIES - libraries required to link against EGL.
# EGL_DEFINITIONS - Compiler switches required for using EGL.
#
# Copyright (C) 2012 Intel Corporation. All rights reserved.
#
# 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_EGL egl)
if (PC_EGL_FOUND)
set(EGL_DEFINITIONS ${PC_EGL_CFLAGS_OTHER})
endif ()
find_path(EGL_INCLUDE_DIRS NAMES EGL/egl.h
HINTS ${PC_EGL_INCLUDEDIR} ${PC_EGL_INCLUDE_DIRS}
)
set(EGL_NAMES ${EGL_NAMES} egl EGL)
find_library(EGL_LIBRARIES NAMES ${EGL_NAMES}
HINTS ${PC_EGL_LIBDIR} ${PC_EGL_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EGL DEFAULT_MSG EGL_INCLUDE_DIRS EGL_LIBRARIES)
mark_as_advanced(EGL_INCLUDE_DIRS EGL_LIBRARIES)
@@ -16,8 +16,13 @@ project(dolphin-emu)
# unique name here.
set(DISTRIBUTOR "None" CACHE STRING "Name of the distributor.")
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
option(TRY_X11 "Enables X11 Support" ON)
if(UNIX AND NOT APPLE AND NOT ANDROID)
option(ENABLE_X11 "Enables X11 Support" ON)
endif()
if(NOT WIN32 AND NOT APPLE)
option(ENABLE_EGL "Enables EGL OpenGL Interface" ON)
endif()
option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF)
option(USE_UPNP "Enables UPnP port mapping support" ON)
option(ENABLE_QT "Enable Qt (Default)" ON)
@@ -87,13 +92,8 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Set up paths
set(bindir ${CMAKE_INSTALL_PREFIX}/bin CACHE PATH "bindir")
if(HAIKU)
set(datadir ${CMAKE_INSTALL_PREFIX}/data/dolphin-emu CACHE PATH "datadir")
set(mandir ${CMAKE_INSTALL_PREFIX}/documentation/man CACHE PATH "mandir")
else()
set(datadir ${CMAKE_INSTALL_PREFIX}/share/dolphin-emu CACHE PATH "datadir")
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man CACHE PATH "mandir")
endif()
set(datadir ${CMAKE_INSTALL_PREFIX}/share/dolphin-emu CACHE PATH "datadir")
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man CACHE PATH "mandir")
add_definitions(-DDATA_DIR="${datadir}/")
if(CMAKE_SYSROOT)
@@ -370,9 +370,7 @@ if(ANDROID)
# but not as a shared library. We want an executable.
set(ANDROID 0)
endif()
set(USE_X11 0)
set(USE_UPNP 0)
set(USE_EGL 1)
set(ENABLE_QT 0)
set(USE_DISCORD_PRESENCE 0)
@@ -381,20 +379,10 @@ if(ANDROID)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
elseif(HAIKU)
set(USE_X11 0)
set(USE_UPNP 0)
set(USE_EGL 0)
endif()
if(ENABLE_HEADLESS)
if(APPLE)
message(STATUS "Enabling Headless! Disabling GUI.")
else()
message(STATUS "Enabling Headless! Disabling GUI, force enabling EGL!")
set(USE_EGL 1)
endif()
set(USE_X11 0)
message(STATUS "Enabling Headless! Disabling GUI.")
set(ENABLE_QT 0)
set(USE_DISCORD_PRESENCE 0)
add_definitions(-DUSE_HEADLESS)
@@ -425,38 +413,31 @@ if (OPENGL_GL)
include_directories(${OPENGL_INCLUDE_DIR})
endif()
set(USE_X11 0)
if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT HAIKU AND NOT ENABLE_HEADLESS)
if(ENABLE_X11)
find_package(X11)
if(TRY_X11 AND X11_FOUND)
set(USE_X11 1)
if(X11_FOUND)
add_definitions(-DHAVE_X11=1)
include_directories(${X11_INCLUDE_DIR})
check_lib(XRANDR xrandr Xrandr)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
else()
add_definitions(-DHAVE_XRANDR=0)
endif()
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0)
message(STATUS "X11 support enabled")
else()
set(USE_X11 0)
SET(X11_FOUND "")
message(STATUS "X11 support disabled")
add_definitions(-DHAVE_X11=0)
endif()
if (NOT USE_X11)
message(FATAL_ERROR "\n"
"No suitable display platform found\n"
"Requires x11 to run")
message(WARNING "X11 support enabled but not found. This build will not support X11.")
endif()
endif()
if(USE_X11)
check_lib(XRANDR xrandr Xrandr)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
if(ENABLE_EGL)
find_package(EGL)
if(EGL_FOUND)
add_definitions(-DHAVE_EGL=1)
message(STATUS "EGL OpenGL interface enabled")
else()
add_definitions(-DHAVE_XRANDR=0)
message(WARNING "EGL support enabled but not found. This build will not support EGL.")
endif()
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0)
endif()
if(ENCODE_FRAMEDUMPS)
@@ -482,11 +463,6 @@ if(OPROFILING)
endif()
endif()
if(USE_EGL)
message(STATUS "EGL OpenGL interface enabled")
add_definitions(-DUSE_EGL=1)
endif()
if(ENABLE_EVDEV)
find_package(Libudev REQUIRED)
find_package(Libevdev REQUIRED)
@@ -22,10 +22,10 @@
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/FileUtil.h"
#include "Common/GL/GLInterfaceBase.h"
#include "Common/Logging/LogManager.h"
#include "Common/MsgHandler.h"
#include "Common/Version.h"
#include "Common/WindowSystemInfo.h"
#include "Core/Analytics.h"
#include "Core/Boot/Boot.h"
@@ -90,11 +90,6 @@ void Host_Message(HostMessageID id)
}
}
void* Host_GetRenderHandle()
{
return s_surf;
}
void Host_UpdateTitle(const std::string& title)
{
__android_log_write(ANDROID_LOG_INFO, DOLPHIN_TAG, title.c_str());
@@ -566,7 +561,8 @@ static void Run(const std::string& path, bool first_open,
s_have_wm_user_stop = false;
std::unique_ptr<BootParameters> boot = BootParameters::GenerateFromFile(path, savestate_path);
boot->delete_savestate = delete_savestate;
if (BootManager::BootCore(std::move(boot)))
WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf);
if (BootManager::BootCore(std::move(boot), wsi))
{
static constexpr int TIMEOUT = 10000;
static constexpr int WAIT_STEP = 25;
@@ -110,17 +110,18 @@ endif()
target_sources(common PRIVATE
GL/GLUtil.cpp
GL/GLExtensions/GLExtensions.cpp
GL/GLInterface/GLInterface.cpp
GL/GLContext.cpp
)
if(USE_EGL)
if(ENABLE_EGL AND EGL_FOUND)
target_sources(common PRIVATE GL/GLInterface/EGL.cpp)
if(ANDROID)
target_sources(common PRIVATE GL/GLInterface/EGLAndroid.cpp)
elseif(USE_X11)
elseif(ENABLE_X11 AND X11_FOUND)
target_sources(common PRIVATE GL/GLInterface/EGLX11.cpp)
endif()
target_link_libraries(common PUBLIC EGL)
target_include_directories(common PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(common PUBLIC ${EGL_LIBRARIES})
endif()
if(WIN32)
@@ -130,18 +131,14 @@ if(WIN32)
)
elseif(APPLE)
target_sources(common PRIVATE GL/GLInterface/AGL.mm)
elseif(HAIKU)
target_sources(common PRIVATE GL/GLInterface/BGL.cpp)
target_link_libraries(common PUBLIC be GL)
elseif(USE_X11)
if (NOT USE_EGL)
target_sources(common PRIVATE GL/GLInterface/GLX.cpp)
# GLX has a hard dependency on libGL.
# Make sure to link to it if using GLX.
target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
endif()
target_sources(common PRIVATE GL/GLInterface/X11_Util.cpp)
target_link_libraries(common PUBLIC ${XRANDR_LIBRARIES})
elseif(ENABLE_X11 AND X11_FOUND)
target_sources(common PRIVATE
GL/GLX11Window.cpp
GL/GLInterface/GLX.cpp)
# GLX has a hard dependency on libGL.
# Make sure to link to it if using GLX.
target_link_libraries(common PUBLIC ${OPENGL_LIBRARIES})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@@ -163,9 +160,6 @@ if(UNIX)
if(SYSTEMD_FOUND)
target_link_libraries(traversal_server PRIVATE ${SYSTEMD_LIBRARIES})
endif()
if(HAIKU)
target_link_libraries(traversal_server PRIVATE network)
endif()
elseif(WIN32)
target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches")
endif()
@@ -121,7 +121,7 @@
<ClInclude Include="GL\GLExtensions\NV_depth_buffer_float.h" />
<ClInclude Include="GL\GLExtensions\NV_occlusion_query_samples.h" />
<ClInclude Include="GL\GLExtensions\NV_primitive_restart.h" />
<ClInclude Include="GL\GLInterfaceBase.h" />
<ClInclude Include="GL\GLContext.h" />
<ClInclude Include="GL\GLInterface\WGL.h" />
<ClInclude Include="GL\GLUtil.h" />
<ClInclude Include="FloatUtils.h" />
@@ -189,7 +189,7 @@
<ClCompile Include="FloatUtils.cpp" />
<ClCompile Include="GekkoDisassembler.cpp" />
<ClCompile Include="GL\GLExtensions\GLExtensions.cpp" />
<ClCompile Include="GL\GLInterface\GLInterface.cpp" />
<ClCompile Include="GL\GLContext.cpp" />
<ClCompile Include="GL\GLInterface\WGL.cpp" />
<ClCompile Include="GL\GLUtil.cpp" />
<ClCompile Include="Hash.cpp" />
@@ -255,4 +255,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
@@ -243,9 +243,6 @@
<ClInclude Include="GL\GLInterface\WGL.h">
<Filter>GL\GLInterface</Filter>
</ClInclude>
<ClInclude Include="GL\GLInterfaceBase.h">
<Filter>GL\GLInterface</Filter>
</ClInclude>
<ClInclude Include="Assert.h" />
<ClInclude Include="Analytics.h" />
<ClInclude Include="Semaphore.h" />
@@ -275,6 +272,9 @@
<ClInclude Include="Debug\MemoryPatches.h">
<Filter>Debug</Filter>
</ClInclude>
<ClInclude Include="GL\GLContext.h">
<Filter>GL\GLInterface</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CDUtils.cpp" />
@@ -339,9 +339,6 @@
<ClCompile Include="GL\GLInterface\WGL.cpp">
<Filter>GL\GLInterface</Filter>
</ClCompile>
<ClCompile Include="GL\GLInterface\GLInterface.cpp">
<Filter>GL\GLInterface</Filter>
</ClCompile>
<ClCompile Include="Analytics.cpp" />
<ClCompile Include="MD5.cpp" />
<ClCompile Include="File.cpp" />
@@ -355,11 +352,14 @@
<ClCompile Include="Debug\MemoryPatches.cpp">
<Filter>Debug</Filter>
</ClCompile>
<ClCompile Include="GL\GLContext.cpp">
<Filter>GL\GLInterface</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Natvis Include="BitField.natvis" />
</ItemGroup>
</Project>
</Project>
Oops, something went wrong.

0 comments on commit c4d1e4a

Please sign in to comment.