bootmanager.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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. glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
  186. if (Core::System::GetInstance().Renderer().TryPresent(100)) {
  187. context->SwapBuffers();
  188. glFinish();
  189. }
  190. }
  191. private:
  192. std::unique_ptr<Core::Frontend::GraphicsContext> context{};
  193. };
  194. #ifdef HAS_VULKAN
  195. class VulkanRenderWidget : public RenderWidget {
  196. public:
  197. explicit VulkanRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {
  198. windowHandle()->setSurfaceType(QWindow::VulkanSurface);
  199. }
  200. };
  201. #endif
  202. static Core::Frontend::WindowSystemType GetWindowSystemType() {
  203. // Determine WSI type based on Qt platform.
  204. QString platform_name = QGuiApplication::platformName();
  205. if (platform_name == QStringLiteral("windows"))
  206. return Core::Frontend::WindowSystemType::Windows;
  207. else if (platform_name == QStringLiteral("xcb"))
  208. return Core::Frontend::WindowSystemType::X11;
  209. else if (platform_name == QStringLiteral("wayland"))
  210. return Core::Frontend::WindowSystemType::Wayland;
  211. LOG_CRITICAL(Frontend, "Unknown Qt platform!");
  212. return Core::Frontend::WindowSystemType::Windows;
  213. }
  214. static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) {
  215. Core::Frontend::EmuWindow::WindowSystemInfo wsi;
  216. wsi.type = GetWindowSystemType();
  217. #ifdef HAS_VULKAN
  218. // Our Win32 Qt external doesn't have the private API.
  219. #if defined(WIN32) || defined(__APPLE__)
  220. wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
  221. #else
  222. QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
  223. wsi.display_connection = pni->nativeResourceForWindow("display", window);
  224. if (wsi.type == Core::Frontend::WindowSystemType::Wayland)
  225. wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
  226. else
  227. wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
  228. #endif
  229. wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
  230. #endif
  231. return wsi;
  232. }
  233. GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread_)
  234. : QWidget(parent_), emu_thread(emu_thread_) {
  235. setWindowTitle(QStringLiteral("yuzu %1 | %2-%3")
  236. .arg(QString::fromUtf8(Common::g_build_name),
  237. QString::fromUtf8(Common::g_scm_branch),
  238. QString::fromUtf8(Common::g_scm_desc)));
  239. setAttribute(Qt::WA_AcceptTouchEvents);
  240. auto layout = new QHBoxLayout(this);
  241. layout->setMargin(0);
  242. setLayout(layout);
  243. InputCommon::Init();
  244. connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete);
  245. }
  246. GRenderWindow::~GRenderWindow() {
  247. InputCommon::Shutdown();
  248. }
  249. void GRenderWindow::PollEvents() {
  250. if (!first_frame) {
  251. first_frame = true;
  252. emit FirstFrameDisplayed();
  253. }
  254. }
  255. bool GRenderWindow::IsShown() const {
  256. return !isMinimized();
  257. }
  258. // On Qt 5.0+, this correctly gets the size of the framebuffer (pixels).
  259. //
  260. // Older versions get the window size (density independent pixels),
  261. // and hence, do not support DPI scaling ("retina" displays).
  262. // The result will be a viewport that is smaller than the extent of the window.
  263. void GRenderWindow::OnFramebufferSizeChanged() {
  264. // Screen changes potentially incur a change in screen DPI, hence we should update the
  265. // framebuffer size
  266. const qreal pixel_ratio = windowPixelRatio();
  267. const u32 width = this->width() * pixel_ratio;
  268. const u32 height = this->height() * pixel_ratio;
  269. UpdateCurrentFramebufferLayout(width, height);
  270. }
  271. void GRenderWindow::BackupGeometry() {
  272. geometry = QWidget::saveGeometry();
  273. }
  274. void GRenderWindow::RestoreGeometry() {
  275. // We don't want to back up the geometry here (obviously)
  276. QWidget::restoreGeometry(geometry);
  277. }
  278. void GRenderWindow::restoreGeometry(const QByteArray& geometry) {
  279. // Make sure users of this class don't need to deal with backing up the geometry themselves
  280. QWidget::restoreGeometry(geometry);
  281. BackupGeometry();
  282. }
  283. QByteArray GRenderWindow::saveGeometry() {
  284. // If we are a top-level widget, store the current geometry
  285. // otherwise, store the last backup
  286. if (parent() == nullptr) {
  287. return QWidget::saveGeometry();
  288. }
  289. return geometry;
  290. }
  291. qreal GRenderWindow::windowPixelRatio() const {
  292. return devicePixelRatio();
  293. }
  294. std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const {
  295. const qreal pixel_ratio = windowPixelRatio();
  296. return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})),
  297. static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))};
  298. }
  299. void GRenderWindow::closeEvent(QCloseEvent* event) {
  300. emit Closed();
  301. QWidget::closeEvent(event);
  302. }
  303. void GRenderWindow::keyPressEvent(QKeyEvent* event) {
  304. InputCommon::GetKeyboard()->PressKey(event->key());
  305. }
  306. void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
  307. InputCommon::GetKeyboard()->ReleaseKey(event->key());
  308. }
  309. void GRenderWindow::mousePressEvent(QMouseEvent* event) {
  310. // touch input is handled in TouchBeginEvent
  311. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  312. return;
  313. }
  314. auto pos = event->pos();
  315. if (event->button() == Qt::LeftButton) {
  316. const auto [x, y] = ScaleTouch(pos);
  317. this->TouchPressed(x, y);
  318. } else if (event->button() == Qt::RightButton) {
  319. InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y());
  320. }
  321. }
  322. void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
  323. // touch input is handled in TouchUpdateEvent
  324. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  325. return;
  326. }
  327. auto pos = event->pos();
  328. const auto [x, y] = ScaleTouch(pos);
  329. this->TouchMoved(x, y);
  330. InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y());
  331. }
  332. void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
  333. // touch input is handled in TouchEndEvent
  334. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  335. return;
  336. }
  337. if (event->button() == Qt::LeftButton) {
  338. this->TouchReleased();
  339. } else if (event->button() == Qt::RightButton) {
  340. InputCommon::GetMotionEmu()->EndTilt();
  341. }
  342. }
  343. void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
  344. // TouchBegin always has exactly one touch point, so take the .first()
  345. const auto [x, y] = ScaleTouch(event->touchPoints().first().pos());
  346. this->TouchPressed(x, y);
  347. }
  348. void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
  349. QPointF pos;
  350. int active_points = 0;
  351. // average all active touch points
  352. for (const auto tp : event->touchPoints()) {
  353. if (tp.state() & (Qt::TouchPointPressed | Qt::TouchPointMoved | Qt::TouchPointStationary)) {
  354. active_points++;
  355. pos += tp.pos();
  356. }
  357. }
  358. pos /= active_points;
  359. const auto [x, y] = ScaleTouch(pos);
  360. this->TouchMoved(x, y);
  361. }
  362. void GRenderWindow::TouchEndEvent() {
  363. this->TouchReleased();
  364. }
  365. bool GRenderWindow::event(QEvent* event) {
  366. if (event->type() == QEvent::TouchBegin) {
  367. TouchBeginEvent(static_cast<QTouchEvent*>(event));
  368. return true;
  369. } else if (event->type() == QEvent::TouchUpdate) {
  370. TouchUpdateEvent(static_cast<QTouchEvent*>(event));
  371. return true;
  372. } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
  373. TouchEndEvent();
  374. return true;
  375. }
  376. return QWidget::event(event);
  377. }
  378. void GRenderWindow::focusOutEvent(QFocusEvent* event) {
  379. QWidget::focusOutEvent(event);
  380. InputCommon::GetKeyboard()->ReleaseAllKeys();
  381. }
  382. void GRenderWindow::resizeEvent(QResizeEvent* event) {
  383. QWidget::resizeEvent(event);
  384. OnFramebufferSizeChanged();
  385. }
  386. std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const {
  387. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  388. auto c = static_cast<OpenGLSharedContext*>(main_context.get());
  389. // Bind the shared contexts to the main surface in case the backend wants to take over
  390. // presentation
  391. return std::make_unique<OpenGLSharedContext>(c->GetShareContext(),
  392. child_widget->windowHandle());
  393. }
  394. return std::make_unique<DummyContext>();
  395. }
  396. bool GRenderWindow::InitRenderTarget() {
  397. ReleaseRenderTarget();
  398. first_frame = false;
  399. switch (Settings::values.renderer_backend) {
  400. case Settings::RendererBackend::OpenGL:
  401. if (!InitializeOpenGL()) {
  402. return false;
  403. }
  404. break;
  405. case Settings::RendererBackend::Vulkan:
  406. if (!InitializeVulkan()) {
  407. return false;
  408. }
  409. break;
  410. }
  411. // Update the Window System information with the new render target
  412. window_info = GetWindowSystemInfo(child_widget->windowHandle());
  413. child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  414. layout()->addWidget(child_widget);
  415. // Reset minimum required size to avoid resizing issues on the main window after restarting.
  416. setMinimumSize(1, 1);
  417. resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  418. OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
  419. OnFramebufferSizeChanged();
  420. BackupGeometry();
  421. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  422. if (!LoadOpenGL()) {
  423. return false;
  424. }
  425. }
  426. return true;
  427. }
  428. void GRenderWindow::ReleaseRenderTarget() {
  429. if (child_widget) {
  430. layout()->removeWidget(child_widget);
  431. child_widget->deleteLater();
  432. child_widget = nullptr;
  433. }
  434. main_context.reset();
  435. }
  436. void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) {
  437. auto& renderer = Core::System::GetInstance().Renderer();
  438. if (res_scale == 0) {
  439. res_scale = VideoCore::GetResolutionScaleFactor(renderer);
  440. }
  441. const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
  442. screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
  443. renderer.RequestScreenshot(
  444. screenshot_image.bits(),
  445. [=] {
  446. const std::string std_screenshot_path = screenshot_path.toStdString();
  447. if (screenshot_image.mirrored(false, true).save(screenshot_path)) {
  448. LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path);
  449. } else {
  450. LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path);
  451. }
  452. },
  453. layout);
  454. }
  455. void GRenderWindow::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) {
  456. setMinimumSize(minimal_size.first, minimal_size.second);
  457. }
  458. bool GRenderWindow::InitializeOpenGL() {
  459. // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
  460. // WA_DontShowOnScreen, WA_DeleteOnClose
  461. auto child = new OpenGLRenderWidget(this);
  462. child_widget = child;
  463. child_widget->windowHandle()->create();
  464. auto context = std::make_shared<OpenGLSharedContext>(child->windowHandle());
  465. main_context = context;
  466. child->SetContext(
  467. std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle()));
  468. return true;
  469. }
  470. bool GRenderWindow::InitializeVulkan() {
  471. #ifdef HAS_VULKAN
  472. auto child = new VulkanRenderWidget(this);
  473. child_widget = child;
  474. child_widget->windowHandle()->create();
  475. main_context = std::make_unique<DummyContext>();
  476. return true;
  477. #else
  478. QMessageBox::critical(this, tr("Vulkan not available!"),
  479. tr("yuzu has not been compiled with Vulkan support."));
  480. return false;
  481. #endif
  482. }
  483. bool GRenderWindow::LoadOpenGL() {
  484. auto context = CreateSharedContext();
  485. auto scope = context->Acquire();
  486. if (!gladLoadGL()) {
  487. QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"),
  488. tr("Your GPU may not support OpenGL 4.3, or you do not have the "
  489. "latest graphics driver."));
  490. return false;
  491. }
  492. QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions();
  493. if (!unsupported_gl_extensions.empty()) {
  494. QMessageBox::critical(
  495. this, tr("Error while initializing OpenGL!"),
  496. tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you "
  497. "have the latest graphics driver.<br><br>Unsupported extensions:<br>") +
  498. unsupported_gl_extensions.join(QStringLiteral("<br>")));
  499. return false;
  500. }
  501. return true;
  502. }
  503. QStringList GRenderWindow::GetUnsupportedGLExtensions() const {
  504. QStringList unsupported_ext;
  505. if (!GLAD_GL_ARB_buffer_storage)
  506. unsupported_ext.append(QStringLiteral("ARB_buffer_storage"));
  507. if (!GLAD_GL_ARB_direct_state_access)
  508. unsupported_ext.append(QStringLiteral("ARB_direct_state_access"));
  509. if (!GLAD_GL_ARB_vertex_type_10f_11f_11f_rev)
  510. unsupported_ext.append(QStringLiteral("ARB_vertex_type_10f_11f_11f_rev"));
  511. if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge)
  512. unsupported_ext.append(QStringLiteral("ARB_texture_mirror_clamp_to_edge"));
  513. if (!GLAD_GL_ARB_multi_bind)
  514. unsupported_ext.append(QStringLiteral("ARB_multi_bind"));
  515. if (!GLAD_GL_ARB_clip_control)
  516. unsupported_ext.append(QStringLiteral("ARB_clip_control"));
  517. // Extensions required to support some texture formats.
  518. if (!GLAD_GL_EXT_texture_compression_s3tc)
  519. unsupported_ext.append(QStringLiteral("EXT_texture_compression_s3tc"));
  520. if (!GLAD_GL_ARB_texture_compression_rgtc)
  521. unsupported_ext.append(QStringLiteral("ARB_texture_compression_rgtc"));
  522. if (!GLAD_GL_ARB_depth_buffer_float)
  523. unsupported_ext.append(QStringLiteral("ARB_depth_buffer_float"));
  524. for (const QString& ext : unsupported_ext)
  525. LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString());
  526. return unsupported_ext;
  527. }
  528. void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
  529. this->emu_thread = emu_thread;
  530. }
  531. void GRenderWindow::OnEmulationStopping() {
  532. emu_thread = nullptr;
  533. }
  534. void GRenderWindow::showEvent(QShowEvent* event) {
  535. QWidget::showEvent(event);
  536. // windowHandle() is not initialized until the Window is shown, so we connect it here.
  537. connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged,
  538. Qt::UniqueConnection);
  539. }