aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/video_core.cpp
diff options
context:
space:
mode:
authorJames Rowe <jroweboy@gmail.com>2020-03-24 20:58:49 -0600
committerJames Rowe <jroweboy@gmail.com>2020-03-24 21:03:42 -0600
commitb37d69e5e1033d7de7c8a2c3cbcfe55144c17de2 (patch)
tree2a98e3bedec2e7fdb33478814a73be664661aecc /src/video_core/video_core.cpp
parentb3f33a2c6b2114f451da68ffe9e51bdf19f7695d (diff)
Frontend/GPU: Refactor context management
Changes the GraphicsContext to be managed by the GPU core. This eliminates the need for the frontends to fool around with tricky MakeCurrent/DoneCurrent calls that are dependent on the settings (such as async gpu option). This also refactors out the need to use QWidget::fromWindowContainer as that caused issues with focus and input handling. Now we use a regular QWidget and just access the native windowHandle() directly. Another change is removing the debug tool setting in FrameMailbox. Instead of trying to block the frontend until a new frame is ready, the core will now take over presentation and draw directly to the window if the renderer detects that its hooked by NSight or RenderDoc Lastly, since it was in the way, I removed ScopeAcquireWindowContext and replaced it with a simple subclass in GraphicsContext that achieves the same result
Diffstat (limited to 'src/video_core/video_core.cpp')
-rw-r--r--src/video_core/video_core.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index a5f81a8a0c..fd9fec0186 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -15,13 +15,13 @@
#endif
#include "video_core/video_core.h"
-namespace VideoCore {
-
-std::unique_ptr<RendererBase> CreateRenderer(Core::Frontend::EmuWindow& emu_window,
- Core::System& system) {
+namespace {
+std::unique_ptr<VideoCore::RendererBase> CreateRenderer(Core::Frontend::EmuWindow& emu_window,
+ Core::System& system,
+ Core::Frontend::GraphicsContext& context) {
switch (Settings::values.renderer_backend) {
case Settings::RendererBackend::OpenGL:
- return std::make_unique<OpenGL::RendererOpenGL>(emu_window, system);
+ return std::make_unique<OpenGL::RendererOpenGL>(emu_window, system, context);
#ifdef HAS_VULKAN
case Settings::RendererBackend::Vulkan:
return std::make_unique<Vulkan::RendererVulkan>(emu_window, system);
@@ -30,13 +30,23 @@ std::unique_ptr<RendererBase> CreateRenderer(Core::Frontend::EmuWindow& emu_wind
return nullptr;
}
}
+} // namespace
-std::unique_ptr<Tegra::GPU> CreateGPU(Core::System& system) {
- if (Settings::values.use_asynchronous_gpu_emulation) {
- return std::make_unique<VideoCommon::GPUAsynch>(system, system.Renderer());
+namespace VideoCore {
+
+std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Core::System& system) {
+ auto context = emu_window.CreateSharedContext();
+ const auto scope = context->Acquire();
+ auto renderer = CreateRenderer(emu_window, system, *context);
+ if (!renderer->Init()) {
+ return {};
}
- return std::make_unique<VideoCommon::GPUSynch>(system, system.Renderer());
+ if (Settings::values.use_asynchronous_gpu_emulation) {
+ return std::make_unique<VideoCommon::GPUAsynch>(system, std::move(renderer),
+ std::move(context));
+ }
+ return std::make_unique<VideoCommon::GPUSynch>(system, std::move(renderer), std::move(context));
}
u16 GetResolutionScaleFactor(const RendererBase& renderer) {