bootmanager.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <glad/glad.h>
  5. #include <QApplication>
  6. #include <QHBoxLayout>
  7. #include <QKeyEvent>
  8. #include <QMessageBox>
  9. #include <QOffscreenSurface>
  10. #include <QOpenGLContext>
  11. #include <QPainter>
  12. #include <QScreen>
  13. #include <QStringList>
  14. #include <QWindow>
  15. #if !defined(WIN32) && HAS_VULKAN
  16. #include <qpa/qplatformnativeinterface.h>
  17. #endif
  18. #include <fmt/format.h>
  19. #include "common/assert.h"
  20. #include "common/microprofile.h"
  21. #include "common/scm_rev.h"
  22. #include "common/scope_exit.h"
  23. #include "core/core.h"
  24. #include "core/frontend/framebuffer_layout.h"
  25. #include "core/settings.h"
  26. #include "input_common/keyboard.h"
  27. #include "input_common/main.h"
  28. #include "input_common/motion_emu.h"
  29. #include "video_core/renderer_base.h"
  30. #include "video_core/video_core.h"
  31. #include "yuzu/bootmanager.h"
  32. #include "yuzu/main.h"
  33. EmuThread::EmuThread() = default;
  34. EmuThread::~EmuThread() = default;
  35. void EmuThread::run() {
  36. MicroProfileOnThreadCreate("EmuThread");
  37. // Main process has been loaded. Make the context current to this thread and begin GPU and CPU
  38. // execution.
  39. Core::System::GetInstance().GPU().Start();
  40. emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
  41. Core::System::GetInstance().Renderer().Rasterizer().LoadDiskResources(
  42. stop_run, [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) {
  43. emit LoadProgress(stage, value, total);
  44. });
  45. emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0);
  46. // Holds whether the cpu was running during the last iteration,
  47. // so that the DebugModeLeft signal can be emitted before the
  48. // next execution step
  49. bool was_active = false;
  50. while (!stop_run) {
  51. if (running) {
  52. if (!was_active)
  53. emit DebugModeLeft();
  54. Core::System::ResultStatus result = Core::System::GetInstance().RunLoop();
  55. if (result != Core::System::ResultStatus::Success) {
  56. this->SetRunning(false);
  57. emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails());
  58. }
  59. was_active = running || exec_step;
  60. if (!was_active && !stop_run)
  61. emit DebugModeEntered();
  62. } else if (exec_step) {
  63. if (!was_active)
  64. emit DebugModeLeft();
  65. exec_step = false;
  66. Core::System::GetInstance().SingleStep();
  67. emit DebugModeEntered();
  68. yieldCurrentThread();
  69. was_active = false;
  70. } else {
  71. std::unique_lock lock{running_mutex};
  72. running_cv.wait(lock, [this] { return IsRunning() || exec_step || stop_run; });
  73. }
  74. }
  75. // Shutdown the core emulation
  76. Core::System::GetInstance().Shutdown();
  77. #if MICROPROFILE_ENABLED
  78. MicroProfileOnThreadExit();
  79. #endif
  80. }
  81. class OpenGLSharedContext : public Core::Frontend::GraphicsContext {
  82. public:
  83. /// Create the original context that should be shared from
  84. explicit OpenGLSharedContext(QSurface* surface) : surface(surface) {
  85. QSurfaceFormat format;
  86. format.setVersion(4, 3);
  87. format.setProfile(QSurfaceFormat::CompatibilityProfile);
  88. format.setOption(QSurfaceFormat::FormatOption::DeprecatedFunctions);
  89. // TODO: expose a setting for buffer value (ie default/single/double/triple)
  90. format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
  91. format.setSwapInterval(0);
  92. context = std::make_unique<QOpenGLContext>();
  93. context->setFormat(format);
  94. if (!context->create()) {
  95. LOG_ERROR(Frontend, "Unable to create main openGL context");
  96. }
  97. }
  98. /// Create the shared contexts for rendering and presentation
  99. explicit OpenGLSharedContext(QOpenGLContext* share_context, QSurface* main_surface = nullptr) {
  100. // disable vsync for any shared contexts
  101. auto format = share_context->format();
  102. format.setSwapInterval(main_surface ? Settings::values.use_vsync : 0);
  103. context = std::make_unique<QOpenGLContext>();
  104. context->setShareContext(share_context);
  105. context->setFormat(format);
  106. if (!context->create()) {
  107. LOG_ERROR(Frontend, "Unable to create shared openGL context");
  108. }
  109. if (!main_surface) {
  110. offscreen_surface = std::make_unique<QOffscreenSurface>(nullptr);
  111. offscreen_surface->setFormat(format);
  112. offscreen_surface->create();
  113. surface = offscreen_surface.get();
  114. } else {
  115. surface = main_surface;
  116. }
  117. }
  118. ~OpenGLSharedContext() {
  119. DoneCurrent();
  120. }
  121. void SwapBuffers() override {
  122. context->swapBuffers(surface);
  123. }
  124. void MakeCurrent() override {
  125. if (is_current) {
  126. return;
  127. }
  128. is_current = context->makeCurrent(surface);
  129. }
  130. void DoneCurrent() override {
  131. if (!is_current) {
  132. return;
  133. }
  134. context->doneCurrent();
  135. is_current = false;
  136. }
  137. QOpenGLContext* GetShareContext() {
  138. return context.get();
  139. }
  140. const QOpenGLContext* GetShareContext() const {
  141. return context.get();
  142. }
  143. private:
  144. // Avoid using Qt parent system here since we might move the QObjects to new threads
  145. // As a note, this means we should avoid using slots/signals with the objects too
  146. std::unique_ptr<QOpenGLContext> context;
  147. std::unique_ptr<QOffscreenSurface> offscreen_surface{};
  148. QSurface* surface;
  149. bool is_current = false;
  150. };
  151. class DummyContext : public Core::Frontend::GraphicsContext {};
  152. class RenderWidget : public QWidget {
  153. public:
  154. explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) {
  155. setAttribute(Qt::WA_NativeWindow);
  156. setAttribute(Qt::WA_PaintOnScreen);
  157. }
  158. virtual ~RenderWidget() = default;
  159. /// Called on the UI thread when this Widget is ready to draw
  160. /// Dervied classes can override this to draw the latest frame.
  161. virtual void Present() {}
  162. void paintEvent(QPaintEvent* event) override {
  163. Present();
  164. update();
  165. }
  166. QPaintEngine* paintEngine() const override {
  167. return nullptr;
  168. }
  169. private:
  170. GRenderWindow* render_window;
  171. };
  172. class OpenGLRenderWidget : public RenderWidget {
  173. public:
  174. explicit OpenGLRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {
  175. windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
  176. }
  177. void SetContext(std::unique_ptr<Core::Frontend::GraphicsContext>&& context_) {
  178. context = std::move(context_);
  179. }
  180. void Present() override {
  181. if (!isVisible()) {
  182. return;
  183. }
  184. context->MakeCurrent();
  185. if (Core::System::GetInstance().Renderer().TryPresent(100)) {
  186. context->SwapBuffers();
  187. glFinish();
  188. }
  189. }
  190. private:
  191. std::unique_ptr<Core::Frontend::GraphicsContext> context{};
  192. };
  193. #ifdef HAS_VULKAN
  194. class VulkanRenderWidget : public RenderWidget {
  195. public:
  196. explicit VulkanRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {
  197. windowHandle()->setSurfaceType(QWindow::VulkanSurface);
  198. }
  199. };
  200. #endif
  201. static Core::Frontend::WindowSystemType GetWindowSystemType() {
  202. // Determine WSI type based on Qt platform.
  203. QString platform_name = QGuiApplication::platformName();
  204. if (platform_name == QStringLiteral("windows"))
  205. return Core::Frontend::WindowSystemType::Windows;
  206. else if (platform_name == QStringLiteral("xcb"))
  207. return Core::Frontend::WindowSystemType::X11;
  208. else if (platform_name == QStringLiteral("wayland"))
  209. return Core::Frontend::WindowSystemType::Wayland;
  210. LOG_CRITICAL(Frontend, "Unknown Qt platform!");
  211. return Core::Frontend::WindowSystemType::Windows;
  212. }
  213. static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
  214. Core::Frontend::EmuWindow::WindowSystemInfo wsi;
  215. wsi.type = GetWindowSystemType();
  216. #ifdef HAS_VULKAN
  217. // Our Win32 Qt external doesn't have the private API.
  218. #if defined(WIN32) || defined(__APPLE__)
  219. wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
  220. #else
  221. QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
  222. wsi.display_connection = pni->nativeResourceForWindow("display", window);
  223. if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
  224. wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
  225. else
  226. wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
  227. #endif
  228. wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
  229. #endif
  230. return wsi;
  231. }
  232. GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread_)
  233. : QWidget(parent_), emu_thread(emu_thread_) {
  234. setWindowTitle(QStringLiteral("yuzu %1 | %2-%3")
  235. .arg(QString::fromUtf8(Common::g_build_name),
  236. QString::fromUtf8(Common::g_scm_branch),
  237. QString::fromUtf8(Common::g_scm_desc)));
  238. setAttribute(Qt::WA_AcceptTouchEvents);
  239. auto layout = new QHBoxLayout(this);
  240. layout->setMargin(0);
  241. setLayout(layout);
  242. InputCommon::Init();
  243. connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete);
  244. }
  245. GRenderWindow::~GRenderWindow() {
  246. InputCommon::Shutdown();
  247. }
  248. void GRenderWindow::PollEvents() {
  249. if (!first_frame) {
  250. first_frame = true;
  251. emit FirstFrameDisplayed();
  252. }
  253. }
  254. bool GRenderWindow::IsShown() const {
  255. return !isMinimized();
  256. }
  257. // On Qt 5.0+, this correctly gets the size of the framebuffer (pixels).
  258. //
  259. // Older versions get the window size (density independent pixels),
  260. // and hence, do not support DPI scaling ("retina" displays).
  261. // The result will be a viewport that is smaller than the extent of the window.
  262. void GRenderWindow::OnFramebufferSizeChanged() {
  263. // Screen changes potentially incur a change in screen DPI, hence we should update the
  264. // framebuffer size
  265. const qreal pixel_ratio = windowPixelRatio();
  266. const u32 width = this->width() * pixel_ratio;
  267. const u32 height = this->height() * pixel_ratio;
  268. UpdateCurrentFramebufferLayout(width, height);
  269. }
  270. void GRenderWindow::BackupGeometry() {
  271. geometry = QWidget::saveGeometry();
  272. }
  273. void GRenderWindow::RestoreGeometry() {
  274. // We don't want to back up the geometry here (obviously)
  275. QWidget::restoreGeometry(geometry);
  276. }
  277. void GRenderWindow::restoreGeometry(const QByteArray& geometry) {
  278. // Make sure users of this class don't need to deal with backing up the geometry themselves
  279. QWidget::restoreGeometry(geometry);
  280. BackupGeometry();
  281. }
  282. QByteArray GRenderWindow::saveGeometry() {
  283. // If we are a top-level widget, store the current geometry
  284. // otherwise, store the last backup
  285. if (parent() == nullptr) {
  286. return QWidget::saveGeometry();
  287. }
  288. return geometry;
  289. }
  290. qreal GRenderWindow::windowPixelRatio() const {
  291. return devicePixelRatio();
  292. }
  293. std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const {
  294. const qreal pixel_ratio = windowPixelRatio();
  295. return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})),
  296. static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))};
  297. }
  298. void GRenderWindow::closeEvent(QCloseEvent* event) {
  299. emit Closed();
  300. QWidget::closeEvent(event);
  301. }
  302. void GRenderWindow::keyPressEvent(QKeyEvent* event) {
  303. InputCommon::GetKeyboard()->PressKey(event->key());
  304. }
  305. void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
  306. InputCommon::GetKeyboard()->ReleaseKey(event->key());
  307. }
  308. void GRenderWindow::mousePressEvent(QMouseEvent* event) {
  309. // touch input is handled in TouchBeginEvent
  310. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  311. return;
  312. }
  313. auto pos = event->pos();
  314. if (event->button() == Qt::LeftButton) {
  315. const auto [x, y] = ScaleTouch(pos);
  316. this->TouchPressed(x, y);
  317. } else if (event->button() == Qt::RightButton) {
  318. InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y());
  319. }
  320. }
  321. void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
  322. // touch input is handled in TouchUpdateEvent
  323. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  324. return;
  325. }
  326. auto pos = event->pos();
  327. const auto [x, y] = ScaleTouch(pos);
  328. this->TouchMoved(x, y);
  329. InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y());
  330. }
  331. void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
  332. // touch input is handled in TouchEndEvent
  333. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  334. return;
  335. }
  336. if (event->button() == Qt::LeftButton) {
  337. this->TouchReleased();
  338. } else if (event->button() == Qt::RightButton) {
  339. InputCommon::GetMotionEmu()->EndTilt();
  340. }
  341. }
  342. void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
  343. // TouchBegin always has exactly one touch point, so take the .first()
  344. const auto [x, y] = ScaleTouch(event->touchPoints().first().pos());
  345. this->TouchPressed(x, y);
  346. }
  347. void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
  348. QPointF pos;
  349. int active_points = 0;
  350. // average all active touch points
  351. for (const auto tp : event->touchPoints()) {
  352. if (tp.state() & (Qt::TouchPointPressed | Qt::TouchPointMoved | Qt::TouchPointStationary)) {
  353. active_points++;
  354. pos += tp.pos();
  355. }
  356. }
  357. pos /= active_points;
  358. const auto [x, y] = ScaleTouch(pos);
  359. this->TouchMoved(x, y);
  360. }
  361. void GRenderWindow::TouchEndEvent() {
  362. this->TouchReleased();
  363. }
  364. bool GRenderWindow::event(QEvent* event) {
  365. if (event->type() == QEvent::TouchBegin) {
  366. TouchBeginEvent(static_cast<QTouchEvent*>(event));
  367. return true;
  368. } else if (event->type() == QEvent::TouchUpdate) {
  369. TouchUpdateEvent(static_cast<QTouchEvent*>(event));
  370. return true;
  371. } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
  372. TouchEndEvent();
  373. return true;
  374. }
  375. return QWidget::event(event);
  376. }
  377. void GRenderWindow::focusOutEvent(QFocusEvent* event) {
  378. QWidget::focusOutEvent(event);
  379. InputCommon::GetKeyboard()->ReleaseAllKeys();
  380. }
  381. void GRenderWindow::resizeEvent(QResizeEvent* event) {
  382. QWidget::resizeEvent(event);
  383. OnFramebufferSizeChanged();
  384. }
  385. std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const {
  386. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  387. auto c = static_cast<OpenGLSharedContext*>(main_context.get());
  388. // Bind the shared contexts to the main surface in case the backend wants to take over
  389. // presentation
  390. return std::make_unique<OpenGLSharedContext>(c->GetShareContext(),
  391. child_widget->windowHandle());
  392. }
  393. return std::make_unique<DummyContext>();
  394. }
  395. bool GRenderWindow::InitRenderTarget() {
  396. ReleaseRenderTarget();
  397. first_frame = false;
  398. switch (Settings::values.renderer_backend) {
  399. case Settings::RendererBackend::OpenGL:
  400. if (!InitializeOpenGL()) {
  401. return false;
  402. }
  403. break;
  404. case Settings::RendererBackend::Vulkan:
  405. if (!InitializeVulkan()) {
  406. return false;
  407. }
  408. break;
  409. }
  410. // Update the Window System information with the new render target
  411. window_info = GetWindowSystemInfo(child_widget->windowHandle());
  412. child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  413. layout()->addWidget(child_widget);
  414. // Reset minimum required size to avoid resizing issues on the main window after restarting.
  415. setMinimumSize(1, 1);
  416. resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  417. OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
  418. OnFramebufferSizeChanged();
  419. BackupGeometry();
  420. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  421. if (!LoadOpenGL()) {
  422. return false;
  423. }
  424. }
  425. return true;
  426. }
  427. void GRenderWindow::ReleaseRenderTarget() {
  428. if (child_widget) {
  429. layout()->removeWidget(child_widget);
  430. child_widget->deleteLater();
  431. child_widget = nullptr;
  432. }
  433. main_context.reset();
  434. }
  435. void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) {
  436. auto& renderer = Core::System::GetInstance().Renderer();
  437. if (res_scale == 0) {
  438. res_scale = VideoCore::GetResolutionScaleFactor(renderer);
  439. }
  440. const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
  441. screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
  442. renderer.RequestScreenshot(
  443. screenshot_image.bits(),
  444. [=] {
  445. const std::string std_screenshot_path = screenshot_path.toStdString();
  446. if (screenshot_image.mirrored(false, true).save(screenshot_path)) {
  447. LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path);
  448. } else {
  449. LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path);
  450. }
  451. },
  452. layout);
  453. }
  454. void GRenderWindow::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) {
  455. setMinimumSize(minimal_size.first, minimal_size.second);
  456. }
  457. bool GRenderWindow::InitializeOpenGL() {
  458. // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
  459. // WA_DontShowOnScreen, WA_DeleteOnClose
  460. auto child = new OpenGLRenderWidget(this);
  461. child_widget = child;
  462. child_widget->windowHandle()->create();
  463. auto context = std::make_shared<OpenGLSharedContext>(child->windowHandle());
  464. main_context = context;
  465. child->SetContext(
  466. std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle()));
  467. return true;
  468. }
  469. bool GRenderWindow::InitializeVulkan() {
  470. #ifdef HAS_VULKAN
  471. auto child = new VulkanRenderWidget(this);
  472. child_widget = child;
  473. child_widget->windowHandle()->create();
  474. main_context = std::make_unique<DummyContext>();
  475. return true;
  476. #else
  477. QMessageBox::critical(this, tr("Vulkan not available!"),
  478. tr("yuzu has not been compiled with Vulkan support."));
  479. return false;
  480. #endif
  481. }
  482. bool GRenderWindow::LoadOpenGL() {
  483. auto context = CreateSharedContext();
  484. auto scope = context->Acquire();
  485. if (!gladLoadGL()) {
  486. QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"),
  487. tr("Your GPU may not support OpenGL 4.3, or you do not have the "
  488. "latest graphics driver."));
  489. return false;
  490. }
  491. QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions();
  492. if (!unsupported_gl_extensions.empty()) {
  493. QMessageBox::critical(
  494. this, tr("Error while initializing OpenGL!"),
  495. tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you "
  496. "have the latest graphics driver.<br><br>Unsupported extensions:<br>") +
  497. unsupported_gl_extensions.join(QStringLiteral("<br>")));
  498. return false;
  499. }
  500. return true;
  501. }
  502. QStringList GRenderWindow::GetUnsupportedGLExtensions() const {
  503. QStringList unsupported_ext;
  504. if (!GLAD_GL_ARB_buffer_storage)
  505. unsupported_ext.append(QStringLiteral("ARB_buffer_storage"));
  506. if (!GLAD_GL_ARB_direct_state_access)
  507. unsupported_ext.append(QStringLiteral("ARB_direct_state_access"));
  508. if (!GLAD_GL_ARB_vertex_type_10f_11f_11f_rev)
  509. unsupported_ext.append(QStringLiteral("ARB_vertex_type_10f_11f_11f_rev"));
  510. if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge)
  511. unsupported_ext.append(QStringLiteral("ARB_texture_mirror_clamp_to_edge"));
  512. if (!GLAD_GL_ARB_multi_bind)
  513. unsupported_ext.append(QStringLiteral("ARB_multi_bind"));
  514. if (!GLAD_GL_ARB_clip_control)
  515. unsupported_ext.append(QStringLiteral("ARB_clip_control"));
  516. // Extensions required to support some texture formats.
  517. if (!GLAD_GL_EXT_texture_compression_s3tc)
  518. unsupported_ext.append(QStringLiteral("EXT_texture_compression_s3tc"));
  519. if (!GLAD_GL_ARB_texture_compression_rgtc)
  520. unsupported_ext.append(QStringLiteral("ARB_texture_compression_rgtc"));
  521. if (!GLAD_GL_ARB_depth_buffer_float)
  522. unsupported_ext.append(QStringLiteral("ARB_depth_buffer_float"));
  523. for (const QString& ext : unsupported_ext)
  524. LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString());
  525. return unsupported_ext;
  526. }
  527. void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
  528. this->emu_thread = emu_thread;
  529. }
  530. void GRenderWindow::OnEmulationStopping() {
  531. emu_thread = nullptr;
  532. }
  533. void GRenderWindow::showEvent(QShowEvent* event) {
  534. QWidget::showEvent(event);
  535. // windowHandle() is not initialized until the Window is shown, so we connect it here.
  536. connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged,
  537. Qt::UniqueConnection);
  538. }