diff options
author | bunnei <bunneidev@gmail.com> | 2018-07-15 05:18:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-15 05:18:11 +0200 |
commit | 2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc (patch) | |
tree | 8004356e5a9cbbeb4e37dcad9d47ddfffc5f3210 /src/video_core/renderer_opengl | |
parent | Merge pull request #663 from Subv/bsd (diff) | |
parent | OpenGL: Use MakeCurrent/DoneCurrent for multithreaded rendering. (diff) | |
download | yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar.gz yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar.bz2 yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar.lz yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar.xz yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.tar.zst yuzu-2cb3fdca86192d5dd2f3c988b5d57732c0bee6dc.zip |
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 6 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 15 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 7 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 1da9e137c..eecbc5ff0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -15,6 +15,7 @@ #include "common/microprofile.h" #include "common/scope_exit.h" #include "core/core.h" +#include "core/frontend/emu_window.h" #include "core/hle/kernel/process.h" #include "core/settings.h" #include "video_core/engines/maxwell_3d.h" @@ -22,6 +23,7 @@ #include "video_core/renderer_opengl/gl_shader_gen.h" #include "video_core/renderer_opengl/maxwell_to_gl.h" #include "video_core/renderer_opengl/renderer_opengl.h" +#include "video_core/video_core.h" using Maxwell = Tegra::Engines::Maxwell3D::Regs; using PixelFormat = SurfaceParams::PixelFormat; @@ -398,6 +400,8 @@ void RasterizerOpenGL::Clear() { if (clear_mask == 0) return; + ScopeAcquireGLContext acquire_context; + auto [dirty_color_surface, dirty_depth_surface] = ConfigureFramebuffers(use_color_fb, use_depth_fb); @@ -424,6 +428,8 @@ void RasterizerOpenGL::DrawArrays() { MICROPROFILE_SCOPE(OpenGL_Drawing); const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; + ScopeAcquireGLContext acquire_context; + auto [dirty_color_surface, dirty_depth_surface] = ConfigureFramebuffers(true, regs.zeta.Address() != 0); diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 00841e937..1930fa6ef 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -92,11 +92,24 @@ static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, cons return matrix; } +ScopeAcquireGLContext::ScopeAcquireGLContext() { + if (Settings::values.use_multi_core) { + VideoCore::g_emu_window->MakeCurrent(); + } +} +ScopeAcquireGLContext::~ScopeAcquireGLContext() { + if (Settings::values.use_multi_core) { + VideoCore::g_emu_window->DoneCurrent(); + } +} + RendererOpenGL::RendererOpenGL() = default; RendererOpenGL::~RendererOpenGL() = default; /// Swap buffers (render frame) void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) { + ScopeAcquireGLContext acquire_context; + Core::System::GetInstance().perf_stats.EndSystemFrame(); // Maintain the rasterizer's state as a priority @@ -418,7 +431,7 @@ static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum /// Initialize the renderer bool RendererOpenGL::Init() { - render_window->MakeCurrent(); + ScopeAcquireGLContext acquire_context; if (GLAD_GL_KHR_debug) { glEnable(GL_DEBUG_OUTPUT); diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 21f0d298c..fd0267cf5 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -31,6 +31,13 @@ struct ScreenInfo { TextureInfo texture; }; +/// Helper class to acquire/release OpenGL context within a given scope +class ScopeAcquireGLContext : NonCopyable { +public: + ScopeAcquireGLContext(); + ~ScopeAcquireGLContext(); +}; + class RendererOpenGL : public RendererBase { public: RendererOpenGL(); |