From 134d967be2dd4ba9531abb8ba8494c3ac423ca72 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:02:45 +1000 Subject: Refactoring and cleanup of GLInterface (now GLContext) --- Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 31 +++++++++------------- Source/Core/VideoBackends/Software/SWOGLWindow.h | 2 -- Source/Core/VideoBackends/Software/SWmain.cpp | 6 ++--- 3 files changed, 15 insertions(+), 24 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index 695f58cc1d..dd390bc6dc 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -4,7 +4,7 @@ #include -#include "Common/GL/GLInterfaceBase.h" +#include "Common/GL/GLContext.h" #include "Common/GL/GLUtil.h" #include "Common/Logging/Log.h" @@ -15,9 +15,8 @@ std::unique_ptr SWOGLWindow::s_instance; void SWOGLWindow::Init(void* window_handle) { - GLUtil::InitInterface(); - GLInterface->SetMode(GLInterfaceMode::MODE_DETECT); - if (!GLInterface->Create(window_handle)) + g_main_gl_context = GLContext::Create(window_handle); + if (!g_main_gl_context) { ERROR_LOG(VIDEO, "GLInterface::Create failed."); } @@ -27,8 +26,8 @@ void SWOGLWindow::Init(void* window_handle) void SWOGLWindow::Shutdown() { - GLInterface->Shutdown(); - GLInterface.reset(); + g_main_gl_context->Shutdown(); + g_main_gl_context.reset(); s_instance.reset(); } @@ -66,10 +65,9 @@ void SWOGLWindow::Prepare() " TexCoord = vec2(rawpos.x, -rawpos.y);\n" "}\n"; - std::string header = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL ? - "#version 140\n" : - "#version 300 es\n" - "precision highp float;\n"; + std::string header = g_main_gl_context->IsGLES() ? "#version 300 es\n" + "precision highp float;\n" : + "#version 140\n"; m_image_program = GLUtil::CompileProgram(header + vertex_shader, header + frag_shader); @@ -93,10 +91,10 @@ void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color) void SWOGLWindow::ShowImage(AbstractTexture* image, const EFBRectangle& xfb_region) { SW::SWTexture* sw_image = static_cast(image); - GLInterface->Update(); // just updates the render window position and the backbuffer size + g_main_gl_context->Update(); // just updates the render window position and the backbuffer size - GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth(); - GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight(); + GLsizei glWidth = (GLsizei)g_main_gl_context->GetBackBufferWidth(); + GLsizei glHeight = (GLsizei)g_main_gl_context->GetBackBufferHeight(); glViewport(0, 0, glWidth, glHeight); @@ -123,10 +121,5 @@ void SWOGLWindow::ShowImage(AbstractTexture* image, const EFBRectangle& xfb_regi // } m_text.clear(); - GLInterface->Swap(); -} - -int SWOGLWindow::PeekMessages() -{ - return GLInterface->PeekMessages(); + g_main_gl_context->Swap(); } diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.h b/Source/Core/VideoBackends/Software/SWOGLWindow.h index 64ee2414bc..eadf3171cb 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.h +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.h @@ -26,8 +26,6 @@ public: // Image to show, will be swapped immediately void ShowImage(AbstractTexture* image, const EFBRectangle& xfb_region); - int PeekMessages(); - static std::unique_ptr s_instance; private: diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 6ca183b57c..8781a2da9b 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -9,7 +9,7 @@ #include "Common/Common.h" #include "Common/CommonTypes.h" -#include "Common/GL/GLInterfaceBase.h" +#include "Common/GL/GLContext.h" #include "VideoBackends/Software/Clipper.h" #include "VideoBackends/Software/DebugUtil.h" @@ -88,7 +88,7 @@ bool VideoSoftware::Initialize(void* window_handle) Rasterizer::Init(); DebugUtil::Init(); - GLInterface->MakeCurrent(); + g_main_gl_context->MakeCurrent(); SWOGLWindow::s_instance->Prepare(); g_renderer = std::make_unique(); @@ -116,4 +116,4 @@ void VideoSoftware::Shutdown() g_renderer.reset(); ShutdownShared(); } -} +} // namespace SW -- cgit v1.2.3 From a3961750a7174be7402fc492367f017d845b8e1f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:13 +1000 Subject: Drop Host_GetRenderSurface and pass display to backend --- Source/Core/VideoBackends/Software/SWRenderer.cpp | 6 ++++++ Source/Core/VideoBackends/Software/SWRenderer.h | 2 ++ Source/Core/VideoBackends/Software/SWmain.cpp | 2 +- Source/Core/VideoBackends/Software/VideoBackend.h | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index f4e322619d..5e76cdd296 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -7,6 +7,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/GL/GLContext.h" #include "Core/Config/GraphicsSettings.h" #include "Core/HW/Memmap.h" @@ -28,6 +29,11 @@ SWRenderer::SWRenderer() { } +bool SWRenderer::IsHeadless() const +{ + return g_main_gl_context->IsHeadless(); +} + std::unique_ptr SWRenderer::CreateTexture(const TextureConfig& config) { return std::make_unique(config); diff --git a/Source/Core/VideoBackends/Software/SWRenderer.h b/Source/Core/VideoBackends/Software/SWRenderer.h index 3c274edda7..6b2a3f0795 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.h +++ b/Source/Core/VideoBackends/Software/SWRenderer.h @@ -13,6 +13,8 @@ class SWRenderer : public Renderer public: SWRenderer(); + bool IsHeadless() const override; + std::unique_ptr CreateTexture(const TextureConfig& config) override; std::unique_ptr CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 8781a2da9b..f4c0aaa641 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -78,7 +78,7 @@ void VideoSoftware::InitBackendInfo() g_Config.backend_info.AAModes = {1}; } -bool VideoSoftware::Initialize(void* window_handle) +bool VideoSoftware::Initialize(void* display_handle, void* window_handle) { InitializeShared(); diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index f618ea44ab..336a96325b 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -11,7 +11,7 @@ namespace SW { class VideoSoftware : public VideoBackendBase { - bool Initialize(void* window_handle) override; + bool Initialize(void* display_handle, void* window_handle) override; void Shutdown() override; std::string GetName() const override; @@ -19,4 +19,4 @@ class VideoSoftware : public VideoBackendBase void InitBackendInfo() override; }; -} +} // namespace SW -- cgit v1.2.3 From 9c57a98723997736adea94383668fbdf8a993fd8 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:19 +1000 Subject: GLContext: Use host connection This also removes the need for a sleeping event thread. --- Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 4 ++-- Source/Core/VideoBackends/Software/SWOGLWindow.h | 2 +- Source/Core/VideoBackends/Software/SWmain.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index dd390bc6dc..fb6731b4b7 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -13,9 +13,9 @@ std::unique_ptr SWOGLWindow::s_instance; -void SWOGLWindow::Init(void* window_handle) +void SWOGLWindow::Init(void* display_handle, void* window_handle) { - g_main_gl_context = GLContext::Create(window_handle); + g_main_gl_context = GLContext::Create(display_handle, window_handle); if (!g_main_gl_context) { ERROR_LOG(VIDEO, "GLInterface::Create failed."); diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.h b/Source/Core/VideoBackends/Software/SWOGLWindow.h index eadf3171cb..a393194ed7 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.h +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.h @@ -16,7 +16,7 @@ class AbstractTexture; class SWOGLWindow { public: - static void Init(void* window_handle); + static void Init(void* display_handle, void* window_handle); static void Shutdown(); void Prepare(); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index f4c0aaa641..2aa099e9e9 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -82,7 +82,7 @@ bool VideoSoftware::Initialize(void* display_handle, void* window_handle) { InitializeShared(); - SWOGLWindow::Init(window_handle); + SWOGLWindow::Init(display_handle, window_handle); Clipper::Init(); Rasterizer::Init(); -- cgit v1.2.3 From eb284b5d661cab6aed770e0e51b790917249ef21 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:22 +1000 Subject: VideoBackends: Pass window system info from host on creation --- Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 4 ++-- Source/Core/VideoBackends/Software/SWOGLWindow.h | 3 ++- Source/Core/VideoBackends/Software/SWmain.cpp | 4 ++-- Source/Core/VideoBackends/Software/VideoBackend.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index fb6731b4b7..d9694c17aa 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -13,9 +13,9 @@ std::unique_ptr SWOGLWindow::s_instance; -void SWOGLWindow::Init(void* display_handle, void* window_handle) +void SWOGLWindow::Init(const WindowSystemInfo& wsi) { - g_main_gl_context = GLContext::Create(display_handle, window_handle); + g_main_gl_context = GLContext::Create(wsi); if (!g_main_gl_context) { ERROR_LOG(VIDEO, "GLInterface::Create failed."); diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.h b/Source/Core/VideoBackends/Software/SWOGLWindow.h index a393194ed7..2d85770e61 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.h +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.h @@ -12,11 +12,12 @@ #include "VideoCommon/VideoCommon.h" class AbstractTexture; +struct WindowSystemInfo; class SWOGLWindow { public: - static void Init(void* display_handle, void* window_handle); + static void Init(const WindowSystemInfo& wsi); static void Shutdown(); void Prepare(); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 2aa099e9e9..070cf74b69 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -78,11 +78,11 @@ void VideoSoftware::InitBackendInfo() g_Config.backend_info.AAModes = {1}; } -bool VideoSoftware::Initialize(void* display_handle, void* window_handle) +bool VideoSoftware::Initialize(const WindowSystemInfo& wsi) { InitializeShared(); - SWOGLWindow::Init(display_handle, window_handle); + SWOGLWindow::Init(wsi); Clipper::Init(); Rasterizer::Init(); diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index 336a96325b..bad120d6a1 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -11,7 +11,7 @@ namespace SW { class VideoSoftware : public VideoBackendBase { - bool Initialize(void* display_handle, void* window_handle) override; + bool Initialize(const WindowSystemInfo& wsi) override; void Shutdown() override; std::string GetName() const override; -- cgit v1.2.3 From dcdd02d646230e7903520a41dc9f86e57ae16dbe Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:26 +1000 Subject: GLContext: Remove global context pointer --- Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 61 +++++++++++++--------- Source/Core/VideoBackends/Software/SWOGLWindow.h | 22 +++++--- Source/Core/VideoBackends/Software/SWRenderer.cpp | 11 ++-- Source/Core/VideoBackends/Software/SWRenderer.h | 9 +++- Source/Core/VideoBackends/Software/SWmain.cpp | 10 ++-- 5 files changed, 69 insertions(+), 44 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index d9694c17aa..4936d1a13c 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -7,48 +7,58 @@ #include "Common/GL/GLContext.h" #include "Common/GL/GLUtil.h" #include "Common/Logging/Log.h" +#include "Common/MsgHandler.h" #include "VideoBackends/Software/SWOGLWindow.h" #include "VideoBackends/Software/SWTexture.h" -std::unique_ptr SWOGLWindow::s_instance; +SWOGLWindow::SWOGLWindow() = default; -void SWOGLWindow::Init(const WindowSystemInfo& wsi) +SWOGLWindow::~SWOGLWindow() { - g_main_gl_context = GLContext::Create(wsi); - if (!g_main_gl_context) + if (m_gl_context) { - ERROR_LOG(VIDEO, "GLInterface::Create failed."); + m_gl_context->ClearCurrent(); + m_gl_context->Shutdown(); } - - s_instance.reset(new SWOGLWindow()); } -void SWOGLWindow::Shutdown() +std::unique_ptr SWOGLWindow::Create(const WindowSystemInfo& wsi) { - g_main_gl_context->Shutdown(); - g_main_gl_context.reset(); + std::unique_ptr window = std::unique_ptr(new SWOGLWindow()); + if (!window->Initialize(wsi)) + { + PanicAlert("Failed to create OpenGL window"); + return nullptr; + } - s_instance.reset(); + return window; } -void SWOGLWindow::Prepare() +bool SWOGLWindow::IsHeadless() const { - if (m_init) - return; - m_init = true; + return m_gl_context->IsHeadless(); +} + +bool SWOGLWindow::Initialize(const WindowSystemInfo& wsi) +{ + m_gl_context = GLContext::Create(wsi); + if (!m_gl_context) + return false; + + m_gl_context->MakeCurrent(); // Init extension support. - if (!GLExtensions::Init()) + if (!GLExtensions::Init(m_gl_context.get())) { ERROR_LOG(VIDEO, "GLExtensions::Init failed!Does your video card support OpenGL 2.0?"); - return; + return false; } else if (GLExtensions::Version() < 310) { ERROR_LOG(VIDEO, "OpenGL Version %d detected, but at least 3.1 is required.", GLExtensions::Version()); - return; + return false; } std::string frag_shader = "in vec2 TexCoord;\n" @@ -65,9 +75,9 @@ void SWOGLWindow::Prepare() " TexCoord = vec2(rawpos.x, -rawpos.y);\n" "}\n"; - std::string header = g_main_gl_context->IsGLES() ? "#version 300 es\n" - "precision highp float;\n" : - "#version 140\n"; + std::string header = m_gl_context->IsGLES() ? "#version 300 es\n" + "precision highp float;\n" : + "#version 140\n"; m_image_program = GLUtil::CompileProgram(header + vertex_shader, header + frag_shader); @@ -81,6 +91,7 @@ void SWOGLWindow::Prepare() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glGenVertexArrays(1, &m_image_vao); + return true; } void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color) @@ -91,10 +102,10 @@ void SWOGLWindow::PrintText(const std::string& text, int x, int y, u32 color) void SWOGLWindow::ShowImage(AbstractTexture* image, const EFBRectangle& xfb_region) { SW::SWTexture* sw_image = static_cast(image); - g_main_gl_context->Update(); // just updates the render window position and the backbuffer size + m_gl_context->Update(); // just updates the render window position and the backbuffer size - GLsizei glWidth = (GLsizei)g_main_gl_context->GetBackBufferWidth(); - GLsizei glHeight = (GLsizei)g_main_gl_context->GetBackBufferHeight(); + GLsizei glWidth = (GLsizei)m_gl_context->GetBackBufferWidth(); + GLsizei glHeight = (GLsizei)m_gl_context->GetBackBufferHeight(); glViewport(0, 0, glWidth, glHeight); @@ -121,5 +132,5 @@ void SWOGLWindow::ShowImage(AbstractTexture* image, const EFBRectangle& xfb_regi // } m_text.clear(); - g_main_gl_context->Swap(); + m_gl_context->Swap(); } diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.h b/Source/Core/VideoBackends/Software/SWOGLWindow.h index 2d85770e61..38ae316d07 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.h +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.h @@ -11,15 +11,18 @@ #include "Common/CommonTypes.h" #include "VideoCommon/VideoCommon.h" +class GLContext; + class AbstractTexture; struct WindowSystemInfo; class SWOGLWindow { public: - static void Init(const WindowSystemInfo& wsi); - static void Shutdown(); - void Prepare(); + ~SWOGLWindow(); + + GLContext* GetContext() const { return m_gl_context.get(); } + bool IsHeadless() const; // Will be printed on the *next* image void PrintText(const std::string& text, int x, int y, u32 color); @@ -27,10 +30,13 @@ public: // Image to show, will be swapped immediately void ShowImage(AbstractTexture* image, const EFBRectangle& xfb_region); - static std::unique_ptr s_instance; + static std::unique_ptr Create(const WindowSystemInfo& wsi); private: - SWOGLWindow() {} + SWOGLWindow(); + + bool Initialize(const WindowSystemInfo& wsi); + struct TextData { std::string text; @@ -39,7 +45,9 @@ private: }; std::vector m_text; - bool m_init{false}; + u32 m_image_program = 0; + u32 m_image_texture = 0; + u32 m_image_vao = 0; - u32 m_image_program, m_image_texture, m_image_vao; + std::unique_ptr m_gl_context; }; diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 5e76cdd296..2c6a97027b 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -24,14 +24,15 @@ #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" -SWRenderer::SWRenderer() - : ::Renderer(static_cast(MAX_XFB_WIDTH), static_cast(MAX_XFB_HEIGHT)) +SWRenderer::SWRenderer(std::unique_ptr window) + : ::Renderer(static_cast(MAX_XFB_WIDTH), static_cast(MAX_XFB_HEIGHT)), + m_window(std::move(window)) { } bool SWRenderer::IsHeadless() const { - return g_main_gl_context->IsHeadless(); + return m_window->IsHeadless(); } std::unique_ptr SWRenderer::CreateTexture(const TextureConfig& config) @@ -55,7 +56,7 @@ SWRenderer::CreateFramebuffer(const AbstractTexture* color_attachment, void SWRenderer::RenderText(const std::string& pstr, int left, int top, u32 color) { - SWOGLWindow::s_instance->PrintText(pstr, left, top, color); + m_window->PrintText(pstr, left, top, color); } class SWShader final : public AbstractShader @@ -100,7 +101,7 @@ void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_regi if (!IsHeadless()) { DrawDebugText(); - SWOGLWindow::s_instance->ShowImage(texture, xfb_region); + m_window->ShowImage(texture, xfb_region); } UpdateActiveConfig(); diff --git a/Source/Core/VideoBackends/Software/SWRenderer.h b/Source/Core/VideoBackends/Software/SWRenderer.h index 6b2a3f0795..936139516f 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.h +++ b/Source/Core/VideoBackends/Software/SWRenderer.h @@ -4,14 +4,18 @@ #pragma once +#include + #include "Common/CommonTypes.h" #include "VideoCommon/RenderBase.h" +class SWOGLWindow; + class SWRenderer : public Renderer { public: - SWRenderer(); + SWRenderer(std::unique_ptr window); bool IsHeadless() const override; @@ -42,4 +46,7 @@ public: u32 color, u32 z) override; void ReinterpretPixelData(unsigned int convtype) override {} + +private: + std::unique_ptr m_window; }; diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 070cf74b69..a0ad349849 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -82,16 +82,15 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi) { InitializeShared(); - SWOGLWindow::Init(wsi); + std::unique_ptr window = SWOGLWindow::Create(wsi); + if (!window) + return false; Clipper::Init(); Rasterizer::Init(); DebugUtil::Init(); - g_main_gl_context->MakeCurrent(); - SWOGLWindow::s_instance->Prepare(); - - g_renderer = std::make_unique(); + g_renderer = std::make_unique(std::move(window)); g_vertex_manager = std::make_unique(); g_perf_query = std::make_unique(); g_texture_cache = std::make_unique(); @@ -108,7 +107,6 @@ void VideoSoftware::Shutdown() g_renderer->Shutdown(); DebugUtil::Shutdown(); - SWOGLWindow::Shutdown(); g_framebuffer_manager.reset(); g_texture_cache.reset(); g_perf_query.reset(); -- cgit v1.2.3 From 025e909773a2761cad8a3954498fe800f6f94963 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 3 Oct 2018 23:03:33 +1000 Subject: GLContext: Use destructor instead of Shutdown() to cleanup Also uses the Initialize() method to make the context current. --- Source/Core/VideoBackends/Software/SWOGLWindow.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'Source/Core/VideoBackends/Software') diff --git a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp index 4936d1a13c..81216ff7ef 100644 --- a/Source/Core/VideoBackends/Software/SWOGLWindow.cpp +++ b/Source/Core/VideoBackends/Software/SWOGLWindow.cpp @@ -13,15 +13,7 @@ #include "VideoBackends/Software/SWTexture.h" SWOGLWindow::SWOGLWindow() = default; - -SWOGLWindow::~SWOGLWindow() -{ - if (m_gl_context) - { - m_gl_context->ClearCurrent(); - m_gl_context->Shutdown(); - } -} +SWOGLWindow::~SWOGLWindow() = default; std::unique_ptr SWOGLWindow::Create(const WindowSystemInfo& wsi) { @@ -46,8 +38,6 @@ bool SWOGLWindow::Initialize(const WindowSystemInfo& wsi) if (!m_gl_context) return false; - m_gl_context->MakeCurrent(); - // Init extension support. if (!GLExtensions::Init(m_gl_context.get())) { -- cgit v1.2.3