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