From 4350036d17743ff9b65971b7e26d1669665b9568 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 27 Oct 2021 05:22:08 +0200 Subject: [PATCH] early-access version 2161 --- README.md | 2 +- src/input_common/gcadapter/gc_adapter.cpp | 10 ++++--- src/input_common/gcadapter/gc_adapter.h | 8 +++--- src/input_common/gcadapter/gc_poller.cpp | 6 ++--- src/input_common/mouse/mouse_input.cpp | 8 +++--- src/input_common/mouse/mouse_input.h | 8 +++--- src/input_common/mouse/mouse_poller.cpp | 8 +++--- src/input_common/sdl/sdl_impl.cpp | 9 ++++--- src/input_common/sdl/sdl_impl.h | 4 +-- src/input_common/udp/client.cpp | 12 +++++---- src/input_common/udp/client.h | 10 +++---- src/input_common/udp/udp.cpp | 2 +- src/video_core/gpu_thread.cpp | 7 ++--- src/video_core/gpu_thread.h | 6 ++--- src/yuzu/configuration/configure_dialog.cpp | 7 +++-- src/yuzu/configuration/configure_per_game.cpp | 2 +- src/yuzu/configuration/configure_per_game.ui | 8 ------ src/yuzu/main.cpp | 27 ++++++++++--------- 18 files changed, 72 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index e757ffac3..40fc39626 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2160. +This is the source code for early-access 2161. ## Legal Notice diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index aed94a52c..a2f1bb67c 100755 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp @@ -170,7 +170,7 @@ void Adapter::UpdateYuzuSettings(std::size_t port) { if (pads[port].buttons != 0) { pad_status.button = pads[port].last_button; - pad_queue.push(pad_status); + pad_queue.Push(pad_status); } // Accounting for a threshold here to ensure an intentional press @@ -181,7 +181,7 @@ void Adapter::UpdateYuzuSettings(std::size_t port) { pad_status.axis = static_cast(i); pad_status.axis_value = value; pad_status.axis_threshold = axis_threshold; - pad_queue.push(pad_status); + pad_queue.Push(pad_status); } } } @@ -478,18 +478,20 @@ bool Adapter::DeviceConnected(std::size_t port) const { } void Adapter::BeginConfiguration() { + pad_queue.Clear(); configuring = true; } void Adapter::EndConfiguration() { + pad_queue.Clear(); configuring = false; } -Common::MPMCQueue& Adapter::GetPadQueue() { +Common::SPSCQueue& Adapter::GetPadQueue() { return pad_queue; } -const Common::MPMCQueue& Adapter::GetPadQueue() const { +const Common::SPSCQueue& Adapter::GetPadQueue() const { return pad_queue; } diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h index c5a93bbed..e5de5e94f 100755 --- a/src/input_common/gcadapter/gc_adapter.h +++ b/src/input_common/gcadapter/gc_adapter.h @@ -8,8 +8,8 @@ #include #include #include -#include "common/atomic_threadsafe_queue.h" #include "common/common_types.h" +#include "common/threadsafe_queue.h" #include "input_common/main.h" struct libusb_context; @@ -85,8 +85,8 @@ public: void BeginConfiguration(); void EndConfiguration(); - Common::MPMCQueue& GetPadQueue(); - const Common::MPMCQueue& GetPadQueue() const; + Common::SPSCQueue& GetPadQueue(); + const Common::SPSCQueue& GetPadQueue() const; GCController& GetPadState(std::size_t port); const GCController& GetPadState(std::size_t port) const; @@ -145,7 +145,7 @@ private: libusb_device_handle* usb_adapter_handle = nullptr; std::array pads; - Common::MPMCQueue pad_queue{1024}; + Common::SPSCQueue pad_queue; std::thread adapter_input_thread; std::thread adapter_scan_thread; diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp index b323ff6b0..1b6ded8d6 100755 --- a/src/input_common/gcadapter/gc_poller.cpp +++ b/src/input_common/gcadapter/gc_poller.cpp @@ -7,7 +7,7 @@ #include #include #include "common/assert.h" -#include "common/atomic_threadsafe_queue.h" +#include "common/threadsafe_queue.h" #include "input_common/gcadapter/gc_adapter.h" #include "input_common/gcadapter/gc_poller.h" @@ -103,7 +103,7 @@ Common::ParamPackage GCButtonFactory::GetNextInput() const { Common::ParamPackage params; GCAdapter::GCPadStatus pad; auto& queue = adapter->GetPadQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { // This while loop will break on the earliest detected button params.Set("engine", "gcpad"); params.Set("port", static_cast(pad.port)); @@ -263,7 +263,7 @@ Common::ParamPackage GCAnalogFactory::GetNextInput() { GCAdapter::GCPadStatus pad; Common::ParamPackage params; auto& queue = adapter->GetPadQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { if (pad.button != GCAdapter::PadButton::Undefined) { params.Set("engine", "gcpad"); params.Set("port", static_cast(pad.port)); diff --git a/src/input_common/mouse/mouse_input.cpp b/src/input_common/mouse/mouse_input.cpp index 1c9f497eb..3b052ffb2 100755 --- a/src/input_common/mouse/mouse_input.cpp +++ b/src/input_common/mouse/mouse_input.cpp @@ -52,7 +52,7 @@ void Mouse::UpdateYuzuSettings() { return; } - mouse_queue.push(MouseStatus{ + mouse_queue.Push(MouseStatus{ .button = last_button, }); } @@ -153,6 +153,7 @@ void Mouse::ReleaseAllButtons() { void Mouse::BeginConfiguration() { buttons = 0; last_button = MouseButton::Undefined; + mouse_queue.Clear(); configuring = true; } @@ -164,6 +165,7 @@ void Mouse::EndConfiguration() { info.data.axis = {0, 0}; } last_button = MouseButton::Undefined; + mouse_queue.Clear(); configuring = false; } @@ -203,11 +205,11 @@ bool Mouse::UnlockButton(std::size_t button_) { return button_state; } -Common::MPMCQueue& Mouse::GetMouseQueue() { +Common::SPSCQueue& Mouse::GetMouseQueue() { return mouse_queue; } -const Common::MPMCQueue& Mouse::GetMouseQueue() const { +const Common::SPSCQueue& Mouse::GetMouseQueue() const { return mouse_queue; } diff --git a/src/input_common/mouse/mouse_input.h b/src/input_common/mouse/mouse_input.h index 41b47eeb6..c8bae99c1 100755 --- a/src/input_common/mouse/mouse_input.h +++ b/src/input_common/mouse/mouse_input.h @@ -9,8 +9,8 @@ #include #include -#include "common/atomic_threadsafe_queue.h" #include "common/common_types.h" +#include "common/threadsafe_queue.h" #include "common/vector_math.h" #include "core/frontend/input.h" #include "input_common/motion_input.h" @@ -79,8 +79,8 @@ public: [[nodiscard]] bool ToggleButton(std::size_t button_); [[nodiscard]] bool UnlockButton(std::size_t button_); - [[nodiscard]] Common::MPMCQueue& GetMouseQueue(); - [[nodiscard]] const Common::MPMCQueue& GetMouseQueue() const; + [[nodiscard]] Common::SPSCQueue& GetMouseQueue(); + [[nodiscard]] const Common::SPSCQueue& GetMouseQueue() const; [[nodiscard]] MouseData& GetMouseState(std::size_t button); [[nodiscard]] const MouseData& GetMouseState(std::size_t button) const; @@ -109,7 +109,7 @@ private: std::jthread update_thread; MouseButton last_button{MouseButton::Undefined}; std::array mouse_info; - Common::MPMCQueue mouse_queue{1024}; + Common::SPSCQueue mouse_queue; bool configuring{false}; int mouse_panning_timout{}; }; diff --git a/src/input_common/mouse/mouse_poller.cpp b/src/input_common/mouse/mouse_poller.cpp index f8cf19d11..090b26972 100755 --- a/src/input_common/mouse/mouse_poller.cpp +++ b/src/input_common/mouse/mouse_poller.cpp @@ -52,7 +52,7 @@ Common::ParamPackage MouseButtonFactory::GetNextInput() const { MouseInput::MouseStatus pad; Common::ParamPackage params; auto& queue = mouse_input->GetMouseQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { // This while loop will break on the earliest detected button if (pad.button != MouseInput::MouseButton::Undefined) { params.Set("engine", "mouse"); @@ -184,7 +184,7 @@ Common::ParamPackage MouseAnalogFactory::GetNextInput() const { MouseInput::MouseStatus pad; Common::ParamPackage params; auto& queue = mouse_input->GetMouseQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { // This while loop will break on the earliest detected button if (pad.button != MouseInput::MouseButton::Undefined) { params.Set("engine", "mouse"); @@ -227,7 +227,7 @@ Common::ParamPackage MouseMotionFactory::GetNextInput() const { MouseInput::MouseStatus pad; Common::ParamPackage params; auto& queue = mouse_input->GetMouseQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { // This while loop will break on the earliest detected button if (pad.button != MouseInput::MouseButton::Undefined) { params.Set("engine", "mouse"); @@ -275,7 +275,7 @@ Common::ParamPackage MouseTouchFactory::GetNextInput() const { MouseInput::MouseStatus pad; Common::ParamPackage params; auto& queue = mouse_input->GetMouseQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { // This while loop will break on the earliest detected button if (pad.button != MouseInput::MouseButton::Undefined) { params.Set("engine", "mouse"); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 30556614a..ecb00d428 100755 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -46,7 +46,7 @@ static int SDLEventWatcher(void* user_data, SDL_Event* event) { // Don't handle the event if we are configuring if (sdl_state->polling) { - sdl_state->event_queue.push(*event); + sdl_state->event_queue.Push(*event); } else { sdl_state->HandleGameControllerEvent(*event); } @@ -1460,6 +1460,7 @@ public: explicit SDLPoller(SDLState& state_) : state(state_) {} void Start([[maybe_unused]] const std::string& device_id) override { + state.event_queue.Clear(); state.polling = true; } @@ -1477,7 +1478,7 @@ public: Common::ParamPackage GetNextInput() override { SDL_Event event; - while (state.event_queue.try_pop(event)) { + while (state.event_queue.Pop(event)) { const auto package = FromEvent(event); if (package) { return *package; @@ -1549,7 +1550,7 @@ public: Common::ParamPackage GetNextInput() override { SDL_Event event; - while (state.event_queue.try_pop(event)) { + while (state.event_queue.Pop(event)) { const auto package = FromEvent(event); if (package) { return *package; @@ -1591,7 +1592,7 @@ public: Common::ParamPackage GetNextInput() override { SDL_Event event; - while (state.event_queue.try_pop(event)) { + while (state.event_queue.Pop(event)) { if (event.type != SDL_JOYAXISMOTION) { // Check for a button press auto button_press = button_poller.FromEvent(event); diff --git a/src/input_common/sdl/sdl_impl.h b/src/input_common/sdl/sdl_impl.h index 78baa576f..7a9ad6346 100755 --- a/src/input_common/sdl/sdl_impl.h +++ b/src/input_common/sdl/sdl_impl.h @@ -12,8 +12,8 @@ #include -#include "common/atomic_threadsafe_queue.h" #include "common/common_types.h" +#include "common/threadsafe_queue.h" #include "input_common/sdl/sdl.h" union SDL_Event; @@ -59,7 +59,7 @@ public: /// Used by the Pollers during config std::atomic polling = false; - Common::MPMCQueue event_queue{1024}; + Common::SPSCQueue event_queue; std::vector GetInputDevices() override; diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 67d5e6653..b9512aa2e 100755 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -338,7 +338,7 @@ void Client::UpdateYuzuSettings(std::size_t client, std::size_t pad_index, gyro[0], gyro[1], gyro[2], acc[0], acc[1], acc[2]); } UDPPadStatus pad{ - .host = clients[client].host.c_str(), + .host = clients[client].host, .port = clients[client].port, .pad_index = pad_index, }; @@ -346,12 +346,12 @@ void Client::UpdateYuzuSettings(std::size_t client, std::size_t pad_index, if (gyro[i] > 5.0f || gyro[i] < -5.0f) { pad.motion = static_cast(i); pad.motion_value = gyro[i]; - pad_queue.push(pad); + pad_queue.Push(pad); } if (acc[i] > 1.75f || acc[i] < -1.75f) { pad.motion = static_cast(i + 3); pad.motion_value = acc[i]; - pad_queue.push(pad); + pad_queue.Push(pad); } } } @@ -401,10 +401,12 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, } void Client::BeginConfiguration() { + pad_queue.Clear(); configuring = true; } void Client::EndConfiguration() { + pad_queue.Clear(); configuring = false; } @@ -432,11 +434,11 @@ const Input::TouchStatus& Client::GetTouchState() const { return touch_status; } -Common::MPMCQueue& Client::GetPadQueue() { +Common::SPSCQueue& Client::GetPadQueue() { return pad_queue; } -const Common::MPMCQueue& Client::GetPadQueue() const { +const Common::SPSCQueue& Client::GetPadQueue() const { return pad_queue; } diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h index 0071da55e..380f9bb76 100755 --- a/src/input_common/udp/client.h +++ b/src/input_common/udp/client.h @@ -11,10 +11,10 @@ #include #include #include -#include "common/atomic_threadsafe_queue.h" #include "common/common_types.h" #include "common/param_package.h" #include "common/thread.h" +#include "common/threadsafe_queue.h" #include "common/vector_math.h" #include "core/frontend/input.h" #include "input_common/motion_input.h" @@ -46,7 +46,7 @@ enum class PadTouch { }; struct UDPPadStatus { - const char* host{"127.0.0.1"}; + std::string host{"127.0.0.1"}; u16 port{26760}; std::size_t pad_index{}; PadMotion motion{PadMotion::Undefined}; @@ -85,8 +85,8 @@ public: bool DeviceConnected(std::size_t pad) const; void ReloadSockets(); - Common::MPMCQueue& GetPadQueue(); - const Common::MPMCQueue& GetPadQueue() const; + Common::SPSCQueue& GetPadQueue(); + const Common::SPSCQueue& GetPadQueue() const; DeviceStatus& GetPadState(const std::string& host, u16 port, std::size_t pad); const DeviceStatus& GetPadState(const std::string& host, u16 port, std::size_t pad) const; @@ -146,7 +146,7 @@ private: static constexpr std::size_t MAX_TOUCH_FINGERS = MAX_UDP_CLIENTS * 2; std::array pads{}; std::array clients{}; - Common::MPMCQueue pad_queue{1024}; + Common::SPSCQueue pad_queue{}; Input::TouchStatus touch_status{}; std::array finger_id{}; }; diff --git a/src/input_common/udp/udp.cpp b/src/input_common/udp/udp.cpp index 3c3842c48..9829da6f0 100755 --- a/src/input_common/udp/udp.cpp +++ b/src/input_common/udp/udp.cpp @@ -59,7 +59,7 @@ Common::ParamPackage UDPMotionFactory::GetNextInput() { Common::ParamPackage params; CemuhookUDP::UDPPadStatus pad; auto& queue = client->GetPadQueue(); - while (queue.try_pop(pad)) { + while (queue.Pop(pad)) { if (pad.motion == CemuhookUDP::PadMotion::Undefined || std::abs(pad.motion_value) < 1) { continue; } diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp index c834e00bb..9547f277a 100755 --- a/src/video_core/gpu_thread.cpp +++ b/src/video_core/gpu_thread.cpp @@ -32,10 +32,7 @@ static void RunThread(std::stop_token stop_token, Core::System& system, VideoCore::RasterizerInterface* const rasterizer = renderer.ReadRasterizer(); while (!stop_token.stop_requested()) { - CommandDataContainer next; - if (!state.queue.try_pop(next)) { - continue; - } + CommandDataContainer next = state.queue.PopWait(stop_token); if (stop_token.stop_requested()) { break; } @@ -122,7 +119,7 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) { std::unique_lock lk(state.write_lock); const u64 fence{++state.last_fence}; - state.queue.push(CommandDataContainer(std::move(command_data), fence, block)); + state.queue.Push(CommandDataContainer(std::move(command_data), fence, block)); if (block) { state.cv.wait(lk, thread.get_stop_token(), [this, fence] { diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index af29563a8..00984188e 100755 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h @@ -11,7 +11,7 @@ #include #include -#include "common/atomic_threadsafe_queue.h" +#include "common/threadsafe_queue.h" #include "video_core/framebuffer_config.h" namespace Tegra { @@ -97,9 +97,9 @@ struct CommandDataContainer { /// Struct used to synchronize the GPU thread struct SynchState final { - using CommandQueue = Common::MPMCQueue; + using CommandQueue = Common::SPSCQueue; std::mutex write_lock; - CommandQueue queue{100000}; + CommandQueue queue; u64 last_fence{}; std::atomic signaled_fence{}; std::condition_variable_any cv; diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 4fa0c4a43..642a5f966 100755 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -81,8 +81,11 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, SetConfiguration(); PopulateSelectionList(); - connect(ui->tabWidget, &QTabWidget::currentChanged, this, - [this]() { debug_tab_tab->SetCurrentIndex(0); }); + connect(ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) { + if (index != -1) { + debug_tab_tab->SetCurrentIndex(0); + } + }); connect(ui_tab.get(), &ConfigureUi::LanguageChanged, this, &ConfigureDialog::OnLanguageChanged); connect(ui->selectorList, &QListWidget::itemSelectionChanged, this, &ConfigureDialog::UpdateVisibleTabs); diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 1031399e1..12699c126 100755 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -66,7 +66,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id, const std::str ui->tabWidget->addTab(system_tab.get(), tr("System")); ui->tabWidget->addTab(cpu_tab.get(), tr("CPU")); ui->tabWidget->addTab(graphics_tab.get(), tr("Graphics")); - ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("GraphicsAdvanced")); + ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics")); ui->tabWidget->addTab(audio_tab.get(), tr("Audio")); setFocusPolicy(Qt::ClickFocus); diff --git a/src/yuzu/configuration/configure_per_game.ui b/src/yuzu/configuration/configure_per_game.ui index 60efdbf21..85c86e107 100755 --- a/src/yuzu/configuration/configure_per_game.ui +++ b/src/yuzu/configuration/configure_per_game.ui @@ -2,14 +2,6 @@ ConfigurePerGame - - - 0 - 0 - 900 - 630 - - 900 diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5e6e04bc4..65b832ec0 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -291,6 +291,14 @@ GMainWindow::GMainWindow() ui->action_Fullscreen->setChecked(false); +#if defined(HAVE_SDL2) && !defined(_WIN32) + SDL_InitSubSystem(SDL_INIT_VIDEO); + // SDL disables the screen saver by default, and setting the hint + // SDL_HINT_VIDEO_ALLOW_SCREENSAVER doesn't seem to work, so we just enable the screen saver + // for now. + SDL_EnableScreenSaver(); +#endif + QStringList args = QApplication::arguments(); if (args.size() < 2) { @@ -361,8 +369,13 @@ GMainWindow::GMainWindow() GMainWindow::~GMainWindow() { // will get automatically deleted otherwise - if (render_window->parent() == nullptr) + if (render_window->parent() == nullptr) { delete render_window; + } + +#if defined(HAVE_SDL2) && !defined(_WIN32) + SDL_QuitSubSystem(SDL_INIT_VIDEO); +#endif } void GMainWindow::RegisterMetaTypes() { @@ -1453,14 +1466,6 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t SelectAndSetCurrentUser(); } -#if defined(HAVE_SDL2) && !defined(_WIN32) - SDL_InitSubSystem(SDL_INIT_VIDEO); - // SDL disables the screen saver by default, and setting the hint - // SDL_HINT_VIDEO_ALLOW_SCREENSAVER doesn't seem to work, so we just enable the screen saver - // for now. - SDL_EnableScreenSaver(); -#endif - if (!LoadROM(filename, program_id, program_index)) return; @@ -1553,10 +1558,6 @@ void GMainWindow::ShutdownGame() { AllowOSSleep(); -#if defined(HAVE_SDL2) && !defined(_WIN32) - SDL_QuitSubSystem(SDL_INIT_VIDEO); -#endif - discord_rpc->Pause(); emu_thread->RequestStop();