Merge pull request #11522 from phire/KillRendererWithFire

Kill Renderer (with phire)
This commit is contained in:
Scott Mansell
2023-02-09 19:59:16 +13:00
committed by GitHub
144 changed files with 5584 additions and 4840 deletions

View File

@ -21,7 +21,7 @@
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
#include "VideoCommon/PostProcessing.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
using ConfigurationOption = VideoCommon::PostProcessingConfiguration::ConfigurationOption;
@ -31,9 +31,9 @@ PostProcessingConfigWindow::PostProcessingConfigWindow(EnhancementsWidget* paren
const std::string& shader)
: QDialog(parent), m_shader(shader)
{
if (g_renderer && g_renderer->GetPostProcessor())
if (g_presenter && g_presenter->GetPostProcessor())
{
m_post_processor = g_renderer->GetPostProcessor()->GetConfig();
m_post_processor = g_presenter->GetPostProcessor()->GetConfig();
}
else
{
@ -52,7 +52,7 @@ PostProcessingConfigWindow::PostProcessingConfigWindow(EnhancementsWidget* paren
PostProcessingConfigWindow::~PostProcessingConfigWindow()
{
m_post_processor->SaveOptionsConfiguration();
if (!(g_renderer && g_renderer->GetPostProcessor()))
if (!(g_presenter && g_presenter->GetPostProcessor()))
{
delete m_post_processor;
}

View File

@ -36,8 +36,9 @@
#include "UICommon/DiscordPresence.h"
#include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/Fifo.cpp"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
static thread_local bool tls_is_host_thread = false;
@ -76,9 +77,9 @@ void Host::SetRenderHandle(void* handle)
return;
m_render_handle = handle;
if (g_renderer)
if (g_presenter)
{
g_renderer->ChangeSurface(handle);
g_presenter->ChangeSurface(handle);
g_controller_interface.ChangeWindow(handle);
}
}
@ -149,11 +150,11 @@ bool Host::GetRenderFullFocus()
void Host::SetRenderFocus(bool focus)
{
m_render_focus = focus;
if (g_renderer && m_render_fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
if (g_gfx && m_render_fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
{
RunWithGPUThreadInactive([focus] {
if (!Config::Get(Config::MAIN_RENDER_TO_MAIN))
g_renderer->SetFullscreen(focus);
g_gfx->SetFullscreen(focus);
});
}
}
@ -181,17 +182,16 @@ void Host::SetRenderFullscreen(bool fullscreen)
{
m_render_fullscreen = fullscreen;
if (g_renderer && g_renderer->IsFullscreen() != fullscreen &&
g_ActiveConfig.ExclusiveFullscreenEnabled())
if (g_gfx && g_gfx->IsFullscreen() != fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
{
RunWithGPUThreadInactive([fullscreen] { g_renderer->SetFullscreen(fullscreen); });
RunWithGPUThreadInactive([fullscreen] { g_gfx->SetFullscreen(fullscreen); });
}
}
void Host::ResizeSurface(int new_width, int new_height)
{
if (g_renderer)
g_renderer->ResizeSurface();
if (g_presenter)
g_presenter->ResizeSurface();
}
std::vector<std::string> Host_GetPreferredLocales()

View File

@ -43,7 +43,6 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"

View File

@ -1383,7 +1383,7 @@ void MainWindow::SetStateSlot(int slot)
void MainWindow::IncrementSelectedStateSlot()
{
int state_slot = m_state_slot + 1;
u32 state_slot = m_state_slot + 1;
if (state_slot > State::NUM_STATES)
state_slot = 1;
m_menu_bar->SetStateSlot(state_slot);
@ -1391,7 +1391,7 @@ void MainWindow::IncrementSelectedStateSlot()
void MainWindow::DecrementSelectedStateSlot()
{
int state_slot = m_state_slot - 1;
u32 state_slot = m_state_slot - 1;
if (state_slot < 1)
state_slot = State::NUM_STATES;
m_menu_bar->SetStateSlot(state_slot);

View File

@ -217,7 +217,7 @@ private:
bool m_exit_requested = false;
bool m_fullscreen_requested = false;
bool m_is_screensaver_inhibited = false;
int m_state_slot = 1;
u32 m_state_slot = 1;
std::unique_ptr<BootParameters> m_pending_boot;
ControllersWindow* m_controllers_window = nullptr;

View File

@ -61,7 +61,6 @@
#include "VideoCommon/NetPlayChatUI.h"
#include "VideoCommon/NetPlayGolfUI.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h"
namespace

View File

@ -19,8 +19,6 @@
#include <QTimer>
#include <QWindow>
#include <imgui.h>
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"
#include "Core/State.h"
@ -32,7 +30,8 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/OnScreenUI.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
#ifdef _WIN32
@ -62,7 +61,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
if (state == Core::State::Running)
SetImGuiKeyMap();
SetPresenterKeyMap();
});
// We have to use Qt::DirectConnection here because we don't want those signals to get queued
@ -338,7 +337,7 @@ void RenderWidget::SetWaitingForMessageBox(bool waiting_for_message_box)
bool RenderWidget::event(QEvent* event)
{
PassEventToImGui(event);
PassEventToPresenter(event);
switch (event->type())
{
@ -470,7 +469,7 @@ bool RenderWidget::event(QEvent* event)
return QWidget::event(event);
}
void RenderWidget::PassEventToImGui(const QEvent* event)
void RenderWidget::PassEventToPresenter(const QEvent* event)
{
if (!Core::IsRunningAndStarted())
return;
@ -487,38 +486,40 @@ void RenderWidget::PassEventToImGui(const QEvent* event)
const QKeyEvent* key_event = static_cast<const QKeyEvent*>(event);
const bool is_down = event->type() == QEvent::KeyPress;
const u32 key = static_cast<u32>(key_event->key() & 0x1FF);
auto lock = g_renderer->GetImGuiLock();
if (key < std::size(ImGui::GetIO().KeysDown))
ImGui::GetIO().KeysDown[key] = is_down;
const char* chars = nullptr;
if (is_down)
{
auto utf8 = key_event->text().toUtf8();
ImGui::GetIO().AddInputCharactersUTF8(utf8.constData());
if (utf8.size())
chars = utf8.constData();
}
// Pass the key onto Presenter (for the imgui UI)
g_presenter->SetKey(key, is_down, chars);
}
break;
case QEvent::MouseMove:
{
auto lock = g_renderer->GetImGuiLock();
// Qt multiplies all coordinates by the scaling factor in highdpi mode, giving us "scaled" mouse
// coordinates (as if the screen was standard dpi). We need to update the mouse position in
// native coordinates, as the UI (and game) is rendered at native resolution.
const float scale = devicePixelRatio();
ImGui::GetIO().MousePos.x = static_cast<const QMouseEvent*>(event)->pos().x() * scale;
ImGui::GetIO().MousePos.y = static_cast<const QMouseEvent*>(event)->pos().y() * scale;
float x = static_cast<const QMouseEvent*>(event)->pos().x() * scale;
float y = static_cast<const QMouseEvent*>(event)->pos().y() * scale;
g_presenter->SetMousePos(x, y);
}
break;
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
{
auto lock = g_renderer->GetImGuiLock();
const u32 button_mask = static_cast<u32>(static_cast<const QMouseEvent*>(event)->buttons());
for (size_t i = 0; i < std::size(ImGui::GetIO().MouseDown); i++)
ImGui::GetIO().MouseDown[i] = (button_mask & (1u << i)) != 0;
g_presenter->SetMousePress(button_mask);
}
break;
@ -527,36 +528,16 @@ void RenderWidget::PassEventToImGui(const QEvent* event)
}
}
void RenderWidget::SetImGuiKeyMap()
void RenderWidget::SetPresenterKeyMap()
{
static constexpr std::array<std::array<int, 2>, 21> key_map{{
{ImGuiKey_Tab, Qt::Key_Tab},
{ImGuiKey_LeftArrow, Qt::Key_Left},
{ImGuiKey_RightArrow, Qt::Key_Right},
{ImGuiKey_UpArrow, Qt::Key_Up},
{ImGuiKey_DownArrow, Qt::Key_Down},
{ImGuiKey_PageUp, Qt::Key_PageUp},
{ImGuiKey_PageDown, Qt::Key_PageDown},
{ImGuiKey_Home, Qt::Key_Home},
{ImGuiKey_End, Qt::Key_End},
{ImGuiKey_Insert, Qt::Key_Insert},
{ImGuiKey_Delete, Qt::Key_Delete},
{ImGuiKey_Backspace, Qt::Key_Backspace},
{ImGuiKey_Space, Qt::Key_Space},
{ImGuiKey_Enter, Qt::Key_Return},
{ImGuiKey_Escape, Qt::Key_Escape},
{ImGuiKey_A, Qt::Key_A},
{ImGuiKey_C, Qt::Key_C},
{ImGuiKey_V, Qt::Key_V},
{ImGuiKey_X, Qt::Key_X},
{ImGuiKey_Y, Qt::Key_Y},
{ImGuiKey_Z, Qt::Key_Z},
}};
auto lock = g_renderer->GetImGuiLock();
static constexpr DolphinKeyMap key_map = {
Qt::Key_Tab, Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, Qt::Key_Down,
Qt::Key_PageUp, Qt::Key_PageDown, Qt::Key_Home, Qt::Key_End, Qt::Key_Insert,
Qt::Key_Delete, Qt::Key_Backspace, Qt::Key_Space, Qt::Key_Return, Qt::Key_Escape,
Qt::Key_Enter, // Keypad enter
Qt::Key_A, Qt::Key_C, Qt::Key_V, Qt::Key_X, Qt::Key_Y,
Qt::Key_Z,
};
if (!ImGui::GetCurrentContext())
return;
for (auto [imgui_key, qt_key] : key_map)
ImGui::GetIO().KeyMap[imgui_key] = (qt_key & 0x1FF);
g_presenter->SetKeyMap(key_map);
}

View File

@ -39,8 +39,8 @@ private:
void OnLockCursorChanged();
void OnKeepOnTopChanged(bool top);
void UpdateCursor();
void PassEventToImGui(const QEvent* event);
void SetImGuiKeyMap();
void PassEventToPresenter(const QEvent* event);
void SetPresenterKeyMap();
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;

View File

@ -46,7 +46,6 @@
#include "VideoCommon/NetPlayChatUI.h"
#include "VideoCommon/NetPlayGolfUI.h"
#include "VideoCommon/RenderBase.h"
Settings::Settings()
{