diff options
| author | 2020-03-24 22:57:36 -0600 | |
|---|---|---|
| committer | 2020-03-25 23:32:42 -0600 | |
| commit | cf9c94d4017120b618194a720942ef4e5c8289bd (patch) | |
| tree | 30cbea0216626e3a1db1a68120b54e6bd53804f5 /src | |
| parent | Frontend/GPU: Refactor context management (diff) | |
| download | yuzu-cf9c94d4017120b618194a720942ef4e5c8289bd.tar.gz yuzu-cf9c94d4017120b618194a720942ef4e5c8289bd.tar.xz yuzu-cf9c94d4017120b618194a720942ef4e5c8289bd.zip | |
Address review and fix broken yuzu-tester build
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 4 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/video_core.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 97 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 9 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp | 42 | ||||
| -rw-r--r-- | src/yuzu_tester/emu_window/emu_window_sdl2_hide.h | 9 | ||||
| -rw-r--r-- | src/yuzu_tester/yuzu.cpp | 6 |
11 files changed, 83 insertions, 102 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 6cc4a0812..26a580cb7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -169,6 +169,9 @@ struct System::Impl { | |||
| 169 | 169 | ||
| 170 | interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system); | 170 | interrupt_manager = std::make_unique<Core::Hardware::InterruptManager>(system); |
| 171 | gpu_core = VideoCore::CreateGPU(emu_window, system); | 171 | gpu_core = VideoCore::CreateGPU(emu_window, system); |
| 172 | if (!gpu_core) { | ||
| 173 | return ResultStatus::ErrorVideoCore; | ||
| 174 | } | ||
| 172 | gpu_core->Renderer().Rasterizer().SetupDirtyFlags(); | 175 | gpu_core->Renderer().Rasterizer().SetupDirtyFlags(); |
| 173 | 176 | ||
| 174 | is_powered_on = true; | 177 | is_powered_on = true; |
| @@ -181,7 +184,6 @@ struct System::Impl { | |||
| 181 | 184 | ||
| 182 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, | 185 | ResultStatus Load(System& system, Frontend::EmuWindow& emu_window, |
| 183 | const std::string& filepath) { | 186 | const std::string& filepath) { |
| 184 | |||
| 185 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); | 187 | app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); |
| 186 | if (!app_loader) { | 188 | if (!app_loader) { |
| 187 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 189 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index bb283d844..72294d4d8 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -30,7 +30,7 @@ public: | |||
| 30 | 30 | ||
| 31 | class Scoped { | 31 | class Scoped { |
| 32 | public: | 32 | public: |
| 33 | Scoped(GraphicsContext& context_) : context(context_) { | 33 | explicit Scoped(GraphicsContext& context_) : context(context_) { |
| 34 | context.MakeCurrent(); | 34 | context.MakeCurrent(); |
| 35 | } | 35 | } |
| 36 | ~Scoped() { | 36 | ~Scoped() { |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 8f59e0442..046ee55a5 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -305,6 +305,7 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | const std::vector gl_cache = disk_cache.LoadPrecompiled(); | 307 | const std::vector gl_cache = disk_cache.LoadPrecompiled(); |
| 308 | const auto supported_formats = GetSupportedFormats(); | ||
| 308 | 309 | ||
| 309 | // Track if precompiled cache was altered during loading to know if we have to | 310 | // Track if precompiled cache was altered during loading to know if we have to |
| 310 | // serialize the virtual precompiled cache file back to the hard drive | 311 | // serialize the virtual precompiled cache file back to the hard drive |
| @@ -327,7 +328,6 @@ void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading, | |||
| 327 | const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, | 328 | const auto worker = [&](Core::Frontend::GraphicsContext* context, std::size_t begin, |
| 328 | std::size_t end) { | 329 | std::size_t end) { |
| 329 | const auto scope = context->Acquire(); | 330 | const auto scope = context->Acquire(); |
| 330 | const auto supported_formats = GetSupportedFormats(); | ||
| 331 | 331 | ||
| 332 | for (std::size_t i = begin; i < end; ++i) { | 332 | for (std::size_t i = begin; i < end; ++i) { |
| 333 | if (stop_loading) { | 333 | if (stop_loading) { |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 6f08803c1..f1a28cc21 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -7,7 +7,9 @@ | |||
| 7 | #include <cstdlib> | 7 | #include <cstdlib> |
| 8 | #include <cstring> | 8 | #include <cstring> |
| 9 | #include <memory> | 9 | #include <memory> |
| 10 | |||
| 10 | #include <glad/glad.h> | 11 | #include <glad/glad.h> |
| 12 | |||
| 11 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 12 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 13 | #include "common/microprofile.h" | 15 | #include "common/microprofile.h" |
| @@ -313,8 +315,8 @@ public: | |||
| 313 | 315 | ||
| 314 | RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system, | 316 | RendererOpenGL::RendererOpenGL(Core::Frontend::EmuWindow& emu_window, Core::System& system, |
| 315 | Core::Frontend::GraphicsContext& context) | 317 | Core::Frontend::GraphicsContext& context) |
| 316 | : VideoCore::RendererBase{emu_window}, emu_window{emu_window}, system{system}, frame_mailbox{}, | 318 | : VideoCore::RendererBase{emu_window}, emu_window{emu_window}, system{system}, |
| 317 | has_debug_tool{HasDebugTool()}, context{context} {} | 319 | frame_mailbox{}, context{context}, has_debug_tool{HasDebugTool()} {} |
| 318 | 320 | ||
| 319 | RendererOpenGL::~RendererOpenGL() = default; | 321 | RendererOpenGL::~RendererOpenGL() = default; |
| 320 | 322 | ||
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index fd9fec018..f60bdc60a 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp | |||
| @@ -30,7 +30,7 @@ std::unique_ptr<VideoCore::RendererBase> CreateRenderer(Core::Frontend::EmuWindo | |||
| 30 | return nullptr; | 30 | return nullptr; |
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | } // namespace | 33 | } // Anonymous namespace |
| 34 | 34 | ||
| 35 | namespace VideoCore { | 35 | namespace VideoCore { |
| 36 | 36 | ||
| @@ -39,7 +39,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor | |||
| 39 | const auto scope = context->Acquire(); | 39 | const auto scope = context->Acquire(); |
| 40 | auto renderer = CreateRenderer(emu_window, system, *context); | 40 | auto renderer = CreateRenderer(emu_window, system, *context); |
| 41 | if (!renderer->Init()) { | 41 | if (!renderer->Init()) { |
| 42 | return {}; | 42 | return nullptr; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | if (Settings::values.use_asynchronous_gpu_emulation) { | 45 | if (Settings::values.use_asynchronous_gpu_emulation) { |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index d120ee818..4e9ced8ba 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -42,6 +42,10 @@ EmuThread::~EmuThread() = default; | |||
| 42 | void EmuThread::run() { | 42 | void EmuThread::run() { |
| 43 | MicroProfileOnThreadCreate("EmuThread"); | 43 | MicroProfileOnThreadCreate("EmuThread"); |
| 44 | 44 | ||
| 45 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU | ||
| 46 | // execution. | ||
| 47 | Core::System::GetInstance().GPU().Start(); | ||
| 48 | |||
| 45 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); | 49 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); |
| 46 | 50 | ||
| 47 | Core::System::GetInstance().Renderer().Rasterizer().LoadDiskResources( | 51 | Core::System::GetInstance().Renderer().Rasterizer().LoadDiskResources( |
| @@ -51,10 +55,6 @@ void EmuThread::run() { | |||
| 51 | 55 | ||
| 52 | emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); | 56 | emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); |
| 53 | 57 | ||
| 54 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU | ||
| 55 | // execution. | ||
| 56 | Core::System::GetInstance().GPU().Start(); | ||
| 57 | |||
| 58 | // Holds whether the cpu was running during the last iteration, | 58 | // Holds whether the cpu was running during the last iteration, |
| 59 | // so that the DebugModeLeft signal can be emitted before the | 59 | // so that the DebugModeLeft signal can be emitted before the |
| 60 | // next execution step | 60 | // next execution step |
| @@ -152,7 +152,7 @@ public: | |||
| 152 | if (is_current) { | 152 | if (is_current) { |
| 153 | return; | 153 | return; |
| 154 | } | 154 | } |
| 155 | context->makeCurrent(surface); | 155 | is_current = context->makeCurrent(surface); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | void DoneCurrent() override { | 158 | void DoneCurrent() override { |
| @@ -160,7 +160,11 @@ public: | |||
| 160 | is_current = false; | 160 | is_current = false; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | QOpenGLContext* GetShareContext() const { | 163 | QOpenGLContext* GetShareContext() { |
| 164 | return context.get(); | ||
| 165 | } | ||
| 166 | |||
| 167 | const QOpenGLContext* GetShareContext() const { | ||
| 164 | return context.get(); | 168 | return context.get(); |
| 165 | } | 169 | } |
| 166 | 170 | ||
| @@ -177,13 +181,15 @@ class DummyContext : public Core::Frontend::GraphicsContext {}; | |||
| 177 | 181 | ||
| 178 | class RenderWidget : public QWidget { | 182 | class RenderWidget : public QWidget { |
| 179 | public: | 183 | public: |
| 180 | RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { | 184 | explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { |
| 181 | setAttribute(Qt::WA_NativeWindow); | 185 | setAttribute(Qt::WA_NativeWindow); |
| 182 | setAttribute(Qt::WA_PaintOnScreen); | 186 | setAttribute(Qt::WA_PaintOnScreen); |
| 183 | } | 187 | } |
| 184 | 188 | ||
| 185 | virtual ~RenderWidget() = default; | 189 | virtual ~RenderWidget() = default; |
| 186 | 190 | ||
| 191 | /// Called on the UI thread when this Widget is ready to draw | ||
| 192 | /// Dervied classes can override this to draw the latest frame. | ||
| 187 | virtual void Present() {} | 193 | virtual void Present() {} |
| 188 | 194 | ||
| 189 | void paintEvent(QPaintEvent* event) override { | 195 | void paintEvent(QPaintEvent* event) override { |
| @@ -191,56 +197,6 @@ public: | |||
| 191 | update(); | 197 | update(); |
| 192 | } | 198 | } |
| 193 | 199 | ||
| 194 | void resizeEvent(QResizeEvent* ev) override { | ||
| 195 | render_window->resize(ev->size()); | ||
| 196 | render_window->OnFramebufferSizeChanged(); | ||
| 197 | } | ||
| 198 | |||
| 199 | void keyPressEvent(QKeyEvent* event) override { | ||
| 200 | InputCommon::GetKeyboard()->PressKey(event->key()); | ||
| 201 | } | ||
| 202 | |||
| 203 | void keyReleaseEvent(QKeyEvent* event) override { | ||
| 204 | InputCommon::GetKeyboard()->ReleaseKey(event->key()); | ||
| 205 | } | ||
| 206 | |||
| 207 | void mousePressEvent(QMouseEvent* event) override { | ||
| 208 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | ||
| 209 | return; // touch input is handled in TouchBeginEvent | ||
| 210 | |||
| 211 | const auto pos{event->pos()}; | ||
| 212 | if (event->button() == Qt::LeftButton) { | ||
| 213 | const auto [x, y] = render_window->ScaleTouch(pos); | ||
| 214 | render_window->TouchPressed(x, y); | ||
| 215 | } else if (event->button() == Qt::RightButton) { | ||
| 216 | InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | void mouseMoveEvent(QMouseEvent* event) override { | ||
| 221 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | ||
| 222 | return; // touch input is handled in TouchUpdateEvent | ||
| 223 | |||
| 224 | const auto pos{event->pos()}; | ||
| 225 | const auto [x, y] = render_window->ScaleTouch(pos); | ||
| 226 | render_window->TouchMoved(x, y); | ||
| 227 | InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); | ||
| 228 | } | ||
| 229 | |||
| 230 | void mouseReleaseEvent(QMouseEvent* event) override { | ||
| 231 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | ||
| 232 | return; // touch input is handled in TouchEndEvent | ||
| 233 | |||
| 234 | if (event->button() == Qt::LeftButton) | ||
| 235 | render_window->TouchReleased(); | ||
| 236 | else if (event->button() == Qt::RightButton) | ||
| 237 | InputCommon::GetMotionEmu()->EndTilt(); | ||
| 238 | } | ||
| 239 | |||
| 240 | std::pair<unsigned, unsigned> GetSize() const { | ||
| 241 | return std::make_pair(width(), height()); | ||
| 242 | } | ||
| 243 | |||
| 244 | QPaintEngine* paintEngine() const override { | 200 | QPaintEngine* paintEngine() const override { |
| 245 | return nullptr; | 201 | return nullptr; |
| 246 | } | 202 | } |
| @@ -276,6 +232,7 @@ private: | |||
| 276 | std::unique_ptr<Core::Frontend::GraphicsContext> context{}; | 232 | std::unique_ptr<Core::Frontend::GraphicsContext> context{}; |
| 277 | }; | 233 | }; |
| 278 | 234 | ||
| 235 | #ifdef HAS_VULKAN | ||
| 279 | class VulkanRenderWidget : public RenderWidget { | 236 | class VulkanRenderWidget : public RenderWidget { |
| 280 | public: | 237 | public: |
| 281 | explicit VulkanRenderWidget(GRenderWindow* parent, QVulkanInstance* instance) | 238 | explicit VulkanRenderWidget(GRenderWindow* parent, QVulkanInstance* instance) |
| @@ -284,6 +241,7 @@ public: | |||
| 284 | windowHandle()->setVulkanInstance(instance); | 241 | windowHandle()->setVulkanInstance(instance); |
| 285 | } | 242 | } |
| 286 | }; | 243 | }; |
| 244 | #endif | ||
| 287 | 245 | ||
| 288 | GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread) | 246 | GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread) |
| 289 | : QWidget(parent_), emu_thread(emu_thread) { | 247 | : QWidget(parent_), emu_thread(emu_thread) { |
| @@ -358,7 +316,7 @@ qreal GRenderWindow::windowPixelRatio() const { | |||
| 358 | return devicePixelRatio(); | 316 | return devicePixelRatio(); |
| 359 | } | 317 | } |
| 360 | 318 | ||
| 361 | std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF pos) const { | 319 | std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const { |
| 362 | const qreal pixel_ratio = windowPixelRatio(); | 320 | const qreal pixel_ratio = windowPixelRatio(); |
| 363 | return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})), | 321 | return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})), |
| 364 | static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))}; | 322 | static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))}; |
| @@ -378,8 +336,10 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { | |||
| 378 | } | 336 | } |
| 379 | 337 | ||
| 380 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { | 338 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { |
| 381 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | 339 | // touch input is handled in TouchBeginEvent |
| 382 | return; // touch input is handled in TouchBeginEvent | 340 | if (event->source() == Qt::MouseEventSynthesizedBySystem) { |
| 341 | return; | ||
| 342 | } | ||
| 383 | 343 | ||
| 384 | auto pos = event->pos(); | 344 | auto pos = event->pos(); |
| 385 | if (event->button() == Qt::LeftButton) { | 345 | if (event->button() == Qt::LeftButton) { |
| @@ -391,8 +351,10 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { | |||
| 391 | } | 351 | } |
| 392 | 352 | ||
| 393 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | 353 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { |
| 394 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | 354 | // touch input is handled in TouchUpdateEvent |
| 395 | return; // touch input is handled in TouchUpdateEvent | 355 | if (event->source() == Qt::MouseEventSynthesizedBySystem) { |
| 356 | return; | ||
| 357 | } | ||
| 396 | 358 | ||
| 397 | auto pos = event->pos(); | 359 | auto pos = event->pos(); |
| 398 | const auto [x, y] = ScaleTouch(pos); | 360 | const auto [x, y] = ScaleTouch(pos); |
| @@ -401,13 +363,16 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | |||
| 401 | } | 363 | } |
| 402 | 364 | ||
| 403 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | 365 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { |
| 404 | if (event->source() == Qt::MouseEventSynthesizedBySystem) | 366 | // touch input is handled in TouchEndEvent |
| 405 | return; // touch input is handled in TouchEndEvent | 367 | if (event->source() == Qt::MouseEventSynthesizedBySystem) { |
| 368 | return; | ||
| 369 | } | ||
| 406 | 370 | ||
| 407 | if (event->button() == Qt::LeftButton) | 371 | if (event->button() == Qt::LeftButton) { |
| 408 | this->TouchReleased(); | 372 | this->TouchReleased(); |
| 409 | else if (event->button() == Qt::RightButton) | 373 | } else if (event->button() == Qt::RightButton) { |
| 410 | InputCommon::GetMotionEmu()->EndTilt(); | 374 | InputCommon::GetMotionEmu()->EndTilt(); |
| 375 | } | ||
| 411 | } | 376 | } |
| 412 | 377 | ||
| 413 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { | 378 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 3739ec7ed..d69078df1 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -7,11 +7,12 @@ | |||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include <condition_variable> | 8 | #include <condition_variable> |
| 9 | #include <mutex> | 9 | #include <mutex> |
| 10 | #include <thread> | 10 | |
| 11 | #include <QImage> | 11 | #include <QImage> |
| 12 | #include <QThread> | 12 | #include <QThread> |
| 13 | #include <QWidget> | 13 | #include <QWidget> |
| 14 | #include <QWindow> | 14 | #include <QWindow> |
| 15 | |||
| 15 | #include "common/thread.h" | 16 | #include "common/thread.h" |
| 16 | #include "core/core.h" | 17 | #include "core/core.h" |
| 17 | #include "core/frontend/emu_window.h" | 18 | #include "core/frontend/emu_window.h" |
| @@ -84,8 +85,8 @@ private: | |||
| 84 | bool exec_step = false; | 85 | bool exec_step = false; |
| 85 | bool running = false; | 86 | bool running = false; |
| 86 | std::atomic_bool stop_run{false}; | 87 | std::atomic_bool stop_run{false}; |
| 87 | std::mutex running_mutex = {}; | 88 | std::mutex running_mutex; |
| 88 | std::condition_variable running_cv = {}; | 89 | std::condition_variable running_cv; |
| 89 | 90 | ||
| 90 | signals: | 91 | signals: |
| 91 | /** | 92 | /** |
| @@ -154,7 +155,7 @@ public: | |||
| 154 | 155 | ||
| 155 | void CaptureScreenshot(u32 res_scale, const QString& screenshot_path); | 156 | void CaptureScreenshot(u32 res_scale, const QString& screenshot_path); |
| 156 | 157 | ||
| 157 | std::pair<u32, u32> ScaleTouch(const QPointF pos) const; | 158 | std::pair<u32, u32> ScaleTouch(const QPointF& pos) const; |
| 158 | 159 | ||
| 159 | public slots: | 160 | public slots: |
| 160 | void OnEmulationStarting(EmuThread* emu_thread); | 161 | void OnEmulationStarting(EmuThread* emu_thread); |
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index e5db7d819..4d2ea7e9e 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -230,11 +230,11 @@ int main(int argc, char** argv) { | |||
| 230 | 230 | ||
| 231 | system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); | 231 | system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); |
| 232 | 232 | ||
| 233 | system.Renderer().Rasterizer().LoadDiskResources(); | ||
| 234 | |||
| 235 | // Core is loaded, start the GPU (makes the GPU contexts current to this thread) | 233 | // Core is loaded, start the GPU (makes the GPU contexts current to this thread) |
| 236 | system.GPU().Start(); | 234 | system.GPU().Start(); |
| 237 | 235 | ||
| 236 | system.Renderer().Rasterizer().LoadDiskResources(); | ||
| 237 | |||
| 238 | std::thread render_thread([&emu_window] { emu_window->Present(); }); | 238 | std::thread render_thread([&emu_window] { emu_window->Present(); }); |
| 239 | while (emu_window->IsOpen()) { | 239 | while (emu_window->IsOpen()) { |
| 240 | system.RunLoop(); | 240 | system.RunLoop(); |
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp index a1bdb1a12..a837430cc 100644 --- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp +++ b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp | |||
| @@ -102,8 +102,6 @@ EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() { | |||
| 102 | LOG_INFO(Frontend, "yuzu-tester Version: {} | {}-{}", Common::g_build_fullname, | 102 | LOG_INFO(Frontend, "yuzu-tester Version: {} | {}-{}", Common::g_build_fullname, |
| 103 | Common::g_scm_branch, Common::g_scm_desc); | 103 | Common::g_scm_branch, Common::g_scm_desc); |
| 104 | Settings::LogSettings(); | 104 | Settings::LogSettings(); |
| 105 | |||
| 106 | DoneCurrent(); | ||
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() { | 107 | EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() { |
| @@ -114,14 +112,6 @@ EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() { | |||
| 114 | 112 | ||
| 115 | void EmuWindow_SDL2_Hide::PollEvents() {} | 113 | void EmuWindow_SDL2_Hide::PollEvents() {} |
| 116 | 114 | ||
| 117 | void EmuWindow_SDL2_Hide::MakeCurrent() { | ||
| 118 | SDL_GL_MakeCurrent(render_window, gl_context); | ||
| 119 | } | ||
| 120 | |||
| 121 | void EmuWindow_SDL2_Hide::DoneCurrent() { | ||
| 122 | SDL_GL_MakeCurrent(render_window, nullptr); | ||
| 123 | } | ||
| 124 | |||
| 125 | bool EmuWindow_SDL2_Hide::IsShown() const { | 115 | bool EmuWindow_SDL2_Hide::IsShown() const { |
| 126 | return false; | 116 | return false; |
| 127 | } | 117 | } |
| @@ -129,3 +119,35 @@ bool EmuWindow_SDL2_Hide::IsShown() const { | |||
| 129 | void EmuWindow_SDL2_Hide::RetrieveVulkanHandlers(void*, void*, void*) const { | 119 | void EmuWindow_SDL2_Hide::RetrieveVulkanHandlers(void*, void*, void*) const { |
| 130 | UNREACHABLE(); | 120 | UNREACHABLE(); |
| 131 | } | 121 | } |
| 122 | |||
| 123 | class SDLGLContext : public Core::Frontend::GraphicsContext { | ||
| 124 | public: | ||
| 125 | explicit SDLGLContext() { | ||
| 126 | // create a hidden window to make the shared context against | ||
| 127 | window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0, | ||
| 128 | SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL); | ||
| 129 | context = SDL_GL_CreateContext(window); | ||
| 130 | } | ||
| 131 | |||
| 132 | ~SDLGLContext() { | ||
| 133 | DoneCurrent(); | ||
| 134 | SDL_GL_DeleteContext(context); | ||
| 135 | SDL_DestroyWindow(window); | ||
| 136 | } | ||
| 137 | |||
| 138 | void MakeCurrent() override { | ||
| 139 | SDL_GL_MakeCurrent(window, context); | ||
| 140 | } | ||
| 141 | |||
| 142 | void DoneCurrent() override { | ||
| 143 | SDL_GL_MakeCurrent(window, nullptr); | ||
| 144 | } | ||
| 145 | |||
| 146 | private: | ||
| 147 | SDL_Window* window; | ||
| 148 | SDL_GLContext context; | ||
| 149 | }; | ||
| 150 | |||
| 151 | std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_Hide::CreateSharedContext() const { | ||
| 152 | return std::make_unique<SDLGLContext>(); | ||
| 153 | } | ||
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h index b13e15309..9f5d04fca 100644 --- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h +++ b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h | |||
| @@ -16,12 +16,6 @@ public: | |||
| 16 | /// Polls window events | 16 | /// Polls window events |
| 17 | void PollEvents() override; | 17 | void PollEvents() override; |
| 18 | 18 | ||
| 19 | /// Makes the graphics context current for the caller thread | ||
| 20 | void MakeCurrent() override; | ||
| 21 | |||
| 22 | /// Releases the GL context from the caller thread | ||
| 23 | void DoneCurrent() override; | ||
| 24 | |||
| 25 | /// Whether the screen is being shown or not. | 19 | /// Whether the screen is being shown or not. |
| 26 | bool IsShown() const override; | 20 | bool IsShown() const override; |
| 27 | 21 | ||
| @@ -29,8 +23,7 @@ public: | |||
| 29 | void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, | 23 | void RetrieveVulkanHandlers(void* get_instance_proc_addr, void* instance, |
| 30 | void* surface) const override; | 24 | void* surface) const override; |
| 31 | 25 | ||
| 32 | /// Whether the window is still open, and a close request hasn't yet been sent | 26 | std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; |
| 33 | bool IsOpen() const; | ||
| 34 | 27 | ||
| 35 | private: | 28 | private: |
| 36 | /// Whether the GPU and driver supports the OpenGL extension required | 29 | /// Whether the GPU and driver supports the OpenGL extension required |
diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp index 94ad50cb3..676e70ebd 100644 --- a/src/yuzu_tester/yuzu.cpp +++ b/src/yuzu_tester/yuzu.cpp | |||
| @@ -164,11 +164,6 @@ int main(int argc, char** argv) { | |||
| 164 | 164 | ||
| 165 | std::unique_ptr<EmuWindow_SDL2_Hide> emu_window{std::make_unique<EmuWindow_SDL2_Hide>()}; | 165 | std::unique_ptr<EmuWindow_SDL2_Hide> emu_window{std::make_unique<EmuWindow_SDL2_Hide>()}; |
| 166 | 166 | ||
| 167 | if (!Settings::values.use_multi_core) { | ||
| 168 | // Single core mode must acquire OpenGL context for entire emulation session | ||
| 169 | emu_window->MakeCurrent(); | ||
| 170 | } | ||
| 171 | |||
| 172 | bool finished = false; | 167 | bool finished = false; |
| 173 | int return_value = 0; | 168 | int return_value = 0; |
| 174 | const auto callback = [&finished, | 169 | const auto callback = [&finished, |
| @@ -257,6 +252,7 @@ int main(int argc, char** argv) { | |||
| 257 | 252 | ||
| 258 | system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDLHideTester"); | 253 | system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDLHideTester"); |
| 259 | 254 | ||
| 255 | system.GPU().Start(); | ||
| 260 | system.Renderer().Rasterizer().LoadDiskResources(); | 256 | system.Renderer().Rasterizer().LoadDiskResources(); |
| 261 | 257 | ||
| 262 | while (!finished) { | 258 | while (!finished) { |