diff options
Diffstat (limited to 'src/yuzu_cmd')
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 37 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 2 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 2 | 
3 files changed, 40 insertions, 1 deletions
| diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index de7a26e14..68a176032 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -19,6 +19,37 @@  #include "input_common/sdl/sdl.h"  #include "yuzu_cmd/emu_window/emu_window_sdl2.h" +class SDLGLContext : public Core::Frontend::GraphicsContext { +public: +    explicit SDLGLContext() { +        // create a hidden window to make the shared context against +        window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, // x position +                                  SDL_WINDOWPOS_UNDEFINED,     // y position +                                  Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, +                                  SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); +        context = SDL_GL_CreateContext(window); +    } + +    ~SDLGLContext() { +        SDL_GL_DeleteContext(context); +        SDL_DestroyWindow(window); +    } + +    void MakeCurrent() override { +        SDL_GL_MakeCurrent(window, context); +    } + +    void DoneCurrent() override { +        SDL_GL_MakeCurrent(window, nullptr); +    } + +    void SwapBuffers() override {} + +private: +    SDL_Window* window; +    SDL_GLContext context; +}; +  void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {      TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));      InputCommon::GetMotionEmu()->Tilt(x, y); @@ -153,6 +184,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {      SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);      SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);      SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); +    SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);      std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname,                                             Common::g_scm_branch, Common::g_scm_desc); @@ -171,7 +203,6 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {      if (fullscreen) {          Fullscreen();      } -      gl_context = SDL_GL_CreateContext(render_window);      if (gl_context == nullptr) { @@ -278,3 +309,7 @@ void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(      SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second);  } + +std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2::CreateSharedContext() const { +    return std::make_unique<SDLGLContext>(); +} diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index b0d4116cc..17e98227f 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -27,6 +27,8 @@ public:      /// Releases the GL context from the caller thread      void DoneCurrent() override; +    std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; +      /// Whether the window is still open, and a close request hasn't yet been sent      bool IsOpen() const; diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 245f25847..7ea4a1b18 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -33,6 +33,7 @@  #include "yuzu_cmd/emu_window/emu_window_sdl2.h"  #include <getopt.h> +#include "core/file_sys/registered_cache.h"  #ifndef _MSC_VER  #include <unistd.h>  #endif @@ -178,6 +179,7 @@ int main(int argc, char** argv) {      }      Core::System& system{Core::System::GetInstance()}; +    system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());      system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());      Service::FileSystem::CreateFactories(*system.GetFilesystem()); | 
