bootmanager.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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. this->setMouseTracking(true);
  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. QWidget::mousePressEvent(event);
  322. }
  323. void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
  324. // touch input is handled in TouchUpdateEvent
  325. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  326. return;
  327. }
  328. auto pos = event->pos();
  329. const auto [x, y] = ScaleTouch(pos);
  330. this->TouchMoved(x, y);
  331. InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y());
  332. QWidget::mouseMoveEvent(event);
  333. }
  334. void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
  335. // touch input is handled in TouchEndEvent
  336. if (event->source() == Qt::MouseEventSynthesizedBySystem) {
  337. return;
  338. }
  339. if (event->button() == Qt::LeftButton) {
  340. this->TouchReleased();
  341. } else if (event->button() == Qt::RightButton) {
  342. InputCommon::GetMotionEmu()->EndTilt();
  343. }
  344. }
  345. void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
  346. // TouchBegin always has exactly one touch point, so take the .first()
  347. const auto [x, y] = ScaleTouch(event->touchPoints().first().pos());
  348. this->TouchPressed(x, y);
  349. }
  350. void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
  351. QPointF pos;
  352. int active_points = 0;
  353. // average all active touch points
  354. for (const auto tp : event->touchPoints()) {
  355. if (tp.state() & (Qt::TouchPointPressed | Qt::TouchPointMoved | Qt::TouchPointStationary)) {
  356. active_points++;
  357. pos += tp.pos();
  358. }
  359. }
  360. pos /= active_points;
  361. const auto [x, y] = ScaleTouch(pos);
  362. this->TouchMoved(x, y);
  363. }
  364. void GRenderWindow::TouchEndEvent() {
  365. this->TouchReleased();
  366. }
  367. bool GRenderWindow::event(QEvent* event) {
  368. if (event->type() == QEvent::TouchBegin) {
  369. TouchBeginEvent(static_cast<QTouchEvent*>(event));
  370. return true;
  371. } else if (event->type() == QEvent::TouchUpdate) {
  372. TouchUpdateEvent(static_cast<QTouchEvent*>(event));
  373. return true;
  374. } else if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
  375. TouchEndEvent();
  376. return true;
  377. }
  378. return QWidget::event(event);
  379. }
  380. void GRenderWindow::focusOutEvent(QFocusEvent* event) {
  381. QWidget::focusOutEvent(event);
  382. InputCommon::GetKeyboard()->ReleaseAllKeys();
  383. }
  384. void GRenderWindow::resizeEvent(QResizeEvent* event) {
  385. QWidget::resizeEvent(event);
  386. OnFramebufferSizeChanged();
  387. }
  388. std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedContext() const {
  389. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  390. auto c = static_cast<OpenGLSharedContext*>(main_context.get());
  391. // Bind the shared contexts to the main surface in case the backend wants to take over
  392. // presentation
  393. return std::make_unique<OpenGLSharedContext>(c->GetShareContext(),
  394. child_widget->windowHandle());
  395. }
  396. return std::make_unique<DummyContext>();
  397. }
  398. bool GRenderWindow::InitRenderTarget() {
  399. ReleaseRenderTarget();
  400. first_frame = false;
  401. switch (Settings::values.renderer_backend) {
  402. case Settings::RendererBackend::OpenGL:
  403. if (!InitializeOpenGL()) {
  404. return false;
  405. }
  406. break;
  407. case Settings::RendererBackend::Vulkan:
  408. if (!InitializeVulkan()) {
  409. return false;
  410. }
  411. break;
  412. }
  413. // Update the Window System information with the new render target
  414. window_info = GetWindowSystemInfo(child_widget->windowHandle());
  415. child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  416. layout()->addWidget(child_widget);
  417. // Reset minimum required size to avoid resizing issues on the main window after restarting.
  418. setMinimumSize(1, 1);
  419. resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height);
  420. OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
  421. OnFramebufferSizeChanged();
  422. BackupGeometry();
  423. if (Settings::values.renderer_backend == Settings::RendererBackend::OpenGL) {
  424. if (!LoadOpenGL()) {
  425. return false;
  426. }
  427. }
  428. return true;
  429. }
  430. void GRenderWindow::ReleaseRenderTarget() {
  431. if (child_widget) {
  432. layout()->removeWidget(child_widget);
  433. child_widget->deleteLater();
  434. child_widget = nullptr;
  435. }
  436. main_context.reset();
  437. }
  438. void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_path) {
  439. auto& renderer = Core::System::GetInstance().Renderer();
  440. if (res_scale == 0) {
  441. res_scale = VideoCore::GetResolutionScaleFactor(renderer);
  442. }
  443. const Layout::FramebufferLayout layout{Layout::FrameLayoutFromResolutionScale(res_scale)};
  444. screenshot_image = QImage(QSize(layout.width, layout.height), QImage::Format_RGB32);
  445. renderer.RequestScreenshot(
  446. screenshot_image.bits(),
  447. [=] {
  448. const std::string std_screenshot_path = screenshot_path.toStdString();
  449. if (screenshot_image.mirrored(false, true).save(screenshot_path)) {
  450. LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path);
  451. } else {
  452. LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path);
  453. }
  454. },
  455. layout);
  456. }
  457. void GRenderWindow::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) {
  458. setMinimumSize(minimal_size.first, minimal_size.second);
  459. }
  460. bool GRenderWindow::InitializeOpenGL() {
  461. // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
  462. // WA_DontShowOnScreen, WA_DeleteOnClose
  463. auto child = new OpenGLRenderWidget(this);
  464. child_widget = child;
  465. child_widget->windowHandle()->create();
  466. auto context = std::make_shared<OpenGLSharedContext>(child->windowHandle());
  467. main_context = context;
  468. child->SetContext(
  469. std::make_unique<OpenGLSharedContext>(context->GetShareContext(), child->windowHandle()));
  470. return true;
  471. }
  472. bool GRenderWindow::InitializeVulkan() {
  473. #ifdef HAS_VULKAN
  474. auto child = new VulkanRenderWidget(this);
  475. child_widget = child;
  476. child_widget->windowHandle()->create();
  477. main_context = std::make_unique<DummyContext>();
  478. return true;
  479. #else
  480. QMessageBox::critical(this, tr("Vulkan not available!"),
  481. tr("yuzu has not been compiled with Vulkan support."));
  482. return false;
  483. #endif
  484. }
  485. bool GRenderWindow::LoadOpenGL() {
  486. auto context = CreateSharedContext();
  487. auto scope = context->Acquire();
  488. if (!gladLoadGL()) {
  489. QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"),
  490. tr("Your GPU may not support OpenGL 4.3, or you do not have the "
  491. "latest graphics driver."));
  492. return false;
  493. }
  494. QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions();
  495. if (!unsupported_gl_extensions.empty()) {
  496. QMessageBox::critical(
  497. this, tr("Error while initializing OpenGL!"),
  498. tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you "
  499. "have the latest graphics driver.<br><br>Unsupported extensions:<br>") +
  500. unsupported_gl_extensions.join(QStringLiteral("<br>")));
  501. return false;
  502. }
  503. return true;
  504. }
  505. QStringList GRenderWindow::GetUnsupportedGLExtensions() const {
  506. QStringList unsupported_ext;
  507. if (!GLAD_GL_ARB_buffer_storage)
  508. unsupported_ext.append(QStringLiteral("ARB_buffer_storage"));
  509. if (!GLAD_GL_ARB_direct_state_access)
  510. unsupported_ext.append(QStringLiteral("ARB_direct_state_access"));
  511. if (!GLAD_GL_ARB_vertex_type_10f_11f_11f_rev)
  512. unsupported_ext.append(QStringLiteral("ARB_vertex_type_10f_11f_11f_rev"));
  513. if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge)
  514. unsupported_ext.append(QStringLiteral("ARB_texture_mirror_clamp_to_edge"));
  515. if (!GLAD_GL_ARB_multi_bind)
  516. unsupported_ext.append(QStringLiteral("ARB_multi_bind"));
  517. if (!GLAD_GL_ARB_clip_control)
  518. unsupported_ext.append(QStringLiteral("ARB_clip_control"));
  519. // Extensions required to support some texture formats.
  520. if (!GLAD_GL_EXT_texture_compression_s3tc)
  521. unsupported_ext.append(QStringLiteral("EXT_texture_compression_s3tc"));
  522. if (!GLAD_GL_ARB_texture_compression_rgtc)
  523. unsupported_ext.append(QStringLiteral("ARB_texture_compression_rgtc"));
  524. if (!GLAD_GL_ARB_depth_buffer_float)
  525. unsupported_ext.append(QStringLiteral("ARB_depth_buffer_float"));
  526. for (const QString& ext : unsupported_ext)
  527. LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString());
  528. return unsupported_ext;
  529. }
  530. void GRenderWindow::OnEmulationStarting(EmuThread* emu_thread) {
  531. this->emu_thread = emu_thread;
  532. }
  533. void GRenderWindow::OnEmulationStopping() {
  534. emu_thread = nullptr;
  535. }
  536. void GRenderWindow::showEvent(QShowEvent* event) {
  537. QWidget::showEvent(event);
  538. // windowHandle() is not initialized until the Window is shown, so we connect it here.
  539. connect(windowHandle(), &QWindow::screenChanged, this, &GRenderWindow::OnFramebufferSizeChanged,
  540. Qt::UniqueConnection);
  541. }