Permalink
Browse files

Refactoring and cleanup of GLInterface (now GLContext)

  • Loading branch information...
stenzek committed Oct 3, 2018
1 parent 74b82ba commit 134d967be2dd4ba9531abb8ba8494c3ac423ca72
Showing with 736 additions and 685 deletions.
  1. +0 −1 Source/Android/jni/MainAndroid.cpp
  2. +2 −2 Source/Core/Common/CMakeLists.txt
  3. +3 −3 Source/Core/Common/Common.vcxproj
  4. +7 −7 Source/Core/Common/Common.vcxproj.filters
  5. +115 −0 Source/Core/Common/GL/GLContext.cpp
  6. +64 −0 Source/Core/Common/GL/GLContext.h
  7. +4 −4 Source/Core/Common/GL/GLExtensions/GLExtensions.cpp
  8. +14 −8 Source/Core/Common/GL/GLInterface/AGL.h
  9. +26 −21 Source/Core/Common/GL/GLInterface/AGL.mm
  10. +102 −111 Source/Core/Common/GL/GLInterface/EGL.cpp
  11. +34 −32 Source/Core/Common/GL/GLInterface/EGL.h
  12. +8 −15 Source/Core/Common/GL/GLInterface/EGLAndroid.cpp
  13. +3 −6 Source/Core/Common/GL/GLInterface/EGLAndroid.h
  14. +22 −24 Source/Core/Common/GL/GLInterface/EGLX11.cpp
  15. +9 −9 Source/Core/Common/GL/GLInterface/EGLX11.h
  16. +0 −45 Source/Core/Common/GL/GLInterface/GLInterface.cpp
  17. +69 −73 Source/Core/Common/GL/GLInterface/GLX.cpp
  18. +28 −24 Source/Core/Common/GL/GLInterface/GLX.h
  19. +33 −42 Source/Core/Common/GL/GLInterface/WGL.cpp
  20. +14 −10 Source/Core/Common/GL/GLInterface/WGL.h
  21. +0 −72 Source/Core/Common/GL/GLInterface/X11_Util.cpp
  22. +0 −27 Source/Core/Common/GL/GLInterface/X11_Util.h
  23. +0 −61 Source/Core/Common/GL/GLInterfaceBase.h
  24. +3 −10 Source/Core/Common/GL/GLUtil.cpp
  25. +1 −2 Source/Core/Common/GL/GLUtil.h
  26. +77 −0 Source/Core/Common/GL/GLX11Window.cpp
  27. +41 −0 Source/Core/Common/GL/GLX11Window.h
  28. +2 −2 Source/Core/VideoBackends/OGL/FramebufferManager.cpp
  29. +0 −1 Source/Core/VideoBackends/OGL/OGLTexture.cpp
  30. +4 −5 Source/Core/VideoBackends/OGL/PerfQuery.cpp
  31. +4 −4 Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
  32. +19 −21 Source/Core/VideoBackends/OGL/Render.cpp
  33. +3 −3 Source/Core/VideoBackends/OGL/SamplerCache.cpp
  34. +0 −1 Source/Core/VideoBackends/OGL/TextureCache.cpp
  35. +10 −10 Source/Core/VideoBackends/OGL/main.cpp
  36. +12 −19 Source/Core/VideoBackends/Software/SWOGLWindow.cpp
  37. +0 −2 Source/Core/VideoBackends/Software/SWOGLWindow.h
  38. +3 −3 Source/Core/VideoBackends/Software/SWmain.cpp
  39. +0 −5 Source/UnitTests/StubHost.cpp
@@ -22,7 +22,6 @@
#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"
@@ -110,7 +110,7 @@ endif()
target_sources(common PRIVATE
GL/GLUtil.cpp
GL/GLExtensions/GLExtensions.cpp
GL/GLInterface/GLInterface.cpp
GL/GLContext.cpp
)
if(USE_EGL)
@@ -137,7 +137,7 @@ elseif(USE_X11)
# 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_sources(common PRIVATE GL/GLX11Window.cpp)
target_link_libraries(common PUBLIC ${XRANDR_LIBRARIES})
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>
@@ -0,0 +1,115 @@
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <memory>
#include "Common/GL/GLContext.h"
#if defined(__APPLE__)
#include "Common/GL/GLInterface/AGL.h"
#elif defined(_WIN32)
#include "Common/GL/GLInterface/WGL.h"
#elif HAVE_X11
#if defined(USE_EGL) && USE_EGL
#include "Common/GL/GLInterface/EGLX11.h"
#else
#include "Common/GL/GLInterface/GLX.h"
#endif
#elif defined(USE_EGL) && USE_EGL && defined(USE_HEADLESS)
#include "Common/GL/GLInterface/EGL.h"
#elif ANDROID
#include "Common/GL/GLInterface/EGLAndroid.h"
#error Platform doesnt have a GLInterface
#endif
std::unique_ptr<GLContext> g_main_gl_context;
GLContext::~GLContext() = default;
bool GLContext::Initialize(void* window_handle, bool stereo, bool core)
{
return false;
}
bool GLContext::Initialize(GLContext* main_context)
{
return false;
}
void GLContext::SetBackBufferDimensions(u32 w, u32 h)
{
m_backbuffer_width = w;
m_backbuffer_height = h;
}
bool GLContext::IsHeadless() const
{
return true;
}
std::unique_ptr<GLContext> GLContext::CreateSharedContext()
{
return nullptr;
}
bool GLContext::MakeCurrent()
{
return false;
}
bool GLContext::ClearCurrent()
{
return false;
}
void GLContext::Shutdown()
{
}
void GLContext::Update()
{
}
void GLContext::UpdateSurface(void* window_handle)
{
}
void GLContext::Swap()
{
}
void GLContext::SwapInterval(int interval)
{
}
void* GLContext::GetFuncAddress(const std::string& name)
{
return nullptr;
}
std::unique_ptr<GLContext> GLContext::Create(void* window_handle, bool stereo, bool core)
{
std::unique_ptr<GLContext> context;
#if defined(__APPLE__)
context = std::make_unique<GLContextAGL>();
#elif defined(_WIN32)
context = std::make_unique<GLContextWGL>();
#elif defined(USE_EGL) && defined(USE_HEADLESS)
context = std::make_unique<GLContextEGL>();
#elif defined(HAVE_X11) && HAVE_X11
#if defined(USE_EGL) && USE_EGL
context = std::make_unique<GLContextEGLX11>();
#else
context = std::make_unique<GLContextGLX>();
#endif
#elif ANDROID
context = std::make_unique<GLContextEGLAndroid>();
#else
return nullptr;
#endif
if (!context->Initialize(window_handle, stereo, core))
return nullptr;
return context;
}
@@ -0,0 +1,64 @@
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
#include "Common/CommonTypes.h"
class GLContext
{
public:
enum class Mode
{
Detect,
OpenGL,
OpenGLES
};
virtual ~GLContext();
Mode GetMode() { return m_opengl_mode; }
bool IsGLES() const { return m_opengl_mode == Mode::OpenGLES; }
u32 GetBackBufferWidth() { return m_backbuffer_width; }
u32 GetBackBufferHeight() { return m_backbuffer_height; }
void SetBackBufferDimensions(u32 w, u32 h);
virtual bool IsHeadless() const;
virtual std::unique_ptr<GLContext> CreateSharedContext();
virtual void Shutdown();
virtual bool MakeCurrent();
virtual bool ClearCurrent();
virtual void Update();
virtual void UpdateSurface(void* window_handle);
virtual void Swap();
virtual void SwapInterval(int interval);
virtual void* GetFuncAddress(const std::string& name);
// Creates an instance of GLInterface specific to the platform we are running on.
static std::unique_ptr<GLContext> Create(void* window_handle, bool stereo = false,
bool core = true);
protected:
virtual bool Initialize(void* window_handle, bool stereo, bool core);
virtual bool Initialize(GLContext* main_context);
Mode m_opengl_mode = Mode::Detect;
// Window dimensions.
u32 m_backbuffer_width = 0;
u32 m_backbuffer_height = 0;
bool m_is_core_context = false;
bool m_is_shared = false;
};
extern std::unique_ptr<GLContext> g_main_gl_context;
@@ -5,8 +5,8 @@
#include <sstream>
#include <unordered_map>
#include "Common/GL/GLContext.h"
#include "Common/GL/GLExtensions/GLExtensions.h"
#include "Common/GL/GLInterfaceBase.h"
#include "Common/Logging/Log.h"
#if defined(__linux__) || defined(__APPLE__)
@@ -2432,7 +2432,7 @@ static void InitVersion()
static void* GetFuncAddress(const std::string& name, void** func)
{
*func = GLInterface->GetFuncAddress(name);
*func = g_main_gl_context->GetFuncAddress(name);
if (*func == nullptr)
{
#if defined(__linux__) || defined(__APPLE__)
@@ -2457,7 +2457,7 @@ bool Supports(const std::string& name)
bool Init()
{
_isES = GLInterface->GetMode() != GLInterfaceMode::MODE_OPENGL;
_isES = g_main_gl_context->GetMode() == GLContext::Mode::OpenGLES;
// Grab a few functions for initial checking
// We need them to grab the extension list
@@ -2507,4 +2507,4 @@ bool InitFunctionPointers()
result &= !!GetFuncAddress(it.function_name, it.function_ptr);
return result;
}
}
} // namespace GLExtensions
@@ -12,22 +12,28 @@ struct NSOpenGLPixelFormat;
struct NSView;
#endif
#include "Common/GL/GLInterfaceBase.h"
#include "Common/GL/GLContext.h"
class cInterfaceAGL : public cInterfaceBase
class GLContextAGL : public GLContext
{
public:
void Swap() override;
bool Create(void* window_handle, bool stereo, bool core) override;
bool Create(cInterfaceBase* main_context) override;
bool IsHeadless() const override;
std::unique_ptr<GLContext> CreateSharedContext() override;
void Shutdown() override;
bool MakeCurrent() override;
bool ClearCurrent() override;
void Shutdown() override;
void Update() override;
void Swap() override;
void SwapInterval(int interval) override;
std::unique_ptr<cInterfaceBase> CreateSharedContext() override;
private:
protected:
bool Initialize(void* window_handle, bool stereo, bool core) override;
bool Initialize(GLContext* main_context) override;
NSView* m_view = nullptr;
NSOpenGLContext* m_context = nullptr;
NSOpenGLPixelFormat* m_pixel_format = nullptr;
Oops, something went wrong.

0 comments on commit 134d967

Please sign in to comment.