From 5e84862e287b0403bc5d9f853020738d858af22d Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Thu, 31 Aug 2023 01:29:12 +0000 Subject: [PATCH 001/314] [Linux/MacOS] Further Wiimote changes for parity with Windows (#945) --- src/gui/input/InputSettings2.cpp | 2 +- .../settings/WiimoteControllerSettings.cpp | 3 ++- .../input/settings/WiimoteControllerSettings.h | 2 +- src/input/CMakeLists.txt | 1 + src/input/InputManager.h | 2 +- src/input/api/Wiimote/hidapi/HidapiWiimote.cpp | 10 ++++++---- src/input/api/Wiimote/hidapi/HidapiWiimote.h | 5 +++-- src/input/emulated/EmulatedController.cpp | 17 ++++++++--------- 8 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index bc3d33e0..e34c9241 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -976,7 +976,7 @@ void InputSettings2::on_controller_settings(wxCommandEvent& event) case InputAPI::Keyboard: break; - #if BOOST_OS_WINDOWS + #ifdef SUPPORTS_WIIMOTE case InputAPI::Wiimote: { const auto wiimote = std::dynamic_pointer_cast(controller); wxASSERT(wiimote); diff --git a/src/gui/input/settings/WiimoteControllerSettings.cpp b/src/gui/input/settings/WiimoteControllerSettings.cpp index a1ea4ecf..5bc20269 100644 --- a/src/gui/input/settings/WiimoteControllerSettings.cpp +++ b/src/gui/input/settings/WiimoteControllerSettings.cpp @@ -14,7 +14,7 @@ #include "gui/components/wxInputDraw.h" #include "gui/input/InputAPIAddWindow.h" -#if BOOST_OS_WINDOWS +#ifdef SUPPORTS_WIIMOTE WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxPoint& position, std::shared_ptr controller) : wxDialog(parent, wxID_ANY, _("Controller settings"), position, wxDefaultSize, @@ -56,6 +56,7 @@ WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxP // Motion m_use_motion = new wxCheckBox(box, wxID_ANY, _("Use motion")); m_use_motion->SetValue(m_settings.motion); + m_use_motion->SetValue(m_settings.motion); m_use_motion->Enable(m_controller->has_motion()); row_sizer->Add(m_use_motion, 0, wxALL, 5); diff --git a/src/gui/input/settings/WiimoteControllerSettings.h b/src/gui/input/settings/WiimoteControllerSettings.h index b519b9e5..d5214efe 100644 --- a/src/gui/input/settings/WiimoteControllerSettings.h +++ b/src/gui/input/settings/WiimoteControllerSettings.h @@ -1,6 +1,6 @@ #pragma once -#if BOOST_OS_WINDOWS +#ifdef SUPPORTS_WIIMOTE #include #include diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index 9f542371..53b4dc3b 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -62,6 +62,7 @@ if(WIN32) endif() if (ENABLE_WIIMOTE) + target_compile_definitions(CemuInput PUBLIC SUPPORTS_WIIMOTE) target_sources(CemuInput PRIVATE api/Wiimote/WiimoteControllerProvider.h api/Wiimote/WiimoteControllerProvider.cpp diff --git a/src/input/InputManager.h b/src/input/InputManager.h index 345f7ba0..715d8f2e 100644 --- a/src/input/InputManager.h +++ b/src/input/InputManager.h @@ -5,7 +5,7 @@ #include "input/api/XInput/XInputControllerProvider.h" #endif -#if defined(HAS_HIDAPI) || BOOST_OS_WINDOWS +#ifdef SUPPORTS_WIIMOTE #include "input/api/Wiimote/WiimoteControllerProvider.h" #endif diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp index 7baad55d..898e6cf4 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp @@ -5,8 +5,8 @@ static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306; static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330; static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22; -HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier) - : m_handle(dev), m_identifier(identifier) { +HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path) + : m_handle(dev), m_identifier(identifier), m_path(path) { } @@ -35,11 +35,12 @@ std::vector HidapiWiimote::get_devices() { cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, boost::nowide::narrow(hid_error(nullptr))); } else { + hid_set_nonblocking(dev, true); // Enough to have a unique id for each device within a session uint64_t id = (static_cast(it->interface_number) << 32) | (static_cast(it->usage_page) << 16) | (it->usage); - wiimote_devices.push_back(std::make_shared(dev, id)); + wiimote_devices.push_back(std::make_shared(dev, id, it->path)); } } hid_free_enumeration(device_enumeration); @@ -47,7 +48,8 @@ std::vector HidapiWiimote::get_devices() { } bool HidapiWiimote::operator==(WiimoteDevice& o) const { - return m_identifier == static_cast(o).m_identifier; + auto const& other_mote = static_cast(o); + return m_identifier == other_mote.m_identifier && other_mote.m_path == m_path; } HidapiWiimote::~HidapiWiimote() { diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.h b/src/input/api/Wiimote/hidapi/HidapiWiimote.h index 6bd90dac..7b91dbbe 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.h +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.h @@ -5,7 +5,7 @@ class HidapiWiimote : public WiimoteDevice { public: - HidapiWiimote(hid_device* dev, uint64_t identifier); + HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path); ~HidapiWiimote() override; bool write_data(const std::vector &data) override; @@ -16,7 +16,8 @@ public: private: hid_device* m_handle; - uint64_t m_identifier; + const uint64_t m_identifier; + const std::string m_path; }; diff --git a/src/input/emulated/EmulatedController.cpp b/src/input/emulated/EmulatedController.cpp index 8712bcf0..e254db34 100644 --- a/src/input/emulated/EmulatedController.cpp +++ b/src/input/emulated/EmulatedController.cpp @@ -2,7 +2,7 @@ #include "input/api/Controller.h" -#if BOOST_OS_WINDOWS +#ifdef SUPPORTS_WIIMOTE #include "input/api/Wiimote/NativeWiimoteController.h" #endif @@ -131,15 +131,15 @@ bool EmulatedController::has_second_motion() const if(controller->use_motion()) { // if wiimote has nunchuck connected, we use its acceleration - #if BOOST_OS_WINDOWS - if(controller->api() == InputAPI::Wiimote) + #if SUPPORTS_WIIMOTE + if(controller->api() == InputAPI::Wiimote) { if(((NativeWiimoteController*)controller.get())->get_extension() == NativeWiimoteController::Nunchuck) { return true; } } - #endif + #endif motion++; } } @@ -156,7 +156,7 @@ MotionSample EmulatedController::get_second_motion_data() const if (controller->use_motion()) { // if wiimote has nunchuck connected, we use its acceleration - #if BOOST_OS_WINDOWS + #ifdef SUPPORTS_WIIMOTE if (controller->api() == InputAPI::Wiimote) { if (((NativeWiimoteController*)controller.get())->get_extension() == NativeWiimoteController::Nunchuck) @@ -211,12 +211,11 @@ void EmulatedController::add_controller(std::shared_ptr controll { controller->connect(); - #if BOOST_OS_WINDOWS - if (const auto wiimote = std::dynamic_pointer_cast(controller)) { + #ifdef SUPPORTS_WIIMOTE + if (const auto wiimote = std::dynamic_pointer_cast(controller)) { wiimote->set_player_index(m_player_index); } - #endif - + #endif std::scoped_lock lock(m_mutex); m_controllers.emplace_back(std::move(controller)); } From 2abf1c2059a95cedc9f2156ca311ad0c5b68799b Mon Sep 17 00:00:00 2001 From: jn64 <23169302+jn64@users.noreply.github.com> Date: Sat, 2 Sep 2023 11:57:21 +0800 Subject: [PATCH 002/314] Disable auto-update on Linux/macOS (#955) It's not implemented yet --- src/gui/GeneralSettings2.cpp | 3 +++ src/gui/GettingStartedDialog.cpp | 3 +++ src/gui/MainWindow.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index ad767ad1..59f0e5ee 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -166,6 +166,9 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) m_auto_update = new wxCheckBox(box, wxID_ANY, _("Automatically check for updates")); m_auto_update->SetToolTip(_("Automatically checks for new cemu versions on startup")); second_row->Add(m_auto_update, 0, botflag, 5); +#if BOOST_OS_LINUX || BOOST_OS_MACOS + m_auto_update->Disable(); +#endif second_row->AddSpacer(10); m_save_screenshot = new wxCheckBox(box, wxID_ANY, _("Save screenshot")); m_save_screenshot->SetToolTip(_("Pressing the screenshot key (F12) will save a screenshot directly to the screenshots folder")); diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index c84582b8..69f429b0 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -146,6 +146,9 @@ wxPanel* GettingStartedDialog::CreatePage2() m_update = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Automatically check for updates")); option_sizer->Add(m_update, 0, wxALL, 5); +#if BOOST_OS_LINUX || BOOST_OS_MACOS + m_update->Disable(); +#endif sizer->Add(option_sizer, 1, wxEXPAND, 5); page2_sizer->Add(sizer, 0, wxALL | wxEXPAND, 5); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 95d9bcdb..74591c58 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2254,6 +2254,9 @@ void MainWindow::RecreateMenu() //helpMenu->Append(MAINFRAME_MENU_ID_HELP_WEB, wxT("&Visit website")); //helpMenu->AppendSeparator(); m_check_update_menu = helpMenu->Append(MAINFRAME_MENU_ID_HELP_UPDATE, _("&Check for updates")); +#if BOOST_OS_LINUX || BOOST_OS_MACOS + m_check_update_menu->Enable(false); +#endif helpMenu->Append(MAINFRAME_MENU_ID_HELP_GETTING_STARTED, _("&Getting started")); helpMenu->AppendSeparator(); helpMenu->Append(MAINFRAME_MENU_ID_HELP_ABOUT, _("&About Cemu")); From d7f0d679047e9fe87de6b36cdd7f2be8b9800477 Mon Sep 17 00:00:00 2001 From: Gloria <32610623+yeah-its-gloria@users.noreply.github.com> Date: Wed, 6 Sep 2023 04:59:50 +0200 Subject: [PATCH 003/314] Add a pairing utility for Wiimotes to Cemu (#941) --- src/gui/CMakeLists.txt | 6 + src/gui/MainWindow.cpp | 1 + src/gui/PairingDialog.cpp | 236 +++++++++++++++++++++ src/gui/PairingDialog.h | 38 ++++ src/gui/input/panels/WiimoteInputPanel.cpp | 24 ++- src/gui/input/panels/WiimoteInputPanel.h | 1 + 6 files changed, 302 insertions(+), 4 deletions(-) create mode 100644 src/gui/PairingDialog.cpp create mode 100644 src/gui/PairingDialog.h diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 90dc91c0..19ce95dc 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -97,6 +97,8 @@ add_library(CemuGui MemorySearcherTool.h PadViewFrame.cpp PadViewFrame.h + PairingDialog.cpp + PairingDialog.h TitleManager.cpp TitleManager.h windows/PPCThreadsViewer @@ -170,3 +172,7 @@ if (ENABLE_WXWIDGETS) # PUBLIC because wx/app.h is included in CemuApp.h target_link_libraries(CemuGui PUBLIC wx::base wx::core wx::gl wx::propgrid wx::xrc) endif() + +if(WIN32) + target_link_libraries(CemuGui PRIVATE bthprops) +endif() diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 74591c58..6fa72801 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2160,6 +2160,7 @@ void MainWindow::RecreateMenu() m_memorySearcherMenuItem->Enable(false); toolsMenu->Append(MAINFRAME_MENU_ID_TOOLS_TITLE_MANAGER, _("&Title Manager")); toolsMenu->Append(MAINFRAME_MENU_ID_TOOLS_DOWNLOAD_MANAGER, _("&Download Manager")); + m_menuBar->Append(toolsMenu, _("&Tools")); // cpu timer speed menu diff --git a/src/gui/PairingDialog.cpp b/src/gui/PairingDialog.cpp new file mode 100644 index 00000000..f90e6d13 --- /dev/null +++ b/src/gui/PairingDialog.cpp @@ -0,0 +1,236 @@ +#include "gui/wxgui.h" +#include "gui/PairingDialog.h" + +#if BOOST_OS_WINDOWS +#include +#endif + +wxDECLARE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); +wxDEFINE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); + +PairingDialog::PairingDialog(wxWindow* parent) + : wxDialog(parent, wxID_ANY, _("Pairing..."), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) +{ + auto* sizer = new wxBoxSizer(wxVERTICAL); + m_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(350, 20), wxGA_HORIZONTAL); + m_gauge->SetValue(0); + sizer->Add(m_gauge, 0, wxALL | wxEXPAND, 5); + + auto* rows = new wxFlexGridSizer(0, 2, 0, 0); + rows->AddGrowableCol(1); + + m_text = new wxStaticText(this, wxID_ANY, _("Searching for controllers...")); + rows->Add(m_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + + { + auto* right_side = new wxBoxSizer(wxHORIZONTAL); + + m_cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); + m_cancelButton->Bind(wxEVT_BUTTON, &PairingDialog::OnCancelButton, this); + right_side->Add(m_cancelButton, 0, wxALL, 5); + + rows->Add(right_side, 1, wxALIGN_RIGHT, 5); + } + + sizer->Add(rows, 0, wxALL | wxEXPAND, 5); + + SetSizerAndFit(sizer); + Centre(wxBOTH); + + Bind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); + Bind(wxEVT_PROGRESS_PAIR, &PairingDialog::OnGaugeUpdate, this); + + m_thread = std::thread(&PairingDialog::WorkerThread, this); +} + +PairingDialog::~PairingDialog() +{ + Unbind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); +} + +void PairingDialog::OnClose(wxCloseEvent& event) +{ + event.Skip(); + + m_threadShouldQuit = true; + if (m_thread.joinable()) + m_thread.join(); +} + +void PairingDialog::OnCancelButton(const wxCommandEvent& event) +{ + Close(); +} + +void PairingDialog::OnGaugeUpdate(wxCommandEvent& event) +{ + PairingState state = (PairingState)event.GetInt(); + + switch (state) + { + case PairingState::Pairing: + { + m_text->SetLabel(_("Found controller. Pairing...")); + m_gauge->SetValue(50); + break; + } + + case PairingState::Finished: + { + m_text->SetLabel(_("Successfully paired the controller.")); + m_gauge->SetValue(100); + m_cancelButton->SetLabel(_("Close")); + break; + } + + case PairingState::NoBluetoothAvailable: + { + m_text->SetLabel(_("Failed to find a suitable Bluetooth radio.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } + + case PairingState::BluetoothFailed: + { + m_text->SetLabel(_("Failed to search for controllers.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } + + case PairingState::PairingFailed: + { + m_text->SetLabel(_("Failed to pair with the found controller.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } + + case PairingState::BluetoothUnusable: + { + m_text->SetLabel(_("Please use your system's Bluetooth manager instead.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } + + + default: + { + break; + } + } +} + +void PairingDialog::WorkerThread() +{ + const std::wstring wiimoteName = L"Nintendo RVL-CNT-01"; + const std::wstring wiiUProControllerName = L"Nintendo RVL-CNT-01-UC"; + +#if BOOST_OS_WINDOWS + const GUID bthHidGuid = {0x00001124,0x0000,0x1000,{0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB}}; + + const BLUETOOTH_FIND_RADIO_PARAMS radioFindParams = + { + .dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS) + }; + + HANDLE radio = INVALID_HANDLE_VALUE; + HBLUETOOTH_RADIO_FIND radioFind = BluetoothFindFirstRadio(&radioFindParams, &radio); + if (radioFind == nullptr) + { + UpdateCallback(PairingState::NoBluetoothAvailable); + return; + } + + BluetoothFindRadioClose(radioFind); + + BLUETOOTH_RADIO_INFO radioInfo = + { + .dwSize = sizeof(BLUETOOTH_RADIO_INFO) + }; + + DWORD result = BluetoothGetRadioInfo(radio, &radioInfo); + if (result != ERROR_SUCCESS) + { + UpdateCallback(PairingState::NoBluetoothAvailable); + return; + } + + const BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = + { + .dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), + + .fReturnAuthenticated = FALSE, + .fReturnRemembered = FALSE, + .fReturnUnknown = TRUE, + .fReturnConnected = FALSE, + + .fIssueInquiry = TRUE, + .cTimeoutMultiplier = 5, + + .hRadio = radio + }; + + BLUETOOTH_DEVICE_INFO info = + { + .dwSize = sizeof(BLUETOOTH_DEVICE_INFO) + }; + + while (!m_threadShouldQuit) + { + HBLUETOOTH_DEVICE_FIND deviceFind = BluetoothFindFirstDevice(&searchParams, &info); + if (deviceFind == nullptr) + { + UpdateCallback(PairingState::BluetoothFailed); + return; + } + + while (!m_threadShouldQuit) + { + if (info.szName == wiimoteName || info.szName == wiiUProControllerName) + { + BluetoothFindDeviceClose(deviceFind); + + UpdateCallback(PairingState::Pairing); + + wchar_t passwd[6] = { radioInfo.address.rgBytes[0], radioInfo.address.rgBytes[1], radioInfo.address.rgBytes[2], radioInfo.address.rgBytes[3], radioInfo.address.rgBytes[4], radioInfo.address.rgBytes[5] }; + DWORD bthResult = BluetoothAuthenticateDevice(nullptr, radio, &info, passwd, 6); + if (bthResult != ERROR_SUCCESS) + { + UpdateCallback(PairingState::PairingFailed); + return; + } + + bthResult = BluetoothSetServiceState(radio, &info, &bthHidGuid, BLUETOOTH_SERVICE_ENABLE); + if (bthResult != ERROR_SUCCESS) + { + UpdateCallback(PairingState::PairingFailed); + return; + } + + UpdateCallback(PairingState::Finished); + return; + } + + BOOL nextDevResult = BluetoothFindNextDevice(deviceFind, &info); + if (nextDevResult == FALSE) + { + break; + } + } + + BluetoothFindDeviceClose(deviceFind); + } +#else + UpdateCallback(PairingState::BluetoothUnusable); +#endif +} + +void PairingDialog::UpdateCallback(PairingState state) +{ + auto* event = new wxCommandEvent(wxEVT_PROGRESS_PAIR); + event->SetInt((int)state); + wxQueueEvent(this, event); +} \ No newline at end of file diff --git a/src/gui/PairingDialog.h b/src/gui/PairingDialog.h new file mode 100644 index 00000000..6c7612d1 --- /dev/null +++ b/src/gui/PairingDialog.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include +#include + +class PairingDialog : public wxDialog +{ +public: + PairingDialog(wxWindow* parent); + ~PairingDialog(); + +private: + enum class PairingState + { + Pairing, + Finished, + NoBluetoothAvailable, + BluetoothFailed, + PairingFailed, + BluetoothUnusable + }; + + void OnClose(wxCloseEvent& event); + void OnCancelButton(const wxCommandEvent& event); + void OnGaugeUpdate(wxCommandEvent& event); + + void WorkerThread(); + void UpdateCallback(PairingState state); + + wxStaticText* m_text; + wxGauge* m_gauge; + wxButton* m_cancelButton; + + std::thread m_thread; + bool m_threadShouldQuit = false; +}; diff --git a/src/gui/input/panels/WiimoteInputPanel.cpp b/src/gui/input/panels/WiimoteInputPanel.cpp index fbc4e325..050baad1 100644 --- a/src/gui/input/panels/WiimoteInputPanel.cpp +++ b/src/gui/input/panels/WiimoteInputPanel.cpp @@ -1,5 +1,6 @@ #include "gui/input/panels/WiimoteInputPanel.h" +#include #include #include #include @@ -11,6 +12,7 @@ #include "input/emulated/WiimoteController.h" #include "gui/helpers/wxHelpers.h" #include "gui/components/wxInputDraw.h" +#include "gui/PairingDialog.h" constexpr WiimoteController::ButtonId g_kFirstColumnItems[] = { @@ -36,10 +38,18 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent) bold_font.MakeBold(); auto* main_sizer = new wxBoxSizer(wxVERTICAL); + auto* horiz_main_sizer = new wxBoxSizer(wxHORIZONTAL); - auto* extensions_sizer = new wxBoxSizer(wxHORIZONTAL); - extensions_sizer->Add(new wxStaticText(this, wxID_ANY, _("Extensions:"))); - extensions_sizer->AddSpacer(10); + auto* pair_button = new wxButton(this, wxID_ANY, _("Pair a Wii or Wii U controller")); + pair_button->Bind(wxEVT_BUTTON, &WiimoteInputPanel::on_pair_button, this); + horiz_main_sizer->Add(pair_button); + horiz_main_sizer->AddSpacer(10); + + auto* extensions_sizer = new wxBoxSizer(wxHORIZONTAL); + horiz_main_sizer->Add(extensions_sizer, wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL)); + + extensions_sizer->Add(new wxStaticText(this, wxID_ANY, _("Extensions:"))); + extensions_sizer->AddSpacer(10); m_motion_plus = new wxCheckBox(this, wxID_ANY, _("MotionPlus")); m_motion_plus->Bind(wxEVT_CHECKBOX, &WiimoteInputPanel::on_extension_change, this); @@ -54,7 +64,7 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent) m_classic->Hide(); extensions_sizer->Add(m_classic); - main_sizer->Add(extensions_sizer, 0, wxEXPAND | wxALL, 5); + main_sizer->Add(horiz_main_sizer, 0, wxEXPAND | wxALL, 5); main_sizer->Add(new wxStaticLine(this), 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 5); m_item_sizer = new wxGridBagSizer(); @@ -254,3 +264,9 @@ void WiimoteInputPanel::load_controller(const EmulatedControllerPtr& emulated_co set_active_device_type(wiimote->get_device_type()); } } + +void WiimoteInputPanel::on_pair_button(wxCommandEvent& event) +{ + PairingDialog pairing_dialog(this); + pairing_dialog.ShowModal(); +} diff --git a/src/gui/input/panels/WiimoteInputPanel.h b/src/gui/input/panels/WiimoteInputPanel.h index a7aed99b..0810fbc3 100644 --- a/src/gui/input/panels/WiimoteInputPanel.h +++ b/src/gui/input/panels/WiimoteInputPanel.h @@ -25,6 +25,7 @@ private: void on_volume_change(wxCommandEvent& event); void on_extension_change(wxCommandEvent& event); + void on_pair_button(wxCommandEvent& event); wxGridBagSizer* m_item_sizer; From 4d1864c8a110dba382805ae2f26cec4da9984719 Mon Sep 17 00:00:00 2001 From: Cemu-Language CI Date: Thu, 7 Sep 2023 23:35:58 +0000 Subject: [PATCH 004/314] Update translation files --- bin/resources/de/cemu.mo | Bin 14625 -> 27890 bytes bin/resources/ko/cemu.mo | Bin 15670 -> 62866 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/de/cemu.mo b/bin/resources/de/cemu.mo index ee2bb29503f1ffa67c1640100e9be11e723d4a3c..70dbb2cb3863647139b90f81460f29f7a247566f 100644 GIT binary patch literal 27890 zcmb8137lM2o$oJ80yH42Ap1=NO+r$gg)MY|*hzPiCh4R}cM^!8-tM~9U37I-QMW3c z4rElsg%K46WD$kIAc6?W2)N+dIzAr5pz|2f5!d$|5uf6K@~Zy+HBj|@H&lCXg(~NMsCIu2 zs=R-Jdfzip&;J-64gV7!1rO+O`9i4j=K1(pa5nJ^pxV<5Rn7oB2yTV5;V4u&MX3IH z8&rL6_VN3m#_utxa=zvHEL8h{236k|pxV37X|7+7glf;pa38qX$IpT)ei)gZ-V0|D{}xm~KI88{3)PMn;7RahcosZN_)fS# zydJ9lw|ag8D&JS2`tvEM_k0hkUe7_5`$x}N^ISh30(Ji=sD79SPk>$UTzD}&0KOmI z3U7z|!?RC!Tn<%_HBjxn)N>dfM|=#b-q%1qcO6uJ-2_#?yZ!x#JU<6j-d8=p4b`sa zq59+ZQ2l$@e3!2ST79A9;9{uvT@Gi%3RL^1pvt)pD&K8T^}QczoF9V9_Xw0+J?{A< zsPcXXRo-9VfpGQ$7e5@TUB^K6UpvgfGhhMU2BlB-%eea|cy_{&^yN_f@kV$WEJKxl z3zQ1m1*O-%1Xa$nQ0;vYs=kMIy7ZHw-hVDs|6B-1;2Yp7I1T$?+d|j=A*lA}p!&N2 zRoChJS*`zylY#{HMY;;`5>U<806Kq2#>B$NQk_I{?++IjDARhkDO7Q1!eS z>OJ>ERBZ4$sQ&)}RQdnq`7%6&_&$qW{v)97&w+E`Tpzy>>OB`hwd*pd_gw*1ziXiC ze=R%!-ss~Wh6fS97iQrjP~(2w64$RM!&8W#2~UNWK-K3>p6`Xqe+N`K_dvDl(@^s9 zRiFL@)N|i~s{eCP^?CuS-oJr*J~+eaql2N!IUcIMr$aq|CR96m;9+nBl)Oan2zV7# z|6U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0OL%^^R%RdaN}H#SClMCp{8Iv4xG+b9x5G9}M#a&GK{nJ9;i0wD;;u zb>}d?^k<(9hg%FIEpB^6lj4K7IF~jytk~C(++;_`2%Fn`2|$k!irUMfbkS`%FdlnQ zjCHnSTGPy!Z%(U4nz0EowBe4>K*#KbCfb9B)~R>gf9_~JN-;LCcDLuZJW@&xrT0s| zT<-nj{jWF&wm3F_DRH0pBFX#YFHU&)TpTgmiLxDLUnkq*Za#0q9jA@UVYTnQ z{-*Ov&Xj^JeY{$hQASgO)j_x$3D>JEo|V60pBv3VJ37jq8}}(&){nL}GV?GIdHKV~ z@_PmyM$fO=An@h;|MB=boEh7w4(I7ONqB~cD)m`}ZImCl)zh?jQz zY)IH7$e1V0l7GedwlXK5ElS2Z-8-OTG{UPFeoy{6=iGKzKk?UC=`7s3uniM-J24t3 rNM3!z!CpD{$^B-6 Date: Fri, 8 Sep 2023 02:09:03 +0200 Subject: [PATCH 005/314] Localization improvements and fixes (#956) --- src/Cafe/Account/Account.h | 16 ----- src/Cafe/Filesystem/FST/KeyCache.cpp | 9 ++- src/Cafe/GraphicPack/GraphicPack2Patches.cpp | 13 ++-- src/Cafe/HW/Latte/Core/LatteShaderCache.cpp | 5 +- .../Tools/DownloadManager/DownloadManager.cpp | 16 ++--- src/config/CemuConfig.h | 19 +++--- src/gui/CemuApp.cpp | 45 ++++---------- src/gui/ChecksumTool.cpp | 40 +++++++------ src/gui/GameProfileWindow.cpp | 4 +- src/gui/GameUpdateWindow.cpp | 20 +++---- src/gui/GeneralSettings2.cpp | 44 +++++++++----- src/gui/GeneralSettings2.h | 2 + src/gui/GraphicPacksWindow2.cpp | 8 +-- src/gui/LoggingWindow.cpp | 2 +- src/gui/MainWindow.cpp | 59 ++----------------- src/gui/MainWindow.h | 2 - src/gui/MemorySearcherTool.cpp | 24 -------- src/gui/MemorySearcherTool.h | 2 - src/gui/TitleManager.cpp | 25 ++++---- src/gui/canvas/VulkanCanvas.cpp | 5 +- src/gui/components/wxDownloadManagerList.cpp | 27 ++++++--- src/gui/components/wxDownloadManagerList.h | 21 +------ src/gui/components/wxGameList.cpp | 18 +++--- src/gui/components/wxTitleManagerList.cpp | 52 ++++++++++------ src/gui/components/wxTitleManagerList.h | 25 +------- .../CreateAccount/wxCreateAccountDialog.cpp | 3 +- .../dialogs/SaveImport/SaveImportWindow.cpp | 20 +++---- src/gui/dialogs/SaveImport/SaveTransfer.cpp | 8 +-- src/gui/guiWrapper.cpp | 2 +- src/gui/helpers/wxHelpers.h | 19 +----- src/gui/input/InputAPIAddWindow.cpp | 2 +- src/gui/input/InputSettings2.cpp | 15 ++--- .../DebugPPCThreadsWindow.cpp | 6 +- src/gui/wxHelper.h | 7 --- 34 files changed, 229 insertions(+), 356 deletions(-) diff --git a/src/Cafe/Account/Account.h b/src/Cafe/Account/Account.h index 63eb5082..da196e42 100644 --- a/src/Cafe/Account/Account.h +++ b/src/Cafe/Account/Account.h @@ -16,22 +16,6 @@ enum class OnlineAccountError kPasswordCacheEmpty, kNoPrincipalId, }; -template <> -struct fmt::formatter : formatter { - template - auto format(const OnlineAccountError v, FormatContext& ctx) { - switch (v) - { - case OnlineAccountError::kNoAccountId: return formatter::format("AccountId missing (The account is not connected to a NNID)", ctx); - case OnlineAccountError::kNoPasswordCached: return formatter::format("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)", ctx); - case OnlineAccountError::kPasswordCacheEmpty: return formatter::format("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)", ctx); - case OnlineAccountError::kNoPrincipalId: return formatter::format("PrincipalId missing", ctx); - default: break; - } - return formatter::format("no error", ctx); - } -}; - struct OnlineValidator { diff --git a/src/Cafe/Filesystem/FST/KeyCache.cpp b/src/Cafe/Filesystem/FST/KeyCache.cpp index 5d8d51c1..29903e84 100644 --- a/src/Cafe/Filesystem/FST/KeyCache.cpp +++ b/src/Cafe/Filesystem/FST/KeyCache.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "config/ActiveSettings.h" #include "util/crypto/aes128.h" @@ -74,7 +75,7 @@ void KeyCache_Prepare() } else { - wxMessageBox("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to it's own directory, the disk is full or if anti-virus software is blocking Cemu.", "Error", wxOK | wxCENTRE | wxICON_ERROR); + wxMessageBox(_("Unable to create file keys.txt\nThis can happen if Cemu does not have write permission to its own directory, the disk is full or if anti-virus software is blocking Cemu."), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); } mtxKeyCache.unlock(); return; @@ -107,10 +108,8 @@ void KeyCache_Prepare() continue; if( strishex(line) == false ) { - // show error message - char errorMsg[512]; - sprintf(errorMsg, "Error in keys.txt in line %d\n", lineNumber); - wxMessageBox(errorMsg, "Error", wxOK | wxCENTRE | wxICON_ERROR); + auto errorMsg = formatWxString(_("Error in keys.txt at line {}"), lineNumber); + wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); continue; } if(line.size() == 32 ) diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp index 578b55db..7fa1e7fe 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp @@ -6,6 +6,7 @@ #include "boost/algorithm/string.hpp" #include "gui/wxgui.h" // for wxMessageBox +#include "gui/helpers/wxHelpers.h" // error handler void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumber, std::string_view errorMsg) @@ -39,13 +40,13 @@ void PatchErrorHandler::printError(class PatchGroup* patchGroup, sint32 lineNumb void PatchErrorHandler::showStageErrorMessageBox() { - std::string errorMsg; + wxString errorMsg; if (m_gp) { if (m_stage == STAGE::PARSER) - errorMsg.assign(fmt::format("Failed to load patches for graphic pack \'{}\'", m_gp->GetName())); + errorMsg.assign(formatWxString(_("Failed to load patches for graphic pack \'{}\'"), m_gp->GetName())); else - errorMsg.assign(fmt::format("Failed to apply patches for graphic pack \'{}\'", m_gp->GetName())); + errorMsg.assign(formatWxString(_("Failed to apply patches for graphic pack \'{}\'"), m_gp->GetName())); } else { @@ -53,7 +54,9 @@ void PatchErrorHandler::showStageErrorMessageBox() } if (cemuLog_isLoggingEnabled(LogType::Patches)) { - errorMsg.append("\n \nDetails:\n"); + errorMsg.append("\n \n") + .append(_("Details:")) + .append("\n"); for (auto& itr : errorMessages) { errorMsg.append(itr); @@ -61,7 +64,7 @@ void PatchErrorHandler::showStageErrorMessageBox() } } - wxMessageBox(errorMsg, "Graphic pack error"); + wxMessageBox(errorMsg, _("Graphic pack error")); } // loads Cemu-style patches (patch_.asm) diff --git a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp index 55bf4b8a..9576eb2e 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp @@ -792,10 +792,9 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path if (hasOldCacheFiles && !hasNewCacheFiles) { // ask user if they want to delete or keep the old cache file - const auto infoMsg = L"Outdated shader cache\n\nCemu detected that the shader cache for this game is outdated\nOnly shader caches generated with Cemu 1.25.0 or above are supported\n\n" - "We recommend deleting the outdated cache file as it will no longer be used by Cemu"; + auto infoMsg = _("Cemu detected that the shader cache for this game is outdated.\nOnly shader caches generated with Cemu 1.25.0 or above are supported.\n\nWe recommend deleting the outdated cache file as it will no longer be used by Cemu."); - wxMessageDialog dialog(nullptr, _(infoMsg), _("Outdated shader cache"), + wxMessageDialog dialog(nullptr, infoMsg, _("Outdated shader cache"), wxYES_NO | wxCENTRE | wxICON_EXCLAMATION); dialog.SetYesNoLabels(_("Delete outdated cache file [recommended]"), _("Keep outdated cache file")); diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index bb8eaa92..200d1641 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -371,7 +371,7 @@ bool DownloadManager::syncAccountTickets() for (auto& tiv : resultTicketIds.tivs) { index++; - std::string msg = _("Downloading account ticket").ToStdString(); + std::string msg = _("Downloading account ticket").utf8_string(); msg.append(fmt::format(" {0}/{1}", index, count)); setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING); // skip if already cached @@ -508,7 +508,7 @@ bool DownloadManager::syncUpdateTickets() if (titleIdParser.GetType() != TitleIdParser::TITLE_TYPE::BASE_TITLE_UPDATE) continue; - std::string msg = _("Downloading ticket").ToStdString(); + std::string msg = _("Downloading ticket").utf8_string(); msg.append(fmt::format(" {0}/{1}", updateIndex, numUpdates)); updateIndex++; setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING); @@ -561,7 +561,7 @@ bool DownloadManager::syncTicketCache() for (auto& ticketInfo : m_ticketCache) { index++; - std::string msg = _("Downloading meta data").ToStdString(); + std::string msg = _("Downloading meta data").utf8_string(); msg.append(fmt::format(" {0}/{1}", index, count)); setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING); prepareIDBE(ticketInfo.titleId); @@ -1054,7 +1054,7 @@ void DownloadManager::asyncPackageDownloadTMD(Package* package) std::unique_lock _l(m_mutex); if (!tmdResult.isValid) { - setPackageError(package, from_wxString(_("TMD download failed"))); + setPackageError(package, _("TMD download failed").utf8_string()); package->state.isDownloadingTMD = false; return; } @@ -1063,7 +1063,7 @@ void DownloadManager::asyncPackageDownloadTMD(Package* package) NCrypto::TMDParser tmdParser; if (!tmdParser.parse(tmdResult.tmdData.data(), tmdResult.tmdData.size())) { - setPackageError(package, from_wxString(_("Invalid TMD"))); + setPackageError(package, _("Invalid TMD").utf8_string()); package->state.isDownloadingTMD = false; return; } @@ -1172,7 +1172,7 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i size_t bytesWritten = callbackInfo->receiveBuffer.size(); if (callbackInfo->fileOutput->writeData(callbackInfo->receiveBuffer.data(), callbackInfo->receiveBuffer.size()) != (uint32)callbackInfo->receiveBuffer.size()) { - callbackInfo->downloadMgr->setPackageError(callbackInfo->package, from_wxString(_("Cannot write file. Disk full?"))); + callbackInfo->downloadMgr->setPackageError(callbackInfo->package, _("Cannot write file. Disk full?").utf8_string()); return false; } callbackInfo->receiveBuffer.clear(); @@ -1193,12 +1193,12 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i callbackInfoData.fileOutput = FileStream::createFile2(packageDownloadPath / fmt::format("{:08x}.app", contentId)); if (!callbackInfoData.fileOutput) { - setPackageError(package, from_wxString(_("Cannot create file"))); + setPackageError(package, _("Cannot create file").utf8_string()); return; } if (!NAPI::CCS_GetContentFile(titleId, contentId, CallbackInfo::writeCallback, &callbackInfoData)) { - setPackageError(package, from_wxString(_("Download failed"))); + setPackageError(package, _("Download failed").utf8_string()); delete callbackInfoData.fileOutput; return; } diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index e90874ba..19d9ca0e 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -6,6 +6,7 @@ #include "Cafe/Account/Account.h" #include +#include struct GameEntry { @@ -258,15 +259,15 @@ struct fmt::formatter : formatter { string_view name; switch (v) { - case CafeConsoleRegion::JPN: name = "Japan"; break; - case CafeConsoleRegion::USA: name = "USA"; break; - case CafeConsoleRegion::EUR: name = "Europe"; break; - case CafeConsoleRegion::AUS_DEPR: name = "Australia"; break; - case CafeConsoleRegion::CHN: name = "China"; break; - case CafeConsoleRegion::KOR: name = "Korea"; break; - case CafeConsoleRegion::TWN: name = "Taiwan"; break; - case CafeConsoleRegion::Auto: name = "Auto"; break; - default: name = "many"; break; + case CafeConsoleRegion::JPN: name = wxTRANSLATE("Japan"); break; + case CafeConsoleRegion::USA: name = wxTRANSLATE("USA"); break; + case CafeConsoleRegion::EUR: name = wxTRANSLATE("Europe"); break; + case CafeConsoleRegion::AUS_DEPR: name = wxTRANSLATE("Australia"); break; + case CafeConsoleRegion::CHN: name = wxTRANSLATE("China"); break; + case CafeConsoleRegion::KOR: name = wxTRANSLATE("Korea"); break; + case CafeConsoleRegion::TWN: name = wxTRANSLATE("Taiwan"); break; + case CafeConsoleRegion::Auto: name = wxTRANSLATE("Auto"); break; + default: name = wxTRANSLATE("many"); break; } return formatter::format(name, ctx); diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 0df90659..03496305 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -38,21 +38,6 @@ void unused_translation_dummy() void(_("Browse")); void(_("Select a file")); void(_("Select a directory")); - - void(_("base")); - void(_("update")); - void(_("dlc")); - void(_("save")); - - void(_("Japan")); - void(_("USA")); - void(_("Europe")); - void(_("Australia")); - void(_("China")); - void(_("Korea")); - void(_("Taiwan")); - void(_("Auto")); - void(_("many")); void(_("Japanese")); void(_("English")); @@ -67,13 +52,6 @@ void unused_translation_dummy() void(_("Russian")); void(_("Taiwanese")); void(_("unknown")); - - - // account.h - void(_("AccountId missing (The account is not connected to a NNID)")); - void(_("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)")); - void(_("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)")); - void(_("PrincipalId missing")); } bool CemuApp::OnInit() @@ -110,7 +88,8 @@ bool CemuApp::OnInit() #endif auto failed_write_access = ActiveSettings::LoadOnce(exePath, user_data_path, config_path, cache_path, data_path); for (auto&& path : failed_write_access) - wxMessageBox(fmt::format("Cemu can't write to {} !", path.generic_string()), _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr); + wxMessageBox(formatWxString(_("Cemu can't write to {}!"), path.generic_string()), + _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr); NetworkConfig::LoadOnce(); g_config.Load(); @@ -288,9 +267,10 @@ void CemuApp::CreateDefaultFiles(bool first_start) // check for mlc01 folder missing if custom path has been set if (!fs::exists(mlc) && !first_start) { - const std::wstring message = fmt::format(fmt::runtime(_(L"Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?").ToStdWstring()), mlc.wstring()); + const wxString message = formatWxString(_("Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?"), + _pathToUtf8(mlc)); - wxMessageDialog dialog(nullptr, message, "Error", wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING); + wxMessageDialog dialog(nullptr, message, _("Error"), wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING); dialog.SetYesNoCancelLabels(_("Yes"), _("No"), _("Select a custom path")); const auto dialogResult = dialog.ShowModal(); if (dialogResult == wxID_NO) @@ -362,16 +342,15 @@ void CemuApp::CreateDefaultFiles(bool first_start) } catch (const std::exception& ex) { - std::stringstream errorMsg; - errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString()), ex.what(), _pathToUtf8(mlc)); + wxString errorMsg = formatWxString(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}"), ex.what(), _pathToUtf8(mlc)); #if BOOST_OS_WINDOWS const DWORD lastError = GetLastError(); if (lastError != ERROR_SUCCESS) errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); - - wxMessageBox(errorMsg.str(), "Error", wxOK | wxCENTRE | wxICON_ERROR); #endif + + wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); exit(0); } @@ -388,17 +367,15 @@ void CemuApp::CreateDefaultFiles(bool first_start) } catch (const std::exception& ex) { - std::stringstream errorMsg; - errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString()), ex.what()); + wxString errorMsg = formatWxString(_("Couldn't create a required cemu directory or file!\n\nError: {0}"), ex.what()); #if BOOST_OS_WINDOWS const DWORD lastError = GetLastError(); if (lastError != ERROR_SUCCESS) errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); - - - wxMessageBox(errorMsg.str(), "Error", wxOK | wxCENTRE | wxICON_ERROR); #endif + + wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); exit(0); } } diff --git a/src/gui/ChecksumTool.cpp b/src/gui/ChecksumTool.cpp index 7dc61bb3..526ceef9 100644 --- a/src/gui/ChecksumTool.cpp +++ b/src/gui/ChecksumTool.cpp @@ -81,8 +81,8 @@ const char kSchema[] = R"( ChecksumTool::ChecksumTool(wxWindow* parent, wxTitleManagerList::TitleEntry& entry) - : wxDialog(parent, wxID_ANY, - wxStringFormat2(_("Title checksum of {:08x}-{:08x}"), (uint32)(entry.title_id >> 32), (uint32)(entry.title_id & 0xFFFFFFFF)), + : wxDialog(parent, wxID_ANY, + formatWxString(_("Title checksum of {:08x}-{:08x}"), (uint32) (entry.title_id >> 32), (uint32) (entry.title_id & 0xFFFFFFFF)), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxFRAME_TOOL_WINDOW | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX), m_entry(entry) { @@ -413,7 +413,7 @@ void ChecksumTool::OnExportChecksums(wxCommandEvent& event) } else { - wxMessageBox(wxStringFormat2(_("Can't write to file: {}"), target_file.string()), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("Can't write to file: {}"), target_file.string()), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); } } @@ -461,17 +461,17 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc) if (m_json_entry.title_id != test_entry.title_id) { - wxMessageBox(wxStringFormat2(_("The file you are comparing with is for a different title.")), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("The file you are comparing with is for a different title.")), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } if (m_json_entry.version != test_entry.version) { - wxMessageBox(wxStringFormat2(_("Wrong version: {}"), test_entry.version), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("Wrong version: {}"), test_entry.version), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } if (m_json_entry.region != test_entry.region) { - wxMessageBox(wxStringFormat2(_("Wrong region: {}"), test_entry.region), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("Wrong region: {}"), test_entry.region), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } if (!m_json_entry.wud_hash.empty()) @@ -483,7 +483,7 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc) } if(!boost::iequals(test_entry.wud_hash, m_json_entry.wud_hash)) { - wxMessageBox(wxStringFormat2(_("Your game image is invalid!\n\nYour hash:\n{}\n\nExpected hash:\n{}"), m_json_entry.wud_hash, test_entry.wud_hash), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("Your game image is invalid!\n\nYour hash:\n{}\n\nExpected hash:\n{}"), m_json_entry.wud_hash, test_entry.wud_hash), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } } @@ -563,7 +563,9 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc) } else if (missing_files.empty() && !invalid_hashes.empty()) { - const int result = wxMessageBox(wxStringFormat2(_("{} files have an invalid hash!\nDo you want to export a list of them to a file?"), invalid_hashes.size()), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR, this); + const int result = wxMessageBox(formatWxString( + _("{} files have an invalid hash!\nDo you want to export a list of them to a file?"), + invalid_hashes.size()), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR, this); if (result == wxYES) { writeMismatchInfoToLog(); @@ -572,7 +574,9 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc) } else if (!missing_files.empty() && !invalid_hashes.empty()) { - const int result = wxMessageBox(wxStringFormat2(_("Multiple issues with your game files have been found!\nDo you want to export them to a file?"), invalid_hashes.size()), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR, this); + const int result = wxMessageBox(formatWxString( + _("Multiple issues with your game files have been found!\nDo you want to export them to a file?"), + invalid_hashes.size()), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR, this); if (result == wxYES) { writeMismatchInfoToLog(); @@ -584,7 +588,7 @@ void ChecksumTool::VerifyJsonEntry(const rapidjson::Document& doc) } catch (const std::exception& ex) { - wxMessageBox(wxStringFormat2(_("JSON parse error: {}"), ex.what()), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(formatWxString(_("JSON parse error: {}"), ex.what()), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); } } @@ -610,7 +614,7 @@ void ChecksumTool::OnVerifyOnline(wxCommandEvent& event) d.ParseStream(str); if (d.HasParseError()) { - wxMessageBox(_("Can't parse json file!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(_("Can't parse JSON file!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -638,7 +642,7 @@ void ChecksumTool::OnVerifyLocal(wxCommandEvent& event) d.ParseStream(str); if (d.HasParseError()) { - wxMessageBox(_("Can't parse json file!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(_("Can't parse JSON file!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -680,7 +684,7 @@ void ChecksumTool::DoWork() case TitleInfo::TitleDataFormat::WUD: { const auto path = m_entry.path.string(); - wxQueueEvent(this, new wxSetGaugeValue(1, m_progress, m_status, wxStringFormat2(_("Reading game image: {}"), path))); + wxQueueEvent(this, new wxSetGaugeValue(1, m_progress, m_status, formatWxString(_("Reading game image: {}"), path))); wud_t* wud = wud_open(m_info.GetPath()); if (!wud) @@ -709,11 +713,11 @@ void ChecksumTool::DoWork() EVP_DigestUpdate(sha256, buffer.data(), read); - wxQueueEvent(this, new wxSetGaugeValue((int)((offset * 90) / wud_size), m_progress, m_status, wxStringFormat2(_("Reading game image: {0}/{1} kB"), offset / 1024, wud_size / 1024))); + wxQueueEvent(this, new wxSetGaugeValue((int)((offset * 90) / wud_size), m_progress, m_status, formatWxString(_("Reading game image: {0}/{1} kB"), offset / 1024, wud_size / 1024))); } while (read != 0 && size > 0); wud_close(wud); - wxQueueEvent(this, new wxSetGaugeValue(90, m_progress, m_status, wxStringFormat2(_("Generating checksum of game image: {}"), path))); + wxQueueEvent(this, new wxSetGaugeValue(90, m_progress, m_status, formatWxString(_("Generating checksum of game image: {}"), path))); if (!m_running.load(std::memory_order_relaxed)) return; @@ -729,7 +733,7 @@ void ChecksumTool::DoWork() m_json_entry.wud_hash = str.str(); - wxQueueEvent(this, new wxSetGaugeValue(100, m_progress, m_status, wxStringFormat2(_("Generated checksum of game image: {}"), path))); + wxQueueEvent(this, new wxSetGaugeValue(100, m_progress, m_status, formatWxString(_("Generated checksum of game image: {}"), path))); break; } default: @@ -765,7 +769,7 @@ void ChecksumTool::DoWork() m_json_entry.file_hashes[filename] = str.str(); ++counter; - wxQueueEvent(this, new wxSetGaugeValue((int)((counter * 100) / file_count), m_progress, m_status, wxStringFormat2(_("Hashing game file: {}/{}"), counter, file_count))); + wxQueueEvent(this, new wxSetGaugeValue((int)((counter * 100) / file_count), m_progress, m_status, formatWxString(_("Hashing game file: {}/{}"), counter, file_count))); if (!m_running.load(std::memory_order_relaxed)) { @@ -775,7 +779,7 @@ void ChecksumTool::DoWork() } m_info.Unmount(temporaryMountPath.c_str()); - wxQueueEvent(this, new wxSetGaugeValue(100, m_progress, m_status, wxStringFormat2(_("Generated checksum of {} game files"), file_count))); + wxQueueEvent(this, new wxSetGaugeValue(100, m_progress, m_status, formatWxString(_("Generated checksum of {} game files"), file_count))); break; } } diff --git a/src/gui/GameProfileWindow.cpp b/src/gui/GameProfileWindow.cpp index 4d56e9cd..17affc84 100644 --- a/src/gui/GameProfileWindow.cpp +++ b/src/gui/GameProfileWindow.cpp @@ -166,7 +166,7 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) for (int i = 0; i < 8; ++i) { - profile_sizer->Add(new wxStaticText(panel, wxID_ANY, fmt::format("{} {}", _("Controller").ToStdString(), (i + 1))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + profile_sizer->Add(new wxStaticText(panel, wxID_ANY, fmt::format("{} {}", _("Controller").utf8_string(), (i + 1))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_controller_profile[i] = new wxComboBox(panel, wxID_ANY,"", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_DROPDOWN| wxCB_READONLY); m_controller_profile[i]->SetMinSize(wxSize(250, -1)); @@ -244,7 +244,7 @@ void GameProfileWindow::SetProfileInt(gameProfileIntegerOption_t& option, wxChec void GameProfileWindow::ApplyProfile() { if(m_game_profile.m_gameName) - this->SetTitle(fmt::format("{} - {}", _("Edit game profile").ToStdString(), m_game_profile.m_gameName.value())); + this->SetTitle(fmt::format("{} - {}", _("Edit game profile").utf8_string(), m_game_profile.m_gameName.value())); // general m_load_libs->SetValue(m_game_profile.m_loadSharedLibraries.value()); diff --git a/src/gui/GameUpdateWindow.cpp b/src/gui/GameUpdateWindow.cpp index e90c9dc7..e422cbe6 100644 --- a/src/gui/GameUpdateWindow.cpp +++ b/src/gui/GameUpdateWindow.cpp @@ -16,18 +16,18 @@ std::string _GetTitleIdTypeStr(TitleId titleId) switch (tip.GetType()) { case TitleIdParser::TITLE_TYPE::AOC: - return _("DLC").ToStdString(); + return _("DLC").utf8_string(); case TitleIdParser::TITLE_TYPE::BASE_TITLE: - return _("Base game").ToStdString(); + return _("Base game").utf8_string(); case TitleIdParser::TITLE_TYPE::BASE_TITLE_DEMO: - return _("Demo").ToStdString(); + return _("Demo").utf8_string(); case TitleIdParser::TITLE_TYPE::SYSTEM_TITLE: case TitleIdParser::TITLE_TYPE::SYSTEM_OVERLAY_TITLE: - return _("System title").ToStdString(); + return _("System title").utf8_string(); case TitleIdParser::TITLE_TYPE::SYSTEM_DATA: - return _("System data title").ToStdString(); + return _("System data title").utf8_string(); case TitleIdParser::TITLE_TYPE::BASE_TITLE_UPDATE: - return _("Update").ToStdString(); + return _("Update").utf8_string(); default: break; } @@ -60,8 +60,8 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath) std::string typeStrToInstall = _GetTitleIdTypeStr(m_title_info.GetAppTitleId()); std::string typeStrCurrentlyInstalled = _GetTitleIdTypeStr(tmp.GetAppTitleId()); - std::string wxMsg = wxHelper::MakeUTF8(_("It seems that there is already a title installed at the target location but it has a different type.\nCurrently installed: \'{}\' Installing: \'{}\'\n\nThis can happen for titles which were installed with very old Cemu versions.\nDo you still want to continue with the installation? It will replace the currently installed title.")); - wxMessageDialog dialog(this, fmt::format(fmt::runtime(wxMsg), typeStrCurrentlyInstalled, typeStrToInstall), _("Warning"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION); + auto wxMsg = _("It seems that there is already a title installed at the target location but it has a different type.\nCurrently installed: \'{}\' Installing: \'{}\'\n\nThis can happen for titles which were installed with very old Cemu versions.\nDo you still want to continue with the installation? It will replace the currently installed title."); + wxMessageDialog dialog(this, formatWxString(wxMsg, typeStrCurrentlyInstalled, typeStrToInstall), _("Warning"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION); if (dialog.ShowModal() != wxID_YES) return false; } @@ -90,7 +90,7 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath) if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to move former title installation:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to move former title installation:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return false; } @@ -244,7 +244,7 @@ void GameUpdateWindow::ThreadWork() error_msg << GetSystemErrorMessage(ex); if(currentDirEntry != fs::directory_entry{}) - error_msg << fmt::format("\n{}\n{}",_("Current file:").ToStdString(), _pathToUtf8(currentDirEntry.path())); + error_msg << fmt::format("\n{}\n{}",_("Current file:").utf8_string(), _pathToUtf8(currentDirEntry.path())); m_thread_exception = error_msg.str(); m_thread_state = ThreadCanceled; diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 59f0e5ee..0fad827f 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -2001,44 +2001,60 @@ void GeneralSettings2::OnShowOnlineValidator(wxCommandEvent& event) if (validator) // everything valid? shouldn't happen return; - std::wstringstream err; - err << L"The following error(s) have been found:" << std::endl; + wxString err; + err << _("The following error(s) have been found:") << '\n'; if (validator.otp == OnlineValidator::FileState::Missing) - err << L"otp.bin missing in cemu root directory" << std::endl; + err << _("otp.bin missing in Cemu root directory") << '\n'; else if(validator.otp == OnlineValidator::FileState::Corrupted) - err << L"otp.bin is invalid" << std::endl; + err << _("otp.bin is invalid") << '\n'; if (validator.seeprom == OnlineValidator::FileState::Missing) - err << L"seeprom.bin missing in cemu root directory" << std::endl; + err << _("seeprom.bin missing in Cemu root directory") << '\n'; else if(validator.seeprom == OnlineValidator::FileState::Corrupted) - err << L"seeprom.bin is invalid" << std::endl; + err << _("seeprom.bin is invalid") << '\n'; if(!validator.missing_files.empty()) { - err << L"Missing certificate and key files:" << std::endl; + err << _("Missing certificate and key files:") << '\n'; int counter = 0; for (const auto& f : validator.missing_files) { - err << f << std::endl; + err << f << '\n'; ++counter; if(counter > 10) { - err << L"..." << std::endl; + err << "..." << '\n'; break; } } - err << std::endl; + err << '\n'; } if (!validator.valid_account) { - err << L"The currently selected account is not a valid or dumped online account:\n" << boost::nowide::widen(fmt::format("{}", validator.account_error)); + err << _("The currently selected account is not a valid or dumped online account:") << '\n'; + err << GetOnlineAccountErrorMessage(validator.account_error); } - - - wxMessageBox(err.str(), _("Online Status"), wxOK | wxCENTRE | wxICON_INFORMATION); + + wxMessageBox(err, _("Online Status"), wxOK | wxCENTRE | wxICON_INFORMATION); } + +std::string GeneralSettings2::GetOnlineAccountErrorMessage(OnlineAccountError error) +{ + switch (error) { + case OnlineAccountError::kNoAccountId: + return _("AccountId missing (The account is not connected to a NNID)").utf8_string(); + case OnlineAccountError::kNoPasswordCached: + return _("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)").utf8_string(); + case OnlineAccountError::kPasswordCacheEmpty: + return _("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)").utf8_string(); + case OnlineAccountError::kNoPrincipalId: + return _("PrincipalId missing").utf8_string(); + default: + return "no error"; + } +} \ No newline at end of file diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index a6136abf..b667faf0 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include class wxColourPickerCtrl; @@ -100,6 +101,7 @@ private: void OnShowOnlineValidator(wxCommandEvent& event); void OnOnlineEnable(wxCommandEvent& event); void OnAccountServiceChanged(wxCommandEvent& event); + std::string GetOnlineAccountErrorMessage(OnlineAccountError error); // updates cemu audio devices void UpdateAudioDevice(); diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 78fa6569..c03c6fdf 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -570,8 +570,8 @@ void GraphicPacksWindow2::OnActivePresetChanged(wxCommandEvent& event) wxASSERT(obj); const auto string_data = dynamic_cast(obj->GetClientObject()); wxASSERT(string_data); - const auto preset = wxHelper::MakeUTF8(obj->GetStringSelection()); - if(m_shown_graphic_pack->SetActivePreset(wxHelper::MakeUTF8(string_data->GetData()), preset)) + const auto preset = obj->GetStringSelection().utf8_string(); + if(m_shown_graphic_pack->SetActivePreset(string_data->GetData().utf8_string(), preset)) { wxWindowUpdateLocker lock(this); ClearPresets(); @@ -629,7 +629,7 @@ void GraphicPacksWindow2::OnCheckForUpdates(wxCommandEvent& event) const auto packs = str.str(); if(!packs.empty()) { - wxMessageBox(fmt::format("{}\n \n{} \n{}", _("This update removed or renamed the following graphic packs:").ToStdString(), packs, _("You may need to set them up again.").ToStdString()), + wxMessageBox(fmt::format("{}\n \n{} \n{}", _("This update removed or renamed the following graphic packs:").utf8_string(), packs, _("You may need to set them up again.").utf8_string()), _("Warning"), wxOK | wxCENTRE | wxICON_INFORMATION, this); } } @@ -668,7 +668,7 @@ void GraphicPacksWindow2::SashPositionChanged(wxEvent& event) void GraphicPacksWindow2::OnFilterUpdate(wxEvent& event) { - m_filter = wxHelper::MakeUTF8(m_filter_text->GetValue()); + m_filter = m_filter_text->GetValue().utf8_string(); FillGraphicPackList(); event.Skip(); } diff --git a/src/gui/LoggingWindow.cpp b/src/gui/LoggingWindow.cpp index dbc7536d..4026113e 100644 --- a/src/gui/LoggingWindow.cpp +++ b/src/gui/LoggingWindow.cpp @@ -88,7 +88,7 @@ void LoggingWindow::OnLogMessage(wxLogEvent& event) void LoggingWindow::OnFilterChange(wxCommandEvent& event) { - m_log_list->SetActiveFilter(from_wxString(m_filter->GetValue())); + m_log_list->SetActiveFilter(m_filter->GetValue().utf8_string()); event.Skip(); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 6fa72801..bba64a24 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -638,7 +638,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) const auto menuId = event.GetId(); if (menuId == MAINFRAME_MENU_ID_FILE_LOAD) { - const auto wildcard = wxStringFormat2( + const auto wildcard = formatWxString( "{}|*.wud;*.wux;*.wua;*.iso;*.rpx;*.elf" "|{}|*.wud;*.wux;*.iso" "|{}|*.wua" @@ -648,7 +648,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) _("Wii U image (*.wud, *.wux, *.iso, *.wad)"), _("Wii U archive (*.wua)"), _("Wii U executable (*.rpx, *.elf)"), - _("All files (*.*)") + _("All files (*.*)") ); wxFileDialog openFileDialog(this, _("Open file to launch"), wxEmptyString, wxEmptyString, wildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST); @@ -706,7 +706,7 @@ void MainWindow::OnInstallUpdate(wxCommandEvent& event) { if (!fs::exists(dirPath.parent_path() / "code") || !fs::exists(dirPath.parent_path() / "content") || !fs::exists(dirPath.parent_path() / "meta")) { - wxMessageBox(wxStringFormat2(_("The (parent) folder of the title you selected is missing at least one of the required subfolders (\"code\", \"content\" and \"meta\")\nMake sure that the files are complete."), dirPath.filename().string())); + wxMessageBox(formatWxString(_("The (parent) folder of the title you selected is missing at least one of the required subfolders (\"code\", \"content\" and \"meta\")\nMake sure that the files are complete."), dirPath.filename().string())); continue; } else @@ -1837,7 +1837,7 @@ public: void AddHeaderInfo(wxWindow* parent, wxSizer* sizer) { - auto versionString = fmt::format(fmt::runtime(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}").ToStdString()), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov"); + auto versionString = formatWxString(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}"), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov"); sizer->Add(new wxStaticText(parent, wxID_ANY, versionString), wxSizerFlags().Border(wxALL, 3).Border(wxTOP, 10)); sizer->Add(new wxHyperlinkCtrl(parent, -1, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3)); @@ -2287,57 +2287,6 @@ void MainWindow::RecreateMenu() SetMenuVisible(false); } -void MainWindow::OnAfterCallShowErrorDialog() -{ - //wxMessageBox((const wxString&)dialogText, (const wxString&)dialogTitle, wxICON_INFORMATION); - //wxDialog* dialog = new wxDialog(NULL,wxID_ANY,(const wxString&)dialogTitle,wxDefaultPosition,wxSize(310,170)); - //dialog->ShowModal(); - //dialogState = 1; -} - -bool MainWindow::EnableOnlineMode() const -{ - // TODO: not used anymore - // - // if enabling online mode, check if all requirements are met - std::wstring additionalErrorInfo; - const sint32 onlineReqError = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo); - - bool enableOnline = false; - if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_OTP_MISSING) - { - wxMessageBox(_("otp.bin could not be found"), _("Error"), wxICON_ERROR); - } - else if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_OTP_CORRUPTED) - { - wxMessageBox(_("otp.bin is corrupted or has invalid size"), _("Error"), wxICON_ERROR); - } - else if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_SEEPROM_MISSING) - { - wxMessageBox(_("seeprom.bin could not be found"), _("Error"), wxICON_ERROR); - } - else if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_SEEPROM_CORRUPTED) - { - wxMessageBox(_("seeprom.bin is corrupted or has invalid size"), _("Error"), wxICON_ERROR); - } - else if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_MISSING_FILE) - { - std::wstring errorMessage = fmt::format(L"Unable to load a necessary file:\n{}", additionalErrorInfo); - wxMessageBox(errorMessage.c_str(), _("Error"), wxICON_ERROR); - } - else if (onlineReqError == IOS_CRYPTO_ONLINE_REQ_OK) - { - enableOnline = true; - } - else - { - wxMessageBox(_("Unknown error occured"), _("Error"), wxICON_ERROR); - } - - //config_get()->enableOnlineMode = enableOnline; - return enableOnline; -} - void MainWindow::RestoreSettingsAfterGameExited() { RecreateMenu(); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 7597c2b2..c1762867 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -104,7 +104,6 @@ public: void OnHelpAbout(wxCommandEvent& event); void OnHelpGettingStarted(wxCommandEvent& event); void OnHelpUpdate(wxCommandEvent& event); - void OnAfterCallShowErrorDialog(); void OnDebugSetting(wxCommandEvent& event); void OnDebugLoggingToggleFlagGeneric(wxCommandEvent& event); void OnPPCInfoToggle(wxCommandEvent& event); @@ -149,7 +148,6 @@ private: void RecreateMenu(); static wxString GetInitialWindowTitle(); void ShowGettingStartedDialog(); - bool EnableOnlineMode() const; bool InstallUpdate(const fs::path& metaFilePath); diff --git a/src/gui/MemorySearcherTool.cpp b/src/gui/MemorySearcherTool.cpp index 093f7ffe..5e711dd9 100644 --- a/src/gui/MemorySearcherTool.cpp +++ b/src/gui/MemorySearcherTool.cpp @@ -664,30 +664,6 @@ void MemorySearcherTool::SetSearchDataType() m_searchDataType = SearchDataType_None; } -std::string MemorySearcherTool::GetSearchTypeName() const -{ - switch (m_searchDataType) - { - case SearchDataType_String: - return from_wxString(kDatatypeString); - case SearchDataType_Float: - return from_wxString(kDatatypeFloat); - case SearchDataType_Double: - return from_wxString(kDatatypeDouble); - case SearchDataType_Int8: - return from_wxString(kDatatypeInt8); - case SearchDataType_Int16: - return from_wxString(kDatatypeInt16); - case SearchDataType_Int32: - return from_wxString(kDatatypeInt32); - case SearchDataType_Int64: - return from_wxString(kDatatypeInt64); - default: - return ""; - } - -} - template <> bool MemorySearcherTool::ConvertStringToType(const char* inValue, sint8& outValue) const { diff --git a/src/gui/MemorySearcherTool.h b/src/gui/MemorySearcherTool.h index add9aced..78b5cb77 100644 --- a/src/gui/MemorySearcherTool.h +++ b/src/gui/MemorySearcherTool.h @@ -56,8 +56,6 @@ private: void RefreshResultList(); void RefreshStashList(); void SetSearchDataType(); - std::string GetSearchTypeName() const; - void CreateRightClickPopupMenu(); void Load(); void Save(); diff --git a/src/gui/TitleManager.cpp b/src/gui/TitleManager.cpp index 2440e12c..a36b3f74 100644 --- a/src/gui/TitleManager.cpp +++ b/src/gui/TitleManager.cpp @@ -70,7 +70,7 @@ wxPanel* TitleManager::CreateTitleManagerPage() row->Add(m_refresh_button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); auto* help_button = new wxStaticBitmap(panel, wxID_ANY, wxBITMAP_PNG_FROM_DATA(PNG_HELP)); - help_button->SetToolTip(wxStringFormat2(_("The following prefixes are supported:\n{0}\n{1}\n{2}\n{3}\n{4}"), + help_button->SetToolTip(formatWxString(_("The following prefixes are supported:\n{0}\n{1}\n{2}\n{3}\n{4}"), "titleid:", "name:", "type:", "version:", "region:")); row->Add(help_button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); @@ -328,7 +328,7 @@ void TitleManager::OnTitleSearchComplete(wxCommandEvent& event) } // update status bar text m_title_list->SortEntries(-1); - m_status_bar->SetStatusText(wxStringFormat2(_("Found {0} games, {1} updates, {2} DLCs and {3} save entries"), + m_status_bar->SetStatusText(formatWxString(_("Found {0} games, {1} updates, {2} DLCs and {3} save entries"), m_title_list->GetCountByType(wxTitleManagerList::EntryType::Base) + m_title_list->GetCountByType(wxTitleManagerList::EntryType::System), m_title_list->GetCountByType(wxTitleManagerList::EntryType::Update), m_title_list->GetCountByType(wxTitleManagerList::EntryType::Dlc), @@ -494,7 +494,7 @@ void TitleManager::OnSaveDelete(wxCommandEvent& event) if (selection.IsEmpty()) return; - const auto msg = wxStringFormat2(_("Are you really sure that you want to delete the save entry for {}"), selection); + const auto msg = formatWxString(_("Are you really sure that you want to delete the save entry for {}"), selection); const auto result = wxMessageBox(msg, _("Warning"), wxYES_NO | wxCENTRE | wxICON_EXCLAMATION, this); if (result == wxNO) return; @@ -545,7 +545,7 @@ void TitleManager::OnSaveDelete(wxCommandEvent& event) fs::remove_all(target, ec); if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to delete the save directory:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to delete the save directory:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return; } @@ -622,7 +622,8 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) const auto persistent_id = (uint32)(uintptr_t)m_save_account_list->GetClientData(selection_index); - wxFileDialog path_dialog(this, _("Select a target file to export the save entry"), entry->path.string(), wxEmptyString, "Exported save entry (*.zip)|*.zip", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + wxFileDialog path_dialog(this, _("Select a target file to export the save entry"), entry->path.string(), wxEmptyString, + fmt::format("{}|*.zip", _("Exported save entry (*.zip)")), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (path_dialog.ShowModal() != wxID_OK || path_dialog.GetPath().IsEmpty()) return; @@ -633,7 +634,7 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) { zip_error_t ziperror; zip_error_init_with_code(&ziperror, ze); - const auto error_msg = wxStringFormat2(_("Error when creating the zip for the save entry:\n{}"), zip_error_strerror(&ziperror)); + const auto error_msg = formatWxString(_("Error when creating the zip for the save entry:\n{}"), zip_error_strerror(&ziperror)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -651,7 +652,7 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) { if(zip_dir_add(zip, (const char*)entryname.substr(savedir_str.size() + 1).c_str(), ZIP_FL_ENC_UTF_8) < 0 ) { - const auto error_msg = wxStringFormat2(_("Error when trying to add a directory to the zip:\n{}"), zip_strerror(zip)); + const auto error_msg = formatWxString(_("Error when trying to add a directory to the zip:\n{}"), zip_strerror(zip)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); } } @@ -660,13 +661,13 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) auto* source = zip_source_file(zip, (const char*)entryname.c_str(), 0, 0); if(!source) { - const auto error_msg = wxStringFormat2(_("Error when trying to add a file to the zip:\n{}"), zip_strerror(zip)); + const auto error_msg = formatWxString(_("Error when trying to add a file to the zip:\n{}"), zip_strerror(zip)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); } if (zip_file_add(zip, (const char*)entryname.substr(savedir_str.size() + 1).c_str(), source, ZIP_FL_ENC_UTF_8) < 0) { - const auto error_msg = wxStringFormat2(_("Error when trying to add a file to the zip:\n{}"), zip_strerror(zip)); + const auto error_msg = formatWxString(_("Error when trying to add a file to the zip:\n{}"), zip_strerror(zip)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); zip_source_free(source); @@ -679,7 +680,7 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) auto* metabuff = zip_source_buffer(zip, metacontent.data(), metacontent.size(), 0); if(zip_file_add(zip, "cemu_meta", metabuff, ZIP_FL_ENC_UTF_8) < 0) { - const auto error_msg = wxStringFormat2(_("Error when trying to add cemu_meta file to the zip:\n{}"), zip_strerror(zip)); + const auto error_msg = formatWxString(_("Error when trying to add cemu_meta file to the zip:\n{}"), zip_strerror(zip)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); zip_source_free(metabuff); @@ -730,11 +731,11 @@ void TitleManager::InitiateConnect() if (!NCrypto::SEEPROM_IsPresent()) { - SetDownloadStatusText("Dumped online files not found"); + SetDownloadStatusText(_("Dumped online files not found")); return; } - SetDownloadStatusText("Connecting..."); + SetDownloadStatusText(_("Connecting...")); // begin async connect dlMgr->setUserData(this); dlMgr->registerCallbacks( diff --git a/src/gui/canvas/VulkanCanvas.cpp b/src/gui/canvas/VulkanCanvas.cpp index 5463a494..eb56b3c4 100644 --- a/src/gui/canvas/VulkanCanvas.cpp +++ b/src/gui/canvas/VulkanCanvas.cpp @@ -7,6 +7,7 @@ #endif #include +#include VulkanCanvas::VulkanCanvas(wxWindow* parent, const wxSize& size, bool is_main_window) : IRenderCanvas(is_main_window), wxWindow(parent, wxID_ANY, wxDefaultPosition, size, wxNO_FULL_REPAINT_ON_RESIZE | wxWANTS_CHARS) @@ -36,8 +37,8 @@ VulkanCanvas::VulkanCanvas(wxWindow* parent, const wxSize& size, bool is_main_wi } catch(const std::exception& ex) { - const auto msg = fmt::format(fmt::runtime(_("Error when initializing Vulkan renderer:\n{}").ToStdString()), ex.what()); - cemuLog_log(LogType::Force, msg); + cemuLog_log(LogType::Force, "Error when initializing Vulkan renderer: {}", ex.what()); + auto msg = formatWxString(_("Error when initializing Vulkan renderer:\n{}"), ex.what()); wxMessageDialog dialog(this, msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); dialog.ShowModal(); exit(0); diff --git a/src/gui/components/wxDownloadManagerList.cpp b/src/gui/components/wxDownloadManagerList.cpp index ebff9e95..ca2d7a71 100644 --- a/src/gui/components/wxDownloadManagerList.cpp +++ b/src/gui/components/wxDownloadManagerList.cpp @@ -432,13 +432,11 @@ wxString wxDownloadManagerList::GetTitleEntryText(const TitleEntry& entry, ItemC switch (column) { case ColumnTitleId: - return wxStringFormat2("{:08x}-{:08x}", (uint32)(entry.titleId >> 32), (uint32)(entry.titleId & 0xFFFFFFFF)); + return formatWxString("{:08x}-{:08x}", (uint32) (entry.titleId >> 32), (uint32) (entry.titleId & 0xFFFFFFFF)); case ColumnName: - { return entry.name; - } case ColumnType: - return wxStringFormat2("{}", entry.type); + return GetTranslatedTitleEntryType(entry.type); case ColumnVersion: { // dont show version for base game unless it is not v0 @@ -446,7 +444,7 @@ wxString wxDownloadManagerList::GetTitleEntryText(const TitleEntry& entry, ItemC return ""; if (entry.type == EntryType::DLC && entry.version == 0) return ""; - return wxStringFormat2("v{}", entry.version); + return formatWxString("v{}", entry.version); } case ColumnProgress: { @@ -454,11 +452,11 @@ wxString wxDownloadManagerList::GetTitleEntryText(const TitleEntry& entry, ItemC { if (entry.progress >= 1000) return "100%"; - return wxStringFormat2("{:.1f}%", (float)entry.progress / 10.0f); // one decimal + return formatWxString("{:.1f}%", (float) entry.progress / 10.0f); // one decimal } else if (entry.status == TitleDownloadStatus::Installing || entry.status == TitleDownloadStatus::Checking || entry.status == TitleDownloadStatus::Verifying) { - return wxStringFormat2("{0}/{1}", entry.progress, entry.progressMax); // number of processed files/content files + return formatWxString("{0}/{1}", entry.progress, entry.progressMax); // number of processed files/content files } return ""; } @@ -503,6 +501,21 @@ wxString wxDownloadManagerList::GetTitleEntryText(const TitleEntry& entry, ItemC return wxEmptyString; } +std::string wxDownloadManagerList::GetTranslatedTitleEntryType(EntryType type) +{ + switch (type) + { + case EntryType::Base: + return _("base").utf8_string(); + case EntryType::Update: + return _("update").utf8_string(); + case EntryType::DLC: + return _("DLC").utf8_string(); + default: + return std::to_string(static_cast>(type)); + } +} + void wxDownloadManagerList::AddOrUpdateTitle(TitleEntryData_t* obj) { const auto& data = obj->GetData(); diff --git a/src/gui/components/wxDownloadManagerList.h b/src/gui/components/wxDownloadManagerList.h index 0af5b082..b0051076 100644 --- a/src/gui/components/wxDownloadManagerList.h +++ b/src/gui/components/wxDownloadManagerList.h @@ -150,25 +150,6 @@ private: bool SortFunc(std::span sortColumnOrder, const Type_t& v1, const Type_t& v2); static wxString GetTitleEntryText(const TitleEntry& entry, ItemColumn column); + static std::string GetTranslatedTitleEntryType(EntryType entryType); std::future m_context_worker; }; - -template <> -struct fmt::formatter : formatter -{ - using base = fmt::formatter; - template - auto format(const wxDownloadManagerList::EntryType& type, FormatContext& ctx) - { - switch (type) - { - case wxDownloadManagerList::EntryType::Base: - return base::format("base", ctx); - case wxDownloadManagerList::EntryType::Update: - return base::format("update", ctx); - case wxDownloadManagerList::EntryType::DLC: - return base::format("DLC", ctx); - } - return base::format(std::to_string(static_cast>(type)), ctx); - } -}; \ No newline at end of file diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 69f74870..ebbab044 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -633,7 +633,7 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event) if(dialog.ShowModal() == wxID_OK) { const auto custom_name = dialog.GetValue(); - GetConfig().SetGameListCustomName(title_id, wxHelper::MakeUTF8(custom_name)); + GetConfig().SetGameListCustomName(title_id, custom_name.utf8_string()); m_name_cache.clear(); g_config.Save(); // update list entry @@ -1036,8 +1036,8 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event) const auto region_text = fmt::format("{}", gameInfo.GetRegion()); - SetItem(index, ColumnRegion, _(region_text)); - SetItem(index, ColumnTitleID, _(fmt::format("{:016x}", titleId))); + SetItem(index, ColumnRegion, wxGetTranslation(region_text)); + SetItem(index, ColumnTitleID, fmt::format("{:016x}", titleId)); } else if (m_style == Style::kIcons) { @@ -1124,7 +1124,7 @@ void wxGameList::HandleTitleListCallback(CafeTitleListCallbackEvent* evt) void wxGameList::RemoveCache(const std::list& cachePaths, const std::string& titleName) { - wxMessageDialog dialog(this, fmt::format(fmt::runtime(_("Remove the shader caches for {}?").ToStdString()), titleName), _("Remove shader caches"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION); + wxMessageDialog dialog(this, formatWxString(_("Remove the shader caches for {}?"), titleName), _("Remove shader caches"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION); dialog.SetYesNoLabels(_("Yes"), _("No")); const auto dialogResult = dialog.ShowModal(); @@ -1139,7 +1139,7 @@ void wxGameList::RemoveCache(const std::list& cachePaths, const std::s if (errs.empty()) wxMessageDialog(this, _("The shader caches were removed!"), _("Shader caches removed"), wxCENTRE | wxOK | wxICON_INFORMATION).ShowModal(); else - wxMessageDialog(this, fmt::format(fmt::runtime(_("Failed to remove the shader caches:\n{}").ToStdString()), fmt::join(errs, "\n")), _("Error"), wxCENTRE | wxOK | wxICON_ERROR).ShowModal(); + wxMessageDialog(this, formatWxString(_("Failed to remove the shader caches:\n{}"), fmt::join(errs, "\n")), _("Error"), wxCENTRE | wxOK | wxICON_ERROR).ShowModal(); } void wxGameList::AsyncWorkerThread() @@ -1265,13 +1265,13 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) { // In most cases it should find it if (!result_index){ - wxMessageBox("Icon is yet to load, so will not be used by the shortcut", "Warning", wxOK | wxCENTRE | wxICON_WARNING); + wxMessageBox(_("Icon is yet to load, so will not be used by the shortcut"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); } else { const fs::path out_icon_dir = ActiveSettings::GetUserDataPath("icons"); if (!fs::exists(out_icon_dir) && !fs::create_directories(out_icon_dir)){ - wxMessageBox("Cannot access the icon directory, the shortcut will have no icon", "Warning", wxOK | wxCENTRE | wxICON_WARNING); + wxMessageBox(_("Cannot access the icon directory, the shortcut will have no icon"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); } else { icon_path = out_icon_dir / fmt::format("{:016x}.png", gameInfo.GetBaseTitleId()); @@ -1282,7 +1282,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) { wxPNGHandler pngHandler; if (!pngHandler.SaveFile(&image, png_file, false)) { icon_path = std::nullopt; - wxMessageBox("The icon was unable to be saved, the shortcut will have no icon", "Warning", wxOK | wxCENTRE | wxICON_WARNING); + wxMessageBox(_("The icon was unable to be saved, the shortcut will have no icon"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); } } } @@ -1306,7 +1306,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) { std::ofstream output_stream(output_path); if (!output_stream.good()) { - const wxString errorMsg = fmt::format("Failed to save desktop entry to {}", output_path.utf8_string()); + auto errorMsg = formatWxString(_("Failed to save desktop entry to {}"), output_path.utf8_string()); wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return; } diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index 6572a702..bae986ca 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -303,29 +303,29 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 righ } } - std::string msg = wxHelper::MakeUTF8(_("The following content will be converted to a compressed Wii U archive file (.wua):")); + wxString msg = _("The following content will be converted to a compressed Wii U archive file (.wua):"); msg.append("\n \n"); if (titleInfo_base.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game:\n{}"))), titleInfo_base.GetPrintPath())); + msg.append(formatWxString(_("Base game:\n{}"), titleInfo_base.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game:\nNot installed"))))); + msg.append(_("Base game:\nNot installed")); msg.append("\n\n"); if (titleInfo_update.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update:\n{}"))), titleInfo_update.GetPrintPath())); + msg.append(formatWxString(_("Update:\n{}"), titleInfo_update.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update:\nNot installed"))))); + msg.append(_("Update:\nNot installed")); msg.append("\n\n"); if (titleInfo_aoc.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC:\n{}"))), titleInfo_aoc.GetPrintPath())); + msg.append(formatWxString(_("DLC:\n{}"), titleInfo_aoc.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC:\nNot installed"))))); + msg.append(_("DLC:\nNot installed")); - const int answer = wxMessageBox(wxString::FromUTF8(msg), _("Confirmation"), wxOK | wxCANCEL | wxCENTRE | wxICON_QUESTION, this); + const int answer = wxMessageBox(msg, _("Confirmation"), wxOK | wxCANCEL | wxCENTRE | wxICON_QUESTION, this); if (answer != wxOK) return; std::vector titlesToConvert; @@ -732,7 +732,7 @@ void wxTitleManagerList::OnItemSelected(wxListEvent& event) // return;; //} - //m_tooltip_text->SetLabel(wxStringFormat2("{}\n{}", msg, _("You can use the context menu to fix it."))); + //m_tooltip_text->SetLabel(formatWxString("{}\n{}", msg, _("You can use the context menu to fix it."))); //m_tooltip_window->Fit(); //m_tooltip_timer->StartOnce(250); } @@ -792,9 +792,9 @@ bool wxTitleManagerList::DeleteEntry(long index, const TitleEntry& entry) wxString msg; const bool is_directory = fs::is_directory(entry.path); if(is_directory) - msg = wxStringFormat2(_("Are you really sure that you want to delete the following folder:\n{}"), wxHelper::FromUtf8(_pathToUtf8(entry.path))); + msg = formatWxString(_("Are you really sure that you want to delete the following folder:\n{}"), _pathToUtf8(entry.path)); else - msg = wxStringFormat2(_("Are you really sure that you want to delete the following file:\n{}"), wxHelper::FromUtf8(_pathToUtf8(entry.path))); + msg = formatWxString(_("Are you really sure that you want to delete the following file:\n{}"), _pathToUtf8(entry.path)); const auto result = wxMessageBox(msg, _("Warning"), wxYES_NO | wxCENTRE | wxICON_EXCLAMATION, this); if (result == wxNO) @@ -835,7 +835,7 @@ bool wxTitleManagerList::DeleteEntry(long index, const TitleEntry& entry) if(ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to delete the entry:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to delete the entry:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK|wxCENTRE, this); return false; } @@ -922,15 +922,15 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu switch (column) { case ColumnTitleId: - return wxStringFormat2("{:08x}-{:08x}", (uint32)(entry.title_id >> 32), (uint32)(entry.title_id & 0xFFFFFFFF)); + return formatWxString("{:08x}-{:08x}", (uint32) (entry.title_id >> 32), (uint32) (entry.title_id & 0xFFFFFFFF)); case ColumnName: return entry.name; case ColumnType: - return wxStringFormat2("{}", entry.type); + return GetTranslatedTitleEntryType(entry.type); case ColumnVersion: - return wxStringFormat2("{}", entry.version); + return formatWxString("{}", entry.version); case ColumnRegion: - return wxStringFormat2("{}", entry.region); // TODO its a flag so formatter is currently not correct + return wxGetTranslation(fmt::format("{}", entry.region)); case ColumnFormat: { if (entry.type == EntryType::Save) @@ -945,7 +945,6 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu return _("WUA"); } return ""; - //return wxStringFormat2("{}", entry.format); } case ColumnLocation: { @@ -964,6 +963,25 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu return wxEmptyString; } +std::string wxTitleManagerList::GetTranslatedTitleEntryType(EntryType type) +{ + switch (type) + { + case EntryType::Base: + return _("base").utf8_string(); + case EntryType::Update: + return _("update").utf8_string(); + case EntryType::Dlc: + return _("DLC").utf8_string(); + case EntryType::Save: + return _("save").utf8_string(); + case EntryType::System: + return _("system").utf8_string(); + default: + return std::to_string(static_cast>(type)); + } +} + void wxTitleManagerList::HandleTitleListCallback(CafeTitleListCallbackEvent* evt) { if (evt->eventType != CafeTitleListCallbackEvent::TYPE::TITLE_DISCOVERED && diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index 547310c2..043c78f6 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -132,32 +132,9 @@ private: bool SortFunc(int column, const Type_t& v1, const Type_t& v2); static wxString GetTitleEntryText(const TitleEntry& entry, ItemColumn column); + static std::string GetTranslatedTitleEntryType(EntryType entryType); std::future m_context_worker; uint64 m_callbackIdTitleList; uint64 m_callbackIdSaveList; }; - -template <> -struct fmt::formatter : formatter -{ - using base = fmt::formatter; - template - auto format(const wxTitleManagerList::EntryType& type, FormatContext& ctx) - { - switch (type) - { - case wxTitleManagerList::EntryType::Base: - return base::format("base", ctx); - case wxTitleManagerList::EntryType::Update: - return base::format("update", ctx); - case wxTitleManagerList::EntryType::Dlc: - return base::format("DLC", ctx); - case wxTitleManagerList::EntryType::Save: - return base::format("save", ctx); - case wxTitleManagerList::EntryType::System: - return base::format("system", ctx); - } - return base::format(std::to_string(static_cast>(type)), ctx); - } -}; \ No newline at end of file diff --git a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp index 71b56637..1da92c34 100644 --- a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp +++ b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "util/helpers/helpers.h" wxCreateAccountDialog::wxCreateAccountDialog(wxWindow* parent) @@ -71,7 +72,7 @@ void wxCreateAccountDialog::OnOK(wxCommandEvent& event) const auto id = GetPersistentId(); if(id < Account::kMinPersistendId) { - wxMessageBox(fmt::format(fmt::runtime(_("The persistent id must be greater than {:x}!").ToStdString()), Account::kMinPersistendId), + wxMessageBox(formatWxString(_("The persistent id must be greater than {:x}!"), Account::kMinPersistendId), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } diff --git a/src/gui/dialogs/SaveImport/SaveImportWindow.cpp b/src/gui/dialogs/SaveImport/SaveImportWindow.cpp index 2a570bb0..b31f24b2 100644 --- a/src/gui/dialogs/SaveImport/SaveImportWindow.cpp +++ b/src/gui/dialogs/SaveImport/SaveImportWindow.cpp @@ -30,8 +30,8 @@ SaveImportWindow::SaveImportWindow(wxWindow* parent, uint64 title_id) row1->Add(new wxStaticText(this, wxID_ANY, _("Source")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_source_selection = new wxFilePickerCtrl(this, wxID_ANY, wxEmptyString, - _("Select a zipped save file"), - wxStringFormat2("{}|*.zip", _("Save entry (*.zip)"))); + _("Select a zipped save file"), + formatWxString("{}|*.zip", _("Save entry (*.zip)"))); m_source_selection->SetMinSize({ 270, -1 }); row1->Add(m_source_selection, 1, wxALL | wxEXPAND, 5); @@ -118,7 +118,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) const uint64_t titleId = ConvertString(str.substr(sizeof("titleId = ") + 1), 16); if(titleId != 0 && titleId != m_title_id) { - const auto msg = wxStringFormat2(_("You are trying to import a savegame for a different title than your currently selected one: {:016x} vs {:016x}\nAre you sure that you want to continue?"), titleId, m_title_id); + const auto msg = formatWxString(_("You are trying to import a savegame for a different title than your currently selected one: {:016x} vs {:016x}\nAre you sure that you want to continue?"), titleId, m_title_id); const auto res = wxMessageBox(msg, _("Error"), wxYES_NO | wxCENTRE | wxICON_WARNING, this); if(res == wxNO) { @@ -143,7 +143,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) //auto tmp_source = fs::temp_directory_path(ec); //if(ec) //{ - // const auto error_msg = wxStringFormat2(_("Error when getting the temp directory path:\n{}"), GetSystemErrorMessage(ec)); + // const auto error_msg = formatWxString(_("Error when getting the temp directory path:\n{}"), GetSystemErrorMessage(ec)); // wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); // return; //} @@ -158,7 +158,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) target_id = ConvertString(m_target_selection->GetValue().ToStdString(), 16); if (target_id < Account::kMinPersistendId) { - const auto msg = wxStringFormat2(_("The given account id is not valid!\nIt must be a hex number bigger or equal than {:08x}"), Account::kMinPersistendId); + const auto msg = formatWxString(_("The given account id is not valid!\nIt must be a hex number bigger or equal than {:08x}"), Account::kMinPersistendId); wxMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -170,7 +170,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) { if (!fs::is_directory(target_path)) { - const auto msg = wxStringFormat2(_("There's already a file at the target directory:\n{}"), _pathToUtf8(target_path)); + const auto msg = formatWxString(_("There's already a file at the target directory:\n{}"), _pathToUtf8(target_path)); wxMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); m_return_code = wxCANCEL; Close(); @@ -193,7 +193,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to delete the former save game:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to delete the former save game:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return; } @@ -213,7 +213,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) fs::create_directories(tmp_source, ec); if (ec) { - const auto error_msg = wxStringFormat2(_("Error when creating the extraction path:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when creating the extraction path:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -221,7 +221,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) zip = zip_open(zipfile.c_str(), ZIP_RDONLY, &ziperr); if (!zip) { - const auto error_msg = wxStringFormat2(_("Error when opening the import zip file:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when opening the import zip file:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -319,7 +319,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) fs::rename(tmp_source, target_path, ec); if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to move the extracted save game:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to move the extracted save game:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return; }*/ diff --git a/src/gui/dialogs/SaveImport/SaveTransfer.cpp b/src/gui/dialogs/SaveImport/SaveTransfer.cpp index 14e473a1..c763c419 100644 --- a/src/gui/dialogs/SaveImport/SaveTransfer.cpp +++ b/src/gui/dialogs/SaveImport/SaveTransfer.cpp @@ -92,7 +92,7 @@ void SaveTransfer::OnTransfer(wxCommandEvent& event) target_id = ConvertString(m_target_selection->GetValue().ToStdString(), 16); if(target_id < Account::kMinPersistendId) { - const auto msg = wxStringFormat2(_("The given account id is not valid!\nIt must be a hex number bigger or equal than {:08x}"), Account::kMinPersistendId); + const auto msg = formatWxString(_("The given account id is not valid!\nIt must be a hex number bigger or equal than {:08x}"), Account::kMinPersistendId); wxMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; } @@ -108,7 +108,7 @@ void SaveTransfer::OnTransfer(wxCommandEvent& event) { if(!fs::is_directory(target_path)) { - const auto msg = wxStringFormat2(_("There's already a file at the target directory:\n{}"), _pathToUtf8(target_path)); + const auto msg = formatWxString(_("There's already a file at the target directory:\n{}"), _pathToUtf8(target_path)); wxMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); m_return_code = wxCANCEL; Close(); @@ -131,7 +131,7 @@ void SaveTransfer::OnTransfer(wxCommandEvent& event) if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to delete the former save game:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to delete the former save game:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return; } @@ -187,7 +187,7 @@ void SaveTransfer::OnTransfer(wxCommandEvent& event) fs::rename(source_path, target_path, ec); if (ec) { - const auto error_msg = wxStringFormat2(_("Error when trying to move the save game:\n{}"), GetSystemErrorMessage(ec)); + const auto error_msg = formatWxString(_("Error when trying to move the save game:\n{}"), GetSystemErrorMessage(ec)); wxMessageBox(error_msg, _("Error"), wxOK | wxCENTRE, this); return; } diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index 1a5e999b..68f97590 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -136,7 +136,7 @@ void gui_updateWindowTitles(bool isIdle, bool isLoading, double fps) g_mainFrame->AsyncSetTitle(windowText); auto* pad = g_mainFrame->GetPadView(); if (pad) - pad->AsyncSetTitle(fmt::format("GamePad View - FPS: {:.02f}", fps)); + pad->AsyncSetTitle(fmt::format("{} - FPS: {:.02f}", _("GamePad View").utf8_string(), fps)); } } diff --git a/src/gui/helpers/wxHelpers.h b/src/gui/helpers/wxHelpers.h index 8fd0f8a9..fa135cf4 100644 --- a/src/gui/helpers/wxHelpers.h +++ b/src/gui/helpers/wxHelpers.h @@ -45,16 +45,9 @@ public: }; template -wxString wxStringFormat2(const wxString& format, TArgs&&...args) +wxString formatWxString(const wxString& format, TArgs&&...args) { - // ignores locale? - return fmt::format(fmt::runtime(format.ToStdString()), std::forward(args)...); -} - -template -wxString wxStringFormat2W(const wxString& format, TArgs&&...args) -{ - return fmt::format(fmt::runtime(format.ToStdWstring()), std::forward(args)...); + return wxString::FromUTF8(fmt::format(fmt::runtime(format.utf8_string()), std::forward(args)...)); } // executes a function when destroying the obj @@ -86,14 +79,6 @@ inline wxString to_wxString(std::string_view str) return wxString::FromUTF8(str.data(), str.size()); } -// creates utf8 std::string from wxString -inline std::string from_wxString(const wxString& str) -{ - const auto tmp = str.ToUTF8(); - return std::string{ tmp.data(), tmp.length() }; -} - - template T get_next_sibling(const T element) { diff --git a/src/gui/input/InputAPIAddWindow.cpp b/src/gui/input/InputAPIAddWindow.cpp index f32a85b6..8fa85fa3 100644 --- a/src/gui/input/InputAPIAddWindow.cpp +++ b/src/gui/input/InputAPIAddWindow.cpp @@ -23,7 +23,7 @@ using wxControllerData = wxCustomData; InputAPIAddWindow::InputAPIAddWindow(wxWindow* parent, const wxPoint& position, const std::vector& controllers) - : wxDialog(parent, wxID_ANY, _("Add input API"), position, wxDefaultSize, 0), m_controllers(controllers) + : wxDialog(parent, wxID_ANY, "Add input API", position, wxDefaultSize, 0), m_controllers(controllers) { this->SetSizeHints(wxDefaultSize, wxDefaultSize); diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index e34c9241..7a52f865 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -79,7 +79,7 @@ InputSettings2::InputSettings2(wxWindow* parent) { auto* page = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); page->SetClientObject(nullptr); // force internal type to client object - m_notebook->AddPage(page, wxStringFormat2(_("Controller {}"), i + 1)); + m_notebook->AddPage(page, formatWxString(_("Controller {}"), i + 1)); } m_notebook->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &InputSettings2::on_controller_page_changed, this); @@ -585,9 +585,7 @@ void InputSettings2::on_profile_text_changed(wxCommandEvent& event) // load_bttn, save_bttn, delete_bttn, profile_status const auto text = event.GetString(); - const auto text_str = from_wxString(text); - - const bool valid_name = InputManager::is_valid_profilename(text_str); + const bool valid_name = InputManager::is_valid_profilename(text.utf8_string()); const bool name_exists = profile_names->FindString(text) != wxNOT_FOUND; page_data.m_profile_load->Enable(name_exists); @@ -603,7 +601,7 @@ void InputSettings2::on_profile_load(wxCommandEvent& event) auto* profile_names = page_data.m_profiles; auto* text = page_data.m_profile_status; - const auto selection = from_wxString(profile_names->GetValue()); + const auto selection = profile_names->GetValue().utf8_string(); text->Show(); if (selection.empty() || !InputManager::is_valid_profilename(selection)) { @@ -639,7 +637,7 @@ void InputSettings2::on_profile_save(wxCommandEvent& event) auto* profile_names = page_data.m_profiles; auto* text = page_data.m_profile_status; - const auto selection = from_wxString(profile_names->GetValue()); + const auto selection = profile_names->GetValue().utf8_string(); text->Show(); if (selection.empty() || !InputManager::is_valid_profilename(selection)) { @@ -670,7 +668,7 @@ void InputSettings2::on_profile_delete(wxCommandEvent& event) auto* profile_names = page_data.m_profiles; auto* text = page_data.m_profile_status; - const auto selection = from_wxString(profile_names->GetStringSelection()); + const auto selection = profile_names->GetStringSelection().utf8_string(); text->Show(); if (selection.empty() || !InputManager::is_valid_profilename(selection)) @@ -725,10 +723,9 @@ void InputSettings2::on_emulated_controller_selected(wxCommandEvent& event) } else { - const auto type_str = from_wxString(event.GetString()); try { - const auto type = EmulatedController::type_from_string(type_str); + const auto type = EmulatedController::type_from_string(event.GetString().utf8_string()); // same has already been selected if (page_data.m_controller && page_data.m_controller->type() == type) return; diff --git a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index b93cf94e..bd71942f 100644 --- a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -8,6 +8,7 @@ #include "gui/components/wxProgressDialogManager.h" #include +#include enum { @@ -333,7 +334,7 @@ void DebugPPCThreadsWindow::PresentProfileResults(OSThread_t* thread, const std: void DebugPPCThreadsWindow::ProfileThreadWorker(OSThread_t* thread) { wxProgressDialogManager progressDialog(this); - progressDialog.Create("Profiling thread", + progressDialog.Create(_("Profiling thread"), _("Capturing samples..."), 1000, // range wxPD_CAN_SKIP); @@ -364,8 +365,7 @@ void DebugPPCThreadsWindow::ProfileThreadWorker(OSThread_t* thread) totalSampleCount++; if ((totalSampleCount % 50) == 0) { - wxString msg = fmt::format("Capturing samples... ({:})\nResults will be written to log.txt\n", - totalSampleCount); + wxString msg = formatWxString(_("Capturing samples... ({:})\nResults will be written to log.txt\n"), totalSampleCount); if (totalSampleCount < 30000) msg.Append(_("Click Skip button for early results with lower accuracy")); else diff --git a/src/gui/wxHelper.h b/src/gui/wxHelper.h index ac959755..468651ac 100644 --- a/src/gui/wxHelper.h +++ b/src/gui/wxHelper.h @@ -3,13 +3,6 @@ namespace wxHelper { - // wxString to utf8 std::string - inline std::string MakeUTF8(const wxString& str) - { - auto tmpUtf8 = str.ToUTF8(); - return std::string(tmpUtf8.data(), tmpUtf8.length()); - } - inline fs::path MakeFSPath(const wxString& str) { auto tmpUtf8 = str.ToUTF8(); From c66ab0c51ac19eedb5655b231e3731310ccdaaf3 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Fri, 8 Sep 2023 02:09:28 +0200 Subject: [PATCH 006/314] Use native language names in language selector (#964) --- src/gui/GeneralSettings2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 0fad827f..bbe1c474 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -123,13 +123,13 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) first_row->Add(new wxStaticText(box, wxID_ANY, _("Language"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - wxString language_choices[] = { _("Default"), _("English") }; + wxString language_choices[] = { _("Default"), "English" }; m_language = new wxChoice(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, std::size(language_choices), language_choices); m_language->SetSelection(0); m_language->SetToolTip(_("Changes the interface language of Cemu\nAvailable languages are stored in the translation directory\nA restart will be required after changing the language")); for (const auto& language : wxGetApp().GetLanguages()) { - m_language->Append(language->Description); + m_language->Append(language->DescriptionNative); } first_row->Add(m_language, 0, wxALL | wxEXPAND, 5); @@ -935,7 +935,7 @@ void GeneralSettings2::StoreConfig() const auto language = m_language->GetStringSelection(); for (const auto& lang : app->GetLanguages()) { - if (lang->Description == language) + if (lang->DescriptionNative == language) { GetConfig().language = lang->Language; break; @@ -1538,7 +1538,7 @@ void GeneralSettings2::ApplyConfig() { if (config.language == language->Language) { - m_language->SetStringSelection(language->Description); + m_language->SetStringSelection(language->DescriptionNative); break; } } From 96800c6f9785d0fc9822da24421a7e6ac9014dd9 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Thu, 14 Sep 2023 12:47:59 +0200 Subject: [PATCH 007/314] Additional localization fixes (#966) --- .github/workflows/generate_pot.yml | 4 +- .../Tools/DownloadManager/DownloadManager.cpp | 20 +++--- src/gui/CemuApp.cpp | 2 +- src/gui/GameProfileWindow.cpp | 4 +- src/gui/GameUpdateWindow.cpp | 22 +++---- src/gui/GeneralSettings2.cpp | 10 +-- src/gui/GeneralSettings2.h | 2 +- src/gui/GraphicPacksWindow2.cpp | 15 ++--- src/gui/MemorySearcherTool.cpp | 4 +- src/gui/TitleManager.cpp | 2 +- src/gui/components/wxDownloadManagerList.cpp | 8 +-- src/gui/components/wxDownloadManagerList.h | 2 +- src/gui/components/wxGameList.cpp | 19 +++--- src/gui/components/wxTitleManagerList.cpp | 12 ++-- src/gui/components/wxTitleManagerList.h | 2 +- src/gui/wxgui.h | 63 +------------------ 16 files changed, 68 insertions(+), 123 deletions(-) diff --git a/.github/workflows/generate_pot.yml b/.github/workflows/generate_pot.yml index f2675574..7dfa86f8 100644 --- a/.github/workflows/generate_pot.yml +++ b/.github/workflows/generate_pot.yml @@ -29,8 +29,8 @@ jobs: - name: "Generate POT file using xgettext" run: > find src -name *.cpp -o -name *.hpp -o -name *.h | - xargs xgettext --from-code=utf-8 - -k_ -kwxTRANSLATE -w 100 + xargs xgettext --from-code=utf-8 -w 100 + --keyword="_" --keyword="wxTRANSLATE" --keyword="wxPLURAL:1,2" --check=space-ellipsis --omit-header -o cemu.pot diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index 200d1641..ec39b928 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -424,7 +424,7 @@ bool DownloadManager::syncAccountTickets() bool DownloadManager::syncSystemTitleTickets() { - setStatusMessage(std::string(_("Downloading system tickets...")), DLMGR_STATUS_CODE::CONNECTING); + setStatusMessage(_("Downloading system tickets...").utf8_string(), DLMGR_STATUS_CODE::CONNECTING); // todo - add GetAuth() function NAPI::AuthInfo authInfo; authInfo.accountId = m_authInfo.nnidAccountName; @@ -486,7 +486,7 @@ bool DownloadManager::syncSystemTitleTickets() // build list of updates for which either an installed game exists or the base title ticket is cached bool DownloadManager::syncUpdateTickets() { - setStatusMessage(std::string(_("Retrieving update information...")), DLMGR_STATUS_CODE::CONNECTING); + setStatusMessage(_("Retrieving update information...").utf8_string(), DLMGR_STATUS_CODE::CONNECTING); // download update version list downloadTitleVersionList(); if (!m_hasTitleVersionList) @@ -566,7 +566,7 @@ bool DownloadManager::syncTicketCache() setStatusMessage(msg, DLMGR_STATUS_CODE::CONNECTING); prepareIDBE(ticketInfo.titleId); } - setStatusMessage(std::string(_("Connected. Right click entries in the list to start downloading")), DLMGR_STATUS_CODE::CONNECTED); + setStatusMessage(_("Connected. Right click entries in the list to start downloading").utf8_string(), DLMGR_STATUS_CODE::CONNECTED); return true; } @@ -652,7 +652,7 @@ void DownloadManager::_handle_connect() // reset login state m_iasToken.serviceAccountId.clear(); m_iasToken.deviceToken.clear(); - setStatusMessage(std::string(_("Logging in..")), DLMGR_STATUS_CODE::CONNECTING); + setStatusMessage(_("Logging in...").utf8_string(), DLMGR_STATUS_CODE::CONNECTING); // retrieve ECS AccountId + DeviceToken from cache if (s_nupFileCache) { @@ -675,7 +675,7 @@ void DownloadManager::_handle_connect() cemuLog_log(LogType::Force, "Failed to request IAS token"); cemu_assert_debug(false); m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(std::string(_("Login failed. Outdated or incomplete online files?")), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Login failed. Outdated or incomplete online files?").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } } @@ -683,16 +683,16 @@ void DownloadManager::_handle_connect() if (!_connect_queryAccountStatusAndServiceURLs()) { m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(std::string(_("Failed to query account status. Invalid account information?")), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Failed to query account status. Invalid account information?").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } // load ticket cache and sync - setStatusMessage(std::string(_("Updating ticket cache")), DLMGR_STATUS_CODE::CONNECTING); + setStatusMessage(_("Updating ticket cache").utf8_string(), DLMGR_STATUS_CODE::CONNECTING); loadTicketCache(); if (!syncTicketCache()) { m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(std::string(_("Failed to request tickets (invalid NNID?)")), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Failed to request tickets (invalid NNID?)").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } searchForIncompleteDownloads(); @@ -716,7 +716,7 @@ void DownloadManager::connect( if (nnidAccountName.empty()) { m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(std::string(_("This account is not linked with an NNID")), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("This account is not linked with an NNID").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } runManager(); @@ -726,7 +726,7 @@ void DownloadManager::connect( { cemuLog_log(LogType::Force, "DLMgr: Invalid password hash"); m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(std::string(_("Failed. Account does not have password set")), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Failed. Account does not have password set").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } m_authInfo.region = region; diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 03496305..74ef6848 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -169,7 +169,7 @@ bool CemuApp::OnInit() "Thank you for testing the in-development build of Cemu for macOS.\n \n" "The macOS port is currently purely experimental and should not be considered stable or ready for issue-free gameplay. " "There are also known issues with degraded performance due to the use of MoltenVk and Rosetta for ARM Macs. We appreciate your patience while we improve Cemu for macOS."); - wxMessageDialog dialog(nullptr, message, "Preview version", wxCENTRE | wxOK | wxICON_WARNING); + wxMessageDialog dialog(nullptr, message, _("Preview version"), wxCENTRE | wxOK | wxICON_WARNING); dialog.SetOKLabel(_("I understand")); dialog.ShowModal(); GetConfig().did_show_macos_disclaimer = true; diff --git a/src/gui/GameProfileWindow.cpp b/src/gui/GameProfileWindow.cpp index 17affc84..f15395e4 100644 --- a/src/gui/GameProfileWindow.cpp +++ b/src/gui/GameProfileWindow.cpp @@ -166,7 +166,7 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) for (int i = 0; i < 8; ++i) { - profile_sizer->Add(new wxStaticText(panel, wxID_ANY, fmt::format("{} {}", _("Controller").utf8_string(), (i + 1))), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + profile_sizer->Add(new wxStaticText(panel, wxID_ANY, formatWxString(_("Controller {}"), i + 1)), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_controller_profile[i] = new wxComboBox(panel, wxID_ANY,"", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_DROPDOWN| wxCB_READONLY); m_controller_profile[i]->SetMinSize(wxSize(250, -1)); @@ -244,7 +244,7 @@ void GameProfileWindow::SetProfileInt(gameProfileIntegerOption_t& option, wxChec void GameProfileWindow::ApplyProfile() { if(m_game_profile.m_gameName) - this->SetTitle(fmt::format("{} - {}", _("Edit game profile").utf8_string(), m_game_profile.m_gameName.value())); + this->SetTitle(_("Edit game profile") + " - " + m_game_profile.m_gameName.value()); // general m_load_libs->SetValue(m_game_profile.m_loadSharedLibraries.value()); diff --git a/src/gui/GameUpdateWindow.cpp b/src/gui/GameUpdateWindow.cpp index e422cbe6..184d5fde 100644 --- a/src/gui/GameUpdateWindow.cpp +++ b/src/gui/GameUpdateWindow.cpp @@ -10,24 +10,24 @@ #include "gui/helpers/wxHelpers.h" #include "wxHelper.h" -std::string _GetTitleIdTypeStr(TitleId titleId) +wxString _GetTitleIdTypeStr(TitleId titleId) { TitleIdParser tip(titleId); switch (tip.GetType()) { case TitleIdParser::TITLE_TYPE::AOC: - return _("DLC").utf8_string(); + return _("DLC"); case TitleIdParser::TITLE_TYPE::BASE_TITLE: - return _("Base game").utf8_string(); + return _("Base game"); case TitleIdParser::TITLE_TYPE::BASE_TITLE_DEMO: - return _("Demo").utf8_string(); + return _("Demo"); case TitleIdParser::TITLE_TYPE::SYSTEM_TITLE: case TitleIdParser::TITLE_TYPE::SYSTEM_OVERLAY_TITLE: - return _("System title").utf8_string(); + return _("System title"); case TitleIdParser::TITLE_TYPE::SYSTEM_DATA: - return _("System data title").utf8_string(); + return _("System data title"); case TitleIdParser::TITLE_TYPE::BASE_TITLE_UPDATE: - return _("Update").utf8_string(); + return _("Update"); default: break; } @@ -57,8 +57,8 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath) if (tip.GetType() != tipOther.GetType()) { - std::string typeStrToInstall = _GetTitleIdTypeStr(m_title_info.GetAppTitleId()); - std::string typeStrCurrentlyInstalled = _GetTitleIdTypeStr(tmp.GetAppTitleId()); + auto typeStrToInstall = _GetTitleIdTypeStr(m_title_info.GetAppTitleId()); + auto typeStrCurrentlyInstalled = _GetTitleIdTypeStr(tmp.GetAppTitleId()); auto wxMsg = _("It seems that there is already a title installed at the target location but it has a different type.\nCurrently installed: \'{}\' Installing: \'{}\'\n\nThis can happen for titles which were installed with very old Cemu versions.\nDo you still want to continue with the installation? It will replace the currently installed title."); wxMessageDialog dialog(this, formatWxString(wxMsg, typeStrCurrentlyInstalled, typeStrToInstall), _("Warning"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION); @@ -131,8 +131,8 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath) const fs::space_info targetSpace = fs::space(ActiveSettings::GetMlcPath()); if (targetSpace.free <= m_required_size) { - auto string = wxStringFormat(_("Not enough space available.\nRequired: {0} MB\nAvailable: {1} MB"), L"%lld %lld", (m_required_size / 1024 / 1024), (targetSpace.free / 1024 / 1024)); - throw std::runtime_error(string); + auto string = formatWxString(_("Not enough space available.\nRequired: {0} MB\nAvailable: {1} MB"), (m_required_size / 1024 / 1024), (targetSpace.free / 1024 / 1024)); + throw std::runtime_error(string.utf8_string()); } return true; diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index bbe1c474..e069c10a 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -2043,17 +2043,17 @@ void GeneralSettings2::OnShowOnlineValidator(wxCommandEvent& event) wxMessageBox(err, _("Online Status"), wxOK | wxCENTRE | wxICON_INFORMATION); } -std::string GeneralSettings2::GetOnlineAccountErrorMessage(OnlineAccountError error) +wxString GeneralSettings2::GetOnlineAccountErrorMessage(OnlineAccountError error) { switch (error) { case OnlineAccountError::kNoAccountId: - return _("AccountId missing (The account is not connected to a NNID)").utf8_string(); + return _("AccountId missing (The account is not connected to a NNID)"); case OnlineAccountError::kNoPasswordCached: - return _("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)").utf8_string(); + return _("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)"); case OnlineAccountError::kPasswordCacheEmpty: - return _("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)").utf8_string(); + return _("AccountPasswordCache is empty (The remember password option on your Wii U must be enabled for this account before dumping it)"); case OnlineAccountError::kNoPrincipalId: - return _("PrincipalId missing").utf8_string(); + return _("PrincipalId missing"); default: return "no error"; } diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index b667faf0..2846af38 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -101,7 +101,7 @@ private: void OnShowOnlineValidator(wxCommandEvent& event); void OnOnlineEnable(wxCommandEvent& event); void OnAccountServiceChanged(wxCommandEvent& event); - std::string GetOnlineAccountErrorMessage(OnlineAccountError error); + static wxString GetOnlineAccountErrorMessage(OnlineAccountError error); // updates cemu audio devices void UpdateAudioDevice(); diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index c03c6fdf..2b618e86 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -445,7 +445,7 @@ void GraphicPacksWindow2::OnTreeSelectionChanged(wxTreeEvent& event) m_graphic_pack_name->SetLabel(wxHelper::FromUtf8(m_gp_name)); if (gp->GetDescription().empty()) - m_gp_description = _("This graphic pack has no description"); + m_gp_description = _("This graphic pack has no description").utf8_string(); else m_gp_description = gp->GetDescription(); @@ -609,7 +609,7 @@ void GraphicPacksWindow2::OnCheckForUpdates(wxCommandEvent& event) // check if enabled graphic packs are lost: const auto& new_packs = GraphicPack2::GetGraphicPacks(); - std::stringstream str; + std::stringstream lost_packs; for(const auto& p : old_packs) { if (!p->IsEnabled()) @@ -622,15 +622,16 @@ void GraphicPacksWindow2::OnCheckForUpdates(wxCommandEvent& event) if(it == new_packs.cend()) { - str << p->GetPath() << std::endl; + lost_packs << p->GetPath() << "\n"; } } - const auto packs = str.str(); - if(!packs.empty()) + const auto lost_packs_str = lost_packs.str(); + if (!lost_packs_str.empty()) { - wxMessageBox(fmt::format("{}\n \n{} \n{}", _("This update removed or renamed the following graphic packs:").utf8_string(), packs, _("You may need to set them up again.").utf8_string()), - _("Warning"), wxOK | wxCENTRE | wxICON_INFORMATION, this); + wxString message = _("This update removed or renamed the following graphic packs:"); + message << "\n \n" << lost_packs_str << " \n" << _("You may need to set them up again."); + wxMessageBox(message, _("Warning"), wxOK | wxCENTRE | wxICON_INFORMATION, this); } } } diff --git a/src/gui/MemorySearcherTool.cpp b/src/gui/MemorySearcherTool.cpp index 5e711dd9..fadebc44 100644 --- a/src/gui/MemorySearcherTool.cpp +++ b/src/gui/MemorySearcherTool.cpp @@ -472,9 +472,7 @@ bool MemorySearcherTool::VerifySearchValue() const void MemorySearcherTool::FillResultList() { - //char text[128]; - //sprintf(text, "Results (%u)", (uint32)m_searchBuffer.size()); - auto text = wxStringFormat(_("Results ({0})"), L"%llu", m_searchBuffer.size()); + auto text = formatWxString(_("Results ({0})"), m_searchBuffer.size()); m_textEntryTable->SetLabelText(text); m_listResults->DeleteAllItems(); diff --git a/src/gui/TitleManager.cpp b/src/gui/TitleManager.cpp index a36b3f74..669a1aaf 100644 --- a/src/gui/TitleManager.cpp +++ b/src/gui/TitleManager.cpp @@ -799,7 +799,7 @@ void TitleManager::SetConnected(bool state) void TitleManager::Callback_ConnectStatusUpdate(std::string statusText, DLMGR_STATUS_CODE statusCode) { TitleManager* titleManager = static_cast(DownloadManager::GetInstance()->getUserData()); - titleManager->SetDownloadStatusText(statusText); + titleManager->SetDownloadStatusText(wxString::FromUTF8(statusText)); if (statusCode == DLMGR_STATUS_CODE::FAILED) { auto* evt = new wxCommandEvent(wxEVT_DL_DISCONNECT_COMPLETE); diff --git a/src/gui/components/wxDownloadManagerList.cpp b/src/gui/components/wxDownloadManagerList.cpp index ca2d7a71..14bf5cbe 100644 --- a/src/gui/components/wxDownloadManagerList.cpp +++ b/src/gui/components/wxDownloadManagerList.cpp @@ -501,16 +501,16 @@ wxString wxDownloadManagerList::GetTitleEntryText(const TitleEntry& entry, ItemC return wxEmptyString; } -std::string wxDownloadManagerList::GetTranslatedTitleEntryType(EntryType type) +wxString wxDownloadManagerList::GetTranslatedTitleEntryType(EntryType type) { switch (type) { case EntryType::Base: - return _("base").utf8_string(); + return _("base"); case EntryType::Update: - return _("update").utf8_string(); + return _("update"); case EntryType::DLC: - return _("DLC").utf8_string(); + return _("DLC"); default: return std::to_string(static_cast>(type)); } diff --git a/src/gui/components/wxDownloadManagerList.h b/src/gui/components/wxDownloadManagerList.h index b0051076..3a6b853a 100644 --- a/src/gui/components/wxDownloadManagerList.h +++ b/src/gui/components/wxDownloadManagerList.h @@ -150,6 +150,6 @@ private: bool SortFunc(std::span sortColumnOrder, const Type_t& v1, const Type_t& v2); static wxString GetTitleEntryText(const TitleEntry& entry, ItemColumn column); - static std::string GetTranslatedTitleEntryType(EntryType entryType); + static wxString GetTranslatedTitleEntryType(EntryType entryType); std::future m_context_worker; }; diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index ebbab044..a64b49bf 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1009,15 +1009,20 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event) if (iosu::pdm::GetStatForGamelist(baseTitleId, playTimeStat)) { // time played - uint32 timePlayed = playTimeStat.numMinutesPlayed * 60; - if (timePlayed == 0) + uint32 minutesPlayed = playTimeStat.numMinutesPlayed; + if (minutesPlayed == 0) SetItem(index, ColumnGameTime, wxEmptyString); - else if (timePlayed < 60) - SetItem(index, ColumnGameTime, fmt::format("{} seconds", timePlayed)); - else if (timePlayed < 60 * 60) - SetItem(index, ColumnGameTime, fmt::format("{} minutes", timePlayed / 60)); + else if (minutesPlayed < 60) + SetItem(index, ColumnGameTime, formatWxString(wxPLURAL("{} minute", "{} minutes", minutesPlayed), minutesPlayed)); else - SetItem(index, ColumnGameTime, fmt::format("{} hours {} minutes", timePlayed / 3600, (timePlayed / 60) % 60)); + { + uint32 hours = minutesPlayed / 60; + uint32 minutes = minutesPlayed % 60; + wxString hoursText = formatWxString(wxPLURAL("{} hour", "{} hours", hours), hours); + wxString minutesText = formatWxString(wxPLURAL("{} minute", "{} minutes", minutes), minutes); + SetItem(index, ColumnGameTime, hoursText + " " + minutesText); + } + // last played if (playTimeStat.last_played.year != 0) { diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index bae986ca..aad46c52 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -963,20 +963,20 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu return wxEmptyString; } -std::string wxTitleManagerList::GetTranslatedTitleEntryType(EntryType type) +wxString wxTitleManagerList::GetTranslatedTitleEntryType(EntryType type) { switch (type) { case EntryType::Base: - return _("base").utf8_string(); + return _("base"); case EntryType::Update: - return _("update").utf8_string(); + return _("update"); case EntryType::Dlc: - return _("DLC").utf8_string(); + return _("DLC"); case EntryType::Save: - return _("save").utf8_string(); + return _("save"); case EntryType::System: - return _("system").utf8_string(); + return _("system"); default: return std::to_string(static_cast>(type)); } diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index 043c78f6..07556068 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -132,7 +132,7 @@ private: bool SortFunc(int column, const Type_t& v1, const Type_t& v2); static wxString GetTitleEntryText(const TitleEntry& entry, ItemColumn column); - static std::string GetTranslatedTitleEntryType(EntryType entryType); + static wxString GetTranslatedTitleEntryType(EntryType entryType); std::future m_context_worker; uint64 m_callbackIdTitleList; diff --git a/src/gui/wxgui.h b/src/gui/wxgui.h index 098449d6..bb4352d1 100644 --- a/src/gui/wxgui.h +++ b/src/gui/wxgui.h @@ -1,5 +1,7 @@ #pragma once +#define wxNO_UNSAFE_WXSTRING_CONV 1 + #include #ifndef WX_PRECOMP #include @@ -36,67 +38,6 @@ extern bool g_inputConfigWindowHasFocus; -// wx helper functions -#include -struct wxStringFormatParameters -{ - sint32 parameter_index; - sint32 parameter_count; - - wchar_t* token_buffer; - wchar_t* substitude_parameter; -}; - -template -wxString wxStringFormat(std::wstring& format, wxStringFormatParameters& parameters) -{ - return format; -} - -template -wxString wxStringFormat(std::wstring& format, wxStringFormatParameters& parameters, T arg, Args... args) -{ - wchar_t tmp[64]; - swprintf(tmp, 64, LR"(\{[%d]+\})", parameters.parameter_index); - const std::wregex placeholder_regex(tmp); - - auto result = format; - while (std::regex_search(result, placeholder_regex)) - { - result = std::regex_replace(result, placeholder_regex, parameters.substitude_parameter, std::regex_constants::format_first_only); - result = wxString::Format(wxString(result), arg); - } - - parameters.parameter_index++; - if (parameters.parameter_index == parameters.parameter_count) - return result; - - parameters.substitude_parameter = std::wcstok(nullptr, LR"( )", ¶meters.token_buffer); - return wxStringFormat(result, parameters, args...); -} - -template -wxString wxStringFormat(const wxString& format, const wchar_t* parameters, T... args) -{ - const auto parameter_count = std::count(parameters, parameters + wcslen(parameters), '%'); - if (parameter_count == 0) - return format; - - const auto copy = wcsdup(parameters); - - wxStringFormatParameters para; - para.substitude_parameter = std::wcstok(copy, LR"( )", ¶.token_buffer); - para.parameter_count = parameter_count; - para.parameter_index = 0; - - auto tmp_string = format.ToStdWstring(); - auto result = wxStringFormat(tmp_string, para, args...); - - free(copy); - - return result; -} - inline bool SendSliderEvent(wxSlider* slider, int new_value) { wxCommandEvent cevent(wxEVT_SLIDER, slider->GetId()); From 524188bb7aa08692a688ea7911f757a298913108 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:28:51 +0200 Subject: [PATCH 008/314] Refactor more GX2 code to use LatteReg.h --- src/Cafe/CafeSystem.cpp | 2 +- src/Cafe/HW/Latte/Core/FetchShader.cpp | 4 +- src/Cafe/HW/Latte/ISA/LatteReg.h | 305 ++++++++++++++++++++- src/Cafe/HW/Latte/ISA/RegDefines.h | 2 - src/Cafe/OS/libs/gx2/GX2.cpp | 7 +- src/Cafe/OS/libs/gx2/GX2.h | 6 - src/Cafe/OS/libs/gx2/GX2_Command.cpp | 4 +- src/Cafe/OS/libs/gx2/GX2_Shader.cpp | 196 ++++++++++++- src/Cafe/OS/libs/gx2/GX2_Shader.h | 58 ++-- src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp | 214 +-------------- 10 files changed, 536 insertions(+), 262 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 8c2344ce..93ced948 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -487,7 +487,7 @@ namespace CafeSystem #if BOOST_OS_WINDOWS std::string GetWindowsNamedVersion(uint32& buildNumber) { - static char productName[256]; + char productName[256]; HKEY hKey; DWORD dwType = REG_SZ; DWORD dwSize = sizeof(productName); diff --git a/src/Cafe/HW/Latte/Core/FetchShader.cpp b/src/Cafe/HW/Latte/Core/FetchShader.cpp index b4beba4e..6c9893f9 100644 --- a/src/Cafe/HW/Latte/Core/FetchShader.cpp +++ b/src/Cafe/HW/Latte/Core/FetchShader.cpp @@ -228,13 +228,13 @@ void _fetchShaderDecompiler_parseInstruction_VTX_SEMANTIC(LatteFetchShader* pars else if (srcSelX == LatteClauseInstruction_VTX::SRC_SEL::SEL_Y) { // use alu divisor 1 - attribGroup->attrib[groupAttribIndex].aluDivisor = (sint32)contextRegister[mmVGT_INSTANCE_STEP_RATE_0 + 0]; + attribGroup->attrib[groupAttribIndex].aluDivisor = (sint32)contextRegister[Latte::REGADDR::VGT_INSTANCE_STEP_RATE_0]; cemu_assert_debug(attribGroup->attrib[groupAttribIndex].aluDivisor > 0); } else if (srcSelX == LatteClauseInstruction_VTX::SRC_SEL::SEL_Z) { // use alu divisor 2 - attribGroup->attrib[groupAttribIndex].aluDivisor = (sint32)contextRegister[mmVGT_INSTANCE_STEP_RATE_0 + 1]; + attribGroup->attrib[groupAttribIndex].aluDivisor = (sint32)contextRegister[Latte::REGADDR::VGT_INSTANCE_STEP_RATE_1]; cemu_assert_debug(attribGroup->attrib[groupAttribIndex].aluDivisor > 0); } } diff --git a/src/Cafe/HW/Latte/ISA/LatteReg.h b/src/Cafe/HW/Latte/ISA/LatteReg.h index e539902f..7f0cf7c9 100644 --- a/src/Cafe/HW/Latte/ISA/LatteReg.h +++ b/src/Cafe/HW/Latte/ISA/LatteReg.h @@ -381,6 +381,9 @@ namespace Latte PA_SC_GENERIC_SCISSOR_TL = 0xA090, PA_SC_GENERIC_SCISSOR_BR = 0xA091, + SQ_VTX_SEMANTIC_0 = 0xA0E0, + SQ_VTX_SEMANTIC_31 = 0xA0FF, + VGT_MULTI_PRIM_IB_RESET_INDX = 0xA103, SX_ALPHA_TEST_CONTROL = 0xA104, CB_BLEND_RED = 0xA105, @@ -398,6 +401,10 @@ namespace Latte PA_CL_VPORT_ZSCALE = 0xA113, PA_CL_VPORT_ZOFFSET = 0xA114, + SPI_VS_OUT_ID_0 = 0xA185, + + SPI_VS_OUT_CONFIG = 0xA1B1, + CB_BLEND0_CONTROL = 0xA1E0, // first CB_BLEND7_CONTROL = 0xA1E7, // last @@ -408,7 +415,23 @@ namespace Latte PA_CL_CLIP_CNTL = 0xA204, PA_SU_SC_MODE_CNTL = 0xA205, PA_CL_VTE_CNTL = 0xA206, - + PA_CL_VS_OUT_CNTL = 0xA207, + + // shader program descriptors: + SQ_PGM_START_PS = 0xA210, + SQ_PGM_RESOURCES_PS = 0xA214, + SQ_PGM_EXPORTS_PS = 0xA215, + SQ_PGM_START_VS = 0xA216, + SQ_PGM_RESOURCES_VS = 0xA21A, + SQ_PGM_START_GS = 0xA21B, + SQ_PGM_RESOURCES_GS = 0xA21F, + SQ_PGM_START_ES = 0xA220, + SQ_PGM_RESOURCES_ES = 0xA224, + SQ_PGM_START_FS = 0xA225, + SQ_PGM_RESOURCES_FS = 0xA229, + + SQ_VTX_SEMANTIC_CLEAR = 0xA238, + PA_SU_POINT_SIZE = 0xA280, PA_SU_POINT_MINMAX = 0xA281, @@ -416,6 +439,35 @@ namespace Latte VGT_DMA_INDEX_TYPE = 0xA29F, // todo - verify offset + VGT_PRIMITIVEID_EN = 0xA2A1, + + VGT_MULTI_PRIM_IB_RESET_EN = 0xA2A5, + + VGT_INSTANCE_STEP_RATE_0 = 0xA2A8, + VGT_INSTANCE_STEP_RATE_1 = 0xA2A9, + + VGT_STRMOUT_BUFFER_SIZE_0 = 0xA2B4, + VGT_STRMOUT_VTX_STRIDE_0 = 0xA2B5, + VGT_STRMOUT_BUFFER_BASE_0 = 0xA2B6, + VGT_STRMOUT_BUFFER_OFFSET_0 = 0xA2B7, + VGT_STRMOUT_BUFFER_SIZE_1 = 0xA2B8, + VGT_STRMOUT_VTX_STRIDE_1 = 0xA2B9, + VGT_STRMOUT_BUFFER_BASE_1 = 0xA2BA, + VGT_STRMOUT_BUFFER_OFFSET_1 = 0xA2BB, + VGT_STRMOUT_BUFFER_SIZE_2 = 0xA2BC, + VGT_STRMOUT_VTX_STRIDE_2 = 0xA2BD, + VGT_STRMOUT_BUFFER_BASE_2 = 0xA2BE, + VGT_STRMOUT_BUFFER_OFFSET_2 = 0xA2BF, + VGT_STRMOUT_BUFFER_SIZE_3 = 0xA2C0, + VGT_STRMOUT_VTX_STRIDE_3 = 0xA2C1, + VGT_STRMOUT_BUFFER_BASE_3 = 0xA2C2, + VGT_STRMOUT_BUFFER_OFFSET_3 = 0xA2C3, + VGT_STRMOUT_BASE_OFFSET_0 = 0xA2C4, + VGT_STRMOUT_BASE_OFFSET_1 = 0xA2C5, + VGT_STRMOUT_BASE_OFFSET_2 = 0xA2C6, + VGT_STRMOUT_BASE_OFFSET_3 = 0xA2C7, + VGT_STRMOUT_BUFFER_EN = 0xA2C8, + // HiZ early stencil test? DB_SRESULTS_COMPARE_STATE0 = 0xA34A, DB_SRESULTS_COMPARE_STATE1 = 0xA34B, @@ -842,6 +894,12 @@ float get_##__regname() const \ LATTE_BITFIELD_BOOL(VTX_W0_FMT, 10); }; + struct LATTE_PA_CL_VS_OUT_CNTL : LATTEREG // 0xA207 + { + LATTE_BITFIELD(CLIP_DIST_ENA_MASK, 0, 8); + LATTE_BITFIELD(CULL_DIST_ENA_MASK, 8, 8); + }; + struct LATTE_PA_SU_POINT_SIZE : LATTEREG // 0xA280 { LATTE_BITFIELD(HEIGHT, 0, 16); @@ -909,6 +967,54 @@ float get_##__regname() const \ LATTE_BITFIELD_FULL_TYPED(INDEX_TYPE, E_INDEX_TYPE); }; + struct LATTE_VGT_PRIMITIVEID_EN : LATTEREG // 0xA2A1 + { + LATTE_BITFIELD_BOOL(PRIMITIVEID_EN, 0); + }; + + struct LATTE_VGT_MULTI_PRIM_IB_RESET_EN : LATTEREG // 0xA2A5 + { + LATTE_BITFIELD_BOOL(RESET_EN, 0); + }; + + struct LATTE_VGT_INSTANCE_STEP_RATE_X : LATTEREG // 0xA2A8-0xA2A9 + { + LATTE_BITFIELD_FULL_TYPED(STEP_RATE, uint32); + }; + + struct LATTE_VGT_STRMOUT_BUFFER_SIZE_X : LATTEREG // 0xA2B4 + index * 4 + { + LATTE_BITFIELD_FULL_TYPED(SIZE, uint32); + }; + + struct LATTE_VGT_STRMOUT_STRIDE_X : LATTEREG // 0xA2B5 + index * 4 + { + LATTE_BITFIELD_FULL_TYPED(STRIDE, uint32); + }; + + struct LATTE_VGT_STRMOUT_BUFFER_BASE_X : LATTEREG // 0xA2B6 + index * 4 + { + LATTE_BITFIELD_FULL_TYPED(BASE, uint32); + }; + + struct LATTE_VGT_STRMOUT_BUFFER_OFFSET_X : LATTEREG // 0xA2B7 + index * 4 + { + LATTE_BITFIELD_FULL_TYPED(BUFFER_OFFSET, uint32); + }; + + struct LATTE_VGT_STRMOUT_BASE_OFFSET_X : LATTEREG // 0xA2C4-0xA2C7 + { + LATTE_BITFIELD_FULL_TYPED(BASE_OFFSET, uint32); + }; + + struct LATTE_VGT_STRMOUT_BUFFER_EN : LATTEREG // 0xA2C8 + { + LATTE_BITFIELD_BOOL(BUFFER_ENABLE_0, 0); + LATTE_BITFIELD_BOOL(BUFFER_ENABLE_1, 1); + LATTE_BITFIELD_BOOL(BUFFER_ENABLE_2, 2); + LATTE_BITFIELD_BOOL(BUFFER_ENABLE_3, 3); + }; + struct LATTE_PA_SU_POLY_OFFSET_CLAMP : LATTEREG // 0xA37F { LATTE_BITFIELD_FLOAT(CLAMP); @@ -934,6 +1040,16 @@ float get_##__regname() const \ LATTE_BITFIELD_FLOAT(OFFSET); }; + struct LATTE_SQ_VTX_SEMANTIC_CLEAR : LATTEREG // 0xA238 + { + LATTE_BITFIELD_FULL_TYPED(CLEAR_MASK, uint32); // probably a bitmask + }; + + struct LATTE_SQ_VTX_SEMANTIC_X : LATTEREG // 0xA0E0 - 0xA0FF + { + LATTE_BITFIELD(SEMANTIC_ID, 0, 8); + }; + struct LATTE_SQ_TEX_RESOURCE_WORD0_N : LATTEREG // 0xE000 + index * 7 { LATTE_BITFIELD_TYPED(DIM, 0, 3, E_DIM); @@ -1154,6 +1270,65 @@ float get_##__regname() const \ LATTE_BITFIELD_TYPED(TYPE, 31, 1, E_SAMPLER_TYPE); }; + struct LATTE_SQ_PGM_START_X : LATTEREG // 0xA210 / 0xA216 / 0xA21B / 0xA220 / 0xA225 + { + LATTE_BITFIELD_FULL_TYPED(PGM_START, uint32); + }; + + struct LATTE_SQ_PGM_RESOURCES_PS : LATTEREG // 0xA214 + { + LATTE_BITFIELD(NUM_GPRS, 0, 8); + LATTE_BITFIELD(NUM_STACK_ENTRIES, 8, 8); + LATTE_BITFIELD_BOOL(DX10_CLAMP, 21); // if true, CLAMP modifier in shaders will return 0 for NaN + LATTE_BITFIELD(FETCH_CACHE_LINES, 24, 3); + LATTE_BITFIELD_BOOL(UNCACHED_FIRST_INST, 28); + LATTE_BITFIELD_BOOL(CLAMP_CONSTS, 31); + }; + + struct LATTE_SQ_PGM_RESOURCES_VS : LATTEREG // 0xA21A + { + LATTE_BITFIELD(NUM_GPRS, 0, 8); + LATTE_BITFIELD(NUM_STACK_ENTRIES, 8, 8); + LATTE_BITFIELD_BOOL(DX10_CLAMP, 21); // if true, CLAMP modifier in shaders will return 0 for NaN + LATTE_BITFIELD(FETCH_CACHE_LINES, 24, 3); + LATTE_BITFIELD_BOOL(UNCACHED_FIRST_INST, 28); + }; + + struct LATTE_SQ_PGM_RESOURCES_GS : LATTEREG // 0xA21F + { + LATTE_BITFIELD(NUM_GPRS, 0, 8); + LATTE_BITFIELD(NUM_STACK_ENTRIES, 8, 8); + LATTE_BITFIELD_BOOL(DX10_CLAMP, 21); // if true, CLAMP modifier in shaders will return 0 for NaN + }; + + struct LATTE_SQ_PGM_RESOURCES_ES : LATTEREG // 0xA224 + { + LATTE_BITFIELD(NUM_GPRS, 0, 8); + LATTE_BITFIELD(NUM_STACK_ENTRIES, 8, 8); + LATTE_BITFIELD_BOOL(DX10_CLAMP, 21); // if true, CLAMP modifier in shaders will return 0 for NaN + }; + + struct LATTE_SQ_PGM_RESOURCES_FS : LATTEREG // 0xA229 + { + LATTE_BITFIELD(NUM_GPRS, 0, 8); + LATTE_BITFIELD(NUM_STACK_ENTRIES, 8, 8); + LATTE_BITFIELD_BOOL(DX10_CLAMP, 21); // if true, CLAMP modifier in shaders will return 0 for NaN + }; + + struct LATTE_SQ_XX_ITEMSIZE : LATTEREG // 0xA227 - 0xA2XX + { + // used by: + // SQ_ESGS_RING_ITEMSIZE + // SQ_GSVS_RING_ITEMSIZE + // SQ_ESTMP_RING_ITEMSIZE + // SQ_GSTMP_RING_ITEMSIZE + // SQ_VSTMP_RING_ITEMSIZE + // SQ_PSTMP_RING_ITEMSIZE + // SQ_FBUF_RING_ITEMSIZE + // SQ_REDUC_RING_ITEMSIZE + LATTE_BITFIELD(ITEMSIZE, 0, 15); + }; + struct LATTE_PA_SU_SC_MODE_CNTL : LATTEREG // 0xA205 { enum class E_FRONTFACE @@ -1185,7 +1360,32 @@ float get_##__regname() const \ LATTE_BITFIELD_BOOL(OFFSET_PARA_ENABLED, 13); // offset enable for lines and points? // additional fields? }; -} + + struct LATTE_SPI_VS_OUT_CONFIG : LATTEREG // 0xA1B1 + { + LATTE_BITFIELD_BOOL(VS_PER_COMPONENT, 0); + LATTE_BITFIELD(VS_EXPORT_COUNT, 1, 5); + LATTE_BITFIELD_BOOL(EXPORTS_FOG, 8); + LATTE_BITFIELD(VS_OUT_FOG_VEC_ADDR, 9, 5); + }; + + struct LATTE_SPI_VS_OUT_ID_N : LATTEREG // 0xA185 - 0xA18E(?) - 0xA1B2 - 0xA1B3 + { + uint8 get_SEMANTIC(sint32 index) + { + cemu_assert_debug(index < 4); + return (uint8)((v >> (index * 8)) & 0xFF); + } + + void set_SEMANTIC(sint32 index, uint8 value) + { + cemu_assert_debug(index < 4); + v &= ~(0xFF << (index * 8)); + v |= (value & 0xFF) << (index * 8); + } + }; + +}; struct _LatteRegisterSetTextureUnit { @@ -1219,6 +1419,16 @@ struct _LatteRegisterSetSamplerBorderColor static_assert(sizeof(_LatteRegisterSetSamplerBorderColor) == 16); +struct _LatteRegisterSetStreamoutBuffer +{ + Latte::LATTE_VGT_STRMOUT_BUFFER_SIZE_X SIZE; + Latte::LATTE_VGT_STRMOUT_STRIDE_X STRIDE; + Latte::LATTE_VGT_STRMOUT_BUFFER_BASE_X BASE; + Latte::LATTE_VGT_STRMOUT_BUFFER_OFFSET_X BUFFER_OFFSET; +}; + +static_assert(sizeof(_LatteRegisterSetStreamoutBuffer) == 16); + struct LatteContextRegister { uint8 padding0[0x08958]; @@ -1235,7 +1445,9 @@ struct LatteContextRegister uint8 padding_2823C[4]; /* +0x28240 */ Latte::LATTE_PA_SC_GENERIC_SCISSOR_TL PA_SC_GENERIC_SCISSOR_TL; /* +0x28244 */ Latte::LATTE_PA_SC_GENERIC_SCISSOR_BR PA_SC_GENERIC_SCISSOR_BR; - uint8 padding_28248[0x2840C - 0x28248]; + uint8 padding_28248[0x28380 - 0x28248]; + /* +0x28380 */ Latte::LATTE_SQ_VTX_SEMANTIC_X SQ_VTX_SEMANTIC_X[32]; + /* +0x28400 */ uint8 padding_28400[0x2840C - 0x28400]; /* +0x2840C */ Latte::LATTE_VGT_MULTI_PRIM_IB_RESET_INDX VGT_MULTI_PRIM_IB_RESET_INDX; /* +0x28410 */ Latte::LATTE_SX_ALPHA_TEST_CONTROL SX_ALPHA_TEST_CONTROL; /* +0x28414 */ Latte::LATTE_CB_BLEND_RED CB_BLEND_RED; @@ -1253,7 +1465,15 @@ struct LatteContextRegister /* +0x2844C */ Latte::LATTE_PA_CL_VPORT_ZSCALE PA_CL_VPORT_ZSCALE; /* +0x28450 */ Latte::LATTE_PA_CL_VPORT_ZOFFSET PA_CL_VPORT_ZOFFSET; - uint8 padding_28450[0x28780 - 0x28454]; + uint8 padding_28450[0x28614 - 0x28454]; + + /* +0x28614 */ Latte::LATTE_SPI_VS_OUT_ID_N LATTE_SPI_VS_OUT_ID_N[10]; + + uint8 padding_2863C[0x286C4 - 0x2863C]; + + /* +0x286C4 */ Latte::LATTE_SPI_VS_OUT_CONFIG SPI_VS_OUT_CONFIG; + + uint8 padding_286C8[0x28780 - 0x286C8]; /* +0x28780 */ Latte::LATTE_CB_BLENDN_CONTROL CB_BLENDN_CONTROL[8]; @@ -1266,9 +1486,44 @@ struct LatteContextRegister /* +0x28810 */ Latte::LATTE_PA_CL_CLIP_CNTL PA_CL_CLIP_CNTL; /* +0x28814 */ Latte::LATTE_PA_SU_SC_MODE_CNTL PA_SU_SC_MODE_CNTL; /* +0x28818 */ Latte::LATTE_PA_CL_VTE_CNTL PA_CL_VTE_CNTL; + /* +0x2881C */ Latte::LATTE_PA_CL_VS_OUT_CNTL PA_CL_VS_OUT_CNTL; - uint8 padding_2881C[0x28A00 - 0x2881C]; + uint8 padding_2881C[0x28840 - 0x28820]; + /* +0x28840 */ Latte::LATTE_SQ_PGM_START_X SQ_PGM_START_PS; + /* +0x28844 */ uint32 ukn28844; // PS size + /* +0x28848 */ uint32 ukn28848; + /* +0x2884C */ uint32 ukn2884C; + /* +0x28850 */ Latte::LATTE_SQ_PGM_RESOURCES_PS SQ_PGM_RESOURCES_PS; + /* +0x28854 */ uint32 ukn28854; // SQ_PGM_EXPORTS_PS + /* +0x28858 */ Latte::LATTE_SQ_PGM_START_X SQ_PGM_START_VS; + /* +0x2885C */ uint32 ukn2885C; // VS size + /* +0x28860 */ uint32 ukn28860; + /* +0x28864 */ uint32 ukn28864; + /* +0x28868 */ Latte::LATTE_SQ_PGM_RESOURCES_VS SQ_PGM_RESOURCES_VS; + /* +0x2886C */ Latte::LATTE_SQ_PGM_START_X SQ_PGM_START_GS; + /* +0x28870 */ uint32 ukn28870; // GS size + /* +0x28874 */ uint32 ukn28874; + /* +0x28878 */ uint32 ukn28878; + /* +0x2887C */ Latte::LATTE_SQ_PGM_RESOURCES_GS SQ_PGM_RESOURCES_GS; + /* +0x28880 */ Latte::LATTE_SQ_PGM_START_X SQ_PGM_START_ES; + /* +0x28884 */ uint32 ukn28884; // ES size + /* +0x28888 */ uint32 ukn28888; + /* +0x2888C */ uint32 ukn2888C; + /* +0x28890 */ Latte::LATTE_SQ_PGM_RESOURCES_ES SQ_PGM_RESOURCES_ES; + /* +0x28894 */ Latte::LATTE_SQ_PGM_START_X SQ_PGM_START_FS; + /* +0x28898 */ uint32 ukn28898; // FS size + /* +0x2889C */ uint32 ukn2889C; + /* +0x288A0 */ uint32 ukn288A0; + /* +0x288A4 */ Latte::LATTE_SQ_PGM_RESOURCES_FS SQ_PGM_RESOURCES_FS; + /* +0x288A8 */ Latte::LATTE_SQ_XX_ITEMSIZE SQ_ESGS_RING_ITEMSIZE; + /* +0x288AC */ Latte::LATTE_SQ_XX_ITEMSIZE SQ_GSVS_RING_ITEMSIZE; + /* +0x288B0 */ Latte::LATTE_SQ_XX_ITEMSIZE SQ_ESTMP_RING_ITEMSIZE; + /* +0x288B4 */ Latte::LATTE_SQ_XX_ITEMSIZE SQ_GSTMP_RING_ITEMSIZE; + /* +0x288B8 */ Latte::LATTE_SQ_XX_ITEMSIZE SQ_VSTMP_RING_ITEMSIZE; + uint8 padding_288BC[0x288E0 - 0x288BC]; + /* +0x288E0 */ Latte::LATTE_SQ_VTX_SEMANTIC_CLEAR SQ_VTX_SEMANTIC_CLEAR; + uint8 padding_288E4[0x28A00 - 0x288E4]; /* +0x28A00 */ Latte::LATTE_PA_SU_POINT_SIZE PA_SU_POINT_SIZE; /* +0x28A04 */ Latte::LATTE_PA_SU_POINT_MINMAX PA_SU_POINT_MINMAX; @@ -1279,8 +1534,24 @@ struct LatteContextRegister uint8 padding_28A44[0x28A7C - 0x28A44]; /* +0x28A7C */ Latte::LATTE_VGT_DMA_INDEX_TYPE VGT_DMA_INDEX_TYPE; + /* +0x28A80 */ uint32 ukn28A80; + /* +0x28A84 */ Latte::LATTE_VGT_PRIMITIVEID_EN VGT_PRIMITIVEID_EN; + /* +0x28A88 */ uint32 ukn28A88; + /* +0x28A8C */ uint32 ukn28A8C; + /* +0x28A90 */ uint32 ukn28A90; + /* +0x28A94 */ Latte::LATTE_VGT_MULTI_PRIM_IB_RESET_EN VGT_MULTI_PRIM_IB_RESET_EN; + /* +0x28A98 */ uint32 ukn28A98; + /* +0x28A9C */ uint32 ukn28A9C; + /* +0x28AA0 */ Latte::LATTE_VGT_INSTANCE_STEP_RATE_X VGT_INSTANCE_STEP_RATE_0; + /* +0x28AA4 */ Latte::LATTE_VGT_INSTANCE_STEP_RATE_X VGT_INSTANCE_STEP_RATE_1; - uint8 padding_28A80[0x28DFC - 0x28A80]; + uint8 padding_28AA8[0x28AD0 - 0x28AA8]; + + /* +0x28AD0 */ _LatteRegisterSetStreamoutBuffer VGT_STRMOUT_BUFFER_X[4]; + /* +0x28B10 */ Latte::LATTE_VGT_STRMOUT_BASE_OFFSET_X VGT_STRMOUT_BASE_OFFSET_X[4]; + /* +0x28B20 */ Latte::LATTE_VGT_STRMOUT_BUFFER_EN VGT_STRMOUT_BUFFER_EN; + + uint8 padding_28B24[0x28DFC - 0x28B24]; /* +0x28DFC */ Latte::LATTE_PA_SU_POLY_OFFSET_CLAMP PA_SU_POLY_OFFSET_CLAMP; /* +0x28E00 */ Latte::LATTE_PA_SU_POLY_OFFSET_FRONT_SCALE PA_SU_POLY_OFFSET_FRONT_SCALE; @@ -1334,6 +1605,13 @@ static_assert(offsetof(LatteContextRegister, CB_TARGET_MASK) == Latte::REGADDR:: static_assert(offsetof(LatteContextRegister, PA_SC_GENERIC_SCISSOR_TL) == Latte::REGADDR::PA_SC_GENERIC_SCISSOR_TL * 4); static_assert(offsetof(LatteContextRegister, PA_SC_GENERIC_SCISSOR_BR) == Latte::REGADDR::PA_SC_GENERIC_SCISSOR_BR * 4); static_assert(offsetof(LatteContextRegister, VGT_MULTI_PRIM_IB_RESET_INDX) == Latte::REGADDR::VGT_MULTI_PRIM_IB_RESET_INDX * 4); +static_assert(offsetof(LatteContextRegister, VGT_PRIMITIVEID_EN) == Latte::REGADDR::VGT_PRIMITIVEID_EN * 4); +static_assert(offsetof(LatteContextRegister, VGT_MULTI_PRIM_IB_RESET_EN) == Latte::REGADDR::VGT_MULTI_PRIM_IB_RESET_EN * 4); +static_assert(offsetof(LatteContextRegister, VGT_INSTANCE_STEP_RATE_0) == Latte::REGADDR::VGT_INSTANCE_STEP_RATE_0 * 4); +static_assert(offsetof(LatteContextRegister, VGT_INSTANCE_STEP_RATE_1) == Latte::REGADDR::VGT_INSTANCE_STEP_RATE_1 * 4); +static_assert(offsetof(LatteContextRegister, VGT_STRMOUT_BUFFER_X) == Latte::REGADDR::VGT_STRMOUT_BUFFER_SIZE_0 * 4); +static_assert(offsetof(LatteContextRegister, VGT_STRMOUT_BASE_OFFSET_X) == Latte::REGADDR::VGT_STRMOUT_BASE_OFFSET_0 * 4); +static_assert(offsetof(LatteContextRegister, VGT_STRMOUT_BUFFER_EN) == Latte::REGADDR::VGT_STRMOUT_BUFFER_EN * 4); static_assert(offsetof(LatteContextRegister, SX_ALPHA_TEST_CONTROL) == Latte::REGADDR::SX_ALPHA_TEST_CONTROL * 4); static_assert(offsetof(LatteContextRegister, DB_STENCILREFMASK) == Latte::REGADDR::DB_STENCILREFMASK * 4); static_assert(offsetof(LatteContextRegister, DB_STENCILREFMASK_BF) == Latte::REGADDR::DB_STENCILREFMASK_BF * 4); @@ -1351,6 +1629,7 @@ static_assert(offsetof(LatteContextRegister, PA_CL_VPORT_ZOFFSET) == Latte::REGA static_assert(offsetof(LatteContextRegister, PA_CL_CLIP_CNTL) == Latte::REGADDR::PA_CL_CLIP_CNTL * 4); static_assert(offsetof(LatteContextRegister, PA_SU_SC_MODE_CNTL) == Latte::REGADDR::PA_SU_SC_MODE_CNTL * 4); static_assert(offsetof(LatteContextRegister, PA_CL_VTE_CNTL) == Latte::REGADDR::PA_CL_VTE_CNTL * 4); +static_assert(offsetof(LatteContextRegister, PA_CL_VS_OUT_CNTL) == Latte::REGADDR::PA_CL_VS_OUT_CNTL * 4); static_assert(offsetof(LatteContextRegister, PA_SU_POINT_SIZE) == Latte::REGADDR::PA_SU_POINT_SIZE * 4); static_assert(offsetof(LatteContextRegister, PA_SU_POINT_MINMAX) == Latte::REGADDR::PA_SU_POINT_MINMAX * 4); static_assert(offsetof(LatteContextRegister, CB_BLENDN_CONTROL) == Latte::REGADDR::CB_BLEND0_CONTROL * 4); @@ -1363,7 +1642,21 @@ static_assert(offsetof(LatteContextRegister, PA_SU_POLY_OFFSET_FRONT_SCALE) == L static_assert(offsetof(LatteContextRegister, PA_SU_POLY_OFFSET_FRONT_OFFSET) == Latte::REGADDR::PA_SU_POLY_OFFSET_FRONT_OFFSET * 4); static_assert(offsetof(LatteContextRegister, PA_SU_POLY_OFFSET_BACK_SCALE) == Latte::REGADDR::PA_SU_POLY_OFFSET_BACK_SCALE * 4); static_assert(offsetof(LatteContextRegister, PA_SU_POLY_OFFSET_BACK_OFFSET) == Latte::REGADDR::PA_SU_POLY_OFFSET_BACK_OFFSET * 4); +static_assert(offsetof(LatteContextRegister, SQ_VTX_SEMANTIC_X) == Latte::REGADDR::SQ_VTX_SEMANTIC_0 * 4); +static_assert(offsetof(LatteContextRegister, SQ_VTX_SEMANTIC_CLEAR) == Latte::REGADDR::SQ_VTX_SEMANTIC_CLEAR * 4); static_assert(offsetof(LatteContextRegister, SQ_TEX_START_PS) == Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS * 4); static_assert(offsetof(LatteContextRegister, SQ_TEX_START_VS) == Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS * 4); static_assert(offsetof(LatteContextRegister, SQ_TEX_START_GS) == Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS * 4); static_assert(offsetof(LatteContextRegister, SQ_TEX_SAMPLER) == Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_START_PS) == Latte::REGADDR::SQ_PGM_START_PS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_RESOURCES_PS) == Latte::REGADDR::SQ_PGM_RESOURCES_PS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_START_VS) == Latte::REGADDR::SQ_PGM_START_VS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_RESOURCES_VS) == Latte::REGADDR::SQ_PGM_RESOURCES_VS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_START_FS) == Latte::REGADDR::SQ_PGM_START_FS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_RESOURCES_FS) == Latte::REGADDR::SQ_PGM_RESOURCES_FS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_START_ES) == Latte::REGADDR::SQ_PGM_START_ES * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_RESOURCES_ES) == Latte::REGADDR::SQ_PGM_RESOURCES_ES * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_START_GS) == Latte::REGADDR::SQ_PGM_START_GS * 4); +static_assert(offsetof(LatteContextRegister, SQ_PGM_RESOURCES_GS) == Latte::REGADDR::SQ_PGM_RESOURCES_GS * 4); +static_assert(offsetof(LatteContextRegister, SPI_VS_OUT_CONFIG) == Latte::REGADDR::SPI_VS_OUT_CONFIG * 4); +static_assert(offsetof(LatteContextRegister, LATTE_SPI_VS_OUT_ID_N) == Latte::REGADDR::SPI_VS_OUT_ID_0 * 4); \ No newline at end of file diff --git a/src/Cafe/HW/Latte/ISA/RegDefines.h b/src/Cafe/HW/Latte/ISA/RegDefines.h index d28739c0..b99c2126 100644 --- a/src/Cafe/HW/Latte/ISA/RegDefines.h +++ b/src/Cafe/HW/Latte/ISA/RegDefines.h @@ -50,8 +50,6 @@ #define mmVGT_PRIMITIVEID_EN 0xA2A1 #define mmVGT_VTX_CNT_EN 0xA2AE #define mmVGT_REUSE_OFF 0xA2AD -#define mmVGT_INSTANCE_STEP_RATE_0 0xA2A8 -#define mmVGT_INSTANCE_STEP_RATE_1 0xA2A9 #define mmVGT_MAX_VTX_INDX 0xA100 #define mmVGT_MIN_VTX_INDX 0xA101 #define mmVGT_INDX_OFFSET 0xA102 diff --git a/src/Cafe/OS/libs/gx2/GX2.cpp b/src/Cafe/OS/libs/gx2/GX2.cpp index 5a1f5520..8c3fbc64 100644 --- a/src/Cafe/OS/libs/gx2/GX2.cpp +++ b/src/Cafe/OS/libs/gx2/GX2.cpp @@ -396,12 +396,7 @@ void gx2_load() osLib_addFunction("gx2", "GX2GetCurrentScanBuffer", gx2Export_GX2GetCurrentScanBuffer); // shader stuff - osLib_addFunction("gx2", "GX2GetVertexShaderGPRs", gx2Export_GX2GetVertexShaderGPRs); - osLib_addFunction("gx2", "GX2GetVertexShaderStackEntries", gx2Export_GX2GetVertexShaderStackEntries); - osLib_addFunction("gx2", "GX2GetPixelShaderGPRs", gx2Export_GX2GetPixelShaderGPRs); - osLib_addFunction("gx2", "GX2GetPixelShaderStackEntries", gx2Export_GX2GetPixelShaderStackEntries); - osLib_addFunction("gx2", "GX2SetFetchShader", gx2Export_GX2SetFetchShader); - osLib_addFunction("gx2", "GX2SetVertexShader", gx2Export_GX2SetVertexShader); + //osLib_addFunction("gx2", "GX2SetVertexShader", gx2Export_GX2SetVertexShader); osLib_addFunction("gx2", "GX2SetPixelShader", gx2Export_GX2SetPixelShader); osLib_addFunction("gx2", "GX2SetGeometryShader", gx2Export_GX2SetGeometryShader); osLib_addFunction("gx2", "GX2SetComputeShader", gx2Export_GX2SetComputeShader); diff --git a/src/Cafe/OS/libs/gx2/GX2.h b/src/Cafe/OS/libs/gx2/GX2.h index c9607ee4..b8a3f919 100644 --- a/src/Cafe/OS/libs/gx2/GX2.h +++ b/src/Cafe/OS/libs/gx2/GX2.h @@ -20,12 +20,6 @@ void gx2_load(); // shader -void gx2Export_GX2SetFetchShader(PPCInterpreter_t* hCPU); -void gx2Export_GX2GetVertexShaderGPRs(PPCInterpreter_t* hCPU); -void gx2Export_GX2GetVertexShaderStackEntries(PPCInterpreter_t* hCPU); -void gx2Export_GX2GetPixelShaderGPRs(PPCInterpreter_t* hCPU); -void gx2Export_GX2GetPixelShaderStackEntries(PPCInterpreter_t* hCPU); -void gx2Export_GX2SetVertexShader(PPCInterpreter_t* hCPU); void gx2Export_GX2SetPixelShader(PPCInterpreter_t* hCPU); void gx2Export_GX2SetGeometryShader(PPCInterpreter_t* hCPU); void gx2Export_GX2SetComputeShader(PPCInterpreter_t* hCPU); diff --git a/src/Cafe/OS/libs/gx2/GX2_Command.cpp b/src/Cafe/OS/libs/gx2/GX2_Command.cpp index 8d584190..6da19741 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Command.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Command.cpp @@ -263,7 +263,7 @@ namespace GX2 if (patchType == GX2_PATCH_TYPE::VERTEX_SHADER) { - GX2VertexShader_t* vertexShader = (GX2VertexShader_t*)obj; + GX2VertexShader* vertexShader = (GX2VertexShader*)obj; displayData[patchOffset / 4 + 2] = memory_virtualToPhysical(vertexShader->GetProgramAddr()) >> 8; } else if (patchType == GX2_PATCH_TYPE::PIXEL_SHADER) @@ -273,7 +273,7 @@ namespace GX2 } else if (patchType == GX2_PATCH_TYPE::FETCH_SHADER) { - GX2FetchShader_t* fetchShader = (GX2FetchShader_t*)obj; + GX2FetchShader* fetchShader = (GX2FetchShader*)obj; displayData[patchOffset / 4 + 2] = memory_virtualToPhysical(fetchShader->GetProgramAddr()) >> 8; } else if (patchType == GX2_PATCH_TYPE::GEOMETRY_COPY_SHADER) diff --git a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp index c63688eb..ad17dc49 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp @@ -3,6 +3,7 @@ #include "GX2_Shader.h" #include "Cafe/HW/Latte/Core/LatteConst.h" #include "Cafe/HW/Latte/Core/LattePM4.h" +#include "Cafe/HW/Latte/ISA/LatteReg.h" #include "Cafe/HW/Latte/ISA/LatteInstructions.h" uint32 memory_getVirtualOffsetFromPointer(void* ptr); // remove once we updated everything to MEMPTR @@ -70,9 +71,9 @@ namespace GX2 static_assert(sizeof(betype) == 0x4); // calculate size of CF program subpart, includes alignment padding for clause instructions - size_t _calcFetchShaderCFCodeSize(uint32 attributeCount, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + size_t _calcFetchShaderCFCodeSize(uint32 attributeCount, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { - cemu_assert_debug(fetchShaderType == GX2FetchShader_t::FetchShaderType::NO_TESSELATION); + cemu_assert_debug(fetchShaderType == GX2FetchShader::FetchShaderType::NO_TESSELATION); cemu_assert_debug(tessellationMode == 0); uint32 numCFInstructions = ((attributeCount + 15) / 16) + 1; // one VTX clause can have up to 16 instructions + final CF instruction is RETURN size_t cfSize = numCFInstructions * 8; @@ -80,16 +81,16 @@ namespace GX2 return cfSize; } - size_t _calcFetchShaderClauseCodeSize(uint32 attributeCount, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + size_t _calcFetchShaderClauseCodeSize(uint32 attributeCount, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { - cemu_assert_debug(fetchShaderType == GX2FetchShader_t::FetchShaderType::NO_TESSELATION); + cemu_assert_debug(fetchShaderType == GX2FetchShader::FetchShaderType::NO_TESSELATION); cemu_assert_debug(tessellationMode == 0); uint32 numClauseInstructions = attributeCount; size_t clauseSize = numClauseInstructions * 16; return clauseSize; } - void _writeFetchShaderCFCode(void* programBufferOut, uint32 attributeCount, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + void _writeFetchShaderCFCode(void* programBufferOut, uint32 attributeCount, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { LatteCFInstruction* cfInstructionWriter = (LatteCFInstruction*)programBufferOut; uint32 attributeIndex = 0; @@ -111,7 +112,7 @@ namespace GX2 memcpy(cfInstructionWriter, &returnInstr, sizeof(LatteCFInstruction)); } - void _writeFetchShaderVTXCode(GX2FetchShader_t* fetchShader, void* programOut, uint32 attributeCount, GX2AttribDescription* attributeDescription, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + void _writeFetchShaderVTXCode(GX2FetchShader* fetchShader, void* programOut, uint32 attributeCount, GX2AttribDescription* attributeDescription, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { uint8* writePtr = (uint8*)programOut; // one instruction per attribute (hardcoded into _writeFetchShaderCFCode) @@ -151,7 +152,7 @@ namespace GX2 bool divisorFound = false; for (uint32 i = 0; i < numDivisors; i++) { - if (_swapEndianU32(fetchShader->divisors[i]) == attrAluDivisor) + if (fetchShader->divisors[i] == attrAluDivisor) { srcSelX = i != 0 ? 2 : 1; divisorFound = true; @@ -168,7 +169,7 @@ namespace GX2 else { srcSelX = numDivisors != 0 ? 2 : 1; - fetchShader->divisors[numDivisors] = _swapEndianU32(attrAluDivisor); + fetchShader->divisors[numDivisors] = attrAluDivisor; numDivisors++; fetchShader->divisorCount = _swapEndianU32(numDivisors); } @@ -213,9 +214,9 @@ namespace GX2 } } - uint32 GX2CalcFetchShaderSizeEx(uint32 attributeCount, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + uint32 GX2CalcFetchShaderSizeEx(uint32 attributeCount, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { - cemu_assert_debug(fetchShaderType == GX2FetchShader_t::FetchShaderType::NO_TESSELATION); // other types are todo + cemu_assert_debug(fetchShaderType == GX2FetchShader::FetchShaderType::NO_TESSELATION); // other types are todo cemu_assert_debug(tessellationMode == 0); // other modes are todo uint32 finalSize = @@ -225,9 +226,9 @@ namespace GX2 return finalSize; } - void GX2InitFetchShaderEx(GX2FetchShader_t* fetchShader, void* programBufferOut, uint32 attributeCount, GX2AttribDescription* attributeDescription, GX2FetchShader_t::FetchShaderType fetchShaderType, uint32 tessellationMode) + void GX2InitFetchShaderEx(GX2FetchShader* fetchShader, void* programBufferOut, uint32 attributeCount, GX2AttribDescription* attributeDescription, GX2FetchShader::FetchShaderType fetchShaderType, uint32 tessellationMode) { - cemu_assert_debug(fetchShaderType == GX2FetchShader_t::FetchShaderType::NO_TESSELATION); + cemu_assert_debug(fetchShaderType == GX2FetchShader::FetchShaderType::NO_TESSELATION); cemu_assert_debug(tessellationMode == 0); /* @@ -238,7 +239,7 @@ namespace GX2 [CLAUSES] */ - memset(fetchShader, 0x00, sizeof(GX2FetchShader_t)); + memset(fetchShader, 0x00, sizeof(GX2FetchShader)); fetchShader->attribCount = _swapEndianU32(attributeCount); fetchShader->shaderPtr = (MPTR)_swapEndianU32(memory_getVirtualOffsetFromPointer(programBufferOut)); @@ -251,14 +252,181 @@ namespace GX2 shaderOutput += _calcFetchShaderClauseCodeSize(attributeCount, fetchShaderType, tessellationMode); uint32 shaderSize = (uint32)(shaderOutput - shaderStart); - cemu_assert_debug(shaderSize == GX2CalcFetchShaderSizeEx(attributeCount, GX2FetchShader_t::FetchShaderType::NO_TESSELATION, tessellationMode)); + cemu_assert_debug(shaderSize == GX2CalcFetchShaderSizeEx(attributeCount, GX2FetchShader::FetchShaderType::NO_TESSELATION, tessellationMode)); fetchShader->shaderSize = _swapEndianU32((uint32)(shaderOutput - shaderStart)); + + fetchShader->reg_SQ_PGM_RESOURCES_FS = Latte::LATTE_SQ_PGM_RESOURCES_FS().set_NUM_GPRS(2); // todo - affected by tesselation params? + } + + uint32 GX2GetVertexShaderGPRs(GX2VertexShader* vertexShader) + { + return vertexShader->regs.SQ_PGM_RESOURCES_VS.value().get_NUM_GPRS(); + } + + uint32 GX2GetVertexShaderStackEntries(GX2VertexShader* vertexShader) + { + return vertexShader->regs.SQ_PGM_RESOURCES_VS.value().get_NUM_STACK_ENTRIES(); + } + + uint32 GX2GetPixelShaderGPRs(GX2PixelShader_t* pixelShader) + { + return _swapEndianU32(pixelShader->regs[0])&0xFF; + } + + uint32 GX2GetPixelShaderStackEntries(GX2PixelShader_t* pixelShader) + { + return (_swapEndianU32(pixelShader->regs[0]>>8))&0xFF; + } + + void GX2SetFetchShader(GX2FetchShader* fetchShaderPtr) + { + GX2ReserveCmdSpace(11); + cemu_assert_debug((_swapEndianU32(fetchShaderPtr->shaderPtr) & 0xFF) == 0); + + gx2WriteGather_submit( + // setup fetch shader + pm4HeaderType3(IT_SET_CONTEXT_REG, 1+5), + Latte::REGADDR::SQ_PGM_START_FS-0xA000, + _swapEndianU32(fetchShaderPtr->shaderPtr)>>8, + _swapEndianU32(fetchShaderPtr->shaderSize)>>3, + 0x10000, // ukn (ring buffer size?) + 0x10000, // ukn (ring buffer size?) + fetchShaderPtr->reg_SQ_PGM_RESOURCES_FS, + + // write instance step + pm4HeaderType3(IT_SET_CONTEXT_REG, 1+2), + Latte::REGADDR::VGT_INSTANCE_STEP_RATE_0-0xA000, + fetchShaderPtr->divisors[0], + fetchShaderPtr->divisors[1]); + } + + void GX2SetVertexShader(GX2VertexShader* vertexShader) + { + GX2ReserveCmdSpace(100); + + MPTR shaderProgramAddr; + uint32 shaderProgramSize; + if (vertexShader->shaderPtr) + { + // without R API + shaderProgramAddr = vertexShader->shaderPtr.GetMPTR(); + shaderProgramSize = vertexShader->shaderSize; + } + else + { + shaderProgramAddr = vertexShader->rBuffer.GetVirtualAddr(); + shaderProgramSize = vertexShader->rBuffer.GetSize(); + } + + cemu_assert_debug(shaderProgramAddr != 0); + cemu_assert_debug(shaderProgramSize != 0); + + if (vertexShader->shaderMode == GX2_SHADER_MODE::GEOMETRY_SHADER) + { + // in geometry shader mode the vertex shader is written to _ES register and almost all vs control registers are set by GX2SetGeometryShader + gx2WriteGather_submit( + pm4HeaderType3(IT_SET_CONTEXT_REG, 6), + Latte::REGADDR::SQ_PGM_START_ES-0xA000, + memory_virtualToPhysical(shaderProgramAddr)>>8, + shaderProgramSize>>3, + 0x100000, + 0x100000, + vertexShader->regs.SQ_PGM_RESOURCES_VS); // SQ_PGM_RESOURCES_VS/SQ_PGM_RESOURCES_ES + } + else + { + gx2WriteGather_submit( + /* vertex shader program */ + pm4HeaderType3(IT_SET_CONTEXT_REG, 6), + Latte::REGADDR::SQ_PGM_START_VS-0xA000, + memory_virtualToPhysical(shaderProgramAddr)>>8, // physical address + shaderProgramSize>>3, + 0x100000, + 0x100000, + vertexShader->regs.SQ_PGM_RESOURCES_VS, // SQ_PGM_RESOURCES_VS/ES + /* primitive id enable */ + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::VGT_PRIMITIVEID_EN-0xA000, + vertexShader->regs.VGT_PRIMITIVEID_EN, + /* output config */ + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::SPI_VS_OUT_CONFIG-0xA000, + vertexShader->regs.SPI_VS_OUT_CONFIG, + /* PA_CL_VS_OUT_CNTL */ + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::PA_CL_VS_OUT_CNTL-0xA000, + vertexShader->regs.PA_CL_VS_OUT_CNTL + ); + + cemu_assert_debug(vertexShader->regs.SPI_VS_OUT_CONFIG.value().get_VS_PER_COMPONENT() == false); // not handled on the GPU side + + uint32 numOutputIds = vertexShader->regs.vsOutIdTableSize; + numOutputIds = std::min(numOutputIds, 0xA); + gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+numOutputIds)); + gx2WriteGather_submitU32AsBE(Latte::REGADDR::SPI_VS_OUT_ID_0-0xA000); + for(uint32 i=0; iregs.LATTE_SPI_VS_OUT_ID_N[i].value().getRawValue()); + + // todo: SQ_PGM_CF_OFFSET_VS + // todo: VGT_STRMOUT_BUFFER_EN + // stream out + if (vertexShader->usesStreamOut != 0) + { + // stride 0 + gx2WriteGather_submit(pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::VGT_STRMOUT_VTX_STRIDE_0-0xA000, + vertexShader->streamOutVertexStride[0]>>2, + // stride 1 + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::VGT_STRMOUT_VTX_STRIDE_1-0xA000, + vertexShader->streamOutVertexStride[1]>>2, + // stride 2 + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::VGT_STRMOUT_VTX_STRIDE_2-0xA000, + vertexShader->streamOutVertexStride[2]>>2, + // stride 3 + pm4HeaderType3(IT_SET_CONTEXT_REG, 2), + Latte::REGADDR::VGT_STRMOUT_VTX_STRIDE_3-0xA000, + vertexShader->streamOutVertexStride[3]>>2); + } + } + // update semantic table + uint32 vsSemanticTableSize = vertexShader->regs.semanticTableSize; + if (vsSemanticTableSize > 0) + { + gx2WriteGather_submit( + pm4HeaderType3(IT_SET_CONTEXT_REG, 1+1), + Latte::REGADDR::SQ_VTX_SEMANTIC_CLEAR-0xA000, + 0xFFFFFFFF); + if (vsSemanticTableSize == 0) + { + gx2WriteGather_submit( + pm4HeaderType3(IT_SET_CONTEXT_REG, 1+1), + Latte::REGADDR::SQ_VTX_SEMANTIC_0-0xA000, + 0xFFFFFFFF); + } + else + { + uint32* vsSemanticTable = (uint32*)vertexShader->regs.SQ_VTX_SEMANTIC_N; + vsSemanticTableSize = std::min(vsSemanticTableSize, 32); + gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+vsSemanticTableSize)); + gx2WriteGather_submitU32AsBE(Latte::REGADDR::SQ_VTX_SEMANTIC_0-0xA000); + gx2WriteGather_submitU32AsLEArray(vsSemanticTable, vsSemanticTableSize); + } + } } void GX2ShaderInit() { cafeExportRegister("gx2", GX2CalcFetchShaderSizeEx, LogType::GX2); cafeExportRegister("gx2", GX2InitFetchShaderEx, LogType::GX2); + + cafeExportRegister("gx2", GX2GetVertexShaderGPRs, LogType::GX2); + cafeExportRegister("gx2", GX2GetVertexShaderStackEntries, LogType::GX2); + cafeExportRegister("gx2", GX2GetPixelShaderGPRs, LogType::GX2); + cafeExportRegister("gx2", GX2GetPixelShaderStackEntries, LogType::GX2); + cafeExportRegister("gx2", GX2SetFetchShader, LogType::GX2); + cafeExportRegister("gx2", GX2SetVertexShader, LogType::GX2); } } \ No newline at end of file diff --git a/src/Cafe/OS/libs/gx2/GX2_Shader.h b/src/Cafe/OS/libs/gx2/GX2_Shader.h index 1d1c79cc..960bdf95 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Shader.h +++ b/src/Cafe/OS/libs/gx2/GX2_Shader.h @@ -2,7 +2,7 @@ #include "Cafe/HW/Latte/ISA/LatteReg.h" #include "GX2_Streamout.h" -struct GX2FetchShader_t +struct GX2FetchShader { enum class FetchShaderType : uint32 { @@ -10,12 +10,12 @@ struct GX2FetchShader_t }; /* +0x00 */ betype fetchShaderType; - /* +0x04 */ uint32 _regs[1]; + /* +0x04 */ betype reg_SQ_PGM_RESOURCES_FS; /* +0x08 */ uint32 shaderSize; /* +0x0C */ MPTR shaderPtr; /* +0x10 */ uint32 attribCount; /* +0x14 */ uint32 divisorCount; - /* +0x18 */ uint32 divisors[2]; + /* +0x18 */ uint32be divisors[2]; MPTR GetProgramAddr() const { @@ -23,8 +23,8 @@ struct GX2FetchShader_t } }; -static_assert(sizeof(GX2FetchShader_t) == 0x20); -static_assert(sizeof(betype) == 4); +static_assert(sizeof(GX2FetchShader) == 0x20); +static_assert(sizeof(betype) == 4); namespace GX2 { @@ -32,19 +32,43 @@ namespace GX2 void GX2ShaderInit(); } -// code below still needs to be modernized (use betype, enum classes) +// code below still needs to be modernized (use betype, enum classes, move to namespace) +// deprecated, use GX2_SHADER_MODE enum class instead #define GX2_SHADER_MODE_UNIFORM_REGISTER 0 #define GX2_SHADER_MODE_UNIFORM_BLOCK 1 #define GX2_SHADER_MODE_GEOMETRY_SHADER 2 #define GX2_SHADER_MODE_COMPUTE_SHADER 3 -struct GX2VertexShader_t +enum class GX2_SHADER_MODE : uint32 { - /* +0x000 */ uint32 regs[52]; - /* +0x0D0 */ uint32 shaderSize; - /* +0x0D4 */ MPTR shaderPtr; - /* +0x0D8 */ uint32 shaderMode; // GX2_SHADER_MODE_* + UNIFORM_REGISTER = 0, + UNIFORM_BLOCK = 1, + GEOMETRY_SHADER = 2, + COMPUTE_SHADER = 3, +}; + +struct GX2VertexShader +{ + /* +0x000 */ + struct + { + /* +0x00 */ betype SQ_PGM_RESOURCES_VS; // compatible with SQ_PGM_RESOURCES_ES + /* +0x04 */ betype VGT_PRIMITIVEID_EN; + /* +0x08 */ betype SPI_VS_OUT_CONFIG; + /* +0x0C */ uint32be vsOutIdTableSize; + /* +0x10 */ betype LATTE_SPI_VS_OUT_ID_N[10]; + /* +0x38 */ betype PA_CL_VS_OUT_CNTL; + /* +0x3C */ uint32be uknReg15; // ? + /* +0x40 */ uint32be semanticTableSize; + /* +0x44 */ betype SQ_VTX_SEMANTIC_N[32]; + /* +0xC4 */ uint32be uknReg49; // ? + /* +0xC8 */ uint32be uknReg50; // vgt_vertex_reuse_block_cntl + /* +0xCC */ uint32be uknReg51; // vgt_hos_reuse_depth + }regs; + /* +0x0D0 */ uint32be shaderSize; + /* +0x0D4 */ MEMPTR shaderPtr; + /* +0x0D8 */ betype shaderMode; /* +0x0DC */ uint32 uniformBlockCount; /* +0x0E0 */ MPTR uniformBlockInfo; /* +0x0E4 */ uint32 uniformVarCount; @@ -57,20 +81,20 @@ struct GX2VertexShader_t /* +0x100 */ MPTR samplerInfo; /* +0x104 */ uint32 attribCount; /* +0x108 */ MPTR attribInfo; - /* +0x10C */ uint32 ringItemsize; // for GS - /* +0x110 */ uint32 usesStreamOut; - /* +0x114 */ uint32 streamOutVertexStride[GX2_MAX_STREAMOUT_BUFFERS]; + /* +0x10C */ uint32be ringItemsize; // for GS + /* +0x110 */ uint32be usesStreamOut; + /* +0x114 */ uint32be streamOutVertexStride[GX2_MAX_STREAMOUT_BUFFERS]; /* +0x124 */ GX2RBuffer rBuffer; MPTR GetProgramAddr() const { - if (_swapEndianU32(this->shaderPtr) != MPTR_NULL) - return _swapEndianU32(this->shaderPtr); + if (this->shaderPtr) + return this->shaderPtr.GetMPTR(); return this->rBuffer.GetVirtualAddr(); } }; -static_assert(sizeof(GX2VertexShader_t) == 0x134); +static_assert(sizeof(GX2VertexShader) == 0x134); typedef struct _GX2PixelShader { diff --git a/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp b/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp index 845292fe..1cb61a7e 100644 --- a/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp @@ -8,204 +8,6 @@ #include "GX2.h" #include "GX2_Shader.h" -void gx2Export_GX2SetFetchShader(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2SetFetchShader(0x{:08x})", hCPU->gpr[3]); - GX2ReserveCmdSpace(11); - GX2FetchShader_t* fetchShaderPtr = (GX2FetchShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - cemu_assert_debug((_swapEndianU32(fetchShaderPtr->shaderPtr) & 0xFF) == 0); - - gx2WriteGather_submit( - // setup fetch shader - pm4HeaderType3(IT_SET_CONTEXT_REG, 1+5), - mmSQ_PGM_START_FS-0xA000, - _swapEndianU32(fetchShaderPtr->shaderPtr)>>8, // pointer divided by 256 - _swapEndianU32(fetchShaderPtr->shaderSize)>>3, // size divided by 8 - 0x10000, // ukn (ring buffer size?) - 0x10000, // ukn (ring buffer size?) - *(uint32be*)&(fetchShaderPtr->_regs[0]), - - // write instance step - pm4HeaderType3(IT_SET_CONTEXT_REG, 1+2), - mmVGT_INSTANCE_STEP_RATE_0-0xA000, - *(uint32be*)&(fetchShaderPtr->divisors[0]), - *(uint32be*)&(fetchShaderPtr->divisors[1])); - - osLib_returnFromFunction(hCPU, 0); -} - -void gx2Export_GX2GetVertexShaderGPRs(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2GetVertexShaderGPRs(0x{:08x})", hCPU->gpr[3]); - GX2VertexShader_t* vertexShader = (GX2VertexShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - uint8 numGPRs = _swapEndianU32(vertexShader->regs[0])&0xFF; - osLib_returnFromFunction(hCPU, numGPRs); -} - -void gx2Export_GX2GetVertexShaderStackEntries(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2GetVertexShaderStackEntries(0x{:08x})", hCPU->gpr[3]); - GX2VertexShader_t* vertexShader = (GX2VertexShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - uint8 stackEntries = (_swapEndianU32(vertexShader->regs[0])>>8)&0xFF; - osLib_returnFromFunction(hCPU, stackEntries); -} - -void gx2Export_GX2GetPixelShaderGPRs(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2GetPixelShaderGPRs(0x{:08x})", hCPU->gpr[3]); - GX2PixelShader_t* pixelShader = (GX2PixelShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - uint8 stackEntries = (_swapEndianU32(pixelShader->regs[0]))&0xFF; - osLib_returnFromFunction(hCPU, stackEntries); -} - -void gx2Export_GX2GetPixelShaderStackEntries(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2GetPixelShaderStackEntries(0x{:08x})", hCPU->gpr[3]); - GX2PixelShader_t* pixelShader = (GX2PixelShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - uint8 numGPRs = (_swapEndianU32(pixelShader->regs[0]>>8))&0xFF; - osLib_returnFromFunction(hCPU, numGPRs); -} - -void gx2Export_GX2SetVertexShader(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2SetVertexShader(0x{:08x})", hCPU->gpr[3]); - GX2ReserveCmdSpace(100); - - GX2VertexShader_t* vertexShader = (GX2VertexShader_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - - MPTR shaderProgramAddr; - uint32 shaderProgramSize; - - if( _swapEndianU32(vertexShader->shaderPtr) != MPTR_NULL ) - { - // without R API - shaderProgramAddr = _swapEndianU32(vertexShader->shaderPtr); - shaderProgramSize = _swapEndianU32(vertexShader->shaderSize); - } - else - { - shaderProgramAddr = vertexShader->rBuffer.GetVirtualAddr(); - shaderProgramSize = vertexShader->rBuffer.GetSize(); - } - - cemu_assert_debug(shaderProgramAddr != 0); - cemu_assert_debug(shaderProgramSize != 0); - - if( _swapEndianU32(vertexShader->shaderMode) == GX2_SHADER_MODE_GEOMETRY_SHADER ) - { - // in geometry shader mode the vertex shader is written to _ES register and almost all vs control registers are set by GX2SetGeometryShader - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 6)); - gx2WriteGather_submitU32AsBE(mmSQ_PGM_START_ES-0xA000); - gx2WriteGather_submitU32AsBE(memory_virtualToPhysical(shaderProgramAddr)>>8); - gx2WriteGather_submitU32AsBE(shaderProgramSize>>3); - gx2WriteGather_submitU32AsBE(0x100000); - gx2WriteGather_submitU32AsBE(0x100000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->regs[0])); // unknown - } - else - { - gx2WriteGather_submit( - /* vertex shader program */ - pm4HeaderType3(IT_SET_CONTEXT_REG, 6), - mmSQ_PGM_START_VS-0xA000, - memory_virtualToPhysical(shaderProgramAddr)>>8, // physical address - shaderProgramSize>>3, // size - 0x100000, - 0x100000, - _swapEndianU32(vertexShader->regs[0]), // unknown - /* primitive id enable */ - pm4HeaderType3(IT_SET_CONTEXT_REG, 2), - mmVGT_PRIMITIVEID_EN-0xA000, - _swapEndianU32(vertexShader->regs[1]), - /* output config */ - pm4HeaderType3(IT_SET_CONTEXT_REG, 2), - mmSPI_VS_OUT_CONFIG-0xA000, - _swapEndianU32(vertexShader->regs[2])); - - if( (_swapEndianU32(vertexShader->regs[2]) & 1) != 0 ) - debugBreakpoint(); // per-component flag? - - // ukn - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 2)); - gx2WriteGather_submitU32AsBE(mmPA_CL_VS_OUT_CNTL-0xA000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->regs[14])); - - uint32 numOutputIds = _swapEndianU32(vertexShader->regs[3]); - numOutputIds = std::min(numOutputIds, 0xA); - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+numOutputIds)); - gx2WriteGather_submitU32AsBE(mmSPI_VS_OUT_ID_0-0xA000); - for(uint32 i=0; iregs[4+i])); - } - - /* - VS _regs[]: - 0 ? - 1 mmVGT_PRIMITIVEID_EN (?) - 2 mmSPI_VS_OUT_CONFIG - 3 Number of used SPI_VS_OUT_ID_* entries - 4 - 13 SPI_VS_OUT_ID_0 - SPI_VS_OUT_ID_9 - 14 pa_cl_vs_out_cntl - ... - 17 - ?? semantic table entry (input) - - ... - 50 vgt_vertex_reuse_block_cntl - 51 vgt_hos_reuse_depth - */ - - // todo: mmSQ_PGM_CF_OFFSET_VS - // todo: mmVGT_STRMOUT_BUFFER_EN - // stream out - if( _swapEndianU32(vertexShader->usesStreamOut) != 0 ) - { - // stride 0 - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 2)); - gx2WriteGather_submitU32AsBE(mmVGT_STRMOUT_VTX_STRIDE_0-0xA000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->streamOutVertexStride[0])>>2); - // stride 1 - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 2)); - gx2WriteGather_submitU32AsBE(mmVGT_STRMOUT_VTX_STRIDE_1-0xA000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->streamOutVertexStride[1])>>2); - // stride 2 - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 2)); - gx2WriteGather_submitU32AsBE(mmVGT_STRMOUT_VTX_STRIDE_2-0xA000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->streamOutVertexStride[2])>>2); - // stride 3 - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 2)); - gx2WriteGather_submitU32AsBE(mmVGT_STRMOUT_VTX_STRIDE_3-0xA000); - gx2WriteGather_submitU32AsBE(_swapEndianU32(vertexShader->streamOutVertexStride[3])>>2); - } - } - // update semantic table - uint32 vsSemanticTableSize = _swapEndianU32(vertexShader->regs[0x40/4]); - if( vsSemanticTableSize > 0 ) - { - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+1)); - gx2WriteGather_submitU32AsBE(mmSQ_VTX_SEMANTIC_CLEAR-0xA000); - gx2WriteGather_submitU32AsBE(0xFFFFFFFF); - if( vsSemanticTableSize == 0 ) - { - // todo: Figure out how this is done on real SW/HW (some vertex shaders don't have a semantic table) - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+1)); - gx2WriteGather_submitU32AsBE(mmSQ_VTX_SEMANTIC_0-0xA000); - gx2WriteGather_submitU32AsBE(0xFFFFFFFF); - } - else - { - uint32* vsSemanticTable = vertexShader->regs+(0x44/4); - vsSemanticTableSize = std::min(vsSemanticTableSize, 0x20); - gx2WriteGather_submitU32AsBE(pm4HeaderType3(IT_SET_CONTEXT_REG, 1+vsSemanticTableSize)); - gx2WriteGather_submitU32AsBE(mmSQ_VTX_SEMANTIC_0-0xA000); - for(uint32 i=0; igpr[3]); @@ -415,14 +217,14 @@ void gx2Export_GX2SetGeometryShader(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); } -struct GX2ComputeShader_t +struct GX2ComputeShader { /* +0x00 */ uint32be regs[12]; /* +0x30 */ uint32be programSize; /* +0x34 */ uint32be programPtr; - /* +0x38 */ uint32 ukn38; - /* +0x3C */ uint32 ukn3C; - /* +0x40 */ uint32 ukn40[8]; + /* +0x38 */ uint32be ukn38; + /* +0x3C */ uint32be ukn3C; + /* +0x40 */ uint32be ukn40[8]; /* +0x60 */ uint32be workgroupSizeX; /* +0x64 */ uint32be workgroupSizeY; /* +0x68 */ uint32be workgroupSizeZ; @@ -431,13 +233,13 @@ struct GX2ComputeShader_t /* +0x74 */ GX2RBuffer rBuffer; }; -static_assert(offsetof(GX2ComputeShader_t, programSize) == 0x30); -static_assert(offsetof(GX2ComputeShader_t, workgroupSizeX) == 0x60); -static_assert(offsetof(GX2ComputeShader_t, rBuffer) == 0x74); +static_assert(offsetof(GX2ComputeShader, programSize) == 0x30); +static_assert(offsetof(GX2ComputeShader, workgroupSizeX) == 0x60); +static_assert(offsetof(GX2ComputeShader, rBuffer) == 0x74); void gx2Export_GX2SetComputeShader(PPCInterpreter_t* hCPU) { - ppcDefineParamTypePtr(computeShader, GX2ComputeShader_t, 0); + ppcDefineParamTypePtr(computeShader, GX2ComputeShader, 0); cemuLog_log(LogType::GX2, "GX2SetComputeShader(0x{:08x})", hCPU->gpr[3]); MPTR shaderPtr; From 62889adfde94710f280868c1b7dc4be4cc8cc229 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Sep 2023 07:04:28 +0200 Subject: [PATCH 009/314] Use memory barriers in Linux fiber implementation Prevent compilers from caching TLS variables across swapcontext calls --- src/util/Fiber/FiberUnix.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/Fiber/FiberUnix.cpp b/src/util/Fiber/FiberUnix.cpp index 7d3bf05a..0d527069 100644 --- a/src/util/Fiber/FiberUnix.cpp +++ b/src/util/Fiber/FiberUnix.cpp @@ -1,5 +1,6 @@ #include "Fiber.h" #include +#include thread_local Fiber* sCurrentFiber{}; @@ -44,7 +45,9 @@ void Fiber::Switch(Fiber& targetFiber) { Fiber* leavingFiber = sCurrentFiber; sCurrentFiber = &targetFiber; + std::atomic_thread_fence(std::memory_order_seq_cst); swapcontext((ucontext_t*)(leavingFiber->m_implData), (ucontext_t*)(targetFiber.m_implData)); + std::atomic_thread_fence(std::memory_order_seq_cst); } void* Fiber::GetFiberPrivateData() From c168cf536a3ee1d6aabcddf41062136843f84e1b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 9 Sep 2023 14:09:40 +0200 Subject: [PATCH 010/314] Vulkan: Dont immediately crash on bad pipeline cache --- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 937e3266..7987b20e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2119,18 +2119,14 @@ void VulkanRenderer::CreatePipelineCache() if (fs::exists(dir)) { const auto filename = dir / fmt::format("{:016x}.bin", CafeSystem::GetForegroundTitleId()); - auto file = std::ifstream(filename, std::ios::in | std::ios::binary | std::ios::ate); if (file.is_open()) { const size_t fileSize = file.tellg(); file.seekg(0, std::ifstream::beg); - cacheData.resize(fileSize); file.read((char*)cacheData.data(), cacheData.size()); file.close(); - - cemuLog_logDebug(LogType::Force, "pipeline cache loaded"); } } @@ -2140,7 +2136,16 @@ void VulkanRenderer::CreatePipelineCache() createInfo.pInitialData = cacheData.data(); VkResult result = vkCreatePipelineCache(m_logicalDevice, &createInfo, nullptr, &m_pipeline_cache); if (result != VK_SUCCESS) - UnrecoverableError(fmt::format("Failed to create pipeline cache: {}", result).c_str()); + { + cemuLog_log(LogType::Force, "Failed to open Vulkan pipeline cache: {}", result); + // unable to load the existing cache, start with an empty cache instead + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; + createInfo.initialDataSize = 0; + createInfo.pInitialData = nullptr; + result = vkCreatePipelineCache(m_logicalDevice, &createInfo, nullptr, &m_pipeline_cache); + if (result != VK_SUCCESS) + UnrecoverableError(fmt::format("Failed to create new Vulkan pipeline cache: {}", result).c_str()); + } size_t cache_size = 0; vkGetPipelineCacheData(m_logicalDevice, m_pipeline_cache, &cache_size, nullptr); From f04c7575d7aa206489668a8493cac993e41c51ae Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 9 Sep 2023 14:33:31 +0200 Subject: [PATCH 011/314] coreinit: Handle non-existing modules in OSDynLoad_Acquire Fixes Togabito crashing on boot coreinit: Handle non-existing modules in OSDynLoad_Acquire --- src/Cafe/CafeSystem.cpp | 2 +- .../HW/Espresso/Recompiler/PPCRecompiler.cpp | 2 + src/Cafe/OS/RPL/rpl.cpp | 152 ++++++++++-------- src/Cafe/OS/RPL/rpl.h | 5 +- src/Cafe/OS/RPL/rpl_structs.h | 8 +- .../OS/libs/coreinit/coreinit_DynLoad.cpp | 6 +- src/Cafe/OS/libs/swkbd/swkbd.cpp | 2 - 7 files changed, 102 insertions(+), 75 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 93ced948..dd761f6e 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -165,7 +165,7 @@ void LoadMainExecutable() { // RPX RPLLoader_AddDependency(_pathToExecutable.c_str()); - applicationRPX = rpl_loadFromMem(rpxData, rpxSize, (char*)_pathToExecutable.c_str()); + applicationRPX = RPLLoader_LoadFromMemory(rpxData, rpxSize, (char*)_pathToExecutable.c_str()); if (!applicationRPX) { wxMessageBox(_("Failed to run this title because the executable is damaged")); diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp index 6b830563..f4d063fa 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp @@ -325,6 +325,8 @@ void PPCRecompiler_thread() PPCRecompilerState.recompilerSpinlock.unlock(); PPCRecompiler_recompileAtAddress(enterAddress); + if(s_recompilerThreadStopSignal) + return; } } } diff --git a/src/Cafe/OS/RPL/rpl.cpp b/src/Cafe/OS/RPL/rpl.cpp index c9683683..48c7acc4 100644 --- a/src/Cafe/OS/RPL/rpl.cpp +++ b/src/Cafe/OS/RPL/rpl.cpp @@ -39,20 +39,22 @@ VHeap rplLoaderHeap_workarea(nullptr, MEMORY_RPLLOADER_AREA_SIZE); PPCCodeHeap rplLoaderHeap_lowerAreaCodeMem2(nullptr, MEMORY_CODE_TRAMPOLINE_AREA_SIZE); PPCCodeHeap rplLoaderHeap_codeArea2(nullptr, MEMORY_CODEAREA_SIZE); -bool rplLoader_applicationHasMemoryControl = false; -uint32 rplLoader_maxCodeAddress = 0; // highest used code address - ChunkedFlatAllocator<64 * 1024> g_heapTrampolineArea; -std::vector rplDependencyList = std::vector(); +std::vector rplDependencyList; RPLModule* rplModuleList[256]; sint32 rplModuleCount = 0; -uint32 _currentTLSModuleIndex = 1; // value 0 is reserved - +bool rplLoader_applicationHasMemoryControl = false; +uint32 rplLoader_maxCodeAddress = 0; // highest used code address +uint32 rplLoader_currentTLSModuleIndex = 1; // value 0 is reserved +uint32 rplLoader_currentHandleCounter = 0x00001000; +sint16 rplLoader_currentTlsModuleIndex = 0x0001; +RPLModule* rplLoader_mainModule = nullptr; uint32 rplLoader_sdataAddr = MPTR_NULL; // r13 uint32 rplLoader_sdata2Addr = MPTR_NULL; // r2 +uint32 rplLoader_currentDataAllocatorAddr = 0x10000000; std::map g_map_callableExports; @@ -110,8 +112,6 @@ MPTR RPLLoader_AllocateCodeSpace(uint32 size, uint32 alignment) return codeAddr; } -uint32 rpl3_currentDataAllocatorAddr = 0x10000000; - uint32 RPLLoader_AllocateDataSpace(RPLModule* rpl, uint32 size, uint32 alignment) { if (rplLoader_applicationHasMemoryControl) @@ -121,9 +121,9 @@ uint32 RPLLoader_AllocateDataSpace(RPLModule* rpl, uint32 size, uint32 alignment PPCCoreCallback(rpl->funcAlloc.value(), size, alignment, memPtr.GetPointer()); return (uint32)*(memPtr.GetPointer()); } - rpl3_currentDataAllocatorAddr = (rpl3_currentDataAllocatorAddr + alignment - 1)&~(alignment-1); - uint32 mem = rpl3_currentDataAllocatorAddr; - rpl3_currentDataAllocatorAddr += size; + rplLoader_currentDataAllocatorAddr = (rplLoader_currentDataAllocatorAddr + alignment - 1) & ~(alignment - 1); + uint32 mem = rplLoader_currentDataAllocatorAddr; + rplLoader_currentDataAllocatorAddr += size; return mem; } @@ -134,7 +134,7 @@ void RPLLoader_FreeData(RPLModule* rpl, void* ptr) uint32 RPLLoader_GetDataAllocatorAddr() { - return (rpl3_currentDataAllocatorAddr + 0xFFF)&(~0xFFF); + return (rplLoader_currentDataAllocatorAddr + 0xFFF) & (~0xFFF); } uint32 RPLLoader_GetMaxCodeOffset() @@ -1385,12 +1385,11 @@ bool RPLLoader_HandleRelocs(RPLModule* rplLoaderContext, std::span 0); - sint32 startIndex = inputLen - 1; + cemu_assert(!input.empty()); + size_t startIndex = input.size() - 1; while (startIndex > 0) { if (input[startIndex] == '/') @@ -1401,23 +1400,20 @@ void _RPLLoader_ExtractModuleNameFromPath(char* output, const char* input) startIndex--; } // cut off after '.' - sint32 endIndex = startIndex; - while (endIndex <= inputLen) + size_t endIndex = startIndex; + while (endIndex < input.size()) { if (input[endIndex] == '.') break; endIndex++; } - sint32 nameLen = endIndex - startIndex; + size_t nameLen = endIndex - startIndex; cemu_assert(nameLen != 0); - nameLen = std::min(nameLen, RPL_MODULE_NAME_LENGTH-1); - memcpy(output, input + startIndex, nameLen); + nameLen = std::min(nameLen, RPL_MODULE_NAME_LENGTH-1); + memcpy(output, input.data() + startIndex, nameLen); output[nameLen] = '\0'; // convert to lower case - for (sint32 i = 0; i < nameLen; i++) - { - output[i] = _ansiToLower(output[i]); - } + std::for_each(output, output + nameLen, [](char& c) {c = _ansiToLower(c);}); } void RPLLoader_InitState() @@ -1432,27 +1428,6 @@ void RPLLoader_InitState() RPLLoader_ResetState(); } -void RPLLoader_ResetState() -{ - // unload all RPL modules - while (rplModuleCount > 0) - RPLLoader_UnloadModule(rplModuleList[0]); - rplDependencyList.clear(); - // unload all remaining symbols - rplSymbolStorage_unloadAll(); - // free all code imports - g_heapTrampolineArea.releaseAll(); - list_mappedFunctionImports.clear(); - g_map_callableExports.clear(); - - rplLoader_applicationHasMemoryControl = false; - rplLoader_maxCodeAddress = 0; - rpl3_currentDataAllocatorAddr = 0x10000000; - _currentTLSModuleIndex = 1; - rplLoader_sdataAddr = MPTR_NULL; - rplLoader_sdata2Addr = MPTR_NULL; -} - void RPLLoader_BeginCemuhookCRC(RPLModule* rpl) { // calculate some values required for CRC @@ -1610,7 +1585,7 @@ void RPLLoader_InitModuleAllocator(RPLModule* rpl) } // map rpl into memory, but do not resolve relocs and imports yet -RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name) +RPLModule* RPLLoader_LoadFromMemory(uint8* rplData, sint32 size, char* name) { char moduleName[RPL_MODULE_NAME_LENGTH]; _RPLLoader_ExtractModuleNameFromPath(moduleName, name); @@ -1699,7 +1674,7 @@ RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name) return rpl; } -void RPLLoader_flushMemory(RPLModule* rpl) +void RPLLoader_FlushMemory(RPLModule* rpl) { // invalidate recompiler cache PPCRecompiler_invalidateRange(rpl->regionMappingBase_text.GetMPTR(), rpl->regionMappingBase_text.GetMPTR() + rpl->regionSize_text); @@ -1755,7 +1730,7 @@ void RPLLoader_LinkSingleModule(RPLModule* rplLoaderContext, bool resolveOnlyExp else RPLLoader_HandleRelocs(rplLoaderContext, sharedImportTracking, 0); - RPLLoader_flushMemory(rplLoaderContext); + RPLLoader_FlushMemory(rplLoaderContext); } void RPLLoader_LoadSectionDebugSymbols(RPLModule* rplLoaderContext, rplSectionEntryNew_t* section, int symtabSectionIndex) @@ -1919,8 +1894,24 @@ uint32 RPLLoader_GetModuleEntrypoint(RPLModule* rplLoaderContext) return rplLoaderContext->entrypoint; } -uint32 rplLoader_currentHandleCounter = 0x00001000; -sint16 rplLoader_currentTlsModuleIndex = 0x0001; +// takes a module name without extension, returns true if the RPL module is a known Cafe OS module +bool RPLLoader_IsKnownCafeOSModule(std::string_view name) +{ + static std::unordered_set s_systemModules556 = { + "avm","camera","coreinit","dc","dmae","drmapp","erreula", + "gx2","h264","lzma920","mic","nfc","nio_prof","nlibcurl", + "nlibnss","nlibnss2","nn_ac","nn_acp","nn_act","nn_aoc","nn_boss", + "nn_ccr","nn_cmpt","nn_dlp","nn_ec","nn_fp","nn_hai","nn_hpad", + "nn_idbe","nn_ndm","nn_nets2","nn_nfp","nn_nim","nn_olv","nn_pdm", + "nn_save","nn_sl","nn_spm","nn_temp","nn_uds","nn_vctl","nsysccr", + "nsyshid","nsyskbd","nsysnet","nsysuhs","nsysuvd","ntag","padscore", + "proc_ui","sndcore2","snduser2","snd_core","snd_user","swkbd","sysapp", + "tcl","tve","uac","uac_rpl","usb_mic","uvc","uvd","vpad","vpadbase", + "zlib125"}; + std::string nameLower{name}; + std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), _ansiToLower); + return s_systemModules556.contains(nameLower); +} // increment reference counter for module void RPLLoader_AddDependency(const char* name) @@ -1946,18 +1937,18 @@ void RPLLoader_AddDependency(const char* name) { if (strcmp(moduleName, dep->modulename) == 0) { - // entry already exists, increment reference counter dep->referenceCount++; return; } } // add new entry - rplDependency_t* newDependency = new rplDependency_t(); + RPLDependency* newDependency = new RPLDependency(); strcpy(newDependency->modulename, moduleName); newDependency->referenceCount = 1; newDependency->coreinitHandle = rplLoader_currentHandleCounter; newDependency->tlsModuleIndex = rplLoader_currentTlsModuleIndex; - rplLoader_currentTlsModuleIndex++; + newDependency->isCafeOSModule = RPLLoader_IsKnownCafeOSModule(moduleName); + rplLoader_currentTlsModuleIndex++; // todo - delay handle and tls allocation until the module is actually loaded. It may not exist rplLoader_currentHandleCounter++; if (rplLoader_currentTlsModuleIndex == 0x7FFF) cemuLog_log(LogType::Force, "RPLLoader: Exhausted TLS module indices pool"); @@ -2005,6 +1996,18 @@ void RPLLoader_RemoveDependency(const char* name) } } +bool RPLLoader_HasDependency(std::string_view name) +{ + char moduleName[RPL_MODULE_NAME_LENGTH]; + _RPLLoader_ExtractModuleNameFromPath(moduleName, name); + for (const auto& dep : rplDependencyList) + { + if (strcmp(moduleName, dep->modulename) == 0) + return true; + } + return false; +} + // decrement reference counter for dependency by module handle void RPLLoader_RemoveDependency(uint32 handle) { @@ -2030,6 +2033,9 @@ uint32 RPLLoader_GetHandleByModuleName(const char* name) { if (strcmp(moduleName, dep->modulename) == 0) { + cemu_assert_debug(dep->loadAttempted); + if (!dep->isCafeOSModule && !dep->rplLoaderContext) + return RPL_INVALID_HANDLE; // module not found return dep->coreinitHandle; } } @@ -2062,21 +2068,21 @@ bool RPLLoader_GetTLSDataByTLSIndex(sint16 tlsModuleIndex, uint8** tlsData, sint return true; } -bool RPLLoader_LoadFromVirtualPath(rplDependency_t* dependency, char* filePath) +bool RPLLoader_LoadFromVirtualPath(RPLDependency* dependency, char* filePath) { uint32 rplSize = 0; uint8* rplData = fsc_extractFile(filePath, &rplSize); if (rplData) { cemuLog_logDebug(LogType::Force, "Loading: {}", filePath); - dependency->rplLoaderContext = rpl_loadFromMem(rplData, rplSize, filePath); + dependency->rplLoaderContext = RPLLoader_LoadFromMemory(rplData, rplSize, filePath); free(rplData); return true; } return false; } -void RPLLoader_LoadDependency(rplDependency_t* dependency) +void RPLLoader_LoadDependency(RPLDependency* dependency) { dependency->loadAttempted = true; // check if module is already loaded @@ -2084,11 +2090,9 @@ void RPLLoader_LoadDependency(rplDependency_t* dependency) { if(!boost::iequals(rplModuleList[i]->moduleName2, dependency->modulename)) continue; - // already loaded dependency->rplLoaderContext = rplModuleList[i]; return; } - // attempt to load rpl from various locations char filePath[RPL_MODULE_PATH_LENGTH]; // check if path is absolute if (dependency->filepath[0] == '/') @@ -2097,7 +2101,7 @@ void RPLLoader_LoadDependency(rplDependency_t* dependency) RPLLoader_LoadFromVirtualPath(dependency, filePath); return; } - // attempt to load rpl from internal folder + // attempt to load rpl from code directory of current title strcpy_s(filePath, "/internal/current_title/code/"); strcat_s(filePath, dependency->filepath); // except if it is blacklisted @@ -2119,7 +2123,8 @@ void RPLLoader_LoadDependency(rplDependency_t* dependency) if (fileData) { cemuLog_log(LogType::Force, "Loading RPL: /cafeLibs/{}", dependency->filepath); - dependency->rplLoaderContext = rpl_loadFromMem(fileData->data(), fileData->size(), dependency->filepath); + dependency->rplLoaderContext = RPLLoader_LoadFromMemory(fileData->data(), fileData->size(), + dependency->filepath); return; } } @@ -2168,8 +2173,6 @@ void RPLLoader_UpdateDependencies() RPLLoader_Link(); } -RPLModule* rplLoader_mainModule = nullptr; - void RPLLoader_SetMainModule(RPLModule* rplLoaderContext) { rplLoaderContext->entrypointCalled = true; @@ -2250,7 +2253,7 @@ uint32 RPLLoader_FindModuleOrHLEExport(uint32 moduleHandle, bool isData, const c { // find dependency from handle RPLModule* rplLoaderContext = nullptr; - rplDependency_t* dependency = nullptr; + RPLDependency* dependency = nullptr; for (auto& dep : rplDependencyList) { if (dep->coreinitHandle == moduleHandle) @@ -2379,3 +2382,24 @@ void RPLLoader_ReleaseCodeCaveMem(MEMPTR addr) { heapCodeCaveArea.free(addr.GetMPTR()); } + +void RPLLoader_ResetState() +{ + // unload all RPL modules + while (rplModuleCount > 0) + RPLLoader_UnloadModule(rplModuleList[0]); + rplDependencyList.clear(); + // unload all remaining symbols + rplSymbolStorage_unloadAll(); + // free all code imports + g_heapTrampolineArea.releaseAll(); + list_mappedFunctionImports.clear(); + g_map_callableExports.clear(); + rplLoader_applicationHasMemoryControl = false; + rplLoader_maxCodeAddress = 0; + rplLoader_currentDataAllocatorAddr = 0x10000000; + rplLoader_currentTLSModuleIndex = 1; + rplLoader_sdataAddr = MPTR_NULL; + rplLoader_sdata2Addr = MPTR_NULL; + rplLoader_mainModule = nullptr; +} diff --git a/src/Cafe/OS/RPL/rpl.h b/src/Cafe/OS/RPL/rpl.h index ced7e83c..1075ee58 100644 --- a/src/Cafe/OS/RPL/rpl.h +++ b/src/Cafe/OS/RPL/rpl.h @@ -2,7 +2,7 @@ struct RPLModule; -#define RPL_INVALID_HANDLE (0xFFFFFFFF) +#define RPL_INVALID_HANDLE 0xFFFFFFFF void RPLLoader_InitState(); void RPLLoader_ResetState(); @@ -14,7 +14,7 @@ MPTR RPLLoader_AllocateCodeSpace(uint32 size, uint32 alignment); uint32 RPLLoader_GetMaxCodeOffset(); uint32 RPLLoader_GetDataAllocatorAddr(); -RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name); +RPLModule* RPLLoader_LoadFromMemory(uint8* rplData, sint32 size, char* name); uint32 rpl_mapHLEImport(RPLModule* rplLoaderContext, const char* rplName, const char* funcName, bool functionMustExist); void RPLLoader_Link(); @@ -29,6 +29,7 @@ void RPLLoader_NotifyControlPassedToApplication(); void RPLLoader_AddDependency(const char* name); void RPLLoader_RemoveDependency(uint32 handle); +bool RPLLoader_HasDependency(std::string_view name); void RPLLoader_UpdateDependencies(); uint32 RPLLoader_GetHandleByModuleName(const char* name); diff --git a/src/Cafe/OS/RPL/rpl_structs.h b/src/Cafe/OS/RPL/rpl_structs.h index 71be960c..998ec8d7 100644 --- a/src/Cafe/OS/RPL/rpl_structs.h +++ b/src/Cafe/OS/RPL/rpl_structs.h @@ -225,17 +225,17 @@ struct RPLModule }; -typedef struct +struct RPLDependency { char modulename[RPL_MODULE_NAME_LENGTH]; char filepath[RPL_MODULE_PATH_LENGTH]; bool loadAttempted; - //bool isHLEModule; // determined to be a HLE module - RPLModule* rplLoaderContext; // context of loaded module + bool isCafeOSModule; // name is a known Cafe OS RPL + RPLModule* rplLoaderContext; // context of loaded module, can be nullptr for HLE COS modules sint32 referenceCount; uint32 coreinitHandle; // fake handle for coreinit sint16 tlsModuleIndex; // tls module index assigned to this dependency -}rplDependency_t; +}; RPLModule* RPLLoader_FindModuleByCodeAddr(uint32 addr); RPLModule* RPLLoader_FindModuleByDataAddr(uint32 addr); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.cpp b/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.cpp index c8b05124..546501b6 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.cpp @@ -86,8 +86,7 @@ namespace coreinit } // search for loaded modules with matching name uint32 rplHandle = RPLLoader_GetHandleByModuleName(libName); - - if (rplHandle == RPL_INVALID_HANDLE) + if (rplHandle == RPL_INVALID_HANDLE && !RPLLoader_HasDependency(libName)) { RPLLoader_AddDependency(libName); RPLLoader_UpdateDependencies(); @@ -100,7 +99,10 @@ namespace coreinit else *moduleHandleOut = rplHandle; if (rplHandle == RPL_INVALID_HANDLE) + { + cemuLog_logDebug(LogType::Force, "OSDynLoad_Acquire() failed to load module '{}'", libName); return 0xFFFCFFE9; // module not found + } return 0; } diff --git a/src/Cafe/OS/libs/swkbd/swkbd.cpp b/src/Cafe/OS/libs/swkbd/swkbd.cpp index 6cc88874..d30992b0 100644 --- a/src/Cafe/OS/libs/swkbd/swkbd.cpp +++ b/src/Cafe/OS/libs/swkbd/swkbd.cpp @@ -276,7 +276,6 @@ void swkbdExport_SwkbdDisappearKeyboard(PPCInterpreter_t* hCPU) void swkbdExport_SwkbdGetInputFormString(PPCInterpreter_t* hCPU) { - debug_printf("SwkbdGetInputFormString__3RplFv LR: %08x\n", hCPU->spr.LR); for(sint32 i=0; iformStringLength; i++) { swkbdInternalState->formStringBufferBE[i] = _swapEndianU16(swkbdInternalState->formStringBuffer[i]); @@ -287,7 +286,6 @@ void swkbdExport_SwkbdGetInputFormString(PPCInterpreter_t* hCPU) void swkbdExport_SwkbdIsDecideOkButton(PPCInterpreter_t* hCPU) { - debug_printf("SwkbdIsDecideOkButton__3RplFPb LR: %08x\n", hCPU->spr.LR); if (swkbdInternalState->decideButtonWasPressed) osLib_returnFromFunction(hCPU, 1); else From fda5ec269741ceb6b25628e365714055363f2a17 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Sep 2023 08:13:53 +0200 Subject: [PATCH 012/314] ih264d: Small optimizations and experiments with multi-threading Using the multi-threaded decoder doesn't seem to be worth it but at least we have a way to enable it now --- dependencies/ih264d/CMakeLists.txt | 6 +++ dependencies/ih264d/common/ithread.c | 50 +++++++++++++++---- .../ih264d/common/x86/ih264_platform_macros.h | 4 +- src/Cafe/OS/libs/h264_avc/H264Dec.cpp | 16 +++++- 4 files changed, 61 insertions(+), 15 deletions(-) diff --git a/dependencies/ih264d/CMakeLists.txt b/dependencies/ih264d/CMakeLists.txt index 212cf346..d97d6dda 100644 --- a/dependencies/ih264d/CMakeLists.txt +++ b/dependencies/ih264d/CMakeLists.txt @@ -183,4 +183,10 @@ endif() if(MSVC) set_property(TARGET ih264d PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + +# tune settings for slightly better performance +target_compile_options(ih264d PRIVATE $<$:/Oi>) # enable intrinsic functions +target_compile_options(ih264d PRIVATE $<$:/Ot>) # favor speed +target_compile_options(ih264d PRIVATE "/GS-") # disable runtime checks + endif() diff --git a/dependencies/ih264d/common/ithread.c b/dependencies/ih264d/common/ithread.c index d710e323..2c25bdb0 100644 --- a/dependencies/ih264d/common/ithread.c +++ b/dependencies/ih264d/common/ithread.c @@ -85,28 +85,59 @@ UWORD32 ithread_get_mutex_lock_size(void) return sizeof(CRITICAL_SECTION); } +struct _ithread_launch_param +{ + void (*startFunc)(void* argument); + void* argument; +}; + +DWORD WINAPI _ithread_WinThreadStartRoutine(LPVOID lpThreadParameter) +{ + struct _ithread_launch_param* param = (struct _ithread_launch_param*)lpThreadParameter; + typedef void *(*ThreadStartRoutineType)(void *); + ThreadStartRoutineType pfnThreadRoutine = (ThreadStartRoutineType)param->startFunc; + void* arg = param->argument; + free(param); + pfnThreadRoutine(arg); + return 0; +} + WORD32 ithread_create(void* thread_handle, void* attribute, void* strt, void* argument) { - //UNUSED(attribute); - //return pthread_create((pthread_t*)thread_handle, NULL, (void* (*)(void*)) strt, argument); - __debugbreak(); + UNUSED(attribute); + struct _ithread_launch_param* param = malloc(sizeof(struct _ithread_launch_param)); + param->startFunc = (void (*)(void*))strt; + param->argument = argument; + HANDLE *handle = (HANDLE*)thread_handle; + *handle = CreateThread(NULL, 0, _ithread_WinThreadStartRoutine, param, 0, NULL); + if(*handle == NULL) + { + return -1; + } return 0; } WORD32 ithread_join(void* thread_handle, void** val_ptr) { //UNUSED(val_ptr); - //pthread_t* pthread_handle = (pthread_t*)thread_handle; - //return pthread_join(*pthread_handle, NULL); - - __debugbreak(); - return 0; + HANDLE *handle = (HANDLE*)thread_handle; + DWORD result = WaitForSingleObject(*handle, INFINITE); + if(result == WAIT_OBJECT_0) + { + CloseHandle(*handle); + return 0; + } + else + { + return -1; + } } WORD32 ithread_get_mutex_struct_size(void) { return sizeof(CRITICAL_SECTION); } + WORD32 ithread_mutex_init(void* mutex) { InitializeCriticalSection((LPCRITICAL_SECTION)mutex); @@ -153,7 +184,6 @@ UWORD32 ithread_get_sem_struct_size(void) //return(sizeof(sem_t)); } - WORD32 ithread_sem_init(void* sem, WORD32 pshared, UWORD32 value) { __debugbreak(); @@ -168,7 +198,6 @@ WORD32 ithread_sem_post(void* sem) //return sem_post((sem_t*)sem); } - WORD32 ithread_sem_wait(void* sem) { __debugbreak(); @@ -176,7 +205,6 @@ WORD32 ithread_sem_wait(void* sem) //return sem_wait((sem_t*)sem); } - WORD32 ithread_sem_destroy(void* sem) { __debugbreak(); diff --git a/dependencies/ih264d/common/x86/ih264_platform_macros.h b/dependencies/ih264d/common/x86/ih264_platform_macros.h index ebc1b106..22de33d6 100644 --- a/dependencies/ih264d/common/x86/ih264_platform_macros.h +++ b/dependencies/ih264d/common/x86/ih264_platform_macros.h @@ -79,10 +79,8 @@ static inline int __builtin_clz(unsigned x) { unsigned long n; - if (x == 0) - return 32; _BitScanReverse(&n, x); - return 31 - n; + return n ^ 31; } static inline int __builtin_ctz(unsigned x) { diff --git a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp index 88ce272a..d88a29d4 100644 --- a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp +++ b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp @@ -254,6 +254,8 @@ namespace H264 m_codecCtx->pv_fxns = (void*)&ih264d_api_function; m_codecCtx->u4_size = sizeof(iv_obj_t); + SetDecoderCoreCount(1); + m_isBufferedMode = isBufferedMode; UpdateParameters(false); @@ -278,6 +280,19 @@ namespace H264 m_codecCtx = nullptr; } + void SetDecoderCoreCount(uint32 coreCount) + { + ih264d_ctl_set_num_cores_ip_t s_set_cores_ip; + ih264d_ctl_set_num_cores_op_t s_set_cores_op; + s_set_cores_ip.e_cmd = IVD_CMD_VIDEO_CTL; + s_set_cores_ip.e_sub_cmd = (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_SET_NUM_CORES; + s_set_cores_ip.u4_num_cores = coreCount; // valid numbers are 1-4 + s_set_cores_ip.u4_size = sizeof(ih264d_ctl_set_num_cores_ip_t); + s_set_cores_op.u4_size = sizeof(ih264d_ctl_set_num_cores_op_t); + IV_API_CALL_STATUS_T status = ih264d_api_function(m_codecCtx, (void *)&s_set_cores_ip, (void *)&s_set_cores_op); + cemu_assert(status == IV_SUCCESS); + } + static bool GetImageInfo(uint8* stream, uint32 length, uint32& imageWidth, uint32& imageHeight) { // create temporary decoder @@ -702,7 +717,6 @@ namespace H264 decodeResult = m_bufferedResults.front(); m_bufferedResults.erase(m_bufferedResults.begin()); } - private: iv_obj_t* m_codecCtx{nullptr}; bool m_hasBufferSizeInfo{ false }; From b902aa20489fbeac4ec8db2ffec95c5fa9da05fd Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 11 Sep 2023 11:59:30 +0200 Subject: [PATCH 013/314] Logging: Refactor and optimizations --- .../coreinit/coreinit_Synchronization.cpp | 62 ++++++------ src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp | 44 ++++----- src/Cafe/OS/libs/nn_olv/nn_olv.cpp | 18 ++-- .../nn_olv/nn_olv_DownloadCommunityTypes.h | 38 +++---- .../OS/libs/nn_olv/nn_olv_InitializeTypes.h | 18 ++-- src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.cpp | 98 +++++++++---------- .../libs/nn_olv/nn_olv_UploadCommunityTypes.h | 38 +++---- .../libs/nn_olv/nn_olv_UploadFavoriteTypes.h | 32 +++--- src/Cemu/Logging/CemuLogging.cpp | 71 +++++--------- src/Cemu/Logging/CemuLogging.h | 80 ++++++++------- src/config/ActiveSettings.h | 4 +- src/config/CemuConfig.cpp | 6 +- src/config/CemuConfig.h | 5 +- src/config/ConfigValue.h | 2 +- src/gui/MainWindow.cpp | 13 ++- 15 files changed, 263 insertions(+), 266 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp index 92c90a9d..9e5de19e 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp @@ -621,49 +621,49 @@ namespace coreinit OSInitEvent(g_rendezvousEvent.GetPtr(), OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_AUTO); // OSEvent - cafeExportRegister("coreinit", OSInitEvent, LogType::ThreadSync); - cafeExportRegister("coreinit", OSInitEventEx, LogType::ThreadSync); - cafeExportRegister("coreinit", OSResetEvent, LogType::ThreadSync); - cafeExportRegister("coreinit", OSWaitEvent, LogType::ThreadSync); - cafeExportRegister("coreinit", OSWaitEventWithTimeout, LogType::ThreadSync); - cafeExportRegister("coreinit", OSSignalEvent, LogType::ThreadSync); - cafeExportRegister("coreinit", OSSignalEventAll, LogType::ThreadSync); + cafeExportRegister("coreinit", OSInitEvent, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSInitEventEx, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSResetEvent, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSWaitEvent, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSWaitEventWithTimeout, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSSignalEvent, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSSignalEventAll, LogType::CoreinitThreadSync); // OSRendezvous - cafeExportRegister("coreinit", OSInitRendezvous, LogType::ThreadSync); - cafeExportRegister("coreinit", OSWaitRendezvous, LogType::ThreadSync); + cafeExportRegister("coreinit", OSInitRendezvous, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSWaitRendezvous, LogType::CoreinitThreadSync); // OSMutex - cafeExportRegister("coreinit", OSInitMutex, LogType::ThreadSync); - cafeExportRegister("coreinit", OSInitMutexEx, LogType::ThreadSync); - cafeExportRegister("coreinit", OSLockMutex, LogType::ThreadSync); - cafeExportRegister("coreinit", OSTryLockMutex, LogType::ThreadSync); - cafeExportRegister("coreinit", OSUnlockMutex, LogType::ThreadSync); + cafeExportRegister("coreinit", OSInitMutex, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSInitMutexEx, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSLockMutex, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSTryLockMutex, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSUnlockMutex, LogType::CoreinitThreadSync); // OSCond - cafeExportRegister("coreinit", OSInitCond, LogType::ThreadSync); - cafeExportRegister("coreinit", OSInitCondEx, LogType::ThreadSync); - cafeExportRegister("coreinit", OSSignalCond, LogType::ThreadSync); - cafeExportRegister("coreinit", OSWaitCond, LogType::ThreadSync); + cafeExportRegister("coreinit", OSInitCond, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSInitCondEx, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSSignalCond, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSWaitCond, LogType::CoreinitThreadSync); // OSSemaphore - cafeExportRegister("coreinit", OSInitSemaphore, LogType::ThreadSync); - cafeExportRegister("coreinit", OSInitSemaphoreEx, LogType::ThreadSync); - cafeExportRegister("coreinit", OSWaitSemaphore, LogType::ThreadSync); - cafeExportRegister("coreinit", OSTryWaitSemaphore, LogType::ThreadSync); - cafeExportRegister("coreinit", OSSignalSemaphore, LogType::ThreadSync); - cafeExportRegister("coreinit", OSGetSemaphoreCount, LogType::ThreadSync); + cafeExportRegister("coreinit", OSInitSemaphore, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSInitSemaphoreEx, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSWaitSemaphore, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSTryWaitSemaphore, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSSignalSemaphore, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSGetSemaphoreCount, LogType::CoreinitThreadSync); // OSFastMutex - cafeExportRegister("coreinit", OSFastMutex_Init, LogType::ThreadSync); - cafeExportRegister("coreinit", OSFastMutex_Lock, LogType::ThreadSync); - cafeExportRegister("coreinit", OSFastMutex_TryLock, LogType::ThreadSync); - cafeExportRegister("coreinit", OSFastMutex_Unlock, LogType::ThreadSync); + cafeExportRegister("coreinit", OSFastMutex_Init, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSFastMutex_Lock, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSFastMutex_TryLock, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSFastMutex_Unlock, LogType::CoreinitThreadSync); // OSFastCond - cafeExportRegister("coreinit", OSFastCond_Init, LogType::ThreadSync); - cafeExportRegister("coreinit", OSFastCond_Wait, LogType::ThreadSync); - cafeExportRegister("coreinit", OSFastCond_Signal, LogType::ThreadSync); + cafeExportRegister("coreinit", OSFastCond_Init, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSFastCond_Wait, LogType::CoreinitThreadSync); + cafeExportRegister("coreinit", OSFastCond_Signal, LogType::CoreinitThreadSync); } }; diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp index d7555394..27a858c1 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp @@ -216,7 +216,7 @@ void nnNfpExport_SetDeactivateEvent(PPCInterpreter_t* hCPU) ppcDefineParamStructPtr(osEvent, coreinit::OSEvent, 0); ppcDefineParamMPTR(osEventMPTR, 0); - cemuLog_log(LogType::nn_nfp, "SetDeactivateEvent(0x{:08x})", osEventMPTR); + cemuLog_log(LogType::NN_NFP, "SetDeactivateEvent(0x{:08x})", osEventMPTR); coreinit::OSInitEvent(osEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); @@ -241,7 +241,7 @@ void nnNfpExport_Initialize(PPCInterpreter_t* hCPU) void nnNfpExport_StartDetection(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "StartDetection()"); + cemuLog_log(LogType::NN_NFP, "StartDetection()"); nnNfpLock(); nfp_data.isDetecting = true; nnNfpUnlock(); @@ -250,7 +250,7 @@ void nnNfpExport_StartDetection(PPCInterpreter_t* hCPU) void nnNfpExport_StopDetection(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "StopDetection()"); + cemuLog_log(LogType::NN_NFP, "StopDetection()"); nnNfpLock(); nfp_data.isDetecting = false; nnNfpUnlock(); @@ -274,7 +274,7 @@ static_assert(sizeof(nfpTagInfo_t) == 0x54, "nfpTagInfo_t has invalid size"); void nnNfpExport_GetTagInfo(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetTagInfo(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "GetTagInfo(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(tagInfo, nfpTagInfo_t, 0); nnNfpLock(); @@ -306,7 +306,7 @@ typedef struct uint32 NFCGetTagInfo(uint32 index, uint32 timeout, MPTR functionPtr, void* userParam) { - cemuLog_log(LogType::nn_nfp, "NFCGetTagInfo({},{},0x{:08x},0x{:08x})", index, timeout, functionPtr, userParam?memory_getVirtualOffsetFromPointer(userParam):0); + cemuLog_log(LogType::NN_NFP, "NFCGetTagInfo({},{},0x{:08x},0x{:08x})", index, timeout, functionPtr, userParam ? memory_getVirtualOffsetFromPointer(userParam) : 0); cemu_assert(index == 0); @@ -331,7 +331,7 @@ uint32 NFCGetTagInfo(uint32 index, uint32 timeout, MPTR functionPtr, void* userP void nnNfpExport_Mount(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "Mount()"); + cemuLog_log(LogType::NN_NFP, "Mount()"); nnNfpLock(); if (nfp_data.hasActiveAmiibo == false) { @@ -348,14 +348,14 @@ void nnNfpExport_Mount(PPCInterpreter_t* hCPU) void nnNfpExport_Unmount(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "Unmount()"); + cemuLog_log(LogType::NN_NFP, "Unmount()"); nfp_data.hasOpenApplicationArea = false; osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0)); } void nnNfpExport_MountRom(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "MountRom()"); + cemuLog_log(LogType::NN_NFP, "MountRom()"); nnNfpLock(); if (nfp_data.hasActiveAmiibo == false) { @@ -386,7 +386,7 @@ static_assert(sizeof(nfpRomInfo_t) == 0x36, "nfpRomInfo_t has invalid size"); void nnNfpExport_GetNfpRomInfo(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetNfpRomInfo(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "GetNfpRomInfo(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(romInfo, nfpRomInfo_t, 0); nnNfpLock(); @@ -438,7 +438,7 @@ static_assert(offsetof(nfpCommonData_t, applicationAreaSize) == 0xE, "nfpCommonD void nnNfpExport_GetNfpCommonInfo(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetNfpCommonInfo(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "GetNfpCommonInfo(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(commonInfo, nfpCommonData_t, 0); nnNfpLock(); @@ -492,7 +492,7 @@ typedef struct void nnNfpExport_GetNfpRegisterInfo(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetNfpRegisterInfo(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "GetNfpRegisterInfo(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(registerInfo, nfpRegisterInfo_t, 0); if(!registerInfo) @@ -515,7 +515,7 @@ void nnNfpExport_GetNfpRegisterInfo(PPCInterpreter_t* hCPU) void nnNfpExport_InitializeRegisterInfoSet(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "InitializeRegisterInfoSet(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "InitializeRegisterInfoSet(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(registerInfoSet, nfpRegisterInfoSet_t, 0); memset(registerInfoSet, 0, sizeof(nfpRegisterInfoSet_t)); @@ -525,7 +525,7 @@ void nnNfpExport_InitializeRegisterInfoSet(PPCInterpreter_t* hCPU) void nnNfpExport_SetNfpRegisterInfo(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "SetNfpRegisterInfo(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "SetNfpRegisterInfo(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(registerInfoSet, nfpRegisterInfoSet_t, 0); memcpy(nfp_data.amiiboInternal.amiiboSettings.mii, registerInfoSet->ownerMii, sizeof(nfp_data.amiiboInternal.amiiboSettings.mii)); @@ -538,7 +538,7 @@ void nnNfpExport_SetNfpRegisterInfo(PPCInterpreter_t* hCPU) void nnNfpExport_IsExistApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "IsExistApplicationArea()"); + cemuLog_log(LogType::NN_NFP, "IsExistApplicationArea()"); if (!nfp_data.hasActiveAmiibo || !nfp_data.isMounted) { osLib_returnFromFunction(hCPU, 0); @@ -550,7 +550,7 @@ void nnNfpExport_IsExistApplicationArea(PPCInterpreter_t* hCPU) void nnNfpExport_OpenApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "OpenApplicationArea(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "OpenApplicationArea(0x{:08x})", hCPU->gpr[3]); ppcDefineParamU32(appAreaId, 0); // note - this API doesn't fail if the application area has already been opened? @@ -575,7 +575,7 @@ void nnNfpExport_OpenApplicationArea(PPCInterpreter_t* hCPU) void nnNfpExport_ReadApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "ReadApplicationArea(0x{:08x}, 0x{:x})", hCPU->gpr[3], hCPU->gpr[4]); + cemuLog_log(LogType::NN_NFP, "ReadApplicationArea(0x{:08x}, 0x{:x})", hCPU->gpr[3], hCPU->gpr[4]); ppcDefineParamPtr(bufferPtr, uint8*, 0); ppcDefineParamU32(len, 1); @@ -592,7 +592,7 @@ void nnNfpExport_ReadApplicationArea(PPCInterpreter_t* hCPU) void nnNfpExport_WriteApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "WriteApplicationArea(0x{:08x}, 0x{:x}, 0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); + cemuLog_log(LogType::NN_NFP, "WriteApplicationArea(0x{:08x}, 0x{:x}, 0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); ppcDefineParamPtr(bufferPtr, uint8*, 0); ppcDefineParamU32(len, 1); @@ -628,7 +628,7 @@ typedef struct void nnNfpExport_CreateApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "CreateApplicationArea(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "CreateApplicationArea(0x{:08x})", hCPU->gpr[3]); ppcDefineParamPtr(createInfo, NfpCreateInfo_t, 0); if (nfp_data.hasOpenApplicationArea || (nfp_data.amiiboInternal.amiiboSettings.flags&0x20)) @@ -677,7 +677,7 @@ void nnNfpExport_CreateApplicationArea(PPCInterpreter_t* hCPU) void nnNfpExport_DeleteApplicationArea(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "DeleteApplicationArea()"); + cemuLog_log(LogType::NN_NFP, "DeleteApplicationArea()"); if (nfp_data.isReadOnly) { @@ -707,7 +707,7 @@ void nnNfpExport_DeleteApplicationArea(PPCInterpreter_t* hCPU) void nnNfpExport_Flush(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "Flush()"); + cemuLog_log(LogType::NN_NFP, "Flush()"); // write Amiibo data if (nfp_data.isReadOnly) @@ -748,7 +748,7 @@ static_assert(offsetof(AmiiboSettingsArgs_t, commonInfo) == 0x114); void nnNfpExport_GetAmiiboSettingsArgs(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetAmiiboSettingsArgs(0x{:08x})", hCPU->gpr[3]); + cemuLog_log(LogType::NN_NFP, "GetAmiiboSettingsArgs(0x{:08x})", hCPU->gpr[3]); ppcDefineParamStructPtr(settingsArg, AmiiboSettingsArgs_t, 0); memset(settingsArg, 0, sizeof(AmiiboSettingsArgs_t)); @@ -917,7 +917,7 @@ void nnNfp_update() void nnNfpExport_GetNfpState(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::nn_nfp, "GetNfpState()"); + cemuLog_log(LogType::NN_NFP, "GetNfpState()"); // workaround for Mario Party 10 eating CPU cycles in an infinite loop (maybe due to incorrect NFP detection handling?) uint64 titleId = CafeSystem::GetForegroundTitleId(); diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv.cpp index 25245b5c..99c113c4 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv.cpp @@ -123,20 +123,20 @@ namespace nn loadOliveUploadFavoriteTypes(); loadOlivePostAndTopicTypes(); - cafeExportRegisterFunc(GetErrorCode, "nn_olv", "GetErrorCode__Q2_2nn3olvFRCQ2_2nn6Result", LogType::None); + cafeExportRegisterFunc(GetErrorCode, "nn_olv", "GetErrorCode__Q2_2nn3olvFRCQ2_2nn6Result", LogType::NN_OLV); osLib_addFunction("nn_olv", "GetServiceToken__Q4_2nn3olv6hidden14PortalAppParamCFv", exportPortalAppParam_GetServiceToken); - cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadPostDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv28UploadPostDataByPostAppParam", LogType::Force); - cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadCommentDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv31UploadCommentDataByPostAppParam", LogType::Force); - cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadDirectMessageDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv37UploadDirectMessageDataByPostAppParam", LogType::Force); + cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadPostDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv28UploadPostDataByPostAppParam", LogType::NN_OLV); + cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadCommentDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv31UploadCommentDataByPostAppParam", LogType::NN_OLV); + cafeExportRegisterFunc(StubPostApp, "nn_olv", "UploadDirectMessageDataByPostApp__Q2_2nn3olvFPCQ3_2nn3olv37UploadDirectMessageDataByPostAppParam", LogType::NN_OLV); - cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultByPostApp__Q2_2nn3olvFv", LogType::Force); - cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedPostDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv16UploadedPostData", LogType::Force); - cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedDirectMessageDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv25UploadedDirectMessageData", LogType::Force); - cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedCommentDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv19UploadedCommentData", LogType::Force); + cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultByPostApp__Q2_2nn3olvFv", LogType::NN_OLV); + cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedPostDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv16UploadedPostData", LogType::NN_OLV); + cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedDirectMessageDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv25UploadedDirectMessageData", LogType::NN_OLV); + cafeExportRegisterFunc(StubPostAppResult, "nn_olv", "GetResultWithUploadedCommentDataByPostApp__Q2_2nn3olvFPQ3_2nn3olv19UploadedCommentData", LogType::NN_OLV); - cafeExportRegisterFunc(UploadedPostData_GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv16UploadedPostDataCFv", LogType::Force); + cafeExportRegisterFunc(UploadedPostData_GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv16UploadedPostDataCFv", LogType::NN_OLV); } void unload() // not called yet diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.h index 3f5df35c..794195a1 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.h @@ -501,30 +501,30 @@ namespace nn static void loadOliveDownloadCommunityTypes() { - cafeExportRegisterFunc(DownloadedCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv23DownloadedCommunityDataFv", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv23DownloadedCommunityDataCFUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv23DownloadedCommunityDataCFPcUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv23DownloadedCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv23DownloadedCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv23DownloadedCommunityDataCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv23DownloadedCommunityDataCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerMiiData, "nn_olv", "GetOwnerMiiData__Q3_2nn3olv23DownloadedCommunityDataCFP12FFLStoreData", LogType::None); - cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerMiiNickname, "nn_olv", "GetOwnerMiiNickname__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::None); + cafeExportRegisterFunc(DownloadedCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv23DownloadedCommunityDataFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv23DownloadedCommunityDataCFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv23DownloadedCommunityDataCFPcUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv23DownloadedCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv23DownloadedCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv23DownloadedCommunityDataCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv23DownloadedCommunityDataCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerMiiData, "nn_olv", "GetOwnerMiiData__Q3_2nn3olv23DownloadedCommunityDataCFP12FFLStoreData", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedCommunityData::__GetOwnerMiiNickname, "nn_olv", "GetOwnerMiiNickname__Q3_2nn3olv23DownloadedCommunityDataCFv", LogType::NN_OLV); - cafeExportRegisterFunc(DownloadCommunityDataListParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv30DownloadCommunityDataListParamFv", LogType::None); - cafeExportRegisterFunc(DownloadCommunityDataListParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadCommunityDataListParam::__SetCommunityDataMaxNum, "nn_olv", "SetCommunityDataMaxNum__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadCommunityDataListParam::__GetRawDataUrl, "nn_olv", "GetRawDataUrl__Q3_2nn3olv30DownloadCommunityDataListParamCFPcUi", LogType::None); + cafeExportRegisterFunc(DownloadCommunityDataListParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv30DownloadCommunityDataListParamFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadCommunityDataListParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadCommunityDataListParam::__SetCommunityDataMaxNum, "nn_olv", "SetCommunityDataMaxNum__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadCommunityDataListParam::__GetRawDataUrl, "nn_olv", "GetRawDataUrl__Q3_2nn3olv30DownloadCommunityDataListParamCFPcUi", LogType::NN_OLV); cafeExportRegisterFunc((sint32 (*)(DownloadCommunityDataListParam*, uint32))DownloadCommunityDataListParam::__SetCommunityId, - "nn_olv", "SetCommunityId__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::None); + "nn_olv", "SetCommunityId__Q3_2nn3olv30DownloadCommunityDataListParamFUi", LogType::NN_OLV); cafeExportRegisterFunc((sint32(*)(DownloadCommunityDataListParam*, uint32, uint8))DownloadCommunityDataListParam::__SetCommunityId, - "nn_olv", "SetCommunityId__Q3_2nn3olv30DownloadCommunityDataListParamFUiUc", LogType::None); + "nn_olv", "SetCommunityId__Q3_2nn3olv30DownloadCommunityDataListParamFUiUc", LogType::NN_OLV); - cafeExportRegisterFunc(DownloadCommunityDataList, "nn_olv", "DownloadCommunityDataList__Q2_2nn3olvFPQ3_2nn3olv23DownloadedCommunityDataPUiUiPCQ3_2nn3olv30DownloadCommunityDataListParam", LogType::None); + cafeExportRegisterFunc(DownloadCommunityDataList, "nn_olv", "DownloadCommunityDataList__Q2_2nn3olvFPQ3_2nn3olv23DownloadedCommunityDataPUiUiPCQ3_2nn3olv30DownloadCommunityDataListParam", LogType::NN_OLV); } } } \ No newline at end of file diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.h index 603b167c..51dce8fe 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.h @@ -113,16 +113,16 @@ namespace nn static void loadOliveInitializeTypes() { - cafeExportRegisterFunc(Initialize, "nn_olv", "Initialize__Q2_2nn3olvFPCQ3_2nn3olv15InitializeParam", LogType::None); - cafeExportRegisterFunc(IsInitialized, "nn_olv", "IsInitialized__Q2_2nn3olvFv", LogType::None); - cafeExportRegisterFunc(Report::GetReportTypes, "nn_olv", "GetReportTypes__Q3_2nn3olv6ReportFv", LogType::None); - cafeExportRegisterFunc(Report::SetReportTypes, "nn_olv", "SetReportTypes__Q3_2nn3olv6ReportFUi", LogType::None); + cafeExportRegisterFunc(Initialize, "nn_olv", "Initialize__Q2_2nn3olvFPCQ3_2nn3olv15InitializeParam", LogType::NN_OLV); + cafeExportRegisterFunc(IsInitialized, "nn_olv", "IsInitialized__Q2_2nn3olvFv", LogType::NN_OLV); + cafeExportRegisterFunc(Report::GetReportTypes, "nn_olv", "GetReportTypes__Q3_2nn3olv6ReportFv", LogType::NN_OLV); + cafeExportRegisterFunc(Report::SetReportTypes, "nn_olv", "SetReportTypes__Q3_2nn3olv6ReportFUi", LogType::NN_OLV); - cafeExportRegisterFunc(InitializeParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv15InitializeParamFv", LogType::None); - cafeExportRegisterFunc(InitializeParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv15InitializeParamFUi", LogType::None); - cafeExportRegisterFunc(InitializeParam::__SetWork, "nn_olv", "SetWork__Q3_2nn3olv15InitializeParamFPUcUi", LogType::None); - cafeExportRegisterFunc(InitializeParam::__SetReportTypes, "nn_olv", "SetReportTypes__Q3_2nn3olv15InitializeParamFUi", LogType::None); - cafeExportRegisterFunc(InitializeParam::__SetSysArgs, "nn_olv", "SetSysArgs__Q3_2nn3olv15InitializeParamFPCvUi", LogType::None); + cafeExportRegisterFunc(InitializeParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv15InitializeParamFv", LogType::NN_OLV); + cafeExportRegisterFunc(InitializeParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv15InitializeParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(InitializeParam::__SetWork, "nn_olv", "SetWork__Q3_2nn3olv15InitializeParamFPUcUi", LogType::NN_OLV); + cafeExportRegisterFunc(InitializeParam::__SetReportTypes, "nn_olv", "SetReportTypes__Q3_2nn3olv15InitializeParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(InitializeParam::__SetSysArgs, "nn_olv", "SetSysArgs__Q3_2nn3olv15InitializeParamFPCvUi", LogType::NN_OLV); } } } \ No newline at end of file diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.cpp index 722e5584..5257530d 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.cpp @@ -391,71 +391,71 @@ namespace nn void loadOlivePostAndTopicTypes() { - cafeExportRegisterFunc(GetSystemTopicDataListFromRawData, "nn_olv", "GetSystemTopicDataListFromRawData__Q3_2nn3olv6hiddenFPQ4_2nn3olv6hidden29DownloadedSystemTopicDataListPQ4_2nn3olv6hidden24DownloadedSystemPostDataPUiUiPCUcT4", LogType::None); + cafeExportRegisterFunc(GetSystemTopicDataListFromRawData, "nn_olv", "GetSystemTopicDataListFromRawData__Q3_2nn3olv6hiddenFPQ4_2nn3olv6hidden29DownloadedSystemTopicDataListPQ4_2nn3olv6hidden24DownloadedSystemPostDataPUiUiPCUcT4", LogType::NN_OLV); // DownloadedDataBase getters - cafeExportRegisterFunc(DownloadedDataBase::TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv18DownloadedDataBaseCFUi", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetUserPid, "nn_olv", "GetUserPid__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetPostDate, "nn_olv", "GetPostDate__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetFeeling, "nn_olv", "GetFeeling__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetRegionId, "nn_olv", "GetRegionId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetPlatformId, "nn_olv", "GetPlatformId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetLanguageId, "nn_olv", "GetLanguageId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetCountryId, "nn_olv", "GetCountryId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetExternalUrl, "nn_olv", "GetExternalUrl__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetMiiData1, "nn_olv", "GetMiiData__Q3_2nn3olv18DownloadedDataBaseCFP12FFLStoreData", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetMiiNickname, "nn_olv", "GetMiiNickname__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetBodyText, "nn_olv", "GetBodyText__Q3_2nn3olv18DownloadedDataBaseCFPwUi", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetBodyMemo, "nn_olv", "GetBodyMemo__Q3_2nn3olv18DownloadedDataBaseCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetTopicTag, "nn_olv", "GetTopicTag__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv18DownloadedDataBaseCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetMiiData2, "nn_olv", "GetMiiData__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::DownloadExternalImageData, "nn_olv", "DownloadExternalImageData__Q3_2nn3olv18DownloadedDataBaseCFPvPUiUi", LogType::None); - cafeExportRegisterFunc(DownloadedDataBase::GetExternalImageDataSize, "nn_olv", "GetExternalImageDataSize__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::None); + cafeExportRegisterFunc(DownloadedDataBase::TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv18DownloadedDataBaseCFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetUserPid, "nn_olv", "GetUserPid__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetPostDate, "nn_olv", "GetPostDate__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetFeeling, "nn_olv", "GetFeeling__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetRegionId, "nn_olv", "GetRegionId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetPlatformId, "nn_olv", "GetPlatformId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetLanguageId, "nn_olv", "GetLanguageId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetCountryId, "nn_olv", "GetCountryId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetExternalUrl, "nn_olv", "GetExternalUrl__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetMiiData1, "nn_olv", "GetMiiData__Q3_2nn3olv18DownloadedDataBaseCFP12FFLStoreData", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetMiiNickname, "nn_olv", "GetMiiNickname__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetBodyText, "nn_olv", "GetBodyText__Q3_2nn3olv18DownloadedDataBaseCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetBodyMemo, "nn_olv", "GetBodyMemo__Q3_2nn3olv18DownloadedDataBaseCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetTopicTag, "nn_olv", "GetTopicTag__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv18DownloadedDataBaseCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetMiiData2, "nn_olv", "GetMiiData__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::DownloadExternalImageData, "nn_olv", "DownloadExternalImageData__Q3_2nn3olv18DownloadedDataBaseCFPvPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedDataBase::GetExternalImageDataSize, "nn_olv", "GetExternalImageDataSize__Q3_2nn3olv18DownloadedDataBaseCFv", LogType::NN_OLV); // DownloadedPostData getters - cafeExportRegisterFunc(DownloadedPostData::GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv18DownloadedPostDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedPostData::GetEmpathyCount, "nn_olv", "GetEmpathyCount__Q3_2nn3olv18DownloadedPostDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedPostData::GetCommentCount, "nn_olv", "GetCommentCount__Q3_2nn3olv18DownloadedPostDataCFv", LogType::None); - cafeExportRegisterFunc(DownloadedPostData::GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv18DownloadedPostDataCFv", LogType::None); + cafeExportRegisterFunc(DownloadedPostData::GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv18DownloadedPostDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedPostData::GetEmpathyCount, "nn_olv", "GetEmpathyCount__Q3_2nn3olv18DownloadedPostDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedPostData::GetCommentCount, "nn_olv", "GetCommentCount__Q3_2nn3olv18DownloadedPostDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadedPostData::GetPostId, "nn_olv", "GetPostId__Q3_2nn3olv18DownloadedPostDataCFv", LogType::NN_OLV); // DownloadedSystemPostData getters - cafeExportRegisterFunc(hidden::DownloadedSystemPostData::GetTitleId, "nn_olv", "GetTitleId__Q4_2nn3olv6hidden24DownloadedSystemPostDataCFv", LogType::None); + cafeExportRegisterFunc(hidden::DownloadedSystemPostData::GetTitleId, "nn_olv", "GetTitleId__Q4_2nn3olv6hidden24DownloadedSystemPostDataCFv", LogType::NN_OLV); // DownloadedTopicData getters - cafeExportRegisterFunc(DownloadedTopicData::GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv19DownloadedTopicDataCFv", LogType::None); + cafeExportRegisterFunc(DownloadedTopicData::GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv19DownloadedTopicDataCFv", LogType::NN_OLV); // DownloadedSystemTopicData getters - cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::TestFlags, "nn_olv", "TestFlags__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFUi", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleId, "nn_olv", "GetTitleId__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFv", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleIdNum, "nn_olv", "GetTitleIdNum__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFv", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleText, "nn_olv", "GetTitleText__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFPwUi", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleIconData, "nn_olv", "GetTitleIconData__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFPUcPUiUi", LogType::None); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::TestFlags, "nn_olv", "TestFlags__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFUi", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleId, "nn_olv", "GetTitleId__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleIdNum, "nn_olv", "GetTitleIdNum__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleText, "nn_olv", "GetTitleText__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicData::GetTitleIconData, "nn_olv", "GetTitleIconData__Q4_2nn3olv6hidden25DownloadedSystemTopicDataCFPUcPUiUi", LogType::NN_OLV); // DownloadedSystemTopicDataList getters - cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemTopicDataNum, "nn_olv", "GetDownloadedSystemTopicDataNum__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFv", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemPostDataNum, "nn_olv", "GetDownloadedSystemPostDataNum__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFi", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemTopicData, "nn_olv", "GetDownloadedSystemTopicData__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFi", LogType::None); - cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemPostData, "nn_olv", "GetDownloadedSystemPostData__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFiT1", LogType::None); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemTopicDataNum, "nn_olv", "GetDownloadedSystemTopicDataNum__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFv", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemPostDataNum, "nn_olv", "GetDownloadedSystemPostDataNum__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFi", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemTopicData, "nn_olv", "GetDownloadedSystemTopicData__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFi", LogType::NN_OLV); + cafeExportRegisterFunc(hidden::DownloadedSystemTopicDataList::GetDownloadedSystemPostData, "nn_olv", "GetDownloadedSystemPostData__Q4_2nn3olv6hidden29DownloadedSystemTopicDataListCFiT1", LogType::NN_OLV); // DownloadPostDataListParam constructor and getters - cafeExportRegisterFunc(DownloadPostDataListParam::Construct, "nn_olv", "__ct__Q3_2nn3olv25DownloadPostDataListParamFv", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetLanguageId, "nn_olv", "SetLanguageId__Q3_2nn3olv25DownloadPostDataListParamFUc", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchKey, "nn_olv", "SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCwUc", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchKeySingle, "nn_olv", "SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCw", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchPid, "nn_olv", "SetSearchPid__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetPostId, "nn_olv", "SetPostId__Q3_2nn3olv25DownloadPostDataListParamFPCcUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetPostDate, "nn_olv", "SetPostDate__Q3_2nn3olv25DownloadPostDataListParamFL", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetPostDataMaxNum, "nn_olv", "SetPostDataMaxNum__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataListParam::SetBodyTextMaxLength, "nn_olv", "SetBodyTextMaxLength__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::None); + cafeExportRegisterFunc(DownloadPostDataListParam::Construct, "nn_olv", "__ct__Q3_2nn3olv25DownloadPostDataListParamFv", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetLanguageId, "nn_olv", "SetLanguageId__Q3_2nn3olv25DownloadPostDataListParamFUc", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchKey, "nn_olv", "SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCwUc", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchKeySingle, "nn_olv", "SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCw", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetSearchPid, "nn_olv", "SetSearchPid__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetPostId, "nn_olv", "SetPostId__Q3_2nn3olv25DownloadPostDataListParamFPCcUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetPostDate, "nn_olv", "SetPostDate__Q3_2nn3olv25DownloadPostDataListParamFL", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetPostDataMaxNum, "nn_olv", "SetPostDataMaxNum__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataListParam::SetBodyTextMaxLength, "nn_olv", "SetBodyTextMaxLength__Q3_2nn3olv25DownloadPostDataListParamFUi", LogType::NN_OLV); // URL and downloading functions - cafeExportRegisterFunc(DownloadPostDataListParam::GetRawDataUrl, "nn_olv", "GetRawDataUrl__Q3_2nn3olv25DownloadPostDataListParamCFPcUi", LogType::None); - cafeExportRegisterFunc(DownloadPostDataList, "nn_olv", "DownloadPostDataList__Q2_2nn3olvFPQ3_2nn3olv19DownloadedTopicDataPQ3_2nn3olv18DownloadedPostDataPUiUiPCQ3_2nn3olv25DownloadPostDataListParam", LogType::None); + cafeExportRegisterFunc(DownloadPostDataListParam::GetRawDataUrl, "nn_olv", "GetRawDataUrl__Q3_2nn3olv25DownloadPostDataListParamCFPcUi", LogType::NN_OLV); + cafeExportRegisterFunc(DownloadPostDataList, "nn_olv", "DownloadPostDataList__Q2_2nn3olvFPQ3_2nn3olv19DownloadedTopicDataPQ3_2nn3olv18DownloadedPostDataPUiUiPCQ3_2nn3olv25DownloadPostDataListParam", LogType::NN_OLV); } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h index 4944e314..16ebd29a 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h @@ -402,30 +402,30 @@ namespace nn static void loadOliveUploadCommunityTypes() { - cafeExportRegisterFunc(UploadedCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv21UploadedCommunityDataFv", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv21UploadedCommunityDataCFUi", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv21UploadedCommunityDataCFPcUi", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv21UploadedCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv21UploadedCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv21UploadedCommunityDataCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv21UploadedCommunityDataCFPUcPUiUi", LogType::None); + cafeExportRegisterFunc(UploadedCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv21UploadedCommunityDataFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv21UploadedCommunityDataCFUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv21UploadedCommunityDataCFPcUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv21UploadedCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv21UploadedCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv21UploadedCommunityDataCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv21UploadedCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv21UploadedCommunityDataCFPUcPUiUi", LogType::NN_OLV); - cafeExportRegisterFunc(UploadCommunityDataParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv24UploadCommunityDataParamFv", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv24UploadCommunityDataParamFUi", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv24UploadCommunityDataParamFUi", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetAppData, "nn_olv", "SetAppData__Q3_2nn3olv24UploadCommunityDataParamFPCUcUi", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetTitleText, "nn_olv", "SetTitleText__Q3_2nn3olv24UploadCommunityDataParamFPCw", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetDescriptionText, "nn_olv", "SetDescriptionText__Q3_2nn3olv24UploadCommunityDataParamFPCw", LogType::None); - cafeExportRegisterFunc(UploadCommunityDataParam::__SetIconData, "nn_olv", "SetIconData__Q3_2nn3olv24UploadCommunityDataParamFPCUcUi", LogType::None); + cafeExportRegisterFunc(UploadCommunityDataParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv24UploadCommunityDataParamFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv24UploadCommunityDataParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv24UploadCommunityDataParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetAppData, "nn_olv", "SetAppData__Q3_2nn3olv24UploadCommunityDataParamFPCUcUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetTitleText, "nn_olv", "SetTitleText__Q3_2nn3olv24UploadCommunityDataParamFPCw", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetDescriptionText, "nn_olv", "SetDescriptionText__Q3_2nn3olv24UploadCommunityDataParamFPCw", LogType::NN_OLV); + cafeExportRegisterFunc(UploadCommunityDataParam::__SetIconData, "nn_olv", "SetIconData__Q3_2nn3olv24UploadCommunityDataParamFPCUcUi", LogType::NN_OLV); cafeExportRegisterFunc((sint32(*)(UploadCommunityDataParam const*))UploadCommunityData, - "nn_olv", "UploadCommunityData__Q2_2nn3olvFPCQ3_2nn3olv24UploadCommunityDataParam", LogType::None); + "nn_olv", "UploadCommunityData__Q2_2nn3olvFPCQ3_2nn3olv24UploadCommunityDataParam", LogType::NN_OLV); cafeExportRegisterFunc((sint32(*)(UploadedCommunityData *, UploadCommunityDataParam const*))UploadCommunityData, - "nn_olv", "UploadCommunityData__Q2_2nn3olvFPQ3_2nn3olv21UploadedCommunityDataPCQ3_2nn3olv24UploadCommunityDataParam", LogType::None); + "nn_olv", "UploadCommunityData__Q2_2nn3olvFPQ3_2nn3olv21UploadedCommunityDataPCQ3_2nn3olv24UploadCommunityDataParam", LogType::NN_OLV); } } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.h index 05ef1dd4..dfa43ec3 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.h @@ -315,27 +315,27 @@ namespace nn static void loadOliveUploadFavoriteTypes() { - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv31UploadedFavoriteToCommunityDataFv", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFUi", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPcUi", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPwUi", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPUcPUiUi", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::None); - cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPUcPUiUi", LogType::None); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__ctor, "nn_olv", "__ct__Q3_2nn3olv31UploadedFavoriteToCommunityDataFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__TestFlags, "nn_olv", "TestFlags__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetCommunityId, "nn_olv", "GetCommunityId__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetCommunityCode, "nn_olv", "GetCommunityCode__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPcUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetOwnerPid, "nn_olv", "GetOwnerPid__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetTitleText, "nn_olv", "GetTitleText__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetDescriptionText, "nn_olv", "GetDescriptionText__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPwUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetAppData, "nn_olv", "GetAppData__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPUcPUiUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetAppDataSize, "nn_olv", "GetAppDataSize__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadedFavoriteToCommunityData::__GetIconData, "nn_olv", "GetIconData__Q3_2nn3olv31UploadedFavoriteToCommunityDataCFPUcPUiUi", LogType::NN_OLV); - cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFv", LogType::None); - cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFUi", LogType::None); - cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetCommunityCode, "nn_olv", "SetCommunityCode__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFPCc", LogType::None); - cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFUi", LogType::None); + cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__ctor, "nn_olv", "__ct__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFv", LogType::NN_OLV); + cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetFlags, "nn_olv", "SetFlags__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFUi", LogType::NN_OLV); + cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetCommunityCode, "nn_olv", "SetCommunityCode__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFPCc", LogType::NN_OLV); + cafeExportRegisterFunc(UploadFavoriteToCommunityDataParam::__SetCommunityId, "nn_olv", "SetCommunityId__Q3_2nn3olv34UploadFavoriteToCommunityDataParamFUi", LogType::NN_OLV); cafeExportRegisterFunc((sint32(*)(const UploadFavoriteToCommunityDataParam*))UploadFavoriteToCommunityData, - "nn_olv", "UploadFavoriteToCommunityData__Q2_2nn3olvFPCQ3_2nn3olv34UploadFavoriteToCommunityDataParam", LogType::None); + "nn_olv", "UploadFavoriteToCommunityData__Q2_2nn3olvFPCQ3_2nn3olv34UploadFavoriteToCommunityDataParam", LogType::NN_OLV); cafeExportRegisterFunc((sint32(*)(UploadedFavoriteToCommunityData*, const UploadFavoriteToCommunityDataParam*))UploadFavoriteToCommunityData, - "nn_olv", "UploadFavoriteToCommunityData__Q2_2nn3olvFPQ3_2nn3olv31UploadedFavoriteToCommunityDataPCQ3_2nn3olv34UploadFavoriteToCommunityDataParam", LogType::None); + "nn_olv", "UploadFavoriteToCommunityData__Q2_2nn3olvFPQ3_2nn3olv31UploadedFavoriteToCommunityDataPCQ3_2nn3olv34UploadFavoriteToCommunityDataParam", LogType::NN_OLV); } } diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index ed8441a7..ac228530 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -1,8 +1,8 @@ #include "CemuLogging.h" -#include "config/CemuConfig.h" #include "gui/LoggingWindow.h" -#include "config/ActiveSettings.h" #include "util/helpers/helpers.h" +#include "config/CemuConfig.h" +#include "config/ActiveSettings.h" #include #include @@ -10,6 +10,8 @@ #include +uint64 s_loggingFlagMask = cemuLog_getFlag(LogType::Force); + struct _LogContext { std::condition_variable_any log_condition; @@ -33,48 +35,32 @@ struct _LogContext const std::map g_logging_window_mapping { - {LogType::UnsupportedAPI, "Unsupported API calls"}, - {LogType::CoreinitLogging, "Coreinit Logging"}, - {LogType::CoreinitFile, "Coreinit File-Access"}, - {LogType::ThreadSync, "Coreinit Thread-Synchronization"}, - {LogType::CoreinitMem, "Coreinit Memory"}, - {LogType::CoreinitMP, "Coreinit MP"}, - {LogType::CoreinitThread, "Coreinit Thread"}, - {LogType::nn_nfp, "nn::nfp"}, - {LogType::GX2, "GX2"}, - {LogType::SoundAPI, "Audio"}, - {LogType::InputAPI, "Input"}, - {LogType::Socket, "Socket"}, - {LogType::Save, "Save"}, - {LogType::H264, "H264"}, - {LogType::Patches, "Graphic pack patches"}, - {LogType::TextureCache, "Texture cache"}, - {LogType::TextureReadback, "Texture readback"}, - {LogType::OpenGLLogging, "OpenGL debug output"}, - {LogType::VulkanValidation, "Vulkan validation layer"}, + {LogType::UnsupportedAPI, "Unsupported API calls"}, + {LogType::CoreinitLogging, "Coreinit Logging"}, + {LogType::CoreinitFile, "Coreinit File-Access"}, + {LogType::CoreinitThreadSync, "Coreinit Thread-Synchronization"}, + {LogType::CoreinitMem, "Coreinit Memory"}, + {LogType::CoreinitMP, "Coreinit MP"}, + {LogType::CoreinitThread, "Coreinit Thread"}, + {LogType::NN_NFP, "nn::nfp"}, + {LogType::GX2, "GX2"}, + {LogType::SoundAPI, "Audio"}, + {LogType::InputAPI, "Input"}, + {LogType::Socket, "Socket"}, + {LogType::Save, "Save"}, + {LogType::H264, "H264"}, + {LogType::Patches, "Graphic pack patches"}, + {LogType::TextureCache, "Texture cache"}, + {LogType::TextureReadback, "Texture readback"}, + {LogType::OpenGLLogging, "OpenGL debug output"}, + {LogType::VulkanValidation, "Vulkan validation layer"}, }; -uint64 cemuLog_getFlag(LogType type) -{ - return type <= LogType::Force ? 0 : (1ULL << ((uint64)type - 1)); -} - bool cemuLog_advancedPPCLoggingEnabled() { return GetConfig().advanced_ppc_logging; } -bool cemuLog_isLoggingEnabled(LogType type) -{ - if (type == LogType::Placeholder) - return false; - - if (type == LogType::None) - return false; - - return (type == LogType::Force) || ((GetConfig().log_flag.GetValue() & cemuLog_getFlag(type)) != 0); -} - void cemuLog_thread() { SetThreadName("cemuLog_thread"); @@ -198,12 +184,7 @@ std::unique_lock cemuLog_acquire() return std::unique_lock(LogContext.log_mutex); } -void cemuLog_setFlag(LogType loggingType, bool isEnable) +void cemuLog_setActiveLoggingFlags(uint64 flagMask) { - if (isEnable) - GetConfig().log_flag = GetConfig().log_flag.GetValue() | cemuLog_getFlag(loggingType); - else - GetConfig().log_flag = GetConfig().log_flag.GetValue() & ~cemuLog_getFlag(loggingType); - - g_config.Save(); -} \ No newline at end of file + s_loggingFlagMask = flagMask | cemuLog_getFlag(LogType::Force); +} diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index d55256c9..e6599c5a 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -1,43 +1,44 @@ #pragma once +extern uint64 s_loggingFlagMask; + enum class LogType : sint32 { - // note: IDs must not exceed 63 - Placeholder = -2, - None = -1, - Force = 0, // this logging type is always on - CoreinitFile = 1, - GX2 = 2, - UnsupportedAPI = 3, - ThreadSync = 4, - SoundAPI = 5, // any audio related API - InputAPI = 6, // any input related API - Socket = 7, - Save = 8, - CoreinitMem = 9, // coreinit memory functions - H264 = 10, - OpenGLLogging = 11, // OpenGL debug logging - TextureCache = 12, // texture cache warnings and info - VulkanValidation = 13, // Vulkan validation layer - nn_nfp = 14, // nn_nfp (Amiibo) API - Patches = 15, - CoreinitMP = 16, - CoreinitThread = 17, - CoreinitLogging = 18, // OSReport, OSConsoleWrite etc. - CoreinitMemoryMapping = 19, // OSGetAvailPhysAddrRange, OSAllocVirtAddr, OSMapMemory etc. - CoreinitAlarm = 23, + // note: IDs must be in range 1-64 + Force = 63, // always enabled + Placeholder = 62, // always disabled + APIErrors = Force, // alias for Force. Logs bad parameters or other API errors in OS libs - PPC_IPC = 20, - NN_AOC = 21, - NN_PDM = 22, - - TextureReadback = 30, + CoreinitFile = 0, + GX2 = 1, + UnsupportedAPI = 2, + SoundAPI = 4, // any audio related API + InputAPI = 5, // any input related API + Socket = 6, + Save = 7, + H264 = 9, + OpenGLLogging = 10, // OpenGL debug logging + TextureCache = 11, // texture cache warnings and info + VulkanValidation = 12, // Vulkan validation layer + Patches = 14, + CoreinitMem = 8, // coreinit memory functions + CoreinitMP = 15, + CoreinitThread = 16, + CoreinitLogging = 17, // OSReport, OSConsoleWrite etc. + CoreinitMemoryMapping = 18, // OSGetAvailPhysAddrRange, OSAllocVirtAddr, OSMapMemory etc. + CoreinitAlarm = 22, + CoreinitThreadSync = 3, - ProcUi = 40, + PPC_IPC = 19, + NN_AOC = 20, + NN_PDM = 21, + NN_OLV = 23, + NN_NFP = 13, - APIErrors = 0, // alias for Force. Logs bad parameters or other API errors in OS libs + TextureReadback = 29, + + ProcUi = 39, - }; template <> @@ -53,7 +54,17 @@ struct fmt::formatter : formatter { void cemuLog_writeLineToLog(std::string_view text, bool date = true, bool new_line = true); inline void cemuLog_writePlainToLog(std::string_view text) { cemuLog_writeLineToLog(text, false, false); } -bool cemuLog_isLoggingEnabled(LogType type); +void cemuLog_setActiveLoggingFlags(uint64 flagMask); + +inline uint64 cemuLog_getFlag(LogType type) +{ + return 1ULL << (uint64)type; +} + +inline bool cemuLog_isLoggingEnabled(LogType type) +{ + return (s_loggingFlagMask & cemuLog_getFlag(type)) != 0; +} bool cemuLog_log(LogType type, std::string_view text); bool cemuLog_log(LogType type, std::u8string_view text); @@ -97,6 +108,8 @@ bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) template bool cemuLog_log(LogType type, const T* format, TArgs&&... args) { + if (!cemuLog_isLoggingEnabled(type)) + return false; auto format_str = std::basic_string(format); return cemuLog_log(type, format_str, std::forward(args)...); } @@ -116,7 +129,6 @@ bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args) bool cemuLog_advancedPPCLoggingEnabled(); uint64 cemuLog_getFlag(LogType type); -void cemuLog_setFlag(LogType type, bool enabled); fs::path cemuLog_GetLogFilePath(); void cemuLog_createLogFile(bool triggeredByCrash); diff --git a/src/config/ActiveSettings.h b/src/config/ActiveSettings.h index 1b66b525..54052741 100644 --- a/src/config/ActiveSettings.h +++ b/src/config/ActiveSettings.h @@ -69,12 +69,12 @@ private: inline static fs::path s_executable_filename; // cemu.exe inline static fs::path s_mlc_path; -public: +public: // general [[nodiscard]] static bool LoadSharedLibrariesEnabled(); [[nodiscard]] static bool DisplayDRCEnabled(); [[nodiscard]] static bool FullscreenEnabled(); - + // cpu [[nodiscard]] static CPUMode GetCPUMode(); [[nodiscard]] static uint8 GetTimerShiftFactor(); diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 833ef1c2..220a2295 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -43,6 +43,7 @@ void CemuConfig::Load(XMLConfigParser& parser) // general settings log_flag = parser.get("logflag", log_flag.GetInitValue()); + cemuLog_setActiveLoggingFlags(GetConfig().log_flag.GetValue()); advanced_ppc_logging = parser.get("advanced_ppc_logging", advanced_ppc_logging.GetInitValue()); const char* mlc = parser.get("mlc_path", ""); @@ -53,7 +54,7 @@ void CemuConfig::Load(XMLConfigParser& parser) language = parser.get("language", wxLANGUAGE_DEFAULT); use_discord_presence = parser.get("use_discord_presence", true); fullscreen_menubar = parser.get("fullscreen_menubar", false); - feral_gamemode = parser.get("feral_gamemode", false); + feral_gamemode = parser.get("feral_gamemode", false); check_update = parser.get("check_update", check_update); save_screenshot = parser.get("save_screenshot", save_screenshot); did_show_vulkan_warning = parser.get("vk_warning", did_show_vulkan_warning); @@ -62,9 +63,6 @@ void CemuConfig::Load(XMLConfigParser& parser) fullscreen = parser.get("fullscreen", fullscreen); proxy_server = parser.get("proxy_server", ""); disable_screensaver = parser.get("disable_screensaver", disable_screensaver); - - // cpu_mode = parser.get("cpu_mode", cpu_mode.GetInitValue()); - //console_region = parser.get("console_region", console_region.GetInitValue()); console_language = parser.get("console_language", console_language.GetInitValue()); window_position.x = parser.get("window_position").get("x", -1); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 19d9ca0e..ea6c3f2c 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -353,7 +353,6 @@ struct CemuConfig }; CemuConfig(const CemuConfig&) = delete; - // // sets mlc path, updates permanent config value, saves config void SetMLCPath(fs::path path, bool save = true); @@ -365,10 +364,10 @@ struct CemuConfig ConfigValue language{ wxLANGUAGE_DEFAULT }; ConfigValue use_discord_presence{ true }; - ConfigValue mlc_path {}; + ConfigValue mlc_path{}; ConfigValue fullscreen_menubar{ false }; ConfigValue fullscreen{ false }; - ConfigValue feral_gamemode{false}; + ConfigValue feral_gamemode{false}; ConfigValue proxy_server{}; // temporary workaround because feature crashes on macOS diff --git a/src/config/ConfigValue.h b/src/config/ConfigValue.h index 11fc1e48..358af67a 100644 --- a/src/config/ConfigValue.h +++ b/src/config/ConfigValue.h @@ -39,7 +39,7 @@ public: return *this; } - [[nodiscard]] TType GetValue() const { return m_value.load(); } + [[nodiscard]] inline TType GetValue() const { return m_value.load(); } void SetValue(const TType& v) { m_value = v; } [[nodiscard]] const TType& GetInitValue() const { return m_init_value; } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index bba64a24..d0ec6e9f 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1103,7 +1103,14 @@ void MainWindow::OnDebugLoggingToggleFlagGeneric(wxCommandEvent& event) sint32 id = event.GetId(); if (id >= loggingIdBase && id < (MAINFRAME_MENU_ID_DEBUG_LOGGING0 + 64)) { - cemuLog_setFlag(static_cast(id - loggingIdBase), event.IsChecked()); + bool isEnable = event.IsChecked(); + LogType loggingType = static_cast(id - loggingIdBase); + if (isEnable) + GetConfig().log_flag = GetConfig().log_flag.GetValue() | cemuLog_getFlag(loggingType); + else + GetConfig().log_flag = GetConfig().log_flag.GetValue() & ~cemuLog_getFlag(loggingType); + cemuLog_setActiveLoggingFlags(GetConfig().log_flag.GetValue()); + g_config.Save(); } } @@ -2190,11 +2197,11 @@ void MainWindow::RecreateMenu() debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::UnsupportedAPI), _("&Unsupported API calls"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::UnsupportedAPI)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitLogging), _("&Coreinit Logging (OSReport/OSConsole)"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitLogging)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitFile), _("&Coreinit File-Access API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitFile)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::ThreadSync), _("&Coreinit Thread-Synchronization API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::ThreadSync)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThreadSync), _("&Coreinit Thread-Synchronization API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThreadSync)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMem), _("&Coreinit Memory API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMem)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMP), _("&Coreinit MP API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("&Coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::nn_nfp), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::nn_nfp)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("&GX2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("&Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::InputAPI), _("&Input API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::InputAPI)); From 92ab87b0492713a2d4c9b980209301e7312c626b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 11 Sep 2023 18:20:37 +0200 Subject: [PATCH 014/314] Latte: Fix shader compilation error when subroutines are used Fixes character colors in Tekken Tag Tournament 2 --- .../Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp | 4 ++-- src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 5ce0b76f..486b7bf5 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -4037,8 +4037,8 @@ void LatteDecompiler_emitGLSLShader(LatteDecompilerShaderContext* shaderContext, for (auto& subroutineInfo : shaderContext->list_subroutines) { sint32 subroutineMaxStackDepth = 0; - src->addFmt("bool activeMaskStackSub%04x[{}];" _CRLF, subroutineInfo.cfAddr, subroutineMaxStackDepth + 1); - src->addFmt("bool activeMaskStackCSub%04x[{}];" _CRLF, subroutineInfo.cfAddr, subroutineMaxStackDepth + 2); + src->addFmt("bool activeMaskStackSub{:04x}[{}];" _CRLF, subroutineInfo.cfAddr, subroutineMaxStackDepth + 1); + src->addFmt("bool activeMaskStackCSub{:04x}[{}];" _CRLF, subroutineInfo.cfAddr, subroutineMaxStackDepth + 2); } } // helper variables for cube maps (todo: Only emit when used) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 804d03cc..4061be33 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -335,6 +335,7 @@ void RendererShaderVk::CompileInternal(bool isRenderThread) if (!Shader.parse(&Resources, 100, false, messagesParseLink)) { cemuLog_log(LogType::Force, fmt::format("GLSL parsing failed for {:016x}_{:016x}: \"{}\"", m_baseHash, m_auxHash, Shader.getInfoLog())); + cemuLog_logDebug(LogType::Force, "GLSL source:\n{}", m_glslCode); cemu_assert_debug(false); FinishCompilation(); return; From 14dd7a72a7cb1a41e32b94c7bd32ef7dea418324 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 14 Sep 2023 19:46:54 +0200 Subject: [PATCH 015/314] Add coding style guidelines and clang-format file --- .clang-format | 65 ++++++++++++++++++++++++++++++++ CODING_STYLE.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 +++--- 3 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 .clang-format create mode 100644 CODING_STYLE.md diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..b22a1048 --- /dev/null +++ b/.clang-format @@ -0,0 +1,65 @@ +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: false +AllowShortLambdasOnASingleLine: Inline +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: true + AfterControlStatement: Always + AfterEnum: true + AfterExternBlock: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeElse: true + BeforeWhile: true + SplitEmptyFunction: false +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +ColumnLimit: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +Language: Cpp +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceBeforeCtorInitializerColon: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Latest +TabWidth: 4 +UseTab: Always diff --git a/CODING_STYLE.md b/CODING_STYLE.md new file mode 100644 index 00000000..26e11733 --- /dev/null +++ b/CODING_STYLE.md @@ -0,0 +1,98 @@ + +# Coding style guidelines for Cemu + +This document describes the latest version of our coding-style guidelines. Since we did not use this style from the beginning, older code may not adhere to these guidelines. Nevertheless, use these rules even if the surrounding code does not match. + +Cemu comes with a `.clang-format` file which is supported by most IDEs for formatting. Avoid auto-reformatting whole files, PRs with a lot of formatting changes are difficult to review. + +## Names for variables, functions and classes + +- Always prefix class member variables with `m_` +- Always prefix static class variables with `s_` +- For variable names: Camel case, starting with a lower case letter after the prefix. Examples: `m_option`, `s_audioVolume` +- For functions/class names: Use camel case starting with a capital letter. Examples: `MyClass`, `SetActive` +- Avoid underscores in variable names after the prefix. Use `m_myVariable` instead of `m_my_variable` + +## About types + +Cemu provides it's own set of basic fixed-width types. They are: +`uint8`, `sint8`, `uint16`, `sint16`, `uint32`, `sint32`, `uint64`, `sint64`. Always use these types over something like `uint32_t`. Using `size_t` is also acceptable where suitable. Avoid C types like `int` or `long`. The only exception is when interacting with external libraries which expect these types as parameters. + +## When and where to put brackets + +Always put curly-brackets (`{ }`) on their own line. Example: + +``` +void FooBar() +{ + if (m_hasFoo) + { + ... + } +} +``` +As an exception, you can put short lambdas onto the same line: +``` +SomeFunc([]() { .... }); +``` +You can skip brackets for single-statement `if`. Example: +``` +if (cond) + action(); +``` + +## Printing + +Avoid sprintf and similar C-style formatting API. Use `fmt::format()`. +In UI related code you can use `formatWxString`, but be aware that number formatting with this function will be locale dependent! + +## Strings and encoding + +We use UTF-8 encoded `std::string` where possible. Some conversations need special handling and we have helper functions for those: +```cpp +// std::filesystem::path <-> std::string (in precompiled.h) +std::string _pathToUtf8(const fs::path& path); +fs::path _utf8ToPath(std::string_view input); + +// wxString <-> std::string +wxString to_wxString(std::string_view str); // in gui/helpers.h +std::string wxString::utf8_string(); + +``` + +## Logging + +If you want to write to log.txt use `cemuLog_log()`. The log type parameter should be mostly self-explanatory. Use `LogType::Force` if you always want to log something. For example: +`cemuLog_log(LogType::Force, "The value is {}", 123);` + +## HLE and endianness + +A pretty large part of Cemu's code base are re-implementations of various Cafe OS modules (e.g. `coreinit.rpl`, `gx2.rpl`...). These generally run in the context of the emulated process, thus special care has to be taken to use types with the correct size and endianness when interacting with memory. + +Keep in mind that the emulated Espresso CPU is 32bit big-endian, while the host architectures targeted by Cemu are 64bit litte-endian! + +To keep code simple and remove the need for manual endian-swapping, Cemu has templates and aliases of the basic types with explicit endian-ness. +For big-endian types add the suffix `be`. Example: `uint32be` + +When you need to store a pointer in the guest's memory. Use `MEMPTR`. It will automatically store any pointer as 32bit big-endian. The pointer you store must point to memory that is within the guest address space. + +## HLE interfaces + +The implementation for each HLE module is inside a namespace with a matching name. E.g. `coreinit.rpl` functions go into `coreinit` namespace. + +To expose a new function as callable from within the emulated machine, use `cafeExportRegister` or `cafeExportRegisterFunc`. Here is a short example: +```cpp +namespace coreinit +{ + uint32 OSGetCoreCount() + { + return Espresso::CORE_COUNT; + } + + void Init() + { + cafeExportRegister("coreinit", OSGetCoreCount, LogType::CoreinitThread); + } +} +``` +You may also see some code which uses `osLib_addFunction` directly. This is a deprecated way of registering functions. \ No newline at end of file diff --git a/README.md b/README.md index 01eb46fe..e57cb483 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Matrix Server](https://img.shields.io/matrix/cemu:cemu.info?server_fqdn=matrix.cemu.info&label=cemu:cemu.info&logo=matrix&logoColor=FFFFFF)](https://matrix.to/#/#cemu:cemu.info) This is the code repository of Cemu, a Wii U emulator that is able to run most Wii U games and homebrew in a playable state. -It's written in C/C++ and is being actively developed with new features and fixes to increase compatibility, convenience and usability. +It's written in C/C++ and is being actively developed with new features and fixes. Cemu is currently only available for 64-bit Windows, Linux & macOS devices. @@ -24,11 +24,9 @@ Cemu is currently only available for 64-bit Windows, Linux & macOS devices. ## Download -You can download the latest Cemu releases from the [GitHub Releases](https://github.com/cemu-project/Cemu/releases/) or from [Cemu's website](https://cemu.info). +You can download the latest Cemu releases for Windows, Linux and Mac from the [GitHub Releases](https://github.com/cemu-project/Cemu/releases/). For Linux you can also find Cemu on [flathub](https://flathub.org/apps/info.cemu.Cemu). -Cemu is currently only available in a portable format so no installation is required besides extracting it in a safe place. - -The native Linux build is currently a work-in-progress. See [Current State Of Linux builds](https://github.com/cemu-project/Cemu/issues/107) for more information about the things to be aware of. +On Windows Cemu is currently only available in a portable format so no installation is required besides extracting it in a safe place. The native macOS build is currently purely experimental and should not be considered stable or ready for issue-free gameplay. There are also known issues with degraded performance due to the use of MoltenVK and Rosetta for ARM Macs. We appreciate your patience while we improve Cemu for macOS. @@ -36,7 +34,7 @@ Pre-2.0 releases can be found on Cemu's [changelog page](https://cemu.info/chang ## Build Instructions -To compile Cemu yourself on Windows, Linux or macOS, view the [BUILD.md file](/BUILD.md). +To compile Cemu yourself on Windows, Linux or macOS, view [BUILD.md](/BUILD.md). ## Issues @@ -46,6 +44,7 @@ The old bug tracker can be found at [bugs.cemu.info](https://bugs.cemu.info) and ## Contributing Pull requests are very welcome. For easier coordination you can visit the developer discussion channel on [Discord](https://discord.gg/5psYsup) or alternatively the [Matrix Server](https://matrix.to/#/#cemu:cemu.info). +Before submitting a pull request, please read and follow our code style guidelines listed in [CODING_STYLE.md](/CODING_STYLE.md). If coding isn't your thing, testing games and making detailed bug reports or updating the (usually outdated) compatibility wiki is also appreciated! From 2a735f1fb72367ce72a6fae9a6034dd7ab979a2c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:22:54 +0200 Subject: [PATCH 016/314] coreinit: Use native COS locks instead of STL --- src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 17 +++++++++-------- src/Cafe/OS/libs/coreinit/coreinit_FS.h | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index 26636eae..a2f59d4d 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -42,17 +42,16 @@ bool strcpy_whole(char* dst, size_t dstLength, const char* src) namespace coreinit { - std::mutex sFSClientLock; - std::recursive_mutex sFSGlobalMutex; + SysAllocator s_fsGlobalMutex; inline void FSLockMutex() { - sFSGlobalMutex.lock(); + OSLockMutex(&s_fsGlobalMutex); } inline void FSUnlockMutex() { - sFSGlobalMutex.unlock(); + OSUnlockMutex(&s_fsGlobalMutex); } void _debugVerifyCommand(const char* stage, FSCmdBlockBody_t* fsCmdBlockBody); @@ -251,7 +250,7 @@ namespace coreinit fsCmdQueueBE->dequeueHandlerFuncMPTR = _swapEndianU32(dequeueHandlerFuncMPTR); fsCmdQueueBE->numCommandsInFlight = 0; fsCmdQueueBE->numMaxCommandsInFlight = numMaxCommandsInFlight; - coreinit::OSInitMutexEx(&fsCmdQueueBE->mutex, nullptr); + coreinit::OSFastMutex_Init(&fsCmdQueueBE->fastMutex, nullptr); fsCmdQueueBE->firstMPTR = _swapEndianU32(0); fsCmdQueueBE->lastMPTR = _swapEndianU32(0); } @@ -672,12 +671,12 @@ namespace coreinit _debugVerifyCommand("FSCmdSubmitResult", fsCmdBlockBody); FSClientBody_t* fsClientBody = fsCmdBlockBody->fsClientBody.GetPtr(); - sFSClientLock.lock(); // OSFastMutex_Lock(&fsClientBody->fsCmdQueue.mutex) + OSFastMutex_Lock(&fsClientBody->fsCmdQueue.fastMutex); fsCmdBlockBody->cancelState &= ~(1 << 0); // clear cancel bit if (fsClientBody->currentCmdBlockBody.GetPtr() == fsCmdBlockBody) fsClientBody->currentCmdBlockBody = nullptr; fsCmdBlockBody->statusCode = _swapEndianU32(FSA_CMD_STATUS_CODE_D900A24); - sFSClientLock.unlock(); + OSFastMutex_Unlock(&fsClientBody->fsCmdQueue.fastMutex); // send result via msg queue or callback cemu_assert_debug(!fsCmdBlockBody->asyncResult.fsAsyncParamsNew.ioMsgQueue != !fsCmdBlockBody->asyncResult.fsAsyncParamsNew.userCallback); // either must be set fsCmdBlockBody->ukn09EA = 0; @@ -1433,7 +1432,7 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask) + sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask) { StackAllocator asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); @@ -2640,6 +2639,8 @@ namespace coreinit void InitializeFS() { + OSInitMutex(&s_fsGlobalMutex); + cafeExportRegister("coreinit", FSInit, LogType::CoreinitFile); cafeExportRegister("coreinit", FSShutdown, LogType::CoreinitFile); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.h b/src/Cafe/OS/libs/coreinit/coreinit_FS.h index 0355c9aa..2a57f7da 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.h @@ -42,7 +42,7 @@ namespace coreinit /* +0x00 */ MPTR firstMPTR; /* +0x04 */ MPTR lastMPTR; - /* +0x08 */ OSMutex mutex; + /* +0x08 */ OSFastMutex fastMutex; /* +0x34 */ MPTR dequeueHandlerFuncMPTR; /* +0x38 */ uint32be numCommandsInFlight; /* +0x3C */ uint32 numMaxCommandsInFlight; @@ -50,6 +50,8 @@ namespace coreinit }; DEFINE_ENUM_FLAG_OPERATORS(FSCmdQueue::QUEUE_FLAG); + static_assert(sizeof(FSCmdQueue) == 0x44); + #define FS_CLIENT_BUFFER_SIZE (5888) #define FS_CMD_BLOCK_SIZE (2688) From 98b5a8758ab30bb4d04ab99143737b48a43aa71f Mon Sep 17 00:00:00 2001 From: Simon <113838661+ssievert42@users.noreply.github.com> Date: Tue, 19 Sep 2023 01:27:40 +0200 Subject: [PATCH 017/314] nsyshid: Add backends for cross platform USB passthrough support (#950) --- .github/workflows/build.yml | 2 +- BUILD.md | 2 +- CMakeLists.txt | 17 + cmake/Findlibusb.cmake | 20 + src/Cafe/CMakeLists.txt | 19 + .../OS/libs/nsyshid/AttachDefaultBackends.cpp | 41 + src/Cafe/OS/libs/nsyshid/Backend.h | 141 +++ src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 791 +++++++++++++ src/Cafe/OS/libs/nsyshid/BackendLibusb.h | 129 ++ .../OS/libs/nsyshid/BackendWindowsHID.cpp | 454 +++++++ src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h | 66 ++ src/Cafe/OS/libs/nsyshid/Whitelist.cpp | 53 + src/Cafe/OS/libs/nsyshid/Whitelist.h | 32 + src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 1040 ++++++++--------- src/Cafe/OS/libs/nsyshid/nsyshid.h | 9 +- .../api/Wiimote/windows/WinWiimoteDevice.cpp | 3 + vcpkg.json | 3 +- 17 files changed, 2298 insertions(+), 524 deletions(-) create mode 100644 cmake/Findlibusb.cmake create mode 100644 src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/Backend.h create mode 100644 src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/BackendLibusb.h create mode 100644 src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h create mode 100644 src/Cafe/OS/libs/nsyshid/Whitelist.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/Whitelist.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a91d562b..eb6ac099 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -232,7 +232,7 @@ jobs: - name: "Install system dependencies" run: | brew update - brew install llvm@15 ninja nasm molten-vk + brew install llvm@15 ninja nasm molten-vk automake libtool - name: "Bootstrap vcpkg" run: | diff --git a/BUILD.md b/BUILD.md index 5ff9bfd5..da6c03ce 100644 --- a/BUILD.md +++ b/BUILD.md @@ -86,7 +86,7 @@ You can skip this section if you have an Intel Mac. Every time you compile, you ### Installing dependencies -`brew install boost git cmake llvm ninja nasm molten-vk` +`brew install boost git cmake llvm ninja nasm molten-vk automake libtool` ### Build Cemu using cmake and clang 1. `git clone --recursive https://github.com/cemu-project/Cemu` diff --git a/CMakeLists.txt b/CMakeLists.txt index 34a28a06..a5749acb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,23 @@ if (WIN32) endif() option(ENABLE_CUBEB "Enabled cubeb backend" ON) +# usb hid backends +if (WIN32) + option(ENABLE_NSYSHID_WINDOWS_HID "Enables the native Windows HID backend for nsyshid" ON) +endif () +# libusb and windows hid backends shouldn't be active at the same time; otherwise we'd see all devices twice! +if (NOT ENABLE_NSYSHID_WINDOWS_HID) + option(ENABLE_NSYSHID_LIBUSB "Enables the libusb backend for nsyshid" ON) +else () + set(ENABLE_NSYSHID_LIBUSB OFF CACHE BOOL "" FORCE) +endif () +if (ENABLE_NSYSHID_WINDOWS_HID) + add_compile_definitions(NSYSHID_ENABLE_BACKEND_WINDOWS_HID) +endif () +if (ENABLE_NSYSHID_LIBUSB) + add_compile_definitions(NSYSHID_ENABLE_BACKEND_LIBUSB) +endif () + option(ENABLE_WXWIDGETS "Build with wxWidgets UI (Currently required)" ON) set(THREADS_PREFER_PTHREAD_FLAG true) diff --git a/cmake/Findlibusb.cmake b/cmake/Findlibusb.cmake new file mode 100644 index 00000000..85da6736 --- /dev/null +++ b/cmake/Findlibusb.cmake @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-License-Identifier: ISC + +find_package(libusb CONFIG) +if (NOT libusb_FOUND) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_search_module(libusb IMPORTED_TARGET GLOBAL libusb-1.0 libusb) + if (libusb_FOUND) + add_library(libusb::libusb ALIAS PkgConfig::libusb) + endif () + endif () +endif () + +find_package_handle_standard_args(libusb + REQUIRED_VARS + libusb_LINK_LIBRARIES + libusb_FOUND + VERSION_VAR libusb_VERSION +) diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index b7656789..29c5a0b3 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -434,6 +434,14 @@ add_library(CemuCafe OS/libs/nn_uds/nn_uds.h OS/libs/nsyshid/nsyshid.cpp OS/libs/nsyshid/nsyshid.h + OS/libs/nsyshid/Backend.h + OS/libs/nsyshid/AttachDefaultBackends.cpp + OS/libs/nsyshid/Whitelist.cpp + OS/libs/nsyshid/Whitelist.h + OS/libs/nsyshid/BackendLibusb.cpp + OS/libs/nsyshid/BackendLibusb.h + OS/libs/nsyshid/BackendWindowsHID.cpp + OS/libs/nsyshid/BackendWindowsHID.h OS/libs/nsyskbd/nsyskbd.cpp OS/libs/nsyskbd/nsyskbd.h OS/libs/nsysnet/nsysnet.cpp @@ -524,6 +532,17 @@ if (ENABLE_WAYLAND) target_link_libraries(CemuCafe PUBLIC Wayland::Client) endif() +if (ENABLE_NSYSHID_LIBUSB) + if (ENABLE_VCPKG) + find_package(libusb CONFIG REQUIRED) + target_include_directories(CemuCafe PRIVATE ${LIBUSB_INCLUDE_DIRS}) + target_link_libraries(CemuCafe PRIVATE ${LIBUSB_LIBRARIES}) + else () + find_package(libusb MODULE REQUIRED) + target_link_libraries(CemuCafe PRIVATE libusb::libusb) + endif () +endif () + if (ENABLE_WXWIDGETS) target_link_libraries(CemuCafe PRIVATE wx::base wx::core) endif() diff --git a/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp new file mode 100644 index 00000000..6e6cb123 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp @@ -0,0 +1,41 @@ +#include "nsyshid.h" +#include "Backend.h" + +#if NSYSHID_ENABLE_BACKEND_LIBUSB + +#include "BackendLibusb.h" + +#endif + +#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID + +#include "BackendWindowsHID.h" + +#endif + +namespace nsyshid::backend +{ + void AttachDefaultBackends() + { +#if NSYSHID_ENABLE_BACKEND_LIBUSB + // add libusb backend + { + auto backendLibusb = std::make_shared(); + if (backendLibusb->IsInitialisedOk()) + { + AttachBackend(backendLibusb); + } + } +#endif // NSYSHID_ENABLE_BACKEND_LIBUSB +#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID + // add windows hid backend + { + auto backendWindowsHID = std::make_shared(); + if (backendWindowsHID->IsInitialisedOk()) + { + AttachBackend(backendWindowsHID); + } + } +#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID + } +} // namespace nsyshid::backend diff --git a/src/Cafe/OS/libs/nsyshid/Backend.h b/src/Cafe/OS/libs/nsyshid/Backend.h new file mode 100644 index 00000000..641104f5 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Backend.h @@ -0,0 +1,141 @@ +#ifndef CEMU_NSYSHID_BACKEND_H +#define CEMU_NSYSHID_BACKEND_H + +#include +#include +#include + +#include "Common/precompiled.h" + +namespace nsyshid +{ + typedef struct + { + /* +0x00 */ uint32be handle; + /* +0x04 */ uint32 ukn04; + /* +0x08 */ uint16 vendorId; // little-endian ? + /* +0x0A */ uint16 productId; // little-endian ? + /* +0x0C */ uint8 ifIndex; + /* +0x0D */ uint8 subClass; + /* +0x0E */ uint8 protocol; + /* +0x0F */ uint8 paddingGuessed0F; + /* +0x10 */ uint16be maxPacketSizeRX; + /* +0x12 */ uint16be maxPacketSizeTX; + } HID_t; + + static_assert(offsetof(HID_t, vendorId) == 0x8, ""); + static_assert(offsetof(HID_t, productId) == 0xA, ""); + static_assert(offsetof(HID_t, ifIndex) == 0xC, ""); + static_assert(offsetof(HID_t, protocol) == 0xE, ""); + + class Device { + public: + Device() = delete; + + Device(uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol); + + Device(const Device& device) = delete; + + Device& operator=(const Device& device) = delete; + + virtual ~Device() = default; + + HID_t* m_hid; // this info is passed to applications and must remain intact + + uint16 m_vendorId; + uint16 m_productId; + uint8 m_interfaceIndex; + uint8 m_interfaceSubClass; + uint8 m_protocol; + uint16 m_maxPacketSizeRX; + uint16 m_maxPacketSizeTX; + + virtual void AssignHID(HID_t* hid); + + virtual bool Open() = 0; + + virtual void Close() = 0; + + virtual bool IsOpened() = 0; + + enum class ReadResult + { + Success, + Error, + ErrorTimeout, + }; + + virtual ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) = 0; + + enum class WriteResult + { + Success, + Error, + ErrorTimeout, + }; + + virtual WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) = 0; + + virtual bool GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) = 0; + + virtual bool SetProtocol(uint32 ifIndef, uint32 protocol) = 0; + + virtual bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) = 0; + }; + + class Backend { + public: + Backend(); + + Backend(const Backend& backend) = delete; + + Backend& operator=(const Backend& backend) = delete; + + virtual ~Backend() = default; + + void DetachAllDevices(); + + // called from nsyshid when this backend is attached - do not call this yourself! + void OnAttach(); + + // called from nsyshid when this backend is detached - do not call this yourself! + void OnDetach(); + + bool IsBackendAttached(); + + virtual bool IsInitialisedOk() = 0; + + protected: + // try to attach a device - only works if this backend is attached + bool AttachDevice(const std::shared_ptr& device); + + void DetachDevice(const std::shared_ptr& device); + + std::shared_ptr FindDevice(std::function&)> isWantedDevice); + + bool IsDeviceWhitelisted(uint16 vendorId, uint16 productId); + + // called from OnAttach() - attach devices that your backend can see here + virtual void AttachVisibleDevices() = 0; + + private: + std::list> m_devices; + std::recursive_mutex m_devicesMutex; + bool m_isAttached; + }; + + namespace backend + { + void AttachDefaultBackends(); + } +} // namespace nsyshid + +#endif // CEMU_NSYSHID_BACKEND_H diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp new file mode 100644 index 00000000..4f88b7ed --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -0,0 +1,791 @@ +#include "BackendLibusb.h" + +#if NSYSHID_ENABLE_BACKEND_LIBUSB + +namespace nsyshid::backend::libusb +{ + BackendLibusb::BackendLibusb() + : m_ctx(nullptr), + m_initReturnCode(0), + m_callbackRegistered(false), + m_hotplugCallbackHandle(0), + m_hotplugThreadStop(false) + { + m_initReturnCode = libusb_init(&m_ctx); + if (m_initReturnCode < 0) + { + m_ctx = nullptr; + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: failed to initialize libusb with return code %i", + m_initReturnCode); + return; + } + + if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) + { + int ret = libusb_hotplug_register_callback(m_ctx, + (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | + LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), + (libusb_hotplug_flag)0, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + HotplugCallback, + this, + &m_hotplugCallbackHandle); + if (ret != LIBUSB_SUCCESS) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::BackendLibusb: failed to register hotplug callback with return code %i", + ret); + } + else + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: registered hotplug callback"); + m_callbackRegistered = true; + m_hotplugThread = std::thread([this] { + while (!m_hotplugThreadStop) + { + timeval timeout{ + .tv_sec = 1, + .tv_usec = 0, + }; + int ret = libusb_handle_events_timeout_completed(m_ctx, &timeout, nullptr); + if (ret != 0) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::BackendLibusb: hotplug thread: error handling events: {}", + ret); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + } + } + }); + } + } + else + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: hotplug not supported by this version of libusb"); + } + } + + bool BackendLibusb::IsInitialisedOk() + { + return m_initReturnCode == 0; + } + + void BackendLibusb::AttachVisibleDevices() + { + // add all currently connected devices + libusb_device** devices; + ssize_t deviceCount = libusb_get_device_list(m_ctx, &devices); + if (deviceCount < 0) + { + cemuLog_log(LogType::Force, "nsyshid::BackendLibusb: failed to get usb devices"); + return; + } + libusb_device* dev; + for (int i = 0; (dev = devices[i]) != nullptr; i++) + { + auto device = CheckAndCreateDevice(dev); + if (device != nullptr) + { + if (IsDeviceWhitelisted(device->m_vendorId, device->m_productId)) + { + if (!AttachDevice(device)) + { + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb: failed to attach device: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + else + { + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb: device not on whitelist: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + } + + libusb_free_device_list(devices, 1); + } + + int BackendLibusb::HotplugCallback(libusb_context* ctx, + libusb_device* dev, + libusb_hotplug_event event, + void* user_data) + { + if (user_data) + { + BackendLibusb* backend = static_cast(user_data); + return backend->OnHotplug(dev, event); + } + return 0; + } + + int BackendLibusb::OnHotplug(libusb_device* dev, libusb_hotplug_event event) + { + struct libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb::OnHotplug(): failed to get device descriptor"); + return 0; + } + + switch (event) + { + case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb::OnHotplug(): device arrived: {:04x}:{:04x}", + desc.idVendor, + desc.idProduct); + auto device = CheckAndCreateDevice(dev); + if (device != nullptr) + { + if (IsDeviceWhitelisted(device->m_vendorId, device->m_productId)) + { + if (!AttachDevice(device)) + { + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb::OnHotplug(): failed to attach device: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + else + { + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb::OnHotplug(): device not on whitelist: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + } + break; + case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb::OnHotplug(): device left: {:04x}:{:04x}", + desc.idVendor, + desc.idProduct); + auto device = FindLibusbDevice(dev); + if (device != nullptr) + { + DetachDevice(device); + } + } + break; + } + + return 0; + } + + BackendLibusb::~BackendLibusb() + { + if (m_callbackRegistered) + { + m_hotplugThreadStop = true; + libusb_hotplug_deregister_callback(m_ctx, m_hotplugCallbackHandle); + m_hotplugThread.join(); + } + DetachAllDevices(); + if (m_ctx) + { + libusb_exit(m_ctx); + m_ctx = nullptr; + } + } + + std::shared_ptr BackendLibusb::FindLibusbDevice(libusb_device* dev) + { + libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::BackendLibusb::FindLibusbDevice(): failed to get device descriptor"); + return nullptr; + } + uint8 busNumber = libusb_get_bus_number(dev); + uint8 deviceAddress = libusb_get_device_address(dev); + auto device = FindDevice([desc, busNumber, deviceAddress](const std::shared_ptr& d) -> bool { + auto device = std::dynamic_pointer_cast(d); + if (device != nullptr && + desc.idVendor == device->m_vendorId && + desc.idProduct == device->m_productId && + busNumber == device->m_libusbBusNumber && + deviceAddress == device->m_libusbDeviceAddress) + { + // we found our device! + return true; + } + return false; + }); + + if (device != nullptr) + { + return device; + } + return nullptr; + } + + std::shared_ptr BackendLibusb::CheckAndCreateDevice(libusb_device* dev) + { + struct libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) + { + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb::CheckAndCreateDevice(): failed to get device descriptor; return code: %i", + ret); + return nullptr; + } + if (desc.idVendor == 0x0e6f && desc.idProduct == 0x0241) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::BackendLibusb::CheckAndCreateDevice(): lego dimensions portal detected"); + } + auto device = std::make_shared(m_ctx, + desc.idVendor, + desc.idProduct, + 1, + 2, + 0, + libusb_get_bus_number(dev), + libusb_get_device_address(dev)); + // figure out device endpoints + if (!FindDefaultDeviceEndpoints(dev, + device->m_libusbHasEndpointIn, + device->m_libusbEndpointIn, + device->m_maxPacketSizeRX, + device->m_libusbHasEndpointOut, + device->m_libusbEndpointOut, + device->m_maxPacketSizeTX)) + { + // most likely couldn't read config descriptor + cemuLog_log(LogType::Force, + "nsyshid::BackendLibusb::CheckAndCreateDevice(): failed to find default endpoints for device: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + return nullptr; + } + return device; + } + + bool BackendLibusb::FindDefaultDeviceEndpoints(libusb_device* dev, bool& endpointInFound, uint8& endpointIn, + uint16& endpointInMaxPacketSize, bool& endpointOutFound, + uint8& endpointOut, uint16& endpointOutMaxPacketSize) + { + endpointInFound = false; + endpointIn = 0; + endpointInMaxPacketSize = 0; + endpointOutFound = false; + endpointOut = 0; + endpointOutMaxPacketSize = 0; + + struct libusb_config_descriptor* conf = nullptr; + int ret = libusb_get_active_config_descriptor(dev, &conf); + + if (ret == 0) + { + for (uint8 interfaceIndex = 0; interfaceIndex < conf->bNumInterfaces; interfaceIndex++) + { + const struct libusb_interface& interface = conf->interface[interfaceIndex]; + for (int altsettingIndex = 0; altsettingIndex < interface.num_altsetting; altsettingIndex++) + { + const struct libusb_interface_descriptor& altsetting = interface.altsetting[altsettingIndex]; + for (uint8 endpointIndex = 0; endpointIndex < altsetting.bNumEndpoints; endpointIndex++) + { + const struct libusb_endpoint_descriptor& endpoint = altsetting.endpoint[endpointIndex]; + // figure out direction + if ((endpoint.bEndpointAddress & (1 << 7)) != 0) + { + // in + if (!endpointInFound) + { + endpointInFound = true; + endpointIn = endpoint.bEndpointAddress; + endpointInMaxPacketSize = endpoint.wMaxPacketSize; + } + } + else + { + // out + if (!endpointOutFound) + { + endpointOutFound = true; + endpointOut = endpoint.bEndpointAddress; + endpointOutMaxPacketSize = endpoint.wMaxPacketSize; + } + } + } + } + } + libusb_free_config_descriptor(conf); + return true; + } + return false; + } + + DeviceLibusb::DeviceLibusb(libusb_context* ctx, + uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol, + uint8 libusbBusNumber, + uint8 libusbDeviceAddress) + : Device(vendorId, + productId, + interfaceIndex, + interfaceSubClass, + protocol), + m_ctx(ctx), + m_libusbHandle(nullptr), + m_handleInUseCounter(-1), + m_libusbBusNumber(libusbBusNumber), + m_libusbDeviceAddress(libusbDeviceAddress), + m_libusbHasEndpointIn(false), + m_libusbEndpointIn(0), + m_libusbHasEndpointOut(false), + m_libusbEndpointOut(0) + { + } + + DeviceLibusb::~DeviceLibusb() + { + CloseDevice(); + } + + bool DeviceLibusb::Open() + { + std::unique_lock lock(m_handleMutex); + if (IsOpened()) + { + return true; + } + // we may still be in the process of closing the device; wait for that to finish + while (m_handleInUseCounter != -1) + { + m_handleInUseCounterDecremented.wait(lock); + } + + libusb_device** devices; + ssize_t deviceCount = libusb_get_device_list(m_ctx, &devices); + if (deviceCount < 0) + { + cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::open(): failed to get usb devices"); + return false; + } + libusb_device* dev; + libusb_device* found = nullptr; + for (int i = 0; (dev = devices[i]) != nullptr; i++) + { + struct libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) + { + cemuLog_log(LogType::Force, + "nsyshid::DeviceLibusb::open(): failed to get device descriptor; return code: %i", + ret); + libusb_free_device_list(devices, 1); + return false; + } + if (desc.idVendor == this->m_vendorId && + desc.idProduct == this->m_productId && + libusb_get_bus_number(dev) == this->m_libusbBusNumber && + libusb_get_device_address(dev) == this->m_libusbDeviceAddress) + { + // we found our device! + found = dev; + break; + } + } + + if (found != nullptr) + { + { + int ret = libusb_open(dev, &(this->m_libusbHandle)); + if (ret < 0) + { + this->m_libusbHandle = nullptr; + cemuLog_log(LogType::Force, + "nsyshid::DeviceLibusb::open(): failed to open device; return code: %i", + ret); + libusb_free_device_list(devices, 1); + return false; + } + this->m_handleInUseCounter = 0; + } + if (libusb_kernel_driver_active(this->m_libusbHandle, 0) == 1) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): kernel driver active"); + if (libusb_detach_kernel_driver(this->m_libusbHandle, 0) == 0) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): kernel driver detached"); + } + else + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): failed to detach kernel driver"); + } + } + { + int ret = libusb_claim_interface(this->m_libusbHandle, 0); + if (ret != 0) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): cannot claim interface"); + } + } + } + + libusb_free_device_list(devices, 1); + return found != nullptr; + } + + void DeviceLibusb::Close() + { + CloseDevice(); + } + + void DeviceLibusb::CloseDevice() + { + std::unique_lock lock(m_handleMutex); + if (IsOpened()) + { + auto handle = m_libusbHandle; + m_libusbHandle = nullptr; + while (m_handleInUseCounter > 0) + { + m_handleInUseCounterDecremented.wait(lock); + } + libusb_release_interface(handle, 0); + libusb_close(handle); + m_handleInUseCounter = -1; + m_handleInUseCounterDecremented.notify_all(); + } + } + + bool DeviceLibusb::IsOpened() + { + return m_libusbHandle != nullptr && m_handleInUseCounter >= 0; + } + + Device::ReadResult DeviceLibusb::Read(uint8* data, sint32 length, sint32& bytesRead) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::read(): cannot read from a non-opened device\n"); + return ReadResult::Error; + } + + const unsigned int timeout = 50; + int actualLength = 0; + int ret = 0; + do + { + ret = libusb_bulk_transfer(handleLock->GetHandle(), + this->m_libusbEndpointIn, + data, + length, + &actualLength, + timeout); + } + while (ret == LIBUSB_ERROR_TIMEOUT && actualLength == 0 && IsOpened()); + + if (ret == 0 || ret == LIBUSB_ERROR_TIMEOUT) + { + // success + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::read(): read {} of {} bytes", + actualLength, + length); + bytesRead = actualLength; + return ReadResult::Success; + } + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::read(): failed with error code: {}", + ret); + return ReadResult::Error; + } + + Device::WriteResult DeviceLibusb::Write(uint8* data, sint32 length, sint32& bytesWritten) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::write(): cannot write to a non-opened device\n"); + return WriteResult::Error; + } + + bytesWritten = 0; + int actualLength = 0; + int ret = libusb_bulk_transfer(handleLock->GetHandle(), + this->m_libusbEndpointOut, + data, + length, + &actualLength, + 0); + + if (ret == 0) + { + // success + bytesWritten = actualLength; + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::write(): wrote {} of {} bytes", + bytesWritten, + length); + return WriteResult::Success; + } + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::write(): failed with error code: {}", + ret); + return WriteResult::Error; + } + + bool DeviceLibusb::GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::getDescriptor(): device is not opened"); + return false; + } + + if (descType == 0x02) + { + struct libusb_config_descriptor* conf = nullptr; + libusb_device* dev = libusb_get_device(handleLock->GetHandle()); + int ret = libusb_get_active_config_descriptor(dev, &conf); + + if (ret == 0) + { + std::vector configurationDescriptor(conf->wTotalLength); + uint8* currentWritePtr = &configurationDescriptor[0]; + + // configuration descriptor + cemu_assert_debug(conf->bLength == LIBUSB_DT_CONFIG_SIZE); + *(uint8*)(currentWritePtr + 0) = conf->bLength; // bLength + *(uint8*)(currentWritePtr + 1) = conf->bDescriptorType; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = conf->wTotalLength; // wTotalLength + *(uint8*)(currentWritePtr + 4) = conf->bNumInterfaces; // bNumInterfaces + *(uint8*)(currentWritePtr + 5) = conf->bConfigurationValue; // bConfigurationValue + *(uint8*)(currentWritePtr + 6) = conf->iConfiguration; // iConfiguration + *(uint8*)(currentWritePtr + 7) = conf->bmAttributes; // bmAttributes + *(uint8*)(currentWritePtr + 8) = conf->MaxPower; // MaxPower + currentWritePtr = currentWritePtr + conf->bLength; + + for (uint8_t interfaceIndex = 0; interfaceIndex < conf->bNumInterfaces; interfaceIndex++) + { + const struct libusb_interface& interface = conf->interface[interfaceIndex]; + for (int altsettingIndex = 0; altsettingIndex < interface.num_altsetting; altsettingIndex++) + { + // interface descriptor + const struct libusb_interface_descriptor& altsetting = interface.altsetting[altsettingIndex]; + cemu_assert_debug(altsetting.bLength == LIBUSB_DT_INTERFACE_SIZE); + *(uint8*)(currentWritePtr + 0) = altsetting.bLength; // bLength + *(uint8*)(currentWritePtr + 1) = altsetting.bDescriptorType; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = altsetting.bInterfaceNumber; // bInterfaceNumber + *(uint8*)(currentWritePtr + 3) = altsetting.bAlternateSetting; // bAlternateSetting + *(uint8*)(currentWritePtr + 4) = altsetting.bNumEndpoints; // bNumEndpoints + *(uint8*)(currentWritePtr + 5) = altsetting.bInterfaceClass; // bInterfaceClass + *(uint8*)(currentWritePtr + 6) = altsetting.bInterfaceSubClass; // bInterfaceSubClass + *(uint8*)(currentWritePtr + 7) = altsetting.bInterfaceProtocol; // bInterfaceProtocol + *(uint8*)(currentWritePtr + 8) = altsetting.iInterface; // iInterface + currentWritePtr = currentWritePtr + altsetting.bLength; + + if (altsetting.extra_length > 0) + { + // unknown descriptors - copy the ones that we can identify ourselves + const unsigned char* extraReadPointer = altsetting.extra; + while (extraReadPointer - altsetting.extra < altsetting.extra_length) + { + uint8 bLength = *(uint8*)(extraReadPointer + 0); + if (bLength == 0) + { + // prevent endless loop + break; + } + if (extraReadPointer + bLength - altsetting.extra > altsetting.extra_length) + { + // prevent out of bounds read + break; + } + uint8 bDescriptorType = *(uint8*)(extraReadPointer + 1); + // HID descriptor + if (bDescriptorType == LIBUSB_DT_HID && bLength == 9) + { + *(uint8*)(currentWritePtr + 0) = + *(uint8*)(extraReadPointer + 0); // bLength + *(uint8*)(currentWritePtr + 1) = + *(uint8*)(extraReadPointer + 1); // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = + *(uint16*)(extraReadPointer + 2); // bcdHID + *(uint8*)(currentWritePtr + 4) = + *(uint8*)(extraReadPointer + 4); // bCountryCode + *(uint8*)(currentWritePtr + 5) = + *(uint8*)(extraReadPointer + 5); // bNumDescriptors + *(uint8*)(currentWritePtr + 6) = + *(uint8*)(extraReadPointer + 6); // bDescriptorType + *(uint16be*)(currentWritePtr + 7) = + *(uint16*)(extraReadPointer + 7); // wDescriptorLength + currentWritePtr += bLength; + } + extraReadPointer += bLength; + } + } + + for (int endpointIndex = 0; endpointIndex < altsetting.bNumEndpoints; endpointIndex++) + { + // endpoint descriptor + const struct libusb_endpoint_descriptor& endpoint = altsetting.endpoint[endpointIndex]; + cemu_assert_debug(endpoint.bLength == LIBUSB_DT_ENDPOINT_SIZE || + endpoint.bLength == LIBUSB_DT_ENDPOINT_AUDIO_SIZE); + *(uint8*)(currentWritePtr + 0) = endpoint.bLength; + *(uint8*)(currentWritePtr + 1) = endpoint.bDescriptorType; + *(uint8*)(currentWritePtr + 2) = endpoint.bEndpointAddress; + *(uint8*)(currentWritePtr + 3) = endpoint.bmAttributes; + *(uint16be*)(currentWritePtr + 4) = endpoint.wMaxPacketSize; + *(uint8*)(currentWritePtr + 6) = endpoint.bInterval; + if (endpoint.bLength == LIBUSB_DT_ENDPOINT_AUDIO_SIZE) + { + *(uint8*)(currentWritePtr + 7) = endpoint.bRefresh; + *(uint8*)(currentWritePtr + 8) = endpoint.bSynchAddress; + } + currentWritePtr += endpoint.bLength; + } + } + } + uint32 bytesWritten = currentWritePtr - &configurationDescriptor[0]; + libusb_free_config_descriptor(conf); + cemu_assert_debug(bytesWritten <= conf->wTotalLength); + + memcpy(output, &configurationDescriptor[0], + std::min(outputMaxLength, bytesWritten)); + return true; + } + else + { + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::getDescriptor(): failed to get config descriptor with error code: {}", + ret); + return false; + } + } + else + { + cemu_assert_unimplemented(); + } + return false; + } + + bool DeviceLibusb::SetProtocol(uint32 ifIndex, uint32 protocol) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetProtocol(): device is not opened"); + return false; + } + + // ToDo: implement this +#if 0 + // is this correct? Discarding "ifIndex" seems like a bad idea + int ret = libusb_set_configuration(handleLock->getHandle(), protocol); + if (ret == 0) { + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::setProtocol(): success"); + return true; + } + cemuLog_logDebug(LogType::Force, + "nsyshid::DeviceLibusb::setProtocol(): failed with error code: {}", + ret); + return false; +#endif + + // pretend that everything is fine + return true; + } + + bool DeviceLibusb::SetReport(uint8* reportData, sint32 length, uint8* originalData, + sint32 originalLength) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): device is not opened"); + return false; + } + + // ToDo: implement this +#if 0 + // not sure if libusb_control_transfer() is the right candidate for this + int ret = libusb_control_transfer(handleLock->getHandle(), + bmRequestType, + bRequest, + wValue, + wIndex, + reportData, + length, + timeout); +#endif + + // pretend that everything is fine + return true; + } + + std::unique_ptr DeviceLibusb::AquireHandleLock() + { + return std::make_unique(&m_libusbHandle, + m_handleMutex, + m_handleInUseCounter, + m_handleInUseCounterDecremented, + *this); + } + + DeviceLibusb::HandleLock::HandleLock(libusb_device_handle** handle, + std::mutex& handleMutex, + std::atomic& handleInUseCounter, + std::condition_variable& handleInUseCounterDecremented, + DeviceLibusb& device) + : m_handle(nullptr), + m_handleMutex(handleMutex), + m_handleInUseCounter(handleInUseCounter), + m_handleInUseCounterDecremented(handleInUseCounterDecremented) + { + std::lock_guard lock(handleMutex); + if (device.IsOpened() && handle != nullptr && handleInUseCounter >= 0) + { + this->m_handle = *handle; + this->m_handleInUseCounter++; + } + } + + DeviceLibusb::HandleLock::~HandleLock() + { + if (IsValid()) + { + std::lock_guard lock(m_handleMutex); + m_handleInUseCounter--; + m_handleInUseCounterDecremented.notify_all(); + } + } + + bool DeviceLibusb::HandleLock::IsValid() + { + return m_handle != nullptr; + } + + libusb_device_handle* DeviceLibusb::HandleLock::GetHandle() + { + return m_handle; + } +} // namespace nsyshid::backend::libusb + +#endif // NSYSHID_ENABLE_BACKEND_LIBUSB diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h new file mode 100644 index 00000000..216be6ce --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h @@ -0,0 +1,129 @@ +#ifndef CEMU_NSYSHID_BACKEND_LIBUSB_H +#define CEMU_NSYSHID_BACKEND_LIBUSB_H + +#include "nsyshid.h" + +#if NSYSHID_ENABLE_BACKEND_LIBUSB + +#include +#include "Backend.h" + +namespace nsyshid::backend::libusb +{ + class BackendLibusb : public nsyshid::Backend { + public: + BackendLibusb(); + + ~BackendLibusb(); + + bool IsInitialisedOk() override; + + protected: + void AttachVisibleDevices() override; + + private: + libusb_context* m_ctx; + int m_initReturnCode; + bool m_callbackRegistered; + libusb_hotplug_callback_handle m_hotplugCallbackHandle; + std::thread m_hotplugThread; + std::atomic m_hotplugThreadStop; + + // called by libusb + static int HotplugCallback(libusb_context* ctx, libusb_device* dev, + libusb_hotplug_event event, void* user_data); + + int OnHotplug(libusb_device* dev, libusb_hotplug_event event); + + std::shared_ptr CheckAndCreateDevice(libusb_device* dev); + + std::shared_ptr FindLibusbDevice(libusb_device* dev); + + bool FindDefaultDeviceEndpoints(libusb_device* dev, + bool& endpointInFound, uint8& endpointIn, uint16& endpointInMaxPacketSize, + bool& endpointOutFound, uint8& endpointOut, uint16& endpointOutMaxPacketSize); + }; + + class DeviceLibusb : public nsyshid::Device { + public: + DeviceLibusb(libusb_context* ctx, + uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol, + uint8 libusbBusNumber, + uint8 libusbDeviceAddress); + + ~DeviceLibusb() override; + + bool Open() override; + + void Close() override; + + bool IsOpened() override; + + ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) override; + + WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) override; + + bool GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) override; + + bool SetProtocol(uint32 ifIndex, uint32 protocol) override; + + bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) override; + + uint8 m_libusbBusNumber; + uint8 m_libusbDeviceAddress; + bool m_libusbHasEndpointIn; + uint8 m_libusbEndpointIn; + bool m_libusbHasEndpointOut; + uint8 m_libusbEndpointOut; + + private: + void CloseDevice(); + + libusb_context* m_ctx; + std::mutex m_handleMutex; + std::atomic m_handleInUseCounter; + std::condition_variable m_handleInUseCounterDecremented; + libusb_device_handle* m_libusbHandle; + + class HandleLock { + public: + HandleLock() = delete; + + HandleLock(libusb_device_handle** handle, + std::mutex& handleMutex, + std::atomic& handleInUseCounter, + std::condition_variable& handleInUseCounterDecremented, + DeviceLibusb& device); + + ~HandleLock(); + + HandleLock(const HandleLock&) = delete; + + HandleLock& operator=(const HandleLock&) = delete; + + bool IsValid(); + + libusb_device_handle* GetHandle(); + + private: + libusb_device_handle* m_handle; + std::mutex& m_handleMutex; + std::atomic& m_handleInUseCounter; + std::condition_variable& m_handleInUseCounterDecremented; + }; + + std::unique_ptr AquireHandleLock(); + }; +} // namespace nsyshid::backend::libusb + +#endif // NSYSHID_ENABLE_BACKEND_LIBUSB + +#endif // CEMU_NSYSHID_BACKEND_LIBUSB_H diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp new file mode 100644 index 00000000..520a0d31 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -0,0 +1,454 @@ +#include "BackendWindowsHID.h" + +#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID + +#include +#include +#include + +#pragma comment(lib, "Setupapi.lib") +#pragma comment(lib, "hid.lib") + +DEFINE_GUID(GUID_DEVINTERFACE_HID, + 0x4D1E55B2L, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30); + +namespace nsyshid::backend::windows +{ + BackendWindowsHID::BackendWindowsHID() + { + } + + void BackendWindowsHID::AttachVisibleDevices() + { + // add all currently connected devices + HDEVINFO hDevInfo; + SP_DEVICE_INTERFACE_DATA DevIntfData; + PSP_DEVICE_INTERFACE_DETAIL_DATA DevIntfDetailData; + SP_DEVINFO_DATA DevData; + + DWORD dwSize, dwMemberIdx; + + hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, NULL, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); + + if (hDevInfo != INVALID_HANDLE_VALUE) + { + DevIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); + dwMemberIdx = 0; + + SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, + dwMemberIdx, &DevIntfData); + + while (GetLastError() != ERROR_NO_MORE_ITEMS) + { + DevData.cbSize = sizeof(DevData); + SetupDiGetDeviceInterfaceDetail( + hDevInfo, &DevIntfData, NULL, 0, &dwSize, NULL); + + DevIntfDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + dwSize); + DevIntfDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); + + if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &DevIntfData, + DevIntfDetailData, dwSize, &dwSize, &DevData)) + { + HANDLE hHIDDevice = OpenDevice(DevIntfDetailData->DevicePath); + if (hHIDDevice != INVALID_HANDLE_VALUE) + { + auto device = CheckAndCreateDevice(DevIntfDetailData->DevicePath, hHIDDevice); + if (device != nullptr) + { + if (IsDeviceWhitelisted(device->m_vendorId, device->m_productId)) + { + if (!AttachDevice(device)) + { + cemuLog_log(LogType::Force, + "nsyshid::BackendWindowsHID: failed to attach device: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + else + { + cemuLog_log(LogType::Force, + "nsyshid::BackendWindowsHID: device not on whitelist: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + } + } + CloseHandle(hHIDDevice); + } + } + HeapFree(GetProcessHeap(), 0, DevIntfDetailData); + // next + SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, ++dwMemberIdx, &DevIntfData); + } + SetupDiDestroyDeviceInfoList(hDevInfo); + } + } + + BackendWindowsHID::~BackendWindowsHID() + { + } + + bool BackendWindowsHID::IsInitialisedOk() + { + return true; + } + + std::shared_ptr BackendWindowsHID::CheckAndCreateDevice(wchar_t* devicePath, HANDLE hDevice) + { + HIDD_ATTRIBUTES hidAttr; + hidAttr.Size = sizeof(HIDD_ATTRIBUTES); + if (HidD_GetAttributes(hDevice, &hidAttr) == FALSE) + return nullptr; + + auto device = std::make_shared(hidAttr.VendorID, + hidAttr.ProductID, + 1, + 2, + 0, + _wcsdup(devicePath)); + // get additional device info + sint32 maxPacketInputLength = -1; + sint32 maxPacketOutputLength = -1; + PHIDP_PREPARSED_DATA ppData = nullptr; + if (HidD_GetPreparsedData(hDevice, &ppData)) + { + HIDP_CAPS caps; + if (HidP_GetCaps(ppData, &caps) == HIDP_STATUS_SUCCESS) + { + // length includes the report id byte + maxPacketInputLength = caps.InputReportByteLength - 1; + maxPacketOutputLength = caps.OutputReportByteLength - 1; + } + HidD_FreePreparsedData(ppData); + } + if (maxPacketInputLength <= 0 || maxPacketInputLength >= 0xF000) + { + cemuLog_log(LogType::Force, "HID: Input packet length not available or out of range (length = {})", + maxPacketInputLength); + maxPacketInputLength = 0x20; + } + if (maxPacketOutputLength <= 0 || maxPacketOutputLength >= 0xF000) + { + cemuLog_log(LogType::Force, "HID: Output packet length not available or out of range (length = {})", + maxPacketOutputLength); + maxPacketOutputLength = 0x20; + } + + device->m_maxPacketSizeRX = maxPacketInputLength; + device->m_maxPacketSizeTX = maxPacketOutputLength; + + return device; + } + + DeviceWindowsHID::DeviceWindowsHID(uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol, + wchar_t* devicePath) + : Device(vendorId, + productId, + interfaceIndex, + interfaceSubClass, + protocol), + m_devicePath(devicePath), + m_hFile(INVALID_HANDLE_VALUE) + { + } + + DeviceWindowsHID::~DeviceWindowsHID() + { + if (m_hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(m_hFile); + m_hFile = INVALID_HANDLE_VALUE; + } + } + + bool DeviceWindowsHID::Open() + { + if (IsOpened()) + { + return true; + } + m_hFile = OpenDevice(m_devicePath); + if (m_hFile == INVALID_HANDLE_VALUE) + { + return false; + } + HidD_SetNumInputBuffers(m_hFile, 2); // don't cache too many reports + return true; + } + + void DeviceWindowsHID::Close() + { + if (m_hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(m_hFile); + m_hFile = INVALID_HANDLE_VALUE; + } + } + + bool DeviceWindowsHID::IsOpened() + { + return m_hFile != INVALID_HANDLE_VALUE; + } + + Device::ReadResult DeviceWindowsHID::Read(uint8* data, sint32 length, sint32& bytesRead) + { + bytesRead = 0; + DWORD bt; + OVERLAPPED ovlp = {0}; + ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + uint8* tempBuffer = (uint8*)malloc(length + 1); + sint32 transferLength = 0; // minus report byte + + _debugPrintHex("HID_READ_BEFORE", data, length); + + cemuLog_logDebug(LogType::Force, "HidRead Begin (Length 0x{:08x})", length); + BOOL readResult = ReadFile(this->m_hFile, tempBuffer, length + 1, &bt, &ovlp); + if (readResult != FALSE) + { + // sometimes we get the result immediately + if (bt == 0) + transferLength = 0; + else + transferLength = bt - 1; + cemuLog_logDebug(LogType::Force, "HidRead Result received immediately (error 0x{:08x}) Length 0x{:08x}", + GetLastError(), transferLength); + } + else + { + // wait for result + cemuLog_logDebug(LogType::Force, "HidRead WaitForResult (error 0x{:08x})", GetLastError()); + // async hid read is never supposed to return unless there is a response? Lego Dimensions stops HIDRead calls as soon as one of them fails with a non-zero error (which includes time out) + DWORD r = WaitForSingleObject(ovlp.hEvent, 2000 * 100); + if (r == WAIT_TIMEOUT) + { + cemuLog_logDebug(LogType::Force, "HidRead internal timeout (error 0x{:08x})", GetLastError()); + // return -108 in case of timeout + free(tempBuffer); + CloseHandle(ovlp.hEvent); + return ReadResult::ErrorTimeout; + } + + cemuLog_logDebug(LogType::Force, "HidRead WaitHalfComplete"); + GetOverlappedResult(this->m_hFile, &ovlp, &bt, false); + if (bt == 0) + transferLength = 0; + else + transferLength = bt - 1; + cemuLog_logDebug(LogType::Force, "HidRead WaitComplete Length: 0x{:08x}", transferLength); + } + sint32 returnCode = 0; + ReadResult result = ReadResult::Success; + if (bt != 0) + { + memcpy(data, tempBuffer + 1, transferLength); + sint32 hidReadLength = transferLength; + + char debugOutput[1024] = {0}; + for (sint32 i = 0; i < transferLength; i++) + { + sprintf(debugOutput + i * 3, "%02x ", tempBuffer[1 + i]); + } + cemuLog_logDebug(LogType::Force, "HIDRead data: {}", debugOutput); + + bytesRead = transferLength; + result = ReadResult::Success; + } + else + { + cemuLog_log(LogType::Force, "Failed HID read"); + result = ReadResult::Error; + } + free(tempBuffer); + CloseHandle(ovlp.hEvent); + return result; + } + + Device::WriteResult DeviceWindowsHID::Write(uint8* data, sint32 length, sint32& bytesWritten) + { + bytesWritten = 0; + DWORD bt; + OVERLAPPED ovlp = {0}; + ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + uint8* tempBuffer = (uint8*)malloc(length + 1); + memcpy(tempBuffer + 1, data, length); + tempBuffer[0] = 0; // report byte? + + cemuLog_logDebug(LogType::Force, "HidWrite Begin (Length 0x{:08x})", length); + BOOL writeResult = WriteFile(this->m_hFile, tempBuffer, length + 1, &bt, &ovlp); + if (writeResult != FALSE) + { + // sometimes we get the result immediately + cemuLog_logDebug(LogType::Force, "HidWrite Result received immediately (error 0x{:08x}) Length 0x{:08x}", + GetLastError()); + } + else + { + // wait for result + cemuLog_logDebug(LogType::Force, "HidWrite WaitForResult (error 0x{:08x})", GetLastError()); + // todo - check for error type + DWORD r = WaitForSingleObject(ovlp.hEvent, 2000); + if (r == WAIT_TIMEOUT) + { + cemuLog_logDebug(LogType::Force, "HidWrite internal timeout"); + // return -108 in case of timeout + free(tempBuffer); + CloseHandle(ovlp.hEvent); + return WriteResult::ErrorTimeout; + } + + cemuLog_logDebug(LogType::Force, "HidWrite WaitHalfComplete"); + GetOverlappedResult(this->m_hFile, &ovlp, &bt, false); + cemuLog_logDebug(LogType::Force, "HidWrite WaitComplete"); + } + + free(tempBuffer); + CloseHandle(ovlp.hEvent); + + if (bt != 0) + { + bytesWritten = length; + return WriteResult::Success; + } + return WriteResult::Error; + } + + bool DeviceWindowsHID::GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) + { + if (!IsOpened()) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceWindowsHID::getDescriptor(): device is not opened"); + return false; + } + if (descType == 0x02) + { + uint8 configurationDescriptor[0x29]; + + uint8* currentWritePtr; + + // configuration descriptor + currentWritePtr = configurationDescriptor + 0; + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength + *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces + *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue + *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration + *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes + *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber + *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting + *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints + *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass + *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass + *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol + *(uint8*)(currentWritePtr + 8) = 0; // iInterface + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID + *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode + *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors + *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType + *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength + currentWritePtr = currentWritePtr + 9; + // endpoint descriptor 1 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = + this->m_maxPacketSizeRX; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + // endpoint descriptor 2 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x02; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = + this->m_maxPacketSizeTX; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + + cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); + + memcpy(output, configurationDescriptor, + std::min(outputMaxLength, sizeof(configurationDescriptor))); + return true; + } + else + { + cemu_assert_unimplemented(); + } + return false; + } + + bool DeviceWindowsHID::SetProtocol(uint32 ifIndef, uint32 protocol) + { + // ToDo: implement this + // pretend that everything is fine + return true; + } + + bool DeviceWindowsHID::SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) + { + sint32 retryCount = 0; + while (true) + { + BOOL r = HidD_SetOutputReport(this->m_hFile, reportData, length); + if (r != FALSE) + break; + Sleep(20); // retry + retryCount++; + if (retryCount >= 50) + { + cemuLog_log(LogType::Force, "nsyshid::DeviceWindowsHID::SetReport(): HID SetReport failed"); + return false; + } + } + return true; + } + + HANDLE OpenDevice(wchar_t* devicePath) + { + return CreateFile(devicePath, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | + FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, + NULL); + } + + void _debugPrintHex(std::string prefix, uint8* data, size_t len) + { + char debugOutput[1024] = {0}; + len = std::min(len, (size_t)100); + for (sint32 i = 0; i < len; i++) + { + sprintf(debugOutput + i * 3, "%02x ", data[i]); + } + fmt::print("{} Data: {}\n", prefix, debugOutput); + cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); + } +} // namespace nsyshid::backend::windows + +#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h new file mode 100644 index 00000000..049b33e4 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h @@ -0,0 +1,66 @@ +#ifndef CEMU_NSYSHID_BACKEND_WINDOWS_HID_H +#define CEMU_NSYSHID_BACKEND_WINDOWS_HID_H + +#include "nsyshid.h" + +#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID + +#include "Backend.h" + +namespace nsyshid::backend::windows +{ + class BackendWindowsHID : public nsyshid::Backend { + public: + BackendWindowsHID(); + + ~BackendWindowsHID(); + + bool IsInitialisedOk() override; + + protected: + void AttachVisibleDevices() override; + + private: + std::shared_ptr CheckAndCreateDevice(wchar_t* devicePath, HANDLE hDevice); + }; + + class DeviceWindowsHID : public nsyshid::Device { + public: + DeviceWindowsHID(uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol, + wchar_t* devicePath); + + ~DeviceWindowsHID(); + + bool Open() override; + + void Close() override; + + bool IsOpened() override; + + ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) override; + + WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) override; + + bool GetDescriptor(uint8 descType, uint8 descIndex, uint8 lang, uint8* output, uint32 outputMaxLength) override; + + bool SetProtocol(uint32 ifIndef, uint32 protocol) override; + + bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) override; + + private: + wchar_t* m_devicePath; + HANDLE m_hFile; + }; + + HANDLE OpenDevice(wchar_t* devicePath); + + void _debugPrintHex(std::string prefix, uint8* data, size_t len); +} // namespace nsyshid::backend::windows + +#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID + +#endif // CEMU_NSYSHID_BACKEND_WINDOWS_HID_H diff --git a/src/Cafe/OS/libs/nsyshid/Whitelist.cpp b/src/Cafe/OS/libs/nsyshid/Whitelist.cpp new file mode 100644 index 00000000..f20e4c45 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Whitelist.cpp @@ -0,0 +1,53 @@ +#include "Whitelist.h" + +namespace nsyshid +{ + Whitelist& Whitelist::GetInstance() + { + static Whitelist whitelist; + return whitelist; + } + + Whitelist::Whitelist() + { + // add known devices + { + // lego dimensions portal + m_devices.emplace_back(0x0e6f, 0x0241); + // skylanders portal + m_devices.emplace_back(0x1430, 0x0150); + // disney infinity base + m_devices.emplace_back(0x0e6f, 0x0129); + } + } + + bool Whitelist::IsDeviceWhitelisted(uint16 vendorId, uint16 productId) + { + auto it = std::find(m_devices.begin(), m_devices.end(), + std::tuple(vendorId, productId)); + return it != m_devices.end(); + } + + void Whitelist::AddDevice(uint16 vendorId, uint16 productId) + { + if (!IsDeviceWhitelisted(vendorId, productId)) + { + m_devices.emplace_back(vendorId, productId); + } + } + + void Whitelist::RemoveDevice(uint16 vendorId, uint16 productId) + { + m_devices.remove(std::tuple(vendorId, productId)); + } + + std::list> Whitelist::GetDevices() + { + return m_devices; + } + + void Whitelist::RemoveAllDevices() + { + m_devices.clear(); + } +} // namespace nsyshid diff --git a/src/Cafe/OS/libs/nsyshid/Whitelist.h b/src/Cafe/OS/libs/nsyshid/Whitelist.h new file mode 100644 index 00000000..73b7742b --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Whitelist.h @@ -0,0 +1,32 @@ +#ifndef CEMU_NSYSHID_WHITELIST_H +#define CEMU_NSYSHID_WHITELIST_H + +namespace nsyshid +{ + class Whitelist { + public: + static Whitelist& GetInstance(); + + Whitelist(const Whitelist&) = delete; + + Whitelist& operator=(const Whitelist&) = delete; + + bool IsDeviceWhitelisted(uint16 vendorId, uint16 productId); + + void AddDevice(uint16 vendorId, uint16 productId); + + void RemoveDevice(uint16 vendorId, uint16 productId); + + std::list> GetDevices(); + + void RemoveAllDevices(); + + private: + Whitelist(); + + // vendorId, productId + std::list> m_devices; + }; +} // namespace nsyshid + +#endif // CEMU_NSYSHID_WHITELIST_H diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index 9b9d2d61..b21e2a43 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -1,289 +1,259 @@ #include "Cafe/OS/common/OSCommon.h" #include "Cafe/HW/Espresso/PPCCallback.h" #include +#include #include "nsyshid.h" - -#if BOOST_OS_WINDOWS - -#include -#include -#include - #include "Cafe/OS/libs/coreinit/coreinit_Thread.h" - -#pragma comment(lib,"Setupapi.lib") -#pragma comment(lib,"hid.lib") - -DEFINE_GUID(GUID_DEVINTERFACE_HID, 0x4D1E55B2L, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30); +#include "Backend.h" +#include "Whitelist.h" namespace nsyshid { - typedef struct - { - /* +0x00 */ uint32be handle; - /* +0x04 */ uint32 ukn04; - /* +0x08 */ uint16 vendorId; // little-endian ? - /* +0x0A */ uint16 productId; // little-endian ? - /* +0x0C */ uint8 ifIndex; - /* +0x0D */ uint8 subClass; - /* +0x0E */ uint8 protocol; - /* +0x0F */ uint8 paddingGuessed0F; - /* +0x10 */ uint16be maxPacketSizeRX; - /* +0x12 */ uint16be maxPacketSizeTX; - }HIDDevice_t; - - static_assert(offsetof(HIDDevice_t, vendorId) == 0x8, ""); - static_assert(offsetof(HIDDevice_t, productId) == 0xA, ""); - static_assert(offsetof(HIDDevice_t, ifIndex) == 0xC, ""); - static_assert(offsetof(HIDDevice_t, protocol) == 0xE, ""); - - typedef struct _HIDDeviceInfo_t - { - uint32 handle; - uint32 physicalDeviceInstance; - uint16 vendorId; - uint16 productId; - uint8 interfaceIndex; - uint8 interfaceSubClass; - uint8 protocol; - HIDDevice_t* hidDevice; // this info is passed to applications and must remain intact - wchar_t* devicePath; - _HIDDeviceInfo_t* next; - // host - HANDLE hFile; - }HIDDeviceInfo_t; - - HIDDeviceInfo_t* firstDevice = nullptr; + std::list> backendList; + std::list> deviceList; typedef struct _HIDClient_t { - MEMPTR<_HIDClient_t> next; uint32be callbackFunc; // attach/detach callback - }HIDClient_t; + } HIDClient_t; - HIDClient_t* firstHIDClient = nullptr; + std::list HIDClientList; - HANDLE openDevice(wchar_t* devicePath) - { - return CreateFile(devicePath, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - } - - void attachClientToList(HIDClient_t* hidClient) + std::recursive_mutex hidMutex; + + void AttachClientToList(HIDClient_t* hidClient) { + std::lock_guard lock(hidMutex); // todo - append at the beginning or end of the list? List order matters because it also controls the order in which attach callbacks are called - if (firstHIDClient) - { - hidClient->next = firstHIDClient; - firstHIDClient = hidClient; - } - else - { - hidClient->next = nullptr; - firstHIDClient = hidClient; - } + HIDClientList.push_front(hidClient); } - void attachDeviceToList(HIDDeviceInfo_t* hidDeviceInfo) + void DetachClientFromList(HIDClient_t* hidClient) { - if (firstDevice) - { - hidDeviceInfo->next = firstDevice; - firstDevice = hidDeviceInfo; - } - else - { - hidDeviceInfo->next = nullptr; - firstDevice = hidDeviceInfo; - } + std::lock_guard lock(hidMutex); + HIDClientList.remove(hidClient); } - HIDDeviceInfo_t* getHIDDeviceInfoByHandle(uint32 handle, bool openFileHandle = false) + std::shared_ptr GetDeviceByHandle(uint32 handle, bool openIfClosed = false) { - HIDDeviceInfo_t* deviceItr = firstDevice; - while (deviceItr) + std::shared_ptr device; { - if (deviceItr->handle == handle) + std::lock_guard lock(hidMutex); + for (const auto& d : deviceList) { - if (openFileHandle && deviceItr->hFile == INVALID_HANDLE_VALUE) + if (d->m_hid->handle == handle) { - deviceItr->hFile = openDevice(deviceItr->devicePath); - if (deviceItr->hFile == INVALID_HANDLE_VALUE) - { - cemuLog_log(LogType::Force, "HID: Failed to open device \"{}\"", boost::nowide::narrow(std::wstring(deviceItr->devicePath))); - return nullptr; - } - HidD_SetNumInputBuffers(deviceItr->hFile, 2); // dont cache too many reports + device = d; + break; } - return deviceItr; } - deviceItr = deviceItr->next; + } + if (device != nullptr) + { + if (openIfClosed && !device->IsOpened()) + { + if (!device->Open()) + { + return nullptr; + } + } + return device; } return nullptr; } uint32 _lastGeneratedHidHandle = 1; - uint32 generateHIDHandle() + uint32 GenerateHIDHandle() { + std::lock_guard lock(hidMutex); _lastGeneratedHidHandle++; return _lastGeneratedHidHandle; } const int HID_MAX_NUM_DEVICES = 128; - SysAllocator _devicePool; - std::bitset _devicePoolMask; + SysAllocator HIDPool; + std::queue HIDPoolIndexQueue; - HIDDevice_t* getFreeDevice() + void InitHIDPoolIndexQueue() { - for (sint32 i = 0; i < HID_MAX_NUM_DEVICES; i++) + static bool HIDPoolIndexQueueInitialized = false; + std::lock_guard lock(hidMutex); + if (HIDPoolIndexQueueInitialized) { - if (_devicePoolMask.test(i) == false) - { - _devicePoolMask.set(i); - return _devicePool.GetPtr() + i; - } + return; + } + HIDPoolIndexQueueInitialized = true; + for (size_t i = 0; i < HID_MAX_NUM_DEVICES; i++) + { + HIDPoolIndexQueue.push(i); } - return nullptr; } - void checkAndAddDevice(wchar_t* devicePath, HANDLE hDevice) + HID_t* GetFreeHID() { - HIDD_ATTRIBUTES hidAttr; - hidAttr.Size = sizeof(HIDD_ATTRIBUTES); - if (HidD_GetAttributes(hDevice, &hidAttr) == FALSE) - return; - HIDDevice_t* hidDevice = getFreeDevice(); - if (hidDevice == nullptr) + std::lock_guard lock(hidMutex); + InitHIDPoolIndexQueue(); + if (HIDPoolIndexQueue.empty()) { - cemuLog_log(LogType::Force, "HID: Maximum number of supported devices exceeded"); - return; + return nullptr; } - - HIDDeviceInfo_t* deviceInfo = (HIDDeviceInfo_t*)malloc(sizeof(HIDDeviceInfo_t)); - memset(deviceInfo, 0, sizeof(HIDDeviceInfo_t)); - deviceInfo->devicePath = _wcsdup(devicePath); - deviceInfo->vendorId = hidAttr.VendorID; - deviceInfo->productId = hidAttr.ProductID; - deviceInfo->hFile = INVALID_HANDLE_VALUE; - // generate handle - deviceInfo->handle = generateHIDHandle(); - // get additional device info - sint32 maxPacketInputLength = -1; - sint32 maxPacketOutputLength = -1; - PHIDP_PREPARSED_DATA ppData = nullptr; - if (HidD_GetPreparsedData(hDevice, &ppData)) - { - HIDP_CAPS caps; - if (HidP_GetCaps(ppData, &caps) == HIDP_STATUS_SUCCESS) - { - // length includes the report id byte - maxPacketInputLength = caps.InputReportByteLength - 1; - maxPacketOutputLength = caps.OutputReportByteLength - 1; - } - HidD_FreePreparsedData(ppData); - } - if (maxPacketInputLength <= 0 || maxPacketInputLength >= 0xF000) - { - cemuLog_log(LogType::Force, "HID: Input packet length not available or out of range (length = {})", maxPacketInputLength); - maxPacketInputLength = 0x20; - } - if (maxPacketOutputLength <= 0 || maxPacketOutputLength >= 0xF000) - { - cemuLog_log(LogType::Force, "HID: Output packet length not available or out of range (length = {})", maxPacketOutputLength); - maxPacketOutputLength = 0x20; - } - // setup HIDDevice struct - deviceInfo->hidDevice = hidDevice; - memset(hidDevice, 0, sizeof(HIDDevice_t)); - hidDevice->handle = deviceInfo->handle; - hidDevice->vendorId = deviceInfo->vendorId; - hidDevice->productId = deviceInfo->productId; - hidDevice->maxPacketSizeRX = maxPacketInputLength; - hidDevice->maxPacketSizeTX = maxPacketOutputLength; - - hidDevice->ukn04 = 0x11223344; - - hidDevice->ifIndex = 1; - hidDevice->protocol = 0; - hidDevice->subClass = 2; - - // todo - other values - //hidDevice->ifIndex = 1; - - - attachDeviceToList(deviceInfo); - + size_t index = HIDPoolIndexQueue.front(); + HIDPoolIndexQueue.pop(); + return HIDPool.GetPtr() + index; } - void initDeviceList() + void ReleaseHID(HID_t* device) { - if (firstDevice) - return; - HDEVINFO hDevInfo; - SP_DEVICE_INTERFACE_DATA DevIntfData; - PSP_DEVICE_INTERFACE_DETAIL_DATA DevIntfDetailData; - SP_DEVINFO_DATA DevData; - - DWORD dwSize, dwMemberIdx; - - hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, NULL, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); - - if (hDevInfo != INVALID_HANDLE_VALUE) + // this should never happen, but having a safeguard can't hurt + if (device == nullptr) { - DevIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - dwMemberIdx = 0; - - SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, - dwMemberIdx, &DevIntfData); - - while (GetLastError() != ERROR_NO_MORE_ITEMS) - { - DevData.cbSize = sizeof(DevData); - SetupDiGetDeviceInterfaceDetail( - hDevInfo, &DevIntfData, NULL, 0, &dwSize, NULL); - - DevIntfDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); - DevIntfDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - - if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &DevIntfData, - DevIntfDetailData, dwSize, &dwSize, &DevData)) - { - HANDLE hHIDDevice = openDevice(DevIntfDetailData->DevicePath); - if (hHIDDevice != INVALID_HANDLE_VALUE) - { - checkAndAddDevice(DevIntfDetailData->DevicePath, hHIDDevice); - CloseHandle(hHIDDevice); - } - } - HeapFree(GetProcessHeap(), 0, DevIntfDetailData); - // next - SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, ++dwMemberIdx, &DevIntfData); - } - SetupDiDestroyDeviceInfoList(hDevInfo); + cemu_assert_error(); } + std::lock_guard lock(hidMutex); + InitHIDPoolIndexQueue(); + size_t index = device - HIDPool.GetPtr(); + HIDPoolIndexQueue.push(index); } const int HID_CALLBACK_DETACH = 0; const int HID_CALLBACK_ATTACH = 1; - uint32 doAttachCallback(HIDClient_t* hidClient, HIDDeviceInfo_t* deviceInfo) + uint32 DoAttachCallback(HIDClient_t* hidClient, const std::shared_ptr& device) { - return PPCCoreCallback(hidClient->callbackFunc, memory_getVirtualOffsetFromPointer(hidClient), memory_getVirtualOffsetFromPointer(deviceInfo->hidDevice), HID_CALLBACK_ATTACH); + return PPCCoreCallback(hidClient->callbackFunc, memory_getVirtualOffsetFromPointer(hidClient), + memory_getVirtualOffsetFromPointer(device->m_hid), HID_CALLBACK_ATTACH); } - void doDetachCallback(HIDClient_t* hidClient, HIDDeviceInfo_t* deviceInfo) + void DoAttachCallbackAsync(HIDClient_t* hidClient, const std::shared_ptr& device) { - PPCCoreCallback(hidClient->callbackFunc, memory_getVirtualOffsetFromPointer(hidClient), memory_getVirtualOffsetFromPointer(deviceInfo->hidDevice), HID_CALLBACK_DETACH); + coreinitAsyncCallback_add(hidClient->callbackFunc, 3, memory_getVirtualOffsetFromPointer(hidClient), + memory_getVirtualOffsetFromPointer(device->m_hid), HID_CALLBACK_ATTACH); + } + + void DoDetachCallback(HIDClient_t* hidClient, const std::shared_ptr& device) + { + PPCCoreCallback(hidClient->callbackFunc, memory_getVirtualOffsetFromPointer(hidClient), + memory_getVirtualOffsetFromPointer(device->m_hid), HID_CALLBACK_DETACH); + } + + void DoDetachCallbackAsync(HIDClient_t* hidClient, const std::shared_ptr& device) + { + coreinitAsyncCallback_add(hidClient->callbackFunc, 3, memory_getVirtualOffsetFromPointer(hidClient), + memory_getVirtualOffsetFromPointer(device->m_hid), HID_CALLBACK_DETACH); + } + + void AttachBackend(const std::shared_ptr& backend) + { + { + std::lock_guard lock(hidMutex); + backendList.push_back(backend); + } + backend->OnAttach(); + } + + void DetachBackend(const std::shared_ptr& backend) + { + { + std::lock_guard lock(hidMutex); + backendList.remove(backend); + } + backend->OnDetach(); + } + + void DetachAllBackends() + { + std::list> backendListCopy; + { + std::lock_guard lock(hidMutex); + backendListCopy = backendList; + backendList.clear(); + } + for (const auto& backend : backendListCopy) + { + backend->OnDetach(); + } + } + + void AttachDefaultBackends() + { + backend::AttachDefaultBackends(); + } + + bool AttachDevice(const std::shared_ptr& device) + { + std::lock_guard lock(hidMutex); + + // is the device already attached? + { + auto it = std::find(deviceList.begin(), deviceList.end(), device); + if (it != deviceList.end()) + { + cemuLog_logDebug(LogType::Force, + "nsyshid.AttachDevice(): failed to attach device: {:04x}:{:04x}: already attached", + device->m_vendorId, + device->m_productId); + return false; + } + } + + HID_t* hidDevice = GetFreeHID(); + if (hidDevice == nullptr) + { + cemuLog_logDebug(LogType::Force, + "nsyshid.AttachDevice(): failed to attach device: {:04x}:{:04x}: no free device slots left", + device->m_vendorId, + device->m_productId); + return false; + } + hidDevice->handle = GenerateHIDHandle(); + device->AssignHID(hidDevice); + deviceList.push_back(device); + + // do attach callbacks + for (auto client : HIDClientList) + { + DoAttachCallbackAsync(client, device); + } + + cemuLog_logDebug(LogType::Force, "nsyshid.AttachDevice(): device attached: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + return true; + } + + void DetachDevice(const std::shared_ptr& device) + { + { + std::lock_guard lock(hidMutex); + + // remove from list + auto it = std::find(deviceList.begin(), deviceList.end(), device); + if (it == deviceList.end()) + { + cemuLog_logDebug(LogType::Force, "nsyshid.DetachDevice(): device not found: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); + return; + } + deviceList.erase(it); + + // do detach callbacks + for (auto client : HIDClientList) + { + DoDetachCallbackAsync(client, device); + } + ReleaseHID(device->m_hid); + } + + device->Close(); + + cemuLog_logDebug(LogType::Force, "nsyshid.DetachDevice(): device removed: {:04x}:{:04x}", + device->m_vendorId, + device->m_productId); } void export_HIDAddClient(PPCInterpreter_t* hCPU) @@ -292,15 +262,14 @@ namespace nsyshid ppcDefineParamMPTR(callbackFuncMPTR, 1); cemuLog_logDebug(LogType::Force, "nsyshid.HIDAddClient(0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4]); hidClient->callbackFunc = callbackFuncMPTR; - attachClientToList(hidClient); - initDeviceList(); + + std::lock_guard lock(hidMutex); + AttachClientToList(hidClient); + // do attach callbacks - HIDDeviceInfo_t* deviceItr = firstDevice; - while (deviceItr) + for (const auto& device : deviceList) { - if (doAttachCallback(hidClient, deviceItr) != 0) - break; - deviceItr = deviceItr->next; + DoAttachCallback(hidClient, device); } osLib_returnFromFunction(hCPU, 0); @@ -310,14 +279,14 @@ namespace nsyshid { ppcDefineParamTypePtr(hidClient, HIDClient_t, 0); cemuLog_logDebug(LogType::Force, "nsyshid.HIDDelClient(0x{:08x})", hCPU->gpr[3]); - - // todo + + std::lock_guard lock(hidMutex); + DetachClientFromList(hidClient); + // do detach callbacks - HIDDeviceInfo_t* deviceItr = firstDevice; - while (deviceItr) + for (const auto& device : deviceList) { - doDetachCallback(hidClient, deviceItr); - deviceItr = deviceItr->next; + DoDetachCallback(hidClient, device); } osLib_returnFromFunction(hCPU, 0); @@ -325,127 +294,68 @@ namespace nsyshid void export_HIDGetDescriptor(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU8(descType, 1); // r4 - ppcDefineParamU8(descIndex, 2); // r5 - ppcDefineParamU8(lang, 3); // r6 - ppcDefineParamUStr(output, 4); // r7 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU8(descType, 1); // r4 + ppcDefineParamU8(descIndex, 2); // r5 + ppcDefineParamU8(lang, 3); // r6 + ppcDefineParamUStr(output, 4); // r7 ppcDefineParamU32(outputMaxLength, 5); // r8 - ppcDefineParamMPTR(cbFuncMPTR, 6); // r9 - ppcDefineParamMPTR(cbParamMPTR, 7); // r10 + ppcDefineParamMPTR(cbFuncMPTR, 6); // r9 + ppcDefineParamMPTR(cbParamMPTR, 7); // r10 - HIDDeviceInfo_t* hidDeviceInfo = getHIDDeviceInfoByHandle(hidHandle); - if (hidDeviceInfo) + int returnValue = -1; + std::shared_ptr device = GetDeviceByHandle(hidHandle, true); + if (device) { - HANDLE hHIDDevice = openDevice(hidDeviceInfo->devicePath); - if (hHIDDevice != INVALID_HANDLE_VALUE) + memset(output, 0, outputMaxLength); + if (device->GetDescriptor(descType, descIndex, lang, output, outputMaxLength)) { - if (descType == 0x02) - { - uint8 configurationDescriptor[0x29]; - - uint8* currentWritePtr; - - // configuration descriptor - currentWritePtr = configurationDescriptor + 0; - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType - *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength - *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces - *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue - *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration - *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes - *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower - currentWritePtr = currentWritePtr + 9; - // configuration descriptor - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType - *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber - *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting - *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints - *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass - *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass - *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol - *(uint8*)(currentWritePtr + 8) = 0; // iInterface - currentWritePtr = currentWritePtr + 9; - // configuration descriptor - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType - *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID - *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode - *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors - *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType - *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength - currentWritePtr = currentWritePtr + 9; - // endpoint descriptor 1 - *(uint8*)(currentWritePtr + 0) = 7; // bLength - *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType - *(uint8*)(currentWritePtr + 1) = 0x81; // bEndpointAddress - *(uint8*)(currentWritePtr + 2) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 3) = 0x40; // wMaxPacketSize - *(uint8*)(currentWritePtr + 5) = 0x01; // bInterval - currentWritePtr = currentWritePtr + 7; - // endpoint descriptor 2 - *(uint8*)(currentWritePtr + 0) = 7; // bLength - *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType - *(uint8*)(currentWritePtr + 1) = 0x02; // bEndpointAddress - *(uint8*)(currentWritePtr + 2) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 3) = 0x40; // wMaxPacketSize - *(uint8*)(currentWritePtr + 5) = 0x01; // bInterval - currentWritePtr = currentWritePtr + 7; - - cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); - - memcpy(output, configurationDescriptor, std::min(outputMaxLength, sizeof(configurationDescriptor))); - } - else - { - cemu_assert_unimplemented(); - } - CloseHandle(hHIDDevice); + returnValue = 0; } else { - cemu_assert_unimplemented(); + returnValue = -1; } } else { cemu_assert_suspicious(); } - osLib_returnFromFunction(hCPU, 0); + osLib_returnFromFunction(hCPU, returnValue); } void _debugPrintHex(std::string prefix, uint8* data, size_t len) { - char debugOutput[1024] = { 0 }; + char debugOutput[1024] = {0}; len = std::min(len, (size_t)100); for (sint32 i = 0; i < len; i++) { sprintf(debugOutput + i * 3, "%02x ", data[i]); } + fmt::print("{} Data: {}\n", prefix, debugOutput); cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); } - void doHIDTransferCallback(MPTR callbackFuncMPTR, MPTR callbackParamMPTR, uint32 hidHandle, uint32 errorCode, MPTR buffer, sint32 length) + void DoHIDTransferCallback(MPTR callbackFuncMPTR, MPTR callbackParamMPTR, uint32 hidHandle, uint32 errorCode, + MPTR buffer, sint32 length) { coreinitAsyncCallback_add(callbackFuncMPTR, 5, hidHandle, errorCode, buffer, length, callbackParamMPTR); } void export_HIDSetIdle(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(ifIndex, 1); // r4 - ppcDefineParamU32(ukn, 2); // r5 - ppcDefineParamU32(duration, 3); // r6 - ppcDefineParamMPTR(callbackFuncMPTR, 4); // r7 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU32(ifIndex, 1); // r4 + ppcDefineParamU32(ukn, 2); // r5 + ppcDefineParamU32(duration, 3); // r6 + ppcDefineParamMPTR(callbackFuncMPTR, 4); // r7 ppcDefineParamMPTR(callbackParamMPTR, 5); // r8 cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetIdle(...)"); // todo if (callbackFuncMPTR) { - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); + DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); } else { @@ -456,67 +366,78 @@ namespace nsyshid void export_HIDSetProtocol(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(ifIndex, 1); // r4 - ppcDefineParamU32(protocol, 2); // r5 - ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU32(ifIndex, 1); // r4 + ppcDefineParamU32(protocol, 2); // r5 + ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(...)"); - - if (callbackFuncMPTR) + + std::shared_ptr device = GetDeviceByHandle(hidHandle, true); + sint32 returnCode = -1; + if (device) { - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); + if (!device->IsOpened()) + { + cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(): error: device is not opened"); + } + else + { + if (device->SetProtocol(ifIndex, protocol)) + { + returnCode = 0; + } + } } else { - cemu_assert_unimplemented(); + cemu_assert_suspicious(); } - osLib_returnFromFunction(hCPU, 0); // for non-async version, return number of bytes transferred + + if (callbackFuncMPTR) + { + DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); + } + osLib_returnFromFunction(hCPU, returnCode); } // handler for async HIDSetReport transfers - void _hidSetReportAsync(HIDDeviceInfo_t* hidDeviceInfo, uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + void _hidSetReportAsync(std::shared_ptr device, uint8* reportData, sint32 length, + uint8* originalData, + sint32 originalLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) { - sint32 retryCount = 0; - while (true) + cemuLog_logDebug(LogType::Force, "_hidSetReportAsync begin"); + if (device->SetReport(reportData, length, originalData, originalLength)) { - BOOL r = HidD_SetOutputReport(hidDeviceInfo->hFile, reportData, length); - if (r != FALSE) - break; - Sleep(20); // retry - retryCount++; - if (retryCount >= 40) - { - cemuLog_log(LogType::Force, "HID async SetReport failed"); - sint32 errorCode = -1; - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidDeviceInfo->handle, errorCode, memory_getVirtualOffsetFromPointer(originalData), 0); - free(reportData); - return; - } + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + 0, + memory_getVirtualOffsetFromPointer(originalData), + originalLength); + } + else + { + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + -1, + memory_getVirtualOffsetFromPointer(originalData), + 0); } - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidDeviceInfo->handle, 0, memory_getVirtualOffsetFromPointer(originalData), originalLength); free(reportData); } // handler for synchronous HIDSetReport transfers - sint32 _hidSetReportSync(HIDDeviceInfo_t* hidDeviceInfo, uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength, OSThread_t* osThread) + sint32 _hidSetReportSync(std::shared_ptr device, uint8* reportData, sint32 length, + uint8* originalData, + sint32 originalLength, OSThread_t* osThread) { - //cemuLog_logDebug(LogType::Force, "_hidSetReportSync begin"); _debugPrintHex("_hidSetReportSync Begin", reportData, length); - sint32 retryCount = 0; sint32 returnCode = 0; - while (true) + if (device->SetReport(reportData, length, originalData, originalLength)) { - BOOL r = HidD_SetOutputReport(hidDeviceInfo->hFile, reportData, length); - if (r != FALSE) - { - returnCode = originalLength; - break; - } - Sleep(100); // retry - retryCount++; - if (retryCount >= 10) - assert_dbg(); + returnCode = originalLength; } free(reportData); cemuLog_logDebug(LogType::Force, "_hidSetReportSync end. returnCode: {}", returnCode); @@ -526,14 +447,15 @@ namespace nsyshid void export_HIDSetReport(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(reportRelatedUkn, 1); // r4 - ppcDefineParamU32(reportId, 2); // r5 - ppcDefineParamUStr(data, 3); // r6 - ppcDefineParamU32(dataLength, 4); // r7 - ppcDefineParamMPTR(callbackFuncMPTR, 5); // r8 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU32(reportRelatedUkn, 1); // r4 + ppcDefineParamU32(reportId, 2); // r5 + ppcDefineParamUStr(data, 3); // r6 + ppcDefineParamU32(dataLength, 4); // r7 + ppcDefineParamMPTR(callbackFuncMPTR, 5); // r8 ppcDefineParamMPTR(callbackParamMPTR, 6); // r9 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetReport({},0x{:02x},0x{:02x},...)", hidHandle, reportRelatedUkn, reportId); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetReport({},0x{:02x},0x{:02x},...)", hidHandle, reportRelatedUkn, + reportId); _debugPrintHex("HIDSetReport", data, dataLength); @@ -542,8 +464,8 @@ namespace nsyshid assert_dbg(); #endif - HIDDeviceInfo_t* hidDeviceInfo = getHIDDeviceInfoByHandle(hidHandle, true); - if (hidDeviceInfo == nullptr) + std::shared_ptr device = GetDeviceByHandle(hidHandle, true); + if (device == nullptr) { cemuLog_log(LogType::Force, "nsyshid.HIDSetReport(): Unable to find device with hid handle {}", hidHandle); osLib_returnFromFunction(hCPU, -1); @@ -552,19 +474,20 @@ namespace nsyshid // prepare report data // note: Currently we need to pad the data to 0x20 bytes for it to work (plus one extra byte for HidD_SetOutputReport) - // Does IOSU pad data to 0x20 byte? Also check if this is specific to Skylanders portal - sint32 paddedLength = (dataLength +0x1F)&~0x1F; - uint8* reportData = (uint8*)malloc(paddedLength+1); - memset(reportData, 0, paddedLength+1); + // Does IOSU pad data to 0x20 byte? Also check if this is specific to Skylanders portal + sint32 paddedLength = (dataLength + 0x1F) & ~0x1F; + uint8* reportData = (uint8*)malloc(paddedLength + 1); + memset(reportData, 0, paddedLength + 1); reportData[0] = 0; memcpy(reportData + 1, data, dataLength); - // issue request (synchronous or asynchronous) sint32 returnCode = 0; if (callbackFuncMPTR == MPTR_NULL) { - std::future res = std::async(std::launch::async, &_hidSetReportSync, hidDeviceInfo, reportData, paddedLength + 1, data, dataLength, coreinitThread_getCurrentThreadDepr(hCPU)); + std::future res = std::async(std::launch::async, &_hidSetReportSync, device, reportData, + paddedLength + 1, data, dataLength, + coreinitThread_getCurrentThreadDepr(hCPU)); coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); PPCCore_switchToScheduler(); returnCode = res.get(); @@ -572,110 +495,88 @@ namespace nsyshid else { // asynchronous - std::thread(&_hidSetReportAsync, hidDeviceInfo, reportData, paddedLength+1, data, dataLength, callbackFuncMPTR, callbackParamMPTR).detach(); + std::thread(&_hidSetReportAsync, device, reportData, paddedLength + 1, data, dataLength, + callbackFuncMPTR, callbackParamMPTR) + .detach(); returnCode = 0; } osLib_returnFromFunction(hCPU, returnCode); } - sint32 _hidReadInternalSync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength) + sint32 _hidReadInternalSync(std::shared_ptr device, uint8* data, sint32 maxLength) { - DWORD bt; - OVERLAPPED ovlp = { 0 }; - ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - uint8* tempBuffer = (uint8*)malloc(maxLength + 1); - sint32 transferLength = 0; // minus report byte - - _debugPrintHex("HID_READ_BEFORE", data, maxLength); - cemuLog_logDebug(LogType::Force, "HidRead Begin (Length 0x{:08x})", maxLength); - BOOL readResult = ReadFile(hidDeviceInfo->hFile, tempBuffer, maxLength + 1, &bt, &ovlp); - if (readResult != FALSE) + if (!device->IsOpened()) { - // sometimes we get the result immediately - if (bt == 0) - transferLength = 0; - else - transferLength = bt - 1; - cemuLog_logDebug(LogType::Force, "HidRead Result received immediately (error 0x{:08x}) Length 0x{:08x}", GetLastError(), transferLength); + cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): cannot read from a non-opened device"); + return -1; } - else + memset(data, 0, maxLength); + + sint32 bytesRead = 0; + Device::ReadResult readResult = device->Read(data, maxLength, bytesRead); + switch (readResult) { - // wait for result - cemuLog_logDebug(LogType::Force, "HidRead WaitForResult (error 0x{:08x})", GetLastError()); - // async hid read is never supposed to return unless there is an response? Lego Dimensions stops HIDRead calls as soon as one of them fails with a non-zero error (which includes time out) - DWORD r = WaitForSingleObject(ovlp.hEvent, 2000*100); - if (r == WAIT_TIMEOUT) - { - cemuLog_logDebug(LogType::Force, "HidRead internal timeout (error 0x{:08x})", GetLastError()); - // return -108 in case of timeout - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return -108; - } - - - cemuLog_logDebug(LogType::Force, "HidRead WaitHalfComplete"); - GetOverlappedResult(hidDeviceInfo->hFile, &ovlp, &bt, false); - if (bt == 0) - transferLength = 0; - else - transferLength = bt - 1; - cemuLog_logDebug(LogType::Force, "HidRead WaitComplete Length: 0x{:08x}", transferLength); - } - sint32 returnCode = 0; - if (bt != 0) + case Device::ReadResult::Success: { - memcpy(data, tempBuffer + 1, transferLength); - sint32 hidReadLength = transferLength; - - char debugOutput[1024] = { 0 }; - for (sint32 i = 0; i < transferLength; i++) - { - sprintf(debugOutput + i * 3, "%02x ", tempBuffer[1 + i]); - } - cemuLog_logDebug(LogType::Force, "HIDRead data: {}", debugOutput); - - returnCode = transferLength; + cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): read {} of {} bytes", + bytesRead, + maxLength); + return bytesRead; } - else + break; + case Device::ReadResult::Error: { - cemuLog_log(LogType::Force, "Failed HID read"); - returnCode = -1; + cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): read error"); + return -1; } - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return returnCode; + break; + case Device::ReadResult::ErrorTimeout: + { + cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): read error: timeout"); + return -108; + } + break; + } + cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): read error: unknown"); + return -1; } - void _hidReadAsync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + void _hidReadAsync(std::shared_ptr device, + uint8* data, sint32 maxLength, + MPTR callbackFuncMPTR, + MPTR callbackParamMPTR) { - sint32 returnCode = _hidReadInternalSync(hidDeviceInfo, data, maxLength); + sint32 returnCode = _hidReadInternalSync(device, data, maxLength); sint32 errorCode = 0; if (returnCode < 0) - errorCode = returnCode; // dont return number of bytes in error code - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidDeviceInfo->handle, errorCode, memory_getVirtualOffsetFromPointer(data), (returnCode>0)?returnCode:0); + errorCode = returnCode; // don't return number of bytes in error code + DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, device->m_hid->handle, errorCode, + memory_getVirtualOffsetFromPointer(data), (returnCode > 0) ? returnCode : 0); } - sint32 _hidReadSync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength, OSThread_t* osThread) + sint32 _hidReadSync(std::shared_ptr device, + uint8* data, + sint32 maxLength, + OSThread_t* osThread) { - sint32 returnCode = _hidReadInternalSync(hidDeviceInfo, data, maxLength); + sint32 returnCode = _hidReadInternalSync(device, data, maxLength); coreinit_resumeThread(osThread, 1000); return returnCode; } void export_HIDRead(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamUStr(data, 1); // r4 - ppcDefineParamU32(maxLength, 2); // r5 - ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamUStr(data, 1); // r4 + ppcDefineParamU32(maxLength, 2); // r5 + ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDRead(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDRead(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); - HIDDeviceInfo_t* hidDeviceInfo = getHIDDeviceInfoByHandle(hidHandle, true); - if (hidDeviceInfo == nullptr) + std::shared_ptr device = GetDeviceByHandle(hidHandle, true); + if (device == nullptr) { cemuLog_log(LogType::Force, "nsyshid.HIDRead(): Unable to find device with hid handle {}", hidHandle); osLib_returnFromFunction(hCPU, -1); @@ -685,13 +586,14 @@ namespace nsyshid if (callbackFuncMPTR != MPTR_NULL) { // asynchronous transfer - std::thread(&_hidReadAsync, hidDeviceInfo, data, maxLength, callbackFuncMPTR, callbackParamMPTR).detach(); + std::thread(&_hidReadAsync, device, data, maxLength, callbackFuncMPTR, callbackParamMPTR).detach(); returnCode = 0; } else { // synchronous transfer - std::future res = std::async(std::launch::async, &_hidReadSync, hidDeviceInfo, data, maxLength, coreinitThread_getCurrentThreadDepr(hCPU)); + std::future res = std::async(std::launch::async, &_hidReadSync, device, data, maxLength, + coreinitThread_getCurrentThreadDepr(hCPU)); coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); PPCCore_switchToScheduler(); returnCode = res.get(); @@ -700,81 +602,78 @@ namespace nsyshid osLib_returnFromFunction(hCPU, returnCode); } - sint32 _hidWriteInternalSync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength) + sint32 _hidWriteInternalSync(std::shared_ptr device, uint8* data, sint32 maxLength) { - DWORD bt; - OVERLAPPED ovlp = { 0 }; - ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - uint8* tempBuffer = (uint8*)malloc(maxLength + 1); - memcpy(tempBuffer + 1, data, maxLength); - tempBuffer[0] = 0; // report byte? - cemuLog_logDebug(LogType::Force, "HidWrite Begin (Length 0x{:08x})", maxLength); - BOOL WriteResult = WriteFile(hidDeviceInfo->hFile, tempBuffer, maxLength + 1, &bt, &ovlp); - if (WriteResult != FALSE) + if (!device->IsOpened()) { - // sometimes we get the result immediately - cemuLog_logDebug(LogType::Force, "HidWrite Result received immediately (error 0x{:08x}) Length 0x{:08x}", GetLastError()); + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): cannot write to a non-opened device"); + return -1; } - else + sint32 bytesWritten = 0; + Device::WriteResult writeResult = device->Write(data, maxLength, bytesWritten); + switch (writeResult) { - // wait for result - cemuLog_logDebug(LogType::Force, "HidWrite WaitForResult (error 0x{:08x})", GetLastError()); - // todo - check for error type - DWORD r = WaitForSingleObject(ovlp.hEvent, 2000); - if (r == WAIT_TIMEOUT) - { - cemuLog_logDebug(LogType::Force, "HidWrite internal timeout"); - // return -108 in case of timeout - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return -108; - } - - - cemuLog_logDebug(LogType::Force, "HidWrite WaitHalfComplete"); - GetOverlappedResult(hidDeviceInfo->hFile, &ovlp, &bt, false); - cemuLog_logDebug(LogType::Force, "HidWrite WaitComplete"); + case Device::WriteResult::Success: + { + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): wrote {} of {} bytes", bytesWritten, + maxLength); + return bytesWritten; } - sint32 returnCode = 0; - if (bt != 0) - returnCode = maxLength; - else - returnCode = -1; - - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return returnCode; + break; + case Device::WriteResult::Error: + { + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): write error"); + return -1; + } + break; + case Device::WriteResult::ErrorTimeout: + { + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): write error: timeout"); + return -108; + } + break; + } + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): write error: unknown"); + return -1; } - void _hidWriteAsync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + void _hidWriteAsync(std::shared_ptr device, + uint8* data, + sint32 maxLength, + MPTR callbackFuncMPTR, + MPTR callbackParamMPTR) { - sint32 returnCode = _hidWriteInternalSync(hidDeviceInfo, data, maxLength); + sint32 returnCode = _hidWriteInternalSync(device, data, maxLength); sint32 errorCode = 0; if (returnCode < 0) - errorCode = returnCode; // dont return number of bytes in error code - doHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidDeviceInfo->handle, errorCode, memory_getVirtualOffsetFromPointer(data), (returnCode > 0) ? returnCode : 0); + errorCode = returnCode; // don't return number of bytes in error code + DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, device->m_hid->handle, errorCode, + memory_getVirtualOffsetFromPointer(data), (returnCode > 0) ? returnCode : 0); } - sint32 _hidWriteSync(HIDDeviceInfo_t* hidDeviceInfo, uint8* data, sint32 maxLength, OSThread_t* osThread) + sint32 _hidWriteSync(std::shared_ptr device, + uint8* data, + sint32 maxLength, + OSThread_t* osThread) { - sint32 returnCode = _hidWriteInternalSync(hidDeviceInfo, data, maxLength); + sint32 returnCode = _hidWriteInternalSync(device, data, maxLength); coreinit_resumeThread(osThread, 1000); return returnCode; } void export_HIDWrite(PPCInterpreter_t* hCPU) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamUStr(data, 1); // r4 - ppcDefineParamU32(maxLength, 2); // r5 - ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamUStr(data, 1); // r4 + ppcDefineParamU32(maxLength, 2); // r5 + ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDWrite(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDWrite(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); - HIDDeviceInfo_t* hidDeviceInfo = getHIDDeviceInfoByHandle(hidHandle, true); - if (hidDeviceInfo == nullptr) + std::shared_ptr device = GetDeviceByHandle(hidHandle, true); + if (device == nullptr) { cemuLog_log(LogType::Force, "nsyshid.HIDWrite(): Unable to find device with hid handle {}", hidHandle); osLib_returnFromFunction(hCPU, -1); @@ -784,13 +683,14 @@ namespace nsyshid if (callbackFuncMPTR != MPTR_NULL) { // asynchronous transfer - std::thread(&_hidWriteAsync, hidDeviceInfo, data, maxLength, callbackFuncMPTR, callbackParamMPTR).detach(); + std::thread(&_hidWriteAsync, device, data, maxLength, callbackFuncMPTR, callbackParamMPTR).detach(); returnCode = 0; } else { // synchronous transfer - std::future res = std::async(std::launch::async, &_hidWriteSync, hidDeviceInfo, data, maxLength, coreinitThread_getCurrentThreadDepr(hCPU)); + std::future res = std::async(std::launch::async, &_hidWriteSync, device, data, maxLength, + coreinitThread_getCurrentThreadDepr(hCPU)); coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); PPCCore_switchToScheduler(); returnCode = res.get(); @@ -804,7 +704,8 @@ namespace nsyshid ppcDefineParamU32(errorCode, 0); ppcDefineParamTypePtr(ukn0, uint32be, 1); ppcDefineParamTypePtr(ukn1, uint32be, 2); - cemuLog_logDebug(LogType::Force, "nsyshid.HIDDecodeError(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDDecodeError(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5]); // todo *ukn0 = 0x3FF; @@ -813,6 +714,114 @@ namespace nsyshid osLib_returnFromFunction(hCPU, 0); } + void Backend::DetachAllDevices() + { + std::lock_guard lock(this->m_devicesMutex); + if (m_isAttached) + { + for (const auto& device : this->m_devices) + { + nsyshid::DetachDevice(device); + } + this->m_devices.clear(); + } + } + + bool Backend::AttachDevice(const std::shared_ptr& device) + { + std::lock_guard lock(this->m_devicesMutex); + if (m_isAttached && nsyshid::AttachDevice(device)) + { + this->m_devices.push_back(device); + return true; + } + return false; + } + + void Backend::DetachDevice(const std::shared_ptr& device) + { + std::lock_guard lock(this->m_devicesMutex); + if (m_isAttached) + { + nsyshid::DetachDevice(device); + this->m_devices.remove(device); + } + } + + std::shared_ptr Backend::FindDevice(std::function&)> isWantedDevice) + { + std::lock_guard lock(this->m_devicesMutex); + auto it = std::find_if(this->m_devices.begin(), this->m_devices.end(), std::move(isWantedDevice)); + if (it != this->m_devices.end()) + { + return *it; + } + return nullptr; + } + + bool Backend::IsDeviceWhitelisted(uint16 vendorId, uint16 productId) + { + return Whitelist::GetInstance().IsDeviceWhitelisted(vendorId, productId); + } + + Backend::Backend() + : m_isAttached(false) + { + } + + void Backend::OnAttach() + { + std::lock_guard lock(this->m_devicesMutex); + m_isAttached = true; + AttachVisibleDevices(); + } + + void Backend::OnDetach() + { + std::lock_guard lock(this->m_devicesMutex); + DetachAllDevices(); + m_isAttached = false; + } + + bool Backend::IsBackendAttached() + { + std::lock_guard lock(this->m_devicesMutex); + return m_isAttached; + } + + Device::Device(uint16 vendorId, + uint16 productId, + uint8 interfaceIndex, + uint8 interfaceSubClass, + uint8 protocol) + : m_hid(nullptr), + m_vendorId(vendorId), + m_productId(productId), + m_interfaceIndex(interfaceIndex), + m_interfaceSubClass(interfaceSubClass), + m_protocol(protocol), + m_maxPacketSizeRX(0x20), + m_maxPacketSizeTX(0x20) + { + } + + void Device::AssignHID(HID_t* hid) + { + if (hid != nullptr) + { + hid->vendorId = this->m_vendorId; + hid->productId = this->m_productId; + hid->ifIndex = this->m_interfaceIndex; + hid->subClass = this->m_interfaceSubClass; + hid->protocol = this->m_protocol; + hid->ukn04 = 0x11223344; + hid->paddingGuessed0F = 0; + hid->maxPacketSizeRX = this->m_maxPacketSizeRX; + hid->maxPacketSizeTX = this->m_maxPacketSizeTX; + } + this->m_hid = hid; + } + void load() { osLib_addFunction("nsyshid", "HIDAddClient", export_HIDAddClient); @@ -826,19 +835,10 @@ namespace nsyshid osLib_addFunction("nsyshid", "HIDWrite", export_HIDWrite); osLib_addFunction("nsyshid", "HIDDecodeError", export_HIDDecodeError); - firstHIDClient = nullptr; + + // initialise whitelist + Whitelist::GetInstance(); + + AttachDefaultBackends(); } -} - -#else - -namespace nsyshid -{ - void load() - { - // unimplemented - }; -}; - - -#endif +} // namespace nsyshid diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.h b/src/Cafe/OS/libs/nsyshid/nsyshid.h index 051b4e7c..1478adf9 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.h +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.h @@ -1,5 +1,12 @@ #pragma once + namespace nsyshid { + class Backend; + + void AttachBackend(const std::shared_ptr& backend); + + void DetachBackend(const std::shared_ptr& backend); + void load(); -} \ No newline at end of file +} // namespace nsyshid diff --git a/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp b/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp index 546a9615..09d73013 100644 --- a/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp +++ b/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp @@ -3,6 +3,9 @@ #include #include +#pragma comment(lib, "Setupapi.lib") +#pragma comment(lib, "hid.lib") + WinWiimoteDevice::WinWiimoteDevice(HANDLE handle, std::vector identifier) : m_handle(handle), m_identifier(std::move(identifier)) { diff --git a/vcpkg.json b/vcpkg.json index 940ed748..7ea8058e 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -46,6 +46,7 @@ "name": "curl", "default-features": false, "features": [ "openssl" ] - } + }, + "libusb" ] } From 323bdfa18382986763450e55a6117e78873e6cfd Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Tue, 19 Sep 2023 16:54:38 +0100 Subject: [PATCH 018/314] More changes to finding wiimotes (#961) --- .../settings/WiimoteControllerSettings.cpp | 1 - .../api/Wiimote/WiimoteControllerProvider.cpp | 46 +++++++++++++------ .../api/Wiimote/hidapi/HidapiWiimote.cpp | 13 ++---- src/input/api/Wiimote/hidapi/HidapiWiimote.h | 3 +- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/gui/input/settings/WiimoteControllerSettings.cpp b/src/gui/input/settings/WiimoteControllerSettings.cpp index 5bc20269..9830b666 100644 --- a/src/gui/input/settings/WiimoteControllerSettings.cpp +++ b/src/gui/input/settings/WiimoteControllerSettings.cpp @@ -56,7 +56,6 @@ WiimoteControllerSettings::WiimoteControllerSettings(wxWindow* parent, const wxP // Motion m_use_motion = new wxCheckBox(box, wxID_ANY, _("Use motion")); m_use_motion->SetValue(m_settings.motion); - m_use_motion->SetValue(m_settings.motion); m_use_motion->Enable(m_controller->has_motion()); row_sizer->Add(m_use_motion, 0, wxALL, 5); diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.cpp b/src/input/api/Wiimote/WiimoteControllerProvider.cpp index 0ebf88aa..0ca00a1a 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.cpp +++ b/src/input/api/Wiimote/WiimoteControllerProvider.cpp @@ -9,6 +9,7 @@ #endif #include +#include WiimoteControllerProvider::WiimoteControllerProvider() : m_running(true) @@ -30,20 +31,39 @@ WiimoteControllerProvider::~WiimoteControllerProvider() std::vector> WiimoteControllerProvider::get_controllers() { std::scoped_lock lock(m_device_mutex); - for (const auto& device : WiimoteDevice_t::get_devices()) + + std::queue disconnected_wiimote_indices; + for (auto i{0u}; i < m_wiimotes.size(); ++i){ + if (!(m_wiimotes[i].connected = m_wiimotes[i].device->write_data({kStatusRequest, 0x00}))){ + disconnected_wiimote_indices.push(i); + } + } + + const auto valid_new_device = [&](std::shared_ptr & device) { + const auto writeable = device->write_data({kStatusRequest, 0x00}); + const auto not_already_connected = + std::none_of(m_wiimotes.cbegin(), m_wiimotes.cend(), + [device](const auto& it) { + return (*it.device == *device) && it.connected; + }); + return writeable && not_already_connected; + }; + + for (auto& device : WiimoteDevice_t::get_devices()) { - // test connection of all devices as they might have been changed - const bool is_connected = device->write_data({kStatusRequest, 0x00}); - if (is_connected) - { - // only add unknown, connected devices to our list - const bool is_new_device = std::none_of(m_wiimotes.cbegin(), m_wiimotes.cend(), - [device](const auto& it) { return *it.device == *device; }); - if (is_new_device) - { - m_wiimotes.push_back(std::make_unique(device)); - } - } + if (!valid_new_device(device)) + continue; + // Replace disconnected wiimotes + if (!disconnected_wiimote_indices.empty()){ + const auto idx = disconnected_wiimote_indices.front(); + disconnected_wiimote_indices.pop(); + + m_wiimotes.replace(idx, std::make_unique(device)); + } + // Otherwise add them + else { + m_wiimotes.push_back(std::make_unique(device)); + } } std::vector> result; diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp index 898e6cf4..a5701f56 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp @@ -5,8 +5,8 @@ static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306; static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330; static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22; -HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path) - : m_handle(dev), m_identifier(identifier), m_path(path) { +HidapiWiimote::HidapiWiimote(hid_device* dev, std::string_view path) + : m_handle(dev), m_path(path) { } @@ -36,11 +36,7 @@ std::vector HidapiWiimote::get_devices() { } else { hid_set_nonblocking(dev, true); - // Enough to have a unique id for each device within a session - uint64_t id = (static_cast(it->interface_number) << 32) | - (static_cast(it->usage_page) << 16) | - (it->usage); - wiimote_devices.push_back(std::make_shared(dev, id, it->path)); + wiimote_devices.push_back(std::make_shared(dev, it->path)); } } hid_free_enumeration(device_enumeration); @@ -48,8 +44,7 @@ std::vector HidapiWiimote::get_devices() { } bool HidapiWiimote::operator==(WiimoteDevice& o) const { - auto const& other_mote = static_cast(o); - return m_identifier == other_mote.m_identifier && other_mote.m_path == m_path; + return static_cast(o).m_path == m_path; } HidapiWiimote::~HidapiWiimote() { diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.h b/src/input/api/Wiimote/hidapi/HidapiWiimote.h index 7b91dbbe..858cb1f3 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.h +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.h @@ -5,7 +5,7 @@ class HidapiWiimote : public WiimoteDevice { public: - HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path); + HidapiWiimote(hid_device* dev, std::string_view path); ~HidapiWiimote() override; bool write_data(const std::vector &data) override; @@ -16,7 +16,6 @@ public: private: hid_device* m_handle; - const uint64_t m_identifier; const std::string m_path; }; From 90c56b773147d412e311f8e27430efdf2c94c0fd Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:17:21 +0200 Subject: [PATCH 019/314] Latte: Optimizations and tweaks (#706) --- .../HW/Latte/Core/LatteCommandProcessor.cpp | 1217 ++++++++++------- src/Cafe/HW/Latte/Core/LatteOverlay.cpp | 6 +- src/Cafe/HW/Latte/Core/LatteOverlay.h | 2 +- .../HW/Latte/Core/LattePerformanceMonitor.cpp | 8 +- .../HW/Latte/Core/LattePerformanceMonitor.h | 1 + src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 28 + .../HW/Latte/Core/LatteTextureReadback.cpp | 37 +- .../HW/Latte/Core/LatteTextureReadbackInfo.h | 1 + src/Cafe/HW/Latte/ISA/LatteReg.h | 2 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 2 +- 10 files changed, 822 insertions(+), 482 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp index 37ce8ff9..60e5935c 100644 --- a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp +++ b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp @@ -16,9 +16,17 @@ #include "Cafe/CafeSystem.h" +#include + +void LatteCP_DebugPrintCmdBuffer(uint32be* bufferPtr, uint32 size); + #define CP_TIMER_RECHECK 1024 -//#define FAST_DRAW_LOGGING +//#define LATTE_CP_LOGGING + +typedef uint32be* LatteCMDPtr; +#define LatteReadCMD() ((uint32)*(cmd++)) +#define LatteSkipCMD(_nWords) cmd += (_nWords) uint8* gxRingBufferReadPtr; // currently active read pointer (gx2 ring buffer or display list) uint8* gx2CPParserDisplayListPtr; @@ -31,6 +39,14 @@ void LatteThread_Exit(); class DrawPassContext { + struct CmdQueuePos + { + CmdQueuePos(LatteCMDPtr current, LatteCMDPtr start, LatteCMDPtr end) : current(current), start(start), end(end) {}; + + LatteCMDPtr current; + LatteCMDPtr start; + LatteCMDPtr end; + }; public: bool isWithinDrawPass() const { @@ -54,6 +70,13 @@ public: if (numInstances == 0) return; + /* + if (GetAsyncKeyState('B')) + { + cemuLog_force("[executeDraw] {} Count {} BaseVertex {} BaseInstance {}", m_isFirstDraw?"Init":"Fast", count, baseVertex, baseInstance); + } + */ + if (!isAutoIndex) { cemu_assert_debug(physIndices != MPTR_NULL); @@ -66,6 +89,9 @@ public: { g_renderer->draw_execute(baseVertex, baseInstance, numInstances, count, MPTR_NULL, Latte::LATTE_VGT_DMA_INDEX_TYPE::E_INDEX_TYPE::AUTO, m_isFirstDraw); } + performanceMonitor.cycle[performanceMonitor.cycleIndex].drawCallCounter++; + if (!m_isFirstDraw) + performanceMonitor.cycle[performanceMonitor.cycleIndex].fastDrawCallCounter++; m_isFirstDraw = false; m_vertexBufferChanged = false; m_uniformBufferChanged = false; @@ -87,14 +113,33 @@ public: m_uniformBufferChanged = true; } + // command buffer processing position + void PushCurrentCommandQueuePos(LatteCMDPtr current, LatteCMDPtr start, LatteCMDPtr end) + { + m_queuePosStack.emplace_back(current, start, end); + } + + bool PopCurrentCommandQueuePos(LatteCMDPtr& current, LatteCMDPtr& start, LatteCMDPtr& end) + { + if (m_queuePosStack.empty()) + return false; + const auto& it = m_queuePosStack.back(); + current = it.current; + start = it.start; + end = it.end; + m_queuePosStack.pop_back(); + return true; + } + private: bool m_drawPassActive{ false }; bool m_isFirstDraw{false}; bool m_vertexBufferChanged{ false }; bool m_uniformBufferChanged{ false }; + boost::container::small_vector m_queuePosStack; }; -void LatteCP_processCommandBuffer(uint8* cmdBuffer, sint32 cmdSize, DrawPassContext& drawPassCtx); +void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx); /* * Read a U32 from the command buffer @@ -193,10 +238,6 @@ void LatteCP_skipWords(uint32 wordsToSkip) } } -typedef uint32be* LatteCMDPtr; -#define LatteReadCMD() ((uint32)*(cmd++)) -#define LatteSkipCMD(_nWords) cmd += (_nWords) - LatteCMDPtr LatteCP_itSurfaceSync(LatteCMDPtr cmd) { uint32 invalidationFlags = LatteReadCMD(); @@ -215,22 +256,31 @@ LatteCMDPtr LatteCP_itSurfaceSync(LatteCMDPtr cmd) return cmd; } -template -void LatteCP_itIndirectBufferDepr(uint32 nWords) +// called from TCL command queue. Executes a memory command buffer +void LatteCP_itIndirectBufferDepr(LatteCMDPtr cmd, uint32 nWords) { cemu_assert_debug(nWords == 3); - - uint32 physicalAddress = readU32(); - uint32 physicalAddressHigh = readU32(); // unused - uint32 sizeInDWords = readU32(); + uint32 physicalAddress = LatteReadCMD(); + uint32 physicalAddressHigh = LatteReadCMD(); // unused + uint32 sizeInDWords = LatteReadCMD(); uint32 displayListSize = sizeInDWords * 4; DrawPassContext drawPassCtx; - LatteCP_processCommandBuffer(memory_getPointerFromPhysicalOffset(physicalAddress), displayListSize, drawPassCtx); + +#ifdef LATTE_CP_LOGGING + if (GetAsyncKeyState('A')) + LatteCP_DebugPrintCmdBuffer(MEMPTR(physicalAddress), displayListSize); +#endif + + uint32be* buf = MEMPTR(physicalAddress).GetPtr(); + drawPassCtx.PushCurrentCommandQueuePos(buf, buf, buf + sizeInDWords); + + LatteCP_processCommandBuffer(drawPassCtx); if (drawPassCtx.isWithinDrawPass()) drawPassCtx.endDrawPass(); } -LatteCMDPtr LatteCP_itIndirectBuffer(LatteCMDPtr cmd, uint32 nWords, DrawPassContext& drawPassCtx) +// pushes the command buffer to the stack +void LatteCP_itIndirectBuffer(LatteCMDPtr cmd, uint32 nWords, DrawPassContext& drawPassCtx) { cemu_assert_debug(nWords == 3); uint32 physicalAddress = LatteReadCMD(); @@ -239,8 +289,8 @@ LatteCMDPtr LatteCP_itIndirectBuffer(LatteCMDPtr cmd, uint32 nWords, DrawPassCon uint32 displayListSize = sizeInDWords * 4; cemu_assert_debug(displayListSize >= 4); - LatteCP_processCommandBuffer(memory_getPointerFromPhysicalOffset(physicalAddress), displayListSize, drawPassCtx); - return cmd; + uint32be* buf = MEMPTR(physicalAddress).GetPtr(); + drawPassCtx.PushCurrentCommandQueuePos(buf, buf, buf + sizeInDWords); } LatteCMDPtr LatteCP_itStreamoutBufferUpdate(LatteCMDPtr cmd, uint32 nWords) @@ -615,8 +665,6 @@ LatteCMDPtr LatteCP_itDrawIndex2(LatteCMDPtr cmd, uint32 nWords, DrawPassContext uint32 count = LatteReadCMD(); uint32 ukn3 = LatteReadCMD(); - performanceMonitor.cycle[performanceMonitor.cycleIndex].drawCallCounter++; - LatteGPUState.currentDrawCallTick = GetTickCount(); drawPassCtx.executeDraw(count, false, physIndices); return cmd; @@ -628,8 +676,6 @@ LatteCMDPtr LatteCP_itDrawIndexAuto(LatteCMDPtr cmd, uint32 nWords, DrawPassCont uint32 count = LatteReadCMD(); uint32 ukn = LatteReadCMD(); - performanceMonitor.cycle[performanceMonitor.cycleIndex].drawCallCounter++; - if (LatteGPUState.drawContext.numInstances == 0) return cmd; LatteGPUState.currentDrawCallTick = GetTickCount(); @@ -692,7 +738,6 @@ LatteCMDPtr LatteCP_itDrawImmediate(LatteCMDPtr cmd, uint32 nWords, DrawPassCont // verify packet size if (nWords != (2 + numIndexU32s)) debugBreakpoint(); - performanceMonitor.cycle[performanceMonitor.cycleIndex].drawCallCounter++; uint32 baseVertex = LatteGPUState.contextRegister[mmSQ_VTX_BASE_VTX_LOC]; uint32 baseInstance = LatteGPUState.contextRegister[mmSQ_VTX_START_INST_LOC]; @@ -930,431 +975,412 @@ void LatteCP_dumpCommandBufferError(LatteCMDPtr cmdStart, LatteCMDPtr cmdEnd, La } // any drawcalls issued without changing textures, framebuffers, shader or other complex states can be done quickly without having to reinitialize the entire pipeline state -// we implement this optimization by having an optimized version of LatteCP_processCommandBuffer, called right after drawcalls, which only implements commands that dont interfere with fast drawing. Other commands will cause this function to return to the complex parser -LatteCMDPtr LatteCP_processCommandBuffer_continuousDrawPass(LatteCMDPtr cmd, LatteCMDPtr cmdStart, LatteCMDPtr cmdEnd, DrawPassContext& drawPassCtx) +// we implement this optimization by having a specialized version of LatteCP_processCommandBuffer, called right after drawcalls, which only implements commands that dont interfere with fast drawing. Other commands will cause this function to return to the complex and generic parser +void LatteCP_processCommandBuffer_continuousDrawPass(DrawPassContext& drawPassCtx) { cemu_assert_debug(drawPassCtx.isWithinDrawPass()); // quit early if there are parameters set which are generally incompatible with fast drawing if (LatteGPUState.contextRegister[mmVGT_STRMOUT_EN] != 0) { drawPassCtx.endDrawPass(); - return cmd; + return; } // check for other special states? - while (cmd < cmdEnd) + while (true) { - LatteCMDPtr cmdBeforeCommand = cmd; - uint32 itHeader = LatteReadCMD(); - uint32 itHeaderType = (itHeader >> 30) & 3; - if (itHeaderType == 3) + LatteCMDPtr cmd, cmdStart, cmdEnd; + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) { - uint32 itCode = (itHeader >> 8) & 0xFF; - uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; - switch (itCode) - { - case IT_SET_RESOURCE: // attribute buffers, uniform buffers or texture units - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords, [&drawPassCtx](uint32 registerStart, uint32 registerEnd) - { - if (registerStart >= Latte::REGADDR::SQ_TEX_RESOURCE_WORD_FIRST && registerStart <= Latte::REGADDR::SQ_TEX_RESOURCE_WORD_LAST) - drawPassCtx.endDrawPass(); // texture updates end the current draw sequence - else if (registerStart >= mmSQ_VTX_ATTRIBUTE_BLOCK_START && registerEnd <= mmSQ_VTX_ATTRIBUTE_BLOCK_END) - drawPassCtx.notifyModifiedVertexBuffer(); - else - drawPassCtx.notifyModifiedUniformBuffer(); - }); - if (!drawPassCtx.isWithinDrawPass()) - return cmd; - break; - } - case IT_SET_ALU_CONST: // uniform register - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - break; - } - case IT_SET_CTL_CONST: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - break; - } - case IT_SET_CONFIG_REG: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - break; - } - case IT_INDEX_TYPE: - { - cmd = LatteCP_itIndexType(cmd, nWords); - break; - } - case IT_NUM_INSTANCES: - { - cmd = LatteCP_itNumInstances(cmd, nWords); - break; - } - case IT_DRAW_INDEX_2: - { -#ifdef FAST_DRAW_LOGGING - if(GetAsyncKeyState('A')) - forceLogRemoveMe_printf("Minimal draw"); -#endif - cmd = LatteCP_itDrawIndex2(cmd, nWords, drawPassCtx); - break; - } - case IT_SET_CONTEXT_REG: - { -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] Quit due to command IT_SET_CONTEXT_REG Reg: %04x", (uint32)cmd[0] + 0xA000); -#endif - drawPassCtx.endDrawPass(); - return cmdBeforeCommand; - } - case IT_INDIRECT_BUFFER_PRIV: - { - cmd = LatteCP_itIndirectBuffer(cmd, nWords, drawPassCtx); - if (!drawPassCtx.isWithinDrawPass()) - return cmd; - break; - } - default: -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] Quit due to command itCode 0x%02x", itCode); -#endif - drawPassCtx.endDrawPass(); - return cmdBeforeCommand; - } - } - else if (itHeaderType == 2) - { - // filler packet - } - else - { -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] Quit due to unsupported headerType 0x%02x", itHeaderType); -#endif drawPassCtx.endDrawPass(); - return cmdBeforeCommand; - } - } - cemu_assert_debug(drawPassCtx.isWithinDrawPass()); - return cmd; -} - -void LatteCP_processCommandBuffer(uint8* cmdBuffer, sint32 cmdSize, DrawPassContext& drawPassCtx) -{ - LatteCMDPtr cmd = (LatteCMDPtr)cmdBuffer; - LatteCMDPtr cmdStart = (LatteCMDPtr)cmdBuffer; - LatteCMDPtr cmdEnd = (LatteCMDPtr)(cmdBuffer + cmdSize); - - if (drawPassCtx.isWithinDrawPass()) - { - cmd = LatteCP_processCommandBuffer_continuousDrawPass(cmd, cmdStart, cmdEnd, drawPassCtx); - cemu_assert_debug(cmd <= cmdEnd); - if (cmd == cmdEnd) return; - cemu_assert_debug(!drawPassCtx.isWithinDrawPass()); - } + } - while (cmd < cmdEnd) - { - uint32 itHeader = LatteReadCMD(); - uint32 itHeaderType = (itHeader >> 30) & 3; - if (itHeaderType == 3) + while (cmd < cmdEnd) { - uint32 itCode = (itHeader >> 8) & 0xFF; - uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; -#ifdef CEMU_DEBUG_ASSERT - LatteCMDPtr expectedPostCmd = cmd + nWords; -#endif - switch (itCode) + LatteCMDPtr cmdBeforeCommand = cmd; + uint32 itHeader = LatteReadCMD(); + uint32 itHeaderType = (itHeader >> 30) & 3; + if (itHeaderType == 3) { - case IT_SET_CONTEXT_REG: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_RESOURCE: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_ALU_CONST: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_CTL_CONST: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_SAMPLER: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_CONFIG_REG: - { - cmd = LatteCP_itSetRegistersGeneric(cmd, nWords); - } - break; - case IT_SET_LOOP_CONST: - { - LatteSkipCMD(nWords); - // todo - } - break; - case IT_SURFACE_SYNC: - { - cmd = LatteCP_itSurfaceSync(cmd); - } - break; - case IT_INDIRECT_BUFFER_PRIV: - { - cmd = LatteCP_itIndirectBuffer(cmd, nWords, drawPassCtx); - if (drawPassCtx.isWithinDrawPass()) + uint32 itCode = (itHeader >> 8) & 0xFF; + uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; + LatteCMDPtr cmdData = cmd; + cmd += nWords; + switch (itCode) { - cmd = LatteCP_processCommandBuffer_continuousDrawPass(cmd, cmdStart, cmdEnd, drawPassCtx); - cemu_assert_debug(cmd <= cmdEnd); - if (cmd == cmdEnd) + case IT_SET_RESOURCE: // attribute buffers, uniform buffers or texture units + { + LatteCP_itSetRegistersGeneric(cmdData, nWords, [&drawPassCtx](uint32 registerStart, uint32 registerEnd) + { + if ((registerStart >= Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS && registerStart < (Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS + Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 7)) || + (registerStart >= Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS && registerStart < (Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS + Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 7)) || + (registerStart >= Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS && registerStart < (Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS + Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 7))) + drawPassCtx.endDrawPass(); // texture updates end the current draw sequence + else if (registerStart >= mmSQ_VTX_ATTRIBUTE_BLOCK_START && registerEnd <= mmSQ_VTX_ATTRIBUTE_BLOCK_END) + drawPassCtx.notifyModifiedVertexBuffer(); + else + drawPassCtx.notifyModifiedUniformBuffer(); + }); + if (!drawPassCtx.isWithinDrawPass()) + { + drawPassCtx.PushCurrentCommandQueuePos(cmd, cmdStart, cmdEnd); return; - cemu_assert_debug(!drawPassCtx.isWithinDrawPass()); + } + break; + } + case IT_SET_ALU_CONST: // uniform register + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + break; + } + case IT_SET_CTL_CONST: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + break; + } + case IT_SET_CONFIG_REG: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + break; + } + case IT_INDEX_TYPE: + { + LatteCP_itIndexType(cmdData, nWords); + break; + } + case IT_NUM_INSTANCES: + { + LatteCP_itNumInstances(cmdData, nWords); + break; + } + case IT_DRAW_INDEX_2: + { + LatteCP_itDrawIndex2(cmdData, nWords, drawPassCtx); + break; + } + case IT_SET_CONTEXT_REG: + { + drawPassCtx.endDrawPass(); + drawPassCtx.PushCurrentCommandQueuePos(cmdBeforeCommand, cmdStart, cmdEnd); + return; + } + case IT_INDIRECT_BUFFER_PRIV: + { + drawPassCtx.PushCurrentCommandQueuePos(cmd, cmdStart, cmdEnd); + LatteCP_itIndirectBuffer(cmdData, nWords, drawPassCtx); + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) // switch to sub buffer + cemu_assert_debug(false); + + //if (!drawPassCtx.isWithinDrawPass()) + // return cmdData; + break; + } + default: + // unsupported command for fast draw + drawPassCtx.endDrawPass(); + drawPassCtx.PushCurrentCommandQueuePos(cmdBeforeCommand, cmdStart, cmdEnd); + return; } -#ifdef CEMU_DEBUG_ASSERT - expectedPostCmd = cmd; -#endif } - break; - case IT_STRMOUT_BUFFER_UPDATE: + else if (itHeaderType == 2) { - cmd = LatteCP_itStreamoutBufferUpdate(cmd, nWords); - } - break; - case IT_INDEX_TYPE: - { - cmd = LatteCP_itIndexType(cmd, nWords); - } - break; - case IT_NUM_INSTANCES: - { - cmd = LatteCP_itNumInstances(cmd, nWords); - } - break; - case IT_DRAW_INDEX_2: - { - drawPassCtx.beginDrawPass(); -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] Starting"); -#endif - cmd = LatteCP_itDrawIndex2(cmd, nWords, drawPassCtx); - cmd = LatteCP_processCommandBuffer_continuousDrawPass(cmd, cmdStart, cmdEnd, drawPassCtx); - cemu_assert_debug(cmd == cmdEnd || drawPassCtx.isWithinDrawPass() == false); // draw sequence should have ended if we didn't reach the end of the command buffer -#ifdef CEMU_DEBUG_ASSERT - expectedPostCmd = cmd; -#endif - } - break; - case IT_DRAW_INDEX_AUTO: - { - drawPassCtx.beginDrawPass(); - cmd = LatteCP_itDrawIndexAuto(cmd, nWords, drawPassCtx); - cmd = LatteCP_processCommandBuffer_continuousDrawPass(cmd, cmdStart, cmdEnd, drawPassCtx); - cemu_assert_debug(cmd == cmdEnd || drawPassCtx.isWithinDrawPass() == false); // draw sequence should have ended if we didn't reach the end of the command buffer -#ifdef CEMU_DEBUG_ASSERT - expectedPostCmd = cmd; -#endif -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] Auto-draw"); -#endif - } - break; - case IT_DRAW_INDEX_IMMD: - { - DrawPassContext drawPassCtx; - drawPassCtx.beginDrawPass(); - cmd = LatteCP_itDrawImmediate(cmd, nWords, drawPassCtx); - drawPassCtx.endDrawPass(); - break; - } - case IT_WAIT_REG_MEM: - { - cmd = LatteCP_itWaitRegMem(cmd, nWords); - LatteTiming_HandleTimedVsync(); - LatteAsyncCommands_checkAndExecute(); - } - break; - case IT_MEM_WRITE: - { - cmd = LatteCP_itMemWrite(cmd, nWords); - } - break; - case IT_CONTEXT_CONTROL: - { - cmd = LatteCP_itContextControl(cmd, nWords); - } - break; - case IT_MEM_SEMAPHORE: - { - cmd = LatteCP_itMemSemaphore(cmd, nWords); - } - break; - case IT_LOAD_CONFIG_REG: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONFIG); - } - break; - case IT_LOAD_CONTEXT_REG: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONTEXT); - } - break; - case IT_LOAD_ALU_CONST: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_ALU_CONST); - } - break; - case IT_LOAD_LOOP_CONST: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_LOOP_CONST); - } - break; - case IT_LOAD_RESOURCE: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_RESOURCE); - } - break; - case IT_LOAD_SAMPLER: - { - cmd = LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_SAMPLER); - } - break; - case IT_SET_PREDICATION: - { - cmd = LatteCP_itSetPredication(cmd, nWords); - } - break; - case IT_HLE_COPY_COLORBUFFER_TO_SCANBUFFER: - { - cmd = LatteCP_itHLECopyColorBufferToScanBuffer(cmd, nWords); - } - break; - case IT_HLE_TRIGGER_SCANBUFFER_SWAP: - { - cmd = LatteCP_itHLESwapScanBuffer(cmd, nWords); - } - break; - case IT_HLE_WAIT_FOR_FLIP: - { - cmd = LatteCP_itHLEWaitForFlip(cmd, nWords); - } - break; - case IT_HLE_REQUEST_SWAP_BUFFERS: - { - cmd = LatteCP_itHLERequestSwapBuffers(cmd, nWords); - } - break; - case IT_HLE_CLEAR_COLOR_DEPTH_STENCIL: - { - cmd = LatteCP_itHLEClearColorDepthStencil(cmd, nWords); - } - break; - case IT_HLE_COPY_SURFACE_NEW: - { - cmd = LatteCP_itHLECopySurfaceNew(cmd, nWords); - } - break; - case IT_HLE_SAMPLE_TIMER: - { - cmd = LatteCP_itHLESampleTimer(cmd, nWords); - } - break; - case IT_HLE_SPECIAL_STATE: - { - cmd = LatteCP_itHLESpecialState(cmd, nWords); - } - break; - case IT_HLE_BEGIN_OCCLUSION_QUERY: - { - cmd = LatteCP_itHLEBeginOcclusionQuery(cmd, nWords); - } - break; - case IT_HLE_END_OCCLUSION_QUERY: - { - cmd = LatteCP_itHLEEndOcclusionQuery(cmd, nWords); - } - break; - case IT_HLE_SET_CB_RETIREMENT_TIMESTAMP: - { - cmd = LatteCP_itHLESetRetirementTimestamp(cmd, nWords); - } - break; - case IT_HLE_BOTTOM_OF_PIPE_CB: - { - cmd = LatteCP_itHLEBottomOfPipeCB(cmd, nWords); - } - break; - case IT_HLE_SYNC_ASYNC_OPERATIONS: - { - LatteSkipCMD(nWords); - LatteTextureReadback_UpdateFinishedTransfers(true); - LatteQuery_UpdateFinishedQueriesForceFinishAll(); - } - break; - default: - debug_printf("Unhandled IT %02x\n", itCode); - cemu_assert_debug(false); - LatteSkipCMD(nWords); - } -#ifdef CEMU_DEBUG_ASSERT - if(cmd != expectedPostCmd) - debug_printf("cmd %016p expectedPostCmd %016p\n", cmd, expectedPostCmd); - cemu_assert_debug(cmd == expectedPostCmd); -#endif - } - else if (itHeaderType == 2) - { - // filler packet - // has no body - } - else if (itHeaderType == 0) - { - uint32 registerBase = (itHeader & 0xFFFF); - uint32 registerCount = ((itHeader >> 16) & 0x3FFF) + 1; - if (registerBase == 0x304A) - { - GX2::__GX2NotifyEvent(GX2::GX2CallbackEventType::TIMESTAMP_TOP); - LatteSkipCMD(registerCount); - } - else if (registerBase == 0x304B) - { - LatteSkipCMD(registerCount); + // filler packet } else { + // unsupported command for fast draw + drawPassCtx.endDrawPass(); + drawPassCtx.PushCurrentCommandQueuePos(cmdBeforeCommand, cmdStart, cmdEnd); + return; + } + } + } + if (drawPassCtx.isWithinDrawPass()) + drawPassCtx.endDrawPass(); +} + +void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx) +{ + while (true) + { + LatteCMDPtr cmd, cmdStart, cmdEnd; + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) + break; + while (cmd < cmdEnd) + { + uint32 itHeader = LatteReadCMD(); + uint32 itHeaderType = (itHeader >> 30) & 3; + if (itHeaderType == 3) + { + uint32 itCode = (itHeader >> 8) & 0xFF; + uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; + LatteCMDPtr cmdData = cmd; + cmd += nWords; + switch (itCode) + { + case IT_SET_CONTEXT_REG: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_RESOURCE: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_ALU_CONST: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_CTL_CONST: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_SAMPLER: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_CONFIG_REG: + { + LatteCP_itSetRegistersGeneric(cmdData, nWords); + } + break; + case IT_SET_LOOP_CONST: + { + // todo + } + break; + case IT_SURFACE_SYNC: + { + LatteCP_itSurfaceSync(cmdData); + } + break; + case IT_INDIRECT_BUFFER_PRIV: + { + drawPassCtx.PushCurrentCommandQueuePos(cmd, cmdStart, cmdEnd); + LatteCP_itIndirectBuffer(cmdData, nWords, drawPassCtx); + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) // switch to sub buffer + cemu_assert_debug(false); + } + break; + case IT_STRMOUT_BUFFER_UPDATE: + { + LatteCP_itStreamoutBufferUpdate(cmdData, nWords); + } + break; + case IT_INDEX_TYPE: + { + LatteCP_itIndexType(cmdData, nWords); + } + break; + case IT_NUM_INSTANCES: + { + LatteCP_itNumInstances(cmdData, nWords); + } + break; + case IT_DRAW_INDEX_2: + { + drawPassCtx.beginDrawPass(); + LatteCP_itDrawIndex2(cmdData, nWords, drawPassCtx); + // enter fast draw mode + drawPassCtx.PushCurrentCommandQueuePos(cmd, cmdStart, cmdEnd); + LatteCP_processCommandBuffer_continuousDrawPass(drawPassCtx); + cemu_assert_debug(!drawPassCtx.isWithinDrawPass()); + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) + return; + } + break; + case IT_DRAW_INDEX_AUTO: + { + drawPassCtx.beginDrawPass(); + LatteCP_itDrawIndexAuto(cmdData, nWords, drawPassCtx); + // enter fast draw mode + drawPassCtx.PushCurrentCommandQueuePos(cmd, cmdStart, cmdEnd); + LatteCP_processCommandBuffer_continuousDrawPass(drawPassCtx); + cemu_assert_debug(!drawPassCtx.isWithinDrawPass()); + if (!drawPassCtx.PopCurrentCommandQueuePos(cmd, cmdStart, cmdEnd)) + return; + } + break; + case IT_DRAW_INDEX_IMMD: + { + DrawPassContext drawPassCtx; + drawPassCtx.beginDrawPass(); + LatteCP_itDrawImmediate(cmdData, nWords, drawPassCtx); + drawPassCtx.endDrawPass(); + break; + } + case IT_WAIT_REG_MEM: + { + LatteCP_itWaitRegMem(cmdData, nWords); + LatteTiming_HandleTimedVsync(); + LatteAsyncCommands_checkAndExecute(); + break; + } + case IT_MEM_WRITE: + { + LatteCP_itMemWrite(cmdData, nWords); + break; + } + case IT_CONTEXT_CONTROL: + { + LatteCP_itContextControl(cmdData, nWords); + break; + } + case IT_MEM_SEMAPHORE: + { + LatteCP_itMemSemaphore(cmdData, nWords); + break; + } + case IT_LOAD_CONFIG_REG: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_CONFIG); + break; + } + case IT_LOAD_CONTEXT_REG: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_CONTEXT); + break; + } + case IT_LOAD_ALU_CONST: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_ALU_CONST); + break; + } + case IT_LOAD_LOOP_CONST: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_LOOP_CONST); + break; + } + case IT_LOAD_RESOURCE: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_RESOURCE); + break; + } + case IT_LOAD_SAMPLER: + { + LatteCP_itLoadReg(cmdData, nWords, LATTE_REG_BASE_SAMPLER); + break; + } + case IT_SET_PREDICATION: + { + LatteCP_itSetPredication(cmdData, nWords); + break; + } + case IT_HLE_COPY_COLORBUFFER_TO_SCANBUFFER: + { + LatteCP_itHLECopyColorBufferToScanBuffer(cmdData, nWords); + break; + } + case IT_HLE_TRIGGER_SCANBUFFER_SWAP: + { + LatteCP_itHLESwapScanBuffer(cmdData, nWords); + break; + } + case IT_HLE_WAIT_FOR_FLIP: + { + LatteCP_itHLEWaitForFlip(cmdData, nWords); + break; + } + case IT_HLE_REQUEST_SWAP_BUFFERS: + { + LatteCP_itHLERequestSwapBuffers(cmdData, nWords); + break; + } + case IT_HLE_CLEAR_COLOR_DEPTH_STENCIL: + { + LatteCP_itHLEClearColorDepthStencil(cmdData, nWords); + break; + } + case IT_HLE_COPY_SURFACE_NEW: + { + LatteCP_itHLECopySurfaceNew(cmdData, nWords); + break; + } + case IT_HLE_SAMPLE_TIMER: + { + LatteCP_itHLESampleTimer(cmdData, nWords); + break; + } + case IT_HLE_SPECIAL_STATE: + { + LatteCP_itHLESpecialState(cmdData, nWords); + break; + } + case IT_HLE_BEGIN_OCCLUSION_QUERY: + { + LatteCP_itHLEBeginOcclusionQuery(cmdData, nWords); + break; + } + case IT_HLE_END_OCCLUSION_QUERY: + { + LatteCP_itHLEEndOcclusionQuery(cmdData, nWords); + break; + } + case IT_HLE_SET_CB_RETIREMENT_TIMESTAMP: + { + LatteCP_itHLESetRetirementTimestamp(cmdData, nWords); + break; + } + case IT_HLE_BOTTOM_OF_PIPE_CB: + { + LatteCP_itHLEBottomOfPipeCB(cmdData, nWords); + break; + } + case IT_HLE_SYNC_ASYNC_OPERATIONS: + { + LatteTextureReadback_UpdateFinishedTransfers(true); + LatteQuery_UpdateFinishedQueriesForceFinishAll(); + break; + } + default: + debug_printf("Unhandled IT %02x\n", itCode); + cemu_assert_debug(false); + break; + } + } + else if (itHeaderType == 2) + { + // filler packet + // has no body + } + else if (itHeaderType == 0) + { + uint32 registerBase = (itHeader & 0xFFFF); + uint32 registerCount = ((itHeader >> 16) & 0x3FFF) + 1; + if (registerBase == 0x304A) + { + GX2::__GX2NotifyEvent(GX2::GX2CallbackEventType::TIMESTAMP_TOP); + LatteSkipCMD(registerCount); + } + else if (registerBase == 0x304B) + { + LatteSkipCMD(registerCount); + } + else + { + LatteCP_dumpCommandBufferError(cmdStart, cmdEnd, cmd); + cemu_assert_debug(false); + } + } + else + { + debug_printf("invalid itHeaderType %08x\n", itHeaderType); LatteCP_dumpCommandBufferError(cmdStart, cmdEnd, cmd); cemu_assert_debug(false); } } - else - { - debug_printf("invalid itHeaderType %08x\n", itHeaderType); - LatteCP_dumpCommandBufferError(cmdStart, cmdEnd, cmd); - cemu_assert_debug(false); - } + cemu_assert_debug(cmd == cmdEnd); } - cemu_assert_debug(cmd == cmdEnd); } void LatteCP_ProcessRingbuffer() { - sint32 timerRecheck = 0; // estimates how much CP processing time passed based on the executed commands, if the value exceeds CP_TIMER_RECHECK then _handleTimers() is called + sint32 timerRecheck = 0; // estimates how much CP processing time has elapsed based on the executed commands, if the value exceeds CP_TIMER_RECHECK then _handleTimers() is called while (true) { uint32 itHeader = LatteCP_readU32Deprc(); @@ -1365,80 +1391,73 @@ void LatteCP_ProcessRingbuffer() uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; LatteCP_waitForNWords(nWords); LatteCMDPtr cmd = (LatteCMDPtr)gxRingBufferReadPtr; - uint8* expectedGxRingBufferReadPtr = gxRingBufferReadPtr + nWords*4; + uint8* cmdEnd = gxRingBufferReadPtr + nWords * 4; + gxRingBufferReadPtr = cmdEnd; switch (itCode) { case IT_SURFACE_SYNC: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSurfaceSync(cmd); + LatteCP_itSurfaceSync(cmd); timerRecheck += CP_TIMER_RECHECK / 512; } break; case IT_SET_CONTEXT_REG: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; } break; case IT_SET_RESOURCE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; } break; case IT_SET_ALU_CONST: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_SET_CTL_CONST: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_SET_SAMPLER: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_SET_CONFIG_REG: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetRegistersGeneric(cmd, nWords); + LatteCP_itSetRegistersGeneric(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_INDIRECT_BUFFER_PRIV: { -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] BEGIN CMD BUFFER"); -#endif - LatteCP_itIndirectBufferDepr(nWords); + LatteCP_itIndirectBufferDepr(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; -#ifdef FAST_DRAW_LOGGING - if (GetAsyncKeyState('A')) - forceLogRemoveMe_printf("[FAST-DRAW] END CMD BUFFER"); -#endif break; } case IT_STRMOUT_BUFFER_UPDATE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itStreamoutBufferUpdate(cmd, nWords); + LatteCP_itStreamoutBufferUpdate(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_INDEX_TYPE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itIndexType(cmd, nWords); + LatteCP_itIndexType(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 1024; break; } case IT_NUM_INSTANCES: { - gxRingBufferReadPtr = (uint8*)LatteCP_itNumInstances(cmd, nWords); + LatteCP_itNumInstances(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 1024; break; } @@ -1446,7 +1465,7 @@ void LatteCP_ProcessRingbuffer() { DrawPassContext drawPassCtx; drawPassCtx.beginDrawPass(); - gxRingBufferReadPtr = (uint8*)LatteCP_itDrawIndex2(cmd, nWords, drawPassCtx); + LatteCP_itDrawIndex2(cmd, nWords, drawPassCtx); drawPassCtx.endDrawPass(); timerRecheck += CP_TIMER_RECHECK / 64; break; @@ -1455,7 +1474,7 @@ void LatteCP_ProcessRingbuffer() { DrawPassContext drawPassCtx; drawPassCtx.beginDrawPass(); - gxRingBufferReadPtr = (uint8*)LatteCP_itDrawIndexAuto(cmd, nWords, drawPassCtx); + LatteCP_itDrawIndexAuto(cmd, nWords, drawPassCtx); drawPassCtx.endDrawPass(); timerRecheck += CP_TIMER_RECHECK / 512; break; @@ -1464,165 +1483,162 @@ void LatteCP_ProcessRingbuffer() { DrawPassContext drawPassCtx; drawPassCtx.beginDrawPass(); - gxRingBufferReadPtr = (uint8*)LatteCP_itDrawImmediate(cmd, nWords, drawPassCtx); + LatteCP_itDrawImmediate(cmd, nWords, drawPassCtx); drawPassCtx.endDrawPass(); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_WAIT_REG_MEM: { - gxRingBufferReadPtr = (uint8*)LatteCP_itWaitRegMem(cmd, nWords); + LatteCP_itWaitRegMem(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 16; break; } case IT_MEM_WRITE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itMemWrite(cmd, nWords); + LatteCP_itMemWrite(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 128; break; } case IT_CONTEXT_CONTROL: { - gxRingBufferReadPtr = (uint8*)LatteCP_itContextControl(cmd, nWords); + LatteCP_itContextControl(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 128; break; } case IT_MEM_SEMAPHORE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itMemSemaphore(cmd, nWords); + LatteCP_itMemSemaphore(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 128; break; } case IT_LOAD_CONFIG_REG: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONFIG); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONFIG); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_LOAD_CONTEXT_REG: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONTEXT); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_CONTEXT); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_LOAD_ALU_CONST: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_ALU_CONST); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_ALU_CONST); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_LOAD_LOOP_CONST: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_LOOP_CONST); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_LOOP_CONST); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_LOAD_RESOURCE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_RESOURCE); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_RESOURCE); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_LOAD_SAMPLER: { - gxRingBufferReadPtr = (uint8*)LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_SAMPLER); + LatteCP_itLoadReg(cmd, nWords, LATTE_REG_BASE_SAMPLER); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_SET_LOOP_CONST: { - LatteSkipCMD(nWords); - gxRingBufferReadPtr = (uint8*)cmd; // todo break; } case IT_SET_PREDICATION: { - gxRingBufferReadPtr = (uint8*)LatteCP_itSetPredication(cmd, nWords); + LatteCP_itSetPredication(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_COPY_COLORBUFFER_TO_SCANBUFFER: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLECopyColorBufferToScanBuffer(cmd, nWords); + LatteCP_itHLECopyColorBufferToScanBuffer(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_HLE_TRIGGER_SCANBUFFER_SWAP: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLESwapScanBuffer(cmd, nWords); + LatteCP_itHLESwapScanBuffer(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_HLE_WAIT_FOR_FLIP: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEWaitForFlip(cmd, nWords); + LatteCP_itHLEWaitForFlip(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 1; break; } case IT_HLE_REQUEST_SWAP_BUFFERS: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLERequestSwapBuffers(cmd, nWords); + LatteCP_itHLERequestSwapBuffers(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 32; break; } case IT_HLE_CLEAR_COLOR_DEPTH_STENCIL: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEClearColorDepthStencil(cmd, nWords); + LatteCP_itHLEClearColorDepthStencil(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 128; break; } case IT_HLE_COPY_SURFACE_NEW: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLECopySurfaceNew(cmd, nWords); + LatteCP_itHLECopySurfaceNew(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 128; break; } case IT_HLE_FIFO_WRAP_AROUND: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEFifoWrapAround(cmd, nWords); - expectedGxRingBufferReadPtr = gxRingBufferReadPtr; + LatteCP_itHLEFifoWrapAround(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_SAMPLE_TIMER: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLESampleTimer(cmd, nWords); + LatteCP_itHLESampleTimer(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_SPECIAL_STATE: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLESpecialState(cmd, nWords); + LatteCP_itHLESpecialState(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_BEGIN_OCCLUSION_QUERY: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEBeginOcclusionQuery(cmd, nWords); + LatteCP_itHLEBeginOcclusionQuery(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_END_OCCLUSION_QUERY: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEEndOcclusionQuery(cmd, nWords); + LatteCP_itHLEEndOcclusionQuery(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_SET_CB_RETIREMENT_TIMESTAMP: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLESetRetirementTimestamp(cmd, nWords); + LatteCP_itHLESetRetirementTimestamp(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 512; break; } case IT_HLE_BOTTOM_OF_PIPE_CB: { - gxRingBufferReadPtr = (uint8*)LatteCP_itHLEBottomOfPipeCB(cmd, nWords); + LatteCP_itHLEBottomOfPipeCB(cmd, nWords); break; } case IT_HLE_SYNC_ASYNC_OPERATIONS: { - LatteCP_skipWords(nWords); + //LatteCP_skipWords(nWords); LatteTextureReadback_UpdateFinishedTransfers(true); LatteQuery_UpdateFinishedQueriesForceFinishAll(); break; @@ -1630,7 +1646,6 @@ void LatteCP_ProcessRingbuffer() default: cemu_assert_debug(false); } - cemu_assert_debug(expectedGxRingBufferReadPtr == gxRingBufferReadPtr); } else if (itHeaderType == 2) { @@ -1668,3 +1683,275 @@ void LatteCP_ProcessRingbuffer() } } } + +#ifdef LATTE_CP_LOGGING +void LatteCP_DebugPrintCmdBuffer(uint32be* bufferPtr, uint32 size) +{ + uint32be* bufferPtrInitial = bufferPtr; + uint32be* bufferPtrEnd = bufferPtr + (size/4); + while (bufferPtr < bufferPtrEnd) + { + std::string strPrefix = fmt::format("[PM4 Buf {:08x} Offs {:04x}]", MEMPTR(bufferPtr).GetMPTR(), (bufferPtr - bufferPtrInitial) * 4); + uint32 itHeader = *bufferPtr; + bufferPtr++; + uint32 itHeaderType = (itHeader >> 30) & 3; + if (itHeaderType == 3) + { + uint32 itCode = (itHeader >> 8) & 0xFF; + uint32 nWords = ((itHeader >> 16) & 0x3FFF) + 1; + uint32be* cmdData = bufferPtr; + bufferPtr += nWords; + switch (itCode) + { + case IT_SURFACE_SYNC: + { + cemuLog_log(LogType::Force, "{} IT_SURFACE_SYNC", strPrefix); + break; + } + case IT_SET_CONTEXT_REG: + { + std::string regVals; + for (uint32 i = 0; i < std::min(nWords - 1, 8); i++) + regVals.append(fmt::format("{:08x} ", cmdData[1 + i].value())); + cemuLog_log(LogType::Force, "{} IT_SET_CONTEXT_REG Reg {:04x} RegValues {}", strPrefix, cmdData[0].value(), regVals); + } + case IT_SET_RESOURCE: + { + std::string regVals; + for (uint32 i = 0; i < std::min(nWords - 1, 8); i++) + regVals.append(fmt::format("{:08x} ", cmdData[1+i].value())); + cemuLog_log(LogType::Force, "{} IT_SET_RESOURCE Reg {:04x} RegValues {}", strPrefix, cmdData[0].value(), regVals); + break; + } + case IT_SET_ALU_CONST: + { + cemuLog_log(LogType::Force, "{} IT_SET_ALU_CONST", strPrefix); + break; + } + case IT_SET_CTL_CONST: + { + cemuLog_log(LogType::Force, "{} IT_SET_CTL_CONST", strPrefix); + break; + } + case IT_SET_SAMPLER: + { + cemuLog_log(LogType::Force, "{} IT_SET_SAMPLER", strPrefix); + break; + } + case IT_SET_CONFIG_REG: + { + cemuLog_log(LogType::Force, "{} IT_SET_CONFIG_REG", strPrefix); + break; + } + case IT_INDIRECT_BUFFER_PRIV: + { + if (nWords != 3) + { + cemuLog_log(LogType::Force, "{} IT_INDIRECT_BUFFER_PRIV (malformed!)", strPrefix); + } + else + { + uint32 physicalAddress = cmdData[0]; + uint32 physicalAddressHigh = cmdData[1]; + uint32 sizeInDWords = cmdData[2]; + cemuLog_log(LogType::Force, "{} IT_INDIRECT_BUFFER_PRIV Addr {:08x} Size {:08x}", strPrefix, physicalAddress, sizeInDWords*4); + LatteCP_DebugPrintCmdBuffer(MEMPTR(physicalAddress), sizeInDWords * 4); + } + break; + } + case IT_STRMOUT_BUFFER_UPDATE: + { + cemuLog_log(LogType::Force, "{} IT_STRMOUT_BUFFER_UPDATE", strPrefix); + break; + } + case IT_INDEX_TYPE: + { + cemuLog_log(LogType::Force, "{} IT_INDEX_TYPE", strPrefix); + break; + } + case IT_NUM_INSTANCES: + { + cemuLog_log(LogType::Force, "{} IT_NUM_INSTANCES", strPrefix); + break; + } + case IT_DRAW_INDEX_2: + { + if (nWords != 5) + { + cemuLog_log(LogType::Force, "{} IT_DRAW_INDEX_2 (malformed!)", strPrefix); + } + else + { + uint32 ukn1 = cmdData[0]; + MPTR physIndices = cmdData[1]; + uint32 ukn2 = cmdData[2]; + uint32 count = cmdData[3]; + uint32 ukn3 = cmdData[4]; + cemuLog_log(LogType::Force, "{} IT_DRAW_INDEX_2 | Count {}", strPrefix, count); + } + break; + } + case IT_DRAW_INDEX_AUTO: + { + cemuLog_log(LogType::Force, "{} IT_DRAW_INDEX_AUTO", strPrefix); + break; + } + case IT_DRAW_INDEX_IMMD: + { + cemuLog_log(LogType::Force, "{} IT_DRAW_INDEX_IMMD", strPrefix); + break; + } + case IT_WAIT_REG_MEM: + { + cemuLog_log(LogType::Force, "{} IT_WAIT_REG_MEM", strPrefix); + break; + } + case IT_MEM_WRITE: + { + cemuLog_log(LogType::Force, "{} IT_MEM_WRITE", strPrefix); + break; + } + case IT_CONTEXT_CONTROL: + { + cemuLog_log(LogType::Force, "{} IT_CONTEXT_CONTROL", strPrefix); + break; + } + case IT_MEM_SEMAPHORE: + { + cemuLog_log(LogType::Force, "{} IT_MEM_SEMAPHORE", strPrefix); + break; + } + case IT_LOAD_CONFIG_REG: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_CONFIG_REG", strPrefix); + break; + } + case IT_LOAD_CONTEXT_REG: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_CONTEXT_REG", strPrefix); + break; + } + case IT_LOAD_ALU_CONST: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_ALU_CONST", strPrefix); + break; + } + case IT_LOAD_LOOP_CONST: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_LOOP_CONST", strPrefix); + break; + } + case IT_LOAD_RESOURCE: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_RESOURCE", strPrefix); + break; + } + case IT_LOAD_SAMPLER: + { + cemuLog_log(LogType::Force, "{} IT_LOAD_SAMPLER", strPrefix); + break; + } + case IT_SET_LOOP_CONST: + { + cemuLog_log(LogType::Force, "{} IT_SET_LOOP_CONST", strPrefix); + break; + } + case IT_SET_PREDICATION: + { + cemuLog_log(LogType::Force, "{} IT_SET_PREDICATION", strPrefix); + break; + } + case IT_HLE_COPY_COLORBUFFER_TO_SCANBUFFER: + { + cemuLog_log(LogType::Force, "{} IT_HLE_COPY_COLORBUFFER_TO_SCANBUFFER", strPrefix); + break; + } + case IT_HLE_TRIGGER_SCANBUFFER_SWAP: + { + cemuLog_log(LogType::Force, "{} IT_HLE_TRIGGER_SCANBUFFER_SWAP", strPrefix); + break; + } + case IT_HLE_WAIT_FOR_FLIP: + { + cemuLog_log(LogType::Force, "{} IT_HLE_WAIT_FOR_FLIP", strPrefix); + break; + } + case IT_HLE_REQUEST_SWAP_BUFFERS: + { + cemuLog_log(LogType::Force, "{} IT_HLE_REQUEST_SWAP_BUFFERS", strPrefix); + break; + } + case IT_HLE_CLEAR_COLOR_DEPTH_STENCIL: + { + cemuLog_log(LogType::Force, "{} IT_HLE_CLEAR_COLOR_DEPTH_STENCIL", strPrefix); + break; + } + case IT_HLE_COPY_SURFACE_NEW: + { + cemuLog_log(LogType::Force, "{} IT_HLE_COPY_SURFACE_NEW", strPrefix); + break; + } + case IT_HLE_FIFO_WRAP_AROUND: + { + cemuLog_log(LogType::Force, "{} IT_HLE_FIFO_WRAP_AROUND", strPrefix); + break; + } + case IT_HLE_SAMPLE_TIMER: + { + cemuLog_log(LogType::Force, "{} IT_HLE_SAMPLE_TIMER", strPrefix); + break; + } + case IT_HLE_SPECIAL_STATE: + { + cemuLog_log(LogType::Force, "{} IT_HLE_SPECIAL_STATE", strPrefix); + break; + } + case IT_HLE_BEGIN_OCCLUSION_QUERY: + { + cemuLog_log(LogType::Force, "{} IT_HLE_BEGIN_OCCLUSION_QUERY", strPrefix); + break; + } + case IT_HLE_END_OCCLUSION_QUERY: + { + cemuLog_log(LogType::Force, "{} IT_HLE_END_OCCLUSION_QUERY", strPrefix); + break; + } + case IT_HLE_SET_CB_RETIREMENT_TIMESTAMP: + { + cemuLog_log(LogType::Force, "{} IT_HLE_SET_CB_RETIREMENT_TIMESTAMP", strPrefix); + break; + } + case IT_HLE_BOTTOM_OF_PIPE_CB: + { + cemuLog_log(LogType::Force, "{} IT_HLE_BOTTOM_OF_PIPE_CB", strPrefix); + break; + } + case IT_HLE_SYNC_ASYNC_OPERATIONS: + { + cemuLog_log(LogType::Force, "{} IT_HLE_SYNC_ASYNC_OPERATIONS", strPrefix); + break; + } + default: + cemuLog_log(LogType::Force, "{} Unsupported operation code", strPrefix); + return; + } + } + else if (itHeaderType == 2) + { + // filler packet + } + else if (itHeaderType == 0) + { + uint32 registerBase = (itHeader & 0xFFFF); + uint32 registerCount = ((itHeader >> 16) & 0x3FFF) + 1; + LatteCP_skipWords(registerCount); + cemuLog_log(LogType::Force, "[LatteCP] itType=0 registerBase={:04x}", registerBase); + } + else + { + cemuLog_log(LogType::Force, "Invalid itHeaderType %08x\n", itHeaderType); + return; + } + } +} +#endif \ No newline at end of file diff --git a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp index ff5238d5..238f85e8 100644 --- a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp +++ b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp @@ -26,6 +26,7 @@ struct OverlayStats double fps{}; uint32 draw_calls_per_frame{}; + uint32 fast_draw_calls_per_frame{}; float cpu_usage{}; // cemu cpu usage in % std::vector cpu_per_core; // global cpu usage in % per core uint32 ram_usage{}; // ram usage in MB @@ -86,7 +87,7 @@ void LatteOverlay_renderOverlay(ImVec2& position, ImVec2& pivot, sint32 directio ImGui::Text("FPS: %.2lf", g_state.fps); if (config.overlay.drawcalls) - ImGui::Text("Draws/f: %d", g_state.draw_calls_per_frame); + ImGui::Text("Draws/f: %d (fast: %d)", g_state.draw_calls_per_frame, g_state.fast_draw_calls_per_frame); if (config.overlay.cpu_usage) ImGui::Text("CPU: %.2lf%%", g_state.cpu_usage); @@ -588,13 +589,14 @@ static void UpdateStats_CpuPerCore() } } -void LatteOverlay_updateStats(double fps, sint32 drawcalls) +void LatteOverlay_updateStats(double fps, sint32 drawcalls, sint32 fastDrawcalls) { if (GetConfig().overlay.position == ScreenPosition::kDisabled) return; g_state.fps = fps; g_state.draw_calls_per_frame = drawcalls; + g_state.fast_draw_calls_per_frame = fastDrawcalls; UpdateStats_CemuCpu(); UpdateStats_CpuPerCore(); diff --git a/src/Cafe/HW/Latte/Core/LatteOverlay.h b/src/Cafe/HW/Latte/Core/LatteOverlay.h index e497abb0..824c68b2 100644 --- a/src/Cafe/HW/Latte/Core/LatteOverlay.h +++ b/src/Cafe/HW/Latte/Core/LatteOverlay.h @@ -2,6 +2,6 @@ void LatteOverlay_init(); void LatteOverlay_render(bool pad_view); -void LatteOverlay_updateStats(double fps, sint32 drawcalls); +void LatteOverlay_updateStats(double fps, sint32 drawcalls, sint32 fastDrawcalls); void LatteOverlay_pushNotification(const std::string& text, sint32 duration); \ No newline at end of file diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp index 6bbc7ea4..f2767446 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp @@ -38,6 +38,7 @@ void LattePerformanceMonitor_frameEnd() uint64 indexDataCached = 0; uint32 frameCounter = 0; uint32 drawCallCounter = 0; + uint32 fastDrawCallCounter = 0; uint32 shaderBindCounter = 0; uint32 recompilerLeaveCount = 0; uint32 threadLeaveCount = 0; @@ -53,6 +54,7 @@ void LattePerformanceMonitor_frameEnd() indexDataCached += performanceMonitor.cycle[i].indexDataCached; frameCounter += performanceMonitor.cycle[i].frameCounter; drawCallCounter += performanceMonitor.cycle[i].drawCallCounter; + fastDrawCallCounter += performanceMonitor.cycle[i].fastDrawCallCounter; shaderBindCounter += performanceMonitor.cycle[i].shaderBindCount; recompilerLeaveCount += performanceMonitor.cycle[i].recompilerLeaveCount; threadLeaveCount += performanceMonitor.cycle[i].threadLeaveCount; @@ -75,7 +77,6 @@ void LattePerformanceMonitor_frameEnd() indexDataUploadPerFrame /= 1024ULL; double fps = (double)elapsedFrames2S * 1000.0 / (double)totalElapsedTimeFPS; - uint32 drawCallsPerFrame = drawCallCounter / elapsedFrames; uint32 shaderBindsPerFrame = shaderBindCounter / elapsedFrames; passedCycles = passedCycles * 1000ULL / totalElapsedTime; uint32 rlps = (uint32)((uint64)recompilerLeaveCount * 1000ULL / (uint64)totalElapsedTime); @@ -85,6 +86,7 @@ void LattePerformanceMonitor_frameEnd() // next counter cycle sint32 nextCycleIndex = (performanceMonitor.cycleIndex + 1) % PERFORMANCE_MONITOR_TRACK_CYCLES; performanceMonitor.cycle[nextCycleIndex].drawCallCounter = 0; + performanceMonitor.cycle[nextCycleIndex].fastDrawCallCounter = 0; performanceMonitor.cycle[nextCycleIndex].frameCounter = 0; performanceMonitor.cycle[nextCycleIndex].shaderBindCount = 0; performanceMonitor.cycle[nextCycleIndex].lastCycleCount = PPCInterpreter_getMainCoreCycleCounter(); @@ -104,12 +106,12 @@ void LattePerformanceMonitor_frameEnd() if (isFirstUpdate) { - LatteOverlay_updateStats(0.0, 0); + LatteOverlay_updateStats(0.0, 0, 0); gui_updateWindowTitles(false, false, 0.0); } else { - LatteOverlay_updateStats(fps, drawCallCounter / elapsedFrames); + LatteOverlay_updateStats(fps, drawCallCounter / elapsedFrames, fastDrawCallCounter / elapsedFrames); gui_updateWindowTitles(false, false, fps); } } diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h index 77554e80..713e094e 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h @@ -84,6 +84,7 @@ typedef struct uint32 lastUpdate; uint32 frameCounter; uint32 drawCallCounter; + uint32 fastDrawCallCounter; uint32 shaderBindCount; uint64 vertexDataUploaded; // amount of vertex data uploaded to GPU (bytes) uint64 vertexDataCached; // amount of vertex data reused from GPU cache (bytes) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 3a52f641..06015949 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -295,6 +295,34 @@ LatteTextureView* LatteMRT::GetColorAttachmentTexture(uint32 index, bool createN uint32 colorBufferHeight = pitchHeight / colorBufferPitch; uint32 colorBufferWidth = colorBufferPitch; + // colorbuffer width/height has to be padded to 8/32 alignment but the actual resolution might be smaller + // use the scissor box as a clue to figure out the original resolution if possible +#if 0 + uint32 scissorBoxWidth = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_X(); + uint32 scissorBoxHeight = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_Y(); + if (((scissorBoxWidth + 7) & ~7) == colorBufferWidth) + colorBufferWidth = scissorBoxWidth; + if (((colorBufferHeight + 31) & ~31) == colorBufferHeight) + colorBufferHeight = scissorBoxHeight; +#endif + + // log resolution changes if the above heuristic takes effect + // this is useful to find resolutions which need to be updated in gfx pack texture rules +#if 0 + uint32 colorBufferHeight2 = pitchHeight / colorBufferPitch; + static std::unordered_set s_foundColorBufferResMappings; + if (colorBufferPitch != colorBufferWidth || colorBufferHeight != colorBufferHeight2) + { + // only log unique, source and dest resolution. Encode into a key with 16 bits per component + uint64 resHash = (uint64)colorBufferWidth | ((uint64)colorBufferHeight << 16) | ((uint64)colorBufferPitch << 32) | ((uint64)colorBufferHeight2 << 48); + if( !s_foundColorBufferResMappings.contains(resHash) ) + { + s_foundColorBufferResMappings.insert(resHash); + cemuLog_log(LogType::Force, "[COLORBUFFER-DBG] Using res {}x{} instead of {}x{}", colorBufferWidth, colorBufferHeight, colorBufferPitch, colorBufferHeight2); + } + } +#endif + bool colorBufferWasFound = false; sint32 viewFirstMip = 0; // todo diff --git a/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp b/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp index 0483e8ee..a6e865d8 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp @@ -8,10 +8,11 @@ #include "Cafe/HW/Latte/Core/LatteTexture.h" #include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.h" -// #define LOG_READBACK_TIME +//#define LOG_READBACK_TIME struct LatteTextureReadbackQueueEntry { + HRTick initiateTime; uint32 lastUpdateDrawcallIndex; LatteTextureView* textureView; }; @@ -22,12 +23,12 @@ std::queue sTextureActiveReadbackQueue; // readbacks void LatteTextureReadback_StartTransfer(LatteTextureView* textureView) { cemuLog_log(LogType::TextureReadback, "[TextureReadback-Start] PhysAddr {:08x} Res {}x{} Fmt {} Slice {} Mip {}", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height, textureView->baseTexture->format, textureView->firstSlice, textureView->firstMip); + HRTick currentTick = HighResolutionTimer().now().getTick(); // create info entry and store in ordered linked list LatteTextureReadbackInfo* readbackInfo = g_renderer->texture_createReadback(textureView); sTextureActiveReadbackQueue.push(readbackInfo); readbackInfo->StartTransfer(); - //debug_printf("[Tex-Readback] %08x %dx%d TM %d FMT %04x\n", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height, textureView->baseTexture->tileMode, textureView->baseTexture->format); - readbackInfo->transferStartTime = HighResolutionTimer().now().getTick(); + readbackInfo->transferStartTime = currentTick; } /* @@ -41,9 +42,15 @@ bool LatteTextureReadback_Update(bool forceStart) for (size_t i = 0; i < sTextureScheduledReadbacks.size(); i++) { LatteTextureReadbackQueueEntry& entry = sTextureScheduledReadbacks[i]; - uint32 numPassedDrawcalls = LatteGPUState.drawCallCounter - entry.lastUpdateDrawcallIndex; - if (forceStart || numPassedDrawcalls >= 5) + uint32 numElapsedDrawcalls = LatteGPUState.drawCallCounter - entry.lastUpdateDrawcallIndex; + if (forceStart || numElapsedDrawcalls >= 5) { +#ifdef LOG_READBACK_TIME + double elapsedSecondsSinceInitiate = HighResolutionTimer::getTimeDiff(entry.initiateTime, HighResolutionTimer().now().getTick()); + char initiateElapsedTimeStr[32]; + sprintf(initiateElapsedTimeStr, "%.4lfms", elapsedSecondsSinceInitiate); + cemuLog_log(LogType::TextureReadback, "[TextureReadback-Update] Starting transfer for {:08x} after {} elapsed drawcalls. Time since initiate: {} Force-start: {}", entry.textureView->baseTexture->physAddress, numElapsedDrawcalls, initiateElapsedTimeStr, forceStart?"yes":"no"); +#endif LatteTextureReadback_StartTransfer(entry.textureView); // remove element vectorRemoveByIndex(sTextureScheduledReadbacks, i); @@ -91,6 +98,7 @@ void LatteTextureReadback_Initate(LatteTextureView* textureView) } // queue LatteTextureReadbackQueueEntry queueEntry; + queueEntry.initiateTime = HighResolutionTimer().now().getTick(); queueEntry.textureView = textureView; queueEntry.lastUpdateDrawcallIndex = LatteGPUState.drawCallCounter; sTextureScheduledReadbacks.emplace_back(queueEntry); @@ -112,6 +120,14 @@ void LatteTextureReadback_UpdateFinishedTransfers(bool forceFinish) if (!readbackInfo->IsFinished()) { readbackInfo->waitStartTime = HighResolutionTimer().now().getTick(); +#ifdef LOG_READBACK_TIME + if (cemuLog_isLoggingEnabled(LogType::TextureReadback)) + { + double elapsedSecondsTransfer = HighResolutionTimer::getTimeDiff(readbackInfo->transferStartTime, HighResolutionTimer().now().getTick()); + forceLog_printf("[Texture-Readback] Force-finish: %08x Res %4d/%4d TM %d FMT %04x Transfer time so far: %.4lfms", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0); + } +#endif + readbackInfo->forceFinish = true; readbackInfo->ForceFinish(); // rerun logic since ->ForceFinish() can recurively call this function and thus modify the queue continue; @@ -125,10 +141,13 @@ void LatteTextureReadback_UpdateFinishedTransfers(bool forceFinish) } // performance testing #ifdef LOG_READBACK_TIME - HRTick currentTick = HighResolutionTimer().now().getTick(); - double elapsedSecondsTransfer = HighResolutionTimer::getTimeDiff(readbackInfo->transferStartTime, currentTick); - double elapsedSecondsWaiting = HighResolutionTimer::getTimeDiff(readbackInfo->waitStartTime, currentTick); - cemuLog_log(LogType::Force, "[Texture-Readback] {:08x} Res {:4}/{:4} TM {} FMT {:04x} ReadbackLatency: {:6.3}ms WaitTime: {:6.3}ms ForcedWait {}", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0, elapsedSecondsWaiting * 1000.0, forceFinish?"yes":"no"); + if (cemuLog_isLoggingEnabled(LogType::TextureReadback)) + { + HRTick currentTick = HighResolutionTimer().now().getTick(); + double elapsedSecondsTransfer = HighResolutionTimer::getTimeDiff(readbackInfo->transferStartTime, currentTick); + double elapsedSecondsWaiting = HighResolutionTimer::getTimeDiff(readbackInfo->waitStartTime, currentTick); + forceLog_printf("[Texture-Readback] %08x Res %4d/%4d TM %d FMT %04x ReadbackLatency: %6.3lfms WaitTime: %6.3lfms ForcedWait %s", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0, elapsedSecondsWaiting * 1000.0, readbackInfo->forceFinish ? "yes" : "no"); + } #endif uint8* pixelData = readbackInfo->GetData(); LatteTextureLoader_writeReadbackTextureToMemory(&readbackInfo->hostTextureCopy, 0, 0, pixelData); diff --git a/src/Cafe/HW/Latte/Core/LatteTextureReadbackInfo.h b/src/Cafe/HW/Latte/Core/LatteTextureReadbackInfo.h index 4f3a3069..535e9442 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureReadbackInfo.h +++ b/src/Cafe/HW/Latte/Core/LatteTextureReadbackInfo.h @@ -21,6 +21,7 @@ public: HRTick transferStartTime; HRTick waitStartTime; + bool forceFinish{ false }; // set to true if not finished in time for dependent operation // texture info LatteTextureDefinition hostTextureCopy{}; diff --git a/src/Cafe/HW/Latte/ISA/LatteReg.h b/src/Cafe/HW/Latte/ISA/LatteReg.h index 7f0cf7c9..d571dc6e 100644 --- a/src/Cafe/HW/Latte/ISA/LatteReg.h +++ b/src/Cafe/HW/Latte/ISA/LatteReg.h @@ -484,7 +484,7 @@ namespace Latte SQ_TEX_RESOURCE_WORD0_N_GS = 0xE930, SQ_TEX_RESOURCE_WORD_FIRST = SQ_TEX_RESOURCE_WORD0_N_PS, SQ_TEX_RESOURCE_WORD_LAST = (SQ_TEX_RESOURCE_WORD0_N_GS + GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 7 - 1), - // there are 54 samplers with 3 registers each. 18 per stage. For stage indices see SAMPLER_BASE_INDEX_* + // there are 54 samplers with 3 registers each. 18 (actually only 16?) per stage. For stage indices see SAMPLER_BASE_INDEX_* SQ_TEX_SAMPLER_WORD0_0 = 0xF000, SQ_TEX_SAMPLER_WORD1_0 = 0xF001, SQ_TEX_SAMPLER_WORD2_0 = 0xF002, diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 7987b20e..c2e0a4f8 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2002,7 +2002,7 @@ void VulkanRenderer::SubmitCommandBuffer(VkSemaphore signalSemaphore, VkSemaphor occlusionQuery_notifyBeginCommandBuffer(); m_recordedDrawcalls = 0; - m_submitThreshold = 500; // this used to be 750 before 1.25.5, but more frequent submission is actually better for latency + m_submitThreshold = 300; m_submitOnIdle = false; } From 1d398551e25a35054ef51780a60756c3015ec312 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper Date: Tue, 19 Sep 2023 20:43:54 +0100 Subject: [PATCH 020/314] Add DS_Store to gitignore (#969) --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e7f104d2..9e9ff7df 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ bin/controllerProfiles/* bin/gameProfiles/* bin/graphicPacks/* + +# Ignore Finder view option files created by OS X +.DS_Store \ No newline at end of file From b4aa10bee4759518e05253d57d3029847bfc39b8 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:01:56 +0200 Subject: [PATCH 021/314] Vulkan: Only create imgui renderpass once (#972) --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 61 +++++++++++-------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 2 +- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index c2e0a4f8..2b8376d5 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1508,34 +1508,37 @@ void VulkanRenderer::DeleteNullObjects() void VulkanRenderer::ImguiInit() { - // TODO: renderpass swapchain format may change between srgb and rgb -> need reinit - VkAttachmentDescription colorAttachment = {}; - colorAttachment.format = m_mainSwapchainInfo->m_surfaceFormat.format; - colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT; - colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; - colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; - colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - colorAttachment.initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + if (m_imguiRenderPass == VK_NULL_HANDLE) + { + // TODO: renderpass swapchain format may change between srgb and rgb -> need reinit + VkAttachmentDescription colorAttachment = {}; + colorAttachment.format = m_mainSwapchainInfo->m_surfaceFormat.format; + colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT; + colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; + colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + colorAttachment.initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - VkAttachmentReference colorAttachmentRef = {}; - colorAttachmentRef.attachment = 0; - colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - VkSubpassDescription subpass = {}; - subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpass.colorAttachmentCount = 1; - subpass.pColorAttachments = &colorAttachmentRef; + VkAttachmentReference colorAttachmentRef = {}; + colorAttachmentRef.attachment = 0; + colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + VkSubpassDescription subpass = {}; + subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; + subpass.colorAttachmentCount = 1; + subpass.pColorAttachments = &colorAttachmentRef; - VkRenderPassCreateInfo renderPassInfo = {}; - renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - renderPassInfo.attachmentCount = 1; - renderPassInfo.pAttachments = &colorAttachment; - renderPassInfo.subpassCount = 1; - renderPassInfo.pSubpasses = &subpass; - const auto result = vkCreateRenderPass(m_logicalDevice, &renderPassInfo, nullptr, &m_imguiRenderPass); - if (result != VK_SUCCESS) - throw VkException(result, "can't create imgui renderpass"); + VkRenderPassCreateInfo renderPassInfo = {}; + renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; + renderPassInfo.attachmentCount = 1; + renderPassInfo.pAttachments = &colorAttachment; + renderPassInfo.subpassCount = 1; + renderPassInfo.pSubpasses = &subpass; + const auto result = vkCreateRenderPass(m_logicalDevice, &renderPassInfo, nullptr, &m_imguiRenderPass); + if (result != VK_SUCCESS) + throw VkException(result, "can't create imgui renderpass"); + } ImGui_ImplVulkan_InitInfo info{}; info.Instance = m_instance; @@ -1564,6 +1567,12 @@ void VulkanRenderer::Shutdown() Renderer::Shutdown(); SubmitCommandBuffer(); WaitDeviceIdle(); + + if (m_imguiRenderPass != VK_NULL_HANDLE) + { + vkDestroyRenderPass(m_logicalDevice, m_imguiRenderPass, nullptr); + m_imguiRenderPass = VK_NULL_HANDLE; + } } void VulkanRenderer::UnrecoverableError(const char* errMsg) const diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 147b6c15..24008ee3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -441,7 +441,7 @@ private: bool m_destroyPadSwapchainNextAcquire = false; bool IsSwapchainInfoValid(bool mainWindow) const; - VkRenderPass m_imguiRenderPass = nullptr; + VkRenderPass m_imguiRenderPass = VK_NULL_HANDLE; VkDescriptorPool m_descriptorPool; From 638c4014a1da1e2cff4000f4c6b64c7b75314055 Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Sat, 23 Sep 2023 03:20:22 +1000 Subject: [PATCH 022/314] nn_olv: Handle nullptr key in SetSearchKey (#974) --- src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.h index e6078a7a..62dad755 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_PostTypes.h @@ -531,6 +531,11 @@ namespace nn // SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCwUc static nnResult SetSearchKey(DownloadPostDataListParam* _this, const uint16be* searchKey, uint8 searchKeyIndex) { + if( !searchKey ) + { + memset(&_this->searchKeyArray[searchKeyIndex], 0, sizeof(SearchKey)); + return OLV_RESULT_SUCCESS; + } if (searchKeyIndex >= MAX_NUM_SEARCH_KEY) return OLV_RESULT_INVALID_PARAMETER; memset(&_this->searchKeyArray[searchKeyIndex], 0, sizeof(SearchKey)); @@ -546,6 +551,11 @@ namespace nn // SetSearchKey__Q3_2nn3olv25DownloadPostDataListParamFPCw static nnResult SetSearchKeySingle(DownloadPostDataListParam* _this, const uint16be* searchKey) { + if (searchKey == nullptr) + { + cemuLog_logDebug(LogType::NN_OLV, "DownloadPostDataListParam::SetSearchKeySingle: searchKeySingle is Null\n"); + return OLV_RESULT_INVALID_PARAMETER; + } return SetSearchKey(_this, searchKey, 0); } From 65e5e20afcb015670585699d21518ddd654d0b00 Mon Sep 17 00:00:00 2001 From: Leif Liddy Date: Wed, 27 Sep 2023 00:29:23 +0200 Subject: [PATCH 023/314] BUILD.md: Require libtool and libusb1-devel for Fedora (#979) --- BUILD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index da6c03ce..35aaffb7 100644 --- a/BUILD.md +++ b/BUILD.md @@ -36,7 +36,7 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required `sudo pacman -S --needed base-devel clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` #### For Fedora and derivatives: -`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel nasm ninja-build perl-core systemd-devel zlib-devel` +`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel nasm ninja-build perl-core systemd-devel zlib-devel` ### Build Cemu using cmake and clang 1. `git clone --recursive https://github.com/cemu-project/Cemu` From 4d6b72b353595d2a009884e62902d4f2663d5969 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 20 Sep 2023 04:54:36 +0200 Subject: [PATCH 024/314] Latte: Very minor refactor + optimization --- .../Renderer/Vulkan/VulkanRendererCore.cpp | 33 +++++++++---------- src/Common/precompiled.h | 3 ++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index c68c664f..9b47a14b 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -370,8 +370,12 @@ void VulkanRenderer::indexData_uploadIndexMemory(uint32 offset, uint32 size) // does nothing since the index buffer memory is coherent } +float s_vkUniformData[512 * 4]; + void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, LatteDecompilerShader* shader) { + auto GET_UNIFORM_DATA_PTR = [&](size_t index) { return s_vkUniformData + (index / 4); }; + sint32 shaderAluConst; sint32 shaderUniformRegisterOffset; @@ -390,27 +394,23 @@ void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, Latt shaderUniformRegisterOffset = mmSQ_GS_UNIFORM_BLOCK_START; break; default: - cemu_assert_debug(false); + UNREACHABLE; } if (shader->resourceMapping.uniformVarsBufferBindingPoint >= 0) { - float uniformData[512 * 4]; - if (shader->uniform.list_ufTexRescale.empty() == false) { for (auto& entry : shader->uniform.list_ufTexRescale) { float* xyScale = LatteTexture_getEffectiveTextureScale(shader->shaderType, entry.texUnit); - float* v = uniformData + (entry.uniformLocation / 4); memcpy(entry.currentValue, xyScale, sizeof(float) * 2); - memcpy(v, xyScale, sizeof(float) * 2); + memcpy(GET_UNIFORM_DATA_PTR(entry.uniformLocation), xyScale, sizeof(float) * 2); } } if (shader->uniform.loc_alphaTestRef >= 0) { - float* v = uniformData + (shader->uniform.loc_alphaTestRef / 4); - v[0] = LatteGPUState.contextNew.SX_ALPHA_REF.get_ALPHA_TEST_REF(); + *GET_UNIFORM_DATA_PTR(shader->uniform.loc_alphaTestRef) = LatteGPUState.contextNew.SX_ALPHA_REF.get_ALPHA_TEST_REF(); } if (shader->uniform.loc_pointSize >= 0) { @@ -418,41 +418,38 @@ void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, Latt float pointWidth = (float)pointSizeReg.get_WIDTH() / 8.0f; if (pointWidth == 0.0f) pointWidth = 1.0f / 8.0f; // minimum size - float* v = uniformData + (shader->uniform.loc_pointSize / 4); - v[0] = pointWidth; + *GET_UNIFORM_DATA_PTR(shader->uniform.loc_pointSize) = pointWidth; } if (shader->uniform.loc_remapped >= 0) { - LatteBufferCache_LoadRemappedUniforms(shader, uniformData + (shader->uniform.loc_remapped / 4)); + LatteBufferCache_LoadRemappedUniforms(shader, GET_UNIFORM_DATA_PTR(shader->uniform.loc_remapped)); } if (shader->uniform.loc_uniformRegister >= 0) { uint32* uniformRegData = (uint32*)(LatteGPUState.contextRegister + mmSQ_ALU_CONSTANT0_0 + shaderAluConst); - float* v = uniformData + (shader->uniform.loc_uniformRegister / 4); - memcpy(v, uniformRegData, shader->uniform.count_uniformRegister * 16); + memcpy(GET_UNIFORM_DATA_PTR(shader->uniform.loc_uniformRegister), uniformRegData, shader->uniform.count_uniformRegister * 16); } if (shader->uniform.loc_windowSpaceToClipSpaceTransform >= 0) { sint32 viewportWidth; sint32 viewportHeight; LatteRenderTarget_GetCurrentVirtualViewportSize(&viewportWidth, &viewportHeight); // always call after _updateViewport() - float* v = uniformData + (shader->uniform.loc_windowSpaceToClipSpaceTransform / 4); + float* v = GET_UNIFORM_DATA_PTR(shader->uniform.loc_windowSpaceToClipSpaceTransform); v[0] = 2.0f / (float)viewportWidth; v[1] = 2.0f / (float)viewportHeight; } if (shader->uniform.loc_fragCoordScale >= 0) { - float* coordScale = uniformData + (shader->uniform.loc_fragCoordScale / 4); - LatteMRT::GetCurrentFragCoordScale(coordScale); + LatteMRT::GetCurrentFragCoordScale(GET_UNIFORM_DATA_PTR(shader->uniform.loc_fragCoordScale)); } if (shader->uniform.loc_verticesPerInstance >= 0) { - *(int*)(uniformData + (shader->uniform.loc_verticesPerInstance / 4)) = m_streamoutState.verticesPerInstance; + *(int*)(s_vkUniformData + ((size_t)shader->uniform.loc_verticesPerInstance / 4)) = m_streamoutState.verticesPerInstance; for (sint32 b = 0; b < LATTE_NUM_STREAMOUT_BUFFER; b++) { if (shader->uniform.loc_streamoutBufferBase[b] >= 0) { - *(int*)(uniformData + (shader->uniform.loc_streamoutBufferBase[b] / 4)) = m_streamoutState.buffer[b].ringBufferOffset; + *(uint32*)GET_UNIFORM_DATA_PTR(shader->uniform.loc_streamoutBufferBase[b]) = m_streamoutState.buffer[b].ringBufferOffset; } } } @@ -463,7 +460,7 @@ void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, Latt } uint32 bufferAlignmentM1 = std::max(m_featureControl.limits.minUniformBufferOffsetAlignment, m_featureControl.limits.nonCoherentAtomSize) - 1; const uint32 uniformOffset = m_uniformVarBufferWriteIndex; - memcpy(m_uniformVarBufferPtr + uniformOffset, uniformData, shader->uniform.uniformRangeSize); + memcpy(m_uniformVarBufferPtr + uniformOffset, s_vkUniformData, shader->uniform.uniformRangeSize); m_uniformVarBufferWriteIndex += shader->uniform.uniformRangeSize; m_uniformVarBufferWriteIndex = (m_uniformVarBufferWriteIndex + bufferAlignmentM1) & ~bufferAlignmentM1; // update dynamic offset diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 7152f2c1..580aeb23 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -235,10 +235,13 @@ inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, #if defined(_MSC_VER) #define UNREACHABLE __assume(false) + #define ASSUME(__cond) __assume(__cond) #elif defined(__GNUC__) #define UNREACHABLE __builtin_unreachable() + #define ASSUME(__cond) __attribute__((assume(__cond))) #else #define UNREACHABLE + #define ASSUME(__cond) #endif #if defined(_MSC_VER) From 3e925b77074ec50fe5f6c825d12c56cb5b9d44f5 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 23 Sep 2023 22:53:57 +0200 Subject: [PATCH 025/314] Latte: Bound uniform buffers based on access patterns within the shader --- src/Cafe/HW/Latte/Core/LatteBufferData.cpp | 12 +-- .../LegacyShaderDecompiler/LatteDecompiler.h | 13 ++-- .../LatteDecompilerAnalyzer.cpp | 74 +++++++++---------- .../LatteDecompilerEmitGLSLHeader.hpp | 30 +------- .../LatteDecompilerInternal.h | 70 ++++++++++++++---- .../Renderer/Vulkan/VulkanRendererCore.cpp | 8 +- 6 files changed, 114 insertions(+), 93 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteBufferData.cpp b/src/Cafe/HW/Latte/Core/LatteBufferData.cpp index d31a8651..85d4cdf7 100644 --- a/src/Cafe/HW/Latte/Core/LatteBufferData.cpp +++ b/src/Cafe/HW/Latte/Core/LatteBufferData.cpp @@ -132,22 +132,18 @@ void LatteBufferCache_syncGPUUniformBuffers(LatteDecompilerShader* shader, const { if (shader->uniformMode == LATTE_DECOMPILER_UNIFORM_MODE_FULL_CBANK) { - // use full uniform buffers - for (sint32 t = 0; t < shader->uniformBufferListCount; t++) + for(const auto& buf : shader->list_quickBufferList) { - sint32 i = shader->uniformBufferList[t]; + sint32 i = buf.index; MPTR physicalAddr = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 0]; uint32 uniformSize = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 1] + 1; - - if (physicalAddr == MPTR_NULL) + if (physicalAddr == MPTR_NULL) [[unlikely]] { - // no data g_renderer->buffer_bindUniformBuffer(shaderType, i, 0, 0); continue; } - + uniformSize = std::min(uniformSize, buf.size); uint32 bindOffset = LatteBufferCache_retrieveDataInCache(physicalAddr, uniformSize); - g_renderer->buffer_bindUniformBuffer(shaderType, i, bindOffset, uniformSize); } } diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h index f7a0ea5f..92777844 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h @@ -1,6 +1,7 @@ #pragma once #include "Cafe/HW/Latte/Core/LatteConst.h" #include "Cafe/HW/Latte/Renderer/RendererShader.h" +#include namespace LatteDecompiler { @@ -158,11 +159,13 @@ struct LatteDecompilerShader struct LatteFetchShader* compatibleFetchShader{}; // error tracking bool hasError{false}; // if set, the shader cannot be used - // optimized access / iteration - // list of uniform buffers used - uint8 uniformBufferList[LATTE_NUM_MAX_UNIFORM_BUFFERS]; - uint8 uniformBufferListCount{ 0 }; - // list of used texture units (faster access than iterating textureUnitMask) + // compact resource lists for optimized access + struct QuickBufferEntry + { + uint8 index; + uint16 size; + }; + boost::container::static_vector list_quickBufferList; uint8 textureUnitList[LATTE_NUM_MAX_TEX_UNITS]; uint8 textureUnitListCount{ 0 }; // input diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index e482be2c..7285d312 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -230,47 +230,39 @@ void LatteDecompiler_analyzeALUClause(LatteDecompilerShaderContext* shaderContex // check input for uniform access if( aluInstruction.sourceOperand[f].sel == 0xFFFFFFFF ) continue; // source operand not set/used + // about uniform register and buffer access tracking: + // for absolute indices we can determine a maximum size that is accessed + // relative accesses are tricky because the upper bound of accessed indices is unknown + // worst case we have to load the full file (256 * 16 byte entries) or for buffers an arbitrary upper bound (64KB in our case) if( GPU7_ALU_SRC_IS_CFILE(aluInstruction.sourceOperand[f].sel) ) { - // uniform register access - - // relative register file accesses are tricky because the range of possible indices is unknown - // worst case we have to load the full file (256 * 16 byte entries) - // by tracking the accessed base indices the shader analyzer can determine bounds for the potentially accessed ranges - - shaderContext->analyzer.uniformRegisterAccess = true; if (aluInstruction.sourceOperand[f].rel) { - shaderContext->analyzer.uniformRegisterDynamicAccess = true; - shaderContext->analyzer.uniformRegisterAccessIndices.emplace_back(GPU7_ALU_SRC_GET_CFILE_INDEX(aluInstruction.sourceOperand[f].sel), true); + shaderContext->analyzer.uniformRegisterAccessTracker.TrackAccess(GPU7_ALU_SRC_GET_CFILE_INDEX(aluInstruction.sourceOperand[f].sel), true); } else { _remapUniformAccess(shaderContext, true, 0, GPU7_ALU_SRC_GET_CFILE_INDEX(aluInstruction.sourceOperand[f].sel)); - shaderContext->analyzer.uniformRegisterAccessIndices.emplace_back(GPU7_ALU_SRC_GET_CFILE_INDEX(aluInstruction.sourceOperand[f].sel), false); + shaderContext->analyzer.uniformRegisterAccessTracker.TrackAccess(GPU7_ALU_SRC_GET_CFILE_INDEX(aluInstruction.sourceOperand[f].sel), false); } } else if( GPU7_ALU_SRC_IS_CBANK0(aluInstruction.sourceOperand[f].sel) ) { // uniform bank 0 (uniform buffer with index cfInstruction->cBank0Index) uint32 uniformBufferIndex = cfInstruction->cBank0Index; - if( uniformBufferIndex >= LATTE_NUM_MAX_UNIFORM_BUFFERS) - debugBreakpoint(); - shaderContext->analyzer.uniformBufferAccessMask |= (1<analyzer.uniformBufferDynamicAccessMask |= (1<cBank0AddrBase); + cemu_assert(uniformBufferIndex < LATTE_NUM_MAX_UNIFORM_BUFFERS); + uint32 offset = GPU7_ALU_SRC_GET_CBANK0_INDEX(aluInstruction.sourceOperand[f].sel)+cfInstruction->cBank0AddrBase; + _remapUniformAccess(shaderContext, false, uniformBufferIndex, offset); + shaderContext->analyzer.uniformBufferAccessTracker[uniformBufferIndex].TrackAccess(offset, aluInstruction.sourceOperand[f].rel); } else if( GPU7_ALU_SRC_IS_CBANK1(aluInstruction.sourceOperand[f].sel) ) { // uniform bank 1 (uniform buffer with index cfInstruction->cBank1Index) uint32 uniformBufferIndex = cfInstruction->cBank1Index; - if( uniformBufferIndex >= LATTE_NUM_MAX_UNIFORM_BUFFERS) - debugBreakpoint(); - shaderContext->analyzer.uniformBufferAccessMask |= (1<analyzer.uniformBufferDynamicAccessMask |= (1<cBank1AddrBase); + cemu_assert(uniformBufferIndex < LATTE_NUM_MAX_UNIFORM_BUFFERS); + uint32 offset = GPU7_ALU_SRC_GET_CBANK1_INDEX(aluInstruction.sourceOperand[f].sel)+cfInstruction->cBank1AddrBase; + _remapUniformAccess(shaderContext, false, uniformBufferIndex, offset); + shaderContext->analyzer.uniformBufferAccessTracker[uniformBufferIndex].TrackAccess(offset, aluInstruction.sourceOperand[f].rel); } else if( GPU7_ALU_SRC_IS_GPR(aluInstruction.sourceOperand[f].sel) ) { @@ -360,8 +352,7 @@ void LatteDecompiler_analyzeTEXClause(LatteDecompilerShaderContext* shaderContex if( texInstruction.textureFetch.textureIndex >= 0x80 && texInstruction.textureFetch.textureIndex <= 0x8F ) { uint32 uniformBufferIndex = texInstruction.textureFetch.textureIndex - 0x80; - shaderContext->analyzer.uniformBufferAccessMask |= (1<analyzer.uniformBufferDynamicAccessMask |= (1<analyzer.uniformBufferAccessTracker[uniformBufferIndex].TrackAccess(0, true); } else if( texInstruction.textureFetch.textureIndex == 0x9F && shader->shaderType == LatteConst::ShaderType::Geometry ) { @@ -576,7 +567,7 @@ namespace LatteDecompiler // for Vulkan we use consecutive indices for (uint32 i = 0; i < LATTE_NUM_MAX_UNIFORM_BUFFERS; i++) { - if ((decompilerContext->analyzer.uniformBufferAccessMask&(1 << i)) == 0) + if (!decompilerContext->analyzer.uniformBufferAccessTracker[i].HasAccess()) continue; sint32 uniformBindingPoint = i; if (decompilerContext->shaderType == LatteConst::ShaderType::Geometry) @@ -592,7 +583,7 @@ namespace LatteDecompiler // for OpenGL we use the relative buffer index for (uint32 i = 0; i < LATTE_NUM_MAX_UNIFORM_BUFFERS; i++) { - if ((decompilerContext->analyzer.uniformBufferAccessMask&(1 << i)) == 0) + if (!decompilerContext->analyzer.uniformBufferAccessTracker[i].HasAccess()) continue; sint32 uniformBindingPoint = i; if (decompilerContext->shaderType == LatteConst::ShaderType::Geometry) @@ -765,17 +756,24 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD LatteDecompiler_analyzeSubroutine(shaderContext, subroutineAddr); } // decide which uniform mode to use - if(shaderContext->analyzer.uniformBufferAccessMask != 0 && shaderContext->analyzer.uniformRegisterAccess ) - debugBreakpoint(); // not allowed - if(shaderContext->analyzer.uniformBufferDynamicAccessMask != 0 ) + bool hasAnyDynamicBufferAccess = false; + bool hasAnyBufferAccess = false; + for(auto& it : shaderContext->analyzer.uniformBufferAccessTracker) + { + if( it.HasRelativeAccess() ) + hasAnyDynamicBufferAccess = true; + if( it.HasAccess() ) + hasAnyBufferAccess = true; + } + if (hasAnyDynamicBufferAccess) { shader->uniformMode = LATTE_DECOMPILER_UNIFORM_MODE_FULL_CBANK; } - else if(shaderContext->analyzer.uniformRegisterDynamicAccess ) + else if(shaderContext->analyzer.uniformRegisterAccessTracker.HasRelativeAccess() ) { shader->uniformMode = LATTE_DECOMPILER_UNIFORM_MODE_FULL_CFILE; } - else if(shaderContext->analyzer.uniformBufferAccessMask != 0 || shaderContext->analyzer.uniformRegisterAccess != 0 ) + else if(hasAnyBufferAccess || shaderContext->analyzer.uniformRegisterAccessTracker.HasAccess() ) { shader->uniformMode = LATTE_DECOMPILER_UNIFORM_MODE_REMAPPED; } @@ -783,16 +781,18 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD { shader->uniformMode = LATTE_DECOMPILER_UNIFORM_MODE_NONE; } - // generate list of uniform buffers based on uniformBufferAccessMask (for faster access) - shader->uniformBufferListCount = 0; + // generate compact list of uniform buffers (for faster access) + cemu_assert_debug(shader->list_quickBufferList.empty()); for (uint32 i = 0; i < LATTE_NUM_MAX_UNIFORM_BUFFERS; i++) { - if( !HAS_FLAG(shaderContext->analyzer.uniformBufferAccessMask, (1<analyzer.uniformBufferAccessTracker[i].HasAccess() ) continue; - shader->uniformBufferList[shader->uniformBufferListCount] = i; - shader->uniformBufferListCount++; + LatteDecompilerShader::QuickBufferEntry entry; + entry.index = i; + entry.size = shaderContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE) * 16; + shader->list_quickBufferList.push_back(entry); } - // get dimension of each used textures + // get dimension of each used texture _LatteRegisterSetTextureUnit* texRegs = nullptr; if( shader->shaderType == LatteConst::ShaderType::Vertex ) texRegs = shaderContext->contextRegistersNew->SQ_TEX_START_VS; diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp index 0bd4eb6f..21cae093 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp @@ -37,36 +37,14 @@ namespace LatteDecompiler } else if (decompilerContext->shader->uniformMode == LATTE_DECOMPILER_UNIFORM_MODE_FULL_CFILE) { - // here we try to predict the accessed range so we dont have to upload the whole register file - // we assume that if there is a fixed-index access on an index higher than a relative access, it bounds the prior relative access - sint16 highestAccessIndex = -1; - bool highestAccessIndexIsRel = false; - for(auto& accessItr : decompilerContext->analyzer.uniformRegisterAccessIndices) - { - if (accessItr.index > highestAccessIndex || (accessItr.index == highestAccessIndex && accessItr.isRelative && !highestAccessIndexIsRel)) - { - highestAccessIndex = accessItr.index; - highestAccessIndexIsRel = accessItr.isRelative; - } - } - if (highestAccessIndex < 0) - highestAccessIndex = 0; - - uint32 cfileSize; - if (highestAccessIndexIsRel) - cfileSize = 256; - else - cfileSize = highestAccessIndex + 1; - - // full uniform register file has to be present + uint32 cfileSize = decompilerContext->analyzer.uniformRegisterAccessTracker.DetermineSize(256); + // full or partial uniform register file has to be present if (shaderType == LatteConst::ShaderType::Vertex) shaderSrc->addFmt("uniform ivec4 uf_uniformRegisterVS[{}];" _CRLF, cfileSize); else if (shaderType == LatteConst::ShaderType::Pixel) shaderSrc->addFmt("uniform ivec4 uf_uniformRegisterPS[{}];" _CRLF, cfileSize); else if (shaderType == LatteConst::ShaderType::Geometry) shaderSrc->addFmt("uniform ivec4 uf_uniformRegisterGS[{}];" _CRLF, cfileSize); - else - debugBreakpoint(); uniformOffsets.offset_uniformRegister = uniformCurrentOffset; uniformOffsets.count_uniformRegister = cfileSize; uniformCurrentOffset += 16 * cfileSize; @@ -168,7 +146,7 @@ namespace LatteDecompiler { for (uint32 i = 0; i < LATTE_NUM_MAX_UNIFORM_BUFFERS; i++) { - if ((decompilerContext->analyzer.uniformBufferAccessMask&(1 << i)) == 0) + if (!decompilerContext->analyzer.uniformBufferAccessTracker[i].HasAccess()) continue; cemu_assert_debug(decompilerContext->output->resourceMappingGL.uniformBuffersBindingPoint[i] >= 0); @@ -178,7 +156,7 @@ namespace LatteDecompiler shaderSrc->addFmt("uniform {}{}" _CRLF, _getShaderUniformBlockInterfaceName(decompilerContext->shaderType), i); shaderSrc->add("{" _CRLF); - shaderSrc->addFmt("vec4 {}{}[{}];" _CRLF, _getShaderUniformBlockVariableName(decompilerContext->shaderType), i, LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE); + shaderSrc->addFmt("vec4 {}{}[{}];" _CRLF, _getShaderUniformBlockVariableName(decompilerContext->shaderType), i, decompilerContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE)); shaderSrc->add("};" _CRLF _CRLF); shaderSrc->add(_CRLF); } diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h index 53fb61ef..54112ddf 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h @@ -125,19 +125,66 @@ struct LatteDecompilerCFInstruction LatteDecompilerCFInstruction& operator=(LatteDecompilerCFInstruction&& mE) = default; }; -struct LatteDecompilerCFileAccess -{ - LatteDecompilerCFileAccess(uint8 index, bool isRelative) : index(index), isRelative(isRelative) {}; - uint8 index; - bool isRelative; -}; - struct LatteDecompilerSubroutineInfo { uint32 cfAddr; std::vector instructions; }; +// helper struct to track the highest accessed offset within a buffer +struct LatteDecompilerBufferAccessTracker +{ + bool hasStaticIndexAccess{false}; + bool hasDynamicIndexAccess{false}; + sint32 highestAccessDynamicIndex{0}; + sint32 highestAccessStaticIndex{0}; + + // track access, index is the array index and not a byte offset + void TrackAccess(sint32 index, bool isDynamicIndex) + { + if (isDynamicIndex) + { + hasDynamicIndexAccess = true; + if (index > highestAccessDynamicIndex) + highestAccessDynamicIndex = index; + } + else + { + hasStaticIndexAccess = true; + if (index > highestAccessStaticIndex) + highestAccessStaticIndex = index; + } + } + + sint32 DetermineSize(sint32 maximumSize) const + { + // here we try to predict the accessed range so we dont have to upload the whole buffer + // potential risky optimization: assume that if there is a fixed-index access on an index higher than any other non-zero relative accesses, it bounds the prior relative access + sint32 highestAccessIndex = -1; + if(hasStaticIndexAccess) + { + highestAccessIndex = highestAccessStaticIndex; + } + if(hasDynamicIndexAccess) + { + return maximumSize; // dynamic index exists and no bound can be determined + } + if (highestAccessIndex < 0) + return 1; // no access at all? But avoid zero as a size + return highestAccessIndex + 1; + } + + bool HasAccess() const + { + return hasStaticIndexAccess || hasDynamicIndexAccess; + } + + bool HasRelativeAccess() const + { + return hasDynamicIndexAccess; + } +}; + struct LatteDecompilerShaderContext { LatteDecompilerOutput_t* output; @@ -174,12 +221,9 @@ struct LatteDecompilerShaderContext bool isPointsPrimitive{}; // set if current render primitive is points bool outputPointSize{}; // set if the current shader should output the point size std::bitset<256> inputAttributSemanticMask; // one set bit for every used semanticId - todo: there are only 128 bit available semantic locations? The MSB has special meaning? - // uniform - bool uniformRegisterAccess; // set to true if cfile (uniform register) is accessed - bool uniformRegisterDynamicAccess; // set to true if cfile (uniform register) is accessed with a dynamic index - uint32 uniformBufferAccessMask; // 1 bit per buffer, set if the uniform buffer is accessed - uint32 uniformBufferDynamicAccessMask; // 1 bit per buffer, set if the uniform buffer is accessed by dynamic index - std::vector uniformRegisterAccessIndices; + // uniforms + LatteDecompilerBufferAccessTracker uniformRegisterAccessTracker; + LatteDecompilerBufferAccessTracker uniformBufferAccessTracker[LATTE_NUM_MAX_UNIFORM_BUFFERS]; // ssbo bool hasSSBORead; // shader has instructions that read from SSBO bool hasSSBOWrite; // shader has instructions that write to SSBO diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 9b47a14b..5bffcc68 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -1591,10 +1591,9 @@ void VulkanRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader { if (shader->uniformMode == LATTE_DECOMPILER_UNIFORM_MODE_FULL_CBANK) { - // use full uniform buffers - for (sint32 t = 0; t < shader->uniformBufferListCount; t++) + for(const auto& buf : shader->list_quickBufferList) { - sint32 i = shader->uniformBufferList[t]; + sint32 i = buf.index; MPTR physicalAddr = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 0]; uint32 uniformSize = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 1] + 1; @@ -1603,6 +1602,7 @@ void VulkanRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader cemu_assert_unimplemented(); continue; } + uniformSize = std::min(uniformSize, buf.size); cemu_assert_debug(physicalAddr < 0x50000000); @@ -1621,7 +1621,7 @@ void VulkanRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT].unformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; break; default: - cemu_assert_debug(false); + UNREACHABLE; } } } From f9f62069298f201448291a6037396618294cfe62 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Sep 2023 08:11:57 +0200 Subject: [PATCH 026/314] Vulkan: Add profiler for Vulkan API CPU cost Disabled by default. Set VULKAN_API_CPU_BENCHMARK to 1 to enable --- .../HW/Latte/Core/LatteTextureReadback.cpp | 12 ++- .../HW/Latte/Renderer/Vulkan/VulkanAPI.cpp | 82 ++++++++++++++++++- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h | 9 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 5 ++ .../Renderer/Vulkan/VulkanRendererCore.cpp | 4 +- 5 files changed, 99 insertions(+), 13 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp b/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp index a6e865d8..8df5dcea 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureReadback.cpp @@ -8,7 +8,7 @@ #include "Cafe/HW/Latte/Core/LatteTexture.h" #include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.h" -//#define LOG_READBACK_TIME +#define LOG_READBACK_TIME struct LatteTextureReadbackQueueEntry { @@ -47,9 +47,7 @@ bool LatteTextureReadback_Update(bool forceStart) { #ifdef LOG_READBACK_TIME double elapsedSecondsSinceInitiate = HighResolutionTimer::getTimeDiff(entry.initiateTime, HighResolutionTimer().now().getTick()); - char initiateElapsedTimeStr[32]; - sprintf(initiateElapsedTimeStr, "%.4lfms", elapsedSecondsSinceInitiate); - cemuLog_log(LogType::TextureReadback, "[TextureReadback-Update] Starting transfer for {:08x} after {} elapsed drawcalls. Time since initiate: {} Force-start: {}", entry.textureView->baseTexture->physAddress, numElapsedDrawcalls, initiateElapsedTimeStr, forceStart?"yes":"no"); + cemuLog_log(LogType::TextureReadback, "[TextureReadback-Update] Starting transfer for {:08x} after {} elapsed drawcalls. Time since initiate: {:.4} Force-start: {}", entry.textureView->baseTexture->physAddress, numElapsedDrawcalls, elapsedSecondsSinceInitiate, forceStart?"yes":"no"); #endif LatteTextureReadback_StartTransfer(entry.textureView); // remove element @@ -83,7 +81,7 @@ void LatteTextureReadback_Initate(LatteTextureView* textureView) // currently we don't support readback for resized textures if (textureView->baseTexture->overwriteInfo.hasResolutionOverwrite) { - cemuLog_log(LogType::Force, "_initate(): Readback is not supported for textures with modified resolution"); + cemuLog_log(LogType::Force, "Texture readback is not supported for textures with modified resolution. Texture: {:08x} {}x{}", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height); return; } // check if texture isn't already queued for transfer @@ -124,7 +122,7 @@ void LatteTextureReadback_UpdateFinishedTransfers(bool forceFinish) if (cemuLog_isLoggingEnabled(LogType::TextureReadback)) { double elapsedSecondsTransfer = HighResolutionTimer::getTimeDiff(readbackInfo->transferStartTime, HighResolutionTimer().now().getTick()); - forceLog_printf("[Texture-Readback] Force-finish: %08x Res %4d/%4d TM %d FMT %04x Transfer time so far: %.4lfms", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0); + cemuLog_log(LogType::TextureReadback, "[Texture-Readback] Force-finish: {:08x} Res {:}/{:} TM {:} FMT {:04x} Transfer time so far: {:.4}ms", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0); } #endif readbackInfo->forceFinish = true; @@ -146,7 +144,7 @@ void LatteTextureReadback_UpdateFinishedTransfers(bool forceFinish) HRTick currentTick = HighResolutionTimer().now().getTick(); double elapsedSecondsTransfer = HighResolutionTimer::getTimeDiff(readbackInfo->transferStartTime, currentTick); double elapsedSecondsWaiting = HighResolutionTimer::getTimeDiff(readbackInfo->waitStartTime, currentTick); - forceLog_printf("[Texture-Readback] %08x Res %4d/%4d TM %d FMT %04x ReadbackLatency: %6.3lfms WaitTime: %6.3lfms ForcedWait %s", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0, elapsedSecondsWaiting * 1000.0, readbackInfo->forceFinish ? "yes" : "no"); + cemuLog_log(LogType::TextureReadback, "[Texture-Readback] {:08x} Res {}/{} TM {} FMT {:04x} ReadbackLatency: {:6.3}ms WaitTime: {:6.3}ms ForcedWait {}", readbackInfo->hostTextureCopy.physAddress, readbackInfo->hostTextureCopy.width, readbackInfo->hostTextureCopy.height, readbackInfo->hostTextureCopy.tileMode, (uint32)readbackInfo->hostTextureCopy.format, elapsedSecondsTransfer * 1000.0, elapsedSecondsWaiting * 1000.0, readbackInfo->forceFinish ? "yes" : "no"); } #endif uint8* pixelData = readbackInfo->GetData(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp index d7d139be..ad32b541 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.cpp @@ -1,13 +1,81 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" #define VKFUNC_DEFINE #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" +#include // for std::iota #if BOOST_OS_LINUX || BOOST_OS_MACOS #include #endif +#define VULKAN_API_CPU_BENCHMARK 0 // if 1, Cemu will log the CPU time spent per Vulkan API function + bool g_vulkan_available = false; +#if VULKAN_API_CPU_BENCHMARK != 0 +uint64 s_vulkanBenchmarkLastResultsTime = 0; + +struct VulkanBenchmarkFuncInfo +{ + std::string funcName; + uint64 cycles; + uint32 numCalls; +}; + +std::vector s_vulkanBenchmarkFuncs; + +template +auto VkWrapperFuncGenTest(TRet (*func)(Args...), const char* name) +{ + static VulkanBenchmarkFuncInfo _FuncInfo; + static auto _FuncPtrCopy = func; + TRet (*newFunc)(Args...); + if constexpr(std::is_void_v) + { + newFunc = +[](Args... args) { uint64 t = __rdtsc(); _mm_mfence(); _FuncPtrCopy(args...); _mm_mfence(); _FuncInfo.cycles += (__rdtsc() - t); _FuncInfo.numCalls++; }; + } + else + newFunc = +[](Args... args) -> TRet { uint64 t = __rdtsc(); _mm_mfence(); TRet r = _FuncPtrCopy(args...); _mm_mfence(); _FuncInfo.cycles += (__rdtsc() - t); _FuncInfo.numCalls++; return r; }; + if(func && func != newFunc) + _FuncPtrCopy = func; + if(_FuncInfo.funcName.empty()) + { + _FuncInfo = {.funcName = name, .cycles = 0, .numCalls = 0}; + s_vulkanBenchmarkFuncs.emplace_back(&_FuncInfo); + } + return newFunc; +}; +#endif + +// called when a TV SwapBuffers is called +void VulkanBenchmarkPrintResults() +{ +#if VULKAN_API_CPU_BENCHMARK != 0 + // note: This could be done by hooking vk present functions + uint64 currentCycle = __rdtsc(); + uint64 elapsedCycles = currentCycle - s_vulkanBenchmarkLastResultsTime; + s_vulkanBenchmarkLastResultsTime = currentCycle; + double elapsedCyclesDbl = (double)elapsedCycles; + cemuLog_log(LogType::Force, "--- Vulkan API CPU benchmark ---"); + cemuLog_log(LogType::Force, "Elapsed cycles this frame: {:} | Current cycle {:} | NumFunc {:}", elapsedCycles, currentCycle, s_vulkanBenchmarkFuncs.size()); + + std::vector sortedIndices(s_vulkanBenchmarkFuncs.size()); + std::iota(sortedIndices.begin(), sortedIndices.end(), 0); + std::sort(sortedIndices.begin(), sortedIndices.end(), + [](int32_t a, int32_t b) { + return s_vulkanBenchmarkFuncs[a]->cycles > s_vulkanBenchmarkFuncs[b]->cycles; + }); + for (sint32 idx : sortedIndices) + { + auto& func = s_vulkanBenchmarkFuncs[idx]; + if(func->cycles == 0) + return; + cemuLog_log(LogType::Force, "{}: {} cycles ({:.4}%) {} calls", func->funcName.c_str(), func->cycles, ((double)func->cycles / elapsedCyclesDbl) * 100.0, func->numCalls); + func->cycles = 0; + func->numCalls = 0; + } +#endif +} + #if BOOST_OS_WINDOWS bool InitializeGlobalVulkan() @@ -57,7 +125,12 @@ bool InitializeDeviceVulkan(VkDevice device) #define VKFUNC_DEVICE_INIT #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" - + +#if VULKAN_API_CPU_BENCHMARK != 0 + #define VKFUNC_DEFINE_CUSTOM(__func) __func = VkWrapperFuncGenTest(__func, #__func) + #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" +#endif + return true; } @@ -121,7 +194,12 @@ bool InitializeDeviceVulkan(VkDevice device) #define VKFUNC_DEVICE_INIT #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" - + +#if VULKAN_API_CPU_BENCHMARK != 0 + #define VKFUNC_DEFINE_CUSTOM(__func) __func = VkWrapperFuncGenTest(__func, #__func) + #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" +#endif + return true; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h index de4f1bb8..0489bb4e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h @@ -14,7 +14,11 @@ extern bool g_vulkan_available; #endif -#ifdef VKFUNC_DEFINE +#ifdef VKFUNC_DEFINE_CUSTOM + #define VKFUNC(__FUNC__) VKFUNC_DEFINE_CUSTOM(__FUNC__) + #define VKFUNC_INSTANCE(__FUNC__) VKFUNC_DEFINE_CUSTOM(__FUNC__) + #define VKFUNC_DEVICE(__FUNC__) VKFUNC_DEFINE_CUSTOM(__FUNC__) +#elif defined(VKFUNC_DEFINE) #define VKFUNC(__FUNC__) NOEXPORT PFN_##__FUNC__ __FUNC__ = nullptr #define VKFUNC_INSTANCE(__FUNC__) NOEXPORT PFN_##__FUNC__ __FUNC__ = nullptr #define VKFUNC_DEVICE(__FUNC__) NOEXPORT PFN_##__FUNC__ __FUNC__ = nullptr @@ -238,4 +242,5 @@ VKFUNC_DEVICE(vkDestroyDescriptorSetLayout); #undef VKFUNC #undef VKFUNC_INSTANCE -#undef VKFUNC_DEVICE \ No newline at end of file +#undef VKFUNC_DEVICE +#undef VKFUNC_DEFINE_CUSTOM diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 2b8376d5..d084a399 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2768,6 +2768,8 @@ void VulkanRenderer::NotifyLatteCommandProcessorIdle() SubmitCommandBuffer(); } +void VulkanBenchmarkPrintResults(); + void VulkanRenderer::SwapBuffers(bool swapTV, bool swapDRC) { SubmitCommandBuffer(); @@ -2777,6 +2779,9 @@ void VulkanRenderer::SwapBuffers(bool swapTV, bool swapDRC) if (swapDRC && IsSwapchainInfoValid(false)) SwapBuffer(false); + + if(swapTV) + VulkanBenchmarkPrintResults(); } void VulkanRenderer::ClearColorbuffer(bool padView) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 5bffcc68..8b0e3b63 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -1574,7 +1574,7 @@ void VulkanRenderer::draw_updateVertexBuffersDirectAccess() uint32 bufferSize = LatteGPUState.contextRegister[bufferBaseRegisterIndex + 1] + 1; uint32 bufferStride = (LatteGPUState.contextRegister[bufferBaseRegisterIndex + 2] >> 11) & 0xFFFF; - if (bufferAddress == MPTR_NULL) + if (bufferAddress == MPTR_NULL) [[unlikely]] { bufferAddress = 0x10000000; } @@ -1597,7 +1597,7 @@ void VulkanRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader MPTR physicalAddr = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 0]; uint32 uniformSize = LatteGPUState.contextRegister[uniformBufferRegOffset + i * 7 + 1] + 1; - if (physicalAddr == MPTR_NULL) + if (physicalAddr == MPTR_NULL) [[unlikely]] { cemu_assert_unimplemented(); continue; From 5ad57bb0c9f6d0966d8ff04696aa16ba384c3ed0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Sep 2023 11:05:40 +0200 Subject: [PATCH 027/314] Add support for games in NUS format (.app) Requires title.tmd and title.tik in same directory --- src/Cafe/OS/RPL/rpl.cpp | 7 ------- src/Cafe/TitleList/TitleInfo.cpp | 23 ++++++++++++++++++----- src/Cafe/TitleList/TitleInfo.h | 1 + src/Cafe/TitleList/TitleList.cpp | 21 ++++++++++++++------- src/Common/precompiled.h | 8 ++++++++ src/gui/MainWindow.cpp | 4 +++- src/gui/components/wxTitleManagerList.cpp | 13 +++++++++---- src/gui/components/wxTitleManagerList.h | 1 + 8 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/Cafe/OS/RPL/rpl.cpp b/src/Cafe/OS/RPL/rpl.cpp index 48c7acc4..0e6d153f 100644 --- a/src/Cafe/OS/RPL/rpl.cpp +++ b/src/Cafe/OS/RPL/rpl.cpp @@ -78,13 +78,6 @@ struct RPLRegionMappingTable void RPLLoader_UnloadModule(RPLModule* rpl); void RPLLoader_RemoveDependency(const char* name); -char _ansiToLower(char c) -{ - if (c >= 'A' && c <= 'Z') - c -= ('A' - 'a'); - return c; -} - uint8* RPLLoader_AllocateTrampolineCodeSpace(RPLModule* rplLoaderContext, sint32 size) { if (rplLoaderContext) diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index 8bbb940d..867e0a7f 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -99,6 +99,7 @@ TitleInfo::TitleInfo(const TitleInfo::CachedInfo& cachedInfo) if (cachedInfo.titleDataFormat != TitleDataFormat::HOST_FS && cachedInfo.titleDataFormat != TitleDataFormat::WIIU_ARCHIVE && cachedInfo.titleDataFormat != TitleDataFormat::WUD && + cachedInfo.titleDataFormat != TitleDataFormat::NUS && cachedInfo.titleDataFormat != TitleDataFormat::INVALID_STRUCTURE) return; if (cachedInfo.path.empty()) @@ -197,13 +198,19 @@ bool TitleInfo::DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataF } } else if (boost::iends_with(filenameStr, ".wud") || - boost::iends_with(filenameStr, ".wux") || - boost::iends_with(filenameStr, ".iso")) + boost::iends_with(filenameStr, ".wux") || + boost::iends_with(filenameStr, ".iso")) { formatOut = TitleDataFormat::WUD; pathOut = path; return true; } + else if (boost::iequals(filenameStr, "title.tmd")) + { + formatOut = TitleDataFormat::NUS; + pathOut = path; + return true; + } else if (boost::iends_with(filenameStr, ".wua")) { formatOut = TitleDataFormat::WIIU_ARCHIVE; @@ -378,12 +385,15 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder, return false; } } - else if (m_titleFormat == TitleDataFormat::WUD) + else if (m_titleFormat == TitleDataFormat::WUD || m_titleFormat == TitleDataFormat::NUS) { if (m_mountpoints.empty()) { cemu_assert_debug(!m_wudVolume); - m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath); + if(m_titleFormat == TitleDataFormat::WUD) + m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath); // open wud/wux + else + m_wudVolume = FSTVolume::OpenFromContentFolder(m_fullPath.parent_path()); // open from .app files directory, the path points to /title.tmd } if (!m_wudVolume) return false; @@ -433,7 +443,7 @@ void TitleInfo::Unmount(std::string_view virtualPath) { if (m_wudVolume) { - cemu_assert_debug(m_titleFormat == TitleDataFormat::WUD); + cemu_assert_debug(m_titleFormat == TitleDataFormat::WUD || m_titleFormat == TitleDataFormat::NUS); delete m_wudVolume; m_wudVolume = nullptr; } @@ -664,6 +674,9 @@ std::string TitleInfo::GetPrintPath() const case TitleDataFormat::WUD: tmp.append(" [WUD]"); break; + case TitleDataFormat::NUS: + tmp.append(" [NUS]"); + break; case TitleDataFormat::WIIU_ARCHIVE: tmp.append(" [WUA]"); break; diff --git a/src/Cafe/TitleList/TitleInfo.h b/src/Cafe/TitleList/TitleInfo.h index da430adc..536e9ccb 100644 --- a/src/Cafe/TitleList/TitleInfo.h +++ b/src/Cafe/TitleList/TitleInfo.h @@ -60,6 +60,7 @@ public: HOST_FS = 1, // host filesystem directory (fullPath points to root with content/code/meta subfolders) WUD = 2, // WUD or WUX WIIU_ARCHIVE = 3, // Wii U compressed single-file archive (.wua) + NUS = 4, // NUS format. Directory with .app files, title.tik and title.tmd // error INVALID_STRUCTURE = 0, }; diff --git a/src/Cafe/TitleList/TitleList.cpp b/src/Cafe/TitleList/TitleList.cpp index 2e50cbf9..03fd0855 100644 --- a/src/Cafe/TitleList/TitleList.cpp +++ b/src/Cafe/TitleList/TitleList.cpp @@ -324,17 +324,25 @@ bool CafeTitleList::RefreshWorkerThread() return true; } -bool _IsKnownFileExtension(std::string fileExtension) +bool _IsKnownFileNameOrExtension(const fs::path& path) { + std::string fileExtension = _pathToUtf8(path.extension()); for (auto& it : fileExtension) - if (it >= 'A' && it <= 'Z') - it -= ('A' - 'a'); + it = _ansiToLower(it); + if(fileExtension == ".tmd") + { + // must be "title.tmd" + std::string fileName = _pathToUtf8(path.filename()); + for (auto& it : fileName) + it = _ansiToLower(it); + return fileName == "title.tmd"; + } return fileExtension == ".wud" || fileExtension == ".wux" || fileExtension == ".iso" || fileExtension == ".wua"; - // note: To detect extracted titles with RPX we use the content/code/meta folder structure + // note: To detect extracted titles with RPX we rely on the presence of the content,code,meta directory structure } void CafeTitleList::ScanGamePath(const fs::path& path) @@ -353,7 +361,6 @@ void CafeTitleList::ScanGamePath(const fs::path& path) else if (it.is_directory(ec)) { dirsInDirectory.emplace_back(it.path()); - std::string dirName = _pathToUtf8(it.path().filename()); if (boost::iequals(dirName, "content")) hasContentFolder = true; @@ -366,10 +373,10 @@ void CafeTitleList::ScanGamePath(const fs::path& path) // always check individual files for (auto& it : filesInDirectory) { - // since checking files is slow, we only do it for known file extensions + // since checking individual files is slow, we limit it to known file names or extensions if (!it.has_extension()) continue; - if (!_IsKnownFileExtension(_pathToUtf8(it.extension()))) + if (!_IsKnownFileNameOrExtension(it)) continue; AddTitleFromPath(it); } diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 580aeb23..60495f53 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -468,6 +468,14 @@ inline fs::path _utf8ToPath(std::string_view input) return fs::path(v); } +// locale-independent variant of tolower() which also matches Wii U behavior +inline char _ansiToLower(char c) +{ + if (c >= 'A' && c <= 'Z') + c -= ('A' - 'a'); + return c; +} + class RunAtCemuBoot // -> replaces this with direct function calls. Linkers other than MSVC may optimize way object files entirely if they are not referenced from outside. So a source file self-registering using this would be causing issues { public: diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d0ec6e9f..e8e90f02 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -639,13 +639,15 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) if (menuId == MAINFRAME_MENU_ID_FILE_LOAD) { const auto wildcard = formatWxString( - "{}|*.wud;*.wux;*.wua;*.iso;*.rpx;*.elf" + "{}|*.wud;*.wux;*.wua;*.iso;*.rpx;*.elf;title.tmd" "|{}|*.wud;*.wux;*.iso" + "|{}|title.tmd" "|{}|*.wua" "|{}|*.rpx;*.elf" "|{}|*", _("All Wii U files (*.wud, *.wux, *.wua, *.iso, *.rpx, *.elf)"), _("Wii U image (*.wud, *.wux, *.iso, *.wad)"), + _("Wii U NUS content"), _("Wii U archive (*.wua)"), _("Wii U executable (*.rpx, *.elf)"), _("All files (*.*)") diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index aad46c52..c65459aa 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -941,6 +941,8 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu return _("Folder"); case wxTitleManagerList::EntryFormat::WUD: return _("WUD"); + case wxTitleManagerList::EntryFormat::NUS: + return _("NUS"); case wxTitleManagerList::EntryFormat::WUA: return _("WUA"); } @@ -1010,16 +1012,19 @@ void wxTitleManagerList::HandleTitleListCallback(CafeTitleListCallbackEvent* evt wxTitleManagerList::EntryFormat entryFormat; switch (titleInfo.GetFormat()) { - case TitleInfo::TitleDataFormat::HOST_FS: - default: - entryFormat = EntryFormat::Folder; - break; case TitleInfo::TitleDataFormat::WUD: entryFormat = EntryFormat::WUD; break; + case TitleInfo::TitleDataFormat::NUS: + entryFormat = EntryFormat::NUS; + break; case TitleInfo::TitleDataFormat::WIIU_ARCHIVE: entryFormat = EntryFormat::WUA; break; + case TitleInfo::TitleDataFormat::HOST_FS: + default: + entryFormat = EntryFormat::Folder; + break; } if (evt->eventType == CafeTitleListCallbackEvent::TYPE::TITLE_DISCOVERED) diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index 07556068..cab531c4 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -42,6 +42,7 @@ public: { Folder, WUD, + NUS, WUA, }; From f6c3c96d9448b3903d2656074cf3817c4893cdde Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:38:51 +0200 Subject: [PATCH 028/314] More detailed error messages when encrypted titles fail to launch --- src/Cafe/Filesystem/FST/FST.cpp | 35 ++++++++++++++++++++++++-------- src/Cafe/Filesystem/FST/FST.h | 16 ++++++++++++--- src/Cafe/TitleList/TitleInfo.cpp | 21 +++++++++++++++++-- src/Cafe/TitleList/TitleInfo.h | 14 ++++++++++++- src/gui/MainWindow.cpp | 10 +++++++++ 5 files changed, 81 insertions(+), 15 deletions(-) diff --git a/src/Cafe/Filesystem/FST/FST.cpp b/src/Cafe/Filesystem/FST/FST.cpp index a4bbfeed..10ae659d 100644 --- a/src/Cafe/Filesystem/FST/FST.cpp +++ b/src/Cafe/Filesystem/FST/FST.cpp @@ -12,6 +12,8 @@ #include "boost/range/adaptor/reversed.hpp" +#define SET_FST_ERROR(__code) if (errorCodeOut) *errorCodeOut = ErrorCode::__code + class FSTDataSource { public: @@ -215,23 +217,22 @@ bool FSTVolume::FindDiscKey(const fs::path& path, NCrypto::AesKey& discTitleKey) // open WUD image using key cache // if no matching key is found then keyFound will return false -FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, bool* keyFound) +FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, ErrorCode* errorCodeOut) { + SET_FST_ERROR(UNKNOWN_ERROR); KeyCache_Prepare(); NCrypto::AesKey discTitleKey; if (!FindDiscKey(path, discTitleKey)) { - if(keyFound) - *keyFound = false; + SET_FST_ERROR(DISC_KEY_MISSING); return nullptr; } - if(keyFound) - *keyFound = true; - return OpenFromDiscImage(path, discTitleKey); + return OpenFromDiscImage(path, discTitleKey, errorCodeOut); } // open WUD image -FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& discTitleKey) +FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& discTitleKey, ErrorCode* errorCodeOut) + { // WUD images support multiple partitions, each with their own key and FST // the process for loading game data FSTVolume from a WUD image is as follows: @@ -240,6 +241,7 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d // 3) find main GM partition // 4) use SI information to get titleKey for GM partition // 5) Load FST for GM + SET_FST_ERROR(UNKNOWN_ERROR); std::unique_ptr dataSource(FSTDataSourceWUD::Open(path)); if (!dataSource) return nullptr; @@ -365,11 +367,15 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d // load GM partition dataSource->SetBaseOffset((uint64)partitionArray[gmPartitionIndex].partitionAddress * DISC_SECTOR_SIZE); - return OpenFST(std::move(dataSource), (uint64)partitionHeaderGM.fstSector * DISC_SECTOR_SIZE, partitionHeaderGM.fstSize, &gmTitleKey, static_cast(partitionHeaderGM.fstHashType)); + FSTVolume* r = OpenFST(std::move(dataSource), (uint64)partitionHeaderGM.fstSector * DISC_SECTOR_SIZE, partitionHeaderGM.fstSize, &gmTitleKey, static_cast(partitionHeaderGM.fstHashType)); + if (r) + SET_FST_ERROR(OK); + return r; } -FSTVolume* FSTVolume::OpenFromContentFolder(fs::path folderPath) +FSTVolume* FSTVolume::OpenFromContentFolder(fs::path folderPath, ErrorCode* errorCodeOut) { + SET_FST_ERROR(UNKNOWN_ERROR); // load TMD FileStream* tmdFile = FileStream::openFile2(folderPath / "title.tmd"); if (!tmdFile) @@ -379,17 +385,26 @@ FSTVolume* FSTVolume::OpenFromContentFolder(fs::path folderPath) delete tmdFile; NCrypto::TMDParser tmdParser; if (!tmdParser.parse(tmdData.data(), tmdData.size())) + { + SET_FST_ERROR(BAD_TITLE_TMD); return nullptr; + } // load ticket FileStream* ticketFile = FileStream::openFile2(folderPath / "title.tik"); if (!ticketFile) + { + SET_FST_ERROR(TITLE_TIK_MISSING); return nullptr; + } std::vector ticketData; ticketFile->extract(ticketData); delete ticketFile; NCrypto::ETicketParser ticketParser; if (!ticketParser.parse(ticketData.data(), ticketData.size())) + { + SET_FST_ERROR(BAD_TITLE_TIK); return nullptr; + } NCrypto::AesKey titleKey; ticketParser.GetTitleKey(titleKey); // open data source @@ -412,6 +427,8 @@ FSTVolume* FSTVolume::OpenFromContentFolder(fs::path folderPath) // load FST // fstSize = size of first cluster? FSTVolume* fstVolume = FSTVolume::OpenFST(std::move(dataSource), 0, fstSize, &titleKey, fstHashMode); + if (fstVolume) + SET_FST_ERROR(OK); return fstVolume; } diff --git a/src/Cafe/Filesystem/FST/FST.h b/src/Cafe/Filesystem/FST/FST.h index 3f59152f..98bf1ae6 100644 --- a/src/Cafe/Filesystem/FST/FST.h +++ b/src/Cafe/Filesystem/FST/FST.h @@ -20,11 +20,21 @@ private: class FSTVolume { public: + enum class ErrorCode + { + OK = 0, + UNKNOWN_ERROR = 1, + DISC_KEY_MISSING = 2, + TITLE_TIK_MISSING = 3, + BAD_TITLE_TMD = 4, + BAD_TITLE_TIK = 5, + }; + static bool FindDiscKey(const fs::path& path, NCrypto::AesKey& discTitleKey); - static FSTVolume* OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& discTitleKey); - static FSTVolume* OpenFromDiscImage(const fs::path& path, bool* keyFound = nullptr); - static FSTVolume* OpenFromContentFolder(fs::path folderPath); + static FSTVolume* OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& discTitleKey, ErrorCode* errorCodeOut = nullptr); + static FSTVolume* OpenFromDiscImage(const fs::path& path, ErrorCode* errorCodeOut = nullptr); + static FSTVolume* OpenFromContentFolder(fs::path folderPath, ErrorCode* errorCodeOut = nullptr); ~FSTVolume(); diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index 867e0a7f..ff457575 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -77,6 +77,7 @@ TitleInfo::TitleInfo(const fs::path& path, std::string_view subPath) if (!path.has_filename()) { m_isValid = false; + SetInvalidReason(InvalidReason::BAD_PATH_OR_INACCESSIBLE); return; } m_isValid = true; @@ -269,6 +270,7 @@ bool TitleInfo::DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataF return true; } } + SetInvalidReason(InvalidReason::UNKNOWN_FORMAT); return false; } @@ -321,6 +323,12 @@ uint64 TitleInfo::GetUID() return m_uid; } +void TitleInfo::SetInvalidReason(InvalidReason reason) +{ + if(m_invalidReason == InvalidReason::NONE) + m_invalidReason = reason; // only update reason when it hasn't been set before +} + std::mutex sZArchivePoolMtx; std::map> sZArchivePool; @@ -382,21 +390,29 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder, if (!r) { cemuLog_log(LogType::Force, "Failed to mount {} to {}", virtualPath, subfolder); + SetInvalidReason(InvalidReason::BAD_PATH_OR_INACCESSIBLE); return false; } } else if (m_titleFormat == TitleDataFormat::WUD || m_titleFormat == TitleDataFormat::NUS) { + FSTVolume::ErrorCode fstError; if (m_mountpoints.empty()) { cemu_assert_debug(!m_wudVolume); if(m_titleFormat == TitleDataFormat::WUD) - m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath); // open wud/wux + m_wudVolume = FSTVolume::OpenFromDiscImage(m_fullPath, &fstError); // open wud/wux else - m_wudVolume = FSTVolume::OpenFromContentFolder(m_fullPath.parent_path()); // open from .app files directory, the path points to /title.tmd + m_wudVolume = FSTVolume::OpenFromContentFolder(m_fullPath.parent_path(), &fstError); // open from .app files directory, the path points to /title.tmd } if (!m_wudVolume) + { + if (fstError == FSTVolume::ErrorCode::DISC_KEY_MISSING) + SetInvalidReason(InvalidReason::NO_DISC_KEY); + else if (fstError == FSTVolume::ErrorCode::TITLE_TIK_MISSING) + SetInvalidReason(InvalidReason::NO_TITLE_TIK); return false; + } bool r = FSCDeviceWUD_Mount(virtualPath, subfolder, m_wudVolume, mountPriority); cemu_assert_debug(r); if (!r) @@ -518,6 +534,7 @@ bool TitleInfo::ParseXmlInfo() m_parsedAppXml = nullptr; m_parsedCosXml = nullptr; m_isValid = false; + SetInvalidReason(InvalidReason::MISSING_XML_FILES); return false; } m_isValid = true; diff --git a/src/Cafe/TitleList/TitleInfo.h b/src/Cafe/TitleList/TitleInfo.h index 536e9ccb..eca6624d 100644 --- a/src/Cafe/TitleList/TitleInfo.h +++ b/src/Cafe/TitleList/TitleInfo.h @@ -65,6 +65,16 @@ public: INVALID_STRUCTURE = 0, }; + enum class InvalidReason : uint8 + { + NONE = 0, + BAD_PATH_OR_INACCESSIBLE = 1, + UNKNOWN_FORMAT = 2, + NO_DISC_KEY = 3, + NO_TITLE_TIK = 4, + MISSING_XML_FILES = 4, + }; + struct CachedInfo { TitleDataFormat titleDataFormat; @@ -101,6 +111,7 @@ public: CachedInfo MakeCacheEntry(); bool IsValid() const; + InvalidReason GetInvalidReason() const { return m_invalidReason; } uint64 GetUID(); // returns a unique identifier derived from the absolute canonical title location which can be used to identify this title by its location. May not persist across sessions, especially when Cemu is used portable fs::path GetPath() const; @@ -182,7 +193,7 @@ private: bool DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataFormat& formatOut); void CalcUID(); - + void SetInvalidReason(InvalidReason reason); bool ParseAppXml(std::vector& appXmlData); bool m_isValid{ false }; @@ -190,6 +201,7 @@ private: fs::path m_fullPath; std::string m_subPath; // used for formats where fullPath isn't unique on its own (like WUA) uint64 m_uid{}; + InvalidReason m_invalidReason{ InvalidReason::NONE }; // if m_isValid == false, this contains a more detailed error code // mounting info std::vector> m_mountpoints; class FSTVolume* m_wudVolume{}; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e8e90f02..69159df2 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -559,6 +559,16 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY { wxString t = _("Unable to launch game\nPath:\n"); t.append(fileName); + if(launchTitle.GetInvalidReason() == TitleInfo::InvalidReason::NO_DISC_KEY) + { + t.append(_("\n\n")); + t.append(_("Could not decrypt title. Make sure that keys.txt contains the correct disc key for this title.")); + } + if(launchTitle.GetInvalidReason() == TitleInfo::InvalidReason::NO_TITLE_TIK) + { + t.append(_("")); + t.append(_("\n\nCould not decrypt title because title.tik is missing.")); + } wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } From abce406ee8640d0fa28a6ee95dde3712e8d613be Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 28 Sep 2023 02:51:40 +0200 Subject: [PATCH 029/314] Refactor more wstring instances to utf8-encoded string --- src/Cafe/GraphicPack/GraphicPack2.cpp | 22 ++++------ src/Cafe/GraphicPack/GraphicPack2.h | 9 ++-- src/Cafe/GraphicPack/GraphicPack2Patches.cpp | 19 +++------ .../GraphicPack/GraphicPack2PatchesParser.cpp | 2 +- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 6 +-- .../Renderer/Vulkan/RendererShaderVk.cpp | 2 +- .../Vulkan/VulkanPipelineStableCache.cpp | 4 +- src/Cafe/IOSU/legacy/iosu_act.cpp | 2 +- src/Cafe/IOSU/legacy/iosu_crypto.cpp | 6 +-- src/Cafe/IOSU/legacy/iosu_crypto.h | 2 +- src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp | 9 ++-- src/Cafe/OS/libs/nn_nfp/nn_nfp.h | 2 +- src/Cemu/Logging/CemuLogging.cpp | 8 ---- src/Cemu/Logging/CemuLogging.h | 1 - .../Tools/DownloadManager/DownloadManager.cpp | 2 +- src/Common/unix/FileStream_unix.cpp | 1 - src/config/ActiveSettings.cpp | 2 +- src/config/CemuConfig.cpp | 26 +++++------- src/config/CemuConfig.h | 10 ++--- src/gui/CemuApp.cpp | 6 +-- src/gui/GeneralSettings2.cpp | 4 +- src/gui/GettingStartedDialog.cpp | 4 +- src/gui/GraphicPacksWindow2.cpp | 2 +- src/gui/MainWindow.cpp | 41 +++++++++---------- src/gui/MainWindow.h | 2 +- src/gui/components/wxTitleManagerList.cpp | 2 +- 26 files changed, 82 insertions(+), 114 deletions(-) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 4594aed0..72e301c4 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -54,7 +54,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath) if (versionNum > GP_LEGACY_VERSION) { - GraphicPack2::LoadGraphicPack(rulesPath.generic_wstring(), iniParser); + GraphicPack2::LoadGraphicPack(_pathToUtf8(rulesPath), iniParser); return; } } @@ -79,7 +79,7 @@ void GraphicPack2::LoadAll() } } -bool GraphicPack2::LoadGraphicPack(const std::wstring& filename, IniParser& rules) +bool GraphicPack2::LoadGraphicPack(const std::string& filename, IniParser& rules) { try { @@ -216,12 +216,6 @@ void GraphicPack2::WaitUntilReady() std::this_thread::sleep_for(std::chrono::milliseconds(5)); } -GraphicPack2::GraphicPack2(std::wstring filename) - : m_filename(std::move(filename)) -{ - // unused for now -} - std::unordered_map GraphicPack2::ParsePresetVars(IniParser& rules) const { ExpressionParser parser; @@ -255,7 +249,7 @@ std::unordered_map GraphicPack2::ParsePres return vars; } -GraphicPack2::GraphicPack2(std::wstring filename, IniParser& rules) +GraphicPack2::GraphicPack2(std::string filename, IniParser& rules) : m_filename(std::move(filename)) { // we're already in [Definition] @@ -265,7 +259,7 @@ GraphicPack2::GraphicPack2(std::wstring filename, IniParser& rules) m_version = StringHelpers::ToInt(*option_version, -1); if (m_version < 0) { - cemuLog_log(LogType::Force, L"{}: Invalid version", m_filename); + cemuLog_log(LogType::Force, "{}: Invalid version", m_filename); throw std::exception(); } @@ -839,7 +833,7 @@ void GraphicPack2::LoadReplacedFiles() return; m_patchedFilesLoaded = true; - fs::path gfxPackPath(m_filename.c_str()); + fs::path gfxPackPath = _utf8ToPath(m_filename); gfxPackPath = gfxPackPath.remove_filename(); // /content/ @@ -892,14 +886,14 @@ bool GraphicPack2::Activate() return false; } - FileStream* fs_rules = FileStream::openFile2({ m_filename }); + FileStream* fs_rules = FileStream::openFile2(_utf8ToPath(m_filename)); if (!fs_rules) return false; std::vector rulesData; fs_rules->extract(rulesData); delete fs_rules; - IniParser rules({ (char*)rulesData.data(), rulesData.size()}, boost::nowide::narrow(m_filename)); + IniParser rules({ (char*)rulesData.data(), rulesData.size()}, m_filename); // load rules try @@ -953,7 +947,7 @@ bool GraphicPack2::Activate() else if (anisotropyValue == 16) rule.overwrite_settings.anistropic_value = 4; else - cemuLog_log(LogType::Force, fmt::format(L"Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, m_filename)); + cemuLog_log(LogType::Force, "Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, m_filename); } m_texture_rules.emplace_back(rule); } diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index a087f757..6396ecc7 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -97,13 +97,12 @@ public: }; using PresetPtr = std::shared_ptr; - GraphicPack2(std::wstring filename); - GraphicPack2(std::wstring filename, IniParser& rules); + GraphicPack2(std::string filename, IniParser& rules); bool IsEnabled() const { return m_enabled; } bool IsActivated() const { return m_activated; } sint32 GetVersion() const { return m_version; } - const std::wstring& GetFilename() const { return m_filename; } + const std::string& GetFilename() const { return m_filename; } const fs::path GetFilename2() const { return fs::path(m_filename); } bool RequiresRestart(bool changeEnableState, bool changePreset); bool Reload(); @@ -165,7 +164,7 @@ public: static const std::vector>& GetGraphicPacks() { return s_graphic_packs; } static const std::vector>& GetActiveGraphicPacks() { return s_active_graphic_packs; } static void LoadGraphicPack(fs::path graphicPackPath); - static bool LoadGraphicPack(const std::wstring& filename, class IniParser& rules); + static bool LoadGraphicPack(const std::string& filename, class IniParser& rules); static bool ActivateGraphicPack(const std::shared_ptr& graphic_pack); static bool DeactivateGraphicPack(const std::shared_ptr& graphic_pack); static void ClearGraphicPacks(); @@ -209,7 +208,7 @@ private: parser.TryAddConstant(var.first, (TType)var.second.second); } - std::wstring m_filename; + std::string m_filename; sint32 m_version; std::string m_name; diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp index 7fa1e7fe..5c79630c 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp @@ -83,7 +83,7 @@ bool GraphicPack2::LoadCemuPatches() }; bool foundPatches = false; - fs::path path(m_filename); + fs::path path(_utf8ToPath(m_filename)); path.remove_filename(); for (auto& p : fs::directory_iterator(path)) { @@ -91,10 +91,10 @@ bool GraphicPack2::LoadCemuPatches() if (fs::is_regular_file(p.status()) && path.has_filename()) { // check if filename matches - std::wstring filename = path.filename().generic_wstring(); - if (boost::istarts_with(filename, L"patch_") && boost::iends_with(filename, L".asm")) + std::string filename = _pathToUtf8(path.filename()); + if (boost::istarts_with(filename, "patch_") && boost::iends_with(filename, ".asm")) { - FileStream* patchFile = FileStream::openFile(path.generic_wstring().c_str()); + FileStream* patchFile = FileStream::openFile2(path); if (patchFile) { // read file @@ -126,27 +126,20 @@ void GraphicPack2::LoadPatchFiles() // order of loading patches: // 1) Load Cemu-style patches (patch_.asm), stop here if at least one patch file exists // 2) Load Cemuhook patches.txt - - // update: As of 1.20.2b Cemu always takes over patching since Cemuhook patching broke due to other internal changes (memory allocation changed and some reordering on when graphic packs get loaded) if (LoadCemuPatches()) return; // exit if at least one Cemu style patch file was found // fall back to Cemuhook patches.txt to guarantee backward compatibility - fs::path path(m_filename); + fs::path path(_utf8ToPath(m_filename)); path.remove_filename(); path.append("patches.txt"); - - FileStream* patchFile = FileStream::openFile(path.generic_wstring().c_str()); - + FileStream* patchFile = FileStream::openFile2(path); if (patchFile == nullptr) return; - // read file std::vector fileData; patchFile->extract(fileData); delete patchFile; - cemu_assert_debug(list_patchGroups.empty()); - // parse MemStreamReader patchesStream(fileData.data(), (sint32)fileData.size()); ParseCemuhookPatchesTxtInternal(patchesStream); diff --git a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp index ce04bf93..d011a10b 100644 --- a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp @@ -25,7 +25,7 @@ sint32 GraphicPack2::GetLengthWithoutComment(const char* str, size_t length) void GraphicPack2::LogPatchesSyntaxError(sint32 lineNumber, std::string_view errorMsg) { - cemuLog_log(LogType::Force, fmt::format(L"Syntax error while parsing patch for graphic pack '{}':", this->GetFilename())); + cemuLog_log(LogType::Force, "Syntax error while parsing patch for graphic pack '{}':", this->GetFilename()); if(lineNumber >= 0) cemuLog_log(LogType::Force, fmt::format("Line {0}: {1}", lineNumber, errorMsg)); else diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 0883c436..6c15f26e 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -511,9 +511,9 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) { if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled) { - std::wstring logName = !bp->comment.empty() ? L"Breakpoint '"+bp->comment+L"'" : fmt::format(L"Breakpoint at 0x{:08X} (no comment)", bp->address); - std::wstring logContext = fmt::format(L"Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? L" Stack Trace:" : L""); - cemuLog_log(LogType::Force, L"[Debugger] {} was executed! {}", logName, logContext); + std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address); + std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : ""); + cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext); if (cemuLog_advancedPPCLoggingEnabled()) DebugLogStackTrace(coreinitThread_getCurrentThreadDepr(hCPU), hCPU->gpr[1]); break; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 4061be33..e4c87d62 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -440,7 +440,7 @@ void RendererShaderVk::ShaderCacheLoading_begin(uint64 cacheTitleId) } uint32 spirvCacheMagic = GeneratePrecompiledCacheId(); const std::string cacheFilename = fmt::format("{:016x}_spirv.bin", cacheTitleId); - const std::wstring cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename).generic_wstring(); + const fs::path cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename); s_spirvCache = FileCache::Open(cachePath, true, spirvCacheMagic); if (s_spirvCache == nullptr) cemuLog_log(LogType::Force, "Unable to open SPIR-V cache {}", cacheFilename); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp index 74247b9a..0ee9f023 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp @@ -59,10 +59,10 @@ uint32 VulkanPipelineStableCache::BeginLoading(uint64 cacheTitleId) // open cache file or create it cemu_assert_debug(s_cache == nullptr); - s_cache = FileCache::Open(pathCacheFile.generic_wstring(), true, LatteShaderCache_getPipelineCacheExtraVersion(cacheTitleId)); + s_cache = FileCache::Open(pathCacheFile, true, LatteShaderCache_getPipelineCacheExtraVersion(cacheTitleId)); if (!s_cache) { - cemuLog_log(LogType::Force, "Failed to open or create Vulkan pipeline cache file: {}", pathCacheFile.generic_string()); + cemuLog_log(LogType::Force, "Failed to open or create Vulkan pipeline cache file: {}", _pathToUtf8(pathCacheFile)); return 0; } else diff --git a/src/Cafe/IOSU/legacy/iosu_act.cpp b/src/Cafe/IOSU/legacy/iosu_act.cpp index 919b7b0f..e7418e8f 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.cpp +++ b/src/Cafe/IOSU/legacy/iosu_act.cpp @@ -113,7 +113,7 @@ void iosuAct_loadAccounts() // } //} - cemuLog_log(LogType::Force, L"IOSU_ACT: using account {} in first slot", first_acc.GetMiiName()); + cemuLog_log(LogType::Force, "IOSU_ACT: using account {} in first slot", boost::nowide::narrow(first_acc.GetMiiName())); _actAccountDataInitialized = true; } diff --git a/src/Cafe/IOSU/legacy/iosu_crypto.cpp b/src/Cafe/IOSU/legacy/iosu_crypto.cpp index 9d7ab875..80eb2f01 100644 --- a/src/Cafe/IOSU/legacy/iosu_crypto.cpp +++ b/src/Cafe/IOSU/legacy/iosu_crypto.cpp @@ -615,10 +615,10 @@ void iosuCrypto_init() iosuCrypto_loadSSLCertificates(); } -bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::wstring& additionalErrorInfo_filePath) +bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::string& additionalErrorInfo_filePath) { const auto path = ActiveSettings::GetMlcPath(mlcSubpath); - additionalErrorInfo_filePath = path.generic_wstring(); + additionalErrorInfo_filePath = _pathToUtf8(path); sint32 fileDataSize = 0; auto fileData = FileStream::LoadIntoMemory(path); if (!fileData) @@ -626,7 +626,7 @@ bool iosuCrypto_checkRequirementMLCFile(std::string_view mlcSubpath, std::wstrin return true; } -sint32 iosuCrypt_checkRequirementsForOnlineMode(std::wstring& additionalErrorInfo) +sint32 iosuCrypt_checkRequirementsForOnlineMode(std::string& additionalErrorInfo) { std::error_code ec; // check if otp.bin is present diff --git a/src/Cafe/IOSU/legacy/iosu_crypto.h b/src/Cafe/IOSU/legacy/iosu_crypto.h index bf3d7e2f..9f1429c7 100644 --- a/src/Cafe/IOSU/legacy/iosu_crypto.h +++ b/src/Cafe/IOSU/legacy/iosu_crypto.h @@ -74,7 +74,7 @@ enum IOS_CRYPTO_ONLINE_REQ_MISSING_FILE }; -sint32 iosuCrypt_checkRequirementsForOnlineMode(std::wstring& additionalErrorInfo); +sint32 iosuCrypt_checkRequirementsForOnlineMode(std::string& additionalErrorInfo); void iosuCrypto_readOtpData(void* output, sint32 wordIndex, sint32 size); std::vector iosuCrypt_getCertificateKeys(); diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp index 27a858c1..ad2ea203 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp @@ -180,7 +180,7 @@ struct bool hasOpenApplicationArea; // set to true if application area was opened or created // currently active Amiibo bool hasActiveAmiibo; - std::wstring amiiboPath; + fs::path amiiboPath; bool hasInvalidHMAC; uint32 amiiboTouchTime; AmiiboRawNFCData amiiboNFCData; // raw data @@ -188,7 +188,6 @@ struct AmiiboProcessedData amiiboProcessedData; }nfp_data = { 0 }; -bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError); bool nnNfp_writeCurrentAmiibo(); #include "AmiiboCrypto.h" @@ -770,7 +769,7 @@ void nnNfp_unloadAmiibo() nnNfpUnlock(); } -bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError) +bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError) { AmiiboRawNFCData rawData = { 0 }; auto nfcData = FileStream::LoadIntoMemory(filePath); @@ -847,11 +846,11 @@ bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError) memcpy(&nfp_data.amiiboNFCData, &rawData, sizeof(AmiiboRawNFCData)); // decrypt amiibo amiiboDecrypt(); - nfp_data.amiiboPath = std::wstring(filePath); + nfp_data.amiiboPath = filePath; nfp_data.hasActiveAmiibo = true; if (nfp_data.activateEvent) { - coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset(nfp_data.activateEvent); + MEMPTR osEvent(nfp_data.activateEvent); coreinit::OSSignalEvent(osEvent); } nfp_data.amiiboTouchTime = GetTickCount(); diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.h b/src/Cafe/OS/libs/nn_nfp/nn_nfp.h index 793b3bc3..e8a1c55f 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.h +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.h @@ -8,7 +8,7 @@ namespace nn::nfp void nnNfp_load(); void nnNfp_update(); -bool nnNfp_touchNfcTagFromFile(const wchar_t* filePath, uint32* nfcError); +bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError); #define NFP_STATE_NONE (0) #define NFP_STATE_INIT (1) diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index ac228530..f8ce7265 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -157,14 +157,6 @@ bool cemuLog_log(LogType type, std::u8string_view text) return cemuLog_log(type, s); } -bool cemuLog_log(LogType type, std::wstring_view text) -{ - if (!cemuLog_isLoggingEnabled(type)) - return false; - - return cemuLog_log(type, boost::nowide::narrow(text.data(), text.size())); -} - void cemuLog_waitForFlush() { cemuLog_createLogFile(false); diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index e6599c5a..8983c847 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -68,7 +68,6 @@ inline bool cemuLog_isLoggingEnabled(LogType type) bool cemuLog_log(LogType type, std::string_view text); bool cemuLog_log(LogType type, std::u8string_view text); -bool cemuLog_log(LogType type, std::wstring_view text); void cemuLog_waitForFlush(); // wait until all log lines are written template diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index ec39b928..09093792 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -1541,7 +1541,7 @@ void DownloadManager::runManager() auto cacheFilePath = ActiveSettings::GetMlcPath("usr/save/system/nim/nup/"); fs::create_directories(cacheFilePath); cacheFilePath /= "cemu_cache.dat"; - s_nupFileCache = FileCache::Open(cacheFilePath.generic_wstring(), true); + s_nupFileCache = FileCache::Open(cacheFilePath, true); // launch worker thread std::thread t(&DownloadManager::threadFunc, this); t.detach(); diff --git a/src/Common/unix/FileStream_unix.cpp b/src/Common/unix/FileStream_unix.cpp index c65a3219..2dba17b7 100644 --- a/src/Common/unix/FileStream_unix.cpp +++ b/src/Common/unix/FileStream_unix.cpp @@ -33,7 +33,6 @@ FileStream* FileStream::openFile(const wchar_t* path, bool allowWrite) FileStream* FileStream::openFile2(const fs::path& path, bool allowWrite) { - //return openFile(path.generic_wstring().c_str(), allowWrite); FileStream* fs = new FileStream(path, true, allowWrite); if (fs->m_isValid) return fs; diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index af7f521e..2049bd65 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -40,7 +40,7 @@ ActiveSettings::LoadOnce( g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring()); g_config.Load(); LaunchSettings::ChangeNetworkServiceURL(GetConfig().account.active_service); - std::wstring additionalErrorInfo; + std::string additionalErrorInfo; s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK; return failed_write_access; } diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 220a2295..1801759a 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -110,7 +110,7 @@ void CemuConfig::Load(XMLConfigParser& parser) try { - recent_launch_files.emplace_back(boost::nowide::widen(path)); + recent_launch_files.emplace_back(path); } catch (const std::exception&) { @@ -125,10 +125,9 @@ void CemuConfig::Load(XMLConfigParser& parser) const std::string path = element.value(""); if (path.empty()) continue; - try { - recent_nfc_files.emplace_back(boost::nowide::widen(path)); + recent_nfc_files.emplace_back(path); } catch (const std::exception&) { @@ -143,10 +142,9 @@ void CemuConfig::Load(XMLConfigParser& parser) const std::string path = element.value(""); if (path.empty()) continue; - try { - game_paths.emplace_back(boost::nowide::widen(path)); + game_paths.emplace_back(path); } catch (const std::exception&) { @@ -402,20 +400,20 @@ void CemuConfig::Save(XMLConfigParser& parser) auto launch_files_parser = config.set("RecentLaunchFiles"); for (const auto& entry : recent_launch_files) { - launch_files_parser.set("Entry", boost::nowide::narrow(entry).c_str()); + launch_files_parser.set("Entry", entry.c_str()); } auto nfc_files_parser = config.set("RecentNFCFiles"); for (const auto& entry : recent_nfc_files) { - nfc_files_parser.set("Entry", boost::nowide::narrow(entry).c_str()); + nfc_files_parser.set("Entry", entry.c_str()); } // game paths auto game_path_parser = config.set("GamePaths"); for (const auto& entry : game_paths) { - game_path_parser.set("Entry", boost::nowide::narrow(entry).c_str()); + game_path_parser.set("Entry", entry.c_str()); } // game list cache @@ -593,22 +591,18 @@ void CemuConfig::SetGameListCustomName(uint64 titleId, std::string customName) gameEntry->custom_name = std::move(customName); } -void CemuConfig::AddRecentlyLaunchedFile(std::wstring_view file) +void CemuConfig::AddRecentlyLaunchedFile(std::string_view file) { - // insert into front - recent_launch_files.insert(recent_launch_files.begin(), std::wstring{ file }); + recent_launch_files.insert(recent_launch_files.begin(), std::string(file)); RemoveDuplicatesKeepOrder(recent_launch_files); - // keep maximum of entries while(recent_launch_files.size() > kMaxRecentEntries) recent_launch_files.pop_back(); } -void CemuConfig::AddRecentNfcFile(std::wstring_view file) +void CemuConfig::AddRecentNfcFile(std::string_view file) { - // insert into front - recent_nfc_files.insert(recent_nfc_files.begin(), std::wstring{ file }); + recent_nfc_files.insert(recent_nfc_files.begin(), std::string(file)); RemoveDuplicatesKeepOrder(recent_nfc_files); - // keep maximum of entries while (recent_nfc_files.size() > kMaxRecentEntries) recent_nfc_files.pop_back(); } diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index ea6c3f2c..eb552fce 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -379,7 +379,7 @@ struct CemuConfig ConfigValue disable_screensaver{DISABLE_SCREENSAVER_DEFAULT}; #undef DISABLE_SCREENSAVER_DEFAULT - std::vector game_paths; + std::vector game_paths; std::mutex game_cache_entries_mutex; std::vector game_cache_entries; @@ -399,8 +399,8 @@ struct CemuConfig // max 15 entries static constexpr size_t kMaxRecentEntries = 15; - std::vector recent_launch_files; - std::vector recent_nfc_files; + std::vector recent_launch_files; + std::vector recent_nfc_files; Vector2i window_position{-1,-1}; Vector2i window_size{ -1,-1 }; @@ -499,8 +499,8 @@ struct CemuConfig void Load(XMLConfigParser& parser); void Save(XMLConfigParser& parser); - void AddRecentlyLaunchedFile(std::wstring_view file); - void AddRecentNfcFile(std::wstring_view file); + void AddRecentlyLaunchedFile(std::string_view file); + void AddRecentNfcFile(std::string_view file); bool IsGameListFavorite(uint64 titleId); void SetGameListFavorite(uint64 titleId, bool isFavorite); diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 74ef6848..04823ca4 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -198,9 +198,9 @@ void CemuApp::OnAssertFailure(const wxChar* file, int line, const wxChar* func, { cemuLog_createLogFile(false); cemuLog_log(LogType::Force, "Encountered wxWidgets assert!"); - cemuLog_log(LogType::Force, fmt::format(L"File: {0} Line: {1}", std::wstring_view(file), line)); - cemuLog_log(LogType::Force, fmt::format(L"Func: {0} Cond: {1}", func, std::wstring_view(cond))); - cemuLog_log(LogType::Force, fmt::format(L"Message: {}", std::wstring_view(msg))); + cemuLog_log(LogType::Force, "File: {0} Line: {1}", wxString(file).utf8_string(), line); + cemuLog_log(LogType::Force, "Func: {0} Cond: {1}", wxString(func).utf8_string(), wxString(cond).utf8_string()); + cemuLog_log(LogType::Force, "Message: {}", wxString(msg).utf8_string()); #if BOOST_OS_WINDOWS DumpThreadStackTrace(); diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index e069c10a..4dd3f9a3 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -923,7 +923,7 @@ void GeneralSettings2::StoreConfig() config.game_paths.clear(); for (auto& path : m_game_paths->GetStrings()) - config.game_paths.emplace_back(path); + config.game_paths.emplace_back(path.utf8_string()); auto selection = m_language->GetSelection(); if (selection == 0) @@ -1530,7 +1530,7 @@ void GeneralSettings2::ApplyConfig() for (auto& path : config.game_paths) { - m_game_paths->Append(path); + m_game_paths->Append(to_wxString(path)); } const auto app = (CemuApp*)wxTheApp; diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index 69f429b0..91cc3a11 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -229,7 +229,7 @@ void GettingStartedDialog::OnClose(wxCloseEvent& event) const auto it = std::find(config.game_paths.cbegin(), config.game_paths.cend(), gamePath); if (it == config.game_paths.cend()) { - config.game_paths.emplace_back(gamePath.generic_wstring()); + config.game_paths.emplace_back(_pathToUtf8(gamePath)); m_game_path_changed = true; } } @@ -248,7 +248,7 @@ void GettingStartedDialog::OnClose(wxCloseEvent& event) CafeTitleList::ClearScanPaths(); for (auto& it : GetConfig().game_paths) - CafeTitleList::AddScanPath(it); + CafeTitleList::AddScanPath(_utf8ToPath(it)); CafeTitleList::Refresh(); } diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 2b618e86..13fec49a 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -329,7 +329,7 @@ void GraphicPacksWindow2::SaveStateToConfig() for (const auto& gp : GraphicPack2::GetGraphicPacks()) { - auto filename = MakeRelativePath(ActiveSettings::GetUserDataPath(), gp->GetFilename()).lexically_normal(); + auto filename = MakeRelativePath(ActiveSettings::GetUserDataPath(), _utf8ToPath(gp->GetFilename())).lexically_normal(); if (gp->IsEnabled()) { data.graphic_pack_entries.try_emplace(filename); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 69159df2..d9c5f4fb 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -248,7 +248,7 @@ public: bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames) override { if(!m_window->IsGameLaunched() && filenames.GetCount() == 1) - return m_window->FileLoad(filenames[0].wc_str(), wxLaunchGameEvent::INITIATED_BY::DRAG_AND_DROP); + return m_window->FileLoad(_utf8ToPath(filenames[0].utf8_string()), wxLaunchGameEvent::INITIATED_BY::DRAG_AND_DROP); return false; } @@ -265,11 +265,11 @@ public: { if (!m_window->IsGameLaunched() || filenames.GetCount() != 1) return false; - uint32 nfcError; - if (nnNfp_touchNfcTagFromFile(filenames[0].wc_str(), &nfcError)) + std::string path = filenames[0].utf8_string(); + if (nnNfp_touchNfcTagFromFile(_utf8ToPath(path), &nfcError)) { - GetConfig().AddRecentNfcFile((wchar_t*)filenames[0].wc_str()); + GetConfig().AddRecentNfcFile(path); m_window->UpdateNFCMenu(); return true; } @@ -493,9 +493,8 @@ bool MainWindow::InstallUpdate(const fs::path& metaFilePath) return false; } -bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY initiatedBy) +bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATED_BY initiatedBy) { - const fs::path launchPath = fs::path(fileName); TitleInfo launchTitle{ launchPath }; if (launchTitle.IsValid()) { @@ -518,14 +517,14 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY else if (r == CafeSystem::STATUS_CODE::UNABLE_TO_MOUNT) { wxString t = _("Unable to mount title.\nMake sure the configured game paths are still valid and refresh the game list.\n\nFile which failed to load:\n"); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } else if (r != CafeSystem::STATUS_CODE::SUCCESS) { wxString t = _("Failed to launch game."); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } @@ -542,7 +541,7 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY { cemu_assert_debug(false); // todo wxString t = _("Failed to launch executable. Path: "); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } @@ -550,7 +549,7 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY else if (initiatedBy == wxLaunchGameEvent::INITIATED_BY::GAME_LIST) { wxString t = _("Unable to launch title.\nMake sure the configured game paths are still valid and refresh the game list.\n\nPath which failed to load:\n"); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } @@ -558,7 +557,7 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY initiatedBy == wxLaunchGameEvent::INITIATED_BY::COMMAND_LINE) { wxString t = _("Unable to launch game\nPath:\n"); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); if(launchTitle.GetInvalidReason() == TitleInfo::InvalidReason::NO_DISC_KEY) { t.append(_("\n\n")); @@ -575,16 +574,16 @@ bool MainWindow::FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY else { wxString t = _("Unable to launch game\nPath:\n"); - t.append(fileName); + t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } } if(launchTitle.IsValid()) - GetConfig().AddRecentlyLaunchedFile(launchTitle.GetPath().generic_wstring()); + GetConfig().AddRecentlyLaunchedFile(_pathToUtf8(launchTitle.GetPath())); else - GetConfig().AddRecentlyLaunchedFile(fileName); + GetConfig().AddRecentlyLaunchedFile(_pathToUtf8(launchPath)); wxWindowUpdateLocker lock(this); @@ -640,7 +639,7 @@ void MainWindow::OnLaunchFromFile(wxLaunchGameEvent& event) { if (event.GetPath().empty()) return; - FileLoad(event.GetPath().generic_wstring(), event.GetInitiatedBy()); + FileLoad(event.GetPath(), event.GetInitiatedBy()); } void MainWindow::OnFileMenu(wxCommandEvent& event) @@ -669,7 +668,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) return; const wxString wxStrFilePath = openFileDialog.GetPath(); - FileLoad(wxStrFilePath.wc_str(), wxLaunchGameEvent::INITIATED_BY::MENU); + FileLoad(_utf8ToPath(wxStrFilePath.utf8_string()), wxLaunchGameEvent::INITIATED_BY::MENU); } else if (menuId >= MAINFRAME_MENU_ID_FILE_RECENT_0 && menuId <= MAINFRAME_MENU_ID_FILE_RECENT_LAST) { @@ -749,7 +748,7 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) return; wxString wxStrFilePath = openFileDialog.GetPath(); uint32 nfcError; - if (nnNfp_touchNfcTagFromFile(wxStrFilePath.wc_str(), &nfcError) == false) + if (nnNfp_touchNfcTagFromFile(_utf8ToPath(wxStrFilePath.utf8_string()), &nfcError) == false) { if (nfcError == NFC_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); @@ -758,7 +757,7 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) } else { - GetConfig().AddRecentNfcFile((wchar_t*)wxStrFilePath.wc_str()); + GetConfig().AddRecentNfcFile(wxStrFilePath.utf8_string()); UpdateNFCMenu(); } } @@ -772,7 +771,7 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) if (!path.empty()) { uint32 nfcError = 0; - if (nnNfp_touchNfcTagFromFile(path.c_str(), &nfcError) == false) + if (nnNfp_touchNfcTagFromFile(_utf8ToPath(path), &nfcError) == false) { if (nfcError == NFC_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); @@ -1766,7 +1765,7 @@ void MainWindow::UpdateNFCMenu() if (recentFileIndex == 0) m_nfcMenuSeparator0 = m_nfcMenu->AppendSeparator(); - m_nfcMenu->Append(MAINFRAME_MENU_ID_NFC_RECENT_0 + i, fmt::format(L"{}. {}", recentFileIndex, entry )); + m_nfcMenu->Append(MAINFRAME_MENU_ID_NFC_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, entry))); recentFileIndex++; if (recentFileIndex >= 12) @@ -2106,7 +2105,7 @@ void MainWindow::RecreateMenu() if (recentFileIndex == 0) m_fileMenuSeparator0 = m_fileMenu->AppendSeparator(); - m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, fmt::format(L"{}. {}", recentFileIndex, entry)); + m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, entry))); recentFileIndex++; if (recentFileIndex >= 8) diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index c1762867..1c4b5235 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -65,7 +65,7 @@ public: void UpdateSettingsAfterGameLaunch(); void RestoreSettingsAfterGameExited(); - bool FileLoad(std::wstring fileName, wxLaunchGameEvent::INITIATED_BY initiatedBy); + bool FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATED_BY initiatedBy); [[nodiscard]] bool IsGameLaunched() const { return m_game_launched; } diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index c65459aa..93f86fdd 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -352,7 +352,7 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 righ boost::replace_all(shortName, ":", ""); } // for the default output directory we use the first game path configured by the user - std::wstring defaultDir = L""; + std::string defaultDir = ""; if (!GetConfig().game_paths.empty()) defaultDir = GetConfig().game_paths.front(); // get the short name, which we will use as a suggested default file name From 21c1f84a87b64e57ffe7d98b0dab5a9dab2c18f9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 28 Sep 2023 05:21:48 +0200 Subject: [PATCH 030/314] Fix WUA conversion not detecting updates --- src/gui/components/wxTitleManagerList.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index 93f86fdd..ea0cc3d3 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -274,6 +274,9 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 righ break; // prefer the users selection } } + } + for (const auto& data : m_data) + { if (hasUpdateTitleId && data->entry.title_id == updateTitleId) { if (!titleInfo_update.IsValid()) From 6217276681b7fb7905235958e01ab8788c53616c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 28 Sep 2023 10:02:12 +0200 Subject: [PATCH 031/314] Enable DPI awareness on Windows --- dist/windows/Cemu.manifest | 16 ++++++++++++++++ src/CMakeLists.txt | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 dist/windows/Cemu.manifest diff --git a/dist/windows/Cemu.manifest b/dist/windows/Cemu.manifest new file mode 100644 index 00000000..5ff952b1 --- /dev/null +++ b/dist/windows/Cemu.manifest @@ -0,0 +1,16 @@ + + + + + + + + + + + + + True/PM + + + \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a343f5a3..00a43a80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,7 +59,8 @@ add_executable(CemuBin if(WIN32) target_sources(CemuBin PRIVATE resource/cemu.rc -) + ../dist/windows/cemu.manifest + ) endif() set_property(TARGET CemuBin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -77,7 +78,7 @@ if (MACOS_BUNDLE) set(MACOSX_BUNDLE_BUNDLE_NAME "Cemu") set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${CMAKE_PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}) - set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2022 Cemu Project") + set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2023 Cemu Project") set(MACOSX_BUNDLE_CATEGORY "public.app-category.games") From 8a4abb8bbbdaf2e2d2162237f8cb39dbf8143dce Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 29 Sep 2023 05:41:33 +0200 Subject: [PATCH 032/314] Update Windows build instructions --- BUILD.md | 20 ++++++++++---------- CODING_STYLE.md | 6 +++--- src/Cafe/OS/libs/coreinit/coreinit_Time.cpp | 13 +------------ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/BUILD.md b/BUILD.md index 35aaffb7..c63251d7 100644 --- a/BUILD.md +++ b/BUILD.md @@ -3,20 +3,19 @@ ## Windows Prerequisites: -- A recent version of Visual Studio 2022 (recommended but not required) with the following additional components: - - C++ CMake tools for Windows - - Windows 10/11 SDK - git +- A recent version of Visual Studio 2022 with the following additional components: + - C++ CMake tools for Windows + - Windows 10/11 SDK -Instructions: +Instructions for Visual Studio 2022: 1. Run `git clone --recursive https://github.com/cemu-project/Cemu` -2. Launch `Cemu/generate_vs_solution.bat`. - - If you installed VS to a custom location or use VS 2019, you may need to manually change the path inside the .bat file. -3. Wait until it's done, then open `Cemu/build/Cemu.sln` in Visual Studio. -4. Then build the solution and once finished you can run and debug it, or build it and check the /bin folder for the final Cemu_release.exe. +2. Open the newly created Cemu directory in Visual Studio using the "Open a local folder" option +3. In the menu select Project -> Configure CMake. Wait until it is done, this may take a long time +4. You can now build, run and debug Cemu -You can also skip steps 3-5 and open the root folder of the cloned repo directly in Visual Studio (as a folder) and use the built-in CMake support but be warned that cmake support in VS can be a bit finicky. +Any other IDE should also work as long as it has CMake and MSVC support. CLion and Visual Studio Code have been confirmed to work. ## Linux @@ -46,7 +45,8 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required 5. You should now have a Cemu executable file in the /bin folder, which you can run using `./bin/Cemu_release`. #### Using GCC -While we use and test Cemu using clang, using GCC might work better with your distro (they should be fairly similar performance/issues wise and should only be considered if compilation is the issue). +While we build and test Cemu using clang, using GCC might work better with your distro (they should be fairly similar performance/issues wise and should only be considered if compilation is the issue). + You can use GCC by doing the following: - make sure you have g++ installed in your system - installation for Ubuntu and derivatives: `sudo apt install g++` diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 26e11733..54767052 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -15,7 +15,7 @@ Cemu comes with a `.clang-format` file which is supported by most IDEs for forma ## About types -Cemu provides it's own set of basic fixed-width types. They are: +Cemu provides its own set of basic fixed-width types. They are: `uint8`, `sint8`, `uint16`, `sint16`, `uint32`, `sint32`, `uint64`, `sint64`. Always use these types over something like `uint32_t`. Using `size_t` is also acceptable where suitable. Avoid C types like `int` or `long`. The only exception is when interacting with external libraries which expect these types as parameters. ## When and where to put brackets @@ -48,7 +48,7 @@ In UI related code you can use `formatWxString`, but be aware that number format ## Strings and encoding -We use UTF-8 encoded `std::string` where possible. Some conversations need special handling and we have helper functions for those: +We use UTF-8 encoded `std::string` where possible. Some conversions need special handling and we have helper functions for those: ```cpp // std::filesystem::path <-> std::string (in precompiled.h) std::string _pathToUtf8(const fs::path& path); @@ -69,7 +69,7 @@ If you want to write to log.txt use `cemuLog_log()`. The log type parameter shou A pretty large part of Cemu's code base are re-implementations of various Cafe OS modules (e.g. `coreinit.rpl`, `gx2.rpl`...). These generally run in the context of the emulated process, thus special care has to be taken to use types with the correct size and endianness when interacting with memory. -Keep in mind that the emulated Espresso CPU is 32bit big-endian, while the host architectures targeted by Cemu are 64bit litte-endian! +Keep in mind that the emulated Espresso CPU is 32bit big-endian, while the host architectures targeted by Cemu are 64bit little-endian! To keep code simple and remove the need for manual endian-swapping, Cemu has templates and aliases of the basic types with explicit endian-ness. For big-endian types add the suffix `be`. Example: `uint32be` diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp index 465439ba..5a75b406 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp @@ -28,16 +28,6 @@ namespace coreinit osLib_returnFromFunction64(hCPU, osTime); } - uint64 coreinit_getTimeBase_dummy() - { - return __rdtsc(); - } - - void export_OSGetSystemTimeDummy(PPCInterpreter_t* hCPU) - { - osLib_returnFromFunction64(hCPU, coreinit_getTimeBase_dummy()); - } - void export_OSGetSystemTime(PPCInterpreter_t* hCPU) { osLib_returnFromFunction64(hCPU, coreinit_getTimerTick()); @@ -371,14 +361,13 @@ namespace coreinit void InitializeTimeAndCalendar() { osLib_addFunction("coreinit", "OSGetTime", export_OSGetTime); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTimeDummy); + osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); osLib_addFunction("coreinit", "OSGetTick", export_OSGetTick); osLib_addFunction("coreinit", "OSGetSystemTick", export_OSGetSystemTick); cafeExportRegister("coreinit", OSTicksToCalendarTime, LogType::Placeholder); cafeExportRegister("coreinit", OSCalendarTimeToTicks, LogType::Placeholder); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); //timeTest(); } From 8bb7ce098c7e439ff88421e431d30378c3f3739b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:17:28 +0200 Subject: [PATCH 033/314] Bump CI clang version to 15 + workaround for unsafe fiber optimizations (#982) --- .github/workflows/build.yml | 10 ++--- .../workflows/deploy_experimental_release.yml | 4 +- .gitignore | 2 +- BUILD.md | 12 ++--- generate_vs_solution.bat | 2 - src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 3 +- src/Cafe/HW/Espresso/Debugger/GDBStub.cpp | 3 +- .../Interpreter/PPCInterpreterMain.cpp | 19 +++++--- src/Cafe/HW/Espresso/PPCCallback.h | 15 ++++--- src/Cafe/HW/Espresso/PPCScheduler.cpp | 19 ++++---- src/Cafe/HW/Espresso/PPCSchedulerLLE.cpp | 2 +- src/Cafe/HW/Espresso/PPCState.h | 3 +- .../Espresso/Recompiler/PPCRecompilerX64.cpp | 4 +- src/Cafe/IOSU/legacy/iosu_ioctl.cpp | 2 +- src/Cafe/OS/common/OSUtil.h | 2 +- src/Cafe/OS/libs/coreinit/coreinit.cpp | 4 +- src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Init.cpp | 9 ++-- src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp | 8 ++-- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 20 ++++----- .../OS/libs/coreinit/coreinit_ThreadQueue.cpp | 4 +- src/Cafe/OS/libs/gx2/GX2.cpp | 8 ++-- src/Cafe/OS/libs/gx2/GX2_Command.cpp | 23 +++++----- src/Cafe/OS/libs/gx2/GX2_Event.cpp | 2 +- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 4 +- src/Cafe/OS/libs/nn_save/nn_save.cpp | 44 +++++++++---------- src/Cafe/OS/libs/snd_core/ax_aux.cpp | 14 +++--- src/Cafe/OS/libs/snd_core/ax_voice.cpp | 13 +++--- src/Cafe/OS/libs/zlib125/zlib125.cpp | 5 +-- .../ExceptionHandler/ExceptionHandler.cpp | 9 ++-- src/Common/precompiled.h | 11 +++-- 31 files changed, 150 insertions(+), 132 deletions(-) delete mode 100644 generate_vs_solution.bat diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb6ac099..d23faa31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ env: jobs: build-ubuntu: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: "Checkout repo" uses: actions/checkout@v3 @@ -53,7 +53,7 @@ jobs: - name: "Install system dependencies" run: | sudo apt update -qq - sudo apt install -y clang-12 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev nasm ninja-build + sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev nasm ninja-build - name: "Bootstrap vcpkg" run: | @@ -75,7 +75,7 @@ jobs: - name: "cmake" run: | - cmake -S . -B build ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DPORTABLE=OFF -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja + cmake -S . -B build ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DPORTABLE=OFF -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja - name: "Build Cemu" run: | @@ -93,7 +93,7 @@ jobs: path: ./bin/Cemu build-appimage: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 needs: build-ubuntu steps: - name: Checkout Upstream Repo @@ -107,7 +107,7 @@ jobs: - name: "Install system dependencies" run: | sudo apt update -qq - sudo apt install -y clang-12 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build appstream + sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build appstream - name: "Build AppImage" run: | diff --git a/.github/workflows/deploy_experimental_release.yml b/.github/workflows/deploy_experimental_release.yml index 9296c1cc..3bf86db4 100644 --- a/.github/workflows/deploy_experimental_release.yml +++ b/.github/workflows/deploy_experimental_release.yml @@ -10,7 +10,7 @@ jobs: experimentalversion: ${{ github.run_number }} deploy: name: Deploy experimental release - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 needs: call-release-build steps: - uses: actions/checkout@v3 @@ -72,7 +72,7 @@ jobs: ls ./bin/ cp -R ./bin ./${{ env.CEMU_FOLDER_NAME }} mv cemu-bin-linux-x64/Cemu ./${{ env.CEMU_FOLDER_NAME }}/Cemu - zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-ubuntu-20.04-x64.zip ${{ env.CEMU_FOLDER_NAME }} + zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-ubuntu-22.04-x64.zip ${{ env.CEMU_FOLDER_NAME }} rm -r ./${{ env.CEMU_FOLDER_NAME }} - name: Create release from macos-bin diff --git a/.gitignore b/.gitignore index 9e9ff7df..18f14cf3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ .idea/ build/ -cmake-build-*-*/ +cmake-build-*/ out/ .cache/ bin/Cemu_* diff --git a/BUILD.md b/BUILD.md index c63251d7..e4993ca1 100644 --- a/BUILD.md +++ b/BUILD.md @@ -19,17 +19,17 @@ Any other IDE should also work as long as it has CMake and MSVC support. CLion a ## Linux -To compile Cemu, a recent enough compiler and STL with C++20 support is required! clang-12 or higher is what we recommend. +To compile Cemu, a recent enough compiler and STL with C++20 support is required! clang-15 or higher is what we recommend. ### Installing dependencies #### For Ubuntu and derivatives: -`sudo apt install -y cmake curl freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build` +`sudo apt install -y cmake curl clang-15 freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build` -*Additionally, for Ubuntu 22.04 only:* - - `sudo apt install -y clang-12` - - At step 3 while building, use - `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-12 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-12 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` +You may also need to install `libusb-1.0-0-dev` as a workaround for an issue with the vcpkg hidapi package. + +At step 3 while building, use: + `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` #### For Arch and derivatives: `sudo pacman -S --needed base-devel clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` diff --git a/generate_vs_solution.bat b/generate_vs_solution.bat deleted file mode 100644 index 21060027..00000000 --- a/generate_vs_solution.bat +++ /dev/null @@ -1,2 +0,0 @@ -"C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -B build/ -pause \ No newline at end of file diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 6c15f26e..e99ce522 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -210,7 +210,8 @@ void debugger_handleSingleStepException(uint64 dr6) } if (catchBP) { - debugger_createCodeBreakpoint(ppcInterpreterCurrentInstance->instructionPointer + 4, DEBUGGER_BP_T_ONE_SHOT); + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + debugger_createCodeBreakpoint(hCPU->instructionPointer + 4, DEBUGGER_BP_T_ONE_SHOT); } } diff --git a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp index d83ea46b..b7e15407 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp +++ b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp @@ -959,8 +959,9 @@ void GDBServer::HandleAccessException(uint64 dr6) if (!response.empty()) { + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); cemuLog_logDebug(LogType::Force, "Received matching breakpoint exception: {}", response); - auto nextInstructions = findNextInstruction(ppcInterpreterCurrentInstance->instructionPointer, ppcInterpreterCurrentInstance->spr.LR, ppcInterpreterCurrentInstance->spr.CTR); + auto nextInstructions = findNextInstruction(hCPU->instructionPointer, hCPU->spr.LR, hCPU->spr.CTR); for (MPTR nextInstr : nextInstructions) { auto bpIt = m_patchedInstructions.find(nextInstr); diff --git a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp index 2d808fef..a9ab49a5 100644 --- a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp +++ b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp @@ -6,7 +6,6 @@ thread_local PPCInterpreter_t* ppcInterpreterCurrentInstance; // main thread instruction counter and timing -volatile uint64 ppcMainThreadCycleCounter = 0; uint64 ppcMainThreadDECCycleValue = 0; // value that was set to dec register uint64 ppcMainThreadDECCycleStart = 0; // at which cycle the dec register was set, if == 0 -> dec is 0 uint64 ppcCyclesSince2000 = 0; @@ -29,11 +28,16 @@ PPCInterpreter_t* PPCInterpreter_createInstance(unsigned int Entrypoint) return pData; } -PPCInterpreter_t* PPCInterpreter_getCurrentInstance() +TLS_WORKAROUND_NOINLINE PPCInterpreter_t* PPCInterpreter_getCurrentInstance() { return ppcInterpreterCurrentInstance; } +TLS_WORKAROUND_NOINLINE void PPCInterpreter_setCurrentInstance(PPCInterpreter_t* hCPU) +{ + ppcInterpreterCurrentInstance = hCPU; +} + uint64 PPCInterpreter_getMainCoreCycleCounter() { return PPCTimer_getFromRDTSC(); @@ -78,24 +82,25 @@ uint32 PPCInterpreter_getCoreIndex(PPCInterpreter_t* hCPU) uint32 PPCInterpreter_getCurrentCoreIndex() { - return ppcInterpreterCurrentInstance->spr.UPIR; + return PPCInterpreter_getCurrentInstance()->spr.UPIR; }; uint8* PPCInterpreterGetStackPointer() { - return memory_getPointerFromVirtualOffset(ppcInterpreterCurrentInstance->gpr[1]); + return memory_getPointerFromVirtualOffset(PPCInterpreter_getCurrentInstance()->gpr[1]); } uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset) { - uint8* result = memory_getPointerFromVirtualOffset(ppcInterpreterCurrentInstance->gpr[1] - offset); - ppcInterpreterCurrentInstance->gpr[1] -= offset; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + uint8* result = memory_getPointerFromVirtualOffset(hCPU->gpr[1] - offset); + hCPU->gpr[1] -= offset; return result; } void PPCInterpreterModifyStackPointer(sint32 offset) { - ppcInterpreterCurrentInstance->gpr[1] -= offset; + PPCInterpreter_getCurrentInstance()->gpr[1] -= offset; } uint32 RPLLoader_MakePPCCallable(void(*ppcCallableExport)(PPCInterpreter_t* hCPU)); diff --git a/src/Cafe/HW/Espresso/PPCCallback.h b/src/Cafe/HW/Espresso/PPCCallback.h index fd790f0c..19fcd4d1 100644 --- a/src/Cafe/HW/Espresso/PPCCallback.h +++ b/src/Cafe/HW/Espresso/PPCCallback.h @@ -18,19 +18,20 @@ uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg, { cemu_assert_debug(data.gprCount <= 8); cemu_assert_debug(data.floatCount <= 8); + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); if constexpr (std::is_pointer_v) { - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR(); + hCPU->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR(); data.gprCount++; } else if constexpr (std::is_base_of_v>) { - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = currentArg.GetMPTR(); + hCPU->gpr[3 + data.gprCount] = currentArg.GetMPTR(); data.gprCount++; } else if constexpr (std::is_reference_v) { - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = MEMPTR(¤tArg).GetMPTR(); + hCPU->gpr[3 + data.gprCount] = MEMPTR(¤tArg).GetMPTR(); data.gprCount++; } else if constexpr(std::is_enum_v) @@ -40,19 +41,19 @@ uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg, } else if constexpr (std::is_floating_point_v) { - ppcInterpreterCurrentInstance->fpr[1 + data.floatCount].fpr = (double)currentArg; + hCPU->fpr[1 + data.floatCount].fpr = (double)currentArg; data.floatCount++; } else if constexpr (std::is_integral_v && sizeof(T) == sizeof(uint64)) { - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)(currentArg >> 32); // high - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount + 1] = (uint32)currentArg; // low + hCPU->gpr[3 + data.gprCount] = (uint32)(currentArg >> 32); // high + hCPU->gpr[3 + data.gprCount + 1] = (uint32)currentArg; // low data.gprCount += 2; } else { - ppcInterpreterCurrentInstance->gpr[3 + data.gprCount] = (uint32)currentArg; + hCPU->gpr[3 + data.gprCount] = (uint32)currentArg; data.gprCount++; } diff --git a/src/Cafe/HW/Espresso/PPCScheduler.cpp b/src/Cafe/HW/Espresso/PPCScheduler.cpp index 2a3a4aaa..a4c04aaa 100644 --- a/src/Cafe/HW/Espresso/PPCScheduler.cpp +++ b/src/Cafe/HW/Espresso/PPCScheduler.cpp @@ -11,21 +11,24 @@ uint32 ppcThreadQuantum = 45000; // execute 45000 instructions before thread res void PPCInterpreter_relinquishTimeslice() { - if( ppcInterpreterCurrentInstance->remainingCycles >= 0 ) + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + if( hCPU->remainingCycles >= 0 ) { - ppcInterpreterCurrentInstance->skippedCycles = ppcInterpreterCurrentInstance->remainingCycles + 1; - ppcInterpreterCurrentInstance->remainingCycles = -1; + hCPU->skippedCycles = hCPU->remainingCycles + 1; + hCPU->remainingCycles = -1; } } void PPCCore_boostQuantum(sint32 numCycles) { - ppcInterpreterCurrentInstance->remainingCycles += numCycles; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + hCPU->remainingCycles += numCycles; } void PPCCore_deboostQuantum(sint32 numCycles) { - ppcInterpreterCurrentInstance->remainingCycles -= numCycles; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + hCPU->remainingCycles -= numCycles; } namespace coreinit @@ -36,7 +39,7 @@ namespace coreinit void PPCCore_switchToScheduler() { cemu_assert_debug(__OSHasSchedulerLock() == false); // scheduler lock must not be hold past thread time slice - cemu_assert_debug(ppcInterpreterCurrentInstance->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600); + cemu_assert_debug(PPCInterpreter_getCurrentInstance()->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600); __OSLockScheduler(); coreinit::__OSThreadSwitchToNext(); __OSUnlockScheduler(); @@ -45,7 +48,7 @@ void PPCCore_switchToScheduler() void PPCCore_switchToSchedulerWithLock() { cemu_assert_debug(__OSHasSchedulerLock() == true); // scheduler lock must be hold - cemu_assert_debug(ppcInterpreterCurrentInstance->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600); + cemu_assert_debug(PPCInterpreter_getCurrentInstance()->coreInterruptMask != 0 || CafeSystem::GetForegroundTitleId() == 0x000500001019e600); coreinit::__OSThreadSwitchToNext(); } @@ -58,7 +61,7 @@ void _PPCCore_callbackExit(PPCInterpreter_t* hCPU) PPCInterpreter_t* PPCCore_executeCallbackInternal(uint32 functionMPTR) { cemu_assert_debug(functionMPTR != 0); - PPCInterpreter_t* hCPU = ppcInterpreterCurrentInstance; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); // remember LR and instruction pointer uint32 lr = hCPU->spr.LR; uint32 ip = hCPU->instructionPointer; diff --git a/src/Cafe/HW/Espresso/PPCSchedulerLLE.cpp b/src/Cafe/HW/Espresso/PPCSchedulerLLE.cpp index 8ef54256..bb4bf9ff 100644 --- a/src/Cafe/HW/Espresso/PPCSchedulerLLE.cpp +++ b/src/Cafe/HW/Espresso/PPCSchedulerLLE.cpp @@ -220,7 +220,7 @@ void PPCCoreLLE_startSingleCoreScheduler(uint32 entrypoint) for (uint32 coreIndex = 0; coreIndex < 3; coreIndex++) { PPCInterpreter_t* hCPU = cpuContext->cores+coreIndex; - ppcInterpreterCurrentInstance = hCPU; + PPCInterpreter_setCurrentInstance(hCPU); if (coreIndex == 1) { // check SCR core 1 enable bit diff --git a/src/Cafe/HW/Espresso/PPCState.h b/src/Cafe/HW/Espresso/PPCState.h index 2b30326b..85b2dc04 100644 --- a/src/Cafe/HW/Espresso/PPCState.h +++ b/src/Cafe/HW/Espresso/PPCState.h @@ -149,6 +149,7 @@ static uint64 PPCInterpreter_getCallParamU64(PPCInterpreter_t* hCPU, uint32 inde PPCInterpreter_t* PPCInterpreter_createInstance(unsigned int Entrypoint); PPCInterpreter_t* PPCInterpreter_getCurrentInstance(); +void PPCInterpreter_setCurrentInstance(PPCInterpreter_t* hCPU); uint64 PPCInterpreter_getMainCoreCycleCounter(); @@ -192,7 +193,6 @@ uint32 PPCInterpreter_getCurrentCoreIndex(); void PPCInterpreter_setDEC(PPCInterpreter_t* hCPU, uint32 newValue); // timing for main processor -extern volatile uint64 ppcMainThreadCycleCounter; extern uint64 ppcCyclesSince2000; // on init this is set to the cycles that passed since 1.1.2000 extern uint64 ppcCyclesSince2000TimerClock; // on init this is set to the cycles that passed since 1.1.2000 / 20 extern uint64 ppcCyclesSince2000_UTC; @@ -213,7 +213,6 @@ void PPCTimer_start(); // core info and control extern uint32 ppcThreadQuantum; -extern thread_local PPCInterpreter_t *ppcInterpreterCurrentInstance; uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset); uint8* PPCInterpreterGetStackPointer(); void PPCInterpreterModifyStackPointer(sint32 offset); diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp index 14d2febb..a30295b5 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp @@ -100,7 +100,7 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun hCPU->remainingCycles -= 500; // let subtract about 500 cycles for each HLE call hCPU->gpr[3] = 0; PPCInterpreter_nextInstruction(hCPU); - return ppcInterpreterCurrentInstance; + return hCPU; } else { @@ -109,7 +109,7 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun hleCall(hCPU); } hCPU->rspTemp = prevRSPTemp; - return ppcInterpreterCurrentInstance; + return PPCInterpreter_getCurrentInstance(); } void ATTR_MS_ABI PPCRecompiler_getTBL(PPCInterpreter_t* hCPU, uint32 gprIndex) diff --git a/src/Cafe/IOSU/legacy/iosu_ioctl.cpp b/src/Cafe/IOSU/legacy/iosu_ioctl.cpp index 00be31b0..1fc2a27a 100644 --- a/src/Cafe/IOSU/legacy/iosu_ioctl.cpp +++ b/src/Cafe/IOSU/legacy/iosu_ioctl.cpp @@ -23,7 +23,7 @@ sint32 iosuIoctl_pushAndWait(uint32 ioctlHandle, ioQueueEntry_t* ioQueueEntry) } __OSLockScheduler(); ioctlMutex.lock(); - ioQueueEntry->ppcThread = coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance); + ioQueueEntry->ppcThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); _ioctlRingbuffer[ioctlHandle].Push(ioQueueEntry); ioctlMutex.unlock(); diff --git a/src/Cafe/OS/common/OSUtil.h b/src/Cafe/OS/common/OSUtil.h index 9bf8480b..6801f6af 100644 --- a/src/Cafe/OS/common/OSUtil.h +++ b/src/Cafe/OS/common/OSUtil.h @@ -65,7 +65,7 @@ public: } else if constexpr (std::is_floating_point_v) { - v = (T)ppcInterpreterCurrentInstance->fpr[1 + fprIndex].fpr; + v = (T)hCPU->fpr[1 + fprIndex].fpr; fprIndex++; } else diff --git a/src/Cafe/OS/libs/coreinit/coreinit.cpp b/src/Cafe/OS/libs/coreinit/coreinit.cpp index e8e4ce1f..8738e3a4 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit.cpp @@ -204,7 +204,7 @@ namespace coreinit { sint32 OSGetCoreId() { - return PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + return PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); } uint32 OSGetCoreCount() @@ -239,7 +239,7 @@ namespace coreinit uint32 OSGetStackPointer() { - return ppcInterpreterCurrentInstance->gpr[1]; + return PPCInterpreter_getCurrentInstance()->gpr[1]; } void coreinitExport_ENVGetEnvironmentVariable(PPCInterpreter_t* hCPU) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index a2f59d4d..916563c8 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -691,7 +691,7 @@ namespace coreinit while (OSSendMessage(ioMsgQueue, &fsCmdBlockBody->asyncResult.msgUnion.osMsg, 0) == 0) { cemuLog_log(LogType::Force, "FS driver: Failed to add message to result queue. Retrying..."); - if (ppcInterpreterCurrentInstance) + if (PPCInterpreter_getCurrentInstance()) PPCCore_switchToScheduler(); else std::this_thread::sleep_for(std::chrono::milliseconds(10)); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp index 51a3f542..72f6ac11 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Init.cpp @@ -142,10 +142,11 @@ void CafeInit() } } // setup UGQR - ppcInterpreterCurrentInstance->spr.UGQR[0 + 2] = 0x00040004; - ppcInterpreterCurrentInstance->spr.UGQR[0 + 3] = 0x00050005; - ppcInterpreterCurrentInstance->spr.UGQR[0 + 4] = 0x00060006; - ppcInterpreterCurrentInstance->spr.UGQR[0 + 5] = 0x00070007; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + hCPU->spr.UGQR[0 + 2] = 0x00040004; + hCPU->spr.UGQR[0 + 3] = 0x00050005; + hCPU->spr.UGQR[0 + 4] = 0x00060006; + hCPU->spr.UGQR[0 + 5] = 0x00070007; coreinit::InitForegroundBucket(); coreinit::InitSysHeap(); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp index 05660c71..d5cd0018 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp @@ -235,7 +235,7 @@ namespace coreinit sint32 __os_snprintf(char* outputStr, sint32 maxLength, const char* formatStr) { - sint32 r = ppcSprintf(formatStr, outputStr, maxLength, ppcInterpreterCurrentInstance, 3); + sint32 r = ppcSprintf(formatStr, outputStr, maxLength, PPCInterpreter_getCurrentInstance(), 3); return r; } @@ -303,7 +303,7 @@ namespace coreinit void OSReport(const char* format) { char buffer[1024 * 2]; - sint32 len = ppcSprintf(format, buffer, sizeof(buffer), ppcInterpreterCurrentInstance, 1); + sint32 len = ppcSprintf(format, buffer, sizeof(buffer), PPCInterpreter_getCurrentInstance(), 1); WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len); } @@ -316,7 +316,7 @@ namespace coreinit { char buffer[1024 * 2]; int prefixLen = sprintf(buffer, "[COSWarn-%d] ", moduleId); - sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, ppcInterpreterCurrentInstance, 2); + sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, PPCInterpreter_getCurrentInstance(), 2); WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len + prefixLen); } @@ -324,7 +324,7 @@ namespace coreinit { char buffer[1024 * 2]; int prefixLen = sprintf(buffer, "[OSLogPrintf-%d-%d-%d] ", ukn1, ukn2, ukn3); - sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, ppcInterpreterCurrentInstance, 4); + sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, PPCInterpreter_getCurrentInstance(), 4); WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len + prefixLen); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 59bd034e..71e5d493 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -305,7 +305,7 @@ namespace coreinit affinityMask = attr & 0x7; // if no core is selected -> set current one if (affinityMask == 0) - affinityMask |= (1 << PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance)); + affinityMask |= (1 << PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance())); // set attr // todo: Support for other attr bits thread->attr = (affinityMask & 0xFF) | (attr & OSThread_t::ATTR_BIT::ATTR_DETACHED); @@ -325,7 +325,7 @@ namespace coreinit { __OSLockScheduler(); - cemu_assert_debug(ppcInterpreterCurrentInstance == nullptr || OSGetCurrentThread() != thread); // called on self, what should this function do? + cemu_assert_debug(PPCInterpreter_getCurrentInstance() == nullptr || OSGetCurrentThread() != thread); // called on self, what should this function do? if (thread->state != OSThread_t::THREAD_STATE::STATE_NONE && thread->state != OSThread_t::THREAD_STATE::STATE_MORIBUND) { @@ -607,7 +607,7 @@ namespace coreinit // todo - only set this once? thread->wakeUpTime = PPCInterpreter_getMainCoreCycleCounter(); // reschedule if thread has higher priority - if (ppcInterpreterCurrentInstance && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) PPCCore_switchToSchedulerWithLock(); } return previousSuspendCount; @@ -930,17 +930,17 @@ namespace coreinit thread->requestFlags = (OSThread_t::REQUEST_FLAG_BIT)(thread->requestFlags & OSThread_t::REQUEST_FLAG_CANCEL); // remove all flags except cancel flag // update total cycles - uint64 remainingCycles = std::min((uint64)ppcInterpreterCurrentInstance->remainingCycles, (uint64)thread->quantumTicks); + uint64 remainingCycles = std::min((uint64)hCPU->remainingCycles, (uint64)thread->quantumTicks); uint64 executedCycles = thread->quantumTicks - remainingCycles; - if (executedCycles < ppcInterpreterCurrentInstance->skippedCycles) + if (executedCycles < hCPU->skippedCycles) executedCycles = 0; else - executedCycles -= ppcInterpreterCurrentInstance->skippedCycles; + executedCycles -= hCPU->skippedCycles; thread->totalCycles += executedCycles; // store context and set current thread to null __OSThreadStoreContext(hCPU, thread); OSSetCurrentThread(OSGetCoreId(), nullptr); - ppcInterpreterCurrentInstance = nullptr; + PPCInterpreter_setCurrentInstance(nullptr); } void __OSLoadThread(OSThread_t* thread, PPCInterpreter_t* hCPU, uint32 coreIndex) @@ -951,7 +951,7 @@ namespace coreinit hCPU->reservedMemValue = 0; hCPU->spr.UPIR = coreIndex; hCPU->coreInterruptMask = 1; - ppcInterpreterCurrentInstance = hCPU; + PPCInterpreter_setCurrentInstance(hCPU); OSSetCurrentThread(OSGetCoreId(), thread); __OSThreadLoadContext(hCPU, thread); thread->context.upir = coreIndex; @@ -1076,7 +1076,7 @@ namespace coreinit // store context of current thread __OSStoreThread(OSGetCurrentThread(), &hostThread->ppcInstance); - cemu_assert_debug(ppcInterpreterCurrentInstance == nullptr); + cemu_assert_debug(PPCInterpreter_getCurrentInstance() == nullptr); if (!sSchedulerActive.load(std::memory_order::relaxed)) { @@ -1165,7 +1165,7 @@ namespace coreinit // create scheduler idle fiber and switch to it g_idleLoopFiber[t_assignedCoreIndex] = new Fiber(__OSThreadCoreIdle, nullptr, nullptr); - cemu_assert_debug(ppcInterpreterCurrentInstance == nullptr); + cemu_assert_debug(PPCInterpreter_getCurrentInstance() == nullptr); __OSLockScheduler(); Fiber::Switch(*g_idleLoopFiber[t_assignedCoreIndex]); // returned from scheduler loop, exit thread diff --git a/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp b/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp index 38302d5a..68cb22b3 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp @@ -139,7 +139,7 @@ namespace coreinit thread->state = OSThread_t::THREAD_STATE::STATE_READY; thread->currentWaitQueue = nullptr; coreinit::__OSAddReadyThreadToRunQueue(thread); - if (reschedule && thread->suspendCounter == 0 && ppcInterpreterCurrentInstance && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) shouldReschedule = true; } if (shouldReschedule) @@ -159,7 +159,7 @@ namespace coreinit thread->state = OSThread_t::THREAD_STATE::STATE_READY; thread->currentWaitQueue = nullptr; coreinit::__OSAddReadyThreadToRunQueue(thread); - if (reschedule && thread->suspendCounter == 0 && ppcInterpreterCurrentInstance && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) shouldReschedule = true; } if (shouldReschedule) diff --git a/src/Cafe/OS/libs/gx2/GX2.cpp b/src/Cafe/OS/libs/gx2/GX2.cpp index 8c3fbc64..82aef164 100644 --- a/src/Cafe/OS/libs/gx2/GX2.cpp +++ b/src/Cafe/OS/libs/gx2/GX2.cpp @@ -4,8 +4,8 @@ #include "GX2.h" #include "Cafe/HW/Latte/Core/Latte.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h" +#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "Cafe/CafeSystem.h" - #include "Cafe/HW/Latte/Core/LattePM4.h" #include "GX2_Command.h" @@ -68,7 +68,7 @@ void gx2Export_GX2SwapScanBuffers(PPCInterpreter_t* hCPU) // Orochi Warriors seems to call GX2SwapScanBuffers on arbitrary threads/cores. The PM4 commands should go through to the GPU as long as there is no active display list and no other core is submitting commands simultaneously // right now, we work around this by avoiding the infinite loop below (request counter incremented, but PM4 not sent) - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); if (GX2::sGX2MainCoreIndex == coreIndex) LatteGPUState.sharedArea->flipRequestCountBE = _swapEndianU32(_swapEndianU32(LatteGPUState.sharedArea->flipRequestCountBE) + 1); @@ -332,7 +332,7 @@ uint64 Latte_GetTime() void _GX2SubmitToTCL() { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); // do nothing if called from non-main GX2 core if (GX2::sGX2MainCoreIndex != coreIndex) { @@ -373,7 +373,7 @@ uint32 _GX2GetUnflushedBytes(uint32 coreIndex) */ void GX2ReserveCmdSpace(uint32 reservedFreeSpaceInU32) { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); // if we are in a display list then do nothing if( gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL ) return; diff --git a/src/Cafe/OS/libs/gx2/GX2_Command.cpp b/src/Cafe/OS/libs/gx2/GX2_Command.cpp index 6da19741..804e3da0 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Command.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Command.cpp @@ -3,6 +3,7 @@ #include "Cafe/OS/common/OSCommon.h" #include "Cafe/HW/Latte/Core/LattePM4.h" #include "Cafe/OS/libs/coreinit/coreinit.h" +#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "Cafe/HW/Latte/ISA/RegDefines.h" #include "GX2.h" #include "GX2_Command.h" @@ -15,7 +16,7 @@ GX2WriteGatherPipeState gx2WriteGatherPipe = { 0 }; void gx2WriteGather_submitU32AsBE(uint32 v) { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) return; *(uint32*)(*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) = _swapEndianU32(v); @@ -24,7 +25,7 @@ void gx2WriteGather_submitU32AsBE(uint32 v) void gx2WriteGather_submitU32AsLE(uint32 v) { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) return; *(uint32*)(*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]) = v; @@ -33,7 +34,7 @@ void gx2WriteGather_submitU32AsLE(uint32 v) void gx2WriteGather_submitU32AsLEArray(uint32* v, uint32 numValues) { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); if (gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex] == NULL) return; memcpy_dwords((*gx2WriteGatherPipe.writeGatherPtrWrite[coreIndex]), v, numValues); @@ -134,7 +135,7 @@ namespace GX2 bool GX2GetCurrentDisplayList(betype* displayListAddr, uint32be* displayListSize) { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); if (gx2WriteGatherPipe.displayListStart[coreIndex] == MPTR_NULL) return false; @@ -149,13 +150,13 @@ namespace GX2 bool GX2GetDisplayListWriteStatus() { // returns true if we are writing to a display list - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); return gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL; } bool GX2WriteGather_isDisplayListActive() { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); if (gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL) return true; return false; @@ -171,7 +172,7 @@ namespace GX2 void GX2WriteGather_checkAndInsertWrapAroundMark() { - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = coreinit::OSGetCoreId(); if (coreIndex != sGX2MainCoreIndex) // only if main gx2 core return; if (gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL) @@ -187,18 +188,18 @@ namespace GX2 void GX2BeginDisplayList(MEMPTR displayListAddr, uint32 size) { - GX2WriteGather_beginDisplayList(ppcInterpreterCurrentInstance, displayListAddr.GetMPTR(), size); + GX2WriteGather_beginDisplayList(PPCInterpreter_getCurrentInstance(), displayListAddr.GetMPTR(), size); } void GX2BeginDisplayListEx(MEMPTR displayListAddr, uint32 size, bool profiling) { - GX2WriteGather_beginDisplayList(ppcInterpreterCurrentInstance, displayListAddr.GetMPTR(), size); + GX2WriteGather_beginDisplayList(PPCInterpreter_getCurrentInstance(), displayListAddr.GetMPTR(), size); } uint32 GX2EndDisplayList(MEMPTR displayListAddr) { cemu_assert_debug(displayListAddr != nullptr); - uint32 displayListSize = GX2WriteGather_endDisplayList(ppcInterpreterCurrentInstance, displayListAddr.GetMPTR()); + uint32 displayListSize = GX2WriteGather_endDisplayList(PPCInterpreter_getCurrentInstance(), displayListAddr.GetMPTR()); return displayListSize; } @@ -220,7 +221,7 @@ namespace GX2 // its basically a way to manually submit a command buffer to the GPU // as such it also affects the submission and retire timestamps - uint32 coreIndex = PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance); + uint32 coreIndex = PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance()); cemu_assert_debug(coreIndex == sGX2MainCoreIndex); coreIndex = sGX2MainCoreIndex; // always submit to main queue which is owned by GX2 main core (TCLSubmitToRing does not need this workaround) diff --git a/src/Cafe/OS/libs/gx2/GX2_Event.cpp b/src/Cafe/OS/libs/gx2/GX2_Event.cpp index ba498477..9748e20b 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Event.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Event.cpp @@ -263,7 +263,7 @@ namespace GX2 gx2WriteGather_submitU32AsBE(0x00000000); // unused } // flush pipeline - if (_GX2GetUnflushedBytes(PPCInterpreter_getCoreIndex(ppcInterpreterCurrentInstance)) > 0) + if (_GX2GetUnflushedBytes(coreinit::OSGetCoreId()) > 0) _GX2SubmitToTCL(); uint64 ts = GX2GetLastSubmittedTimeStamp(); diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 9afb9f85..ce9501ab 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -225,7 +225,7 @@ void CurlWorkerThread(CURL_t* curl, PPCConcurrentQueue* callerQueue, uint32 SendOrderToWorker(CURL_t* curl, QueueOrder order, uint32 arg1 = 0) { - OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance); + OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); curl->curlThread = currentThread; // cemuLog_logDebug(LogType::Force, "CURRENTTHREAD: 0x{} -> {}",currentThread, order) @@ -707,7 +707,7 @@ void export_curl_easy_init(PPCInterpreter_t* hCPU) memset(result.GetPtr(), 0, sizeof(CURL_t)); *result = {}; result->curl = curl_easy_init(); - result->curlThread = coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance); + result->curlThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); result->info_contentType = nullptr; result->info_redirectUrl = nullptr; diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 109c00d2..1311dd46 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -451,14 +451,14 @@ namespace save asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -685,14 +685,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -754,14 +754,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -867,14 +867,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -940,14 +940,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1076,14 +1076,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1127,14 +1127,14 @@ namespace save asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, hFile, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1187,14 +1187,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1238,14 +1238,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1427,14 +1427,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1496,14 +1496,14 @@ namespace save asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(ppcInterpreterCurrentInstance), 1000); + coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); PPCCore_switchToScheduler(); return param->returnStatus; } diff --git a/src/Cafe/OS/libs/snd_core/ax_aux.cpp b/src/Cafe/OS/libs/snd_core/ax_aux.cpp index 837adf06..a9176562 100644 --- a/src/Cafe/OS/libs/snd_core/ax_aux.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_aux.cpp @@ -218,9 +218,10 @@ namespace snd_core AXAUXCBCHANNELINFO* cbStruct = __AXAuxCB_auxCBStruct.GetPtr(); cbStruct->numChannels = tvChannelCount; cbStruct->numSamples = sampleCount; - ppcInterpreterCurrentInstance->gpr[3] = __AXAuxCB_dataPtrs.GetMPTR(); - ppcInterpreterCurrentInstance->gpr[4] = __AXAuxTVCallbackUserParam[auxBusIndex]; - ppcInterpreterCurrentInstance->gpr[5] = __AXAuxCB_auxCBStruct.GetMPTR(); + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + hCPU->gpr[3] = __AXAuxCB_dataPtrs.GetMPTR(); + hCPU->gpr[4] = __AXAuxTVCallbackUserParam[auxBusIndex]; + hCPU->gpr[5] = __AXAuxCB_auxCBStruct.GetMPTR(); PPCCore_executeCallbackInternal(auxCBFuncMPTR); } else @@ -255,9 +256,10 @@ namespace snd_core AXAUXCBCHANNELINFO* cbStruct = __AXAuxCB_auxCBStruct.GetPtr(); cbStruct->numChannels = drcChannelCount; cbStruct->numSamples = sampleCount; - ppcInterpreterCurrentInstance->gpr[3] = __AXAuxCB_dataPtrs.GetMPTR(); - ppcInterpreterCurrentInstance->gpr[4] = __AXAuxDRCCallbackUserParam[auxBusIndex + drcIndex * 3]; - ppcInterpreterCurrentInstance->gpr[5] = __AXAuxCB_auxCBStruct.GetMPTR(); + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + hCPU->gpr[3] = __AXAuxCB_dataPtrs.GetMPTR(); + hCPU->gpr[4] = __AXAuxDRCCallbackUserParam[auxBusIndex + drcIndex * 3]; + hCPU->gpr[5] = __AXAuxCB_auxCBStruct.GetMPTR(); PPCCore_executeCallbackInternal(auxCBFuncMPTR); } else diff --git a/src/Cafe/OS/libs/snd_core/ax_voice.cpp b/src/Cafe/OS/libs/snd_core/ax_voice.cpp index 8a49b0f4..877eecab 100644 --- a/src/Cafe/OS/libs/snd_core/ax_voice.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_voice.cpp @@ -3,6 +3,7 @@ #include "Cafe/HW/Espresso/PPCCallback.h" #include "Cafe/OS/libs/snd_core/ax.h" #include "Cafe/OS/libs/snd_core/ax_internal.h" +#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "util/helpers/fspinlock.h" namespace snd_core @@ -120,7 +121,7 @@ namespace snd_core { return -2; } - MPTR currentThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + MPTR currentThreadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); for (sint32 i = __AXUserProtectionArraySize - 1; i >= 0; i--) { if (__AXUserProtectionArray[i].threadMPTR == currentThreadMPTR) @@ -151,7 +152,7 @@ namespace snd_core PPCCore_deboostQuantum(10000); if (AXIst_IsFrameBeingProcessed()) return -2; - MPTR currentThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + MPTR currentThreadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); for (sint32 i = __AXUserProtectionArraySize - 1; i >= 0; i--) { if (__AXUserProtectionArray[i].threadMPTR == currentThreadMPTR) @@ -206,7 +207,7 @@ namespace snd_core if (AXIst_IsFrameBeingProcessed()) isProtected = __AXVoiceProtection[index].threadMPTR != MPTR_NULL; else - isProtected = __AXVoiceProtection[index].threadMPTR != coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + isProtected = __AXVoiceProtection[index].threadMPTR != memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); return isProtected; } @@ -219,7 +220,7 @@ namespace snd_core return; if (__AXVoiceProtection[index].threadMPTR == MPTR_NULL) { - __AXVoiceProtection[index].threadMPTR = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + __AXVoiceProtection[index].threadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); // does not set count? } } @@ -246,7 +247,7 @@ namespace snd_core } if (AXIst_IsFrameBeingProcessed()) return -2; - MPTR currentThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + MPTR currentThreadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); if (__AXVoiceProtection[index].threadMPTR == MPTR_NULL) { __AXVoiceProtection[index].threadMPTR = currentThreadMPTR; @@ -286,7 +287,7 @@ namespace snd_core } if (AXIst_IsFrameBeingProcessed()) return -2; - MPTR currentThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(ppcInterpreterCurrentInstance); + MPTR currentThreadMPTR = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); if (__AXVoiceProtection[index].threadMPTR == currentThreadMPTR) { if (__AXVoiceProtection[index].count > 0) diff --git a/src/Cafe/OS/libs/zlib125/zlib125.cpp b/src/Cafe/OS/libs/zlib125/zlib125.cpp index 72855c61..25df6a9d 100644 --- a/src/Cafe/OS/libs/zlib125/zlib125.cpp +++ b/src/Cafe/OS/libs/zlib125/zlib125.cpp @@ -28,8 +28,7 @@ static_assert(sizeof(z_stream_ppc2) == 0x38); voidpf zcallocWrapper(voidpf opaque, uInt items, uInt size) { z_stream_ppc2* zstream = (z_stream_ppc2*)opaque; - - PPCInterpreter_t* hCPU = ppcInterpreterCurrentInstance; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); hCPU->gpr[3] = zstream->opaque.GetMPTR(); hCPU->gpr[4] = items; hCPU->gpr[5] = size; @@ -41,7 +40,7 @@ voidpf zcallocWrapper(voidpf opaque, uInt items, uInt size) void zcfreeWrapper(voidpf opaque, voidpf baseIndex) { z_stream_ppc2* zstream = (z_stream_ppc2*)opaque; - PPCInterpreter_t* hCPU = ppcInterpreterCurrentInstance; + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); hCPU->gpr[3] = zstream->opaque.GetMPTR(); hCPU->gpr[4] = memory_getVirtualOffsetFromPointer(baseIndex); PPCCore_executeCallbackInternal(zstream->zfree.GetMPTR()); diff --git a/src/Common/ExceptionHandler/ExceptionHandler.cpp b/src/Common/ExceptionHandler/ExceptionHandler.cpp index 5308ea8e..5fefc8ca 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler.cpp @@ -73,16 +73,17 @@ void ExceptionHandler_LogGeneralInfo() // info about active PPC instance: CrashLog_WriteLine(""); CrashLog_WriteHeader("Active PPC instance"); - if (ppcInterpreterCurrentInstance) + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); + if (hCPU) { OSThread_t* currentThread = coreinit::OSGetCurrentThread(); uint32 threadPtr = memory_getVirtualOffsetFromPointer(coreinit::OSGetCurrentThread()); - sprintf(dumpLine, "IP 0x%08x LR 0x%08x Thread 0x%08x", ppcInterpreterCurrentInstance->instructionPointer, ppcInterpreterCurrentInstance->spr.LR, threadPtr); + sprintf(dumpLine, "IP 0x%08x LR 0x%08x Thread 0x%08x", hCPU->instructionPointer, hCPU->spr.LR, threadPtr); CrashLog_WriteLine(dumpLine); // GPR info CrashLog_WriteLine(""); - auto gprs = ppcInterpreterCurrentInstance->gpr; + auto gprs = hCPU->gpr; sprintf(dumpLine, "r0 =%08x r1 =%08x r2 =%08x r3 =%08x r4 =%08x r5 =%08x r6 =%08x r7 =%08x", gprs[0], gprs[1], gprs[2], gprs[3], gprs[4], gprs[5], gprs[6], gprs[7]); CrashLog_WriteLine(dumpLine); sprintf(dumpLine, "r8 =%08x r9 =%08x r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x", gprs[8], gprs[9], gprs[10], gprs[11], gprs[12], gprs[13], gprs[14], gprs[15]); @@ -93,7 +94,7 @@ void ExceptionHandler_LogGeneralInfo() CrashLog_WriteLine(dumpLine); // stack trace - MPTR currentStackVAddr = ppcInterpreterCurrentInstance->gpr[1]; + MPTR currentStackVAddr = hCPU->gpr[1]; CrashLog_WriteLine(""); CrashLog_WriteHeader("PPC stack trace"); DebugLogStackTrace(currentThread, currentStackVAddr); diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 60495f53..c55314d5 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -236,12 +236,17 @@ inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, #if defined(_MSC_VER) #define UNREACHABLE __assume(false) #define ASSUME(__cond) __assume(__cond) -#elif defined(__GNUC__) + #define TLS_WORKAROUND_NOINLINE // no-op for MSVC as it has a flag for fiber-safe TLS optimizations +#elif defined(__GNUC__) && !defined(__llvm__) #define UNREACHABLE __builtin_unreachable() #define ASSUME(__cond) __attribute__((assume(__cond))) + #define TLS_WORKAROUND_NOINLINE __attribute__((noinline)) +#elif defined(__clang__) + #define UNREACHABLE __builtin_unreachable() + #define ASSUME(__cond) __builtin_assume(__cond) + #define TLS_WORKAROUND_NOINLINE __attribute__((noinline)) #else - #define UNREACHABLE - #define ASSUME(__cond) + #error Unknown compiler #endif #if defined(_MSC_VER) From ce34b95b82399923df88d12d7783c9318acc6320 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 30 Sep 2023 03:07:49 +0200 Subject: [PATCH 034/314] Fix game path not respecting utf8 encoding --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f7a66bf9..1ccc2805 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,7 +139,7 @@ void CemuCommonInit() // init title list CafeTitleList::Initialize(ActiveSettings::GetUserDataPath("title_list_cache.xml")); for (auto& it : GetConfig().game_paths) - CafeTitleList::AddScanPath(it); + CafeTitleList::AddScanPath(_utf8ToPath(it)); fs::path mlcPath = ActiveSettings::GetMlcPath(); if (!mlcPath.empty()) CafeTitleList::SetMLCPath(mlcPath); From 43976ca7ebbc91fc4eb6cd4822ae240301095b53 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 30 Sep 2023 06:21:14 +0200 Subject: [PATCH 035/314] Prioritize non-NUS format over NUS If a title exists multiple times in the game folder in different formats, then prefer and use non-NUS format if one is available. This is so we match previous Cemu behavior where Cemu would pick non-NUS simply due the fact that NUS format wasn't supported yet. --- src/Cafe/TitleList/GameInfo.h | 31 +++++++++++++++++------ src/Cafe/TitleList/TitleList.cpp | 3 +-- src/gui/components/wxTitleManagerList.cpp | 4 +-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Cafe/TitleList/GameInfo.h b/src/Cafe/TitleList/GameInfo.h index d1c557ab..8836d1e4 100644 --- a/src/Cafe/TitleList/GameInfo.h +++ b/src/Cafe/TitleList/GameInfo.h @@ -27,17 +27,13 @@ public: void SetBase(const TitleInfo& titleInfo) { - m_base = titleInfo; + if (IsPrioritizedVersionOrFormat(m_base, titleInfo)) + m_base = titleInfo; } void SetUpdate(const TitleInfo& titleInfo) { - if (HasUpdate()) - { - if (titleInfo.GetAppTitleVersion() > m_update.GetAppTitleVersion()) - m_update = titleInfo; - } - else + if (IsPrioritizedVersionOrFormat(m_update, titleInfo)) m_update = titleInfo; } @@ -53,7 +49,7 @@ public: auto it = std::find_if(m_aoc.begin(), m_aoc.end(), [aocTitleId](const TitleInfo& rhs) { return rhs.GetAppTitleId() == aocTitleId; }); if (it != m_aoc.end()) { - if(it->GetAppTitleVersion() >= aocVersion) + if (!IsPrioritizedVersionOrFormat(*it, titleInfo)) return; m_aoc.erase(it); } @@ -126,6 +122,25 @@ public: } private: + bool IsPrioritizedVersionOrFormat(const TitleInfo& currentTitle, const TitleInfo& newTitle) + { + if (!currentTitle.IsValid()) + return true; // always prefer a valid title over an invalid one + // always prefer higher version + if (newTitle.GetAppTitleVersion() > currentTitle.GetAppTitleVersion()) + return true; + // never prefer lower version + if (newTitle.GetAppTitleVersion() < currentTitle.GetAppTitleVersion()) + return false; + // for users which have both NUS and non-NUS titles in their games folder we want to prioritize non-NUS formats + // this is to stay consistent with previous Cemu versions which did not support NUS format at all + TitleInfo::TitleDataFormat currentFormat = currentTitle.GetFormat(); + TitleInfo::TitleDataFormat newFormat = newTitle.GetFormat(); + if (currentFormat != newFormat && currentFormat == TitleInfo::TitleDataFormat::NUS) + return true; + return true; + }; + TitleInfo m_base; TitleInfo m_update; std::vector m_aoc; diff --git a/src/Cafe/TitleList/TitleList.cpp b/src/Cafe/TitleList/TitleList.cpp index 03fd0855..1cc084b8 100644 --- a/src/Cafe/TitleList/TitleList.cpp +++ b/src/Cafe/TitleList/TitleList.cpp @@ -633,8 +633,7 @@ GameInfo2 CafeTitleList::GetGameInfo(TitleId titleId) uint64 baseTitleId; if (!FindBaseTitleId(titleId, baseTitleId)) { - cemuLog_logDebug(LogType::Force, "Failed to translate title id in GetGameInfo()"); - return gameInfo; + cemu_assert_suspicious(); } // determine if an optional update title id exists TitleIdParser tip(baseTitleId); diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index ea0cc3d3..d6ad8118 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -953,9 +953,7 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu } case ColumnLocation: { - const auto relative_mlc_path = - entry.path.lexically_relative(ActiveSettings::GetMlcPath()).string(); - + const auto relative_mlc_path = _pathToUtf8(entry.path.lexically_relative(ActiveSettings::GetMlcPath())); if (relative_mlc_path.starts_with("usr") || relative_mlc_path.starts_with("sys")) return _("MLC"); else From 5b27d32cb7b7c02996ef6681690d5909c6a543f7 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Sat, 30 Sep 2023 15:27:56 +0200 Subject: [PATCH 036/314] Minor localization adjustments (#984) --- CODING_STYLE.md | 1 + src/audio/audioDebuggerWindow.cpp | 36 +++++++++---------- src/config/LaunchSettings.cpp | 2 +- src/gui/CemuUpdateWindow.cpp | 4 +-- src/gui/GeneralSettings2.cpp | 36 +++++++++---------- src/gui/MainWindow.cpp | 14 +++----- src/gui/MainWindow.h | 1 - .../CreateAccount/wxCreateAccountDialog.cpp | 4 +-- src/gui/input/InputAPIAddWindow.cpp | 4 +-- src/gui/input/InputSettings2.cpp | 4 +-- 10 files changed, 50 insertions(+), 56 deletions(-) diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 54767052..39e1d342 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -55,6 +55,7 @@ std::string _pathToUtf8(const fs::path& path); fs::path _utf8ToPath(std::string_view input); // wxString <-> std::string +wxString wxString::FromUTF8(const std::string& s) wxString to_wxString(std::string_view str); // in gui/helpers.h std::string wxString::utf8_string(); diff --git a/src/audio/audioDebuggerWindow.cpp b/src/audio/audioDebuggerWindow.cpp index 41107820..3a51d187 100644 --- a/src/audio/audioDebuggerWindow.cpp +++ b/src/audio/audioDebuggerWindow.cpp @@ -33,93 +33,93 @@ AudioDebuggerWindow::AudioDebuggerWindow(wxFrame& parent) // add columns wxListItem col0; col0.SetId(0); - col0.SetText(wxT("idx")); + col0.SetText("idx"); col0.SetWidth(40); voiceListbox->InsertColumn(0, col0); wxListItem col1; col1.SetId(1); - col1.SetText(wxT("state")); + col1.SetText("state"); col1.SetWidth(48); voiceListbox->InsertColumn(1, col1); //wxListItem col2; // format col1.SetId(2); - col1.SetText(wxT("fmt")); + col1.SetText("fmt"); col1.SetWidth(52); voiceListbox->InsertColumn(2, col1); // sample base addr col1.SetId(3); - col1.SetText(wxT("base")); + col1.SetText("base"); col1.SetWidth(70); voiceListbox->InsertColumn(3, col1); // current offset col1.SetId(4); - col1.SetText(wxT("current")); + col1.SetText("current"); col1.SetWidth(70); voiceListbox->InsertColumn(4, col1); // loop offset col1.SetId(5); - col1.SetText(wxT("loop")); + col1.SetText("loop"); col1.SetWidth(70); voiceListbox->InsertColumn(5, col1); // end offset col1.SetId(6); - col1.SetText(wxT("end")); + col1.SetText("end"); col1.SetWidth(70); voiceListbox->InsertColumn(6, col1); // volume col1.SetId(7); - col1.SetText(wxT("vol")); + col1.SetText("vol"); col1.SetWidth(46); voiceListbox->InsertColumn(7, col1); // volume delta col1.SetId(8); - col1.SetText(wxT("volD")); + col1.SetText("volD"); col1.SetWidth(46); voiceListbox->InsertColumn(8, col1); // src col1.SetId(9); - col1.SetText(wxT("src")); + col1.SetText("src"); col1.SetWidth(70); voiceListbox->InsertColumn(9, col1); // low-pass filter coef a0 col1.SetId(10); - col1.SetText(wxT("lpa0")); + col1.SetText("lpa0"); col1.SetWidth(46); voiceListbox->InsertColumn(10, col1); // low-pass filter coef b0 col1.SetId(11); - col1.SetText(wxT("lpb0")); + col1.SetText("lpb0"); col1.SetWidth(46); voiceListbox->InsertColumn(11, col1); // biquad filter coef b0 col1.SetId(12); - col1.SetText(wxT("bqb0")); + col1.SetText("bqb0"); col1.SetWidth(46); voiceListbox->InsertColumn(12, col1); // biquad filter coef b0 col1.SetId(13); - col1.SetText(wxT("bqb1")); + col1.SetText("bqb1"); col1.SetWidth(46); voiceListbox->InsertColumn(13, col1); // biquad filter coef b0 col1.SetId(14); - col1.SetText(wxT("bqb2")); + col1.SetText("bqb2"); col1.SetWidth(46); voiceListbox->InsertColumn(14, col1); // biquad filter coef a0 col1.SetId(15); - col1.SetText(wxT("bqa1")); + col1.SetText("bqa1"); col1.SetWidth(46); voiceListbox->InsertColumn(15, col1); // biquad filter coef a1 col1.SetId(16); - col1.SetText(wxT("bqa2")); + col1.SetText("bqa2"); col1.SetWidth(46); voiceListbox->InsertColumn(16, col1); // device mix col1.SetId(17); - col1.SetText(wxT("deviceMix")); + col1.SetText("deviceMix"); col1.SetWidth(186); voiceListbox->InsertColumn(17, col1); diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index 92289edd..fdd4cc65 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -215,7 +215,7 @@ bool LaunchSettings::HandleCommandline(const std::vector& args) std::string errorMsg; errorMsg.append("Error while trying to parse command line parameter:\n"); errorMsg.append(ex.what()); - wxMessageBox(errorMsg, wxT("Parameter error"), wxICON_ERROR); + wxMessageBox(errorMsg, "Parameter error", wxICON_ERROR); return false; } diff --git a/src/gui/CemuUpdateWindow.cpp b/src/gui/CemuUpdateWindow.cpp index f3568ee7..91394ee2 100644 --- a/src/gui/CemuUpdateWindow.cpp +++ b/src/gui/CemuUpdateWindow.cpp @@ -24,7 +24,7 @@ wxDECLARE_EVENT(wxEVT_PROGRESS, wxCommandEvent); wxDEFINE_EVENT(wxEVT_PROGRESS, wxCommandEvent); CemuUpdateWindow::CemuUpdateWindow(wxWindow* parent) - : wxDialog(parent, wxID_ANY, "Cemu update", wxDefaultPosition, wxDefaultSize, + : wxDialog(parent, wxID_ANY, _("Cemu update"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) { auto* sizer = new wxBoxSizer(wxVERTICAL); @@ -35,7 +35,7 @@ CemuUpdateWindow::CemuUpdateWindow(wxWindow* parent) auto* rows = new wxFlexGridSizer(0, 2, 0, 0); rows->AddGrowableCol(1); - m_text = new wxStaticText(this, wxID_ANY, "Checking for latest version..."); + m_text = new wxStaticText(this, wxID_ANY, _("Checking for latest version...")); rows->Add(m_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); { diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 4dd3f9a3..e406c698 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -51,17 +51,17 @@ #include "util/ScreenSaver/ScreenSaver.h" -const wxString kDirectSound(wxT("DirectSound")); -const wxString kXAudio27(wxT("XAudio2.7")); -const wxString kXAudio2(wxT("XAudio2")); -const wxString kCubeb(wxT("Cubeb")); +const wxString kDirectSound("DirectSound"); +const wxString kXAudio27("XAudio2.7"); +const wxString kXAudio2("XAudio2"); +const wxString kCubeb("Cubeb"); -const wxString kPropertyPersistentId(wxT("PersistentId")); -const wxString kPropertyMiiName(wxT("MiiName")); -const wxString kPropertyBirthday(wxT("Birthday")); -const wxString kPropertyGender(wxT("Gender")); -const wxString kPropertyEmail(wxT("Email")); -const wxString kPropertyCountry(wxT("Country")); +const wxString kPropertyPersistentId("PersistentId"); +const wxString kPropertyMiiName("MiiName"); +const wxString kPropertyBirthday("Birthday"); +const wxString kPropertyGender("Gender"); +const wxString kPropertyEmail("Email"); +const wxString kPropertyCountry("Country"); wxDEFINE_EVENT(wxEVT_ACCOUNTLIST_REFRESH, wxCommandEvent); @@ -211,7 +211,7 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) box_sizer->Add(m_mlc_path, 1, wxALL | wxEXPAND, 5); - auto* change_path = new wxButton(box, wxID_ANY, wxT("...")); + auto* change_path = new wxButton(box, wxID_ANY, "..."); change_path->Bind(wxEVT_BUTTON, &GeneralSettings2::OnMLCPathSelect, this); change_path->SetToolTip(_("Select a custom mlc path\nThe mlc path is used to store Wii U related files like save games, game updates and dlc data")); box_sizer->Add(change_path, 0, wxALL, 5); @@ -369,7 +369,7 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook) m_audio_latency = new wxSlider(box, wxID_ANY, 2, 0, IAudioAPI::kBlockCount - 1, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); m_audio_latency->SetToolTip(_("Controls the amount of buffered audio data\nHigher values will create a delay in audio playback, but may avoid audio problems when emulation is too slow")); audio_general_row->Add(m_audio_latency, 0, wxEXPAND | wxALL, 5); - auto latency_text = new wxStaticText(box, wxID_ANY, wxT("24ms")); + auto latency_text = new wxStaticText(box, wxID_ANY, "24ms"); audio_general_row->Add(latency_text, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_RIGHT, 5); m_audio_latency->Bind(wxEVT_SLIDER, &GeneralSettings2::OnLatencySliderChanged, this, wxID_ANY, wxID_ANY, new wxControlObject(latency_text)); m_audio_latency->Bind(wxEVT_SLIDER, &GeneralSettings2::OnAudioLatencyChanged, this); @@ -408,7 +408,7 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook) audio_tv_row->Add(new wxStaticText(box, wxID_ANY, _("Volume")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_tv_volume = new wxSlider(box, wxID_ANY, 100, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); audio_tv_row->Add(m_tv_volume, 0, wxEXPAND | wxALL, 5); - auto audio_tv_volume_text = new wxStaticText(box, wxID_ANY, wxT("100%")); + auto audio_tv_volume_text = new wxStaticText(box, wxID_ANY, "100%"); audio_tv_row->Add(audio_tv_volume_text, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_RIGHT, 5); m_tv_volume->Bind(wxEVT_SLIDER, &GeneralSettings2::OnSliderChangedPercent, this, wxID_ANY, wxID_ANY, new wxControlObject(audio_tv_volume_text)); @@ -449,7 +449,7 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook) audio_pad_row->Add(new wxStaticText(box, wxID_ANY, _("Volume")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_pad_volume = new wxSlider(box, wxID_ANY, 100, 0, 100); audio_pad_row->Add(m_pad_volume, 0, wxEXPAND | wxALL, 5); - auto audio_pad_volume_text = new wxStaticText(box, wxID_ANY, wxT("100%")); + auto audio_pad_volume_text = new wxStaticText(box, wxID_ANY, "100%"); audio_pad_row->Add(audio_pad_volume_text, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_RIGHT, 5); m_pad_volume->Bind(wxEVT_SLIDER, &GeneralSettings2::OnSliderChangedPercent, this, wxID_ANY, wxID_ANY, new wxControlObject(audio_pad_volume_text)); @@ -490,7 +490,7 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook) audio_input_row->Add(new wxStaticText(box, wxID_ANY, _("Volume")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_input_volume = new wxSlider(box, wxID_ANY, 100, 0, 100); audio_input_row->Add(m_input_volume, 0, wxEXPAND | wxALL, 5); - auto audio_input_volume_text = new wxStaticText(box, wxID_ANY, wxT("100%")); + auto audio_input_volume_text = new wxStaticText(box, wxID_ANY, "100%"); audio_input_row->Add(audio_input_volume_text, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_RIGHT, 5); m_input_volume->Bind(wxEVT_SLIDER, &GeneralSettings2::OnSliderChangedPercent, this, wxID_ANY, wxID_ANY, new wxControlObject(audio_input_volume_text)); @@ -747,7 +747,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) m_account_grid->SetMinSize({ 300, -1 }); //m_account_grid->Append(new wxPropertyCategory("Main")); - auto* persistent_id_gprop = m_account_grid->Append(new wxStringProperty(wxT("PersistentId"), kPropertyPersistentId)); + auto* persistent_id_gprop = m_account_grid->Append(new wxStringProperty("PersistentId", kPropertyPersistentId)); persistent_id_gprop->SetHelpString(_("The persistent id is the internal folder name used for your saves")); m_account_grid->SetPropertyReadOnly(persistent_id_gprop); @@ -757,7 +757,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) wxPGChoices gender; gender.Add(_("Female"), 0); gender.Add(_("Male"), 1); - m_account_grid->Append(new wxEnumProperty("Gender", kPropertyGender, gender)); + m_account_grid->Append(new wxEnumProperty(_("Gender"), kPropertyGender, gender)); m_account_grid->Append(new wxStringProperty(_("Email"), kPropertyEmail)); @@ -821,7 +821,7 @@ wxPanel* GeneralSettings2::AddDebugPage(wxNotebook* notebook) debug_row->Add(new wxStaticText(panel, wxID_ANY, _("GDB Stub port"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_gdb_port = new wxSpinCtrl(panel, wxID_ANY, wxT("1337"), wxDefaultPosition, wxDefaultSize, 0, 1000, 65535); + m_gdb_port = new wxSpinCtrl(panel, wxID_ANY, "1337", wxDefaultPosition, wxDefaultSize, 0, 1000, 65535); m_gdb_port->SetToolTip(_("Changes the port that the GDB stub will use, which you can use by either starting Cemu with the --enable-gdbstub option or by enabling it the Debug tab.")); debug_row->Add(m_gdb_port, 0, wxALL | wxEXPAND, 5); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d9c5f4fb..e1985653 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -150,8 +150,7 @@ enum MAINFRAME_MENU_ID_DEBUG_DUMP_FST, MAINFRAME_MENU_ID_DEBUG_DUMP_CURL_REQUESTS, // help - MAINFRAME_MENU_ID_HELP_WEB = 21700, - MAINFRAME_MENU_ID_HELP_ABOUT, + MAINFRAME_MENU_ID_HELP_ABOUT = 21700, MAINFRAME_MENU_ID_HELP_UPDATE, MAINFRAME_MENU_ID_HELP_GETTING_STARTED, @@ -225,7 +224,6 @@ EVT_MENU(MAINFRAME_MENU_ID_DEBUG_VIEW_PPC_DEBUGGER, MainWindow::OnDebugViewPPCDe EVT_MENU(MAINFRAME_MENU_ID_DEBUG_VIEW_AUDIO_DEBUGGER, MainWindow::OnDebugViewAudioDebugger) EVT_MENU(MAINFRAME_MENU_ID_DEBUG_VIEW_TEXTURE_RELATIONS, MainWindow::OnDebugViewTextureRelations) // help menu -EVT_MENU(MAINFRAME_MENU_ID_HELP_WEB, MainWindow::OnHelpVistWebpage) EVT_MENU(MAINFRAME_MENU_ID_HELP_ABOUT, MainWindow::OnHelpAbout) EVT_MENU(MAINFRAME_MENU_ID_HELP_UPDATE, MainWindow::OnHelpUpdate) EVT_MENU(MAINFRAME_MENU_ID_HELP_GETTING_STARTED, MainWindow::OnHelpGettingStarted) @@ -560,13 +558,13 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE t.append(_pathToUtf8(launchPath)); if(launchTitle.GetInvalidReason() == TitleInfo::InvalidReason::NO_DISC_KEY) { - t.append(_("\n\n")); + t.append("\n\n"); t.append(_("Could not decrypt title. Make sure that keys.txt contains the correct disc key for this title.")); } if(launchTitle.GetInvalidReason() == TitleInfo::InvalidReason::NO_TITLE_TIK) { - t.append(_("")); - t.append(_("\n\nCould not decrypt title because title.tik is missing.")); + t.append("\n\n"); + t.append(_("Could not decrypt title because title.tik is missing.")); } wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; @@ -1815,8 +1813,6 @@ void MainWindow::OnTimer(wxTimerEvent& event) } -void MainWindow::OnHelpVistWebpage(wxCommandEvent& event) {} - #define BUILD_DATE __DATE__ " " __TIME__ class CemuAboutDialog : public wxDialog @@ -2270,8 +2266,6 @@ void MainWindow::RecreateMenu() m_menuBar->Append(debugMenu, _("&Debug")); // help menu wxMenu* helpMenu = new wxMenu(); - //helpMenu->Append(MAINFRAME_MENU_ID_HELP_WEB, wxT("&Visit website")); - //helpMenu->AppendSeparator(); m_check_update_menu = helpMenu->Append(MAINFRAME_MENU_ID_HELP_UPDATE, _("&Check for updates")); #if BOOST_OS_LINUX || BOOST_OS_MACOS m_check_update_menu->Enable(false); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 1c4b5235..07189b52 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -100,7 +100,6 @@ public: void OnOptionsInput(wxCommandEvent& event); void OnAccountSelect(wxCommandEvent& event); void OnConsoleLanguage(wxCommandEvent& event); - void OnHelpVistWebpage(wxCommandEvent& event); void OnHelpAbout(wxCommandEvent& event); void OnHelpGettingStarted(wxCommandEvent& event); void OnHelpUpdate(wxCommandEvent& event); diff --git a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp index 1da92c34..82b4d795 100644 --- a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp +++ b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp @@ -18,13 +18,13 @@ wxCreateAccountDialog::wxCreateAccountDialog(wxWindow* parent) main_sizer->SetFlexibleDirection(wxBOTH); main_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - main_sizer->Add(new wxStaticText(this, wxID_ANY, wxT("PersistentId")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + main_sizer->Add(new wxStaticText(this, wxID_ANY, "PersistentId"), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_persistent_id = new wxTextCtrl(this, wxID_ANY, fmt::format("{:x}", Account::GetNextPersistentId())); m_persistent_id->SetToolTip(_("The persistent id is the internal folder name used for your saves. Only change this if you are importing saves from a Wii U with a specific id")); main_sizer->Add(m_persistent_id, 1, wxALL | wxEXPAND, 5); - main_sizer->Add(new wxStaticText(this, wxID_ANY, wxT("Mii name")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + main_sizer->Add(new wxStaticText(this, wxID_ANY, _("Mii name")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_mii_name = new wxTextCtrl(this, wxID_ANY); m_mii_name->SetFocus(); diff --git a/src/gui/input/InputAPIAddWindow.cpp b/src/gui/input/InputAPIAddWindow.cpp index 8fa85fa3..a6d1f1a9 100644 --- a/src/gui/input/InputAPIAddWindow.cpp +++ b/src/gui/input/InputAPIAddWindow.cpp @@ -90,11 +90,11 @@ InputAPIAddWindow::InputAPIAddWindow(wxWindow* parent, const wxPoint& position, auto* row = new wxBoxSizer(wxHORIZONTAL); // we only have dsu settings atm, so add elements now row->Add(new wxStaticText(m_settings_panel, wxID_ANY, _("IP")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_ip = new wxTextCtrl(m_settings_panel, wxID_ANY, wxT("127.0.0.1")); + m_ip = new wxTextCtrl(m_settings_panel, wxID_ANY, "127.0.0.1"); row->Add(m_ip, 0, wxALL, 5); row->Add(new wxStaticText(m_settings_panel, wxID_ANY, _("Port")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_port = new wxTextCtrl(m_settings_panel, wxID_ANY, wxT("26760")); + m_port = new wxTextCtrl(m_settings_panel, wxID_ANY, "26760"); row->Add(m_port, 0, wxALL, 5); panel_sizer->Add(row, 0, wxEXPAND); diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 7a52f865..58c168a3 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -238,11 +238,11 @@ wxWindow* InputSettings2::initialize_page(size_t index) // add/remove buttons auto* bttn_sizer = new wxBoxSizer(wxHORIZONTAL); - auto* add_api = new wxButton(page, wxID_ANY, wxT(" + "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + auto* add_api = new wxButton(page, wxID_ANY, " + ", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); add_api->Bind(wxEVT_BUTTON, &InputSettings2::on_controller_add, this); bttn_sizer->Add(add_api, 0, wxALL, 5); - auto* remove_api = new wxButton(page, wxID_ANY, wxT(" - "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); + auto* remove_api = new wxButton(page, wxID_ANY, " - ", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); remove_api->Bind(wxEVT_BUTTON, &InputSettings2::on_controller_remove, this); bttn_sizer->Add(remove_api, 0, wxALL, 5); From 9523993a248155be5986ba4f32a81ba7e4ab3de6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 30 Sep 2023 13:59:45 +0200 Subject: [PATCH 037/314] Fix file menu list of recent games --- src/gui/MainWindow.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e1985653..c220c686 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -674,7 +674,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) const size_t index = menuId - MAINFRAME_MENU_ID_FILE_RECENT_0; if (index < config.recent_launch_files.size()) { - const auto& path = config.recent_launch_files[index]; + fs::path path = _utf8ToPath(config.recent_launch_files[index]); if (!path.empty()) FileLoad(path, wxLaunchGameEvent::INITIATED_BY::MENU); } @@ -2091,17 +2091,12 @@ void MainWindow::RecreateMenu() m_fileMenuSeparator1 = nullptr; for (size_t i = 0; i < config.recent_launch_files.size(); i++) { - const auto& entry = config.recent_launch_files[i]; - if (entry.empty()) + const std::string& pathStr = config.recent_launch_files[i]; + if (pathStr.empty()) continue; - - if (!fs::exists(entry)) - continue; - if (recentFileIndex == 0) m_fileMenuSeparator0 = m_fileMenu->AppendSeparator(); - - m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, entry))); + m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_RECENT_0 + i, to_wxString(fmt::format("{}. {}", recentFileIndex, pathStr))); recentFileIndex++; if (recentFileIndex >= 8) From ff9d180154699ed991e0fbda380c7f8db88e92de Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:43:24 +0200 Subject: [PATCH 038/314] Code cleanup --- CMakeSettings.json | 2 +- src/Cafe/CafeSystem.cpp | 7 --- src/Cafe/GamePatch.cpp | 2 +- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 6 +- src/Cafe/HW/Espresso/Debugger/GDBStub.cpp | 4 +- src/Cafe/HW/Latte/Core/LatteConst.h | 24 +++++--- src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 8 +-- .../LatteDecompilerAnalyzer.cpp | 8 +-- .../HW/Latte/Renderer/Vulkan/CachedFBOVk.h | 4 -- .../Renderer/Vulkan/VulkanRendererCore.cpp | 12 ++-- src/Cafe/IOSU/legacy/iosu_ioctl.cpp | 3 +- src/Cafe/OS/libs/coreinit/coreinit.cpp | 6 +- src/Cafe/OS/libs/coreinit/coreinit.h | 9 +-- src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp | 1 - src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 48 +++++++--------- src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 5 +- src/Cafe/OS/libs/gx2/GX2.h | 5 -- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 4 +- src/Cafe/OS/libs/nn_act/nn_act.cpp | 1 - src/Cafe/OS/libs/nn_save/nn_save.cpp | 55 +++++++++++-------- src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 2 +- src/gui/MainWindow.cpp | 12 +--- src/gui/TitleManager.h | 1 - src/gui/components/wxTitleManagerList.h | 3 +- src/gui/debugger/DisasmCtrl.cpp | 2 +- src/gui/guiWrapper.h | 2 - 26 files changed, 105 insertions(+), 131 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 3097caab..0927e98b 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -14,7 +14,7 @@ "generator": "Ninja", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}" }, { "name": "Debug", diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index dd761f6e..668def01 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -254,13 +254,6 @@ void InfoLog_PrintActiveSettings() cemuLog_log(LogType::Force, "Console language: {}", config.console_language); } -void PPCCore_setupSPR(PPCInterpreter_t* hCPU, uint32 coreIndex) -{ - hCPU->sprExtended.PVR = 0x70010001; - hCPU->spr.UPIR = coreIndex; - hCPU->sprExtended.msr |= MSR_FP; // enable floating point -} - struct SharedDataEntry { /* +0x00 */ uint32be name; diff --git a/src/Cafe/GamePatch.cpp b/src/Cafe/GamePatch.cpp index 84bfcb21..77eaff32 100644 --- a/src/Cafe/GamePatch.cpp +++ b/src/Cafe/GamePatch.cpp @@ -52,7 +52,7 @@ typedef struct void hleExport_xcx_enterCriticalSection(PPCInterpreter_t* hCPU) { ppcDefineParamStructPtr(xcxCS, xcxCS_t, 0); - uint32 threadId = coreinitThread_getCurrentThreadMPTRDepr(hCPU); + uint32 threadId = MEMPTR(coreinit::OSGetCurrentThread()).GetMPTR(); cemu_assert_debug(xcxCS->ukn08 != 0); cemu_assert_debug(threadId); if (xcxCS->ownerThreadId == (uint32be)threadId) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index e99ce522..62a5d592 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -513,10 +513,10 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled) { std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address); - std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", coreinitThread_getCurrentThreadMPTRDepr(hCPU), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : ""); + std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", MEMPTR(coreinit::OSGetCurrentThread()).GetMPTR(), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : ""); cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext); if (cemuLog_advancedPPCLoggingEnabled()) - DebugLogStackTrace(coreinitThread_getCurrentThreadDepr(hCPU), hCPU->gpr[1]); + DebugLogStackTrace(coreinit::OSGetCurrentThread(), hCPU->gpr[1]); break; } bp = bp->next; @@ -535,7 +535,7 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) // handle breakpoints debuggerState.debugSession.isTrapped = true; - debuggerState.debugSession.debuggedThreadMPTR = coreinitThread_getCurrentThreadMPTRDepr(hCPU); + debuggerState.debugSession.debuggedThreadMPTR = MEMPTR(coreinit::OSGetCurrentThread()).GetMPTR(); debuggerState.debugSession.instructionPointer = hCPU->instructionPointer; debuggerState.debugSession.hCPU = hCPU; debugger_createPPCStateSnapshot(hCPU); diff --git a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp index b7e15407..e934e55d 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp +++ b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp @@ -900,7 +900,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU) return cemu_assert_suspicious(); // Secondly, delete one-shot breakpoints but also temporarily delete patched instruction to run original instruction - OSThread_t* currThread = coreinitThread_getCurrentThreadDepr(hCPU); + OSThread_t* currThread = coreinit::OSGetCurrentThread(); std::string pauseReason = fmt::format("T05thread:{:08X};core:{:02X};{}", GET_THREAD_ID(currThread), PPCInterpreter_getCoreIndex(hCPU), patchedBP->second.GetReason()); bool pauseThreads = patchedBP->second.ShouldBreakThreads() || patchedBP->second.ShouldBreakThreadsOnNextInterrupt(); if (patchedBP->second.IsPersistent()) @@ -939,7 +939,7 @@ void GDBServer::HandleTrapInstruction(PPCInterpreter_t* hCPU) ThreadPool::FireAndForget(&waitForBrokenThreads, std::move(m_resumed_context), pauseReason); } - breakThreads(GET_THREAD_ID(coreinitThread_getCurrentThreadDepr(hCPU))); + breakThreads(GET_THREAD_ID(coreinit::OSGetCurrentThread())); cemuLog_logDebug(LogType::Force, "[GDBStub] Resumed from a breakpoint!"); } } diff --git a/src/Cafe/HW/Latte/Core/LatteConst.h b/src/Cafe/HW/Latte/Core/LatteConst.h index ffbead1c..04c7b888 100644 --- a/src/Cafe/HW/Latte/Core/LatteConst.h +++ b/src/Cafe/HW/Latte/Core/LatteConst.h @@ -1,21 +1,27 @@ #pragma once #include "Cafe/HW/Latte/ISA/LatteReg.h" -// this file contains legacy C-style defines, modernize and merge into LatteReg.h +// todo - this file contains legacy C-style defines, modernize and merge into LatteReg.h // GPU7/Latte hardware info -#define LATTE_NUM_GPR (128) -#define LATTE_NUM_STREAMOUT_BUFFER (4) -#define LATTE_NUM_COLOR_TARGET (8) +#define LATTE_NUM_GPR 128 +#define LATTE_NUM_STREAMOUT_BUFFER 4 +#define LATTE_NUM_COLOR_TARGET 8 -#define LATTE_NUM_MAX_TEX_UNITS (18) // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?) -#define LATTE_NUM_MAX_UNIFORM_BUFFERS (16) // number of supported uniform buffer binding locations +#define LATTE_NUM_MAX_TEX_UNITS 18 // number of available texture units per shader stage (this might be higher than 18? BotW is the only game which uses more than 16?) +#define LATTE_NUM_MAX_UNIFORM_BUFFERS 16 // number of supported uniform buffer binding locations -#define LATTE_VS_ATTRIBUTE_LIMIT (32) // todo: verify -#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS (256) // should this be 128 since there are only 128 GPRs? +#define LATTE_VS_ATTRIBUTE_LIMIT 32 // todo: verify +#define LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS 256 // should this be 128 since there are only 128 GPRs? -#define LATTE_MAX_VERTEX_BUFFERS (16) +#define LATTE_MAX_VERTEX_BUFFERS 16 + +// Cemu-specific constants + +#define LATTE_CEMU_PS_TEX_UNIT_BASE 0 +#define LATTE_CEMU_VS_TEX_UNIT_BASE 32 +#define LATTE_CEMU_GS_TEX_UNIT_BASE 64 // vertex formats diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index 1bf17c51..9cce2526 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -1,10 +1,8 @@ #include "Cafe/HW/Latte/ISA/RegDefines.h" -#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency #include "Cafe/HW/Latte/Core/Latte.h" #include "Cafe/HW/Latte/Core/LatteShader.h" #include "Cafe/HW/Latte/Renderer/Renderer.h" -#include "Cafe/GraphicPack/GraphicPack2.h" #include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h" #include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h" @@ -330,15 +328,15 @@ void LatteTexture_updateTextures() // pixel shader LatteDecompilerShader* pixelShader = LatteSHRC_GetActivePixelShader(); if (pixelShader) - LatteTexture_updateTexturesForStage(pixelShader, CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS); + LatteTexture_updateTexturesForStage(pixelShader, LATTE_CEMU_PS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_PS); // vertex shader LatteDecompilerShader* vertexShader = LatteSHRC_GetActiveVertexShader(); cemu_assert_debug(vertexShader != nullptr); - LatteTexture_updateTexturesForStage(vertexShader, CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS); + LatteTexture_updateTexturesForStage(vertexShader, LATTE_CEMU_VS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_VS); // geometry shader LatteDecompilerShader* geometryShader = LatteSHRC_GetActiveGeometryShader(); if (geometryShader) - LatteTexture_updateTexturesForStage(geometryShader, CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS); + LatteTexture_updateTexturesForStage(geometryShader, LATTE_CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS); } // returns the width, height, depth of the texture diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index 7285d312..2e837198 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -1,9 +1,7 @@ #include "Cafe/HW/Latte/Core/LatteConst.h" #include "Cafe/HW/Latte/Core/LatteShaderAssembly.h" #include "Cafe/HW/Latte/ISA/RegDefines.h" -#include "Cafe/OS/libs/gx2/GX2.h" // todo - remove this dependency #include "Cafe/HW/Latte/Core/Latte.h" -#include "Cafe/HW/Latte/Core/LatteDraw.h" #include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h" #include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h" #include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h" @@ -477,11 +475,11 @@ namespace LatteDecompiler continue; sint32 textureBindingPoint; if (decompilerContext->shaderType == LatteConst::ShaderType::Vertex) - textureBindingPoint = i + CEMU_VS_TEX_UNIT_BASE; + textureBindingPoint = i + LATTE_CEMU_VS_TEX_UNIT_BASE; else if (decompilerContext->shaderType == LatteConst::ShaderType::Geometry) - textureBindingPoint = i + CEMU_GS_TEX_UNIT_BASE; + textureBindingPoint = i + LATTE_CEMU_GS_TEX_UNIT_BASE; else if (decompilerContext->shaderType == LatteConst::ShaderType::Pixel) - textureBindingPoint = i + CEMU_PS_TEX_UNIT_BASE; + textureBindingPoint = i + LATTE_CEMU_PS_TEX_UNIT_BASE; decompilerContext->output->resourceMappingGL.textureUnitToBindingPoint[i] = textureBindingPoint; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.h index 4e6be012..bf72996e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.h @@ -75,10 +75,6 @@ private: VkRenderingAttachmentInfoKHR m_vkColorAttachments[8]; VkRenderingAttachmentInfoKHR m_vkDepthAttachment; VkRenderingAttachmentInfoKHR m_vkStencilAttachment; - //uint8 m_vkColorAttachmentsCount{0}; - bool m_vkHasDepthAttachment{ false }; - bool m_vkHasStencilAttachment{ false }; - std::vector m_usedByPipelines; // PipelineInfo objects which use this renderpass/framebuffer }; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 8b0e3b63..320357f1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -513,15 +513,15 @@ uint64 VulkanRenderer::GetDescriptorSetStateHash(LatteDecompilerShader* shader) switch (shader->shaderType) { case LatteConst::ShaderType::Vertex: - hostTextureUnit += CEMU_VS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS; break; case LatteConst::ShaderType::Pixel: - hostTextureUnit += CEMU_PS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS; break; case LatteConst::ShaderType::Geometry: - hostTextureUnit += CEMU_GS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS; break; default: @@ -631,15 +631,15 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo* switch (shader->shaderType) { case LatteConst::ShaderType::Vertex: - hostTextureUnit += CEMU_VS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_VS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_VS; break; case LatteConst::ShaderType::Pixel: - hostTextureUnit += CEMU_PS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_PS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_PS; break; case LatteConst::ShaderType::Geometry: - hostTextureUnit += CEMU_GS_TEX_UNIT_BASE; + hostTextureUnit += LATTE_CEMU_GS_TEX_UNIT_BASE; texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS; break; default: diff --git a/src/Cafe/IOSU/legacy/iosu_ioctl.cpp b/src/Cafe/IOSU/legacy/iosu_ioctl.cpp index 1fc2a27a..22e5a55d 100644 --- a/src/Cafe/IOSU/legacy/iosu_ioctl.cpp +++ b/src/Cafe/IOSU/legacy/iosu_ioctl.cpp @@ -1,6 +1,5 @@ #include "Cafe/OS/common/OSCommon.h" #include "Cafe/OS/libs/coreinit/coreinit_Thread.h" -#include "Cafe/OS/libs/coreinit/coreinit.h" #include "iosu_ioctl.h" #include "util/helpers/ringbuffer.h" @@ -23,7 +22,7 @@ sint32 iosuIoctl_pushAndWait(uint32 ioctlHandle, ioQueueEntry_t* ioQueueEntry) } __OSLockScheduler(); ioctlMutex.lock(); - ioQueueEntry->ppcThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); + ioQueueEntry->ppcThread = coreinit::OSGetCurrentThread(); _ioctlRingbuffer[ioctlHandle].Push(ioQueueEntry); ioctlMutex.unlock(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit.cpp b/src/Cafe/OS/libs/coreinit/coreinit.cpp index 8738e3a4..660f874f 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit.cpp @@ -35,7 +35,7 @@ #include "Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.h" #include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h" -coreinitData_t* gCoreinitData = NULL; +CoreinitSharedData* gCoreinitData = NULL; sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp) { @@ -323,8 +323,8 @@ void coreinit_load() coreinit::InitializeSysHeap(); // allocate coreinit global data - gCoreinitData = (coreinitData_t*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(coreinitData_t), 32)); - memset(gCoreinitData, 0x00, sizeof(coreinitData_t)); + gCoreinitData = (CoreinitSharedData*)memory_getPointerFromVirtualOffset(coreinit_allocFromSysArea(sizeof(CoreinitSharedData), 32)); + memset(gCoreinitData, 0x00, sizeof(CoreinitSharedData)); // coreinit weak links osLib_addVirtualPointer("coreinit", "MEMAllocFromDefaultHeap", memory_getVirtualOffsetFromPointer(&gCoreinitData->MEMAllocFromDefaultHeap)); diff --git a/src/Cafe/OS/libs/coreinit/coreinit.h b/src/Cafe/OS/libs/coreinit/coreinit.h index 046ffe1e..74aab9b2 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.h +++ b/src/Cafe/OS/libs/coreinit/coreinit.h @@ -16,8 +16,7 @@ void coreinitAsyncCallback_addWithLock(MPTR functionMPTR, uint32 numParameters, void coreinit_load(); // coreinit shared memory - -typedef struct +struct CoreinitSharedData { MEMPTR MEMAllocFromDefaultHeap; MEMPTR MEMAllocFromDefaultHeapEx; @@ -26,11 +25,9 @@ typedef struct MPTR __cpp_exception_init_ptr; MPTR __cpp_exception_cleanup_ptr; MPTR __stdio_cleanup; -}coreinitData_t; +}; -extern coreinitData_t* gCoreinitData; - -#include "Cafe/OS/libs/coreinit/coreinit_Spinlock.h" +extern CoreinitSharedData* gCoreinitData; // coreinit init void coreinit_start(PPCInterpreter_t* hCPU); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp index b348218f..14d7a645 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp @@ -71,7 +71,6 @@ sint32 MCP_GetSysProdSettings(MCPHANDLE mcpHandle, SysProdSettings* sysProdSetti void coreinitExport_MCP_GetSysProdSettings(PPCInterpreter_t* hCPU) { - cemuLog_logDebug(LogType::Force, "MCP_GetSysProdSettings(0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4]); sint32 result = MCP_GetSysProdSettings(hCPU->gpr[3], (SysProdSettings*)memory_getPointerFromVirtualOffset(hCPU->gpr[4])); osLib_returnFromFunction(hCPU, result); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 71e5d493..d9b33dca 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -198,7 +198,7 @@ namespace coreinit void threadEntry(PPCInterpreter_t* hCPU) { - OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(hCPU); + OSThread_t* currentThread = coreinit::OSGetCurrentThread(); uint32 r3 = hCPU->gpr[3]; uint32 r4 = hCPU->gpr[4]; uint32 lr = hCPU->spr.LR; @@ -368,39 +368,38 @@ namespace coreinit { PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); hCPU->gpr[3] = exitValue; - OSThread_t* threadBE = coreinitThread_getCurrentThreadDepr(hCPU); - MPTR t = memory_getVirtualOffsetFromPointer(threadBE); + OSThread_t* currentThread = coreinit::OSGetCurrentThread(); // thread cleanup callback - if (!threadBE->cleanupCallback2.IsNull()) + if (!currentThread->cleanupCallback2.IsNull()) { - threadBE->stateFlags = _swapEndianU32(_swapEndianU32(threadBE->stateFlags) | 0x00000001); - PPCCoreCallback(threadBE->cleanupCallback2.GetMPTR(), threadBE, _swapEndianU32(threadBE->stackEnd)); + currentThread->stateFlags = _swapEndianU32(_swapEndianU32(currentThread->stateFlags) | 0x00000001); + PPCCoreCallback(currentThread->cleanupCallback2.GetMPTR(), currentThread, _swapEndianU32(currentThread->stackEnd)); } // cpp exception cleanup - if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && threadBE->crt.eh_globals != nullptr) + if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && currentThread->crt.eh_globals != nullptr) { - PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), &threadBE->crt.eh_globals); - threadBE->crt.eh_globals = nullptr; + PPCCoreCallback(_swapEndianU32(gCoreinitData->__cpp_exception_cleanup_ptr), ¤tThread->crt.eh_globals); + currentThread->crt.eh_globals = nullptr; } // set exit code - threadBE->exitValue = exitValue; + currentThread->exitValue = exitValue; __OSLockScheduler(); // release held synchronization primitives - if (!threadBE->mutexQueue.isEmpty()) + if (!currentThread->mutexQueue.isEmpty()) { cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutexes"); while (true) { - OSMutex* mutex = threadBE->mutexQueue.getFirst(); + OSMutex* mutex = currentThread->mutexQueue.getFirst(); if (!mutex) break; - if (mutex->owner != threadBE) + if (mutex->owner != currentThread) { cemuLog_log(LogType::Force, "OSExitThread: Thread is holding mutex which it doesn't own"); - threadBE->mutexQueue.removeMutex(mutex); + currentThread->mutexQueue.removeMutex(mutex); continue; } coreinit::OSUnlockMutexInternal(mutex); @@ -409,22 +408,22 @@ namespace coreinit // todo - release all fast mutexes // handle join queue - if (!threadBE->joinQueue.isEmpty()) - threadBE->joinQueue.wakeupEntireWaitQueue(false); + if (!currentThread->joinQueue.isEmpty()) + currentThread->joinQueue.wakeupEntireWaitQueue(false); - if ((threadBE->attr & 8) != 0) + if ((currentThread->attr & 8) != 0) { // deactivate thread since it is detached - threadBE->state = OSThread_t::THREAD_STATE::STATE_NONE; - coreinit::__OSDeactivateThread(threadBE); + currentThread->state = OSThread_t::THREAD_STATE::STATE_NONE; + coreinit::__OSDeactivateThread(currentThread); // queue call to thread deallocator if set - if (!threadBE->deallocatorFunc.IsNull()) - __OSQueueThreadDeallocation(threadBE); + if (!currentThread->deallocatorFunc.IsNull()) + __OSQueueThreadDeallocation(currentThread); } else { // non-detached threads remain active - threadBE->state = OSThread_t::THREAD_STATE::STATE_MORIBUND; + currentThread->state = OSThread_t::THREAD_STATE::STATE_MORIBUND; } PPCCore_switchToSchedulerWithLock(); } @@ -1401,11 +1400,6 @@ void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count) __OSUnlockScheduler(); } -MPTR coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_t* hCPU) -{ - return memory_getVirtualOffsetFromPointer(coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)]); -} - OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU) { return coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)]; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index e2f5bef2..e619d5b6 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -486,8 +486,8 @@ struct OSThread_t /* +0x668 */ MPTR tlsBlocksMPTR; /* +0x66C */ MEMPTR waitingForFastMutex; - /* +0x670 */ coreinit::OSFastMutexLink contendedFastMutex; // link or queue? - /* +0x678 */ coreinit::OSFastMutexLink ownedFastMutex; // link or queue? + /* +0x670 */ coreinit::OSFastMutexLink contendedFastMutex; + /* +0x678 */ coreinit::OSFastMutexLink ownedFastMutex; /* +0x680 */ uint32 padding680[28 / 4]; }; @@ -615,7 +615,6 @@ namespace coreinit void coreinit_suspendThread(OSThread_t* OSThreadBE, sint32 count = 1); void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count = 1); -MPTR coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_t* hCPU); OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU); extern MPTR activeThread[256]; diff --git a/src/Cafe/OS/libs/gx2/GX2.h b/src/Cafe/OS/libs/gx2/GX2.h index b8a3f919..58d98191 100644 --- a/src/Cafe/OS/libs/gx2/GX2.h +++ b/src/Cafe/OS/libs/gx2/GX2.h @@ -7,11 +7,6 @@ #define GX2_ENABLE 1 #define GX2_DISABLE 0 -// tex unit base for render backends -#define CEMU_PS_TEX_UNIT_BASE 0 -#define CEMU_VS_TEX_UNIT_BASE 32 -#define CEMU_GS_TEX_UNIT_BASE 64 - #include "GX2_Surface.h" // general diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index ce9501ab..53981a5a 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -225,7 +225,7 @@ void CurlWorkerThread(CURL_t* curl, PPCConcurrentQueue* callerQueue, uint32 SendOrderToWorker(CURL_t* curl, QueueOrder order, uint32 arg1 = 0) { - OSThread_t* currentThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); + OSThread_t* currentThread = coreinit::OSGetCurrentThread(); curl->curlThread = currentThread; // cemuLog_logDebug(LogType::Force, "CURRENTTHREAD: 0x{} -> {}",currentThread, order) @@ -707,7 +707,7 @@ void export_curl_easy_init(PPCInterpreter_t* hCPU) memset(result.GetPtr(), 0, sizeof(CURL_t)); *result = {}; result->curl = curl_easy_init(); - result->curlThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); + result->curlThread = coreinit::OSGetCurrentThread(); result->info_contentType = nullptr; result->info_redirectUrl = nullptr; diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index fb1d4d14..68109586 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -283,7 +283,6 @@ void nnActExport_GetSimpleAddressIdEx(PPCInterpreter_t* hCPU) void nnActExport_GetPrincipalId(PPCInterpreter_t* hCPU) { // return error for non-nnid accounts? - cemuLog_logDebug(LogType::Force, "nn_act.GetPrincipalId()"); uint32be principalId; GetPrincipalIdEx(&principalId, iosu::act::ACT_SLOT_CURRENT); osLib_returnFromFunction(hCPU, (uint32)principalId); diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 1311dd46..78de8291 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -446,19 +446,20 @@ namespace save SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParamsNew_t asyncParams; asyncParams.ioMsgQueue = nullptr; asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -680,19 +681,20 @@ namespace save SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -749,19 +751,20 @@ namespace save SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -862,19 +865,20 @@ namespace save SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -935,19 +939,20 @@ namespace save SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1071,19 +1076,20 @@ namespace save SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1122,19 +1128,20 @@ namespace save SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParamsNew_t asyncParams; asyncParams.ioMsgQueue = nullptr; asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, hFile, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1182,19 +1189,20 @@ namespace save SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1233,19 +1241,20 @@ namespace save SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1422,19 +1431,20 @@ namespace save SAVEStatus SAVEChangeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } @@ -1491,19 +1501,20 @@ namespace save SAVEStatus SAVEFlushQuota(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling) { + MEMPTR currentThread{coreinit::OSGetCurrentThread()}; FSAsyncParams_t asyncParams; asyncParams.ioMsgQueue = MPTR_NULL; asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); StackAllocator param; - param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance()); + param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetMPTRBE(); SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000); + coreinit_suspendThread(currentThread, 1000); PPCCore_switchToScheduler(); return param->returnStatus; } diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index f39a24ea..e0224148 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -85,7 +85,7 @@ void nsysnetExport_socket_lib_finish(PPCInterpreter_t* hCPU) uint32* __gh_errno_ptr() { - OSThread_t* osThread = coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()); + OSThread_t* osThread = coreinit::OSGetCurrentThread(); return &osThread->context.error; } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c220c686..c0d975ec 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -14,8 +14,6 @@ #include "gui/canvas/VulkanCanvas.h" #include "Cafe/OS/libs/nn_nfp/nn_nfp.h" #include "Cafe/OS/libs/swkbd/swkbd.h" -#include "Cafe/IOSU/legacy/iosu_crypto.h" -#include "Cafe/GameProfile/GameProfile.h" #include "gui/debugger/DebuggerWindow2.h" #include "util/helpers/helpers.h" #include "config/CemuConfig.h" @@ -23,10 +21,8 @@ #include "util/ScreenSaver/ScreenSaver.h" #include "gui/GeneralSettings2.h" #include "gui/GraphicPacksWindow2.h" -#include "gui/GameProfileWindow.h" #include "gui/CemuApp.h" #include "gui/CemuUpdateWindow.h" -#include "gui/helpers/wxCustomData.h" #include "gui/LoggingWindow.h" #include "config/ActiveSettings.h" #include "config/LaunchSettings.h" @@ -36,9 +32,7 @@ #include "gui/TitleManager.h" #include "Cafe/CafeSystem.h" -#include "Cafe/TitleList/GameInfo.h" -#include #include "util/helpers/SystemException.h" #include "gui/DownloadGraphicPacksWindow.h" #include "gui/GettingStartedDialog.h" @@ -529,8 +523,8 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE } else //if (launchTitle.GetFormat() == TitleInfo::TitleDataFormat::INVALID_STRUCTURE ) { - // title is invalid, if its an RPX/ELF we can launch it directly - // otherwise its an error + // title is invalid, if it's an RPX/ELF we can launch it directly + // otherwise it's an error CafeTitleFileType fileType = DetermineCafeSystemFileType(launchPath); if (fileType == CafeTitleFileType::RPX || fileType == CafeTitleFileType::ELF) { @@ -1875,7 +1869,7 @@ public: { wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); lineSizer->Add(new wxStaticText(parent, -1, "zLib ("), 0); - lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "http://www.zlib.net", "http://www.zlib.net"), 0); + lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.zlib.net", "https://www.zlib.net"), 0); lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); sizer->Add(lineSizer); } diff --git a/src/gui/TitleManager.h b/src/gui/TitleManager.h index 17a48976..2973618f 100644 --- a/src/gui/TitleManager.h +++ b/src/gui/TitleManager.h @@ -86,7 +86,6 @@ private: void OnDisconnect(wxCommandEvent& event); void OnDlFilterCheckbox(wxCommandEvent& event); - void OnDlCheckboxShowUpdates(wxCommandEvent& event); void SetConnected(bool state); diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index cab531c4..14721c57 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -107,8 +107,7 @@ private: [[nodiscard]] boost::optional GetTitleEntry(long item); [[nodiscard]] boost::optional GetTitleEntry(const fs::path& path) const; [[nodiscard]] boost::optional GetTitleEntry(const fs::path& path); - - bool VerifyEntryFiles(TitleEntry& entry); + void OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID); bool DeleteEntry(long index, const TitleEntry& entry); diff --git a/src/gui/debugger/DisasmCtrl.cpp b/src/gui/debugger/DisasmCtrl.cpp index 21f6fc1d..c2cd5722 100644 --- a/src/gui/debugger/DisasmCtrl.cpp +++ b/src/gui/debugger/DisasmCtrl.cpp @@ -256,7 +256,7 @@ void DisasmCtrl::DrawDisassemblyLine(wxDC& dc, const wxPoint& linePosition, MPTR { sint32 sImm = disasmInstr.operand[o].immS32; if (disasmInstr.operand[o].immWidth == 16 && (sImm & 0x8000)) - sImm |= 0xFFFF0000; + sImm |= (sint32)0xFFFF0000; if ((sImm > -10 && sImm < 10) || forceDecDisplay) string = wxString::Format("%d", sImm); diff --git a/src/gui/guiWrapper.h b/src/gui/guiWrapper.h index 0e13596b..dd77819c 100644 --- a/src/gui/guiWrapper.h +++ b/src/gui/guiWrapper.h @@ -1,7 +1,5 @@ #pragma once -#include - #if BOOST_OS_LINUX #include "xcb/xproto.h" #include From 757d458161180598e606ddddc6f2a9f157e956e0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:52:54 +0200 Subject: [PATCH 039/314] Compatibility with fmtlib 10.1.x --- CMakeLists.txt | 2 +- src/Cafe/CafeSystem.cpp | 2 +- .../LatteDecompilerEmitGLSL.cpp | 5 ++++ src/Cemu/Logging/CemuLogging.h | 17 +----------- src/Common/MemPtr.h | 2 +- src/Common/precompiled.h | 26 +++++++++++++++++-- src/config/ConfigValue.h | 16 ------------ src/config/XMLConfig.h | 7 ++++- 8 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5749acb..9dc1a6f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ find_package(ZLIB REQUIRED) find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED) find_package(glm REQUIRED) -find_package(fmt 9.1.0...<10 REQUIRED) +find_package(fmt 9 REQUIRED) find_package(PNG REQUIRED) # glslang versions older than 11.11.0 define targets without a namespace diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 668def01..a3f42791 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -251,7 +251,7 @@ void InfoLog_PrintActiveSettings() if(!GetConfig().vk_accurate_barriers.GetValue()) cemuLog_log(LogType::Force, "Accurate barriers are disabled!"); } - cemuLog_log(LogType::Force, "Console language: {}", config.console_language); + cemuLog_log(LogType::Force, "Console language: {}", stdx::to_underlying(config.console_language.GetValue())); } struct SharedDataEntry diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 486b7bf5..334b4855 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -908,6 +908,11 @@ void _emitOperandInputCode(LatteDecompilerShaderContext* shaderContext, LatteDec { char floatAsStr[32]; size_t floatAsStrLen = fmt::format_to_n(floatAsStr, 32, "{:#}", *(float*)&constVal).size; + if(floatAsStrLen > 0 && floatAsStr[floatAsStrLen-1] == '.') + { + floatAsStr[floatAsStrLen] = '0'; + floatAsStrLen++; + } cemu_assert_debug(floatAsStrLen >= 3); // shortest possible form is "0.0" src->add(std::string_view(floatAsStr, floatAsStrLen)); } diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 8983c847..7d6499fe 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -70,21 +70,6 @@ bool cemuLog_log(LogType type, std::string_view text); bool cemuLog_log(LogType type, std::u8string_view text); void cemuLog_waitForFlush(); // wait until all log lines are written -template -auto ForwardEnum(T t) -{ - if constexpr (std::is_enum_v) - return fmt::underlying(t); - else - return std::forward(t); -} - -template -auto ForwardEnum(std::tuple t) -{ - return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t); -} - template bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) { @@ -98,7 +83,7 @@ bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) else { const auto format_view = fmt::basic_string_view(formatStr); - const auto text = fmt::vformat(format_view, fmt::make_format_args>(ForwardEnum(args)...)); + const auto text = fmt::vformat(format_view, fmt::make_format_args>(args...)); cemuLog_log(type, std::basic_string_view(text.data(), text.size())); } return true; diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index dc1ecd36..de787cc1 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -159,5 +159,5 @@ template struct fmt::formatter> : formatter { template - auto format(const MEMPTR& v, FormatContext& ctx) { return formatter::format(fmt::format("{:#x}", v.GetMPTR()), ctx); } + auto format(const MEMPTR& v, FormatContext& ctx) const -> format_context::iterator { return fmt::format_to(ctx.out(), "{:#x}", v.GetMPTR()); } }; diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index c55314d5..790a001a 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -552,6 +552,29 @@ inline uint32 GetTitleIdLow(uint64 titleId) #include "Cafe/HW/Espresso/PPCState.h" #include "Cafe/HW/Espresso/PPCCallback.h" +// generic formatter for enums (to underlying) +template + requires std::is_enum_v +struct fmt::formatter : fmt::formatter> +{ + auto format(const Enum& e, format_context& ctx) const + { + //return fmt::format_to(ctx.out(), "{}", fmt::underlying(e)); + + return formatter>::format(fmt::underlying(e), ctx); + } +}; + +// formatter for betype +template +struct fmt::formatter> : fmt::formatter +{ + auto format(const betype& e, format_context& ctx) const + { + return formatter::format(static_cast(e), ctx); + } +}; + // useful C++23 stuff that isn't yet widely supported // std::to_underlying @@ -561,5 +584,4 @@ namespace stdx constexpr std::underlying_type_t to_underlying(EnumT e) noexcept { return static_cast>(e); }; -} - +} \ No newline at end of file diff --git a/src/config/ConfigValue.h b/src/config/ConfigValue.h index 358af67a..43e2ad3b 100644 --- a/src/config/ConfigValue.h +++ b/src/config/ConfigValue.h @@ -232,19 +232,3 @@ private: const TType m_min_value; const TType m_max_value; }; - -template -struct fmt::formatter< ConfigValue > : formatter { - template - auto format(const ConfigValue& v, FormatContext& ctx) { - return formatter::format(v.GetValue(), ctx); - } -}; - -template -struct fmt::formatter< ConfigValueBounds > : formatter { - template - auto format(const ConfigValueBounds& v, FormatContext& ctx) { - return formatter::format(v.GetValue(), ctx); - } -}; \ No newline at end of file diff --git a/src/config/XMLConfig.h b/src/config/XMLConfig.h index 788dc9a7..2a32dc56 100644 --- a/src/config/XMLConfig.h +++ b/src/config/XMLConfig.h @@ -235,6 +235,12 @@ public: set(name, value.load()); } + template + void set(const char* name, const ConfigValue& value) + { + set(name, value.GetValue()); + } + void set(const char* name, uint64 value) { set(name, (sint64)value); @@ -462,4 +468,3 @@ public: private: T m_data; }; - From 29c823fa1fdba394b7fce21583f529d8941e653d Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:05:44 +0200 Subject: [PATCH 040/314] Latte: Fix uniform size limit being too low --- src/Cafe/HW/Latte/Core/Latte.h | 2 +- src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/Latte.h b/src/Cafe/HW/Latte/Core/Latte.h index f13abca0..861d7ddf 100644 --- a/src/Cafe/HW/Latte/Core/Latte.h +++ b/src/Cafe/HW/Latte/Core/Latte.h @@ -167,7 +167,7 @@ void LatteBufferCache_LoadRemappedUniforms(struct LatteDecompilerShader* shader, void LatteRenderTarget_updateViewport(); -#define LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE (1024) // maximum size for uniform blocks (in vec4s). On Nvidia hardware 4096 is the maximum (64K / 16 = 4096) all other vendors have much higher limits +#define LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE (4096) // maximum size for uniform blocks (in vec4s). On Nvidia hardware 4096 is the maximum (64K / 16 = 4096) all other vendors have much higher limits //static uint32 glTempError; //#define catchOpenGLError() glFinish(); if( (glTempError = glGetError()) != 0 ) { printf("OpenGL error 0x%x: %s : %d timestamp %08x\n", glTempError, __FILE__, __LINE__, GetTickCount()); __debugbreak(); } diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h index 92777844..1159614e 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h @@ -162,8 +162,8 @@ struct LatteDecompilerShader // compact resource lists for optimized access struct QuickBufferEntry { - uint8 index; - uint16 size; + uint32 index : 8; + uint32 size : 24; }; boost::container::static_vector list_quickBufferList; uint8 textureUnitList[LATTE_NUM_MAX_TEX_UNITS]; From db53f3b98020160e0890a1b237755d15c091bd83 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 2 Oct 2023 21:24:50 +0200 Subject: [PATCH 041/314] Fixes for titles in NUS format Symlinks were not handled correctly --- src/Cafe/Filesystem/FST/FST.cpp | 13 +++++++------ src/Cafe/Filesystem/FST/FST.h | 18 ++++++++++++------ src/Cafe/Filesystem/fscDeviceWud.cpp | 4 ++-- src/Cafe/TitleList/GameInfo.h | 4 ++-- .../Tools/DownloadManager/DownloadManager.cpp | 6 +++++- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Cafe/Filesystem/FST/FST.cpp b/src/Cafe/Filesystem/FST/FST.cpp index 10ae659d..570671d4 100644 --- a/src/Cafe/Filesystem/FST/FST.cpp +++ b/src/Cafe/Filesystem/FST/FST.cpp @@ -686,25 +686,25 @@ bool FSTVolume::OpenFile(std::string_view path, FSTFileHandle& fileHandleOut, bo return true; } -bool FSTVolume::IsDirectory(FSTFileHandle& fileHandle) const +bool FSTVolume::IsDirectory(const FSTFileHandle& fileHandle) const { cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size()); return m_entries[fileHandle.m_fstIndex].GetType() == FSTEntry::TYPE::DIRECTORY; }; -bool FSTVolume::IsFile(FSTFileHandle& fileHandle) const +bool FSTVolume::IsFile(const FSTFileHandle& fileHandle) const { cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size()); return m_entries[fileHandle.m_fstIndex].GetType() == FSTEntry::TYPE::FILE; }; -bool FSTVolume::HasLinkFlag(FSTFileHandle& fileHandle) const +bool FSTVolume::HasLinkFlag(const FSTFileHandle& fileHandle) const { cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size()); return HAS_FLAG(m_entries[fileHandle.m_fstIndex].GetFlags(), FSTEntry::FLAGS::FLAG_LINK); }; -std::string_view FSTVolume::GetName(FSTFileHandle& fileHandle) const +std::string_view FSTVolume::GetName(const FSTFileHandle& fileHandle) const { if (fileHandle.m_fstIndex > m_entries.size()) return ""; @@ -712,7 +712,7 @@ std::string_view FSTVolume::GetName(FSTFileHandle& fileHandle) const return entryName; } -std::string FSTVolume::GetPath(FSTFileHandle& fileHandle) const +std::string FSTVolume::GetPath(const FSTFileHandle& fileHandle) const { std::string path; auto& entry = m_entries[fileHandle.m_fstIndex]; @@ -743,7 +743,7 @@ std::string FSTVolume::GetPath(FSTFileHandle& fileHandle) const return path; } -uint32 FSTVolume::GetFileSize(FSTFileHandle& fileHandle) const +uint32 FSTVolume::GetFileSize(const FSTFileHandle& fileHandle) const { if (m_entries[fileHandle.m_fstIndex].GetType() != FSTEntry::TYPE::FILE) return 0; @@ -994,6 +994,7 @@ bool FSTVolume::OpenDirectoryIterator(std::string_view path, FSTDirectoryIterato if (!IsDirectory(fileHandle)) return false; auto const& fstEntry = m_entries[fileHandle.m_fstIndex]; + directoryIteratorOut.dirHandle = fileHandle; directoryIteratorOut.startIndex = fileHandle.m_fstIndex + 1; directoryIteratorOut.endIndex = fstEntry.dirInfo.endIndex; directoryIteratorOut.currentIndex = directoryIteratorOut.startIndex; diff --git a/src/Cafe/Filesystem/FST/FST.h b/src/Cafe/Filesystem/FST/FST.h index 98bf1ae6..24fc39ea 100644 --- a/src/Cafe/Filesystem/FST/FST.h +++ b/src/Cafe/Filesystem/FST/FST.h @@ -11,7 +11,13 @@ private: struct FSTDirectoryIterator { friend class FSTVolume; + + const FSTFileHandle& GetDirHandle() const + { + return dirHandle; + } private: + FSTFileHandle dirHandle; uint32 startIndex; uint32 endIndex; uint32 currentIndex; @@ -43,15 +49,15 @@ public: bool OpenFile(std::string_view path, FSTFileHandle& fileHandleOut, bool openOnlyFiles = false); // file and directory functions - bool IsDirectory(FSTFileHandle& fileHandle) const; - bool IsFile(FSTFileHandle& fileHandle) const; - bool HasLinkFlag(FSTFileHandle& fileHandle) const; + bool IsDirectory(const FSTFileHandle& fileHandle) const; + bool IsFile(const FSTFileHandle& fileHandle) const; + bool HasLinkFlag(const FSTFileHandle& fileHandle) const; - std::string_view GetName(FSTFileHandle& fileHandle) const; - std::string GetPath(FSTFileHandle& fileHandle) const; + std::string_view GetName(const FSTFileHandle& fileHandle) const; + std::string GetPath(const FSTFileHandle& fileHandle) const; // file functions - uint32 GetFileSize(FSTFileHandle& fileHandle) const; + uint32 GetFileSize(const FSTFileHandle& fileHandle) const; uint32 ReadFile(FSTFileHandle& fileHandle, uint32 offset, uint32 size, void* dataOut); // directory iterator diff --git a/src/Cafe/Filesystem/fscDeviceWud.cpp b/src/Cafe/Filesystem/fscDeviceWud.cpp index bf43bf3e..517c8573 100644 --- a/src/Cafe/Filesystem/fscDeviceWud.cpp +++ b/src/Cafe/Filesystem/fscDeviceWud.cpp @@ -128,7 +128,7 @@ class fscDeviceWUDC : public fscDeviceC if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE)) { FSTFileHandle fstFileHandle; - if (mountedVolume->OpenFile(path, fstFileHandle, true)) + if (mountedVolume->OpenFile(path, fstFileHandle, true) && !mountedVolume->HasLinkFlag(fstFileHandle)) { *fscStatus = FSC_STATUS_OK; return new FSCDeviceWudFileCtx(mountedVolume, fstFileHandle); @@ -137,7 +137,7 @@ class fscDeviceWUDC : public fscDeviceC if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR)) { FSTDirectoryIterator dirIterator; - if (mountedVolume->OpenDirectoryIterator(path, dirIterator)) + if (mountedVolume->OpenDirectoryIterator(path, dirIterator) && !mountedVolume->HasLinkFlag(dirIterator.GetDirHandle())) { *fscStatus = FSC_STATUS_OK; return new FSCDeviceWudFileCtx(mountedVolume, dirIterator); diff --git a/src/Cafe/TitleList/GameInfo.h b/src/Cafe/TitleList/GameInfo.h index 8836d1e4..6e922b93 100644 --- a/src/Cafe/TitleList/GameInfo.h +++ b/src/Cafe/TitleList/GameInfo.h @@ -136,8 +136,8 @@ private: // this is to stay consistent with previous Cemu versions which did not support NUS format at all TitleInfo::TitleDataFormat currentFormat = currentTitle.GetFormat(); TitleInfo::TitleDataFormat newFormat = newTitle.GetFormat(); - if (currentFormat != newFormat && currentFormat == TitleInfo::TitleDataFormat::NUS) - return true; + if (currentFormat != TitleInfo::TitleDataFormat::NUS && newFormat == TitleInfo::TitleDataFormat::NUS) + return false; return true; }; diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index 09093792..807a4e72 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -1286,7 +1286,11 @@ bool DownloadManager::asyncPackageInstallRecursiveExtractFiles(Package* package, setPackageError(package, "Internal error"); return false; } - + if (fstVolume->HasLinkFlag(dirItr.GetDirHandle())) + { + cemu_assert_suspicious(); + return true; + } FSTFileHandle itr; while (fstVolume->Next(dirItr, itr)) { From db44a2d130d6d4ff497c60d4c7a0d04a56c2779f Mon Sep 17 00:00:00 2001 From: Cemu-Language CI Date: Wed, 4 Oct 2023 21:39:01 +0000 Subject: [PATCH 042/314] Update translation files --- bin/resources/de/cemu.mo | Bin 27890 -> 65048 bytes bin/resources/he/cemu.mo | Bin 0 -> 23202 bytes bin/resources/it/cemu.mo | Bin 57658 -> 71398 bytes bin/resources/ko/cemu.mo | Bin 62866 -> 69116 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 bin/resources/he/cemu.mo diff --git a/bin/resources/de/cemu.mo b/bin/resources/de/c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itT zo<0Q5OxNEesmTu{Dk{Br)T6d3`({xcewBaxO((N@L({B(9=3eQ`TR|y<95oo9aG0` z{***~h4%Ao3R`}6Wy9>*!Js=cJKxOv{=P=3j;!#4anthebJP0nKk)ZDY37WRStkEv z?<5~NEjbl|kPaJuMK6w>I*gs{>QGt#0onQLxDyU~j=th-dlqM(`ko^i#xGxV1&0P> z)d$T6`F9U!mzC-xtle22%&CmKd>%T<<610_srhB|om!!{P7X}!B#FoT27h&$|L48< sHxK=$C;xv(x~KMvGtbjUaaJ%?PXB|^YG+xXD(d{QnogBj_0yvN1%%kT#sB~S diff --git a/bin/resources/he/cemu.mo b/bin/resources/he/cemu.mo new file mode 100644 index 0000000000000000000000000000000000000000..072e48c61e40f0228e3cc80d0ab8099a2fb8a09c GIT binary patch literal 23202 zcmd6td4OESedi01!EP+T9040JPd4ZP%^-=x@_;0S4iE@wm>B^!BBV9_W~Nb3_t1w% z11NSJ+a&nXF+xZhgd~JUlI`^od?X>paah(TiPwo6+iSeZvc_yo*f{a}#`%1IRqyp1 z9XNk(OEuqD^{RgLt6%-Ds_y4bpS0ESIqNv*&I6x%t#b{YOK(uCbJv{h++=Ve_uFtup02bfbR#@ZzFgrI0l{qehkcke+fr2G0P$2a1oELCyP1@HOBG zZ}j6|2daJscoO(VQ0tijs(%}(bzKQ+o~5Ar-3E$}KLEu?1r(hTQ1iVD)VK#g(b)m2 z-=m<$e>}8*281Q|1yJj5f|A#dK=peG)cBu*;_DSq>&v~#@7MXD`dtEQ{g;92-vMgA zMWFb&2}H#14)FKD2B>}?1VwjisP6$q=MboMdjy=r465HBf#Pd3co+CdP;xkzM)7eWsC}Fna1N;X=YrCw>%j%! zYEb>hLi;{Y{C^&l9G(V6=UGtnp980ZFMyKwX>WFJHh3N={a*n_U;)&8?*pfSTS4{z zD-aR8uYj=Zo(DDVxC{Jx&IYy4D?sBD6hEs$$>}ao{Ja;`zCHj-K3hT283V=lr@_m> zr$Ej7b5L|9Mb2Ffo(|3cSArej2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uv^dUBiNFm*;Fsb9d|P9sXSa(2+8i{7*U2K!ZBvC!?C%koyu&Y8cQr~0-gl9QF;o0(~? zn&NU*TvgoVO7&wGL$8!swZr8q>TwEhou CG|Kq^ From d4a2a8e8de39821a22dd2ad82d2186796e566af5 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 16 Oct 2023 07:33:12 +0200 Subject: [PATCH 043/314] Vulkan: Cleanup image barrier code (#988) --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 47 ++++--------------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 39 +++++++++------ 2 files changed, 33 insertions(+), 53 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index d084a399..052ca21a 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2801,47 +2801,18 @@ void VulkanRenderer::ClearColorImageRaw(VkImage image, uint32 sliceIndex, uint32 { draw_endRenderPass(); - VkImageMemoryBarrier barrier = {}; - barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barrier.oldLayout = inputLayout; - barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier.image = image; - barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barrier.subresourceRange.baseMipLevel = mipIndex; - barrier.subresourceRange.levelCount = 1; - barrier.subresourceRange.baseArrayLayer = sliceIndex; - barrier.subresourceRange.layerCount = 1; + VkImageSubresourceRange subresourceRange{}; + subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresourceRange.baseMipLevel = mipIndex; + subresourceRange.levelCount = 1; + subresourceRange.baseArrayLayer = sliceIndex; + subresourceRange.layerCount = 1; - VkPipelineStageFlags srcStages = 0; - VkPipelineStageFlags dstStages = 0; - barrier.srcAccessMask = 0; - barrier.dstAccessMask = 0; - barrier_calcStageAndMask(srcStages, barrier.srcAccessMask); - barrier_calcStageAndMask(dstStages, barrier.dstAccessMask); + barrier_image(image, subresourceRange, inputLayout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, 1, &barrier); + vkCmdClearColorImage(m_state.currentCommandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &color, 1, &subresourceRange); - VkImageSubresourceRange imageRange{}; - imageRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - imageRange.baseArrayLayer = sliceIndex; - imageRange.layerCount = 1; - imageRange.baseMipLevel = mipIndex; - imageRange.levelCount = 1; - - vkCmdClearColorImage(m_state.currentCommandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &color, 1, &imageRange); - - barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barrier.newLayout = outputLayout; - - srcStages = 0; - dstStages = 0; - barrier.srcAccessMask = 0; - barrier.dstAccessMask = 0; - barrier_calcStageAndMask(srcStages, barrier.srcAccessMask); - barrier_calcStageAndMask(dstStages, barrier.dstAccessMask); - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, 1, &barrier); + barrier_image(image, subresourceRange, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, outputLayout); } void VulkanRenderer::ClearColorImage(LatteTextureVk* vkTexture, uint32 sliceIndex, uint32 mipIndex, const VkClearColorValue& color, VkImageLayout outputLayout) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 24008ee3..3d68f844 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -906,10 +906,8 @@ private: } template - void barrier_image(LatteTextureVk* vkTexture, VkImageSubresourceLayers& subresourceLayers, VkImageLayout newLayout) + void barrier_image(VkImage imageVk, VkImageSubresourceRange& subresourceRange, VkImageLayout oldLayout, VkImageLayout newLayout) { - VkImage imageVk = vkTexture->GetImageObj()->m_image; - VkPipelineStageFlags srcStages = 0; VkPipelineStageFlags dstStages = 0; @@ -922,22 +920,33 @@ private: barrier_calcStageAndMask(srcStages, imageMemBarrier.srcAccessMask); barrier_calcStageAndMask(dstStages, imageMemBarrier.dstAccessMask); imageMemBarrier.image = imageVk; - imageMemBarrier.subresourceRange.aspectMask = subresourceLayers.aspectMask; - imageMemBarrier.subresourceRange.baseArrayLayer = subresourceLayers.baseArrayLayer; - imageMemBarrier.subresourceRange.layerCount = subresourceLayers.layerCount; - imageMemBarrier.subresourceRange.baseMipLevel = subresourceLayers.mipLevel; - imageMemBarrier.subresourceRange.levelCount = 1; - imageMemBarrier.oldLayout = vkTexture->GetImageLayout(imageMemBarrier.subresourceRange); + imageMemBarrier.subresourceRange = subresourceRange; + imageMemBarrier.oldLayout = oldLayout; imageMemBarrier.newLayout = newLayout; vkCmdPipelineBarrier(m_state.currentCommandBuffer, - srcStages, dstStages, - 0, - 0, NULL, - 0, NULL, - 1, &imageMemBarrier); + srcStages, dstStages, + 0, + 0, NULL, + 0, NULL, + 1, &imageMemBarrier); + } - vkTexture->SetImageLayout(imageMemBarrier.subresourceRange, newLayout); + template + void barrier_image(LatteTextureVk* vkTexture, VkImageSubresourceLayers& subresourceLayers, VkImageLayout newLayout) + { + VkImage imageVk = vkTexture->GetImageObj()->m_image; + + VkImageSubresourceRange subresourceRange; + subresourceRange.aspectMask = subresourceLayers.aspectMask; + subresourceRange.baseArrayLayer = subresourceLayers.baseArrayLayer; + subresourceRange.layerCount = subresourceLayers.layerCount; + subresourceRange.baseMipLevel = subresourceLayers.mipLevel; + subresourceRange.levelCount = 1; + + barrier_image(imageVk, subresourceRange, vkTexture->GetImageLayout(subresourceRange), newLayout); + + vkTexture->SetImageLayout(subresourceRange, newLayout); } From 13a50a915e55a257388c369085b85bac0a4aa3cc Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Mon, 16 Oct 2023 13:41:06 +0200 Subject: [PATCH 044/314] Fix several language selection issues (#994) --- src/gui/CemuApp.cpp | 77 +++++++++++++------------------ src/gui/CemuApp.h | 7 +-- src/gui/GeneralSettings2.cpp | 4 +- src/gui/components/wxGameList.cpp | 2 +- 4 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 04823ca4..53a42a10 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -99,29 +99,7 @@ bool CemuApp::OnInit() wxInitAllImageHandlers(); - - m_languages = GetAvailableLanguages(); - - const sint32 language = GetConfig().language; - const auto it = std::find_if(m_languages.begin(), m_languages.end(), [language](const wxLanguageInfo* info) { return info->Language == language; }); - if (it != m_languages.end() && wxLocale::IsAvailable(language)) - { - if (m_locale.Init(language)) - { - m_locale.AddCatalogLookupPathPrefix(ActiveSettings::GetDataPath("resources").generic_string()); - m_locale.AddCatalog("cemu"); - } - } - - if (!m_locale.IsOk()) - { - if (!wxLocale::IsAvailable(wxLANGUAGE_DEFAULT) || !m_locale.Init(wxLANGUAGE_DEFAULT)) - { - m_locale.Init(wxLANGUAGE_ENGLISH); - m_locale.AddCatalogLookupPathPrefix(ActiveSettings::GetDataPath("resources").generic_string()); - m_locale.AddCatalog("cemu"); - } - } + LocalizeUI(); // fill colour db wxTheColourDatabase->AddColour("ERROR", wxColour(0xCC, 0, 0)); @@ -231,33 +209,44 @@ int CemuApp::FilterEvent(wxEvent& event) return wxApp::FilterEvent(event); } -std::vector CemuApp::GetAvailableLanguages() +std::vector CemuApp::GetLanguages() const { + std::vector availableLanguages(m_availableTranslations); + availableLanguages.insert(availableLanguages.begin(), wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH)); + return availableLanguages; +} + +void CemuApp::LocalizeUI() { - const auto path = ActiveSettings::GetDataPath("resources"); - if (!exists(path)) - return {}; - - std::vector result; - for (const auto& p : fs::directory_iterator(path)) + std::unique_ptr translationsMgr(new wxTranslations()); + m_availableTranslations = GetAvailableTranslationLanguages(translationsMgr.get()); + + const sint32 configuredLanguage = GetConfig().language; + bool isTranslationAvailable = std::any_of(m_availableTranslations.begin(), m_availableTranslations.end(), + [configuredLanguage](const wxLanguageInfo* info) { return info->Language == configuredLanguage; }); + if (configuredLanguage == wxLANGUAGE_DEFAULT || isTranslationAvailable) { - if (!fs::is_directory(p)) - continue; + translationsMgr->SetLanguage(static_cast(configuredLanguage)); + translationsMgr->AddCatalog("cemu"); - const auto& path = p.path(); - auto filename = path.filename(); + if (translationsMgr->IsLoaded("cemu") && wxLocale::IsAvailable(configuredLanguage)) + m_locale.Init(configuredLanguage); - const auto* lang_info = wxLocale::FindLanguageInfo(filename.c_str()); - if (!lang_info) - continue; - - const auto language_file = path / "cemu.mo"; - if (!fs::exists(language_file)) - continue; - - result.emplace_back(lang_info); + // This must be run after wxLocale::Init, as the latter sets up its own wxTranslations instance which we want to override + wxTranslations::Set(translationsMgr.release()); } +} - return result; +std::vector CemuApp::GetAvailableTranslationLanguages(wxTranslations* translationsMgr) +{ + wxFileTranslationsLoader::AddCatalogLookupPathPrefix(wxHelper::FromPath(ActiveSettings::GetDataPath("resources"))); + std::vector languages; + for (const auto& langName : translationsMgr->GetAvailableTranslations("cemu")) + { + const auto* langInfo = wxLocale::FindLanguageInfo(langName); + if (langInfo) + languages.emplace_back(langInfo); + } + return languages; } void CemuApp::CreateDefaultFiles(bool first_start) diff --git a/src/gui/CemuApp.h b/src/gui/CemuApp.h index 1dac29f1..cfdab0a2 100644 --- a/src/gui/CemuApp.h +++ b/src/gui/CemuApp.h @@ -13,8 +13,7 @@ public: void OnAssertFailure(const wxChar* file, int line, const wxChar* func, const wxChar* cond, const wxChar* msg) override; int FilterEvent(wxEvent& event) override; - const std::vector& GetLanguages() const { return m_languages; } - static std::vector GetAvailableLanguages(); + std::vector GetLanguages() const; static void CreateDefaultFiles(bool first_start = false); static bool TrySelectMLCPath(fs::path path); @@ -22,11 +21,13 @@ public: private: void ActivateApp(wxActivateEvent& event); + void LocalizeUI(); + static std::vector GetAvailableTranslationLanguages(wxTranslations* translationsMgr); MainWindow* m_mainFrame = nullptr; wxLocale m_locale; - std::vector m_languages; + std::vector m_availableTranslations; }; wxDECLARE_APP(CemuApp); diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index e406c698..e33cfbf6 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -123,7 +123,7 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) first_row->Add(new wxStaticText(box, wxID_ANY, _("Language"), wxDefaultPosition, wxDefaultSize, 0), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - wxString language_choices[] = { _("Default"), "English" }; + wxString language_choices[] = { _("Default") }; m_language = new wxChoice(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, std::size(language_choices), language_choices); m_language->SetSelection(0); m_language->SetToolTip(_("Changes the interface language of Cemu\nAvailable languages are stored in the translation directory\nA restart will be required after changing the language")); @@ -928,8 +928,6 @@ void GeneralSettings2::StoreConfig() auto selection = m_language->GetSelection(); if (selection == 0) GetConfig().language = wxLANGUAGE_DEFAULT; - else if (selection == 1) - GetConfig().language = wxLANGUAGE_ENGLISH; else { const auto language = m_language->GetStringSelection(); diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index a64b49bf..2c78ea3c 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1027,7 +1027,7 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event) if (playTimeStat.last_played.year != 0) { const wxDateTime tmp((wxDateTime::wxDateTime_t)playTimeStat.last_played.day, (wxDateTime::Month)playTimeStat.last_played.month, (wxDateTime::wxDateTime_t)playTimeStat.last_played.year, 0, 0, 0, 0); - SetItem(index, ColumnGameStarted, tmp.FormatISODate()); + SetItem(index, ColumnGameStarted, tmp.FormatDate()); } else SetItem(index, ColumnGameStarted, _("never")); From 0d71885c881984978ab8e0375975be3053a0a864 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 17 Oct 2023 04:41:22 +0200 Subject: [PATCH 045/314] nn_fp: Full rework of friend service --- src/Cafe/CafeSystem.cpp | 24 +- .../Interpreter/PPCInterpreterHLE.cpp | 2 +- src/Cafe/HW/Espresso/PPCState.h | 2 +- src/Cafe/IOSU/iosu_types_common.h | 14 +- src/Cafe/IOSU/kernel/iosu_kernel.cpp | 232 +- src/Cafe/IOSU/kernel/iosu_kernel.h | 7 +- src/Cafe/IOSU/legacy/iosu_act.cpp | 9 + src/Cafe/IOSU/legacy/iosu_act.h | 4 + src/Cafe/IOSU/legacy/iosu_fpd.cpp | 2105 ++++++++++------- src/Cafe/IOSU/legacy/iosu_fpd.h | 417 ++-- src/Cafe/IOSU/nn/iosu_nn_service.cpp | 129 +- src/Cafe/IOSU/nn/iosu_nn_service.h | 67 + src/Cafe/OS/RPL/rpl.cpp | 2 +- src/Cafe/OS/common/OSCommon.cpp | 5 +- src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 86 +- src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp | 17 - src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp | 23 +- src/Cafe/OS/libs/h264_avc/H264Dec.cpp | 14 +- src/Cafe/OS/libs/nn_act/nn_act.cpp | 4 +- src/Cafe/OS/libs/nn_fp/nn_fp.cpp | 1269 +++++----- .../nn_olv/nn_olv_DownloadCommunityTypes.cpp | 4 +- .../OS/libs/nn_olv/nn_olv_InitializeTypes.cpp | 4 +- src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp | 10 +- .../nn_olv/nn_olv_UploadCommunityTypes.cpp | 4 +- .../nn_olv/nn_olv_UploadFavoriteTypes.cpp | 4 +- src/Cemu/Logging/CemuLogging.cpp | 1 + src/Cemu/Logging/CemuLogging.h | 1 + src/Cemu/napi/napi_act.cpp | 2 +- src/Cemu/nex/nex.cpp | 6 +- src/Cemu/nex/nexFriends.cpp | 211 +- src/Cemu/nex/nexFriends.h | 57 +- src/Common/CMakeLists.txt | 1 + src/Common/CafeString.h | 73 + src/Common/StackAllocator.h | 31 +- src/gui/MainWindow.cpp | 1 + src/util/helpers/StringHelpers.h | 1 + .../highresolutiontimer/HighResolutionTimer.h | 10 + 37 files changed, 2862 insertions(+), 1991 deletions(-) create mode 100644 src/Common/CafeString.h diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index a3f42791..3d06281e 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -526,6 +526,13 @@ namespace CafeSystem cemuLog_log(LogType::Force, "Platform: {}", platform); } + static std::vector s_iosuModules = + { + // entries in this list are ordered by initialization order. Shutdown in reverse order + iosu::kernel::GetModule(), + iosu::fpd::GetModule() + }; + // initialize all subsystems which are persistent and don't depend on a game running void Initialize() { @@ -550,14 +557,15 @@ namespace CafeSystem // allocate memory for all SysAllocators // must happen before COS module init, but also before iosu::kernel::Initialize() SysAllocatorContainer::GetInstance().Initialize(); - // init IOSU + // init IOSU modules + for(auto& module : s_iosuModules) + module->SystemLaunch(); + // init IOSU (deprecated manual init) iosuCrypto_init(); - iosu::kernel::Initialize(); iosu::fsa::Initialize(); iosuIoctl_init(); iosuAct_init_depr(); iosu::act::Initialize(); - iosu::fpd::Initialize(); iosu::iosuMcp_init(); iosu::mcp::Init(); iosu::iosuAcp_init(); @@ -593,11 +601,14 @@ namespace CafeSystem // if a title is running, shut it down if (sSystemRunning) ShutdownTitle(); - // shutdown persistent subsystems + // shutdown persistent subsystems (deprecated manual shutdown) iosu::odm::Shutdown(); iosu::act::Stop(); iosu::mcp::Shutdown(); iosu::fsa::Shutdown(); + // shutdown IOSU modules + for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it) + (*it)->SystemExit(); s_initialized = false; } @@ -821,7 +832,8 @@ namespace CafeSystem void _LaunchTitleThread() { - // init + for(auto& module : s_iosuModules) + module->TitleStart(); cemu_initForGame(); // enter scheduler if (ActiveSettings::GetCPUMode() == CPUMode::MulticoreRecompiler) @@ -956,6 +968,8 @@ namespace CafeSystem nn::save::ResetToDefaultState(); coreinit::__OSDeleteAllActivePPCThreads(); RPLLoader_ResetState(); + for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it) + (*it)->TitleStop(); // stop time tracking iosu::pdm::Stop(); // reset Cemu subsystems diff --git a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHLE.cpp b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHLE.cpp index 6aa1fcfa..24219e66 100644 --- a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHLE.cpp +++ b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHLE.cpp @@ -19,7 +19,7 @@ void PPCInterpreter_handleUnsupportedHLECall(PPCInterpreter_t* hCPU) std::vector* sPPCHLETable{}; -HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall) +HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall, std::string hleName) { if (!sPPCHLETable) sPPCHLETable = new std::vector(); diff --git a/src/Cafe/HW/Espresso/PPCState.h b/src/Cafe/HW/Espresso/PPCState.h index 85b2dc04..134f73a8 100644 --- a/src/Cafe/HW/Espresso/PPCState.h +++ b/src/Cafe/HW/Espresso/PPCState.h @@ -230,7 +230,7 @@ static inline float flushDenormalToZero(float f) typedef void(*HLECALL)(PPCInterpreter_t* hCPU); typedef sint32 HLEIDX; -HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall); +HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall, std::string hleName); HLECALL PPCInterpreter_getHLECall(HLEIDX funcIndex); // HLE scheduler diff --git a/src/Cafe/IOSU/iosu_types_common.h b/src/Cafe/IOSU/iosu_types_common.h index 94c0cd2c..1f7f78f8 100644 --- a/src/Cafe/IOSU/iosu_types_common.h +++ b/src/Cafe/IOSU/iosu_types_common.h @@ -1,6 +1,9 @@ #pragma once using IOSMsgQueueId = uint32; +using IOSTimerId = uint32; + +static constexpr IOSTimerId IOSInvalidTimerId = 0xFFFFFFFF; // returned for syscalls // maybe also shared with IPC? @@ -19,4 +22,13 @@ enum IOS_ERROR : sint32 inline bool IOS_ResultIsError(const IOS_ERROR err) { return (err & 0x80000000) != 0; -} \ No newline at end of file +} + +class IOSUModule +{ + public: + virtual void SystemLaunch() {}; // CafeSystem is initialized + virtual void SystemExit() {}; // CafeSystem is shutdown + virtual void TitleStart() {}; // foreground title is launched + virtual void TitleStop() {}; // foreground title is closed +}; diff --git a/src/Cafe/IOSU/kernel/iosu_kernel.cpp b/src/Cafe/IOSU/kernel/iosu_kernel.cpp index 680170bc..52097698 100644 --- a/src/Cafe/IOSU/kernel/iosu_kernel.cpp +++ b/src/Cafe/IOSU/kernel/iosu_kernel.cpp @@ -1,6 +1,8 @@ #include "iosu_kernel.h" #include "util/helpers/fspinlock.h" +#include "util/helpers/helpers.h" #include "Cafe/OS/libs/coreinit/coreinit_IPC.h" +#include "util/highresolutiontimer/HighResolutionTimer.h" namespace iosu { @@ -8,6 +10,9 @@ namespace iosu { std::mutex sInternalMutex; + void IOS_DestroyResourceManagerForQueueId(IOSMsgQueueId msgQueueId); + void _IPCDestroyAllHandlesForMsgQueue(IOSMsgQueueId msgQueueId); + static void _assume_lock() { #ifdef CEMU_DEBUG_ASSERT @@ -84,6 +89,19 @@ namespace iosu return queueHandle; } + IOS_ERROR IOS_DestroyMessageQueue(IOSMsgQueueId msgQueueId) + { + std::unique_lock _l(sInternalMutex); + IOSMessageQueue* msgQueue = nullptr; + IOS_ERROR r = _IOS_GetMessageQueue(msgQueueId, msgQueue); + if (r != IOS_ERROR_OK) + return r; + msgQueue->msgArraySize = 0; + msgQueue->queueHandle = 0; + IOS_DestroyResourceManagerForQueueId(msgQueueId); + return IOS_ERROR_OK; + } + IOS_ERROR IOS_SendMessage(IOSMsgQueueId msgQueueId, IOSMessage message, uint32 flags) { std::unique_lock _l(sInternalMutex); @@ -146,6 +164,133 @@ namespace iosu return IOS_ERROR_OK; } + /* timer */ + + std::mutex sTimerMutex; + std::condition_variable sTimerCV; + std::atomic_bool sTimerThreadStop; + + struct IOSTimer + { + IOSMsgQueueId queueId; + uint32 message; + HRTick nextFire; + HRTick repeat; + bool isValid; + }; + + std::vector sTimers; + std::vector sTimersFreeHandles; + + auto sTimerSortComparator = [](const IOSTimerId& idA, const IOSTimerId& idB) + { + // order by nextFire, then by timerId to avoid duplicate keys + IOSTimer& timerA = sTimers[idA]; + IOSTimer& timerB = sTimers[idB]; + if (timerA.nextFire != timerB.nextFire) + return timerA.nextFire < timerB.nextFire; + return idA < idB; + }; + std::set sTimerByFireTime; + + IOSTimer& IOS_GetFreeTimer() + { + cemu_assert_debug(!sTimerMutex.try_lock()); // lock must be held by current thread + if (sTimersFreeHandles.empty()) + return sTimers.emplace_back(); + IOSTimerId timerId = sTimersFreeHandles.back(); + sTimersFreeHandles.pop_back(); + return sTimers[timerId]; + } + + void IOS_TimerSetNextFireTime(IOSTimer& timer, HRTick nextFire) + { + cemu_assert_debug(!sTimerMutex.try_lock()); // lock must be held by current thread + IOSTimerId timerId = &timer - sTimers.data(); + auto it = sTimerByFireTime.find(timerId); + if(it != sTimerByFireTime.end()) + sTimerByFireTime.erase(it); + timer.nextFire = nextFire; + if(nextFire != 0) + sTimerByFireTime.insert(timerId); + } + + void IOS_StopTimerInternal(IOSTimerId timerId) + { + cemu_assert_debug(!sTimerMutex.try_lock()); + IOS_TimerSetNextFireTime(sTimers[timerId], 0); + } + + IOS_ERROR IOS_CreateTimer(uint32 startMicroseconds, uint32 repeatMicroseconds, uint32 queueId, uint32 message) + { + std::unique_lock _l(sTimerMutex); + IOSTimer& timer = IOS_GetFreeTimer(); + timer.queueId = queueId; + timer.message = message; + HRTick nextFire = HighResolutionTimer::now().getTick() + HighResolutionTimer::microsecondsToTicks(startMicroseconds); + timer.repeat = HighResolutionTimer::microsecondsToTicks(repeatMicroseconds); + IOS_TimerSetNextFireTime(timer, nextFire); + timer.isValid = true; + sTimerCV.notify_one(); + return (IOS_ERROR)(&timer - sTimers.data()); + } + + IOS_ERROR IOS_StopTimer(IOSTimerId timerId) + { + std::unique_lock _l(sTimerMutex); + if (timerId >= sTimers.size() || !sTimers[timerId].isValid) + return IOS_ERROR_INVALID; + IOS_StopTimerInternal(timerId); + return IOS_ERROR_OK; + } + + IOS_ERROR IOS_DestroyTimer(IOSTimerId timerId) + { + std::unique_lock _l(sTimerMutex); + if (timerId >= sTimers.size() || !sTimers[timerId].isValid) + return IOS_ERROR_INVALID; + IOS_StopTimerInternal(timerId); + sTimers[timerId].isValid = false; + sTimersFreeHandles.push_back(timerId); + return IOS_ERROR_OK; + } + + void IOSTimerThread() + { + SetThreadName("IOS-Timer"); + std::unique_lock _l(sTimerMutex); + while (!sTimerThreadStop) + { + if (sTimerByFireTime.empty()) + { + sTimerCV.wait_for(_l, std::chrono::milliseconds(10000)); + continue; + } + IOSTimerId timerId = *sTimerByFireTime.begin(); + IOSTimer& timer = sTimers[timerId]; + HRTick now = HighResolutionTimer::now().getTick(); + if (now >= timer.nextFire) + { + if(timer.repeat == 0) + IOS_TimerSetNextFireTime(timer, 0); + else + IOS_TimerSetNextFireTime(timer, timer.nextFire + timer.repeat); + IOSMsgQueueId queueId = timer.queueId; + uint32 message = timer.message; + // fire timer + _l.unlock(); + IOSMessage msg; + IOS_SendMessage(queueId, message, 1); + _l.lock(); + continue; + } + else + { + sTimerCV.wait_for(_l, std::chrono::microseconds(HighResolutionTimer::ticksToMicroseconds(timer.nextFire - now))); + } + } + } + /* devices and IPC */ struct IOSResourceManager @@ -209,6 +354,23 @@ namespace iosu return IOS_ERROR_OK; } + void IOS_DestroyResourceManagerForQueueId(IOSMsgQueueId msgQueueId) + { + _assume_lock(); + // destroy all IPC handles associated with this queue + _IPCDestroyAllHandlesForMsgQueue(msgQueueId); + // destroy device resource manager + for (auto& it : sDeviceResources) + { + if (it.isSet && it.msgQueueId == msgQueueId) + { + it.isSet = false; + it.path.clear(); + it.msgQueueId = 0; + } + } + } + IOS_ERROR IOS_DeviceAssociateId(const char* devicePath, uint32 id) { // not yet implemented @@ -344,6 +506,22 @@ namespace iosu return IOS_ERROR_OK; } + void _IPCDestroyAllHandlesForMsgQueue(IOSMsgQueueId msgQueueId) + { + _assume_lock(); + for (auto& it : sActiveDeviceHandles) + { + if (it.isSet && it.msgQueueId == msgQueueId) + { + it.isSet = false; + it.path.clear(); + it.handleCheckValue = 0; + it.hasDispatchTargetHandle = false; + it.msgQueueId = 0; + } + } + } + IOS_ERROR _IPCAssignDispatchTargetHandle(IOSDevHandle devHandle, IOSDevHandle internalHandle) { std::unique_lock _lock(sInternalMutex); @@ -453,7 +631,6 @@ namespace iosu uint32 numIn = dispatchCmd->body.args[1]; uint32 numOut = dispatchCmd->body.args[2]; IPCIoctlVector* vec = MEMPTR(cmd.args[3]).GetPtr(); - // copy the vector array uint32 numVec = numIn + numOut; if (numVec <= 8) @@ -466,8 +643,23 @@ namespace iosu // reuse the original vector pointer cemuLog_log(LogType::Force, "Info: Ioctlv command with more than 8 vectors"); } - IOS_ERROR r = _IPCDispatchToResourceManager(dispatchCmd->body.devHandle, dispatchCmd); - return r; + return _IPCDispatchToResourceManager(dispatchCmd->body.devHandle, dispatchCmd); + } + + // normally COS kernel handles this, but currently we skip the IPC getting proxied through it + IOS_ERROR _IPCHandlerIn_TranslateVectorAddresses(IOSDispatchableCommand* dispatchCmd) + { + uint32 numIn = dispatchCmd->body.args[1]; + uint32 numOut = dispatchCmd->body.args[2]; + IPCIoctlVector* vec = MEMPTR(dispatchCmd->body.args[3]).GetPtr(); + for (uint32 i = 0; i < numIn + numOut; i++) + { + if (vec[i].baseVirt == nullptr && vec[i].size != 0) + return IOS_ERROR_INVALID; + // todo - check for valid pointer range + vec[i].basePhys = vec[i].baseVirt; + } + return IOS_ERROR_OK; } // called by COS directly @@ -494,7 +686,11 @@ namespace iosu r = _IPCHandlerIn_IOS_Ioctl(dispatchCmd); break; case IPCCommandId::IOS_IOCTLV: - r = _IPCHandlerIn_IOS_Ioctlv(dispatchCmd); + r = _IPCHandlerIn_TranslateVectorAddresses(dispatchCmd); + if(r < 0) + cemuLog_log(LogType::Force, "Ioctlv error"); + else + r = _IPCHandlerIn_IOS_Ioctlv(dispatchCmd); break; default: cemuLog_log(LogType::Force, "Invalid IPC command {}", (uint32)(IPCCommandId)cmd->cmdId); @@ -547,10 +743,34 @@ namespace iosu return IOS_ERROR_OK; } - void Initialize() + class : public ::IOSUModule { - _IPCInitDispatchablePool(); + void SystemLaunch() override + { + _IPCInitDispatchablePool(); + // start timer thread + sTimerThreadStop = false; + m_timerThread = std::thread(IOSTimerThread); + } + + void SystemExit() override + { + // stop timer thread + sTimerThreadStop = true; + sTimerCV.notify_one(); + m_timerThread.join(); + // reset resources + // todo + } + + std::thread m_timerThread; + }sIOSUModuleKernel; + + IOSUModule* GetModule() + { + return static_cast(&sIOSUModuleKernel); } + } } \ No newline at end of file diff --git a/src/Cafe/IOSU/kernel/iosu_kernel.h b/src/Cafe/IOSU/kernel/iosu_kernel.h index 2b82374e..0355c118 100644 --- a/src/Cafe/IOSU/kernel/iosu_kernel.h +++ b/src/Cafe/IOSU/kernel/iosu_kernel.h @@ -9,15 +9,20 @@ namespace iosu using IOSMessage = uint32; IOSMsgQueueId IOS_CreateMessageQueue(IOSMessage* messageArray, uint32 messageCount); + IOS_ERROR IOS_DestroyMessageQueue(IOSMsgQueueId msgQueueId); IOS_ERROR IOS_SendMessage(IOSMsgQueueId msgQueueId, IOSMessage message, uint32 flags); IOS_ERROR IOS_ReceiveMessage(IOSMsgQueueId msgQueueId, IOSMessage* messageOut, uint32 flags); + IOS_ERROR IOS_CreateTimer(uint32 startMicroseconds, uint32 repeatMicroseconds, uint32 queueId, uint32 message); + IOS_ERROR IOS_StopTimer(IOSTimerId timerId); + IOS_ERROR IOS_DestroyTimer(IOSTimerId timerId); + IOS_ERROR IOS_RegisterResourceManager(const char* devicePath, IOSMsgQueueId msgQueueId); IOS_ERROR IOS_DeviceAssociateId(const char* devicePath, uint32 id); IOS_ERROR IOS_ResourceReply(IPCCommandBody* cmd, IOS_ERROR result); void IPCSubmitFromCOS(uint32 ppcCoreIndex, IPCCommandBody* cmd); - void Initialize(); + IOSUModule* GetModule(); } } \ No newline at end of file diff --git a/src/Cafe/IOSU/legacy/iosu_act.cpp b/src/Cafe/IOSU/legacy/iosu_act.cpp index e7418e8f..ed3a69bd 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.cpp +++ b/src/Cafe/IOSU/legacy/iosu_act.cpp @@ -192,6 +192,15 @@ namespace iosu return true; } + // returns empty string if invalid + std::string getAccountId2(uint8 slot) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + return {}; + return {_actAccountData[accountIndex].accountId}; + } + bool getMii(uint8 slot, FFLData_t* fflData) { sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); diff --git a/src/Cafe/IOSU/legacy/iosu_act.h b/src/Cafe/IOSU/legacy/iosu_act.h index 04dd579f..5336f519 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.h +++ b/src/Cafe/IOSU/legacy/iosu_act.h @@ -3,6 +3,8 @@ void iosuAct_init_depr(); bool iosuAct_isInitialized(); +#define ACT_ACCOUNTID_LENGTH (17) // includes '\0' + // Mii #define MII_FFL_STORAGE_SIZE (96) @@ -48,6 +50,8 @@ namespace iosu bool getScreenname(uint8 slot, uint16 screenname[ACT_NICKNAME_LENGTH]); bool getCountryIndex(uint8 slot, uint32* countryIndex); + std::string getAccountId2(uint8 slot); + const uint8 ACT_SLOT_CURRENT = 0xFE; void Initialize(); diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index 4457d602..75bf0463 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -1,4 +1,3 @@ -#include "iosu_ioctl.h" #include "iosu_act.h" #include "iosu_fpd.h" #include "Cemu/nex/nex.h" @@ -9,12 +8,10 @@ #include "config/ActiveSettings.h" #include "Cemu/napi/napi.h" #include "util/helpers/StringHelpers.h" -#include "Cafe/OS/libs/coreinit/coreinit.h" +#include "Cafe/IOSU/iosu_types_common.h" +#include "Cafe/IOSU/nn/iosu_nn_service.h" -uint32 memory_getVirtualOffsetFromPointer(void* ptr); // remove once we updated everything to MEMPTR - -SysAllocator _fpdAsyncLoginRetCode; -SysAllocator _fpdAsyncAddFriendRetCode; +#include "Common/CafeString.h" std::mutex g_friend_notification_mutex; std::vector< std::pair > g_friend_notifications; @@ -23,78 +20,114 @@ namespace iosu { namespace fpd { + using NotificationRunningId = uint64; + + struct NotificationEntry + { + NotificationEntry(uint64 index, NexFriends::NOTIFICATION_TYPE type, uint32 pid) : timestamp(std::chrono::steady_clock::now()), runningId(index), type(type), pid(pid) {} + std::chrono::steady_clock::time_point timestamp; + NotificationRunningId runningId; + NexFriends::NOTIFICATION_TYPE type; + uint32 pid; + }; + + class + { + public: + void TrackNotification(NexFriends::NOTIFICATION_TYPE type, uint32 pid) + { + std::unique_lock _l(m_mtxNotificationQueue); + m_notificationQueue.emplace_back(m_notificationQueueIndex++, type, pid); + } + + void RemoveExpired() + { + // remove entries older than 10 seconds + std::chrono::steady_clock::time_point expireTime = std::chrono::steady_clock::now() - std::chrono::seconds(10); + std::erase_if(m_notificationQueue, [expireTime](const auto& notification) { + return notification.timestamp < expireTime; + }); + } + + std::optional GetNextNotification(NotificationRunningId& previousRunningId) + { + std::unique_lock _l(m_mtxNotificationQueue); + auto it = std::lower_bound(m_notificationQueue.begin(), m_notificationQueue.end(), previousRunningId, [](const auto& notification, const auto& runningId) { + return notification.runningId <= runningId; + }); + size_t itIndex = it - m_notificationQueue.begin(); + if(it == m_notificationQueue.end()) + return std::nullopt; + previousRunningId = it->runningId; + return *it; + } + + private: + std::vector m_notificationQueue; + std::mutex m_mtxNotificationQueue; + std::atomic_uint64_t m_notificationQueueIndex{1}; + }g_NotificationQueue; struct { bool isThreadStarted; bool isInitialized2; NexFriends* nexFriendSession; - // notification handler - MPTR notificationFunc; - MPTR notificationCustomParam; - uint32 notificationMask; - // login callback - struct - { - MPTR func; - MPTR customParam; - }asyncLoginCallback; + std::mutex mtxFriendSession; + // session state + std::atomic_bool sessionStarted{false}; // current state nexPresenceV2 myPresence; }g_fpd = {}; - void notificationHandler(NexFriends::NOTIFICATION_TYPE type, uint32 pid) + void OverlayNotificationHandler(NexFriends::NOTIFICATION_TYPE type, uint32 pid) { cemuLog_logDebug(LogType::Force, "Friends::Notification {:02x} pid {:08x}", type, pid); - if(GetConfig().notification.friends) + if(!GetConfig().notification.friends) + return; + std::unique_lock lock(g_friend_notification_mutex); + std::string message; + if(type == NexFriends::NOTIFICATION_TYPE::NOTIFICATION_TYPE_ONLINE) { - std::unique_lock lock(g_friend_notification_mutex); - std::string message; - if(type == NexFriends::NOTIFICATION_TYPE::NOTIFICATION_TYPE_ONLINE) + g_friend_notifications.emplace_back("Connected to friend service", 5000); + if(g_fpd.nexFriendSession && g_fpd.nexFriendSession->getPendingFriendRequestCount() > 0) + g_friend_notifications.emplace_back(fmt::format("You have {} pending friend request(s)", g_fpd.nexFriendSession->getPendingFriendRequestCount()), 5000); + } + else + { + std::string msg_format; + switch(type) { - g_friend_notifications.emplace_back("Connected to friend service", 5000); - if(g_fpd.nexFriendSession && g_fpd.nexFriendSession->getPendingFriendRequestCount() > 0) - g_friend_notifications.emplace_back(fmt::format("You have {} pending friend request(s)", g_fpd.nexFriendSession->getPendingFriendRequestCount()), 5000); + case NexFriends::NOTIFICATION_TYPE_ONLINE: break; + case NexFriends::NOTIFICATION_TYPE_FRIEND_LOGIN: msg_format = "{} is now online"; break; + case NexFriends::NOTIFICATION_TYPE_FRIEND_LOGOFF: msg_format = "{} is now offline"; break; + case NexFriends::NOTIFICATION_TYPE_FRIEND_PRESENCE_CHANGE: break; + case NexFriends::NOTIFICATION_TYPE_ADDED_FRIEND: msg_format = "{} has been added to your friend list"; break; + case NexFriends::NOTIFICATION_TYPE_REMOVED_FRIEND: msg_format = "{} has been removed from your friend list"; break; + case NexFriends::NOTIFICATION_TYPE_ADDED_OUTGOING_REQUEST: break; + case NexFriends::NOTIFICATION_TYPE_REMOVED_OUTGOING_REQUEST: break; + case NexFriends::NOTIFICATION_TYPE_ADDED_INCOMING_REQUEST: msg_format = "{} wants to add you to his friend list"; break; + case NexFriends::NOTIFICATION_TYPE_REMOVED_INCOMING_REQUEST: break; + default: ; } - else + if (!msg_format.empty()) { - std::string msg_format; - switch(type) + std::string name = fmt::format("{:#x}", pid); + if (g_fpd.nexFriendSession) { - case NexFriends::NOTIFICATION_TYPE_ONLINE: break; - case NexFriends::NOTIFICATION_TYPE_FRIEND_LOGIN: msg_format = "{} is now online"; break; - case NexFriends::NOTIFICATION_TYPE_FRIEND_LOGOFF: msg_format = "{} is now offline"; break; - case NexFriends::NOTIFICATION_TYPE_FRIEND_PRESENCE_CHANGE: break; - case NexFriends::NOTIFICATION_TYPE_ADDED_FRIEND: msg_format = "{} has been added to your friend list"; break; - case NexFriends::NOTIFICATION_TYPE_REMOVED_FRIEND: msg_format = "{} has been removed from your friend list"; break; - case NexFriends::NOTIFICATION_TYPE_ADDED_OUTGOING_REQUEST: break; - case NexFriends::NOTIFICATION_TYPE_REMOVED_OUTGOING_REQUEST: break; - case NexFriends::NOTIFICATION_TYPE_ADDED_INCOMING_REQUEST: msg_format = "{} wants to add you to his friend list"; break; - case NexFriends::NOTIFICATION_TYPE_REMOVED_INCOMING_REQUEST: break; - default: ; - } - - if (!msg_format.empty()) - { - std::string name = fmt::format("{:#x}", pid); - if (g_fpd.nexFriendSession) - { - const std::string tmp = g_fpd.nexFriendSession->getAccountNameByPid(pid); - if (!tmp.empty()) - name = tmp; - } - - g_friend_notifications.emplace_back(fmt::format(fmt::runtime(msg_format), name), 5000); + const std::string tmp = g_fpd.nexFriendSession->getAccountNameByPid(pid); + if (!tmp.empty()) + name = tmp; } + g_friend_notifications.emplace_back(fmt::format(fmt::runtime(msg_format), name), 5000); } } + } - if (g_fpd.notificationFunc == MPTR_NULL) - return; - uint32 notificationFlag = 1 << (type - 1); - if ( (notificationFlag&g_fpd.notificationMask) == 0 ) - return; - coreinitAsyncCallback_add(g_fpd.notificationFunc, 3, type, pid, g_fpd.notificationCustomParam); + void NotificationHandler(NexFriends::NOTIFICATION_TYPE type, uint32 pid) + { + OverlayNotificationHandler(type, pid); + g_NotificationQueue.TrackNotification(type, pid); } void convertMultiByteStringToBigEndianWidechar(const char* input, uint16be* output, sint32 maxOutputLength) @@ -107,7 +140,7 @@ namespace iosu output[beStr.size()] = '\0'; } - void convertFPDTimestampToDate(uint64 timestamp, fpdDate_t* fpdDate) + void convertFPDTimestampToDate(uint64 timestamp, FPDDate* fpdDate) { // if the timestamp is zero then still return a valid date if (timestamp == 0) @@ -128,7 +161,7 @@ namespace iosu fpdDate->year = (uint16)((timestamp >> 26)); } - uint64 convertDateToFPDTimestamp(fpdDate_t* fpdDate) + uint64 convertDateToFPDTimestamp(FPDDate* fpdDate) { uint64 t = 0; t |= (uint64)fpdDate->second; @@ -140,111 +173,33 @@ namespace iosu return t; } - void startFriendSession() + void NexPresenceToGameMode(nexPresenceV2* presence, GameMode* gameMode) { - cemu_assert(!g_fpd.nexFriendSession); - - NAPI::AuthInfo authInfo; - NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); - NAPI::ACTGetNexTokenResult nexTokenResult = NAPI::ACT_GetNexToken_WithCache(authInfo, 0x0005001010001C00, 0x0000, 0x00003200); - if (nexTokenResult.isValid()) - { - // get values needed for friend session - uint32 myPid; - uint8 currentSlot = iosu::act::getCurrentAccountSlot(); - iosu::act::getPrincipalId(currentSlot, &myPid); - char accountId[256] = { 0 }; - iosu::act::getAccountId(currentSlot, accountId); - FFLData_t miiData; - act::getMii(currentSlot, &miiData); - uint16 screenName[ACT_NICKNAME_LENGTH + 1] = { 0 }; - act::getScreenname(currentSlot, screenName); - uint32 countryCode = 0; - act::getCountryIndex(currentSlot, &countryCode); - // init presence - g_fpd.myPresence.isOnline = 1; - g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); - g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); - - // Resolve potential domain to IP address - struct addrinfo hints = {0}, *addrs; - hints.ai_family = AF_INET; - - const int status = getaddrinfo(nexTokenResult.nexToken.host, NULL, &hints, &addrs); - if (status != 0) { -#if BOOST_OS_WINDOWS - cemuLog_log(LogType::Force, "IOSU_FPD: Failed to resolve hostname {}, {}", nexTokenResult.nexToken.host, gai_strerrorA(status)); -#else - cemuLog_log(LogType::Force, "IOSU_FPD: Failed to resolve hostname {}, {}", nexTokenResult.nexToken.host, gai_strerror(status)); -#endif - return; - } - - char addrstr[NI_MAXHOST]; - getnameinfo(addrs->ai_addr, addrs->ai_addrlen, addrstr, sizeof addrstr, NULL, 0, NI_NUMERICHOST); - cemuLog_log(LogType::Force, "IOSU_FPD: Resolved IP for hostname {}, {}", nexTokenResult.nexToken.host, addrstr); - - // start session - const uint32_t hostIp = ((struct sockaddr_in*)addrs->ai_addr)->sin_addr.s_addr; - freeaddrinfo(addrs); - g_fpd.nexFriendSession = new NexFriends(hostIp, nexTokenResult.nexToken.port, "ridfebb9", myPid, nexTokenResult.nexToken.nexPassword, nexTokenResult.nexToken.token, accountId, (uint8*)&miiData, (wchar_t*)screenName, (uint8)countryCode, g_fpd.myPresence); - g_fpd.nexFriendSession->setNotificationHandler(notificationHandler); - cemuLog_log(LogType::Force, "IOSU_FPD: Created friend server session"); - } - else - { - cemuLog_logDebug(LogType::Force, "IOSU_FPD: Failed to acquire nex token for friend server"); - } + memset(gameMode, 0, sizeof(GameMode)); + gameMode->joinFlagMask = presence->joinFlagMask; + gameMode->matchmakeType = presence->joinAvailability; + gameMode->joinGameId = presence->gameId; + gameMode->joinGameMode = presence->gameMode; + gameMode->hostPid = presence->hostPid; + gameMode->groupId = presence->groupId; + memcpy(gameMode->appSpecificData, presence->appSpecificData, 0x14); } - void handleRequest_GetFriendList(iosuFpdCemuRequest_t* fpdCemuRequest, bool getAll) + void GameModeToNexPresence(GameMode* gameMode, nexPresenceV2* presence) { - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0; - fpdCemuRequest->resultU32.u32 = 0; // zero entries returned - return; - } - - uint32 temporaryPidList[800]; - uint32 pidCount = 0; - g_fpd.nexFriendSession->getFriendPIDs(temporaryPidList, &pidCount, fpdCemuRequest->getFriendList.startIndex, std::min(sizeof(temporaryPidList) / sizeof(temporaryPidList[0]), fpdCemuRequest->getFriendList.maxCount), getAll); - uint32be* pidListOutput = fpdCemuRequest->getFriendList.pidList.GetPtr(); - if (pidListOutput) - { - for (uint32 i = 0; i < pidCount; i++) - pidListOutput[i] = temporaryPidList[i]; - } - fpdCemuRequest->returnCode = 0; - fpdCemuRequest->resultU32.u32 = pidCount; + memset(presence, 0, sizeof(nexPresenceV2)); + presence->joinFlagMask = gameMode->joinFlagMask; + presence->joinAvailability = (uint8)(uint32)gameMode->matchmakeType; + presence->gameId = gameMode->joinGameId; + presence->gameMode = gameMode->joinGameMode; + presence->hostPid = gameMode->hostPid; + presence->groupId = gameMode->groupId; + memcpy(presence->appSpecificData, gameMode->appSpecificData, 0x14); } - void handleRequest_GetFriendRequestList(iosuFpdCemuRequest_t* fpdCemuRequest) + void NexFriendToFPDFriendData(FriendData* friendData, nexFriend* frd) { - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0; - fpdCemuRequest->resultU32.u32 = 0; // zero entries returned - return; - } - - uint32 temporaryPidList[800]; - uint32 pidCount = 0; - // get only incoming friend requests - g_fpd.nexFriendSession->getFriendRequestPIDs(temporaryPidList, &pidCount, fpdCemuRequest->getFriendList.startIndex, std::min(sizeof(temporaryPidList) / sizeof(temporaryPidList[0]), fpdCemuRequest->getFriendList.maxCount), true, false); - uint32be* pidListOutput = fpdCemuRequest->getFriendList.pidList.GetPtr(); - if (pidListOutput) - { - for (uint32 i = 0; i < pidCount; i++) - pidListOutput[i] = temporaryPidList[i]; - } - fpdCemuRequest->returnCode = 0; - fpdCemuRequest->resultU32.u32 = pidCount; - } - - void setFriendDataFromNexFriend(friendData_t* friendData, nexFriend* frd) - { - memset(friendData, 0, sizeof(friendData_t)); + memset(friendData, 0, sizeof(FriendData)); // setup friend data friendData->type = 1; // friend friendData->pid = frd->nnaInfo.principalInfo.principalId; @@ -253,13 +208,11 @@ namespace iosu // screenname convertMultiByteStringToBigEndianWidechar(frd->nnaInfo.principalInfo.mii.miiNickname, friendData->screenname, sizeof(friendData->screenname) / sizeof(uint16be)); - //friendData->friendExtraData.ukn0E4 = 0; friendData->friendExtraData.isOnline = frd->presence.isOnline != 0 ? 1 : 0; - friendData->friendExtraData.gameKeyTitleId = _swapEndianU64(frd->presence.gameKey.titleId); - friendData->friendExtraData.gameKeyUkn = frd->presence.gameKey.ukn; - - friendData->friendExtraData.statusMessage[0] = '\0'; + friendData->friendExtraData.gameKey.titleId = frd->presence.gameKey.titleId; + friendData->friendExtraData.gameKey.ukn08 = frd->presence.gameKey.ukn; + NexPresenceToGameMode(&frd->presence, &friendData->friendExtraData.gameMode); // set valid dates friendData->uknDate.year = 2018; @@ -269,19 +222,19 @@ namespace iosu friendData->uknDate.minute = 1; friendData->uknDate.second = 1; - friendData->friendExtraData.uknDate218.year = 2018; - friendData->friendExtraData.uknDate218.day = 1; - friendData->friendExtraData.uknDate218.month = 1; - friendData->friendExtraData.uknDate218.hour = 1; - friendData->friendExtraData.uknDate218.minute = 1; - friendData->friendExtraData.uknDate218.second = 1; + friendData->friendExtraData.approvalTime.year = 2018; + friendData->friendExtraData.approvalTime.day = 1; + friendData->friendExtraData.approvalTime.month = 1; + friendData->friendExtraData.approvalTime.hour = 1; + friendData->friendExtraData.approvalTime.minute = 1; + friendData->friendExtraData.approvalTime.second = 1; convertFPDTimestampToDate(frd->lastOnlineTimestamp, &friendData->friendExtraData.lastOnline); } - void setFriendDataFromNexFriendRequest(friendData_t* friendData, nexFriendRequest* frdReq, bool isIncoming) + void NexFriendRequestToFPDFriendData(FriendData* friendData, nexFriendRequest* frdReq, bool isIncoming) { - memset(friendData, 0, sizeof(friendData_t)); + memset(friendData, 0, sizeof(FriendData)); // setup friend data friendData->type = 0; // friend request friendData->pid = frdReq->principalInfo.principalId; @@ -292,7 +245,7 @@ namespace iosu convertMultiByteStringToBigEndianWidechar(frdReq->message.commentStr.c_str(), friendData->requestExtraData.comment, sizeof(friendData->requestExtraData.comment) / sizeof(uint16be)); - fpdDate_t expireDate; + FPDDate expireDate; convertFPDTimestampToDate(frdReq->message.expireTimestamp, &expireDate); bool isProvisional = frdReq->message.expireTimestamp == 0; @@ -301,10 +254,7 @@ namespace iosu //friendData->requestExtraData.ukn0A0 = 0; // if not set -> provisional friend request //friendData->requestExtraData.ukn0A4 = isProvisional ? 0 : 123; // no change? - friendData->requestExtraData.messageId = _swapEndianU64(frdReq->message.messageId); - - - //find the value for 'markedAsReceived' + friendData->requestExtraData.messageId = frdReq->message.messageId; ///* +0x0A8 */ uint8 ukn0A8; ///* +0x0A9 */ uint8 ukn0A9; // comment language? (guessed) @@ -332,9 +282,9 @@ namespace iosu convertFPDTimestampToDate(frdReq->message.expireTimestamp, &friendData->requestExtraData.uknData1); } - void setFriendRequestFromNexFriendRequest(friendRequest_t* friendRequest, nexFriendRequest* frdReq, bool isIncoming) + void NexFriendRequestToFPDFriendRequest(FriendRequest* friendRequest, nexFriendRequest* frdReq, bool isIncoming) { - memset(friendRequest, 0, sizeof(friendRequest_t)); + memset(friendRequest, 0, sizeof(FriendRequest)); friendRequest->pid = frdReq->principalInfo.principalId; @@ -355,715 +305,1170 @@ namespace iosu convertFPDTimestampToDate(frdReq->message.expireTimestamp, &friendRequest->expireDate); } - void handleRequest_GetFriendListEx(iosuFpdCemuRequest_t* fpdCemuRequest) + struct FPProfile { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - for (uint32 i = 0; i < fpdCemuRequest->getFriendListEx.count; i++) - { - uint32 pid = fpdCemuRequest->getFriendListEx.pidList[i]; - friendData_t* friendData = fpdCemuRequest->getFriendListEx.friendData.GetPtr() + i; - nexFriend frd; - nexFriendRequest frdReq; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - setFriendDataFromNexFriend(friendData, &frd); - continue; - } - bool incoming = false; - if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) - { - setFriendDataFromNexFriendRequest(friendData, &frdReq, incoming); - continue; - } - fpdCemuRequest->returnCode = 0x80000000; - return; - } - } + uint8be country; + uint8be area; + uint16be unused; + }; + static_assert(sizeof(FPProfile) == 4); - void handleRequest_GetFriendRequestListEx(iosuFpdCemuRequest_t* fpdCemuRequest) + struct SelfPresence { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) + uint8be ukn[0x130]; // todo + }; + static_assert(sizeof(SelfPresence) == 0x130); + + struct SelfPlayingGame + { + uint8be ukn0[0x10]; + }; + static_assert(sizeof(SelfPlayingGame) == 0x10); + + static const auto FPResult_Ok = 0; + static const auto FPResult_InvalidIPCParam = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_FP, 0x680); + static const auto FPResult_RequestFailed = BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // figure out proper error code + + class FPDService : public iosu::nn::IPCSimpleService + { + + struct NotificationAsyncRequest { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - for (uint32 i = 0; i < fpdCemuRequest->getFriendRequestListEx.count; i++) - { - uint32 pid = fpdCemuRequest->getFriendListEx.pidList[i]; - friendRequest_t* friendRequest = fpdCemuRequest->getFriendRequestListEx.friendRequest.GetPtr() + i; - nexFriendRequest frdReq; - bool incoming = false; - if (!g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + NotificationAsyncRequest(IPCCommandBody* cmd, uint32 maxNumEntries, FPDNotification* notificationsOut, uint32be* countOut) + : cmd(cmd), maxNumEntries(maxNumEntries), notificationsOut(notificationsOut), countOut(countOut) { - cemuLog_log(LogType::Force, "Failed to get friend request"); - fpdCemuRequest->returnCode = 0x80000000; + } + + IPCCommandBody* cmd; + uint32 maxNumEntries; + FPDNotification* notificationsOut; + uint32be* countOut; + }; + + struct FPDClient + { + bool hasLoggedIn{false}; + uint32 notificationMask{0}; + NotificationRunningId prevRunningId{0}; + std::vector notificationRequests; + }; + + // storage for async IPC requests + std::vector m_asyncLoginRequests; + std::vector m_clients; + + public: + FPDService() : iosu::nn::IPCSimpleService("/dev/fpd") {} + + std::string GetThreadName() override + { + return "IOSUModule::FPD"; + } + + void StartService() override + { + cemu_assert_debug(m_asyncLoginRequests.empty()); + } + + void StopService() override + { + m_asyncLoginRequests.clear(); + for(auto& it : m_clients) + delete it; + m_clients.clear(); + } + + void* CreateClientObject() override + { + FPDClient* client = new FPDClient(); + m_clients.push_back(client); + return client; + } + + void DestroyClientObject(void* clientObject) override + { + FPDClient* client = (FPDClient*)clientObject; + std::erase(m_clients, client); + delete client; + } + + void SendQueuedNotifications(FPDClient* client) + { + if (client->notificationRequests.empty()) return; + if (client->notificationRequests.size() > 1) + cemuLog_log(LogType::Force, "FPD: More than one simultanous notification query not supported"); + NotificationAsyncRequest& request = client->notificationRequests[0]; + uint32 numNotifications = 0; + while(numNotifications < request.maxNumEntries) + { + auto notification = g_NotificationQueue.GetNextNotification(client->prevRunningId); + if (!notification) + break; + uint32 flag = 1 << static_cast(notification->type); + if((client->notificationMask & flag) == 0) + continue; + request.notificationsOut[numNotifications].type = static_cast(notification->type); + request.notificationsOut[numNotifications].pid = notification->pid; + numNotifications++; } - setFriendRequestFromNexFriendRequest(friendRequest, &frdReq, incoming); - } - } - - typedef struct - { - MPTR funcMPTR; - MPTR customParam; - }fpAsyncCallback_t; - - typedef struct - { - nexPrincipalBasicInfo* principalBasicInfo; - uint32* pidList; - sint32 count; - friendBasicInfo_t* friendBasicInfo; - fpAsyncCallback_t fpCallback; - }getBasicInfoAsyncParams_t; - - SysAllocator _fpCallbackResultArray; // use a ring buffer of results to avoid overwriting the result when multiple callbacks are queued at the same time - sint32 fpCallbackResultIndex = 0; - - void handleFPCallback(fpAsyncCallback_t* fpCallback, uint32 resultCode) - { - fpCallbackResultIndex = (fpCallbackResultIndex + 1) % 32; - uint32* resultPtr = _fpCallbackResultArray.GetPtr() + fpCallbackResultIndex; - - *resultPtr = resultCode; - - coreinitAsyncCallback_add(fpCallback->funcMPTR, 2, memory_getVirtualOffsetFromPointer(resultPtr), fpCallback->customParam); - } - - void handleFPCallback2(MPTR funcMPTR, MPTR custom, uint32 resultCode) - { - fpCallbackResultIndex = (fpCallbackResultIndex + 1) % 32; - uint32* resultPtr = _fpCallbackResultArray.GetPtr() + fpCallbackResultIndex; - - *resultPtr = resultCode; - - coreinitAsyncCallback_add(funcMPTR, 2, memory_getVirtualOffsetFromPointer(resultPtr), custom); - } - - void handleResultCB_GetBasicInfoAsync(NexFriends* nexFriends, uint32 result, void* custom) - { - getBasicInfoAsyncParams_t* cbInfo = (getBasicInfoAsyncParams_t*)custom; - if (result != 0) - { - handleFPCallback(&cbInfo->fpCallback, 0x80000000); // todo - properly translate internal error to nn::fp error code - free(cbInfo->principalBasicInfo); - free(cbInfo->pidList); - free(cbInfo); - return; + if (numNotifications == 0) + return; + *request.countOut = numNotifications; + ServiceCallAsyncRespond(request.cmd, FPResult_Ok); + client->notificationRequests.erase(client->notificationRequests.begin()); } - // convert PrincipalBasicInfo into friendBasicInfo - for (sint32 i = 0; i < cbInfo->count; i++) + void TimerUpdate() override { - friendBasicInfo_t* basicInfo = cbInfo->friendBasicInfo + i; - nexPrincipalBasicInfo* principalBasicInfo = cbInfo->principalBasicInfo + i; + // called once a second while service is running + std::unique_lock _l(g_fpd.mtxFriendSession); + if (!g_fpd.nexFriendSession) + return; + g_fpd.nexFriendSession->update(); + while(!m_asyncLoginRequests.empty()) + { + if(g_fpd.nexFriendSession->isOnline()) + { + ServiceCallAsyncRespond(m_asyncLoginRequests.front(), FPResult_Ok); + m_asyncLoginRequests.erase(m_asyncLoginRequests.begin()); + } + else + break; + } + // handle notification responses + g_NotificationQueue.RemoveExpired(); + for(auto& client : m_clients) + SendQueuedNotifications(client); + } - memset(basicInfo, 0, sizeof(friendBasicInfo_t)); - basicInfo->pid = principalBasicInfo->principalId; - strcpy(basicInfo->nnid, principalBasicInfo->nnid); + uint32 ServiceCall(void* clientObject, uint32 requestId, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) override + { + // for /dev/fpd input and output vectors are swapped + std::swap(vecIn, vecOut); + std::swap(numVecIn, numVecOut); - convertMultiByteStringToBigEndianWidechar(principalBasicInfo->mii.miiNickname, basicInfo->screenname, sizeof(basicInfo->screenname) / sizeof(uint16be)); - memcpy(basicInfo->miiData, principalBasicInfo->mii.miiData, FFL_SIZE); + FPDClient* fpdClient = (FPDClient*)clientObject; + switch(static_cast(requestId)) + { + case FPD_REQUEST_ID::SetNotificationMask: + return CallHandler_SetNotificationMask(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetNotificationAsync: + return CallHandler_GetNotificationAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::SetLedEventMask: + cemuLog_logDebug(LogType::Force, "[/dev/fpd] SetLedEventMask is todo"); + return FPResult_Ok; + case FPD_REQUEST_ID::LoginAsync: + return CallHandler_LoginAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::HasLoggedIn: + return CallHandler_HasLoggedIn(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::IsOnline: + return CallHandler_IsOnline(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyPrincipalId: + return CallHandler_GetMyPrincipalId(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyAccountId: + return CallHandler_GetMyAccountId(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyScreenName: + return CallHandler_GetMyScreenName(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyMii: + return CallHandler_GetMyMii(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyProfile: + return CallHandler_GetMyProfile(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyPresence: + return CallHandler_GetMyPresence(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyComment: + return CallHandler_GetMyComment(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyPreference: + return CallHandler_GetMyPreference(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetMyPlayingGame: + return CallHandler_GetMyPlayingGame(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendAccountId: + return CallHandler_GetFriendAccountId(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendScreenName: + return CallHandler_GetFriendScreenName(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendMii: + return CallHandler_GetFriendMii(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendPresence: + return CallHandler_GetFriendPresence(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendRelationship: + return CallHandler_GetFriendRelationship(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendList: + return CallHandler_GetFriendList_GetFriendListAll(fpdClient, vecIn, numVecIn, vecOut, numVecOut, false); + case FPD_REQUEST_ID::GetFriendListAll: + return CallHandler_GetFriendList_GetFriendListAll(fpdClient, vecIn, numVecIn, vecOut, numVecOut, true); + case FPD_REQUEST_ID::GetFriendRequestList: + return CallHandler_GetFriendRequestList(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendRequestListEx: + return CallHandler_GetFriendRequestListEx(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetBlackList: + return CallHandler_GetBlackList(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetFriendListEx: + return CallHandler_GetFriendListEx(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::UpdatePreferenceAsync: + return CallHandler_UpdatePreferenceAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::AddFriendRequestByPlayRecordAsync: + return CallHandler_AddFriendRequestAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::AcceptFriendRequestAsync: + return CallHandler_AcceptFriendRequestAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::DeleteFriendRequestAsync: + return CallHandler_DeleteFriendRequestAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::CancelFriendRequestAsync: + return CallHandler_CancelFriendRequestAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::MarkFriendRequestsAsReceivedAsync: + return CallHandler_MarkFriendRequestsAsReceivedAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::RemoveFriendAsync: + return CallHandler_RemoveFriendAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::DeleteFriendFlagsAsync: + return CallHandler_DeleteFriendFlagsAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetBasicInfoAsync: + return CallHandler_GetBasicInfoAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::CheckSettingStatusAsync: + return CallHandler_CheckSettingStatusAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::IsPreferenceValid: + return CallHandler_IsPreferenceValid(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::GetRequestBlockSettingAsync: + return CallHandler_GetRequestBlockSettingAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::AddFriendAsyncByPid: + return CallHandler_AddFriendAsyncByPid(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::UpdateGameModeVariation1: + case FPD_REQUEST_ID::UpdateGameModeVariation2: + return CallHandler_UpdateGameMode(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + default: + cemuLog_log(LogType::Force, "Unsupported service call {} to /dev/fpd", requestId); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); + } + } - basicInfo->uknDate90.day = 1; - basicInfo->uknDate90.month = 1; - basicInfo->uknDate90.hour = 1; - basicInfo->uknDate90.minute = 1; - basicInfo->uknDate90.second = 1; + #define DeclareInputPtr(__Name, __T, __count, __vecIndex) if(sizeof(__T)*(__count) != vecIn[__vecIndex].size) { cemuLog_log(LogType::Force, "FPD: IPC buffer has incorrect size"); return FPResult_InvalidIPCParam;}; __T* __Name = ((__T*)vecIn[__vecIndex].basePhys.GetPtr()) + #define DeclareInput(__Name, __T, __vecIndex) if(sizeof(__T) != vecIn[__vecIndex].size) { cemuLog_log(LogType::Force, "FPD: IPC buffer has incorrect size"); return FPResult_InvalidIPCParam;}; __T __Name = *((__T*)vecIn[__vecIndex].basePhys.GetPtr()) + #define DeclareOutputPtr(__Name, __T, __count, __vecIndex) if(sizeof(__T)*(__count) != vecOut[__vecIndex].size) { cemuLog_log(LogType::Force, "FPD: IPC buffer has incorrect size"); return FPResult_InvalidIPCParam;}; __T* __Name = ((__T*)vecOut[__vecIndex].basePhys.GetPtr()) + + template + static nnResult WriteValueOutput(IPCIoctlVector* vec, const T& value) + { + if(vec->size != sizeof(T)) + return FPResult_InvalidIPCParam; + *(T*)vec->basePhys.GetPtr() = value; + return FPResult_Ok; + } + + nnResult CallHandler_SetNotificationMask(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + DeclareInput(notificationMask, uint32be, 0); + fpdClient->notificationMask = notificationMask; + return FPResult_Ok; + } + + nnResult CallHandler_GetNotificationAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 2) + return FPResult_InvalidIPCParam; + if((vecOut[0].size % sizeof(FPDNotification)) != 0 || vecOut[0].size < sizeof(FPDNotification)) + { + cemuLog_log(LogType::Force, "FPD GetNotificationAsync: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + DeclareOutputPtr(countOut, uint32be, 1, 1); + uint32 maxCount = vecOut[0].size / sizeof(FPDNotification); + DeclareOutputPtr(notificationList, FPDNotification, maxCount, 0); + fpdClient->notificationRequests.emplace_back(cmd, maxCount, notificationList, countOut); + SendQueuedNotifications(fpdClient); // if any notifications are queued, send them immediately + return FPResult_Ok; + } + + nnResult CallHandler_LoginAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!ActiveSettings::IsOnlineEnabled()) + { + // not online, fail immediately + return BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // todo + } + StartFriendSession(); + fpdClient->hasLoggedIn = true; + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + m_asyncLoginRequests.emplace_back(cmd); + return FPResult_Ok; + } + + nnResult CallHandler_HasLoggedIn(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + return WriteValueOutput(vecOut, fpdClient->hasLoggedIn ? 1 : 0); + } + + nnResult CallHandler_IsOnline(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + bool isOnline = g_fpd.nexFriendSession ? g_fpd.nexFriendSession->isOnline() : false; + return WriteValueOutput(vecOut, isOnline?1:0); + } + + nnResult CallHandler_GetMyPrincipalId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + uint32 pid = 0; + iosu::act::getPrincipalId(slot, &pid); + return WriteValueOutput(vecOut, pid); + } + + nnResult CallHandler_GetMyAccountId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + std::string accountId = iosu::act::getAccountId2(slot); + if(vecOut->size != ACT_ACCOUNTID_LENGTH) + { + cemuLog_log(LogType::Force, "GetMyAccountId: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + if(accountId.length() > ACT_ACCOUNTID_LENGTH-1) + { + cemuLog_log(LogType::Force, "GetMyAccountId: AccountID is too long"); + return FPResult_InvalidIPCParam; + } + if(accountId.empty()) + { + cemuLog_log(LogType::Force, "GetMyAccountId: AccountID is empty"); + return FPResult_InvalidIPCParam; // should return 0xC0C00800 ? + } + char* outputStr = (char*)vecOut->basePhys.GetPtr(); + memset(outputStr, 0, ACT_ACCOUNTID_LENGTH); + memcpy(outputStr, accountId.data(), accountId.length()); + return FPResult_Ok; + } + + nnResult CallHandler_GetMyScreenName(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + if(vecOut->size != ACT_NICKNAME_SIZE*sizeof(uint16be)) + { + cemuLog_log(LogType::Force, "GetMyScreenName: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + uint16 screenname[ACT_NICKNAME_SIZE]{0}; + bool r = iosu::act::getScreenname(slot, screenname); + if (!r) + { + cemuLog_log(LogType::Force, "GetMyScreenName: Screenname is empty"); + return FPResult_InvalidIPCParam; // should return 0xC0C00800 ? + } + uint16be* outputStr = (uint16be*)vecOut->basePhys.GetPtr(); + for(sint32 i = 0; i < ACT_NICKNAME_SIZE; i++) + outputStr[i] = screenname[i]; + return FPResult_Ok; + } + + nnResult CallHandler_GetMyMii(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + if(vecOut->size != FFL_SIZE) + { + cemuLog_log(LogType::Force, "GetMyMii: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + bool r = iosu::act::getMii(slot, (FFLData_t*)vecOut->basePhys.GetPtr()); + if (!r) + { + cemuLog_log(LogType::Force, "GetMyMii: Mii is empty"); + return FPResult_InvalidIPCParam; // should return 0xC0C00800 ? + } + return FPResult_Ok; + } + + nnResult CallHandler_GetMyProfile(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + FPProfile profile{0}; + // todo + cemuLog_log(LogType::Force, "GetMyProfile is todo"); + return WriteValueOutput(vecOut, profile); + } + + nnResult CallHandler_GetMyPresence(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + uint8 slot = iosu::act::getCurrentAccountSlot(); + SelfPresence selfPresence{0}; + cemuLog_log(LogType::Force, "GetMyPresence is todo"); + return WriteValueOutput(vecOut, selfPresence); + } + + nnResult CallHandler_GetMyComment(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + static constexpr uint32 MY_COMMENT_LENGTH = 0x12; // are comments utf16? Buffer length is 0x24 + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + if(vecOut->size != MY_COMMENT_LENGTH*sizeof(uint16be)) + { + cemuLog_log(LogType::Force, "GetMyComment: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + std::basic_string myComment; + myComment.resize(MY_COMMENT_LENGTH); + memcpy(vecOut->basePhys.GetPtr(), myComment.data(), MY_COMMENT_LENGTH*sizeof(uint16be)); + return 0; + } + + nnResult CallHandler_GetMyPreference(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + FPDPreference selfPreference{0}; + if(g_fpd.nexFriendSession) + { + nexPrincipalPreference nexPreference; + g_fpd.nexFriendSession->getMyPreference(nexPreference); + selfPreference.showOnline = nexPreference.showOnline; + selfPreference.showGame = nexPreference.showGame; + selfPreference.blockFriendRequests = nexPreference.blockFriendRequests; + selfPreference.ukn = 0; + } + else + memset(&selfPreference, 0, sizeof(FPDPreference)); + return WriteValueOutput(vecOut, selfPreference); + } + + nnResult CallHandler_GetMyPlayingGame(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + SelfPlayingGame selfPlayingGame{0}; + cemuLog_log(LogType::Force, "GetMyPlayingGame is todo"); + return WriteValueOutput(vecOut, selfPlayingGame); + } + + nnResult CallHandler_GetFriendAccountId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + // todo - online check + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareOutputPtr(accountId, CafeString, count, 0); + memset(accountId, 0, ACT_ACCOUNTID_LENGTH * count); + if (g_fpd.nexFriendSession) + { + for (uint32 i = 0; i < count; i++) + { + const uint32 pid = pidList[i]; + auto& nnidOutput = accountId[i]; + nexFriend frd; + nexFriendRequest frdReq; + if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) + { + nnidOutput.assign(frd.nnaInfo.principalInfo.nnid); + continue; + } + bool incoming = false; + if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + { + nnidOutput.assign(frdReq.principalInfo.nnid); + continue; + } + cemuLog_log(LogType::Force, "GetFriendAccountId: PID {} not found", pid); + } + } + return FPResult_Ok; + } + + nnResult CallHandler_GetFriendScreenName(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + static_assert(sizeof(CafeWideString) == 11*2); + if(numVecIn != 3 || numVecOut != 2) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareInput(replaceNonAscii, uint8be, 2); + DeclareOutputPtr(nameList, CafeWideString, count, 0); + uint8be* languageList = nullptr; + if(vecOut[1].size > 0) // languageList is optional + { + DeclareOutputPtr(_languageList, uint8be, count, 1); + languageList = _languageList; + } + memset(nameList, 0, ACT_NICKNAME_SIZE * sizeof(CafeWideString)); + if (g_fpd.nexFriendSession) + { + for (uint32 i = 0; i < count; i++) + { + const uint32 pid = pidList[i]; + CafeWideString& screennameOutput = nameList[i]; + if (languageList) + languageList[i] = 0; // unknown + nexFriend frd; + nexFriendRequest frdReq; + if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) + { + screennameOutput.assignFromUTF8(frd.nnaInfo.principalInfo.mii.miiNickname); + if (languageList) + languageList[i] = frd.nnaInfo.principalInfo.regionGuessed; + continue; + } + bool incoming = false; + if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + { + screennameOutput.assignFromUTF8(frdReq.principalInfo.mii.miiNickname); + if (languageList) + languageList[i] = frdReq.principalInfo.regionGuessed; + continue; + } + cemuLog_log(LogType::Force, "GetFriendScreenName: PID {} not found", pid); + } + } + return FPResult_Ok; + } + + nnResult CallHandler_GetFriendMii(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareOutputPtr(miiList, FFLData_t, count, 0); + memset(miiList, 0, sizeof(FFLData_t) * count); + if (g_fpd.nexFriendSession) + { + for (uint32 i = 0; i < count; i++) + { + const uint32 pid = pidList[i]; + FFLData_t& miiOutput = miiList[i]; + nexFriend frd; + nexFriendRequest frdReq; + if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) + { + memcpy(&miiOutput, frd.nnaInfo.principalInfo.mii.miiData, FFL_SIZE); + continue; + } + bool incoming = false; + if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + { + memcpy(&miiOutput, frdReq.principalInfo.mii.miiData, FFL_SIZE); + continue; + } + } + } + return FPResult_Ok; + } + + nnResult CallHandler_GetFriendPresence(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareOutputPtr(presenceList, FriendPresence, count, 0); + memset(presenceList, 0, sizeof(FriendPresence) * count); + if (g_fpd.nexFriendSession) + { + for (uint32 i = 0; i < count; i++) + { + FriendPresence& presenceOutput = presenceList[i]; + const uint32 pid = pidList[i]; + nexFriend frd; + if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) + { + presenceOutput.isOnline = frd.presence.isOnline ? 1 : 0; + presenceOutput.isValid = 1; + // todo - region and subregion + presenceOutput.gameMode.joinFlagMask = frd.presence.joinFlagMask; + presenceOutput.gameMode.matchmakeType = frd.presence.joinAvailability; + presenceOutput.gameMode.joinGameId = frd.presence.gameId; + presenceOutput.gameMode.joinGameMode = frd.presence.gameMode; + presenceOutput.gameMode.hostPid = frd.presence.hostPid; + presenceOutput.gameMode.groupId = frd.presence.groupId; + + memcpy(presenceOutput.gameMode.appSpecificData, frd.presence.appSpecificData, 0x14); + } + else + { + cemuLog_log(LogType::Force, "GetFriendPresence: PID {} not found", pid); + } + } + } + return FPResult_Ok; + } + + nnResult CallHandler_GetFriendRelationship(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + // todo - check for valid session (same for all GetFriend* functions) + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareOutputPtr(relationshipList, uint8be, count, 0); // correct? + for(uint32 i=0; igetFriendByPID(frd, pid)) + { + relationshipOutput = RELATIONSHIP_FRIEND; + continue; + } + else if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + { + if (incoming) + relationshipOutput = RELATIONSHIP_FRIENDREQUEST_IN; + else + relationshipOutput = RELATIONSHIP_FRIENDREQUEST_OUT; + } + } + } + return FPResult_Ok; + } + + nnResult CallHandler_GetFriendList_GetFriendListAll(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut, bool isAll) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if(numVecIn != 2 || numVecOut != 2) + return FPResult_InvalidIPCParam; + DeclareInput(startIndex, uint32be, 0); + DeclareInput(maxCount, uint32be, 1); + if (maxCount * sizeof(FriendPID) != vecOut[0].size || vecOut[0].basePhys.IsNull()) + { + cemuLog_log(LogType::Force, "GetFriendListAll: pid list buffer size is incorrect"); + return FPResult_InvalidIPCParam; + } + if (!g_fpd.nexFriendSession) + return WriteValueOutput(vecOut+1, 0); + betype* pidList = (betype*)vecOut[0].basePhys.GetPtr(); + std::vector temporaryPidList; + temporaryPidList.resize(std::min(maxCount, 500)); + uint32 pidCount = 0; + g_fpd.nexFriendSession->getFriendPIDs(temporaryPidList.data(), &pidCount, startIndex, temporaryPidList.size(), isAll); + std::copy(temporaryPidList.begin(), temporaryPidList.begin() + pidCount, pidList); + return WriteValueOutput(vecOut+1, pidCount); + } + + nnResult CallHandler_GetFriendRequestList(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if(numVecIn != 2 || numVecOut != 2) + return FPResult_InvalidIPCParam; + DeclareInput(startIndex, uint32be, 0); + DeclareInput(maxCount, uint32be, 1); + if(maxCount * sizeof(FriendPID) != vecOut[0].size || vecOut[0].basePhys.IsNull()) + { + cemuLog_log(LogType::Force, "GetFriendRequestList: pid list buffer size is incorrect"); + return FPResult_InvalidIPCParam; + } + if (!g_fpd.nexFriendSession) + return WriteValueOutput(vecOut+1, 0); + betype* pidList = (betype*)vecOut[0].basePhys.GetPtr(); + std::vector temporaryPidList; + temporaryPidList.resize(std::min(maxCount, 500)); + uint32 pidCount = 0; + g_fpd.nexFriendSession->getFriendRequestPIDs(temporaryPidList.data(), &pidCount, startIndex, temporaryPidList.size(), true, false); + std::copy(temporaryPidList.begin(), temporaryPidList.begin() + pidCount, pidList); + return WriteValueOutput(vecOut+1, pidCount); + } + + nnResult CallHandler_GetFriendRequestListEx(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, uint32be, count, 0); + DeclareOutputPtr(friendRequests, FriendRequest, count, 0); + memset(friendRequests, 0, sizeof(FriendRequest) * count); + if (!g_fpd.nexFriendSession) + return FPResult_Ok; + for(uint32 i=0; igetFriendRequestByPID(frdReq, &incoming, pidList[i])) + { + cemuLog_log(LogType::Force, "GetFriendRequestListEx: Failed to get friend request"); + return FPResult_RequestFailed; + } + NexFriendRequestToFPDFriendRequest(friendRequests + i, &frdReq, incoming); + } + return FPResult_Ok; + } + + nnResult CallHandler_GetBlackList(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if(numVecIn != 2 || numVecOut != 2) + return FPResult_InvalidIPCParam; + DeclareInput(startIndex, uint32be, 0); + DeclareInput(maxCount, uint32be, 1); + if(maxCount * sizeof(FriendPID) != vecOut[0].size) + { + cemuLog_log(LogType::Force, "GetBlackList: pid list buffer size is incorrect"); + return FPResult_InvalidIPCParam; + } + if (!g_fpd.nexFriendSession) + return WriteValueOutput(vecOut+1, 0); + betype* pidList = (betype*)vecOut[0].basePhys.GetPtr(); + // todo! + cemuLog_logDebug(LogType::Force, "GetBlackList is todo"); + uint32 countOut = 0; + + return WriteValueOutput(vecOut+1, countOut); + } + + nnResult CallHandler_GetFriendListEx(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if(numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, betype, count, 0); + if(count * sizeof(FriendPID) != vecIn[0].size) + { + cemuLog_log(LogType::Force, "GetFriendListEx: pid input list buffer size is incorrect"); + return FPResult_InvalidIPCParam; + } + if(count * sizeof(FriendData) != vecOut[0].size) + { + cemuLog_log(LogType::Force, "GetFriendListEx: Friend output list buffer size is incorrect"); + return FPResult_InvalidIPCParam; + } + FriendData* friendOutput = (FriendData*)vecOut[0].basePhys.GetPtr(); + memset(friendOutput, 0, sizeof(FriendData) * count); + if (g_fpd.nexFriendSession) + { + for (uint32 i = 0; i < count; i++) + { + uint32 pid = pidList[i]; + FriendData* friendData = friendOutput + i; + nexFriend frd; + nexFriendRequest frdReq; + if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) + { + NexFriendToFPDFriendData(friendData, &frd); + continue; + } + bool incoming = false; + if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) + { + NexFriendRequestToFPDFriendData(friendData, &frdReq, incoming); + continue; + } + cemuLog_logDebug(LogType::Force, "GetFriendListEx: Failed to find friend or request with pid {}", pid); + memset(friendData, 0, sizeof(FriendData)); + } + } + return FPResult_Ok; + } + + static void NexBasicInfoToBasicInfo(const nexPrincipalBasicInfo& nexBasicInfo, FriendBasicInfo& basicInfo) + { + memset(&basicInfo, 0, sizeof(FriendBasicInfo)); + basicInfo.pid = nexBasicInfo.principalId; + strcpy(basicInfo.nnid, nexBasicInfo.nnid); + + convertMultiByteStringToBigEndianWidechar(nexBasicInfo.mii.miiNickname, basicInfo.screenname, sizeof(basicInfo.screenname) / sizeof(uint16be)); + memcpy(basicInfo.miiData, nexBasicInfo.mii.miiData, FFL_SIZE); + + basicInfo.uknDate90.day = 1; + basicInfo.uknDate90.month = 1; + basicInfo.uknDate90.hour = 1; + basicInfo.uknDate90.minute = 1; + basicInfo.uknDate90.second = 1; // unknown values not set: // ukn15 // ukn2E // ukn2F } - // success - handleFPCallback(&cbInfo->fpCallback, 0x00000000); - free(cbInfo->principalBasicInfo); - free(cbInfo->pidList); - free(cbInfo); - } - - void handleRequest_GetBasicInfoAsync(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) + nnResult CallHandler_GetBasicInfoAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - sint32 count = fpdCemuRequest->getBasicInfo.count; - - nexPrincipalBasicInfo* principalBasicInfo = new nexPrincipalBasicInfo[count]; - uint32* pidList = (uint32*)malloc(sizeof(uint32)*count); - for (sint32 i = 0; i < count; i++) - pidList[i] = fpdCemuRequest->getBasicInfo.pidList[i]; - getBasicInfoAsyncParams_t* cbInfo = (getBasicInfoAsyncParams_t*)malloc(sizeof(getBasicInfoAsyncParams_t)); - cbInfo->principalBasicInfo = principalBasicInfo; - cbInfo->pidList = pidList; - cbInfo->count = count; - cbInfo->friendBasicInfo = fpdCemuRequest->getBasicInfo.basicInfo.GetPtr(); - cbInfo->fpCallback.funcMPTR = fpdCemuRequest->getBasicInfo.funcPtr; - cbInfo->fpCallback.customParam = fpdCemuRequest->getBasicInfo.custom; - g_fpd.nexFriendSession->requestPrincipleBaseInfoByPID(principalBasicInfo, pidList, count, handleResultCB_GetBasicInfoAsync, cbInfo); - } - - void handleResponse_addOrRemoveFriend(uint32 errorCode, MPTR funcMPTR, MPTR custom) - { - if (errorCode == 0) - { - handleFPCallback2(funcMPTR, custom, 0); - g_fpd.nexFriendSession->requestGetAllInformation(); // refresh list - } - else - handleFPCallback2(funcMPTR, custom, 0x80000000); - } - - void handleRequest_RemoveFriendAsync(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - g_fpd.nexFriendSession->removeFriend(fpdCemuRequest->addOrRemoveFriend.pid, std::bind(handleResponse_addOrRemoveFriend, std::placeholders::_1, fpdCemuRequest->addOrRemoveFriend.funcPtr, fpdCemuRequest->addOrRemoveFriend.custom)); - } - - void handleResponse_MarkFriendRequestAsReceivedAsync(uint32 errorCode, MPTR funcMPTR, MPTR custom) - { - if (errorCode == 0) - handleFPCallback2(funcMPTR, custom, 0); - else - handleFPCallback2(funcMPTR, custom, 0x80000000); - } - - void handleRequest_MarkFriendRequestAsReceivedAsync(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - // convert messageId list to little endian - uint64 messageIds[100]; - sint32 count = 0; - for (uint32 i = 0; i < fpdCemuRequest->markFriendRequest.count; i++) - { - uint64 mid = _swapEndianU64(fpdCemuRequest->markFriendRequest.messageIdList.GetPtr()[i]); - if (mid == 0) + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidListBE, betype, count, 0); + DeclareOutputPtr(basicInfoList, FriendBasicInfo, count, 0); + if (!g_fpd.nexFriendSession) { - cemuLog_logDebug(LogType::Force, "MarkFriendRequestAsReceivedAsync - Invalid messageId"); - continue; + memset(basicInfoList, 0, sizeof(FriendBasicInfo) * sizeof(count)); + return FPResult_Ok; } - messageIds[count] = mid; - count++; - if (count >= sizeof(messageIds)/sizeof(messageIds[0])) - break; - } - // skipped for now - g_fpd.nexFriendSession->markFriendRequestsAsReceived(messageIds, count, std::bind(handleResponse_MarkFriendRequestAsReceivedAsync, std::placeholders::_1, fpdCemuRequest->markFriendRequest.funcPtr, fpdCemuRequest->markFriendRequest.custom)); - } - - void handleResponse_cancelMyFriendRequest(uint32 errorCode, uint32 pid, MPTR funcMPTR, MPTR custom) - { - if (errorCode == 0) - { - handleFPCallback2(funcMPTR, custom, 0); - } - else - handleFPCallback2(funcMPTR, custom, 0x80000000); - } - - void handleRequest_CancelFriendRequestAsync(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - // find friend request with matching pid - nexFriendRequest frq; - bool isIncoming; - if (g_fpd.nexFriendSession->getFriendRequestByMessageId(frq, &isIncoming, fpdCemuRequest->cancelOrAcceptFriendRequest.messageId)) - { - g_fpd.nexFriendSession->removeFriend(frq.principalInfo.principalId, std::bind(handleResponse_cancelMyFriendRequest, std::placeholders::_1, frq.principalInfo.principalId, fpdCemuRequest->cancelOrAcceptFriendRequest.funcPtr, fpdCemuRequest->cancelOrAcceptFriendRequest.custom)); - } - else - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - } - - void handleResponse_acceptFriendRequest(uint32 errorCode, uint32 pid, MPTR funcMPTR, MPTR custom) - { - if (errorCode == 0) - { - handleFPCallback2(funcMPTR, custom, 0); - g_fpd.nexFriendSession->requestGetAllInformation(); // refresh list - } - else - handleFPCallback2(funcMPTR, custom, 0x80000000); - } - - void handleRequest_AcceptFriendRequestAsync(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - // find friend request with matching pid - nexFriendRequest frq; - bool isIncoming; - if (g_fpd.nexFriendSession->getFriendRequestByMessageId(frq, &isIncoming, fpdCemuRequest->cancelOrAcceptFriendRequest.messageId)) - { - g_fpd.nexFriendSession->acceptFriendRequest(fpdCemuRequest->cancelOrAcceptFriendRequest.messageId, std::bind(handleResponse_acceptFriendRequest, std::placeholders::_1, frq.principalInfo.principalId, fpdCemuRequest->cancelOrAcceptFriendRequest.funcPtr, fpdCemuRequest->cancelOrAcceptFriendRequest.custom)); - } - else - { - fpdCemuRequest->returnCode = 0x80000000; - return; - } - } - - void handleResponse_addFriendRequest(uint32 errorCode, MPTR funcMPTR, MPTR custom) - { - if (errorCode == 0) - { - handleFPCallback2(funcMPTR, custom, 0); - g_fpd.nexFriendSession->requestGetAllInformation(); // refresh list - } - else - handleFPCallback2(funcMPTR, custom, 0x80000000); - } - - void handleRequest_AddFriendRequest(iosuFpdCemuRequest_t* fpdCemuRequest) - { - fpdCemuRequest->returnCode = 0; - if (g_fpd.nexFriendSession == nullptr || g_fpd.nexFriendSession->isOnline() == false) - { - fpdCemuRequest->returnCode = 0x80000000; - return; + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + std::vector pidList; + std::copy(pidListBE, pidListBE + count, std::back_inserter(pidList)); + g_fpd.nexFriendSession->requestPrincipleBaseInfoByPID(pidList.data(), count, [cmd, basicInfoList, count](NexFriends::RpcErrorCode result, std::span basicInfo) -> void { + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + cemu_assert_debug(basicInfo.size() == count); + for(uint32 i = 0; i < count; i++) + NexBasicInfoToBasicInfo(basicInfo[i], basicInfoList[i]); + ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; } - uint16be* input = fpdCemuRequest->addFriendRequest.message.GetPtr(); - size_t inputLen = 0; - while (input[inputLen] != 0) - inputLen++; - std::string msg = StringHelpers::ToUtf8({ input, inputLen }); - - g_fpd.nexFriendSession->addFriendRequest(fpdCemuRequest->addFriendRequest.pid, msg.data(), std::bind(handleResponse_addFriendRequest, std::placeholders::_1, fpdCemuRequest->addFriendRequest.funcPtr, fpdCemuRequest->addFriendRequest.custom)); - } - - // called once a second to handle state checking and updates of the friends service - void iosuFpd_updateFriendsService() - { - if (g_fpd.nexFriendSession) + nnResult CallHandler_UpdatePreferenceAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) { - g_fpd.nexFriendSession->update(); + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInputPtr(newPreference, FPDPreference, 1, 0); + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->updatePreferencesAsync(nexPrincipalPreference(newPreference->showOnline != 0 ? 1 : 0, newPreference->showGame != 0 ? 1 : 0, newPreference->blockFriendRequests != 0 ? 1 : 0), [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } - if (g_fpd.asyncLoginCallback.func != MPTR_NULL) + nnResult CallHandler_AddFriendRequestAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 2 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInputPtr(playRecord, RecentPlayRecordEx, 1, 0); + uint32 msgLength = vecIn[1].size/sizeof(uint16be); + DeclareInputPtr(msgBE, uint16be, msgLength, 1); + if(msgLength == 0 || msgBE[msgLength-1] != 0) { - if (g_fpd.nexFriendSession->isOnline()) - { - *_fpdAsyncLoginRetCode.GetPtr() = 0x00000000; - coreinitAsyncCallback_add(g_fpd.asyncLoginCallback.func, 2, _fpdAsyncLoginRetCode.GetMPTR(), g_fpd.asyncLoginCallback.customParam); - g_fpd.asyncLoginCallback.func = MPTR_NULL; - g_fpd.asyncLoginCallback.customParam = MPTR_NULL; - } + cemuLog_log(LogType::Force, "AddFriendRequestAsync: Message must contain at least a null-termination character and end with one"); + return FPResult_InvalidIPCParam; } + std::string msg = StringHelpers::ToUtf8({ msgBE, msgLength-1 }); + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->addFriendRequest(playRecord->pid, msg.data(), [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; } - } - void iosuFpd_thread() - { - SetThreadName("iosuFpd_thread"); - while (true) + nnResult CallHandler_AcceptFriendRequestAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) { - uint32 returnValue = 0; // Ioctl return value - ioQueueEntry_t* ioQueueEntry = iosuIoctl_getNextWithTimeout(IOS_DEVICE_FPD, 1000); - if (ioQueueEntry == nullptr) + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(requestId, uint64be, 0); + nexFriendRequest frq; + bool isIncoming; + if (!g_fpd.nexFriendSession->getFriendRequestByMessageId(frq, &isIncoming, requestId)) + return FPResult_RequestFailed; + if(!isIncoming) { - iosuFpd_updateFriendsService(); - continue; + cemuLog_log(LogType::Force, "AcceptFriendRequestAsync: Trying to accept outgoing friend request"); + return FPResult_RequestFailed; } - if (ioQueueEntry->request == IOSU_FPD_REQUEST_CEMU) - { - iosuFpdCemuRequest_t* fpdCemuRequest = (iosuFpdCemuRequest_t*)ioQueueEntry->bufferVectors[0].buffer.GetPtr(); - if (fpdCemuRequest->requestCode == IOSU_FPD_INITIALIZE) - { - if (g_fpd.isInitialized2 == false) - { - if(ActiveSettings::IsOnlineEnabled()) - startFriendSession(); - - g_fpd.isInitialized2 = true; - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_SET_NOTIFICATION_HANDLER) - { - g_fpd.notificationFunc = fpdCemuRequest->setNotificationHandler.funcPtr; - g_fpd.notificationCustomParam = fpdCemuRequest->setNotificationHandler.custom; - g_fpd.notificationMask = fpdCemuRequest->setNotificationHandler.notificationMask; - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_LOGIN_ASYNC) - { - if (g_fpd.nexFriendSession) - { - g_fpd.asyncLoginCallback.func = fpdCemuRequest->loginAsync.funcPtr; - g_fpd.asyncLoginCallback.customParam = fpdCemuRequest->loginAsync.custom; - } - else - { - // offline mode - *_fpdAsyncLoginRetCode.GetPtr() = 0; // if we return 0x80000000 here then Splatoon softlocks during boot - coreinitAsyncCallback_add(fpdCemuRequest->loginAsync.funcPtr, 2, _fpdAsyncLoginRetCode.GetMPTR(), fpdCemuRequest->loginAsync.custom); - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_IS_ONLINE) - { - fpdCemuRequest->resultU32.u32 = g_fpd.nexFriendSession ? g_fpd.nexFriendSession->isOnline() : 0; - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_IS_PREFERENCE_VALID) - { - fpdCemuRequest->resultU32.u32 = 1; // todo (if this returns 0, the friend app will show the first-time-setup screen and ask the user to configure preferences) - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_MY_PRINCIPAL_ID) - { - uint8 slot = iosu::act::getCurrentAccountSlot(); - iosu::act::getPrincipalId(slot, &fpdCemuRequest->resultU32.u32); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_MY_ACCOUNT_ID) - { - char* accountId = (char*)fpdCemuRequest->common.ptr.GetPtr(); - uint8 slot = iosu::act::getCurrentAccountSlot(); - if (iosu::act::getAccountId(slot, accountId) == false) - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - else - fpdCemuRequest->returnCode = 0; - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_MY_MII) - { - FFLData_t* fflData = (FFLData_t*)fpdCemuRequest->common.ptr.GetPtr(); - uint8 slot = iosu::act::getCurrentAccountSlot(); - if (iosu::act::getMii(slot, fflData) == false) - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - else - fpdCemuRequest->returnCode = 0; - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_MY_SCREENNAME) - { - uint16be* screennameOutput = (uint16be*)fpdCemuRequest->common.ptr.GetPtr(); - uint8 slot = iosu::act::getCurrentAccountSlot(); - uint16 screennameTemp[ACT_NICKNAME_LENGTH]; - if (iosu::act::getScreenname(slot, screennameTemp)) - { - for (sint32 i = 0; i < ACT_NICKNAME_LENGTH; i++) - { - screennameOutput[i] = screennameTemp[i]; - } - screennameOutput[ACT_NICKNAME_LENGTH] = '\0'; // length is ACT_NICKNAME_LENGTH+1 - fpdCemuRequest->returnCode = 0; - } - else - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - screennameOutput[0] = '\0'; - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_ACCOUNT_ID) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - fpdCemuRequest->returnCode = 0; - for (sint32 i = 0; i < fpdCemuRequest->getFriendAccountId.count; i++) - { - char* nnidOutput = fpdCemuRequest->getFriendAccountId.accountIds.GetPtr()+i*17; - uint32 pid = fpdCemuRequest->getFriendAccountId.pidList[i]; - if (g_fpd.nexFriendSession == nullptr) - { - nnidOutput[0] = '\0'; - continue; - } - nexFriend frd; - nexFriendRequest frdReq; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - strcpy(nnidOutput, frd.nnaInfo.principalInfo.nnid); - continue; - } - bool incoming = false; - if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) - { - strcpy(nnidOutput, frdReq.principalInfo.nnid); - continue; - } - nnidOutput[0] = '\0'; - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_SCREENNAME) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - fpdCemuRequest->returnCode = 0; - for (sint32 i = 0; i < fpdCemuRequest->getFriendScreenname.count; i++) - { - uint16be* screennameOutput = fpdCemuRequest->getFriendScreenname.nameList.GetPtr()+i*11; - uint32 pid = fpdCemuRequest->getFriendScreenname.pidList[i]; - if(fpdCemuRequest->getFriendScreenname.languageList.IsNull() == false) - fpdCemuRequest->getFriendScreenname.languageList.GetPtr()[i] = 0; - if (g_fpd.nexFriendSession == nullptr) - { - screennameOutput[0] = '\0'; - continue; - } - nexFriend frd; - nexFriendRequest frdReq; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - convertMultiByteStringToBigEndianWidechar(frd.nnaInfo.principalInfo.mii.miiNickname, screennameOutput, 11); - if (fpdCemuRequest->getFriendScreenname.languageList.IsNull() == false) - fpdCemuRequest->getFriendScreenname.languageList.GetPtr()[i] = frd.nnaInfo.principalInfo.regionGuessed; - continue; - } - bool incoming = false; - if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) - { - convertMultiByteStringToBigEndianWidechar(frdReq.principalInfo.mii.miiNickname, screennameOutput, 11); - if (fpdCemuRequest->getFriendScreenname.languageList.IsNull() == false) - fpdCemuRequest->getFriendScreenname.languageList.GetPtr()[i] = frdReq.principalInfo.regionGuessed; - continue; - } - screennameOutput[0] = '\0'; - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_MII) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - fpdCemuRequest->returnCode = 0; - for (sint32 i = 0; i < fpdCemuRequest->getFriendMii.count; i++) - { - uint8* miiOutput = fpdCemuRequest->getFriendMii.miiList + i * FFL_SIZE; - uint32 pid = fpdCemuRequest->getFriendMii.pidList[i]; - if (g_fpd.nexFriendSession == nullptr) - { - memset(miiOutput, 0, FFL_SIZE); - continue; - } - nexFriend frd; - nexFriendRequest frdReq; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - memcpy(miiOutput, frd.nnaInfo.principalInfo.mii.miiData, FFL_SIZE); - continue; - } - bool incoming = false; - if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) - { - memcpy(miiOutput, frdReq.principalInfo.mii.miiData, FFL_SIZE); - continue; - } - memset(miiOutput, 0, FFL_SIZE); - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_PRESENCE) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - fpdCemuRequest->returnCode = 0; - for (sint32 i = 0; i < fpdCemuRequest->getFriendPresence.count; i++) - { - friendPresence_t* presenceOutput = (friendPresence_t*)(fpdCemuRequest->getFriendPresence.presenceList + i * sizeof(friendPresence_t)); - memset(presenceOutput, 0, sizeof(friendPresence_t)); - uint32 pid = fpdCemuRequest->getFriendPresence.pidList[i]; - if (g_fpd.nexFriendSession == nullptr) - { - continue; - } - nexFriend frd; - nexFriendRequest frdReq; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - presenceOutput->isOnline = frd.presence.isOnline ? 1 : 0; - presenceOutput->isValid = 1; - - presenceOutput->gameMode.joinFlagMask = frd.presence.joinFlagMask; - presenceOutput->gameMode.matchmakeType = frd.presence.joinAvailability; - presenceOutput->gameMode.joinGameId = frd.presence.gameId; - presenceOutput->gameMode.joinGameMode = frd.presence.gameMode; - presenceOutput->gameMode.hostPid = frd.presence.hostPid; - presenceOutput->gameMode.groupId = frd.presence.groupId; - - memcpy(presenceOutput->gameMode.appSpecificData, frd.presence.appSpecificData, 0x14); - - continue; - } - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_RELATIONSHIP) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - fpdCemuRequest->returnCode = 0; - for (sint32 i = 0; i < fpdCemuRequest->getFriendRelationship.count; i++) - { - uint8* relationshipOutput = (fpdCemuRequest->getFriendRelationship.relationshipList + i); - uint32 pid = fpdCemuRequest->getFriendRelationship.pidList[i]; - *relationshipOutput = RELATIONSHIP_INVALID; - if (g_fpd.nexFriendSession == nullptr) - { - continue; - } - nexFriend frd; - nexFriendRequest frdReq; - bool incoming; - if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) - { - *relationshipOutput = RELATIONSHIP_FRIEND; - continue; - } - else if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) - { - if(incoming) - *relationshipOutput = RELATIONSHIP_FRIENDREQUEST_IN; - else - *relationshipOutput = RELATIONSHIP_FRIENDREQUEST_OUT; - } - } - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_LIST) - { - handleRequest_GetFriendList(fpdCemuRequest, false); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIENDREQUEST_LIST) - { - handleRequest_GetFriendRequestList(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_LIST_ALL) - { - handleRequest_GetFriendList(fpdCemuRequest, true); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIEND_LIST_EX) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - handleRequest_GetFriendListEx(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_FRIENDREQUEST_LIST_EX) - { - if (g_fpd.nexFriendSession == nullptr) - { - fpdCemuRequest->returnCode = 0x80000000; // todo - proper error code - iosuIoctl_completeRequest(ioQueueEntry, returnValue); - return; - } - handleRequest_GetFriendRequestListEx(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_ADD_FRIEND) - { - // todo - figure out how this works - *_fpdAsyncAddFriendRetCode.GetPtr() = 0; - coreinitAsyncCallback_add(fpdCemuRequest->addOrRemoveFriend.funcPtr, 2, _fpdAsyncAddFriendRetCode.GetMPTR(), fpdCemuRequest->addOrRemoveFriend.custom); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_ADD_FRIEND_REQUEST) - { - handleRequest_AddFriendRequest(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_REMOVE_FRIEND_ASYNC) - { - handleRequest_RemoveFriendAsync(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_MARK_FRIEND_REQUEST_AS_RECEIVED_ASYNC) - { - handleRequest_MarkFriendRequestAsReceivedAsync(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_CANCEL_FRIEND_REQUEST_ASYNC) - { - handleRequest_CancelFriendRequestAsync(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_ACCEPT_FRIEND_REQUEST_ASYNC) - { - handleRequest_AcceptFriendRequestAsync(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_GET_BASIC_INFO_ASYNC) - { - handleRequest_GetBasicInfoAsync(fpdCemuRequest); - } - else if (fpdCemuRequest->requestCode == IOSU_FPD_UPDATE_GAMEMODE) - { - gameMode_t* gameMode = fpdCemuRequest->updateGameMode.gameMode.GetPtr(); - uint16be* gameModeMessage = fpdCemuRequest->updateGameMode.gameModeMessage.GetPtr(); - - g_fpd.myPresence.joinFlagMask = gameMode->joinFlagMask; - - g_fpd.myPresence.joinAvailability = (uint8)(uint32)gameMode->matchmakeType; - g_fpd.myPresence.gameId = gameMode->joinGameId; - g_fpd.myPresence.gameMode = gameMode->joinGameMode; - g_fpd.myPresence.hostPid = gameMode->hostPid; - g_fpd.myPresence.groupId = gameMode->groupId; - memcpy(g_fpd.myPresence.appSpecificData, gameMode->appSpecificData, 0x14); - - if (g_fpd.nexFriendSession) - { - g_fpd.nexFriendSession->updateMyPresence(g_fpd.myPresence); - } - - fpdCemuRequest->returnCode = 0; - } - else - cemu_assert_unimplemented(); - } - else - assert_dbg(); - iosuIoctl_completeRequest(ioQueueEntry, returnValue); + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->acceptFriendRequest(requestId, [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + return ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; } - return; + + nnResult CallHandler_DeleteFriendRequestAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + // reject incoming friend request + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(requestId, uint64be, 0); + nexFriendRequest frq; + bool isIncoming; + if (!g_fpd.nexFriendSession->getFriendRequestByMessageId(frq, &isIncoming, requestId)) + return FPResult_RequestFailed; + if(!isIncoming) + { + cemuLog_log(LogType::Force, "CancelFriendRequestAsync: Trying to block outgoing friend request"); + return FPResult_RequestFailed; + } + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->deleteFriendRequest(requestId, [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + return ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } + + nnResult CallHandler_CancelFriendRequestAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + // retract outgoing friend request + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(requestId, uint64be, 0); + nexFriendRequest frq; + bool isIncoming; + if (!g_fpd.nexFriendSession->getFriendRequestByMessageId(frq, &isIncoming, requestId)) + return FPResult_RequestFailed; + if(isIncoming) + { + cemuLog_log(LogType::Force, "CancelFriendRequestAsync: Trying to cancel incoming friend request"); + return FPResult_RequestFailed; + } + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->removeFriend(frq.principalInfo.principalId, [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + return ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } + + nnResult CallHandler_MarkFriendRequestsAsReceivedAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 2 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(requestIdsBE, uint64be, count, 0); + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + // endian convert + std::vector requestIds; + std::copy(requestIdsBE, requestIdsBE + count, std::back_inserter(requestIds)); + g_fpd.nexFriendSession->markFriendRequestsAsReceived(requestIds.data(), requestIds.size(), [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + return ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } + + nnResult CallHandler_RemoveFriendAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(pid, uint32be, 0); + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + g_fpd.nexFriendSession->removeFriend(pid, [cmd](NexFriends::RpcErrorCode result){ + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + return ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } + + nnResult CallHandler_DeleteFriendFlagsAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 3 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(pid, uint32be, 0); + cemuLog_logDebug(LogType::Force, "DeleteFriendFlagsAsync is todo"); + return FPResult_Ok; + } + + nnResult CallHandler_CheckSettingStatusAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if (numVecIn != 0 || numVecOut != 1) + return FPResult_InvalidIPCParam; + if (vecOut[0].size != sizeof(uint8be)) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + + // for now we respond immediately + uint8 settingsStatus = 1; // todo - figure out what this status means + auto r = WriteValueOutput(vecOut, settingsStatus); + ServiceCallAsyncRespond(cmd, r); + cemuLog_log(LogType::Force, "CheckSettingStatusAsync is todo"); + + return FPResult_Ok; + } + + nnResult CallHandler_IsPreferenceValid(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if (numVecIn != 0 || numVecOut != 1) + return 0; + if (!g_fpd.nexFriendSession) + return 0; + // we currently automatically put the preferences into a valid state on session creation if they are not set yet + return WriteValueOutput(vecOut, 1); // if we return 0, the friend app will show the first time setup screen + } + + nnResult CallHandler_GetRequestBlockSettingAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) // todo + { + if (numVecIn != 2 || numVecOut != 1) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(count, uint32be, 1); + DeclareInputPtr(pidList, betype, count, 0); + DeclareOutputPtr(settingList, uint8be, count, 0); + cemuLog_log(LogType::Force, "GetRequestBlockSettingAsync is todo"); + + for (uint32 i = 0; i < count; i++) + settingList[i] = 0; + // implementation is todo. Used by friend list app when adding a friend + // 0 means not blocked. Friend app will continue with GetBasicInformation() + // 1 means blocked. Friend app will continue with AddFriendAsync to add the user as a provisional friend + + return FPResult_Ok; + } + + nnResult CallHandler_AddFriendAsyncByPid(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInput(pid, uint32be, 0); + cemuLog_log(LogType::Force, "AddFriendAsyncByPid is todo"); + return FPResult_Ok; + } + + nnResult CallHandler_UpdateGameMode(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + if (numVecIn != 2 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + DeclareInputPtr(gameMode, iosu::fpd::GameMode, 1, 0); + uint32 messageLength = vecIn[1].size / sizeof(uint16be); + if(messageLength == 0 || (vecIn[1].size%sizeof(uint16be)) != 0) + { + cemuLog_log(LogType::Force, "UpdateGameMode: Message must contain at least a null-termination character"); + return FPResult_InvalidIPCParam; + } + DeclareInputPtr(gameModeMessage, uint16be, messageLength, 1); + messageLength--; + GameModeToNexPresence(gameMode, &g_fpd.myPresence); + g_fpd.nexFriendSession->updateMyPresence(g_fpd.myPresence); + // todo - message + return FPResult_Ok; + } + + void StartFriendSession() + { + bool expected = false; + if (!g_fpd.sessionStarted.compare_exchange_strong(expected, true)) + return; + cemu_assert(!g_fpd.nexFriendSession); + NAPI::AuthInfo authInfo; + NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); + NAPI::ACTGetNexTokenResult nexTokenResult = NAPI::ACT_GetNexToken_WithCache(authInfo, 0x0005001010001C00, 0x0000, 0x00003200); + if (!nexTokenResult.isValid()) + { + cemuLog_logDebug(LogType::Force, "IOSU_FPD: Failed to acquire nex token for friend server"); + g_fpd.myPresence.isOnline = 0; + return; + } + // get values needed for friend session + uint32 myPid; + uint8 currentSlot = iosu::act::getCurrentAccountSlot(); + iosu::act::getPrincipalId(currentSlot, &myPid); + char accountId[256] = { 0 }; + iosu::act::getAccountId(currentSlot, accountId); + FFLData_t miiData; + act::getMii(currentSlot, &miiData); + uint16 screenName[ACT_NICKNAME_LENGTH + 1] = { 0 }; + act::getScreenname(currentSlot, screenName); + uint32 countryCode = 0; + act::getCountryIndex(currentSlot, &countryCode); + // init presence + g_fpd.myPresence.isOnline = 1; + g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); + g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); + // resolve potential domain to IP address + struct addrinfo hints = {0}, *addrs; + hints.ai_family = AF_INET; + const int status = getaddrinfo(nexTokenResult.nexToken.host, NULL, &hints, &addrs); + if (status != 0) + { + cemuLog_log(LogType::Force, "IOSU_FPD: Failed to resolve hostname {}", nexTokenResult.nexToken.host); + return; + } + char addrstr[NI_MAXHOST]; + getnameinfo(addrs->ai_addr, addrs->ai_addrlen, addrstr, sizeof addrstr, NULL, 0, NI_NUMERICHOST); + cemuLog_log(LogType::Force, "IOSU_FPD: Resolved IP for hostname {}, {}", nexTokenResult.nexToken.host, addrstr); + // start session + const uint32_t hostIp = ((struct sockaddr_in*)addrs->ai_addr)->sin_addr.s_addr; + freeaddrinfo(addrs); + g_fpd.mtxFriendSession.lock(); + g_fpd.nexFriendSession = new NexFriends(hostIp, nexTokenResult.nexToken.port, "ridfebb9", myPid, nexTokenResult.nexToken.nexPassword, nexTokenResult.nexToken.token, accountId, (uint8*)&miiData, (wchar_t*)screenName, (uint8)countryCode, g_fpd.myPresence); + g_fpd.nexFriendSession->setNotificationHandler(NotificationHandler); + g_fpd.mtxFriendSession.unlock(); + cemuLog_log(LogType::Force, "IOSU_FPD: Created friend server session"); + } + + void StopFriendSession() + { + std::unique_lock _l(g_fpd.mtxFriendSession); + bool expected = true; + if (!g_fpd.sessionStarted.compare_exchange_strong(expected, false) ) + return; + delete g_fpd.nexFriendSession; + g_fpd.nexFriendSession = nullptr; + } + + private: + + + }; + + FPDService gFPDService; + + class : public ::IOSUModule + { + void TitleStart() override + { + gFPDService.Start(); + gFPDService.SetTimerUpdate(1000); // call TimerUpdate() once a second + } + void TitleStop() override + { + gFPDService.StopFriendSession(); + gFPDService.Stop(); + } + }sIOSUModuleNNFPD; + + IOSUModule* GetModule() + { + return static_cast(&sIOSUModuleNNFPD); } - void Initialize() - { - if (g_fpd.isThreadStarted) - return; - std::thread t1(iosuFpd_thread); - t1.detach(); - g_fpd.isThreadStarted = true; - } } } + diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.h b/src/Cafe/IOSU/legacy/iosu_fpd.h index bd52035c..79f524d6 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.h +++ b/src/Cafe/IOSU/legacy/iosu_fpd.h @@ -1,10 +1,12 @@ #pragma once +#include "Cafe/IOSU/iosu_types_common.h" +#include "Common/CafeString.h" namespace iosu { namespace fpd { - typedef struct + struct FPDDate { /* +0x0 */ uint16be year; /* +0x2 */ uint8 month; @@ -13,13 +15,61 @@ namespace iosu /* +0x5 */ uint8 minute; /* +0x6 */ uint8 second; /* +0x7 */ uint8 padding; - }fpdDate_t; + }; - static_assert(sizeof(fpdDate_t) == 8); + static_assert(sizeof(FPDDate) == 8); - typedef struct + struct RecentPlayRecordEx { - /* +0x000 */ uint8 type; // type(Non-Zero -> Friend, 0 -> Friend request ? ) + /* +0x00 */ uint32be pid; + /* +0x04 */ uint8 ukn04; + /* +0x05 */ uint8 ukn05; + /* +0x06 */ uint8 ukn06[0x22]; + /* +0x28 */ uint8 ukn28[0x22]; + /* +0x4A */ uint8 _uknOrPadding4A[6]; + /* +0x50 */ uint32be ukn50; + /* +0x54 */ uint32be ukn54; + /* +0x58 */ uint16be ukn58; + /* +0x5C */ uint8 _padding5C[4]; + /* +0x60 */ iosu::fpd::FPDDate date; + }; + + static_assert(sizeof(RecentPlayRecordEx) == 0x68, ""); + static_assert(offsetof(RecentPlayRecordEx, ukn06) == 0x06, ""); + static_assert(offsetof(RecentPlayRecordEx, ukn50) == 0x50, ""); + + struct GameKey + { + /* +0x00 */ uint64be titleId; + /* +0x08 */ uint16be ukn08; + /* +0x0A */ uint8 _padding0A[6]; + }; + static_assert(sizeof(GameKey) == 0x10); + + struct Profile + { + uint8be region; + uint8be regionSubcode; + uint8be platform; + uint8be ukn3; + }; + static_assert(sizeof(Profile) == 0x4); + + struct GameMode + { + /* +0x00 */ uint32be joinFlagMask; + /* +0x04 */ uint32be matchmakeType; + /* +0x08 */ uint32be joinGameId; + /* +0x0C */ uint32be joinGameMode; + /* +0x10 */ uint32be hostPid; + /* +0x14 */ uint32be groupId; + /* +0x18 */ uint8 appSpecificData[0x14]; + }; + static_assert(sizeof(GameMode) == 0x2C); + + struct FriendData + { + /* +0x000 */ uint8 type; // type (Non-Zero -> Friend, 0 -> Friend request ? ) /* +0x001 */ uint8 _padding1[7]; /* +0x008 */ uint32be pid; /* +0x00C */ char nnid[0x10 + 1]; @@ -29,43 +79,29 @@ namespace iosu /* +0x036 */ uint8 ukn036; /* +0x037 */ uint8 _padding037; /* +0x038 */ uint8 mii[0x60]; - /* +0x098 */ fpdDate_t uknDate; + /* +0x098 */ FPDDate uknDate; // sub struct (the part above seems to be shared with friend requests) union { struct { - /* +0x0A0 */ uint8 ukn0A0; // country code? - /* +0x0A1 */ uint8 ukn0A1; // country subcode? - /* +0x0A2 */ uint8 _paddingA2[2]; + /* +0x0A0 */ Profile profile; // this is returned for nn_fp.GetFriendProfile /* +0x0A4 */ uint32be ukn0A4; - /* +0x0A8 */ uint64 gameKeyTitleId; - /* +0x0B0 */ uint16be gameKeyUkn; - /* +0x0B2 */ uint8 _paddingB2[6]; - /* +0x0B8 */ uint32 ukn0B8; - /* +0x0BC */ uint32 ukn0BC; - /* +0x0C0 */ uint32 ukn0C0; - /* +0x0C4 */ uint32 ukn0C4; - /* +0x0C8 */ uint32 ukn0C8; - /* +0x0CC */ uint32 ukn0CC; - /* +0x0D0 */ uint8 appSpecificData[0x14]; - /* +0x0E4 */ uint8 ukn0E4; - /* +0x0E5 */ uint8 _paddingE5; - /* +0x0E6 */ uint16 uknStr[0x80]; // game mode description (could be larger) - /* +0x1E6 */ uint8 _padding1E6[0x1EC - 0x1E6]; + /* +0x0A8 */ GameKey gameKey; + /* +0x0B8 */ GameMode gameMode; + /* +0x0E4 */ CafeWideString<0x82> gameModeDescription; + /* +0x1E8 */ Profile profile1E8; // how does it differ from the one at 0xA0? Returned by GetFriendPresence /* +0x1EC */ uint8 isOnline; /* +0x1ED */ uint8 _padding1ED[3]; // some other sub struct? - /* +0x1F0 */ uint8 ukn1F0; - /* +0x1F1 */ uint8 _padding1F1; - /* +0x1F2 */ uint16be statusMessage[16 + 1]; // pops up every few seconds in friend list (ingame character name?) - /* +0x214 */ uint8 _padding214[4]; - /* +0x218 */ fpdDate_t uknDate218; - /* +0x220 */ fpdDate_t lastOnline; + /* +0x1F0 */ char comment[36]; // pops up every few seconds in friend list + /* +0x214 */ uint32be _padding214; + /* +0x218 */ FPDDate approvalTime; + /* +0x220 */ FPDDate lastOnline; }friendExtraData; struct { - /* +0x0A0 */ uint64 messageId; // guessed + /* +0x0A0 */ uint64be messageId; // guessed. If 0, then relationship is FRIENDSHIP_REQUEST_OUT, otherwise FRIENDSHIP_REQUEST_IN /* +0x0A8 */ uint8 ukn0A8; /* +0x0A9 */ uint8 ukn0A9; // comment language? (guessed) /* +0x0AA */ uint16be comment[0x40]; @@ -75,26 +111,23 @@ namespace iosu /* +0x150 */ uint64 gameKeyTitleId; /* +0x158 */ uint16be gameKeyUkn; /* +0x15A */ uint8 _padding[6]; - /* +0x160 */ fpdDate_t uknData0; - /* +0x168 */ fpdDate_t uknData1; + /* +0x160 */ FPDDate uknData0; + /* +0x168 */ FPDDate uknData1; }requestExtraData; }; - }friendData_t; - - static_assert(sizeof(friendData_t) == 0x228, ""); - static_assert(offsetof(friendData_t, nnid) == 0x00C, ""); - static_assert(offsetof(friendData_t, friendExtraData.gameKeyTitleId) == 0x0A8, ""); - static_assert(offsetof(friendData_t, friendExtraData.appSpecificData) == 0x0D0, ""); - static_assert(offsetof(friendData_t, friendExtraData.uknStr) == 0x0E6, ""); - static_assert(offsetof(friendData_t, friendExtraData.ukn1F0) == 0x1F0, ""); + }; + static_assert(sizeof(FriendData) == 0x228); + static_assert(offsetof(FriendData, friendExtraData.gameKey) == 0x0A8); + static_assert(offsetof(FriendData, friendExtraData.gameModeDescription) == 0x0E4); + static_assert(offsetof(FriendData, friendExtraData.comment) == 0x1F0); - static_assert(offsetof(friendData_t, requestExtraData.messageId) == 0x0A0, ""); - static_assert(offsetof(friendData_t, requestExtraData.comment) == 0x0AA, ""); - static_assert(offsetof(friendData_t, requestExtraData.uknMessage) == 0x12C, ""); - static_assert(offsetof(friendData_t, requestExtraData.gameKeyTitleId) == 0x150, ""); - static_assert(offsetof(friendData_t, requestExtraData.uknData1) == 0x168, ""); + static_assert(offsetof(FriendData, requestExtraData.messageId) == 0x0A0); + static_assert(offsetof(FriendData, requestExtraData.comment) == 0x0AA); + static_assert(offsetof(FriendData, requestExtraData.uknMessage) == 0x12C); + static_assert(offsetof(FriendData, requestExtraData.gameKeyTitleId) == 0x150); + static_assert(offsetof(FriendData, requestExtraData.uknData1) == 0x168); - typedef struct + struct FriendBasicInfo { /* +0x00 */ uint32be pid; /* +0x04 */ char nnid[0x11]; @@ -104,17 +137,17 @@ namespace iosu /* +0x2E */ uint8 ukn2E; // bool option /* +0x2F */ uint8 ukn2F; /* +0x30 */ uint8 miiData[0x60]; - /* +0x90 */ fpdDate_t uknDate90; - }friendBasicInfo_t; // size is 0x98 + /* +0x90 */ FPDDate uknDate90; + }; - static_assert(sizeof(friendBasicInfo_t) == 0x98, ""); - static_assert(offsetof(friendBasicInfo_t, nnid) == 0x04, ""); - static_assert(offsetof(friendBasicInfo_t, ukn15) == 0x15, ""); - static_assert(offsetof(friendBasicInfo_t, screenname) == 0x18, ""); - static_assert(offsetof(friendBasicInfo_t, ukn2E) == 0x2E, ""); - static_assert(offsetof(friendBasicInfo_t, miiData) == 0x30, ""); + static_assert(sizeof(FriendBasicInfo) == 0x98); + static_assert(offsetof(FriendBasicInfo, nnid) == 0x04); + static_assert(offsetof(FriendBasicInfo, ukn15) == 0x15); + static_assert(offsetof(FriendBasicInfo, screenname) == 0x18); + static_assert(offsetof(FriendBasicInfo, ukn2E) == 0x2E); + static_assert(offsetof(FriendBasicInfo, miiData) == 0x30); - typedef struct + struct FriendRequest { /* +0x000 */ uint32be pid; /* +0x004 */ uint8 nnid[17]; // guessed type @@ -125,7 +158,7 @@ namespace iosu /* +0x02E */ uint8 ukn2E; // bool option /* +0x02F */ uint8 ukn2F; // ukn /* +0x030 */ uint8 miiData[0x60]; - /* +0x090 */ fpdDate_t uknDate; + /* +0x090 */ FPDDate uknDate; /* +0x098 */ uint64 ukn98; /* +0x0A0 */ uint8 isMarkedAsReceived; /* +0x0A1 */ uint8 uknA1; @@ -136,216 +169,98 @@ namespace iosu /* +0x148 */ uint64 gameKeyTitleId; /* +0x150 */ uint16be gameKeyUkn; /* +0x152 */ uint8 _padding152[6]; - /* +0x158 */ fpdDate_t uknDate2; - /* +0x160 */ fpdDate_t expireDate; - }friendRequest_t; + /* +0x158 */ FPDDate uknDate2; + /* +0x160 */ FPDDate expireDate; + }; - static_assert(sizeof(friendRequest_t) == 0x168, ""); - static_assert(offsetof(friendRequest_t, uknDate) == 0x090, ""); - static_assert(offsetof(friendRequest_t, message) == 0x0A2, ""); - static_assert(offsetof(friendRequest_t, uknString2) == 0x124, ""); - static_assert(offsetof(friendRequest_t, gameKeyTitleId) == 0x148, ""); + static_assert(sizeof(FriendRequest) == 0x168); + static_assert(offsetof(FriendRequest, uknDate) == 0x090); + static_assert(offsetof(FriendRequest, message) == 0x0A2); + static_assert(offsetof(FriendRequest, uknString2) == 0x124); + static_assert(offsetof(FriendRequest, gameKeyTitleId) == 0x148); - typedef struct + struct FriendPresence { - /* +0x00 */ uint32be joinFlagMask; - /* +0x04 */ uint32be matchmakeType; - /* +0x08 */ uint32be joinGameId; - /* +0x0C */ uint32be joinGameMode; - /* +0x10 */ uint32be hostPid; - /* +0x14 */ uint32be groupId; - /* +0x18 */ uint8 appSpecificData[0x14]; - }gameMode_t; - - static_assert(sizeof(gameMode_t) == 0x2C, ""); - - typedef struct - { - gameMode_t gameMode; - /* +0x2C */ uint8 region; - /* +0x2D */ uint8 regionSubcode; - /* +0x2E */ uint8 platform; - /* +0x2F */ uint8 _padding2F; + GameMode gameMode; + /* +0x2C */ Profile profile; /* +0x30 */ uint8 isOnline; /* +0x31 */ uint8 isValid; /* +0x32 */ uint8 padding[2]; // guessed - }friendPresence_t; + }; + static_assert(sizeof(FriendPresence) == 0x34); + static_assert(offsetof(FriendPresence, isOnline) == 0x30); - static_assert(sizeof(friendPresence_t) == 0x34, ""); - static_assert(offsetof(friendPresence_t, region) == 0x2C, ""); - static_assert(offsetof(friendPresence_t, isOnline) == 0x30, ""); + struct FPDNotification + { + betype type; + betype pid; + }; + static_assert(sizeof(FPDNotification) == 8); + + struct FPDPreference + { + uint8be showOnline; // show online status to others + uint8be showGame; // show played game to others + uint8be blockFriendRequests; // block friend requests + uint8be ukn; // probably padding? + }; + static_assert(sizeof(FPDPreference) == 4); static const int RELATIONSHIP_INVALID = 0; static const int RELATIONSHIP_FRIENDREQUEST_OUT = 1; static const int RELATIONSHIP_FRIENDREQUEST_IN = 2; static const int RELATIONSHIP_FRIEND = 3; - typedef struct + static const int GAMEMODE_MAX_MESSAGE_LENGTH = 0x80; // limit includes null-terminator character, so only 0x7F actual characters can be used + + enum class FPD_REQUEST_ID { - uint32 requestCode; - union - { - struct - { - MEMPTR ptr; - }common; - struct - { - MPTR funcPtr; - MPTR custom; - }loginAsync; - struct - { - MEMPTR pidList; - uint32 startIndex; - uint32 maxCount; - }getFriendList; - struct - { - MEMPTR friendData; - MEMPTR pidList; - uint32 count; - }getFriendListEx; - struct - { - MEMPTR friendRequest; - MEMPTR pidList; - uint32 count; - }getFriendRequestListEx; - struct - { - uint32 pid; - MPTR funcPtr; - MPTR custom; - }addOrRemoveFriend; - struct - { - uint64 messageId; - MPTR funcPtr; - MPTR custom; - }cancelOrAcceptFriendRequest; - struct - { - uint32 pid; - MEMPTR message; - MPTR funcPtr; - MPTR custom; - }addFriendRequest; - struct - { - MEMPTR messageIdList; - uint32 count; - MPTR funcPtr; - MPTR custom; - }markFriendRequest; - struct - { - MEMPTR basicInfo; - MEMPTR pidList; - sint32 count; - MPTR funcPtr; - MPTR custom; - }getBasicInfo; - struct - { - uint32 notificationMask; - MPTR funcPtr; - MPTR custom; - }setNotificationHandler; - struct - { - MEMPTR accountIds; - MEMPTR pidList; - sint32 count; - }getFriendAccountId; - struct - { - MEMPTR nameList; - MEMPTR pidList; - sint32 count; - bool replaceNonAscii; - MEMPTR languageList; - }getFriendScreenname; - struct - { - uint8* miiList; - MEMPTR pidList; - sint32 count; - }getFriendMii; - struct - { - uint8* presenceList; - MEMPTR pidList; - sint32 count; - }getFriendPresence; - struct - { - uint8* relationshipList; - MEMPTR pidList; - sint32 count; - }getFriendRelationship; - struct - { - MEMPTR gameMode; - MEMPTR gameModeMessage; - }updateGameMode; - }; - - // output - uint32 returnCode; // return value - union - { - struct - { - uint32 numReturnedCount; - }resultGetFriendList; - struct - { - uint32 u32; - }resultU32; - }; - }iosuFpdCemuRequest_t; - - // custom dev/fpd protocol (Cemu only) - #define IOSU_FPD_REQUEST_CEMU (0xEE) - - // FPD request Cemu subcodes - enum - { - _IOSU_FPD_NONE, - IOSU_FPD_INITIALIZE, - IOSU_FPD_SET_NOTIFICATION_HANDLER, - IOSU_FPD_LOGIN_ASYNC, - IOSU_FPD_IS_ONLINE, - IOSU_FPD_IS_PREFERENCE_VALID, - - IOSU_FPD_UPDATE_GAMEMODE, - - IOSU_FPD_GET_MY_PRINCIPAL_ID, - IOSU_FPD_GET_MY_ACCOUNT_ID, - IOSU_FPD_GET_MY_MII, - IOSU_FPD_GET_MY_SCREENNAME, - - IOSU_FPD_GET_FRIEND_ACCOUNT_ID, - IOSU_FPD_GET_FRIEND_SCREENNAME, - IOSU_FPD_GET_FRIEND_MII, - IOSU_FPD_GET_FRIEND_PRESENCE, - IOSU_FPD_GET_FRIEND_RELATIONSHIP, - - IOSU_FPD_GET_FRIEND_LIST, - IOSU_FPD_GET_FRIENDREQUEST_LIST, - IOSU_FPD_GET_FRIEND_LIST_ALL, - IOSU_FPD_GET_FRIEND_LIST_EX, - IOSU_FPD_GET_FRIENDREQUEST_LIST_EX, - IOSU_FPD_ADD_FRIEND, - IOSU_FPD_ADD_FRIEND_REQUEST, - IOSU_FPD_REMOVE_FRIEND_ASYNC, - IOSU_FPD_CANCEL_FRIEND_REQUEST_ASYNC, - IOSU_FPD_ACCEPT_FRIEND_REQUEST_ASYNC, - IOSU_FPD_MARK_FRIEND_REQUEST_AS_RECEIVED_ASYNC, - IOSU_FPD_GET_BASIC_INFO_ASYNC, + LoginAsync = 0x2775, + HasLoggedIn = 0x2777, + IsOnline = 0x2778, + GetMyPrincipalId = 0x27D9, + GetMyAccountId = 0x27DA, + GetMyScreenName = 0x27DB, + GetMyMii = 0x27DC, + GetMyProfile = 0x27DD, + GetMyPreference = 0x27DE, + GetMyPresence = 0x27DF, + IsPreferenceValid = 0x27E0, + GetFriendList = 0x283D, + GetFriendListAll = 0x283E, + GetFriendAccountId = 0x283F, + GetFriendScreenName = 0x2840, + GetFriendPresence = 0x2845, + GetFriendRelationship = 0x2846, + GetFriendMii = 0x2841, + GetBlackList = 0x28A1, + GetFriendRequestList = 0x2905, + UpdateGameModeVariation1 = 0x2969, // there seem to be two different requestIds for the 2-param and 3-param version of UpdateGameMode, + UpdateGameModeVariation2 = 0x296A, // but the third parameter is never used and the same handler is used for both + AddFriendAsyncByPid = 0x29CD, + AddFriendAsyncByXXX = 0x29CE, // probably by name? + GetRequestBlockSettingAsync = 0x2B5D, + GetMyComment = 0x4EE9, + GetMyPlayingGame = 0x4EEA, + CheckSettingStatusAsync = 0x7596, + GetFriendListEx = 0x75F9, + GetFriendRequestListEx = 0x76C1, + UpdatePreferenceAsync = 0x7727, + RemoveFriendAsync = 0x7789, + DeleteFriendFlagsAsync = 0x778A, + AddFriendRequestByPlayRecordAsync = 0x778B, + CancelFriendRequestAsync = 0x778C, + AcceptFriendRequestAsync = 0x7851, + DeleteFriendRequestAsync = 0x7852, + MarkFriendRequestsAsReceivedAsync = 0x7854, + GetBasicInfoAsync = 0x7919, + SetLedEventMask = 0x9D0B, + SetNotificationMask = 0x15ff5, + GetNotificationAsync = 0x15FF6, }; - void Initialize(); + using FriendPID = uint32; + + IOSUModule* GetModule(); } } \ No newline at end of file diff --git a/src/Cafe/IOSU/nn/iosu_nn_service.cpp b/src/Cafe/IOSU/nn/iosu_nn_service.cpp index ade1fa2b..b3b2d4c9 100644 --- a/src/Cafe/IOSU/nn/iosu_nn_service.cpp +++ b/src/Cafe/IOSU/nn/iosu_nn_service.cpp @@ -1,5 +1,6 @@ #include "iosu_nn_service.h" #include "../kernel/iosu_kernel.h" +#include "util/helpers/helpers.h" using namespace iosu::kernel; @@ -7,6 +8,132 @@ namespace iosu { namespace nn { + /* IPCSimpleService */ + void IPCSimpleService::Start() + { + if (m_isRunning.exchange(true)) + return; + m_threadInitialized = false; + m_requestStop = false; + m_serviceThread = std::thread(&IPCSimpleService::ServiceThread, this); + while (!m_threadInitialized) std::this_thread::sleep_for(std::chrono::milliseconds(10)); + StartService(); + } + + void IPCSimpleService::Stop() + { + if (!m_isRunning.exchange(false)) + return; + m_requestStop = true; + StopService(); + if(m_timerId != IOSInvalidTimerId) + IOS_DestroyTimer(m_timerId); + m_timerId = IOSInvalidTimerId; + IOS_SendMessage(m_msgQueueId, 0, 0); // wake up thread + m_serviceThread.join(); + } + + void IPCSimpleService::ServiceThread() + { + if(!GetThreadName().empty()) + SetThreadName(GetThreadName().c_str()); + m_msgQueueId = IOS_CreateMessageQueue(_m_msgBuffer.GetPtr(), _m_msgBuffer.GetCount()); + cemu_assert(!IOS_ResultIsError((IOS_ERROR)m_msgQueueId)); + IOS_ERROR r = IOS_RegisterResourceManager(m_devicePath.c_str(), m_msgQueueId); + cemu_assert(!IOS_ResultIsError(r)); + m_threadInitialized = true; + while (true) + { + IOSMessage msg; + r = IOS_ReceiveMessage(m_msgQueueId, &msg, 0); + cemu_assert(!IOS_ResultIsError(r)); + if (msg == 0) + { + cemu_assert_debug(m_requestStop); + break; + } + else if(msg == 1) + { + TimerUpdate(); + continue; + } + IPCCommandBody* cmd = MEMPTR(msg).GetPtr(); + if (cmd->cmdId == IPCCommandId::IOS_OPEN) + { + void* clientObject = CreateClientObject(); + if(clientObject == nullptr) + { + cemuLog_log(LogType::Force, "IPCSimpleService[{}]: Maximum handle count reached or handle rejected", m_devicePath); + IOS_ResourceReply(cmd, IOS_ERROR_MAXIMUM_REACHED); + continue; + } + IOSDevHandle newHandle = GetFreeHandle(); + m_clientObjects[newHandle] = clientObject; + IOS_ResourceReply(cmd, (IOS_ERROR)newHandle); + continue; + } + else if (cmd->cmdId == IPCCommandId::IOS_CLOSE) + { + void* clientObject = GetClientObjectByHandle(cmd->devHandle); + if (clientObject) + DestroyClientObject(clientObject); + IOS_ResourceReply(cmd, IOS_ERROR_OK); + continue; + } + else if (cmd->cmdId == IPCCommandId::IOS_IOCTLV) + { + void* clientObject = GetClientObjectByHandle(cmd->devHandle); + if (!clientObject) + { + cemuLog_log(LogType::Force, "IPCSimpleService[{}]: Invalid IPC handle", m_devicePath); + IOS_ResourceReply(cmd, IOS_ERROR_INVALID); + continue; + } + uint32 requestId = cmd->args[0]; + uint32 numIn = cmd->args[1]; + uint32 numOut = cmd->args[2]; + IPCIoctlVector* vec = MEMPTR{ cmd->args[3] }.GetPtr(); + IPCIoctlVector* vecIn = vec + 0; // the ordering of vecIn/vecOut differs from IPCService + IPCIoctlVector* vecOut = vec + numIn; + m_delayResponse = false; + m_activeCmd = cmd; + uint32 result = ServiceCall(clientObject, requestId, vecIn, numIn, vecOut, numOut); + if (!m_delayResponse) + IOS_ResourceReply(cmd, (IOS_ERROR)result); + m_activeCmd = nullptr; + continue; + } + else + { + cemuLog_log(LogType::Force, "IPCSimpleService[{}]: Unsupported IPC cmdId {}", m_devicePath, (uint32)cmd->cmdId.value()); + cemu_assert_unimplemented(); + IOS_ResourceReply(cmd, IOS_ERROR_INVALID); + } + } + IOS_DestroyMessageQueue(m_msgQueueId); + m_threadInitialized = false; + } + + void IPCSimpleService::SetTimerUpdate(uint32 milliseconds) + { + if(m_timerId != IOSInvalidTimerId) + IOS_DestroyTimer(m_timerId); + m_timerId = IOS_CreateTimer(milliseconds * 1000, milliseconds * 1000, m_msgQueueId, 1); + } + + IPCCommandBody* IPCSimpleService::ServiceCallDelayCurrentResponse() + { + cemu_assert_debug(m_activeCmd); + m_delayResponse = true; + return m_activeCmd; + } + + void IPCSimpleService::ServiceCallAsyncRespond(IPCCommandBody* response, uint32 r) + { + IOS_ResourceReply(response, (IOS_ERROR)r); + } + + /* IPCService */ void IPCService::Start() { if (m_isRunning.exchange(true)) @@ -83,4 +210,4 @@ namespace iosu m_threadInitialized = false; } }; -}; \ No newline at end of file +}; diff --git a/src/Cafe/IOSU/nn/iosu_nn_service.h b/src/Cafe/IOSU/nn/iosu_nn_service.h index 7f06139f..d50a0794 100644 --- a/src/Cafe/IOSU/nn/iosu_nn_service.h +++ b/src/Cafe/IOSU/nn/iosu_nn_service.h @@ -8,6 +8,71 @@ namespace iosu { namespace nn { + // a simple service interface which wraps handle management and Ioctlv/IoctlvAsync + class IPCSimpleService + { + public: + IPCSimpleService(std::string_view devicePath) : m_devicePath(devicePath) {}; + virtual ~IPCSimpleService() {}; + + virtual void StartService() {}; + virtual void StopService() {}; + + virtual std::string GetThreadName() = 0; + + virtual void* CreateClientObject() = 0; + virtual void DestroyClientObject(void* clientObject) = 0; + virtual uint32 ServiceCall(void* clientObject, uint32 requestId, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) = 0; + virtual void TimerUpdate() {}; + + IPCCommandBody* ServiceCallDelayCurrentResponse(); + static void ServiceCallAsyncRespond(IPCCommandBody* response, uint32 r); + + void Start(); + void Stop(); + + void SetTimerUpdate(uint32 milliseconds); + + private: + void ServiceThread(); + + IOSDevHandle GetFreeHandle() + { + while(m_clientObjects.find(m_nextHandle) != m_clientObjects.end() || m_nextHandle == 0) + { + m_nextHandle++; + m_nextHandle &= 0x7FFFFFFF; + } + IOSDevHandle newHandle = m_nextHandle; + m_nextHandle++; + m_nextHandle &= 0x7FFFFFFF; + return newHandle; + } + + void* GetClientObjectByHandle(IOSDevHandle handle) const + { + auto it = m_clientObjects.find(handle); + if(it == m_clientObjects.end()) + return nullptr; + return it->second; + } + + std::string m_devicePath; + std::thread m_serviceThread; + std::atomic_bool m_requestStop{false}; + std::atomic_bool m_isRunning{false}; + std::atomic_bool m_threadInitialized{ false }; + std::unordered_map m_clientObjects; + IOSDevHandle m_nextHandle{1}; + IOSTimerId m_timerId{IOSInvalidTimerId}; + + IPCCommandBody* m_activeCmd{nullptr}; + bool m_delayResponse{false}; + + IOSMsgQueueId m_msgQueueId; + SysAllocator _m_msgBuffer; + }; + struct IPCServiceRequest { uint32be ukn00; @@ -23,6 +88,7 @@ namespace iosu uint32be nnResultCode; }; + // a complex service interface which wraps Ioctlv and adds an additional service channel, used by /dev/act, ? class IPCService { public: @@ -60,5 +126,6 @@ namespace iosu IOSMsgQueueId m_msgQueueId; SysAllocator _m_msgBuffer; }; + }; }; \ No newline at end of file diff --git a/src/Cafe/OS/RPL/rpl.cpp b/src/Cafe/OS/RPL/rpl.cpp index 0e6d153f..f0703290 100644 --- a/src/Cafe/OS/RPL/rpl.cpp +++ b/src/Cafe/OS/RPL/rpl.cpp @@ -724,7 +724,7 @@ uint32 RPLLoader_MakePPCCallable(void(*ppcCallableExport)(PPCInterpreter_t* hCPU if (it != g_map_callableExports.end()) return it->second; // get HLE function index - sint32 functionIndex = PPCInterpreter_registerHLECall(ppcCallableExport); + sint32 functionIndex = PPCInterpreter_registerHLECall(ppcCallableExport, fmt::format("PPCCallback{:x}", (uintptr_t)ppcCallableExport)); MPTR codeAddr = memory_getVirtualOffsetFromPointer(RPLLoader_AllocateTrampolineCodeSpace(4)); uint32 opcode = (1 << 26) | functionIndex; memory_write(codeAddr, opcode); diff --git a/src/Cafe/OS/common/OSCommon.cpp b/src/Cafe/OS/common/OSCommon.cpp index 7e11ea13..5aedd197 100644 --- a/src/Cafe/OS/common/OSCommon.cpp +++ b/src/Cafe/OS/common/OSCommon.cpp @@ -85,6 +85,7 @@ void osLib_addFunctionInternal(const char* libraryName, const char* functionName uint32 funcHashA, funcHashB; osLib_generateHashFromName(libraryName, &libHashA, &libHashB); osLib_generateHashFromName(functionName, &funcHashA, &funcHashB); + std::string hleName = fmt::format("{}.{}", libraryName, functionName); // if entry already exists, update it for (auto& it : *s_osFunctionTable) { @@ -93,11 +94,11 @@ void osLib_addFunctionInternal(const char* libraryName, const char* functionName it.funcHashA == funcHashA && it.funcHashB == funcHashB) { - it.hleFunc = PPCInterpreter_registerHLECall(osFunction); + it.hleFunc = PPCInterpreter_registerHLECall(osFunction, hleName); return; } } - s_osFunctionTable->emplace_back(libHashA, libHashB, funcHashA, funcHashB, fmt::format("{}.{}", libraryName, functionName), PPCInterpreter_registerHLECall(osFunction)); + s_osFunctionTable->emplace_back(libHashA, libHashB, funcHashA, funcHashB, hleName, PPCInterpreter_registerHLECall(osFunction, hleName)); } extern "C" DLLEXPORT void osLib_registerHLEFunction(const char* libraryName, const char* functionName, void(*osFunction)(PPCInterpreter_t * hCPU)) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index 916563c8..1e6eb92b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -912,8 +912,8 @@ namespace coreinit sint32 FSOpenFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandleDepr_t* fileHandle, uint32 errHandling) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSOpenFileAsync(fsClient, fsCmdBlock, path, mode, fileHandle, errHandling, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSOpenFileAsync(fsClient, fsCmdBlock, path, mode, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } @@ -941,8 +941,8 @@ namespace coreinit sint32 FSOpenFileEx(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, uint32 createMode, uint32 openFlag, uint32 preallocSize, FSFileHandleDepr_t* fileHandle, uint32 errHandling) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSOpenFileExAsync(fsClient, fsCmdBlock, path, mode, createMode, openFlag, preallocSize, fileHandle, errHandling, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSOpenFileExAsync(fsClient, fsCmdBlock, path, mode, createMode, openFlag, preallocSize, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } @@ -975,8 +975,8 @@ namespace coreinit sint32 FSCloseFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errHandling) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSCloseFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSCloseFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } @@ -1009,8 +1009,8 @@ namespace coreinit sint32 FSFlushFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errHandling) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSFlushFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSFlushFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } @@ -1090,7 +1090,7 @@ namespace coreinit sint32 FSReadFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSReadFileAsync(fsClient, fsCmdBlock, dst, size, count, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1105,7 +1105,7 @@ namespace coreinit sint32 FSReadFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSReadFileWithPosAsync(fsClient, fsCmdBlock, dst, size, count, filePos, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1183,7 +1183,7 @@ namespace coreinit sint32 FSWriteFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSWriteFileAsync(fsClient, fsCmdBlock, src, size, count, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1196,7 +1196,7 @@ namespace coreinit sint32 FSWriteFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSWriteFileWithPosAsync(fsClient, fsCmdBlock, src, size, count, filePos, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1228,7 +1228,7 @@ namespace coreinit { // used by games: Mario Kart 8 StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSSetPosFileAsync(fsClient, fsCmdBlock, fileHandle, filePos, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1259,7 +1259,7 @@ namespace coreinit sint32 FSGetPosFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetPosFileAsync(fsClient, fsCmdBlock, fileHandle, returnedFilePos, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1307,8 +1307,8 @@ namespace coreinit sint32 FSOpenDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSOpenDirAsync(fsClient, fsCmdBlock, path, dirHandleOut, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSOpenDirAsync(fsClient, fsCmdBlock, path, dirHandleOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1337,8 +1337,8 @@ namespace coreinit sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSReadDirAsync(fsClient, fsCmdBlock, dirHandle, dirEntryOut, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSReadDirAsync(fsClient, fsCmdBlock, dirHandle, dirEntryOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1367,8 +1367,8 @@ namespace coreinit sint32 FSCloseDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSCloseDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSCloseDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1400,8 +1400,8 @@ namespace coreinit sint32 FSRewindDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSRewindDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSRewindDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1435,7 +1435,7 @@ namespace coreinit sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSAppendFileAsync(fsClient, fsCmdBlock, size, count, fileHandle, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1467,7 +1467,7 @@ namespace coreinit sint32 FSTruncateFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSTruncateFileAsync(fsClient, fsCmdBlock, fileHandle, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1531,7 +1531,7 @@ namespace coreinit sint32 FSRename(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSRenameAsync(fsClient, fsCmdBlock, srcPath, dstPath, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1582,8 +1582,8 @@ namespace coreinit sint32 FSRemove(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSRemoveAsync(fsClient, fsCmdBlock, filePath, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSRemoveAsync(fsClient, fsCmdBlock, filePath, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1634,8 +1634,8 @@ namespace coreinit sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSMakeDirAsync(fsClient, fsCmdBlock, path, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSMakeDirAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1683,8 +1683,8 @@ namespace coreinit sint32 FSChangeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSChangeDirAsync(fsClient, fsCmdBlock, path, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSChangeDirAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1718,8 +1718,8 @@ namespace coreinit sint32 FSGetCwd(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSGetCwdAsync(fsClient, fsCmdBlock, dirPathOut, dirPathMaxLen, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSGetCwdAsync(fsClient, fsCmdBlock, dirPathOut, dirPathMaxLen, errorMask, &asyncParams); auto r = __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); return r; } @@ -1763,8 +1763,8 @@ namespace coreinit sint32 FSFlushQuota(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSFlushQuotaAsync(fsClient, fsCmdBlock, path, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSFlushQuotaAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1821,8 +1821,8 @@ namespace coreinit sint32 FSGetStat(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSStat_t* statOut, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSGetStatAsync(fsClient, fsCmdBlock, path, statOut, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSGetStatAsync(fsClient, fsCmdBlock, path, statOut, errorMask, &asyncParams); sint32 ret = __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); return ret; } @@ -1858,8 +1858,8 @@ namespace coreinit sint32 FSGetStatFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, FSStat_t* statOut, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSGetStatFileAsync(fsClient, fsCmdBlock, fileHandle, statOut, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSGetStatFileAsync(fsClient, fsCmdBlock, fileHandle, statOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1873,8 +1873,8 @@ namespace coreinit sint32 FSGetFreeSpaceSize(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSGetFreeSpaceSizeAsync(fsClient, fsCmdBlock, path, returnedFreeSize, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSGetFreeSpaceSizeAsync(fsClient, fsCmdBlock, path, returnedFreeSize, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } @@ -1908,8 +1908,8 @@ namespace coreinit sint32 FSIsEof(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask) { StackAllocator asyncParams; - __FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams); - sint32 fsAsyncRet = FSIsEofAsync(fsClient, fsCmdBlock, fileHandle, errorMask, asyncParams); + __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); + sint32 fsAsyncRet = FSIsEofAsync(fsClient, fsCmdBlock, fileHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp b/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp index ef847f26..be3cb300 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp @@ -355,23 +355,6 @@ namespace coreinit IOS_ERROR _IPCDriver_SetupCmd_IOSIoctlv(IPCDriver& ipcDriver, IPCResourceBufferDescriptor* requestDescriptor, uint32 requestId, uint32 numIn, uint32 numOut, IPCIoctlVector* vec) { IPCCommandBody& cmdBody = requestDescriptor->resourcePtr->commandBody; - // verify input and output vectors - IPCIoctlVector* vecIn = vec; - IPCIoctlVector* vecOut = vec + numIn; - for (uint32 i = 0; i < numIn; i++) - { - if (vecIn[i].baseVirt == nullptr && vecIn[i].size != 0) - return IOS_ERROR_INVALID_ARG; - vecIn[i].basePhys = vecIn[i].baseVirt; - vecIn[i].baseVirt = nullptr; - } - for (uint32 i = 0; i < numOut; i++) - { - if (vecOut[i].baseVirt == nullptr && vecOut[i].size != 0) - return IOS_ERROR_INVALID_ARG; - vecOut[i].basePhys = vecOut[i].baseVirt; - vecOut[i].baseVirt = nullptr; - } // set args cmdBody.ppcVirt0 = MEMPTR(vec).GetMPTR(); cmdBody.args[0] = requestId; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp index d5cd0018..2d7468cf 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp @@ -195,7 +195,28 @@ namespace coreinit else if ((formatStr[0] == 'l' && formatStr[1] == 'l' && (formatStr[2] == 'x' || formatStr[2] == 'X'))) { formatStr += 3; - // number (64bit) + // double (64bit) + strncpy(tempFormat, formatStart, std::min((std::ptrdiff_t)sizeof(tempFormat) - 1, formatStr - formatStart)); + if ((formatStr - formatStart) < sizeof(tempFormat)) + tempFormat[(formatStr - formatStart)] = '\0'; + else + tempFormat[sizeof(tempFormat) - 1] = '\0'; + if (integerParamIndex & 1) + integerParamIndex++; + sint32 tempLen = sprintf(tempStr, tempFormat, PPCInterpreter_getCallParamU64(hCPU, integerParamIndex)); + integerParamIndex += 2; + for (sint32 i = 0; i < tempLen; i++) + { + if (writeIndex >= maxLength) + break; + strOut[writeIndex] = tempStr[i]; + writeIndex++; + } + } + else if ((formatStr[0] == 'l' && formatStr[1] == 'l' && formatStr[2] == 'd')) + { + formatStr += 3; + // signed integer (64bit) strncpy(tempFormat, formatStart, std::min((std::ptrdiff_t)sizeof(tempFormat) - 1, formatStr - formatStart)); if ((formatStr - formatStart) < sizeof(tempFormat)) tempFormat[(formatStr - formatStart)] = '\0'; diff --git a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp index d88a29d4..024965fd 100644 --- a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp +++ b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp @@ -859,10 +859,10 @@ namespace H264 return H264DEC_STATUS::SUCCESS; } StackAllocator executeDoneEvent; - coreinit::OSInitEvent(executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); std::vector results; auto asyncTask = std::async(std::launch::async, _async_H264DECEnd, executeDoneEvent.GetPointer(), session, ctx, &results); - coreinit::OSWaitEvent(executeDoneEvent); + coreinit::OSWaitEvent(&executeDoneEvent); _ReleaseDecoderSession(session); if (!results.empty()) { @@ -977,9 +977,9 @@ namespace H264 StackAllocator stack_decodedFrameResult; for (sint32 i = 0; i < outputFrameCount; i++) - stack_resultPtrArray[i] = stack_decodedFrameResult + i; + stack_resultPtrArray[i] = &stack_decodedFrameResult + i; - H264DECFrameOutput* frameOutput = stack_decodedFrameResult + 0; + H264DECFrameOutput* frameOutput = &stack_decodedFrameResult + 0; memset(frameOutput, 0x00, sizeof(H264DECFrameOutput)); frameOutput->imagePtr = (uint8*)decodeResult.imageOutput; frameOutput->result = 100; @@ -1022,10 +1022,10 @@ namespace H264 return 0; } StackAllocator executeDoneEvent; - coreinit::OSInitEvent(executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); H264AVCDecoder::DecodeResult decodeResult; - auto asyncTask = std::async(std::launch::async, _async_H264DECExecute, executeDoneEvent.GetPointer(), session, ctx, imageOutput , &decodeResult); - coreinit::OSWaitEvent(executeDoneEvent); + auto asyncTask = std::async(std::launch::async, _async_H264DECExecute, &executeDoneEvent, session, ctx, imageOutput , &decodeResult); + coreinit::OSWaitEvent(&executeDoneEvent); _ReleaseDecoderSession(session); if(decodeResult.frameReady) H264DoFrameOutputCallback(ctx, decodeResult); diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index 68109586..0fd9df5a 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -391,7 +391,7 @@ void nnActExport_GetMiiName(PPCInterpreter_t* hCPU) StackAllocator miiData; - uint32 r = nn::act::GetMiiEx(miiData, iosu::act::ACT_SLOT_CURRENT); + uint32 r = nn::act::GetMiiEx(&miiData, iosu::act::ACT_SLOT_CURRENT); // extract name sint32 miiNameLength = 0; for (sint32 i = 0; i < MII_FFL_NAME_LENGTH; i++) @@ -414,7 +414,7 @@ void nnActExport_GetMiiNameEx(PPCInterpreter_t* hCPU) StackAllocator miiData; - uint32 r = nn::act::GetMiiEx(miiData, slot); + uint32 r = nn::act::GetMiiEx(&miiData, slot); // extract name sint32 miiNameLength = 0; for (sint32 i = 0; i < MII_FFL_NAME_LENGTH; i++) diff --git a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp index e33b6369..53ab3eef 100644 --- a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp +++ b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp @@ -1,426 +1,554 @@ #include "Cafe/OS/common/OSCommon.h" -#include "Cafe/IOSU/legacy/iosu_ioctl.h" #include "Cafe/IOSU/legacy/iosu_act.h" #include "Cafe/IOSU/legacy/iosu_fpd.h" +#include "Cafe/IOSU/legacy/iosu_ioctl.h" // deprecated +#include "Cafe/IOSU/iosu_ipc_common.h" #include "Cafe/OS/libs/coreinit/coreinit_IOS.h" - -#define fpdPrepareRequest() \ -StackAllocator _buf_fpdRequest; \ -StackAllocator _buf_bufferVector; \ -iosu::fpd::iosuFpdCemuRequest_t* fpdRequest = _buf_fpdRequest.GetPointer(); \ -ioBufferVector_t* fpdBufferVector = _buf_bufferVector.GetPointer(); \ -memset(fpdRequest, 0, sizeof(iosu::fpd::iosuFpdCemuRequest_t)); \ -memset(fpdBufferVector, 0, sizeof(ioBufferVector_t)); \ -fpdBufferVector->buffer = (uint8*)fpdRequest; +#include "Cafe/OS/libs/coreinit/coreinit_IPC.h" +#include "Cafe/OS/libs/nn_common.h" +#include "util/ChunkedHeap/ChunkedHeap.h" +#include "Common/CafeString.h" namespace nn { namespace fp { + static const auto FPResult_OkZero = 0; + static const auto FPResult_Ok = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_FP, 0); + static const auto FPResult_InvalidIPCParam = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_FP, 0x680); + static const auto FPResult_RequestFailed = BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // figure out proper error code - struct + struct { - bool isInitialized; + uint32 initCounter; bool isAdminMode; + bool isLoggedIn; + IOSDevHandle fpdHandle; + SysAllocator fpMutex; + SysAllocator g_fpdAllocatorSpace; + VHeap* fpBufferHeap{nullptr}; + // PPC buffers for async notification query + SysAllocator notificationCount; + SysAllocator notificationBuffer; + bool getNotificationCalled{false}; + // notification handler + MEMPTR notificationHandler{nullptr}; + MEMPTR notificationHandlerParam{nullptr}; }g_fp = { }; - void Initialize() + class { - if (g_fp.isInitialized == false) + public: + void Init() { - g_fp.isInitialized = true; - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_INITIALIZE; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); + std::unique_lock _l(m_mtx); + g_fp.fpBufferHeap = new VHeap(g_fp.g_fpdAllocatorSpace.GetPtr(), g_fp.g_fpdAllocatorSpace.GetByteSize()); } - } - - - - void export_IsInitialized(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "Called nn_fp.IsInitialized"); - osLib_returnFromFunction(hCPU, g_fp.isInitialized ? 1 : 0); - } - - void export_Initialize(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "Called nn_fp.Initialize"); - - Initialize(); - - osLib_returnFromFunction(hCPU, 0); - } - - void export_InitializeAdmin(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "Called nn_fp.InitializeAdmin"); - Initialize(); - g_fp.isAdminMode = true; - osLib_returnFromFunction(hCPU, 0); - } - - void export_IsInitializedAdmin(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "nn_fp.IsInitializedAdmin()"); - osLib_returnFromFunction(hCPU, g_fp.isInitialized ? 1 : 0); - } - - void export_SetNotificationHandler(PPCInterpreter_t* hCPU) - { - ppcDefineParamU32(notificationMask, 0); - ppcDefineParamMPTR(funcMPTR, 1); - ppcDefineParamMPTR(customParam, 2); - - cemuLog_logDebug(LogType::Force, "nn_fp.SetNotificationHandler(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_SET_NOTIFICATION_HANDLER; - fpdRequest->setNotificationHandler.notificationMask = notificationMask; - fpdRequest->setNotificationHandler.funcPtr = funcMPTR; - fpdRequest->setNotificationHandler.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, 0); - } - - void export_LoginAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMPTR(funcPtr, 0); - ppcDefineParamMPTR(custom, 1); - cemuLog_logDebug(LogType::Force, "nn_fp.LoginAsync(0x{:08x},0x{:08x})", funcPtr, custom); - if (g_fp.isInitialized == false) + void Destroy() { - osLib_returnFromFunction(hCPU, 0xC0C00580); + std::unique_lock _l(m_mtx); + delete g_fp.fpBufferHeap; + } + + void* Allocate(uint32 size, uint32 alignment) + { + std::unique_lock _l(m_mtx); + void* p = g_fp.fpBufferHeap->alloc(size, 32); + uint32 heapSize, allocationSize, allocNum; + g_fp.fpBufferHeap->getStats(heapSize, allocationSize, allocNum); + return p; + } + + void Free(void* ptr) + { + std::unique_lock _l(m_mtx); + g_fp.fpBufferHeap->free(ptr); + } + + private: + std::mutex m_mtx; + }FPIpcBufferAllocator; + + class FPIpcContext { + static inline constexpr uint32 MAX_VEC_COUNT = 8; + public: + // use FP heap for this class + static void* operator new(size_t size) + { + return FPIpcBufferAllocator.Allocate(size, (uint32)alignof(FPIpcContext)); + } + + static void operator delete(void* ptr) + { + FPIpcBufferAllocator.Free(ptr); + } + + FPIpcContext(iosu::fpd::FPD_REQUEST_ID requestId) : m_requestId(requestId) + { + } + + ~FPIpcContext() + { + if(m_dataBuffer) + FPIpcBufferAllocator.Free(m_dataBuffer); + } + + void AddInput(void* ptr, uint32 size) + { + size_t vecIndex = GetVecInIndex(m_numVecIn); + m_vec[vecIndex].baseVirt = ptr; + m_vec[vecIndex].size = size; + m_numVecIn = m_numVecIn + 1; + } + + void AddOutput(void* ptr, uint32 size) + { + cemu_assert_debug(m_numVecIn == 0); // all outputs need to be added before any inputs + size_t vecIndex = GetVecOutIndex(m_numVecOut); + m_vec[vecIndex].baseVirt = ptr; + m_vec[vecIndex].size = size; + m_numVecOut = m_numVecOut + 1; + } + + uint32 Submit(std::unique_ptr owner) + { + InitSubmissionBuffer(); + // note: While generally, Ioctlv() usage has the order as input (app->IOSU) followed by output (IOSU->app), FP uses it the other way around + nnResult r = coreinit::IOS_Ioctlv(g_fp.fpdHandle, (uint32)m_requestId.value(), m_numVecOut, m_numVecIn, m_vec); + CopyBackOutputs(); + owner.reset(); + return r; + } + + nnResult SubmitAsync(std::unique_ptr owner, MEMPTR callbackFunc, MEMPTR callbackParam) + { + InitSubmissionBuffer(); + this->m_callbackFunc = callbackFunc; + this->m_callbackParam = callbackParam; + nnResult r = coreinit::IOS_IoctlvAsync(g_fp.fpdHandle, (uint32)m_requestId.value(), m_numVecOut, m_numVecIn, m_vec, MEMPTR(PPCInterpreter_makeCallableExportDepr(AsyncHandler)), MEMPTR(this)); + owner.release(); + return r; + } + + private: + size_t GetVecInIndex(uint8 inIndex) + { + return m_numVecOut + inIndex; + } + + size_t GetVecOutIndex(uint8 outIndex) + { + return outIndex; + } + + void InitSubmissionBuffer() + { + // allocate a chunk of memory to hold the input/output vectors and their data + uint32 vecOffset[MAX_VEC_COUNT]; + uint32 totalBufferSize = 0; + for(uint8 i=0; i(m_vec[vecIndex].baseVirt).GetPtr(), MEMPTR(m_vecOriginalAddress[vecIndex]).GetPtr(), m_vec[vecIndex].size); + } + } + + static void AsyncHandler(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(result, 0); + ppcDefineParamPtr(ipcCtx, FPIpcContext, 1); + ipcCtx->m_asyncResult = result; // store result in variable since FP callbacks pass a pointer to nnResult and not the value directly + ipcCtx->CopyBackOutputs(); + cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler BeforeCallback"); + PPCCoreCallback(ipcCtx->m_callbackFunc, &ipcCtx->m_asyncResult, ipcCtx->m_callbackParam); + cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler AfterCallback"); + delete ipcCtx; + osLib_returnFromFunction(hCPU, 0); + } + + void CopyBackOutputs() + { + if(m_numVecOut > 0) + { + // copy output from temporary output buffers to the original addresses + for(uint8 i=0; i m_requestId; + uint8be m_numVecIn{0}; + uint8be m_numVecOut{0}; + IPCIoctlVector m_vec[MAX_VEC_COUNT]; + MEMPTR m_vecOriginalAddress[MAX_VEC_COUNT]{}; + MEMPTR m_dataBuffer{nullptr}; + MEMPTR m_callbackFunc{nullptr}; + MEMPTR m_callbackParam{nullptr}; + betype m_asyncResult; + }; + + struct FPGlobalLock + { + FPGlobalLock() + { + coreinit::OSLockMutex(&g_fp.fpMutex); + } + ~FPGlobalLock() + { + coreinit::OSUnlockMutex(&g_fp.fpMutex); + } + }; + #define FP_API_BASE() if (g_fp.initCounter == 0) return 0xC0C00580; FPGlobalLock _fpLock; + #define FP_API_BASE_ZeroOnError() if (g_fp.initCounter == 0) return 0; FPGlobalLock _fpLock; + + nnResult Initialize() + { + FPGlobalLock _fpLock; + if (g_fp.initCounter == 0) + { + g_fp.fpdHandle = coreinit::IOS_Open("/dev/fpd", 0); + } + g_fp.initCounter++; + return FPResult_OkZero; + } + + uint32 IsInitialized() + { + FPGlobalLock _fpLock; + return g_fp.initCounter > 0 ? 1 : 0; + } + + nnResult InitializeAdmin(PPCInterpreter_t* hCPU) + { + FPGlobalLock _fpLock; + g_fp.isAdminMode = true; + return Initialize(); + } + + uint32 IsInitializedAdmin() + { + FPGlobalLock _fpLock; + return g_fp.initCounter > 0 ? 1 : 0; + } + + nnResult Finalize() + { + FPGlobalLock _fpLock; + if (g_fp.initCounter == 1) + { + g_fp.initCounter = 0; + g_fp.isAdminMode = false; + g_fp.isLoggedIn = false; + coreinit::IOS_Close(g_fp.fpdHandle); + g_fp.getNotificationCalled = false; + } + else if (g_fp.initCounter > 0) + g_fp.initCounter--; + return FPResult_OkZero; + } + + nnResult FinalizeAdmin() + { + return Finalize(); + } + + void GetNextNotificationAsync(); + + nnResult SetNotificationHandler(uint32 notificationMask, void* funcPtr, void* userParam) + { + FP_API_BASE(); + g_fp.notificationHandler = funcPtr; + g_fp.notificationHandlerParam = userParam; + StackAllocator notificationMaskBuf; notificationMaskBuf = notificationMask; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::SetNotificationMask); + ipcCtx->AddInput(¬ificationMaskBuf, sizeof(uint32be)); + nnResult r = ipcCtx->Submit(std::move(ipcCtx)); + if (NN_RESULT_IS_SUCCESS(r)) + { + // async query for notifications + GetNextNotificationAsync(); + } + return r; + } + + void GetNextNotificationAsyncHandler(PPCInterpreter_t* hCPU) + { + coreinit::OSLockMutex(&g_fp.fpMutex); + cemu_assert_debug(g_fp.getNotificationCalled); + g_fp.getNotificationCalled = false; + auto bufPtr = g_fp.notificationBuffer.GetPtr(); + uint32 count = g_fp.notificationCount->value(); + if (count == 0) + { + GetNextNotificationAsync(); + coreinit::OSUnlockMutex(&g_fp.fpMutex); + osLib_returnFromFunction(hCPU, 0); return; } - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_LOGIN_ASYNC; - fpdRequest->loginAsync.funcPtr = funcPtr; - fpdRequest->loginAsync.custom = custom; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); + // copy notifications to temporary buffer using std::copy + iosu::fpd::FPDNotification tempBuffer[256]; + std::copy(g_fp.notificationBuffer.GetPtr(), g_fp.notificationBuffer.GetPtr() + count, tempBuffer); + // call handler for each notification, but do it outside of the lock + void* notificationHandler = g_fp.notificationHandler; + void* notificationHandlerParam = g_fp.notificationHandlerParam; + coreinit::OSUnlockMutex(&g_fp.fpMutex); + iosu::fpd::FPDNotification* notificationBuffer = g_fp.notificationBuffer.GetPtr(); + for (uint32 i = 0; i < count; i++) + PPCCoreCallback(notificationHandler, (uint32)notificationBuffer[i].type, notificationBuffer[i].pid, notificationHandlerParam); + coreinit::OSLockMutex(&g_fp.fpMutex); + // query more notifications + GetNextNotificationAsync(); + coreinit::OSUnlockMutex(&g_fp.fpMutex); osLib_returnFromFunction(hCPU, 0); } - void export_HasLoggedIn(PPCInterpreter_t* hCPU) + void GetNextNotificationAsync() { - // Sonic All Star Racing needs this - cemuLog_logDebug(LogType::Force, "nn_fp.HasLoggedIn()"); - osLib_returnFromFunction(hCPU, 1); + if (g_fp.getNotificationCalled) + return; + g_fp.getNotificationCalled = true; + g_fp.notificationCount = 0; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetNotificationAsync); + ipcCtx->AddOutput(g_fp.notificationBuffer.GetPtr(), g_fp.notificationBuffer.GetByteSize()); + ipcCtx->AddOutput(g_fp.notificationCount.GetPtr(), sizeof(uint32be)); + cemu_assert_debug(g_fp.notificationBuffer.GetByteSize() == 0x800); + nnResult r = ipcCtx->SubmitAsync(std::move(ipcCtx), MEMPTR(PPCInterpreter_makeCallableExportDepr(GetNextNotificationAsyncHandler)), nullptr); } - void export_IsOnline(PPCInterpreter_t* hCPU) + nnResult LoginAsync(void* funcPtr, void* userParam) { - //cemuLog_logDebug(LogType::Force, "nn_fp.IsOnline();"); - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_IS_ONLINE; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - cemuLog_logDebug(LogType::Force, "nn_fp.IsOnline() -> {}", fpdRequest->resultU32.u32); - - osLib_returnFromFunction(hCPU, fpdRequest->resultU32.u32); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::LoginAsync); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, userParam); } - void export_GetFriendList(PPCInterpreter_t* hCPU) + uint32 HasLoggedIn() { - ppcDefineParamMEMPTR(pidList, uint32be, 0); - ppcDefineParamMEMPTR(returnedCount, uint32be, 1); - ppcDefineParamU32(startIndex, 2); - ppcDefineParamU32(maxCount, 3); - - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendList(...)"); - //debug_printf("nn_fp.GetFriendList(0x%08x, 0x%08x, %d, %d)\n", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6]); - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_LIST; - - fpdRequest->getFriendList.pidList = pidList; - fpdRequest->getFriendList.startIndex = startIndex; - fpdRequest->getFriendList.maxCount = maxCount; - - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - *returnedCount = fpdRequest->resultU32.u32; - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE_ZeroOnError(); + // Sonic All Star Racing uses this + // and Monster Hunter 3 Ultimate needs this to return false at least once to initiate login and not get stuck + // this returns false until LoginAsync was called and has completed (?) even if the user is already logged in + StackAllocator resultBuf; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::HasLoggedIn); + ipcCtx->AddOutput(&resultBuf, sizeof(uint32be)); + ipcCtx->Submit(std::move(ipcCtx)); + return resultBuf != 0 ? 1 : 0; } - void export_GetFriendRequestList(PPCInterpreter_t* hCPU) + uint32 IsOnline() { - // GetFriendRequestList__Q2_2nn2fpFPUiT1UiT3 - ppcDefineParamMEMPTR(pidList, uint32be, 0); - ppcDefineParamMEMPTR(returnedCount, uint32be, 1); - ppcDefineParamU32(startIndex, 2); - ppcDefineParamU32(maxCount, 3); - - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendRequestList(...)"); - //debug_printf("nn_fp.GetFriendList(0x%08x, 0x%08x, %d, %d)\n", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6]); - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIENDREQUEST_LIST; - - fpdRequest->getFriendList.pidList = pidList; - fpdRequest->getFriendList.startIndex = startIndex; - fpdRequest->getFriendList.maxCount = maxCount; - - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - *returnedCount = fpdRequest->resultU32.u32; - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE_ZeroOnError(); + StackAllocator resultBuf; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::IsOnline); + ipcCtx->AddOutput(&resultBuf, sizeof(uint32be)); + ipcCtx->Submit(std::move(ipcCtx)); + return resultBuf != 0 ? 1 : 0; } - void export_GetFriendListAll(PPCInterpreter_t* hCPU) + nnResult GetFriendList(uint32be* pidList, uint32be* returnedCount, uint32 startIndex, uint32 maxCount) { - ppcDefineParamMEMPTR(pidList, uint32be, 0); - ppcDefineParamMEMPTR(returnedCount, uint32be, 1); - ppcDefineParamU32(startIndex, 2); - ppcDefineParamU32(maxCount, 3); - - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendListAll(...)"); - - //debug_printf("nn_fp.GetFriendListAll(0x%08x, 0x%08x, %d, %d)\n", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6]); - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_LIST_ALL; - - fpdRequest->getFriendList.pidList = pidList; - fpdRequest->getFriendList.startIndex = startIndex; - fpdRequest->getFriendList.maxCount = maxCount; - - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - *returnedCount = fpdRequest->resultU32.u32; - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator startIndexBuf; startIndexBuf = startIndex; + StackAllocator maxCountBuf; maxCountBuf = maxCount; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendList); + ipcCtx->AddOutput(pidList, sizeof(uint32be) * maxCount); + ipcCtx->AddOutput(returnedCount, sizeof(uint32be)); + ipcCtx->AddInput(&startIndexBuf, sizeof(uint32be)); + ipcCtx->AddInput(&maxCountBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendListEx(PPCInterpreter_t* hCPU) + nnResult GetFriendRequestList(uint32be* pidList, uint32be* returnedCount, uint32 startIndex, uint32 maxCount) { - ppcDefineParamMEMPTR(friendData, iosu::fpd::friendData_t, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendListEx(...)"); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_LIST_EX; - - fpdRequest->getFriendListEx.friendData = friendData; - fpdRequest->getFriendListEx.pidList = pidList; - fpdRequest->getFriendListEx.count = count; - - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator startIndexBuf; startIndexBuf = startIndex; + StackAllocator maxCountBuf; maxCountBuf = maxCount; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendRequestList); + ipcCtx->AddOutput(pidList, sizeof(uint32be) * maxCount); + ipcCtx->AddOutput(returnedCount, sizeof(uint32be)); + ipcCtx->AddInput(&startIndexBuf, sizeof(uint32be)); + ipcCtx->AddInput(&maxCountBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendRequestListEx(PPCInterpreter_t* hCPU) + nnResult GetFriendListAll(uint32be* pidList, uint32be* returnedCount, uint32 startIndex, uint32 maxCount) { - ppcDefineParamMEMPTR(friendRequest, iosu::fpd::friendRequest_t, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendRequestListEx(...)"); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIENDREQUEST_LIST_EX; - - fpdRequest->getFriendRequestListEx.friendRequest = friendRequest; - fpdRequest->getFriendRequestListEx.pidList = pidList; - fpdRequest->getFriendRequestListEx.count = count; - - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator startIndexBuf; startIndexBuf = startIndex; + StackAllocator maxCountBuf; maxCountBuf = maxCount; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendListAll); + ipcCtx->AddOutput(pidList, sizeof(uint32be) * maxCount); + ipcCtx->AddOutput(returnedCount, sizeof(uint32be)); + ipcCtx->AddInput(&startIndexBuf, sizeof(uint32be)); + ipcCtx->AddInput(&maxCountBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetBasicInfoAsync(PPCInterpreter_t* hCPU) + nnResult GetFriendListEx(iosu::fpd::FriendData* friendData, uint32be* pidList, uint32 count) { - ppcDefineParamMEMPTR(basicInfo, iosu::fpd::friendBasicInfo_t, 0); - ppcDefineParamTypePtr(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - ppcDefineParamMPTR(funcMPTR, 3); - ppcDefineParamU32(customParam, 4); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_BASIC_INFO_ASYNC; - fpdRequest->getBasicInfo.basicInfo = basicInfo; - fpdRequest->getBasicInfo.pidList = pidList; - fpdRequest->getBasicInfo.count = count; - fpdRequest->getBasicInfo.funcPtr = funcMPTR; - fpdRequest->getBasicInfo.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector);; - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendListEx); + ipcCtx->AddOutput(friendData, sizeof(iosu::fpd::FriendData) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetMyPrincipalId(PPCInterpreter_t* hCPU) + nnResult GetFriendRequestListEx(iosu::fpd::FriendRequest* friendRequest, uint32be* pidList, uint32 count) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetMyPrincipalId()"); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_MY_PRINCIPAL_ID; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - uint32 principalId = fpdRequest->resultU32.u32; - - osLib_returnFromFunction(hCPU, principalId); + FP_API_BASE(); + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendRequestListEx); + ipcCtx->AddOutput(friendRequest, sizeof(iosu::fpd::FriendRequest) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetMyAccountId(PPCInterpreter_t* hCPU) + nnResult GetBasicInfoAsync(iosu::fpd::FriendBasicInfo* basicInfo, uint32be* pidList, uint32 count, void* funcPtr, void* customParam) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetMyAccountId(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamTypePtr(accountId, uint8, 0); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_MY_ACCOUNT_ID; - fpdRequest->common.ptr = (void*)accountId; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetBasicInfoAsync); + ipcCtx->AddOutput(basicInfo, sizeof(iosu::fpd::FriendBasicInfo) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_GetMyScreenName(PPCInterpreter_t* hCPU) + uint32 GetMyPrincipalId() { - cemuLog_logDebug(LogType::Force, "nn_fp.GetMyScreenName(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamTypePtr(screenname, uint16be, 0); - - screenname[0] = '\0'; - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_MY_SCREENNAME; - fpdRequest->common.ptr = (void*)screenname; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, 0); + FP_API_BASE_ZeroOnError(); + StackAllocator resultBuf; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetMyPrincipalId); + ipcCtx->AddOutput(&resultBuf, sizeof(uint32be)); + ipcCtx->Submit(std::move(ipcCtx)); + return resultBuf->value(); } - typedef struct + nnResult GetMyAccountId(uint8be* accountId) { - uint8 showOnline; // show online status to others - uint8 showGame; // show played game to others - uint8 blockFriendRequests; // block friend requests - }fpPerference_t; - - void export_GetMyPreference(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "nn_fp.GetMyPreference(0x{:08x}) - placeholder", hCPU->gpr[3]); - ppcDefineParamTypePtr(pref, fpPerference_t, 0); - - pref->showOnline = 1; - pref->showGame = 1; - pref->blockFriendRequests = 0; - - osLib_returnFromFunction(hCPU, 0); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetMyAccountId); + ipcCtx->AddOutput(accountId, ACT_ACCOUNTID_LENGTH); + return ipcCtx->Submit(std::move(ipcCtx)); } - // GetMyPreference__Q2_2nn2fpFPQ3_2nn2fp10Preference - - void export_GetMyMii(PPCInterpreter_t* hCPU) + nnResult GetMyScreenName(uint16be* screenname) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetMyMii(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamTypePtr(fflData, FFLData_t, 0); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_MY_MII; - fpdRequest->common.ptr = (void*)fflData; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetMyScreenName); + ipcCtx->AddOutput(screenname, ACT_NICKNAME_SIZE*sizeof(uint16)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendAccountId(PPCInterpreter_t* hCPU) + nnResult GetMyPreference(iosu::fpd::FPDPreference* myPreference) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendAccountId(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamMEMPTR(accountIds, char, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_ACCOUNT_ID; - fpdRequest->getFriendAccountId.accountIds = accountIds; - fpdRequest->getFriendAccountId.pidList = pidList; - fpdRequest->getFriendAccountId.count = count; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetMyPreference); + ipcCtx->AddOutput(myPreference, sizeof(iosu::fpd::FPDPreference)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendScreenName(PPCInterpreter_t* hCPU) + nnResult GetMyMii(FFLData_t* fflData) { - // GetFriendScreenName__Q2_2nn2fpFPA11_wPCUiUibPUc - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendScreenName(0x{:08x},0x{:08x},0x{:08x},{},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); - ppcDefineParamMEMPTR(nameList, uint16be, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - ppcDefineParamU32(replaceNonAscii, 3); - ppcDefineParamMEMPTR(languageList, uint8, 4); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_SCREENNAME; - fpdRequest->getFriendScreenname.nameList = nameList; - fpdRequest->getFriendScreenname.pidList = pidList; - fpdRequest->getFriendScreenname.count = count; - fpdRequest->getFriendScreenname.replaceNonAscii = replaceNonAscii != 0; - fpdRequest->getFriendScreenname.languageList = languageList; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetMyMii); + ipcCtx->AddOutput(fflData, sizeof(FFLData_t)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendMii(PPCInterpreter_t* hCPU) + nnResult GetFriendAccountId(uint8be* accountIdArray, uint32be* pidList, uint32 count) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendMii(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamMEMPTR(miiList, FFLData_t, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_MII; - fpdRequest->getFriendMii.miiList = (uint8*)miiList.GetPtr(); - fpdRequest->getFriendMii.pidList = pidList; - fpdRequest->getFriendMii.count = count; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + if (count == 0) + return 0; + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendAccountId); + ipcCtx->AddOutput(accountIdArray, ACT_ACCOUNTID_LENGTH * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendPresence(PPCInterpreter_t* hCPU) + nnResult GetFriendScreenName(uint16be* nameList, uint32be* pidList, uint32 count, uint8 replaceNonAscii, uint8be* languageList) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendPresence(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamMEMPTR(presenceList, uint8, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_PRESENCE; - fpdRequest->getFriendPresence.presenceList = (uint8*)presenceList.GetPtr(); - fpdRequest->getFriendPresence.pidList = pidList; - fpdRequest->getFriendPresence.count = count; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + if (count == 0) + return 0; + StackAllocator countBuf; countBuf = count; + StackAllocator replaceNonAsciiBuf; replaceNonAsciiBuf = replaceNonAscii; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendScreenName); + ipcCtx->AddOutput(nameList, ACT_NICKNAME_SIZE * sizeof(uint16be) * count); + ipcCtx->AddOutput(languageList, languageList ? sizeof(uint8be) * count : 0); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + ipcCtx->AddInput(&replaceNonAsciiBuf, sizeof(uint8be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_GetFriendRelationship(PPCInterpreter_t* hCPU) + nnResult GetFriendMii(FFLData_t* miiList, uint32be* pidList, uint32 count) { - cemuLog_logDebug(LogType::Force, "nn_fp.GetFriendRelationship(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamMEMPTR(relationshipList, uint8, 0); - ppcDefineParamMEMPTR(pidList, uint32be, 1); - ppcDefineParamU32(count, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_RELATIONSHIP; - fpdRequest->getFriendRelationship.relationshipList = (uint8*)relationshipList.GetPtr(); - fpdRequest->getFriendRelationship.pidList = pidList; - fpdRequest->getFriendRelationship.count = count; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + if(count == 0) + return 0; + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendMii); + ipcCtx->AddOutput(miiList, sizeof(FFLData_t) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_IsJoinable(PPCInterpreter_t* hCPU) + nnResult GetFriendPresence(iosu::fpd::FriendPresence* presenceList, uint32be* pidList, uint32 count) { - ppcDefineParamTypePtr(presence, iosu::fpd::friendPresence_t, 0); - ppcDefineParamU64(joinMask, 2); + FP_API_BASE(); + if(count == 0) + return 0; + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendPresence); + ipcCtx->AddOutput(presenceList, sizeof(iosu::fpd::FriendPresence) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); + } + nnResult GetFriendRelationship(uint8* relationshipList, uint32be* pidList, uint32 count) + { + FP_API_BASE(); + if(count == 0) + return 0; + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetFriendRelationship); + ipcCtx->AddOutput(relationshipList, sizeof(uint8) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->Submit(std::move(ipcCtx)); + } + + uint32 IsJoinable(iosu::fpd::FriendPresence* presence, uint64 joinMask) + { if (presence->isValid == 0 || presence->isOnline == 0 || presence->gameMode.joinGameId == 0 || @@ -428,368 +556,237 @@ namespace nn presence->gameMode.groupId == 0 || presence->gameMode.joinGameMode >= 64 ) { - osLib_returnFromFunction(hCPU, 0); - return; + return 0; } uint32 joinGameMode = presence->gameMode.joinGameMode; uint64 joinModeMask = (1ULL<gameMode.joinFlagMask; if (joinFlagMask == 0) - { - osLib_returnFromFunction(hCPU, 0); - return; - } + return 0; if (joinFlagMask == 1) - { - osLib_returnFromFunction(hCPU, 1); - return; - } + return 1; if (joinFlagMask == 2) { - // check relationship + // check relationship uint8 relationship[1] = { 0 }; StackAllocator pidList; - pidList[0] = presence->gameMode.hostPid; - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_GET_FRIEND_RELATIONSHIP; - fpdRequest->getFriendRelationship.relationshipList = relationship; - fpdRequest->getFriendRelationship.pidList = pidList.GetPointer(); - fpdRequest->getFriendRelationship.count = 1; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - + pidList = presence->gameMode.hostPid; + GetFriendRelationship(relationship, &pidList, 1); if(relationship[0] == iosu::fpd::RELATIONSHIP_FRIEND) - osLib_returnFromFunction(hCPU, 1); - else - osLib_returnFromFunction(hCPU, 0); - return; + return 1; + return 0; } if (joinFlagMask == 0x65 || joinFlagMask == 0x66) { cemuLog_log(LogType::Force, "Unsupported friend invite"); } - - osLib_returnFromFunction(hCPU, 0); + return 0; } - void export_CheckSettingStatusAsync(PPCInterpreter_t* hCPU) + nnResult CheckSettingStatusAsync(uint8* status, void* funcPtr, void* customParam) { - cemuLog_logDebug(LogType::Force, "nn_fp.CheckSettingStatusAsync(0x{:08x},0x{:08x},0x{:08x}) - placeholder", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamTypePtr(uknR3, uint8, 0); - ppcDefineParamMPTR(funcMPTR, 1); - ppcDefineParamU32(customParam, 2); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::CheckSettingStatusAsync); + ipcCtx->AddOutput(status, sizeof(uint8be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); + } - if (g_fp.isAdminMode == false) + uint32 IsPreferenceValid() + { + FP_API_BASE_ZeroOnError(); + StackAllocator resultBuf; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::IsPreferenceValid); + ipcCtx->AddOutput(&resultBuf, sizeof(uint32be)); + ipcCtx->Submit(std::move(ipcCtx)); + return resultBuf != 0 ? 1 : 0; + } + + nnResult UpdatePreferenceAsync(iosu::fpd::FPDPreference* newPreference, void* funcPtr, void* customParam) + { + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::UpdatePreferenceAsync); + ipcCtx->AddInput(newPreference, sizeof(iosu::fpd::FPDPreference)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); + } + + nnResult UpdateGameModeWithUnusedParam(iosu::fpd::GameMode* gameMode, uint16be* gameModeMessage, uint32 unusedParam) + { + FP_API_BASE(); + uint32 messageLen = CafeStringHelpers::Length(gameModeMessage, iosu::fpd::GAMEMODE_MAX_MESSAGE_LENGTH); + if(messageLen >= iosu::fpd::GAMEMODE_MAX_MESSAGE_LENGTH) { - - osLib_returnFromFunction(hCPU, 0xC0C00800); - return; + cemuLog_log(LogType::Force, "UpdateGameMode: message too long"); + return FPResult_InvalidIPCParam; } - - *uknR3 = 1; - - StackAllocator callbackResultCode; - - *callbackResultCode.GetPointer() = 0; - - hCPU->gpr[3] = callbackResultCode.GetMPTR(); - hCPU->gpr[4] = customParam; - PPCCore_executeCallbackInternal(funcMPTR); - - osLib_returnFromFunction(hCPU, 0); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::UpdateGameModeVariation2); + ipcCtx->AddInput(gameMode, sizeof(iosu::fpd::GameMode)); + ipcCtx->AddInput(gameModeMessage, sizeof(uint16be) * (messageLen + 1)); + return ipcCtx->Submit(std::move(ipcCtx)); } - void export_IsPreferenceValid(PPCInterpreter_t* hCPU) + nnResult UpdateGameMode(iosu::fpd::GameMode* gameMode, uint16be* gameModeMessage) { - cemuLog_logDebug(LogType::Force, "nn_fp.IsPreferenceValid()"); - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_IS_PREFERENCE_VALID; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->resultU32.u32); + return UpdateGameModeWithUnusedParam(gameMode, gameModeMessage, 0); } - void export_UpdatePreferenceAsync(PPCInterpreter_t* hCPU) + nnResult GetRequestBlockSettingAsync(uint8* blockSettingList, uint32be* pidList, uint32 count, void* funcPtr, void* customParam) { - cemuLog_logDebug(LogType::Force, "nn_fp.UpdatePreferenceAsync(0x{:08x},0x{:08x},0x{:08x}) - placeholder", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamTypePtr(uknR3, uint8, 0); - ppcDefineParamMPTR(funcMPTR, 1); - ppcDefineParamU32(customParam, 2); - - if (g_fp.isAdminMode == false) - { - - osLib_returnFromFunction(hCPU, 0xC0C00800); - return; - } - - //*uknR3 = 0; // seems to be 3 bytes (nn::fp::Preference const *) - - StackAllocator callbackResultCode; - - *callbackResultCode.GetPointer() = 0; - - hCPU->gpr[3] = callbackResultCode.GetMPTR(); - hCPU->gpr[4] = customParam; - PPCCore_executeCallbackInternal(funcMPTR); - - osLib_returnFromFunction(hCPU, 0); + FP_API_BASE(); + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::GetRequestBlockSettingAsync); + ipcCtx->AddOutput(blockSettingList, sizeof(uint8be) * count); + ipcCtx->AddInput(pidList, sizeof(uint32be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_UpdateGameMode(PPCInterpreter_t* hCPU) + // overload of AddFriendAsync + nnResult AddFriendAsyncByPid(uint32 pid, void* funcPtr, void* customParam) { - cemuLog_logDebug(LogType::Force, "nn_fp.UpdateGameMode(0x{:08x},0x{:08x},{})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - ppcDefineParamMEMPTR(gameMode, iosu::fpd::gameMode_t, 0); - ppcDefineParamMEMPTR(gameModeMessage, uint16be, 1); - ppcDefineParamU32(uknR5, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_UPDATE_GAMEMODE; - fpdRequest->updateGameMode.gameMode = gameMode; - fpdRequest->updateGameMode.gameModeMessage = gameModeMessage; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, 0); + FP_API_BASE(); + StackAllocator pidBuf; pidBuf = pid; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::AddFriendAsyncByPid); + ipcCtx->AddInput(&pidBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_GetRequestBlockSettingAsync(PPCInterpreter_t* hCPU) + nnResult DeleteFriendFlagsAsync(uint32be* pidList, uint32 pidCount, uint32 ukn, void* funcPtr, void* customParam) { - ppcDefineParamTypePtr(settingList, uint8, 0); - ppcDefineParamTypePtr(pidList, uint32be, 1); - ppcDefineParamU32(pidCount, 2); - ppcDefineParamMPTR(funcMPTR, 3); - ppcDefineParamMPTR(customParam, 4); - - cemuLog_logDebug(LogType::Force, "GetRequestBlockSettingAsync(...) - todo"); - - for (uint32 i = 0; i < pidCount; i++) - settingList[i] = 0; - // 0 means not blocked. Friend app will continue with GetBasicInformation() - // 1 means blocked. Friend app will continue with AddFriendAsync to add the user as a provisional friend - - StackAllocator callbackResultCode; - - *callbackResultCode.GetPointer() = 0; - - hCPU->gpr[3] = callbackResultCode.GetMPTR(); - hCPU->gpr[4] = customParam; - PPCCore_executeCallbackInternal(funcMPTR); - - osLib_returnFromFunction(hCPU, 0); + // admin function? + FP_API_BASE(); + StackAllocator pidCountBuf; pidCountBuf = pidCount; + StackAllocator uknBuf; uknBuf = ukn; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::DeleteFriendFlagsAsync); + ipcCtx->AddInput(pidList, sizeof(uint32be) * pidCount); + ipcCtx->AddInput(&pidCountBuf, sizeof(uint32be)); + ipcCtx->AddInput(&uknBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_AddFriendAsync(PPCInterpreter_t* hCPU) + // overload of AddFriendRequestAsync + nnResult AddFriendRequestByPlayRecordAsync(iosu::fpd::RecentPlayRecordEx* playRecord, uint16be* message, void* funcPtr, void* customParam) { - // AddFriendAsync__Q2_2nn2fpFPCcPFQ2_2nn6ResultPv_vPv - ppcDefineParamU32(principalId, 0); - ppcDefineParamMPTR(funcMPTR, 1); - ppcDefineParamMPTR(customParam, 2); - -#ifdef CEMU_DEBUG_ASSERT - assert_dbg(); -#endif - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_ADD_FRIEND; - fpdRequest->addOrRemoveFriend.pid = principalId; - fpdRequest->addOrRemoveFriend.funcPtr = funcMPTR; - fpdRequest->addOrRemoveFriend.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::AddFriendRequestByPlayRecordAsync); + uint32 messageLen = 0; + while(message[messageLen] != 0) + messageLen++; + ipcCtx->AddInput(playRecord, sizeof(iosu::fpd::RecentPlayRecordEx)); + ipcCtx->AddInput(message, sizeof(uint16be) * (messageLen+1)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - - void export_DeleteFriendFlagsAsync(PPCInterpreter_t* hCPU) + nnResult RemoveFriendAsync(uint32 pid, void* funcPtr, void* customParam) { - cemuLog_logDebug(LogType::Force, "nn_fp.DeleteFriendFlagsAsync(...) - todo"); - ppcDefineParamU32(uknR3, 0); // example value: pointer - ppcDefineParamU32(uknR4, 1); // example value: 1 - ppcDefineParamU32(uknR5, 2); // example value: 1 - ppcDefineParamMPTR(funcMPTR, 3); - ppcDefineParamU32(customParam, 4); - - if (g_fp.isAdminMode == false) - { - osLib_returnFromFunction(hCPU, 0xC0C00800); - return; - } - - StackAllocator callbackResultCode; - - *callbackResultCode.GetPointer() = 0; - - hCPU->gpr[3] = callbackResultCode.GetMPTR(); - hCPU->gpr[4] = customParam; - PPCCore_executeCallbackInternal(funcMPTR); - - osLib_returnFromFunction(hCPU, 0); + FP_API_BASE(); + StackAllocator pidBuf; pidBuf = pid; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::RemoveFriendAsync); + ipcCtx->AddInput(&pidBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - - typedef struct + nnResult MarkFriendRequestsAsReceivedAsync(uint64be* messageIdList, uint32 count, void* funcPtr, void* customParam) { - /* +0x00 */ uint32be pid; - /* +0x04 */ uint8 ukn04; - /* +0x05 */ uint8 ukn05; - /* +0x06 */ uint8 ukn06[0x22]; - /* +0x28 */ uint8 ukn28[0x22]; - /* +0x4A */ uint8 _uknOrPadding4A[6]; - /* +0x50 */ uint32be ukn50; - /* +0x54 */ uint32be ukn54; - /* +0x58 */ uint16be ukn58; - /* +0x5C */ uint8 _padding5C[4]; - /* +0x60 */ iosu::fpd::fpdDate_t date; - }RecentPlayRecordEx_t; - - static_assert(sizeof(RecentPlayRecordEx_t) == 0x68, ""); - static_assert(offsetof(RecentPlayRecordEx_t, ukn06) == 0x06, ""); - static_assert(offsetof(RecentPlayRecordEx_t, ukn50) == 0x50, ""); - - void export_AddFriendRequestAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamTypePtr(playRecord, RecentPlayRecordEx_t, 0); - ppcDefineParamTypePtr(message, uint16be, 1); - ppcDefineParamMPTR(funcMPTR, 2); - ppcDefineParamMPTR(customParam, 3); - - fpdPrepareRequest(); - - uint8* uknData = (uint8*)playRecord; - - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_ADD_FRIEND_REQUEST; - fpdRequest->addFriendRequest.pid = playRecord->pid; - fpdRequest->addFriendRequest.message = message; - fpdRequest->addFriendRequest.funcPtr = funcMPTR; - fpdRequest->addFriendRequest.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator countBuf; countBuf = count; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::MarkFriendRequestsAsReceivedAsync); + ipcCtx->AddInput(messageIdList, sizeof(uint64be) * count); + ipcCtx->AddInput(&countBuf, sizeof(uint32be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_RemoveFriendAsync(PPCInterpreter_t* hCPU) + nnResult CancelFriendRequestAsync(uint64 requestId, void* funcPtr, void* customParam) { - ppcDefineParamU32(principalId, 0); - ppcDefineParamMPTR(funcMPTR, 1); - ppcDefineParamMPTR(customParam, 2); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_REMOVE_FRIEND_ASYNC; - fpdRequest->addOrRemoveFriend.pid = principalId; - fpdRequest->addOrRemoveFriend.funcPtr = funcMPTR; - fpdRequest->addOrRemoveFriend.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator requestIdBuf; requestIdBuf = requestId; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::CancelFriendRequestAsync); + ipcCtx->AddInput(&requestIdBuf, sizeof(uint64be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_MarkFriendRequestsAsReceivedAsync(PPCInterpreter_t* hCPU) + nnResult DeleteFriendRequestAsync(uint64 requestId, void* funcPtr, void* customParam) { - ppcDefineParamTypePtr(messageIdList, uint64, 0); - ppcDefineParamU32(count, 1); - ppcDefineParamMPTR(funcMPTR, 2); - ppcDefineParamMPTR(customParam, 3); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_MARK_FRIEND_REQUEST_AS_RECEIVED_ASYNC; - fpdRequest->markFriendRequest.messageIdList = messageIdList; - fpdRequest->markFriendRequest.count = count; - fpdRequest->markFriendRequest.funcPtr = funcMPTR; - fpdRequest->markFriendRequest.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator requestIdBuf; requestIdBuf = requestId; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::DeleteFriendRequestAsync); + ipcCtx->AddInput(&requestIdBuf, sizeof(uint64be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } - void export_CancelFriendRequestAsync(PPCInterpreter_t* hCPU) + nnResult AcceptFriendRequestAsync(uint64 requestId, void* funcPtr, void* customParam) { - ppcDefineParamU64(frqMessageId, 0); - ppcDefineParamMPTR(funcMPTR, 2); - ppcDefineParamMPTR(customParam, 3); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_CANCEL_FRIEND_REQUEST_ASYNC; - fpdRequest->cancelOrAcceptFriendRequest.messageId = frqMessageId; - fpdRequest->cancelOrAcceptFriendRequest.funcPtr = funcMPTR; - fpdRequest->cancelOrAcceptFriendRequest.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); - } - - void export_AcceptFriendRequestAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamU64(frqMessageId, 0); - ppcDefineParamMPTR(funcMPTR, 2); - ppcDefineParamMPTR(customParam, 3); - - fpdPrepareRequest(); - fpdRequest->requestCode = iosu::fpd::IOSU_FPD_ACCEPT_FRIEND_REQUEST_ASYNC; - fpdRequest->cancelOrAcceptFriendRequest.messageId = frqMessageId; - fpdRequest->cancelOrAcceptFriendRequest.funcPtr = funcMPTR; - fpdRequest->cancelOrAcceptFriendRequest.custom = customParam; - __depr__IOS_Ioctlv(IOS_DEVICE_FPD, IOSU_FPD_REQUEST_CEMU, 1, 1, fpdBufferVector); - - osLib_returnFromFunction(hCPU, fpdRequest->returnCode); + FP_API_BASE(); + StackAllocator requestIdBuf; requestIdBuf = requestId; + auto ipcCtx = std::make_unique(iosu::fpd::FPD_REQUEST_ID::AcceptFriendRequestAsync); + ipcCtx->AddInput(&requestIdBuf, sizeof(uint64be)); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); } void load() { - osLib_addFunction("nn_fp", "Initialize__Q2_2nn2fpFv", export_Initialize); - osLib_addFunction("nn_fp", "InitializeAdmin__Q2_2nn2fpFv", export_InitializeAdmin); - osLib_addFunction("nn_fp", "IsInitialized__Q2_2nn2fpFv", export_IsInitialized); - osLib_addFunction("nn_fp", "IsInitializedAdmin__Q2_2nn2fpFv", export_IsInitializedAdmin); + g_fp.initCounter = 0; + g_fp.isAdminMode = false; + g_fp.isLoggedIn = false; + g_fp.getNotificationCalled = false; + g_fp.notificationHandler = nullptr; + g_fp.notificationHandlerParam = nullptr; - osLib_addFunction("nn_fp", "SetNotificationHandler__Q2_2nn2fpFUiPFQ3_2nn2fp16NotificationTypeUiPv_vPv", export_SetNotificationHandler); + coreinit::OSInitMutex(&g_fp.fpMutex); + FPIpcBufferAllocator.Init(); - osLib_addFunction("nn_fp", "LoginAsync__Q2_2nn2fpFPFQ2_2nn6ResultPv_vPv", export_LoginAsync); - osLib_addFunction("nn_fp", "HasLoggedIn__Q2_2nn2fpFv", export_HasLoggedIn); + cafeExportRegisterFunc(Initialize, "nn_fp", "Initialize__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(InitializeAdmin, "nn_fp", "InitializeAdmin__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(IsInitialized, "nn_fp", "IsInitialized__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(IsInitializedAdmin, "nn_fp", "IsInitializedAdmin__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(Finalize, "nn_fp", "Finalize__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(FinalizeAdmin, "nn_fp", "FinalizeAdmin__Q2_2nn2fpFv", LogType::NN_FP); - osLib_addFunction("nn_fp", "IsOnline__Q2_2nn2fpFv", export_IsOnline); + cafeExportRegisterFunc(SetNotificationHandler, "nn_fp", "SetNotificationHandler__Q2_2nn2fpFUiPFQ3_2nn2fp16NotificationTypeUiPv_vPv", LogType::NN_FP); - osLib_addFunction("nn_fp", "GetFriendList__Q2_2nn2fpFPUiT1UiT3", export_GetFriendList); - osLib_addFunction("nn_fp", "GetFriendRequestList__Q2_2nn2fpFPUiT1UiT3", export_GetFriendRequestList); - osLib_addFunction("nn_fp", "GetFriendListAll__Q2_2nn2fpFPUiT1UiT3", export_GetFriendListAll); - osLib_addFunction("nn_fp", "GetFriendListEx__Q2_2nn2fpFPQ3_2nn2fp10FriendDataPCUiUi", export_GetFriendListEx); - osLib_addFunction("nn_fp", "GetFriendRequestListEx__Q2_2nn2fpFPQ3_2nn2fp13FriendRequestPCUiUi", export_GetFriendRequestListEx); - osLib_addFunction("nn_fp", "GetBasicInfoAsync__Q2_2nn2fpFPQ3_2nn2fp9BasicInfoPCUiUiPFQ2_2nn6ResultPv_vPv", export_GetBasicInfoAsync); + cafeExportRegisterFunc(LoginAsync, "nn_fp", "LoginAsync__Q2_2nn2fpFPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(HasLoggedIn, "nn_fp", "HasLoggedIn__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(IsOnline, "nn_fp", "IsOnline__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendList, "nn_fp", "GetFriendList__Q2_2nn2fpFPUiT1UiT3", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendRequestList, "nn_fp", "GetFriendRequestList__Q2_2nn2fpFPUiT1UiT3", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendListAll, "nn_fp", "GetFriendListAll__Q2_2nn2fpFPUiT1UiT3", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendListEx, "nn_fp", "GetFriendListEx__Q2_2nn2fpFPQ3_2nn2fp10FriendDataPCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendRequestListEx, "nn_fp", "GetFriendRequestListEx__Q2_2nn2fpFPQ3_2nn2fp13FriendRequestPCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(GetBasicInfoAsync, "nn_fp", "GetBasicInfoAsync__Q2_2nn2fpFPQ3_2nn2fp9BasicInfoPCUiUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); - osLib_addFunction("nn_fp", "GetMyPrincipalId__Q2_2nn2fpFv", export_GetMyPrincipalId); - osLib_addFunction("nn_fp", "GetMyAccountId__Q2_2nn2fpFPc", export_GetMyAccountId); - osLib_addFunction("nn_fp", "GetMyScreenName__Q2_2nn2fpFPw", export_GetMyScreenName); - osLib_addFunction("nn_fp", "GetMyMii__Q2_2nn2fpFP12FFLStoreData", export_GetMyMii); - osLib_addFunction("nn_fp", "GetMyPreference__Q2_2nn2fpFPQ3_2nn2fp10Preference", export_GetMyPreference); + cafeExportRegisterFunc(GetMyPrincipalId, "nn_fp", "GetMyPrincipalId__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(GetMyAccountId, "nn_fp", "GetMyAccountId__Q2_2nn2fpFPc", LogType::NN_FP); + cafeExportRegisterFunc(GetMyScreenName, "nn_fp", "GetMyScreenName__Q2_2nn2fpFPw", LogType::NN_FP); + cafeExportRegisterFunc(GetMyMii, "nn_fp", "GetMyMii__Q2_2nn2fpFP12FFLStoreData", LogType::NN_FP); + cafeExportRegisterFunc(GetMyPreference, "nn_fp", "GetMyPreference__Q2_2nn2fpFPQ3_2nn2fp10Preference", LogType::NN_FP); - osLib_addFunction("nn_fp", "GetFriendAccountId__Q2_2nn2fpFPA17_cPCUiUi", export_GetFriendAccountId); - osLib_addFunction("nn_fp", "GetFriendScreenName__Q2_2nn2fpFPA11_wPCUiUibPUc", export_GetFriendScreenName); - osLib_addFunction("nn_fp", "GetFriendMii__Q2_2nn2fpFP12FFLStoreDataPCUiUi", export_GetFriendMii); - osLib_addFunction("nn_fp", "GetFriendPresence__Q2_2nn2fpFPQ3_2nn2fp14FriendPresencePCUiUi", export_GetFriendPresence); - osLib_addFunction("nn_fp", "GetFriendRelationship__Q2_2nn2fpFPUcPCUiUi", export_GetFriendRelationship); - osLib_addFunction("nn_fp", "IsJoinable__Q2_2nn2fpFPCQ3_2nn2fp14FriendPresenceUL", export_IsJoinable); + cafeExportRegisterFunc(GetFriendAccountId, "nn_fp", "GetFriendAccountId__Q2_2nn2fpFPA17_cPCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendScreenName, "nn_fp", "GetFriendScreenName__Q2_2nn2fpFPA11_wPCUiUibPUc", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendMii, "nn_fp", "GetFriendMii__Q2_2nn2fpFP12FFLStoreDataPCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendPresence, "nn_fp", "GetFriendPresence__Q2_2nn2fpFPQ3_2nn2fp14FriendPresencePCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(GetFriendRelationship, "nn_fp", "GetFriendRelationship__Q2_2nn2fpFPUcPCUiUi", LogType::NN_FP); + cafeExportRegisterFunc(IsJoinable, "nn_fp", "IsJoinable__Q2_2nn2fpFPCQ3_2nn2fp14FriendPresenceUL", LogType::NN_FP); - osLib_addFunction("nn_fp", "CheckSettingStatusAsync__Q2_2nn2fpFPUcPFQ2_2nn6ResultPv_vPv", export_CheckSettingStatusAsync); - osLib_addFunction("nn_fp", "IsPreferenceValid__Q2_2nn2fpFv", export_IsPreferenceValid); - osLib_addFunction("nn_fp", "UpdatePreferenceAsync__Q2_2nn2fpFPCQ3_2nn2fp10PreferencePFQ2_2nn6ResultPv_vPv", export_UpdatePreferenceAsync); + cafeExportRegisterFunc(CheckSettingStatusAsync, "nn_fp", "CheckSettingStatusAsync__Q2_2nn2fpFPUcPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(IsPreferenceValid, "nn_fp", "IsPreferenceValid__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(UpdatePreferenceAsync, "nn_fp", "UpdatePreferenceAsync__Q2_2nn2fpFPCQ3_2nn2fp10PreferencePFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(GetRequestBlockSettingAsync, "nn_fp", "GetRequestBlockSettingAsync__Q2_2nn2fpFPUcPCUiUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); - osLib_addFunction("nn_fp", "UpdateGameMode__Q2_2nn2fpFPCQ3_2nn2fp8GameModePCwUi", export_UpdateGameMode); - - osLib_addFunction("nn_fp", "GetRequestBlockSettingAsync__Q2_2nn2fpFPUcPCUiUiPFQ2_2nn6ResultPv_vPv", export_GetRequestBlockSettingAsync); - - osLib_addFunction("nn_fp", "AddFriendAsync__Q2_2nn2fpFPCcPFQ2_2nn6ResultPv_vPv", export_AddFriendAsync); - osLib_addFunction("nn_fp", "AddFriendRequestAsync__Q2_2nn2fpFPCQ3_2nn2fp18RecentPlayRecordExPCwPFQ2_2nn6ResultPv_vPv", export_AddFriendRequestAsync); - osLib_addFunction("nn_fp", "DeleteFriendFlagsAsync__Q2_2nn2fpFPCUiUiT2PFQ2_2nn6ResultPv_vPv", export_DeleteFriendFlagsAsync); - - osLib_addFunction("nn_fp", "RemoveFriendAsync__Q2_2nn2fpFUiPFQ2_2nn6ResultPv_vPv", export_RemoveFriendAsync); - osLib_addFunction("nn_fp", "MarkFriendRequestsAsReceivedAsync__Q2_2nn2fpFPCULUiPFQ2_2nn6ResultPv_vPv", export_MarkFriendRequestsAsReceivedAsync); - osLib_addFunction("nn_fp", "CancelFriendRequestAsync__Q2_2nn2fpFULPFQ2_2nn6ResultPv_vPv", export_CancelFriendRequestAsync); - osLib_addFunction("nn_fp", "AcceptFriendRequestAsync__Q2_2nn2fpFULPFQ2_2nn6ResultPv_vPv", export_AcceptFriendRequestAsync); + cafeExportRegisterFunc(UpdateGameModeWithUnusedParam, "nn_fp", "UpdateGameMode__Q2_2nn2fpFPCQ3_2nn2fp8GameModePCwUi", LogType::NN_FP); + cafeExportRegisterFunc(UpdateGameMode, "nn_fp", "UpdateGameMode__Q2_2nn2fpFPCQ3_2nn2fp8GameModePCw", LogType::NN_FP); + cafeExportRegisterFunc(AddFriendAsyncByPid, "nn_fp", "AddFriendAsync__Q2_2nn2fpFUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(AddFriendRequestByPlayRecordAsync, "nn_fp", "AddFriendRequestAsync__Q2_2nn2fpFPCQ3_2nn2fp18RecentPlayRecordExPCwPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(DeleteFriendFlagsAsync, "nn_fp", "DeleteFriendFlagsAsync__Q2_2nn2fpFPCUiUiT2PFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(RemoveFriendAsync, "nn_fp", "RemoveFriendAsync__Q2_2nn2fpFUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(MarkFriendRequestsAsReceivedAsync, "nn_fp", "MarkFriendRequestsAsReceivedAsync__Q2_2nn2fpFPCULUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(CancelFriendRequestAsync, "nn_fp", "CancelFriendRequestAsync__Q2_2nn2fpFULPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(DeleteFriendRequestAsync, "nn_fp", "DeleteFriendRequestAsync__Q2_2nn2fpFULPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); + cafeExportRegisterFunc(AcceptFriendRequestAsync, "nn_fp", "AcceptFriendRequestAsync__Q2_2nn2fpFULPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); } } } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp index 8df14ce0..1bf2b37d 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp @@ -47,10 +47,10 @@ namespace nn InitializeOliveRequest(req); StackAllocator requestDoneEvent; - coreinit::OSInitEvent(requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); std::future requestRes = std::async(std::launch::async, DownloadCommunityDataList_AsyncRequest, std::ref(req), reqUrl, requestDoneEvent.GetPointer(), pOutList, pOutNum, numMaxList, pParam); - coreinit::OSWaitEvent(requestDoneEvent); + coreinit::OSWaitEvent(&requestDoneEvent); return requestRes.get(); } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp index 0ae581e0..5e6dba7e 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp @@ -199,9 +199,9 @@ namespace nn InitializeOliveRequest(req); StackAllocator requestDoneEvent; - coreinit::OSInitEvent(requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); std::future requestRes = std::async(std::launch::async, MakeDiscoveryRequest_AsyncRequest, std::ref(req), requestUrl.c_str(), requestDoneEvent.GetPointer()); - coreinit::OSWaitEvent(requestDoneEvent); + coreinit::OSWaitEvent(&requestDoneEvent); return requestRes.get(); } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp index e6cea082..309394e6 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp @@ -25,7 +25,7 @@ namespace nn // open archive g_offlineDBArchive = ZArchiveReader::OpenFromFile(ActiveSettings::GetUserDataPath("resources/miiverse/OfflineDB.zar")); if(!g_offlineDBArchive) - cemuLog_log(LogType::Force, "Failed to open resources/miiverse/OfflineDB.zar. Miiverse posts will not be available"); + cemuLog_log(LogType::Force, "Offline miiverse posts are not available"); g_offlineDBInitialized = true; } @@ -175,9 +175,9 @@ namespace nn return OLV_RESULT_SUCCESS; // the offlineDB doesn't contain any self posts StackAllocator doneEvent; - coreinit::OSInitEvent(doneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&doneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); auto asyncTask = std::async(std::launch::async, _Async_OfflineDB_DownloadPostDataListParam_DownloadPostDataList, doneEvent.GetPointer(), downloadedTopicData, downloadedPostData, postCountOut, maxCount, param); - coreinit::OSWaitEvent(doneEvent); + coreinit::OSWaitEvent(&doneEvent); nnResult r = asyncTask.get(); return r; } @@ -204,9 +204,9 @@ namespace nn nnResult OfflineDB_DownloadPostDataListParam_DownloadExternalImageData(DownloadedDataBase* _this, void* imageDataOut, uint32be* imageSizeOut, uint32 maxSize) { StackAllocator doneEvent; - coreinit::OSInitEvent(doneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&doneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); auto asyncTask = std::async(std::launch::async, _Async_OfflineDB_DownloadPostDataListParam_DownloadExternalImageData, doneEvent.GetPointer(), _this, imageDataOut, imageSizeOut, maxSize); - coreinit::OSWaitEvent(doneEvent); + coreinit::OSWaitEvent(&doneEvent); nnResult r = asyncTask.get(); return r; } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp index b76e6d63..179d66bd 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp @@ -54,9 +54,9 @@ namespace nn InitializeOliveRequest(req); StackAllocator requestDoneEvent; - coreinit::OSInitEvent(requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); std::future requestRes = std::async(std::launch::async, UploadCommunityData_AsyncRequest, std::ref(req), requestUrl, requestDoneEvent.GetPointer(), pOutData, pParam); - coreinit::OSWaitEvent(requestDoneEvent); + coreinit::OSWaitEvent(&requestDoneEvent); return requestRes.get(); } diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp index 7d9220fc..307004b9 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp @@ -44,9 +44,9 @@ namespace nn InitializeOliveRequest(req); StackAllocator requestDoneEvent; - coreinit::OSInitEvent(requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); + coreinit::OSInitEvent(&requestDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); std::future requestRes = std::async(std::launch::async, UploadFavoriteToCommunityData_AsyncRequest, std::ref(req), requestUrl, requestDoneEvent.GetPointer(), pOutData, pParam); - coreinit::OSWaitEvent(requestDoneEvent); + coreinit::OSWaitEvent(&requestDoneEvent); return requestRes.get(); } diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index f8ce7265..6d596acf 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -43,6 +43,7 @@ const std::map g_logging_window_mapping {LogType::CoreinitMP, "Coreinit MP"}, {LogType::CoreinitThread, "Coreinit Thread"}, {LogType::NN_NFP, "nn::nfp"}, + {LogType::NN_FP, "nn::fp"}, {LogType::GX2, "GX2"}, {LogType::SoundAPI, "Audio"}, {LogType::InputAPI, "Input"}, diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 7d6499fe..728c8b93 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -34,6 +34,7 @@ enum class LogType : sint32 NN_PDM = 21, NN_OLV = 23, NN_NFP = 13, + NN_FP = 24, TextureReadback = 29, diff --git a/src/Cemu/napi/napi_act.cpp b/src/Cemu/napi/napi_act.cpp index b395e2b7..9716c41e 100644 --- a/src/Cemu/napi/napi_act.cpp +++ b/src/Cemu/napi/napi_act.cpp @@ -358,7 +358,7 @@ namespace NAPI std::string_view port = tokenNode.child_value("port"); std::string_view token = tokenNode.child_value("token"); - std::memset(&result.nexToken, 0, sizeof(result.nexToken)); + memset(&result.nexToken, 0, sizeof(ACTNexToken)); if (host.size() > 15) cemuLog_log(LogType::Force, "NexToken response: host field too long"); if (nex_password.size() > 64) diff --git a/src/Cemu/nex/nex.cpp b/src/Cemu/nex/nex.cpp index 317b3877..d0857507 100644 --- a/src/Cemu/nex/nex.cpp +++ b/src/Cemu/nex/nex.cpp @@ -160,11 +160,10 @@ bool nexService::isMarkedForDestruction() void nexService::callMethod(uint8 protocolId, uint32 methodId, nexPacketBuffer* parameter, void(*nexServiceResponse)(nexService* nex, nexServiceResponse_t* serviceResponse), void* custom, bool callHandlerIfError) { - // add to queue queuedRequest_t queueRequest = { 0 }; queueRequest.protocolId = protocolId; queueRequest.methodId = methodId; - queueRequest.parameterData = std::vector(parameter->getDataPtr(), parameter->getDataPtr() + parameter->getWriteIndex()); + queueRequest.parameterData.assign(parameter->getDataPtr(), parameter->getDataPtr() + parameter->getWriteIndex()); queueRequest.nexServiceResponse = nexServiceResponse; queueRequest.custom = custom; queueRequest.callHandlerIfError = callHandlerIfError; @@ -175,11 +174,10 @@ void nexService::callMethod(uint8 protocolId, uint32 methodId, nexPacketBuffer* void nexService::callMethod(uint8 protocolId, uint32 methodId, nexPacketBuffer* parameter, std::function cb, bool callHandlerIfError) { - // add to queue queuedRequest_t queueRequest = { 0 }; queueRequest.protocolId = protocolId; queueRequest.methodId = methodId; - queueRequest.parameterData = std::vector(parameter->getDataPtr(), parameter->getDataPtr() + parameter->getWriteIndex()); + queueRequest.parameterData.assign(parameter->getDataPtr(), parameter->getDataPtr() + parameter->getWriteIndex()); queueRequest.nexServiceResponse = nullptr; queueRequest.cb2 = cb; queueRequest.callHandlerIfError = callHandlerIfError; diff --git a/src/Cemu/nex/nexFriends.cpp b/src/Cemu/nex/nexFriends.cpp index cf169b72..4fae8143 100644 --- a/src/Cemu/nex/nexFriends.cpp +++ b/src/Cemu/nex/nexFriends.cpp @@ -274,8 +274,7 @@ void NexFriends::handleResponse_getAllInformation(nexServiceResponse_t* response return; } NexFriends* session = (NexFriends*)nexFriends; - - nexPrincipalPreference preference(&response->data); + session->myPreference = nexPrincipalPreference(&response->data); nexComment comment(&response->data); if (response->data.hasReadOutOfBounds()) return; @@ -290,29 +289,21 @@ void NexFriends::handleResponse_getAllInformation(nexServiceResponse_t* response uint32 friendCount = response->data.readU32(); session->list_friends.resize(friendCount); for (uint32 i = 0; i < friendCount; i++) - { session->list_friends[i].readData(&response->data); - } // friend requests (outgoing) uint32 friendRequestsOutCount = response->data.readU32(); if (response->data.hasReadOutOfBounds()) - { return; - } session->list_friendReqOutgoing.resize(friendRequestsOutCount); for (uint32 i = 0; i < friendRequestsOutCount; i++) - { session->list_friendReqOutgoing[i].readData(&response->data); - } // friend requests (incoming) uint32 friendRequestsInCount = response->data.readU32(); if (response->data.hasReadOutOfBounds()) return; session->list_friendReqIncoming.resize(friendRequestsInCount); for (uint32 i = 0; i < friendRequestsInCount; i++) - { session->list_friendReqIncoming[i].readData(&response->data); - } if (response->data.hasReadOutOfBounds()) return; // blacklist @@ -336,7 +327,7 @@ void NexFriends::handleResponse_getAllInformation(nexServiceResponse_t* response if (isPreferenceInvalid) { cemuLog_log(LogType::Force, "NEX: First time login into friend account, setting up default preferences"); - session->updatePreferences(nexPrincipalPreference(1, 1, 0)); + session->updatePreferencesAsync(nexPrincipalPreference(1, 1, 0), [](RpcErrorCode err){}); } if (session->firstInformationRequest == false) @@ -377,20 +368,27 @@ bool NexFriends::requestGetAllInformation(std::function cb) return true; } -void NexFriends::handleResponse_updatePreferences(nexServiceResponse_t* response, NexFriends* nexFriends, std::function cb) -{ - // todo -} - -bool NexFriends::updatePreferences(const nexPrincipalPreference& newPreferences) +bool NexFriends::updatePreferencesAsync(nexPrincipalPreference newPreferences, std::function cb) { uint8 tempNexBufferArray[1024]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); newPreferences.writeData(&packetBuffer); - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 16, &packetBuffer, std::bind(handleResponse_updatePreferences, std::placeholders::_1, this, nullptr), true); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 16, &packetBuffer, [this, cb, newPreferences](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + this->myPreference = newPreferences; + return cb(NexFriends::ERR_NONE); + }, true); + // TEST return true; } +void NexFriends::getMyPreference(nexPrincipalPreference& preference) +{ + preference = myPreference; +} + bool NexFriends::addProvisionalFriendByPidGuessed(uint32 principalId) { uint8 tempNexBufferArray[512]; @@ -401,6 +399,7 @@ bool NexFriends::addProvisionalFriendByPidGuessed(uint32 principalId) return true; } +// returns true once connection is established and friend list data is available bool NexFriends::isOnline() { return isCurrentlyConnected && hasData; @@ -683,7 +682,7 @@ bool NexFriends::getFriendRequestByPID(nexFriendRequest& friendRequestData, bool { friendRequestData = it; if (isIncoming) - *isIncoming = false; + *isIncoming = false; return true; } } @@ -731,7 +730,7 @@ void addProvisionalFriendHandler(nexServiceResponse_t* nexResponse, std::functio } } -bool NexFriends::addProvisionalFriend(char* name, std::function cb) +bool NexFriends::addProvisionalFriend(char* name, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) { @@ -754,12 +753,11 @@ void addFriendRequestHandler(nexServiceResponse_t* nexResponse, NexFriends* nexF { // todo: Properly handle returned error code cb(NexFriends::ERR_RPC_FAILED); - // refresh the list - nexFriends->requestGetAllInformation(); + nexFriends->requestGetAllInformation(); // refresh friend list and send add/remove notifications } } -void NexFriends::addFriendRequest(uint32 pid, const char* comment, std::function cb) +void NexFriends::addFriendRequest(uint32 pid, const char* comment, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) { @@ -779,72 +777,31 @@ void NexFriends::addFriendRequest(uint32 pid, const char* comment, std::function nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 5, &packetBuffer, std::bind(addFriendRequestHandler, std::placeholders::_1, this, cb), true); } -typedef struct -{ - NEXFRIENDS_CALLBACK cb; - void* customParam; - NexFriends* nexFriends; - // command specific - struct - { - nexPrincipalBasicInfo* basicInfo; - sint32 count; - }principalBaseInfo; -}nexFriendsCallInfo_t; - -void NexFriends_handleResponse_requestPrincipleBaseInfoByPID(nexService* nex, nexServiceResponse_t* response) -{ - nexFriendsCallInfo_t* callInfo = (nexFriendsCallInfo_t*)response->custom; - if (response->isSuccessful == false) - { - // handle error case - callInfo->cb(callInfo->nexFriends, NexFriends::ERR_RPC_FAILED, callInfo->customParam); - free(callInfo); - return; - } - // process result - uint32 count = response->data.readU32(); - if (count != callInfo->principalBaseInfo.count) - { - callInfo->cb(callInfo->nexFriends, NexFriends::ERR_UNEXPECTED_RESULT, callInfo->customParam); - free(callInfo); - return; - } - for (uint32 i = 0; i < count; i++) - { - callInfo->principalBaseInfo.basicInfo[i].readData(&response->data); - } - if (response->data.hasReadOutOfBounds()) - { - callInfo->cb(callInfo->nexFriends, NexFriends::ERR_UNEXPECTED_RESULT, callInfo->customParam); - free(callInfo); - return; - } - // callback - callInfo->cb(callInfo->nexFriends, NexFriends::ERR_NONE, callInfo->customParam); - free(callInfo); -} - -void NexFriends::requestPrincipleBaseInfoByPID(nexPrincipalBasicInfo* basicInfo, uint32* pidList, sint32 count, NEXFRIENDS_CALLBACK cb, void* customParam) +void NexFriends::requestPrincipleBaseInfoByPID(uint32* pidList, sint32 count, const std::function basicInfo)>& cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) - { - // not connected - cb(this, ERR_NOT_CONNECTED, customParam); - return; - } + return cb(ERR_NOT_CONNECTED, {}); uint8 tempNexBufferArray[512]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); packetBuffer.writeU32(count); for(sint32 i=0; iprincipalBaseInfo.basicInfo = basicInfo; - callInfo->principalBaseInfo.count = count; - callInfo->cb = cb; - callInfo->customParam = customParam; - callInfo->nexFriends = this; - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 17, &packetBuffer, NexFriends_handleResponse_requestPrincipleBaseInfoByPID, callInfo, true); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 17, &packetBuffer, [cb, count](nexServiceResponse_t* response) + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED, {}); + // process result + uint32 resultCount = response->data.readU32(); + if (resultCount != count) + return cb(NexFriends::ERR_UNEXPECTED_RESULT, {}); + std::vector nexBasicInfo; + nexBasicInfo.resize(count); + for (uint32 i = 0; i < resultCount; i++) + nexBasicInfo[i].readData(&response->data); + if (response->data.hasReadOutOfBounds()) + return cb(NexFriends::ERR_UNEXPECTED_RESULT, {}); + return cb(NexFriends::ERR_NONE, nexBasicInfo); + }, true); } void genericFriendServiceNoResponseHandler(nexServiceResponse_t* nexResponse, std::function cb) @@ -858,7 +815,7 @@ void genericFriendServiceNoResponseHandler(nexServiceResponse_t* nexResponse, st } } -void NexFriends::removeFriend(uint32 pid, std::function cb) +void NexFriends::removeFriend(uint32 pid, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) { @@ -869,10 +826,20 @@ void NexFriends::removeFriend(uint32 pid, std::function cb) uint8 tempNexBufferArray[512]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); packetBuffer.writeU32(pid); - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 4, &packetBuffer, std::bind(genericFriendServiceNoResponseHandler, std::placeholders::_1, cb), true); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 4, &packetBuffer, [this, cb](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + else + { + cb(NexFriends::ERR_NONE); + this->requestGetAllInformation(); // refresh friend list and send add/remove notifications + return; + } + }, true); } -void NexFriends::cancelOutgoingProvisionalFriendRequest(uint32 pid, std::function cb) +void NexFriends::cancelOutgoingProvisionalFriendRequest(uint32 pid, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) { @@ -883,53 +850,63 @@ void NexFriends::cancelOutgoingProvisionalFriendRequest(uint32 pid, std::functio uint8 tempNexBufferArray[512]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); packetBuffer.writeU32(pid); - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 4, &packetBuffer, std::bind(genericFriendServiceNoResponseHandler, std::placeholders::_1, cb), true); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 4, &packetBuffer, [cb](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + else + return cb(NexFriends::ERR_NONE); + }, true); } -void NexFriends::acceptFriendRequest(uint64 messageId, std::function cb) +void NexFriends::acceptFriendRequest(uint64 messageId, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) - { - // not connected - cb(ERR_NOT_CONNECTED); - return; - } + return cb(ERR_NOT_CONNECTED); uint8 tempNexBufferArray[128]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); packetBuffer.writeU64(messageId); - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 7, &packetBuffer, std::bind(genericFriendServiceNoResponseHandler, std::placeholders::_1, cb), true); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 7, &packetBuffer, [cb](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + else + return cb(NexFriends::ERR_NONE); + }, true); } -void markFriendRequestsAsReceivedHandler(nexServiceResponse_t* nexResponse, std::function cb) -{ - if (nexResponse->isSuccessful) - cb(0); - else - { - // todo: Properly handle returned error code - cb(NexFriends::ERR_RPC_FAILED); - } -} - -void NexFriends::markFriendRequestsAsReceived(uint64* messageIdList, sint32 count, std::function cb) +void NexFriends::deleteFriendRequest(uint64 messageId, std::function cb) { if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) - { - // not connected - cb(ERR_NOT_CONNECTED); - return; - } + return cb(ERR_NOT_CONNECTED); + uint8 tempNexBufferArray[128]; + nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); + packetBuffer.writeU64(messageId); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 8, &packetBuffer, [this, cb](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + cb(NexFriends::ERR_NONE); + this->requestGetAllInformation(); // refresh friend list and send add/remove notifications + }, true); +} + +void NexFriends::markFriendRequestsAsReceived(uint64* messageIdList, sint32 count, std::function cb) +{ + if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) + return cb(ERR_NOT_CONNECTED); uint8 tempNexBufferArray[1024]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); packetBuffer.writeU32(count); for(sint32 i=0; icallMethod(NEX_PROTOCOL_FRIENDS_WIIU, 10, &packetBuffer, std::bind(markFriendRequestsAsReceivedHandler, std::placeholders::_1, cb), true); -} - -void genericFriendServiceNoResponseHandlerWithoutCB(nexServiceResponse_t* nexResponse) -{ - + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 10, &packetBuffer, [cb](nexServiceResponse_t* response) -> void + { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + else + return cb(NexFriends::ERR_NONE); + }, true); } void NexFriends::updateMyPresence(nexPresenceV2& myPresence) @@ -943,7 +920,7 @@ void NexFriends::updateMyPresence(nexPresenceV2& myPresence) uint8 tempNexBufferArray[1024]; nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); myPresence.writeData(&packetBuffer); - nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 13, &packetBuffer, std::bind(genericFriendServiceNoResponseHandlerWithoutCB, std::placeholders::_1), false); + nexCon->callMethod(NEX_PROTOCOL_FRIENDS_WIIU, 13, &packetBuffer, +[](nexServiceResponse_t* nexResponse){}, false); } void NexFriends::update() diff --git a/src/Cemu/nex/nexFriends.h b/src/Cemu/nex/nexFriends.h index 16548bf3..06c75110 100644 --- a/src/Cemu/nex/nexFriends.h +++ b/src/Cemu/nex/nexFriends.h @@ -248,9 +248,9 @@ public: nexPrincipalPreference(uint8 ukn0, uint8 ukn1, uint8 ukn2) { - this->ukn0 = ukn0; - this->ukn1 = ukn1; - this->ukn2 = ukn2; + this->showOnline = ukn0; + this->showGame = ukn1; + this->blockFriendRequests = ukn2; } nexPrincipalPreference(nexPacketBuffer* pb) @@ -260,21 +260,21 @@ public: void writeData(nexPacketBuffer* pb) const override { - pb->writeU8(ukn0); - pb->writeU8(ukn1); - pb->writeU8(ukn2); + pb->writeU8(showOnline); + pb->writeU8(showGame); + pb->writeU8(blockFriendRequests); } void readData(nexPacketBuffer* pb) override { - ukn0 = pb->readU8(); - ukn1 = pb->readU8(); - ukn2 = pb->readU8(); + showOnline = pb->readU8(); + showGame = pb->readU8(); + blockFriendRequests = pb->readU8(); } public: - uint8 ukn0; - uint8 ukn1; - uint8 ukn2; + uint8 showOnline; + uint8 showGame; + uint8 blockFriendRequests; }; class nexComment : public nexType @@ -505,13 +505,12 @@ public: uint32 type; std::string msg; }; -class NexFriends; - -typedef void (*NEXFRIENDS_CALLBACK)(NexFriends* nexFriends, uint32 result, void* custom); class NexFriends { public: + using RpcErrorCode = int; // replace with enum class later + static const int ERR_NONE = 0; static const int ERR_RPC_FAILED = 1; static const int ERR_UNEXPECTED_RESULT = 2; @@ -544,27 +543,29 @@ public: int getPendingFriendRequestCount(); bool requestGetAllInformation(); - bool requestGetAllInformation(std::function cb); bool addProvisionalFriendByPidGuessed(uint32 principalId); - void acceptFriendRequest(uint64 messageId, std::function cb); - bool isOnline(); + // synchronous API (returns immediately) + bool requestGetAllInformation(std::function cb); void getFriendPIDs(uint32* pidList, uint32* pidCount, sint32 offset, sint32 count, bool includeFriendRequests); void getFriendRequestPIDs(uint32* pidList, uint32* pidCount, sint32 offset, sint32 count, bool includeIncoming, bool includeOutgoing); bool getFriendByPID(nexFriend& friendData, uint32 pid); bool getFriendRequestByPID(nexFriendRequest& friendRequestData, bool* isIncoming, uint32 searchedPid); bool getFriendRequestByMessageId(nexFriendRequest& friendRequestData, bool* isIncoming, uint64 messageId); + bool isOnline(); + void getMyPreference(nexPrincipalPreference& preference); - bool addProvisionalFriend(char* name, std::function cb); - void addFriendRequest(uint32 pid, const char* comment, std::function cb); - - void requestPrincipleBaseInfoByPID(nexPrincipalBasicInfo* basicInfo, uint32* pidList, sint32 count, NEXFRIENDS_CALLBACK cb, void* customParam); - void removeFriend(uint32 pid, std::function cb); - void cancelOutgoingProvisionalFriendRequest(uint32 pid, std::function cb); - void markFriendRequestsAsReceived(uint64* messageIdList, sint32 count, std::function cb); - + // asynchronous API (data has to be requested) + bool addProvisionalFriend(char* name, std::function cb); + void addFriendRequest(uint32 pid, const char* comment, std::function cb); + void requestPrincipleBaseInfoByPID(uint32* pidList, sint32 count, const std::function basicInfo)>& cb); + void removeFriend(uint32 pid, std::function cb); + void cancelOutgoingProvisionalFriendRequest(uint32 pid, std::function cb); + void markFriendRequestsAsReceived(uint64* messageIdList, sint32 count, std::function cb); + void acceptFriendRequest(uint64 messageId, std::function cb); + void deleteFriendRequest(uint64 messageId, std::function cb); // rejecting incoming friend request (differs from blocking friend requests) + bool updatePreferencesAsync(const nexPrincipalPreference newPreferences, std::function cb); void updateMyPresence(nexPresenceV2& myPresence); - bool updatePreferences(const nexPrincipalPreference& newPreferences); void setNotificationHandler(void(*notificationHandler)(NOTIFICATION_TYPE notificationType, uint32 pid)); @@ -578,7 +579,6 @@ private: static void handleResponse_acceptFriendRequest(nexService* nex, nexServiceResponse_t* response); static void handleResponse_getAllInformation(nexServiceResponse_t* response, NexFriends* nexFriends, std::function cb); - static void handleResponse_updatePreferences(nexServiceResponse_t* response, NexFriends* nexFriends, std::function cb); void generateNotification(NOTIFICATION_TYPE notificationType, uint32 pid); void trackNotifications(); @@ -618,6 +618,7 @@ private: }auth; // local friend state nexPresenceV2 myPresence; + nexPrincipalPreference myPreference; std::recursive_mutex mtx_lists; std::vector list_friends; diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 7ed3d67a..9a764593 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(CemuCommon StackAllocator.h SysAllocator.cpp SysAllocator.h + CafeString.h version.h ) diff --git a/src/Common/CafeString.h b/src/Common/CafeString.h new file mode 100644 index 00000000..45a515b1 --- /dev/null +++ b/src/Common/CafeString.h @@ -0,0 +1,73 @@ +#pragma once +#include "betype.h" +#include "util/helpers/StringHelpers.h" + +/* Helper classes to represent CafeOS strings in emulated memory */ +template +class CafeString // fixed buffer size, null-terminated, PPC char +{ + public: + bool assign(std::string_view sv) + { + if (sv.size()+1 >= N) + { + memcpy(data, sv.data(), sv.size()-1); + data[sv.size()-1] = '\0'; + return false; + } + memcpy(data, sv.data(), sv.size()); + data[sv.size()] = '\0'; + return true; + } + + uint8be data[N]; +}; + +template +class CafeWideString // fixed buffer size, null-terminated, PPC wchar_t (16bit big-endian) +{ + public: + bool assign(const uint16be* input) + { + size_t i = 0; + while(input[i]) + { + if(i >= N-1) + { + data[N-1] = 0; + return false; + } + data[i] = input[i]; + i++; + } + data[i] = 0; + return true; + } + + bool assignFromUTF8(std::string_view sv) + { + std::basic_string beStr = StringHelpers::FromUtf8(sv); + if(beStr.length() > N-1) + { + memcpy(data, beStr.data(), (N-1)*sizeof(uint16be)); + data[N-1] = 0; + return false; + } + memcpy(data, beStr.data(), beStr.length()*sizeof(uint16be)); + data[beStr.length()] = '\0'; + return true; + } + + uint16be data[N]; +}; + +namespace CafeStringHelpers +{ + static uint32 Length(const uint16be* input, uint32 maxLength) + { + uint32 i = 0; + while(input[i] && i < maxLength) + i++; + return i; + } +}; diff --git a/src/Common/StackAllocator.h b/src/Common/StackAllocator.h index 750db13f..a69b7aaa 100644 --- a/src/Common/StackAllocator.h +++ b/src/Common/StackAllocator.h @@ -29,9 +29,36 @@ public: T* GetPointer() const { return m_ptr; } uint32 GetMPTR() const { return MEMPTR(m_ptr).GetMPTR(); } uint32 GetMPTRBE() const { return MEMPTR(m_ptr).GetMPTRBE(); } - - operator T*() const { return GetPointer(); } + + T* operator&() { return GetPointer(); } + explicit operator T*() const { return GetPointer(); } explicit operator uint32() const { return GetMPTR(); } + explicit operator bool() const { return *m_ptr != 0; } + + // for arrays (count > 1) allow direct access via [] operator + template + requires (c > 1) + T& operator[](const uint32 index) + { + return m_ptr[index]; + } + + // if count is 1, then allow direct value assignment via = operator + template + requires (c == 1) + T& operator=(const T& rhs) + { + *m_ptr = rhs; + return *m_ptr; + } + + // if count is 1, then allow == and != operators + template + requires (c == 1) + bool operator==(const T& rhs) const + { + return *m_ptr == rhs; + } private: static const uint32 kStaticMemOffset = 64; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c0d975ec..3156f2de 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2198,6 +2198,7 @@ void MainWindow::RecreateMenu() debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMP), _("&Coreinit MP API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("&Coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_FP), _("&NN FP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_FP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("&GX2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("&Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::InputAPI), _("&Input API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::InputAPI)); diff --git a/src/util/helpers/StringHelpers.h b/src/util/helpers/StringHelpers.h index 24e70d49..54141808 100644 --- a/src/util/helpers/StringHelpers.h +++ b/src/util/helpers/StringHelpers.h @@ -2,6 +2,7 @@ #include "boost/nowide/convert.hpp" #include +// todo - move the Cafe/PPC specific parts to CafeString.h eventually namespace StringHelpers { // convert Wii U big-endian wchar_t string to utf8 string diff --git a/src/util/highresolutiontimer/HighResolutionTimer.h b/src/util/highresolutiontimer/HighResolutionTimer.h index 12dc0751..7a545c86 100644 --- a/src/util/highresolutiontimer/HighResolutionTimer.h +++ b/src/util/highresolutiontimer/HighResolutionTimer.h @@ -36,6 +36,16 @@ public: static HighResolutionTimer now(); static HRTick getFrequency(); + static HRTick microsecondsToTicks(uint64 microseconds) + { + return microseconds * m_freq / 1000000; + } + + static uint64 ticksToMicroseconds(HRTick ticks) + { + return ticks * 1000000 / m_freq; + } + private: HighResolutionTimer(uint64 timePoint) : m_timePoint(timePoint) {}; From 2959802ae25cf026a6f8ea08b81b02282b650687 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:24:59 +0200 Subject: [PATCH 046/314] Use utf-8 for exe path --- src/gui/CemuApp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 53a42a10..f48957df 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -58,7 +58,7 @@ bool CemuApp::OnInit() { fs::path user_data_path, config_path, cache_path, data_path; auto standardPaths = wxStandardPaths::Get(); - fs::path exePath(standardPaths.GetExecutablePath().ToStdString()); + fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); #ifdef PORTABLE #if MACOS_BUNDLE exePath = exePath.parent_path().parent_path().parent_path(); @@ -88,7 +88,7 @@ bool CemuApp::OnInit() #endif auto failed_write_access = ActiveSettings::LoadOnce(exePath, user_data_path, config_path, cache_path, data_path); for (auto&& path : failed_write_access) - wxMessageBox(formatWxString(_("Cemu can't write to {}!"), path.generic_string()), + wxMessageBox(formatWxString(_("Cemu can't write to {}!"), wxString::FromUTF8(_pathToUtf8(path))), _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr); NetworkConfig::LoadOnce(); From c440ecdf36495008541e7ea39bd2000f82cec7a7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 17 Oct 2023 06:16:29 +0200 Subject: [PATCH 047/314] FPD: Fix a crash due to incorrect instantiation --- src/Cafe/IOSU/legacy/iosu_fpd.cpp | 18 +++++++++--------- src/Cemu/nex/nexTypes.h | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index 75bf0463..bcd580ef 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -173,7 +173,7 @@ namespace iosu return t; } - void NexPresenceToGameMode(nexPresenceV2* presence, GameMode* gameMode) + void NexPresenceToGameMode(const nexPresenceV2* presence, GameMode* gameMode) { memset(gameMode, 0, sizeof(GameMode)); gameMode->joinFlagMask = presence->joinFlagMask; @@ -185,9 +185,9 @@ namespace iosu memcpy(gameMode->appSpecificData, presence->appSpecificData, 0x14); } - void GameModeToNexPresence(GameMode* gameMode, nexPresenceV2* presence) + void GameModeToNexPresence(const GameMode* gameMode, nexPresenceV2* presence) { - memset(presence, 0, sizeof(nexPresenceV2)); + *presence = {}; presence->joinFlagMask = gameMode->joinFlagMask; presence->joinAvailability = (uint8)(uint32)gameMode->matchmakeType; presence->gameId = gameMode->joinGameId; @@ -197,7 +197,7 @@ namespace iosu memcpy(presence->appSpecificData, gameMode->appSpecificData, 0x14); } - void NexFriendToFPDFriendData(FriendData* friendData, nexFriend* frd) + void NexFriendToFPDFriendData(const nexFriend* frd, FriendData* friendData) { memset(friendData, 0, sizeof(FriendData)); // setup friend data @@ -232,7 +232,7 @@ namespace iosu convertFPDTimestampToDate(frd->lastOnlineTimestamp, &friendData->friendExtraData.lastOnline); } - void NexFriendRequestToFPDFriendData(FriendData* friendData, nexFriendRequest* frdReq, bool isIncoming) + void NexFriendRequestToFPDFriendData(const nexFriendRequest* frdReq, bool isIncoming, FriendData* friendData) { memset(friendData, 0, sizeof(FriendData)); // setup friend data @@ -282,7 +282,7 @@ namespace iosu convertFPDTimestampToDate(frdReq->message.expireTimestamp, &friendData->requestExtraData.uknData1); } - void NexFriendRequestToFPDFriendRequest(FriendRequest* friendRequest, nexFriendRequest* frdReq, bool isIncoming) + void NexFriendRequestToFPDFriendRequest(const nexFriendRequest* frdReq, bool isIncoming, FriendRequest* friendRequest) { memset(friendRequest, 0, sizeof(FriendRequest)); @@ -1007,7 +1007,7 @@ namespace iosu cemuLog_log(LogType::Force, "GetFriendRequestListEx: Failed to get friend request"); return FPResult_RequestFailed; } - NexFriendRequestToFPDFriendRequest(friendRequests + i, &frdReq, incoming); + NexFriendRequestToFPDFriendRequest(&frdReq, incoming, friendRequests + i); } return FPResult_Ok; } @@ -1063,13 +1063,13 @@ namespace iosu nexFriendRequest frdReq; if (g_fpd.nexFriendSession->getFriendByPID(frd, pid)) { - NexFriendToFPDFriendData(friendData, &frd); + NexFriendToFPDFriendData(&frd, friendData); continue; } bool incoming = false; if (g_fpd.nexFriendSession->getFriendRequestByPID(frdReq, &incoming, pid)) { - NexFriendRequestToFPDFriendData(friendData, &frdReq, incoming); + NexFriendRequestToFPDFriendData(&frdReq, incoming, friendData); continue; } cemuLog_logDebug(LogType::Force, "GetFriendListEx: Failed to find friend or request with pid {}", pid); diff --git a/src/Cemu/nex/nexTypes.h b/src/Cemu/nex/nexTypes.h index 49edd3d3..f43a83f2 100644 --- a/src/Cemu/nex/nexTypes.h +++ b/src/Cemu/nex/nexTypes.h @@ -16,7 +16,9 @@ public: class nexType { -public: + public: + virtual ~nexType(){}; + virtual const char* getMetaName() { cemu_assert_unimplemented(); From 66711529bec7e652b12db3e9f9729d1bc04f5386 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:06:36 +0200 Subject: [PATCH 048/314] Avoid wxGetKeyState since it asserts on Linux with wayland GTK Only modifier keys are allowed, but we used it to test for Escape --- src/gui/CemuApp.cpp | 1 - src/gui/guiWrapper.h | 4 ++++ src/gui/input/panels/InputPanel.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index f48957df..4acc1cf5 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -191,7 +191,6 @@ int CemuApp::FilterEvent(wxEvent& event) if(event.GetEventType() == wxEVT_KEY_DOWN) { const auto& key_event = (wxKeyEvent&)event; - wxGetKeyState(wxKeyCode::WXK_F17); g_window_info.set_keystate(fix_raw_keycode(key_event.GetRawKeyCode(), key_event.GetRawKeyFlags()), true); } else if(event.GetEventType() == wxEVT_KEY_UP) diff --git a/src/gui/guiWrapper.h b/src/gui/guiWrapper.h index dd77819c..ec94c1a0 100644 --- a/src/gui/guiWrapper.h +++ b/src/gui/guiWrapper.h @@ -41,18 +41,22 @@ enum struct PlatformKeyCodes : uint32 LCONTROL = VK_LCONTROL, RCONTROL = VK_RCONTROL, TAB = VK_TAB, + ESCAPE = VK_ESCAPE, #elif BOOST_OS_LINUX LCONTROL = GDK_KEY_Control_L, RCONTROL = GDK_KEY_Control_R, TAB = GDK_KEY_Tab, + ESCAPE = GDK_KEY_Escape, #elif BOOST_OS_MACOS LCONTROL = kVK_Control, RCONTROL = kVK_RightControl, TAB = kVK_Tab, + ESCAPE = kVK_Escape, #else LCONTROL = 0, RCONTROL = 0, TAB = 0, + ESCAPE = 0, #endif }; diff --git a/src/gui/input/panels/InputPanel.cpp b/src/gui/input/panels/InputPanel.cpp index 6c1b8dda..514461fd 100644 --- a/src/gui/input/panels/InputPanel.cpp +++ b/src/gui/input/panels/InputPanel.cpp @@ -1,3 +1,4 @@ +#include "gui/guiWrapper.h" #include "gui/input/panels/InputPanel.h" #include @@ -26,7 +27,7 @@ void InputPanel::on_timer(const EmulatedControllerPtr& emulated_controller, cons const auto mapping = reinterpret_cast(element->GetClientData()); // reset mapping - if(std::exchange(m_right_down, false) || wxGetKeyState(WXK_ESCAPE)) + if(std::exchange(m_right_down, false) || gui_isKeyDown(PlatformKeyCodes::ESCAPE)) { element->SetBackgroundColour(kKeyColourNormalMode); m_color_backup[element->GetId()] = kKeyColourNormalMode; From 63861bf812ef6364b90b0f84412b5ac76bbc78ef Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:07:43 +0200 Subject: [PATCH 049/314] Fix SpotPass downloads on Linux/MacOS --- src/Cafe/IOSU/legacy/iosu_boss.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_boss.cpp b/src/Cafe/IOSU/legacy/iosu_boss.cpp index 7b7ce250..c2c1eb51 100644 --- a/src/Cafe/IOSU/legacy/iosu_boss.cpp +++ b/src/Cafe/IOSU/legacy/iosu_boss.cpp @@ -119,7 +119,7 @@ namespace iosu uint32 turn_state = 0; uint32 wait_state = 0; - uint32 http_status_code = 0; + long http_status_code = 0; ContentType content_type = ContentType::kUnknownContent; std::vector result_buffer; @@ -592,6 +592,7 @@ namespace iosu int curl_result = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &it->http_status_code); + static_assert(sizeof(it->http_status_code) == sizeof(long)); //it->turn_state = kFinished; @@ -909,10 +910,10 @@ namespace iosu return it != g_boss.tasks.cend() ? std::make_pair(it->exec_count, it->processed_length) : std::make_pair(0u, (uint64)0); } - std::pair task_get_http_status_code(const char* taskId, uint32 accountId, uint64 titleId) + std::pair task_get_http_status_code(const char* taskId, uint32 accountId, uint64 titleId) { const auto it = get_task(taskId, accountId, titleId); - return it != g_boss.tasks.cend() ? std::make_pair(it->exec_count, it->http_status_code) : std::make_pair(0u, (uint32)0); + return it != g_boss.tasks.cend() ? std::make_pair(it->exec_count, it->http_status_code) : std::make_pair(0u, (long)0); } std::pair task_get_turn_state(const char* taskId, uint32 accountId, uint64 titleId) From 9ec50b865ddea2ffda33fbb34f0cdebcba643b55 Mon Sep 17 00:00:00 2001 From: bslhq Date: Tue, 17 Oct 2023 20:45:55 +0800 Subject: [PATCH 050/314] Fix nfc menu list of recent nfc files (#996) --- src/gui/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3156f2de..92594d00 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1751,7 +1751,7 @@ void MainWindow::UpdateNFCMenu() if (entry.empty()) continue; - if (!fs::exists(entry)) + if (!fs::exists(_utf8ToPath(entry))) continue; if (recentFileIndex == 0) From 9bb409314d307024899c7e41d1b4980ca73bb588 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:43:36 +0200 Subject: [PATCH 051/314] coreinit: Fix potential race condition in IPC code --- src/Cafe/IOSU/kernel/iosu_kernel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Cafe/IOSU/kernel/iosu_kernel.cpp b/src/Cafe/IOSU/kernel/iosu_kernel.cpp index 52097698..666e0373 100644 --- a/src/Cafe/IOSU/kernel/iosu_kernel.cpp +++ b/src/Cafe/IOSU/kernel/iosu_kernel.cpp @@ -578,8 +578,12 @@ namespace iosu return r; } + std::mutex sMtxReply[3]; + void _IPCReplyAndRelease(IOSDispatchableCommand* dispatchCmd, uint32 result) { + cemu_assert(dispatchCmd->ppcCoreIndex < 3); + std::unique_lock _l(sMtxReply[(uint32)dispatchCmd->ppcCoreIndex]); cemu_assert(dispatchCmd >= sIPCDispatchableCommandPool.GetPtr() && dispatchCmd < sIPCDispatchableCommandPool.GetPtr() + sIPCDispatchableCommandPool.GetCount()); dispatchCmd->originalBody->result = result; // submit to COS From b0a7fd4e072434d910600c62e7ce7199a2c70c81 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:49:12 +0200 Subject: [PATCH 052/314] Set default alignment for SysAllocator to cache-line size Avoids memory corruptions when the memory is cleared via DCZeroRange. Seen in BotW with AX AUX buffers. --- src/Common/SysAllocator.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Common/SysAllocator.h b/src/Common/SysAllocator.h index 7930a16b..7a11601e 100644 --- a/src/Common/SysAllocator.h +++ b/src/Common/SysAllocator.h @@ -1,10 +1,10 @@ #pragma once -#include - uint32 coreinit_allocFromSysArea(uint32 size, uint32 alignment); class SysAllocatorBase; +#define SYSALLOCATOR_GUARDS 0 // if 1, create a magic constant at the top of each memory allocation which is used to check for memory corruption + class SysAllocatorContainer { public: @@ -29,9 +29,7 @@ private: virtual void Initialize() = 0; }; - - -template +template class SysAllocator : public SysAllocatorBase { public: @@ -68,11 +66,17 @@ public: T* GetPtr() const { +#if SYSALLOCATOR_GUARDS + cemu_assert(*(uint32*)((uint8*)m_sysMem.GetPtr()+(sizeof(T) * count)) == 0x112A33C4); +#endif return m_sysMem.GetPtr(); } uint32 GetMPTR() const { +#if SYSALLOCATOR_GUARDS + cemu_assert(*(uint32*)((uint8*)m_sysMem.GetPtr()+(sizeof(T) * count)) == 0x112A33C4); +#endif return m_sysMem.GetMPTR(); } @@ -130,11 +134,17 @@ private: { if (m_sysMem.GetMPTR() != 0) return; - // alloc mem - m_sysMem = { coreinit_allocFromSysArea(sizeof(T) * count, alignment) }; + uint32 guardSize = 0; +#if SYSALLOCATOR_GUARDS + guardSize = 4; +#endif + m_sysMem = { coreinit_allocFromSysArea(sizeof(T) * count + guardSize, alignment) }; // copy temp buffer to mem and clear it memcpy(m_sysMem.GetPtr(), m_tempData.data(), sizeof(T)*count); +#if SYSALLOCATOR_GUARDS + *(uint32*)((uint8*)m_sysMem.GetPtr()+(sizeof(T) * count)) = 0x112A33C4; +#endif m_tempData.clear(); } @@ -197,9 +207,8 @@ private: { if (m_sysMem.GetMPTR() != 0) return; - // alloc mem - m_sysMem = { coreinit_allocFromSysArea(sizeof(T), 8) }; + m_sysMem = { coreinit_allocFromSysArea(sizeof(T), 32) }; // copy temp buffer to mem and clear it *m_sysMem = m_tempData; } From f3c95f72e74d8a5f5873061fbb994643c63ec9c5 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:55:52 +0200 Subject: [PATCH 053/314] nn_fp: Multiple fixes --- src/Cafe/IOSU/legacy/iosu_fpd.cpp | 3 ++- src/Cafe/OS/libs/nn_fp/nn_fp.cpp | 13 +++++++------ src/util/ChunkedHeap/ChunkedHeap.h | 10 +++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index bcd580ef..9130b28d 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -328,6 +328,7 @@ namespace iosu static const auto FPResult_Ok = 0; static const auto FPResult_InvalidIPCParam = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_FP, 0x680); static const auto FPResult_RequestFailed = BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // figure out proper error code + static const auto FPResult_Aborted = BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_FP, 0x3480); class FPDService : public iosu::nn::IPCSimpleService { @@ -586,7 +587,7 @@ namespace iosu if (!ActiveSettings::IsOnlineEnabled()) { // not online, fail immediately - return BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // todo + return FPResult_Ok; // Splatoon expects this to always return success otherwise it will softlock. This should be FPResult_Aborted? } StartFriendSession(); fpdClient->hasLoggedIn = true; diff --git a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp index 53ab3eef..fc757ea9 100644 --- a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp +++ b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp @@ -55,8 +55,8 @@ namespace nn { std::unique_lock _l(m_mtx); void* p = g_fp.fpBufferHeap->alloc(size, 32); - uint32 heapSize, allocationSize, allocNum; - g_fp.fpBufferHeap->getStats(heapSize, allocationSize, allocNum); + if (!p) + cemuLog_log(LogType::Force, "nn_fp: Internal heap is full"); return p; } @@ -153,8 +153,11 @@ namespace nn totalBufferSize += m_vec[i].size; totalBufferSize = (totalBufferSize+31)&~31; } - m_dataBuffer = FPIpcBufferAllocator.Allocate(totalBufferSize, 32); - cemu_assert_debug(m_dataBuffer); + if(totalBufferSize > 0) + { + m_dataBuffer = FPIpcBufferAllocator.Allocate(totalBufferSize, 32); + cemu_assert_debug(m_dataBuffer); + } // update Ioctl vector addresses for(uint8 i=0; im_asyncResult = result; // store result in variable since FP callbacks pass a pointer to nnResult and not the value directly ipcCtx->CopyBackOutputs(); - cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler BeforeCallback"); PPCCoreCallback(ipcCtx->m_callbackFunc, &ipcCtx->m_asyncResult, ipcCtx->m_callbackParam); - cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler AfterCallback"); delete ipcCtx; osLib_returnFromFunction(hCPU, 0); } diff --git a/src/util/ChunkedHeap/ChunkedHeap.h b/src/util/ChunkedHeap/ChunkedHeap.h index 8e458d40..abc45429 100644 --- a/src/util/ChunkedHeap/ChunkedHeap.h +++ b/src/util/ChunkedHeap/ChunkedHeap.h @@ -489,6 +489,11 @@ private: bool _alloc(uint32 size, uint32 alignment, uint32& allocOffsetOut) { + if(size == 0) + { + size = 1; // zero-sized allocations are not supported + cemu_assert_suspicious(); + } // find smallest bucket to scan uint32 alignmentM1 = alignment - 1; uint32 bucketIndex = ulog2(size); @@ -521,7 +526,10 @@ private: { auto it = map_allocatedRange.find(addrOffset); if (it == map_allocatedRange.end()) - assert_dbg(); + { + cemuLog_log(LogType::Force, "VHeap internal error"); + cemu_assert(false); + } allocRange_t* range = it->second; map_allocatedRange.erase(it); m_statsMemAllocated -= range->size; From 5047c4d083d0cb939200f29b5554dce697847998 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:21:52 +0100 Subject: [PATCH 054/314] GDBStub: Fix checkSum string to int conversion (#1029) --- src/Cafe/HW/Espresso/Debugger/GDBStub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp index e934e55d..c8308594 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp +++ b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp @@ -356,7 +356,7 @@ void GDBServer::ThreadFunc() } char checkSumStr[2]; receiveMessage(checkSumStr, 2); - uint32_t checkSum = std::stoi(checkSumStr, nullptr, 16); + uint32_t checkSum = std::stoi(std::string(checkSumStr, sizeof(checkSumStr)), nullptr, 16); assert((checkedSum & 0xFF) == checkSum); HandleCommand(message); From 09409a51089db5432c0bdd7ec8f2e3907a8b2669 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:24:26 +0100 Subject: [PATCH 055/314] Set macOS min version to 12.0 Monterey (#1025) --- src/CMakeLists.txt | 1 + src/resource/MacOSXBundleInfo.plist.in | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00a43a80..8ab07e7a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,7 @@ if (MACOS_BUNDLE) set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2023 Cemu Project") set(MACOSX_BUNDLE_CATEGORY "public.app-category.games") + set(MACOSX_MINIMUM_SYSTEM_VERSION "12.0") set_target_properties(CemuBin PROPERTIES MACOSX_BUNDLE true diff --git a/src/resource/MacOSXBundleInfo.plist.in b/src/resource/MacOSXBundleInfo.plist.in index c181b388..74dc0d59 100644 --- a/src/resource/MacOSXBundleInfo.plist.in +++ b/src/resource/MacOSXBundleInfo.plist.in @@ -26,7 +26,9 @@ NSHumanReadableCopyright ${MACOSX_BUNDLE_COPYRIGHT} - LSApplicationCategoryType - ${MACOSX_BUNDLE_CATEGORY} + LSApplicationCategoryType + ${MACOSX_BUNDLE_CATEGORY} + LSMinimumSystemVersion + ${MACOSX_MINIMUM_SYSTEM_VERSION} - \ No newline at end of file + From 18490830738c61b1b35fa11a9207bcf3fc4edd3e Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Wed, 6 Dec 2023 01:33:29 +0000 Subject: [PATCH 056/314] Use hidapi for Wiimotes on Windows (#1033) --- CMakeLists.txt | 5 +- src/input/CMakeLists.txt | 11 +- .../api/Wiimote/WiimoteControllerProvider.cpp | 4 - .../api/Wiimote/windows/WinWiimoteDevice.cpp | 130 ------------------ .../api/Wiimote/windows/WinWiimoteDevice.h | 24 ---- vcpkg.json | 5 +- 6 files changed, 4 insertions(+), 175 deletions(-) delete mode 100644 src/input/api/Wiimote/windows/WinWiimoteDevice.cpp delete mode 100644 src/input/api/Wiimote/windows/WinWiimoteDevice.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dc1a6f2..c988508c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,10 +89,9 @@ if (WIN32) option(ENABLE_XINPUT "Enables the usage of XInput" ON) option(ENABLE_DIRECTINPUT "Enables the usage of DirectInput" ON) add_compile_definitions(HAS_DIRECTINPUT) - set(ENABLE_WIIMOTE ON) -elseif (UNIX) - option(ENABLE_HIDAPI "Build with HIDAPI" ON) endif() + +option(ENABLE_HIDAPI "Build with HIDAPI" ON) option(ENABLE_SDL "Enables the SDLController backend" ON) # audio backends diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index 53b4dc3b..9f7873a1 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -70,18 +70,9 @@ if (ENABLE_WIIMOTE) api/Wiimote/NativeWiimoteController.h api/Wiimote/NativeWiimoteController.cpp api/Wiimote/WiimoteDevice.h - ) - if (ENABLE_HIDAPI) - target_sources(CemuInput PRIVATE api/Wiimote/hidapi/HidapiWiimote.cpp api/Wiimote/hidapi/HidapiWiimote.h - ) - elseif (WIN32) - target_sources(CemuInput PRIVATE - api/Wiimote/windows/WinWiimoteDevice.cpp - api/Wiimote/windows/WinWiimoteDevice.h - ) - endif() + ) endif () diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.cpp b/src/input/api/Wiimote/WiimoteControllerProvider.cpp index 0ca00a1a..55f28c01 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.cpp +++ b/src/input/api/Wiimote/WiimoteControllerProvider.cpp @@ -2,11 +2,7 @@ #include "input/api/Wiimote/NativeWiimoteController.h" #include "input/api/Wiimote/WiimoteMessages.h" -#ifdef HAS_HIDAPI #include "input/api/Wiimote/hidapi/HidapiWiimote.h" -#elif BOOST_OS_WINDOWS -#include "input/api/Wiimote/windows/WinWiimoteDevice.h" -#endif #include #include diff --git a/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp b/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp deleted file mode 100644 index 09d73013..00000000 --- a/src/input/api/Wiimote/windows/WinWiimoteDevice.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "input/api/Wiimote/windows/WinWiimoteDevice.h" - -#include -#include - -#pragma comment(lib, "Setupapi.lib") -#pragma comment(lib, "hid.lib") - -WinWiimoteDevice::WinWiimoteDevice(HANDLE handle, std::vector identifier) - : m_handle(handle), m_identifier(std::move(identifier)) -{ - m_overlapped.hEvent = CreateEvent(nullptr, TRUE, TRUE, nullptr); -} - -WinWiimoteDevice::~WinWiimoteDevice() -{ - CancelIo(m_handle); - ResetEvent(m_overlapped.hEvent); - CloseHandle(m_handle); -} - -bool WinWiimoteDevice::write_data(const std::vector& data) -{ - return HidD_SetOutputReport(m_handle, (void*)data.data(), (ULONG)data.size()); -} - -std::optional> WinWiimoteDevice::read_data() -{ - DWORD read = 0; - std::array buffer{}; - - if (!ReadFile(m_handle, buffer.data(), (DWORD)buffer.size(), &read, &m_overlapped)) - { - const auto error = GetLastError(); - if (error == ERROR_DEVICE_NOT_CONNECTED) - return {}; - else if (error == ERROR_IO_PENDING) - { - const auto wait_result = WaitForSingleObject(m_overlapped.hEvent, 100); - if (wait_result == WAIT_TIMEOUT) - { - CancelIo(m_handle); - ResetEvent(m_overlapped.hEvent); - return {}; - } - else if (wait_result == WAIT_FAILED) - return {}; - - if (GetOverlappedResult(m_handle, &m_overlapped, &read, FALSE) == FALSE) - return {}; - } - else if (error == ERROR_INVALID_HANDLE) - { - ResetEvent(m_overlapped.hEvent); - return {}; - } - else - { - cemu_assert_debug(false); - } - } - - ResetEvent(m_overlapped.hEvent); - if (read == 0) - return {}; - - return {{buffer.cbegin(), buffer.cbegin() + read}}; -} - -std::vector WinWiimoteDevice::get_devices() -{ - std::vector result; - - GUID hid_guid; - HidD_GetHidGuid(&hid_guid); - - const auto device_info = SetupDiGetClassDevs(&hid_guid, nullptr, nullptr, (DIGCF_DEVICEINTERFACE | DIGCF_PRESENT)); - - for (DWORD index = 0; ; ++index) - { - SP_DEVICE_INTERFACE_DATA device_data{}; - device_data.cbSize = sizeof(device_data); - if (SetupDiEnumDeviceInterfaces(device_info, nullptr, &hid_guid, index, &device_data) == FALSE) - break; - - DWORD device_data_len; - if (SetupDiGetDeviceInterfaceDetail(device_info, &device_data, nullptr, 0, &device_data_len, nullptr) == FALSE - && GetLastError() != ERROR_INSUFFICIENT_BUFFER) - continue; - - std::vector detail_data_buffer; - detail_data_buffer.resize(device_data_len); - - const auto detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA)detail_data_buffer.data(); - detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - - if (SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, device_data_len, nullptr, nullptr) - == FALSE) - continue; - - HANDLE device_handle = CreateFile(detail_data->DevicePath, (GENERIC_READ | GENERIC_WRITE), - (FILE_SHARE_READ | FILE_SHARE_WRITE), nullptr, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, nullptr); - if (device_handle == INVALID_HANDLE_VALUE) - continue; - - HIDD_ATTRIBUTES attributes{}; - attributes.Size = sizeof(attributes); - if (HidD_GetAttributes(device_handle, &attributes) == FALSE) - { - CloseHandle(device_handle); - continue; - } - - if (attributes.VendorID != 0x057e || (attributes.ProductID != 0x0306 && attributes.ProductID != 0x0330)) - { - CloseHandle(device_handle); - continue; - } - - result.emplace_back(std::make_shared(device_handle, detail_data_buffer)); - } - - return result; -} - -bool WinWiimoteDevice::operator==(WiimoteDevice& o) const -{ - return m_identifier == static_cast(o).m_identifier; -} diff --git a/src/input/api/Wiimote/windows/WinWiimoteDevice.h b/src/input/api/Wiimote/windows/WinWiimoteDevice.h deleted file mode 100644 index 077882db..00000000 --- a/src/input/api/Wiimote/windows/WinWiimoteDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "input/api/Wiimote/WiimoteDevice.h" - -class WinWiimoteDevice : public WiimoteDevice -{ -public: - WinWiimoteDevice(HANDLE handle, std::vector identifier); - ~WinWiimoteDevice(); - - bool write_data(const std::vector& data) override; - std::optional> read_data() override; - - static std::vector get_devices(); - - bool operator==(WiimoteDevice& o) const override; - -private: - HANDLE m_handle; - OVERLAPPED m_overlapped{}; - std::vector m_identifier; -}; - -using WiimoteDevice_t = WinWiimoteDevice; diff --git a/vcpkg.json b/vcpkg.json index 7ea8058e..d14a1a8a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -26,10 +26,7 @@ "boost-static-string", "boost-random", "fmt", - { - "name": "hidapi", - "platform": "!windows" - }, + "hidapi", "libpng", "glm", { From b6aaf6633063be47d89a8216e269e32aec5a4b49 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:07:50 -0800 Subject: [PATCH 057/314] [AppImage] Bundle libstdc++ (#1038) --- dist/linux/appimage.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/linux/appimage.sh b/dist/linux/appimage.sh index 7043a759..60a50329 100755 --- a/dist/linux/appimage.sh +++ b/dist/linux/appimage.sh @@ -46,6 +46,7 @@ fi echo "Cemu Version Cemu-${GITVERSION}" rm AppDir/usr/lib/libwayland-client.so.0 +cp /lib/x86_64-linux-gnu/libstdc++.so.6 AppDir/usr/lib/ echo -e "export LC_ALL=C\nexport FONTCONFIG_PATH=/etc/fonts" >> AppDir/apprun-hooks/linuxdeploy-plugin-gtk.sh VERSION="${GITVERSION}" ./mkappimage.AppImage --appimage-extract-and-run "${GITHUB_WORKSPACE}"/AppDir From f6bb666abf9a34bab705b53bf8fb913696bb4b31 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Sun, 10 Dec 2023 08:30:08 +0100 Subject: [PATCH 058/314] Mac: Add wua filetype to info.plist (#1039) --- src/CMakeLists.txt | 1 + src/resource/MacOSXBundleInfo.plist.in | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ab07e7a..de9a6600 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,6 +82,7 @@ if (MACOS_BUNDLE) set(MACOSX_BUNDLE_CATEGORY "public.app-category.games") set(MACOSX_MINIMUM_SYSTEM_VERSION "12.0") + set(MACOSX_BUNDLE_TYPE_EXTENSION "wua") set_target_properties(CemuBin PROPERTIES MACOSX_BUNDLE true diff --git a/src/resource/MacOSXBundleInfo.plist.in b/src/resource/MacOSXBundleInfo.plist.in index 74dc0d59..98064735 100644 --- a/src/resource/MacOSXBundleInfo.plist.in +++ b/src/resource/MacOSXBundleInfo.plist.in @@ -30,5 +30,18 @@ ${MACOSX_BUNDLE_CATEGORY} LSMinimumSystemVersion ${MACOSX_MINIMUM_SYSTEM_VERSION} + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + ${MACOSX_BUNDLE_TYPE_EXTENSION} + + CFBundleTypeName + Wii U File + CFBundleTypeRole + Viewer + + From 9398c0ca6b142ec92e297dd099bbcba7f22749b1 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:18:17 +0100 Subject: [PATCH 059/314] Latte: Simplify and fix texture copy --- src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp | 26 +++------------------ src/Cafe/HW/Latte/Core/LatteTexture.cpp | 18 ++++++++++++-- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp b/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp index df99307c..4f5b24ad 100644 --- a/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp @@ -46,9 +46,7 @@ void LatteSurfaceCopy_copySurfaceNew(MPTR srcPhysAddr, MPTR srcMipAddr, uint32 s // mark source and destination texture as still in use LatteTC_MarkTextureStillInUse(destinationTexture); LatteTC_MarkTextureStillInUse(sourceTexture); - // determine GL slice indices sint32 realSrcSlice = srcSlice; - sint32 realDstSlice = dstSlice; if (LatteTexture_doesEffectiveRescaleRatioMatch(sourceTexture, sourceView->firstMip, destinationTexture, destinationView->firstMip)) { // adjust copy size @@ -62,29 +60,11 @@ void LatteSurfaceCopy_copySurfaceNew(MPTR srcPhysAddr, MPTR srcMipAddr, uint32 s LatteTexture_scaleToEffectiveSize(sourceTexture, &effectiveCopyWidth, &effectiveCopyHeight, 0); // copy slice if (sourceView->baseTexture->isDepth != destinationView->baseTexture->isDepth) - { g_renderer->surfaceCopy_copySurfaceWithFormatConversion(sourceTexture, sourceView->firstMip, sourceView->firstSlice, destinationTexture, destinationView->firstMip, destinationView->firstSlice, copyWidth, copyHeight); - uint64 eventCounter = LatteTexture_getNextUpdateEventCounter(); - LatteTexture_MarkDynamicTextureAsChanged(destinationTexture->baseView, destinationView->firstSlice, destinationView->firstMip, eventCounter); - } else - { - // calculate mip levels relative to texture base - sint32 texDstMipLevel; - if (destinationTexture->physAddress == dstPhysAddr) - { - texDstMipLevel = dstLevel; - } - else - { - // todo - handle mip addresses properly - texDstMipLevel = dstLevel - destinationView->firstMip; - } - - g_renderer->texture_copyImageSubData(sourceTexture, sourceView->firstMip, 0, 0, realSrcSlice, destinationTexture, texDstMipLevel, 0, 0, realDstSlice, effectiveCopyWidth, effectiveCopyHeight, 1); - uint64 eventCounter = LatteTexture_getNextUpdateEventCounter(); - LatteTexture_MarkDynamicTextureAsChanged(destinationTexture->baseView, destinationView->firstSlice, texDstMipLevel, eventCounter); - } + g_renderer->texture_copyImageSubData(sourceTexture, sourceView->firstMip, 0, 0, realSrcSlice, destinationTexture, destinationView->firstMip, 0, 0, destinationView->firstSlice, effectiveCopyWidth, effectiveCopyHeight, 1); + const uint64 eventCounter = LatteTexture_getNextUpdateEventCounter(); + LatteTexture_MarkDynamicTextureAsChanged(destinationTexture->baseView, destinationView->firstSlice, destinationView->firstMip, eventCounter); } else { diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 19162e04..42a9d8c6 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -836,6 +836,11 @@ bool IsDimensionCompatibleForView(Latte::E_DIM baseDim, Latte::E_DIM viewDim) // not compatible incompatibleDim = true; } + else if (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_3D) + { + // incompatible by default, but may be compatible if the view matches the depth of the base texture and starts at mip/slice 0 + incompatibleDim = true; + } else if ((baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_CUBEMAP) || (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_2D)) { @@ -872,7 +877,9 @@ VIEWCOMPATIBILITY LatteTexture_CanTextureBeRepresentedAsView(LatteTexture* baseT return VIEW_NOT_COMPATIBLE; // depth and non-depth formats are never compatible (on OpenGL) if (!LatteTexture_IsTexelSizeCompatibleFormat(baseTexture->format, format) || baseTexture->width != width || baseTexture->height != height) return VIEW_NOT_COMPATIBLE; - if (!IsDimensionCompatibleForView(baseTexture->dim, dimView)) + // 3D views are only compatible on Vulkan if they match the base texture in regards to mip and slice count + bool isCompatible3DView = dimView == Latte::E_DIM::DIM_3D && baseTexture->dim == dimView && firstSlice == 0 && firstMip == 0 && baseTexture->mipLevels == numMip && baseTexture->depth == numSlice; + if (!isCompatible3DView && !IsDimensionCompatibleForView(baseTexture->dim, dimView)) return VIEW_NOT_COMPATIBLE; if (baseTexture->isDepth && baseTexture->format != format) { @@ -999,6 +1006,7 @@ void LatteTexture_RecreateTextureWithDifferentMipSliceCount(LatteTexture* textur // create new texture representation // if allowCreateNewDataTexture is true, a new texture will be created if necessary. If it is false, only existing textures may be used, except if a data-compatible version of the requested texture already exists and it's not view compatible +// the returned view will map to the provided mip and slice range within the created texture, this is to match the behavior of lookupSliceEx LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dimBase, Latte::E_DIM dimView, bool isDepth, bool allowCreateNewDataTexture) { if (format == Latte::E_GX2SURFFMT::INVALID_FORMAT) @@ -1105,11 +1113,17 @@ LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, si if (allowCreateNewDataTexture == false) return nullptr; LatteTextureView* view = LatteTexture_CreateTexture(0, dimBase, physAddr, physMipAddr, format, width, height, depth, pitch, firstMip + numMip, swizzle, tileMode, isDepth); + LatteTexture* newTexture = view->baseTexture; LatteTexture_GatherTextureRelations(view->baseTexture); LatteTexture_UpdateTextureFromDynamicChanges(view->baseTexture); // delete any individual smaller slices/mips that have become redundant LatteTexture_DeleteAbsorbedSubtextures(view->baseTexture); - return view; + // create view + sint32 relativeMipIndex; + sint32 relativeSliceIndex; + VIEWCOMPATIBILITY viewCompatibility = LatteTexture_CanTextureBeRepresentedAsView(newTexture, physAddr, width, height, pitch, dimView, format, isDepth, firstMip, numMip, firstSlice, numSlice, relativeMipIndex, relativeSliceIndex); + cemu_assert(viewCompatibility == VIEW_COMPATIBLE); + return view->baseTexture->GetOrCreateView(dimView, format, relativeMipIndex + firstMip, numMip, relativeSliceIndex + firstSlice, numSlice); } LatteTextureView* LatteTC_LookupTextureByData(MPTR physAddr, sint32 width, sint32 height, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, sint32* searchIndex) From 67f7ce815c0b97c5ff0f19e9c3ad9a6d64d756a7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:39:55 +0100 Subject: [PATCH 060/314] nn_pdm: Refactor code to use new module structure --- src/Cafe/CafeSystem.cpp | 7 +- src/Cafe/IOSU/PDM/iosu_pdm.cpp | 135 +++++++++++++++++++++++++++------ src/Cafe/IOSU/PDM/iosu_pdm.h | 7 +- 3 files changed, 117 insertions(+), 32 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 3d06281e..30dab1d4 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -530,7 +530,8 @@ namespace CafeSystem { // entries in this list are ordered by initialization order. Shutdown in reverse order iosu::kernel::GetModule(), - iosu::fpd::GetModule() + iosu::fpd::GetModule(), + iosu::pdm::GetModule(), }; // initialize all subsystems which are persistent and don't depend on a game running @@ -571,7 +572,6 @@ namespace CafeSystem iosu::iosuAcp_init(); iosu::boss_init(); iosu::nim::Initialize(); - iosu::pdm::Initialize(); iosu::odm::Initialize(); // init Cafe OS avm::Initialize(); @@ -840,7 +840,6 @@ namespace CafeSystem coreinit::OSSchedulerBegin(3); else coreinit::OSSchedulerBegin(1); - iosu::pdm::StartTrackingTime(GetForegroundTitleId()); } void LaunchForegroundTitle() @@ -970,8 +969,6 @@ namespace CafeSystem RPLLoader_ResetState(); for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it) (*it)->TitleStop(); - // stop time tracking - iosu::pdm::Stop(); // reset Cemu subsystems PPCRecompiler_Shutdown(); GraphicPack2::Reset(); diff --git a/src/Cafe/IOSU/PDM/iosu_pdm.cpp b/src/Cafe/IOSU/PDM/iosu_pdm.cpp index 45b4a1d8..e54529a9 100644 --- a/src/Cafe/IOSU/PDM/iosu_pdm.cpp +++ b/src/Cafe/IOSU/PDM/iosu_pdm.cpp @@ -1,4 +1,5 @@ #include "iosu_pdm.h" +#include "Cafe/CafeSystem.h" #include "config/ActiveSettings.h" #include "Common/FileStream.h" #include "util/helpers/Semaphore.h" @@ -17,7 +18,8 @@ namespace iosu { namespace pdm { - std::mutex sDiaryLock; + std::recursive_mutex sPlaystatsLock; + std::recursive_mutex sDiaryLock; fs::path GetPDFile(const char* filename) { @@ -80,14 +82,16 @@ namespace iosu static_assert((NUM_PLAY_STATS_ENTRIES * sizeof(PlayStatsEntry)) == 0x1400); } - void LoadPlaystats() + void OpenPlaystats() { + std::unique_lock _l(sPlaystatsLock); PlayStats.numEntries = 0; for (size_t i = 0; i < NUM_PLAY_STATS_ENTRIES; i++) { auto& e = PlayStats.entry[i]; memset(&e, 0, sizeof(PlayStatsEntry)); } + cemu_assert_debug(!PlayStats.fs); PlayStats.fs = FileStream::openFile2(GetPDFile("PlayStats.dat"), true); if (!PlayStats.fs) { @@ -98,18 +102,39 @@ namespace iosu { delete PlayStats.fs; PlayStats.fs = nullptr; - cemuLog_log(LogType::Force, "PlayStats.dat malformed"); + cemuLog_log(LogType::Force, "PlayStats.dat malformed. Time tracking wont be used"); // dont delete the existing file in case it could still be salvaged (todo) and instead just dont track play time return; } + PlayStats.numEntries = 0; PlayStats.fs->readData(&PlayStats.numEntries, sizeof(uint32be)); if (PlayStats.numEntries > NUM_PLAY_STATS_ENTRIES) PlayStats.numEntries = NUM_PLAY_STATS_ENTRIES; PlayStats.fs->readData(PlayStats.entry, NUM_PLAY_STATS_ENTRIES * 20); } + void ClosePlaystats() + { + std::unique_lock _l(sPlaystatsLock); + if (PlayStats.fs) + { + delete PlayStats.fs; + PlayStats.fs = nullptr; + } + } + + void UnloadPlaystats() + { + std::unique_lock _l(sPlaystatsLock); + cemu_assert_debug(!PlayStats.fs); // unloading expects that file is closed + PlayStats.numEntries = 0; + for(auto& it : PlayStats.entry) + it = PlayStatsEntry{}; + } + PlayStatsEntry* PlayStats_GetEntry(uint64 titleId) { + std::unique_lock _l(sPlaystatsLock); uint32be titleIdHigh = (uint32)(titleId>>32); uint32be titleIdLow = (uint32)(titleId & 0xFFFFFFFF); size_t numEntries = PlayStats.numEntries; @@ -121,7 +146,7 @@ namespace iosu return nullptr; } - void PlayStats_WriteEntry(PlayStatsEntry* entry, bool writeEntryCount = false) + void PlayStats_WriteEntryNoLock(PlayStatsEntry* entry, bool writeEntryCount = false) { if (!PlayStats.fs) return; @@ -141,8 +166,15 @@ namespace iosu } } + void PlayStats_WriteEntry(PlayStatsEntry* entry, bool writeEntryCount = false) + { + std::unique_lock _l(sPlaystatsLock); + PlayStats_WriteEntryNoLock(entry, writeEntryCount); + } + PlayStatsEntry* PlayStats_CreateEntry(uint64 titleId) { + std::unique_lock _l(sPlaystatsLock); bool entryCountChanged = false; PlayStatsEntry* newEntry; if(PlayStats.numEntries < NUM_PLAY_STATS_ENTRIES) @@ -168,7 +200,7 @@ namespace iosu newEntry->numTimesLaunched = 1; newEntry->totalMinutesPlayed = 0; newEntry->ukn12 = 0; - PlayStats_WriteEntry(newEntry, entryCountChanged); + PlayStats_WriteEntryNoLock(newEntry, entryCountChanged); return newEntry; } @@ -176,6 +208,7 @@ namespace iosu // if it does not exist it creates a new entry with first and last played set to today PlayStatsEntry* PlayStats_BeginNewTracking(uint64 titleId) { + std::unique_lock _l(sPlaystatsLock); PlayStatsEntry* entry = PlayStats_GetEntry(titleId); if (entry) { @@ -189,11 +222,12 @@ namespace iosu void PlayStats_CountAdditionalMinutes(PlayStatsEntry* entry, uint32 additionalMinutes) { + std::unique_lock _l(sPlaystatsLock); if (additionalMinutes == 0) return; entry->totalMinutesPlayed += additionalMinutes; entry->mostRecentDayIndex = GetTodaysDayIndex(); - PlayStats_WriteEntry(entry); + PlayStats_WriteEntryNoLock(entry); } struct PlayDiaryHeader @@ -218,6 +252,7 @@ namespace iosu void CreatePlayDiary() { MakeDirectory(); + cemu_assert_debug(!PlayDiaryData.fs); PlayDiaryData.fs = FileStream::createFile2(GetPDFile("PlayDiary.dat")); if (!PlayDiaryData.fs) { @@ -230,7 +265,7 @@ namespace iosu PlayDiaryData.fs->writeData(&PlayDiaryData.header, sizeof(PlayDiaryHeader)); } - void LoadPlayDiary() + void OpenPlayDiary() { std::unique_lock _lock(sDiaryLock); cemu_assert_debug(!PlayDiaryData.fs); @@ -268,6 +303,26 @@ namespace iosu } } + void ClosePlayDiary() + { + std::unique_lock _lock(sDiaryLock); + if (PlayDiaryData.fs) + { + delete PlayDiaryData.fs; + PlayDiaryData.fs = nullptr; + } + } + + void UnloadDiaryData() + { + std::unique_lock _lock(sDiaryLock); + cemu_assert_debug(!PlayDiaryData.fs); // unloading expects that file is closed + PlayDiaryData.header.readIndex = 0; + PlayDiaryData.header.writeIndex = 0; + for (auto& it : PlayDiaryData.entry) + it = PlayDiaryEntry{}; + } + uint32 GetDiaryEntries(uint8 accountSlot, PlayDiaryEntry* diaryEntries, uint32 maxEntries) { std::unique_lock _lock(sDiaryLock); @@ -352,25 +407,59 @@ namespace iosu } } - void Initialize() + class : public ::IOSUModule { - // todo - add support for per-account handling - LoadPlaystats(); - LoadPlayDiary(); - } - - void StartTrackingTime(uint64 titleId) - { - sPDMRequestExitThread = false; - sPDMTimeTrackingThread = std::thread(TimeTrackingThread, titleId); - } + void PDMLoadAll() + { + OpenPlaystats(); + OpenPlayDiary(); + } - void Stop() + void PDMUnloadAll() + { + UnloadPlaystats(); + UnloadDiaryData(); + } + + void PDMCloseAll() + { + ClosePlaystats(); + ClosePlayDiary(); + } + + void SystemLaunch() override + { + // todo - add support for per-account handling + PDMLoadAll(); + PDMCloseAll(); // close the files again, user may mess with MLC files or change MLC path while no game is running + } + void SystemExit() override + { + PDMCloseAll(); + PDMUnloadAll(); + } + void TitleStart() override + { + // reload data and keep files open + PDMUnloadAll(); + PDMLoadAll(); + auto titleId = CafeSystem::GetForegroundTitleId(); + sPDMRequestExitThread = false; + sPDMTimeTrackingThread = std::thread(TimeTrackingThread, titleId); + } + void TitleStop() override + { + sPDMRequestExitThread.store(true); + sPDMSem.increment(); + if(sPDMTimeTrackingThread.joinable()) + sPDMTimeTrackingThread.join(); + PDMCloseAll(); + } + }sIOSUModuleNNPDM; + + IOSUModule* GetModule() { - sPDMRequestExitThread.store(true); - sPDMSem.increment(); - if(sPDMTimeTrackingThread.joinable()) - sPDMTimeTrackingThread.join(); + return static_cast(&sIOSUModuleNNPDM); } }; diff --git a/src/Cafe/IOSU/PDM/iosu_pdm.h b/src/Cafe/IOSU/PDM/iosu_pdm.h index fbafbc02..0dd8a39d 100644 --- a/src/Cafe/IOSU/PDM/iosu_pdm.h +++ b/src/Cafe/IOSU/PDM/iosu_pdm.h @@ -1,13 +1,10 @@ #pragma once +#include "Cafe/IOSU/iosu_types_common.h" namespace iosu { namespace pdm { - void Initialize(); - void StartTrackingTime(uint64 titleId); - void Stop(); - inline constexpr size_t NUM_PLAY_STATS_ENTRIES = 256; inline constexpr size_t NUM_PLAY_DIARY_ENTRIES_MAX = 18250; // 0x474A @@ -34,5 +31,7 @@ namespace iosu }; bool GetStatForGamelist(uint64 titleId, GameListStat& stat); + + IOSUModule* GetModule(); }; }; \ No newline at end of file From bffeb818d1e2770c3f47e7290deffdc5136c6b90 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:57:20 +0100 Subject: [PATCH 061/314] GfxPack: Refactor + better unicode support --- src/Cafe/GameProfile/GameProfile.cpp | 2 +- src/Cafe/GraphicPack/GraphicPack2.cpp | 63 +++++++++---------- src/Cafe/GraphicPack/GraphicPack2.h | 18 +++--- src/Cafe/GraphicPack/GraphicPack2Patches.cpp | 15 +---- .../GraphicPack/GraphicPack2PatchesParser.cpp | 2 +- src/gui/GraphicPacksWindow2.cpp | 45 ++++++------- 6 files changed, 64 insertions(+), 81 deletions(-) diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index d068237e..ee92107a 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -209,7 +209,7 @@ bool GameProfile::Load(uint64_t title_id) m_gameName = std::string(game_name.begin(), game_name.end()); trim(m_gameName.value()); } - IniParser iniParser(*profileContents, gameProfilePath.string()); + IniParser iniParser(*profileContents, _pathToUtf8(gameProfilePath)); // parse ini while (iniParser.NextSection()) { diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 72e301c4..365e6e3e 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -28,7 +28,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath) return; std::vector rulesData; fs_rules->extract(rulesData); - IniParser iniParser(rulesData, rulesPath.string()); + IniParser iniParser(rulesData, _pathToUtf8(rulesPath)); if (!iniParser.NextSection()) { @@ -51,10 +51,9 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath) cemuLog_log(LogType::Force, "{}: Unable to parse version", _pathToUtf8(rulesPath)); return; } - if (versionNum > GP_LEGACY_VERSION) { - GraphicPack2::LoadGraphicPack(_pathToUtf8(rulesPath), iniParser); + GraphicPack2::LoadGraphicPack(rulesPath, iniParser); return; } } @@ -79,22 +78,22 @@ void GraphicPack2::LoadAll() } } -bool GraphicPack2::LoadGraphicPack(const std::string& filename, IniParser& rules) +bool GraphicPack2::LoadGraphicPack(const fs::path& rulesPath, IniParser& rules) { try { - auto gp = std::make_shared(filename, rules); + auto gp = std::make_shared(rulesPath, rules); // check if enabled and preset set const auto& config_entries = g_config.data().graphic_pack_entries; // legacy absolute path checking for not breaking compatibility - auto file = gp->GetFilename2(); + auto file = gp->GetRulesPath(); auto it = config_entries.find(file.lexically_normal()); if (it == config_entries.cend()) { // check for relative path - it = config_entries.find(MakeRelativePath(ActiveSettings::GetUserDataPath(), gp->GetFilename2()).lexically_normal()); + it = config_entries.find(_utf8ToPath(gp->GetNormalizedPathString())); } if (it != config_entries.cend()) @@ -145,7 +144,7 @@ bool GraphicPack2::DeactivateGraphicPack(const std::shared_ptr& gr const auto it = std::find_if(s_active_graphic_packs.begin(), s_active_graphic_packs.end(), [graphic_pack](const GraphicPackPtr& gp) { - return gp->GetFilename() == graphic_pack->GetFilename(); + return gp->GetNormalizedPathString() == graphic_pack->GetNormalizedPathString(); } ); @@ -173,12 +172,12 @@ void GraphicPack2::ActivateForCurrentTitle() { if (gp->GetPresets().empty()) { - cemuLog_log(LogType::Force, "Activate graphic pack: {}", gp->GetPath()); + cemuLog_log(LogType::Force, "Activate graphic pack: {}", gp->GetVirtualPath()); } else { std::string logLine; - logLine.assign(fmt::format("Activate graphic pack: {} [Presets: ", gp->GetPath())); + logLine.assign(fmt::format("Activate graphic pack: {} [Presets: ", gp->GetVirtualPath())); bool isFirst = true; for (auto& itr : gp->GetPresets()) { @@ -249,8 +248,8 @@ std::unordered_map GraphicPack2::ParsePres return vars; } -GraphicPack2::GraphicPack2(std::string filename, IniParser& rules) - : m_filename(std::move(filename)) +GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) + : m_rulesPath(std::move(rulesPath)) { // we're already in [Definition] auto option_version = rules.FindOption("version"); @@ -259,7 +258,7 @@ GraphicPack2::GraphicPack2(std::string filename, IniParser& rules) m_version = StringHelpers::ToInt(*option_version, -1); if (m_version < 0) { - cemuLog_log(LogType::Force, "{}: Invalid version", m_filename); + cemuLog_log(LogType::Force, "{}: Invalid version", _pathToUtf8(m_rulesPath)); throw std::exception(); } @@ -305,7 +304,7 @@ GraphicPack2::GraphicPack2(std::string filename, IniParser& rules) cemuLog_log(LogType::Force, "[Definition] section from '{}' graphic pack must contain option: path", gp_name_log.has_value() ? *gp_name_log : "Unknown"); throw std::exception(); } - m_path = *option_path; + m_virtualPath = *option_path; auto option_gp_name = rules.FindOption("name"); if (option_gp_name) @@ -508,6 +507,11 @@ bool GraphicPack2::Reload() return Activate(); } +std::string GraphicPack2::GetNormalizedPathString() const +{ + return _pathToUtf8(MakeRelativePath(ActiveSettings::GetUserDataPath(), GetRulesPath()).lexically_normal()); +} + bool GraphicPack2::ContainsTitleId(uint64_t title_id) const { const auto it = std::find_if(m_title_ids.begin(), m_title_ids.end(), [title_id](uint64 id) { return id == title_id; }); @@ -650,7 +654,7 @@ bool GraphicPack2::SetActivePreset(std::string_view category, std::string_view n void GraphicPack2::LoadShaders() { - fs::path path(m_filename); + fs::path path = GetRulesPath(); for (auto& it : fs::directory_iterator(path.remove_filename())) { if (!is_regular_file(it)) @@ -676,7 +680,7 @@ void GraphicPack2::LoadShaders() { std::ifstream file(p); if (!file.is_open()) - throw std::runtime_error(fmt::format("can't open graphic pack file: {}", p.filename().string()).c_str()); + throw std::runtime_error(fmt::format("can't open graphic pack file: {}", _pathToUtf8(p.filename()))); file.seekg(0, std::ios::end); m_output_shader_source.reserve(file.tellg()); @@ -689,7 +693,7 @@ void GraphicPack2::LoadShaders() { std::ifstream file(p); if (!file.is_open()) - throw std::runtime_error(fmt::format("can't open graphic pack file: {}", p.filename().string()).c_str()); + throw std::runtime_error(fmt::format("can't open graphic pack file: {}", _pathToUtf8(p.filename()))); file.seekg(0, std::ios::end); m_upscaling_shader_source.reserve(file.tellg()); @@ -702,7 +706,7 @@ void GraphicPack2::LoadShaders() { std::ifstream file(p); if (!file.is_open()) - throw std::runtime_error(fmt::format("can't open graphic pack file: {}", p.filename().string()).c_str()); + throw std::runtime_error(fmt::format("can't open graphic pack file: {}", _pathToUtf8(p.filename()))); file.seekg(0, std::ios::end); m_downscaling_shader_source.reserve(file.tellg()); @@ -805,7 +809,7 @@ void GraphicPack2::AddConstantsForCurrentPreset(ExpressionParser& ep) } } -void GraphicPack2::_iterateReplacedFiles(const fs::path& currentPath, std::wstring& internalPath, bool isAOC) +void GraphicPack2::_iterateReplacedFiles(const fs::path& currentPath, bool isAOC) { uint64 currentTitleId = CafeSystem::GetForegroundTitleId(); uint64 aocTitleId = (currentTitleId & 0xFFFFFFFFull) | 0x0005000c00000000ull; @@ -833,7 +837,7 @@ void GraphicPack2::LoadReplacedFiles() return; m_patchedFilesLoaded = true; - fs::path gfxPackPath = _utf8ToPath(m_filename); + fs::path gfxPackPath = GetRulesPath(); gfxPackPath = gfxPackPath.remove_filename(); // /content/ @@ -843,10 +847,9 @@ void GraphicPack2::LoadReplacedFiles() std::error_code ec; if (fs::exists(contentPath, ec)) { - std::wstring internalPath(L"/vol/content/"); // setup redirections fscDeviceRedirect_map(); - _iterateReplacedFiles(contentPath, internalPath, false); + _iterateReplacedFiles(contentPath, false); } // /aoc/ fs::path aocPath(gfxPackPath); @@ -857,13 +860,9 @@ void GraphicPack2::LoadReplacedFiles() uint64 aocTitleId = CafeSystem::GetForegroundTitleId(); aocTitleId = aocTitleId & 0xFFFFFFFFULL; aocTitleId |= 0x0005000c00000000ULL; - wchar_t internalAocPath[128]; - swprintf(internalAocPath, sizeof(internalAocPath)/sizeof(wchar_t), L"/aoc/%016llx/", aocTitleId); - - std::wstring internalPath(internalAocPath); // setup redirections fscDeviceRedirect_map(); - _iterateReplacedFiles(aocPath, internalPath, true); + _iterateReplacedFiles(aocPath, true); } } @@ -886,14 +885,14 @@ bool GraphicPack2::Activate() return false; } - FileStream* fs_rules = FileStream::openFile2(_utf8ToPath(m_filename)); + FileStream* fs_rules = FileStream::openFile2(m_rulesPath); if (!fs_rules) return false; std::vector rulesData; fs_rules->extract(rulesData); delete fs_rules; - IniParser rules({ (char*)rulesData.data(), rulesData.size()}, m_filename); + IniParser rules({ (char*)rulesData.data(), rulesData.size()}, GetNormalizedPathString()); // load rules try @@ -947,7 +946,7 @@ bool GraphicPack2::Activate() else if (anisotropyValue == 16) rule.overwrite_settings.anistropic_value = 4; else - cemuLog_log(LogType::Force, "Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, m_filename); + cemuLog_log(LogType::Force, "Invalid value {} for overwriteAnisotropy in graphic pack {}. Only the values 1, 2, 4, 8 or 16 are allowed.", anisotropyValue, GetNormalizedPathString()); } m_texture_rules.emplace_back(rule); } @@ -992,11 +991,11 @@ bool GraphicPack2::Activate() if (LatteTiming_getCustomVsyncFrequency(globalCustomVsyncFreq)) { if (customVsyncFreq != globalCustomVsyncFreq) - cemuLog_log(LogType::Force, "rules.txt error: Mismatching vsync frequency {} in graphic pack \'{}\'", customVsyncFreq, GetPath()); + cemuLog_log(LogType::Force, "rules.txt error: Mismatching vsync frequency {} in graphic pack \'{}\'", customVsyncFreq, GetVirtualPath()); } else { - cemuLog_log(LogType::Force, "Set vsync frequency to {} (graphic pack {})", customVsyncFreq, GetPath()); + cemuLog_log(LogType::Force, "Set vsync frequency to {} (graphic pack {})", customVsyncFreq, GetVirtualPath()); LatteTiming_setCustomVsyncFrequency(customVsyncFreq); } } diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index 6396ecc7..6b07cce9 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -97,20 +97,20 @@ public: }; using PresetPtr = std::shared_ptr; - GraphicPack2(std::string filename, IniParser& rules); + GraphicPack2(fs::path rulesPath, IniParser& rules); bool IsEnabled() const { return m_enabled; } bool IsActivated() const { return m_activated; } sint32 GetVersion() const { return m_version; } - const std::string& GetFilename() const { return m_filename; } - const fs::path GetFilename2() const { return fs::path(m_filename); } + const fs::path GetRulesPath() const { return m_rulesPath; } + std::string GetNormalizedPathString() const; bool RequiresRestart(bool changeEnableState, bool changePreset); bool Reload(); bool HasName() const { return !m_name.empty(); } - const std::string& GetName() const { return m_name.empty() ? m_path : m_name; } - const std::string& GetPath() const { return m_path; } + const std::string& GetName() const { return m_name.empty() ? m_virtualPath : m_name; } + const std::string& GetVirtualPath() const { return m_virtualPath; } // returns the path in the gfx tree hierarchy const std::string& GetDescription() const { return m_description; } bool IsDefaultEnabled() const { return m_default_enabled; } @@ -164,7 +164,7 @@ public: static const std::vector>& GetGraphicPacks() { return s_graphic_packs; } static const std::vector>& GetActiveGraphicPacks() { return s_active_graphic_packs; } static void LoadGraphicPack(fs::path graphicPackPath); - static bool LoadGraphicPack(const std::string& filename, class IniParser& rules); + static bool LoadGraphicPack(const fs::path& rulesPath, class IniParser& rules); static bool ActivateGraphicPack(const std::shared_ptr& graphic_pack); static bool DeactivateGraphicPack(const std::shared_ptr& graphic_pack); static void ClearGraphicPacks(); @@ -208,11 +208,11 @@ private: parser.TryAddConstant(var.first, (TType)var.second.second); } - std::string m_filename; + fs::path m_rulesPath; sint32 m_version; std::string m_name; - std::string m_path; + std::string m_virtualPath; std::string m_description; bool m_default_enabled = false; @@ -257,7 +257,7 @@ private: CustomShader LoadShader(const fs::path& path, uint64 shader_base_hash, uint64 shader_aux_hash, GP_SHADER_TYPE shader_type) const; void ApplyShaderPresets(std::string& shader_source) const; void LoadReplacedFiles(); - void _iterateReplacedFiles(const fs::path& currentPath, std::wstring& internalPath, bool isAOC); + void _iterateReplacedFiles(const fs::path& currentPath, bool isAOC); // ram mappings std::vector> m_ramMappings; diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp index 5c79630c..2c067484 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp @@ -71,19 +71,8 @@ void PatchErrorHandler::showStageErrorMessageBox() // returns true if at least one file was found even if it could not be successfully parsed bool GraphicPack2::LoadCemuPatches() { - // todo - once we have updated to C++20 we can replace these with the new std::string functions - auto startsWith = [](const std::wstring& str, const std::wstring& prefix) - { - return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), prefix); - }; - - auto endsWith = [](const std::wstring& str, const std::wstring& suffix) - { - return str.size() >= suffix.size() && 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix); - }; - bool foundPatches = false; - fs::path path(_utf8ToPath(m_filename)); + fs::path path(m_rulesPath); path.remove_filename(); for (auto& p : fs::directory_iterator(path)) { @@ -129,7 +118,7 @@ void GraphicPack2::LoadPatchFiles() if (LoadCemuPatches()) return; // exit if at least one Cemu style patch file was found // fall back to Cemuhook patches.txt to guarantee backward compatibility - fs::path path(_utf8ToPath(m_filename)); + fs::path path(m_rulesPath); path.remove_filename(); path.append("patches.txt"); FileStream* patchFile = FileStream::openFile2(path); diff --git a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp index d011a10b..05f8c696 100644 --- a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp @@ -25,7 +25,7 @@ sint32 GraphicPack2::GetLengthWithoutComment(const char* str, size_t length) void GraphicPack2::LogPatchesSyntaxError(sint32 lineNumber, std::string_view errorMsg) { - cemuLog_log(LogType::Force, "Syntax error while parsing patch for graphic pack '{}':", this->GetFilename()); + cemuLog_log(LogType::Force, "Syntax error while parsing patch for graphic pack '{}':", _pathToUtf8(this->GetRulesPath())); if(lineNumber >= 0) cemuLog_log(LogType::Force, fmt::format("Line {0}: {1}", lineNumber, errorMsg)); else diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 13fec49a..78b344d5 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -64,7 +64,7 @@ void GraphicPacksWindow2::FillGraphicPackList() const { bool found = false; - if (boost::icontains(p->GetPath(), m_filter)) + if (boost::icontains(p->GetVirtualPath(), m_filter)) found = true; else { @@ -82,7 +82,7 @@ void GraphicPacksWindow2::FillGraphicPackList() const continue; } - const auto& path = p->GetPath(); + const auto& path = p->GetVirtualPath(); auto tokens = TokenizeView(path, '/'); auto node = root; for(size_t i=0; iGetFilename())).lexically_normal(); + auto filename = _utf8ToPath(gp->GetNormalizedPathString()); if (gp->IsEnabled()) { data.graphic_pack_entries.try_emplace(filename); @@ -603,34 +603,29 @@ void GraphicPacksWindow2::OnCheckForUpdates(wxCommandEvent& event) { if (!CafeSystem::IsTitleRunning()) { - std::vector old_packs = GraphicPack2::GetGraphicPacks(); + // remember virtual paths of all the enabled packs + std::map previouslyEnabledPacks; + for(auto& it : GraphicPack2::GetGraphicPacks()) + { + if(it->IsEnabled()) + previouslyEnabledPacks.emplace(it->GetNormalizedPathString(), it->GetVirtualPath()); + } + // reload graphic packs RefreshGraphicPacks(); FillGraphicPackList(); - - // check if enabled graphic packs are lost: - const auto& new_packs = GraphicPack2::GetGraphicPacks(); - std::stringstream lost_packs; - for(const auto& p : old_packs) + // remove packs which are still present + for(auto& it : GraphicPack2::GetGraphicPacks()) + previouslyEnabledPacks.erase(it->GetNormalizedPathString()); + if(!previouslyEnabledPacks.empty()) { - if (!p->IsEnabled()) - continue; - - const auto it = std::find_if(new_packs.cbegin(), new_packs.cend(), [&p](const auto& gp) - { - return gp->GetFilename() == p->GetFilename(); - }); - - if(it == new_packs.cend()) + std::string lost_packs; + for(auto& it : previouslyEnabledPacks) { - lost_packs << p->GetPath() << "\n"; + lost_packs.append(it.second); + lost_packs.push_back('\n'); } - } - - const auto lost_packs_str = lost_packs.str(); - if (!lost_packs_str.empty()) - { wxString message = _("This update removed or renamed the following graphic packs:"); - message << "\n \n" << lost_packs_str << " \n" << _("You may need to set them up again."); + message << "\n \n" << wxString::FromUTF8(lost_packs) << " \n" << _("You may need to set them up again."); wxMessageBox(message, _("Warning"), wxOK | wxCENTRE | wxICON_INFORMATION, this); } } From e7fa8ec0c63f37a93fbcb0c7b372d5fb8640091e Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:16:17 +0100 Subject: [PATCH 062/314] Vulkan: Properly shut down compilation threads --- .../Renderer/Vulkan/RendererShaderVk.cpp | 23 ++++++++++++++++--- .../Latte/Renderer/Vulkan/RendererShaderVk.h | 3 +++ .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 5 ++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index e4c87d62..8460c8b5 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -139,7 +139,7 @@ public: } } - ~_ShaderVkThreadPool() + void StopThreads() { m_shutdownThread.store(true); for (uint32 i = 0; i < s_threads.size(); ++i) @@ -149,6 +149,11 @@ public: s_threads.clear(); } + ~_ShaderVkThreadPool() + { + StopThreads(); + } + void CompilerThreadFunc() { while (!m_shutdownThread.load(std::memory_order::relaxed)) @@ -176,6 +181,8 @@ public: } } + bool HasThreadsRunning() const { return !m_shutdownThread; } + public: std::vector s_threads; @@ -195,8 +202,8 @@ RendererShaderVk::RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxH m_compilationState.setValue(COMPILATION_STATE::QUEUED); ShaderVkThreadPool.s_compilationQueue.push_back(this); ShaderVkThreadPool.s_compilationQueueCount.increment(); - ShaderVkThreadPool.StartThreads(); ShaderVkThreadPool.s_compilationQueueMutex.unlock(); + cemu_assert_debug(ShaderVkThreadPool.HasThreadsRunning()); // make sure .StartThreads() was called } RendererShaderVk::~RendererShaderVk() @@ -204,6 +211,16 @@ RendererShaderVk::~RendererShaderVk() VulkanRenderer::GetInstance()->destroyShader(this); } +void RendererShaderVk::Init() +{ + ShaderVkThreadPool.StartThreads(); +} + +void RendererShaderVk::Shutdown() +{ + ShaderVkThreadPool.StopThreads(); +} + sint32 RendererShaderVk::GetUniformLocation(const char* name) { cemu_assert_suspicious(); @@ -457,4 +474,4 @@ void RendererShaderVk::ShaderCacheLoading_Close() { delete s_spirvCache; s_spirvCache = nullptr; -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h index 561145f9..207ea3ea 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h @@ -28,6 +28,9 @@ public: RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxHash, bool isGameShader, bool isGfxPackShader, const std::string& glslCode); virtual ~RendererShaderVk(); + static void Init(); + static void Shutdown(); + sint32 GetUniformLocation(const char* name) override; void SetUniform1iv(sint32 location, void* data, sint32 count) override; void SetUniform2fv(sint32 location, void* data, sint32 count) override; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 052ca21a..5b4dd739 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -591,6 +591,9 @@ VulkanRenderer::VulkanRenderer() { //cemuLog_log(LogType::Force, "Disable surface copies via buffer (Requires 2GB. Has only {}MB available)", availableSurfaceCopyBufferMem / 1024ull / 1024ull); } + + // start compilation threads + RendererShaderVk::Init(); } VulkanRenderer::~VulkanRenderer() @@ -598,6 +601,8 @@ VulkanRenderer::~VulkanRenderer() SubmitCommandBuffer(); WaitDeviceIdle(); WaitCommandBufferFinished(GetCurrentCommandBufferId()); + // shut down compilation threads + RendererShaderVk::Shutdown(); // shut down pipeline save thread m_destructionRequested = true; m_pipeline_cache_semaphore.notify(); From dee764473db26462a898aae8ea73c65a9cbafda1 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:29:56 +0100 Subject: [PATCH 063/314] Latte: Small refactor for GLSL texture coord handling Also adds support for 2D textures coordinates with source as 0.0 or 1.0 literals instead of GPRs. Seen in shaders generated by CafeGLSL --- .../LatteDecompilerEmitGLSL.cpp | 108 ++++++++---------- 1 file changed, 46 insertions(+), 62 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 334b4855..a37ba011 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -507,7 +507,7 @@ void _emitRegisterAccessCode(LatteDecompilerShaderContext* shaderContext, sint32 { _emitTypeConversionPrefix(shaderContext, registerElementDataType, dataType); } - if(shaderContext->typeTracker.useArrayGPRs ) + if (shaderContext->typeTracker.useArrayGPRs) src->add("R"); else src->addFmt("R{}", gprIndex); @@ -540,6 +540,26 @@ void _emitRegisterAccessCode(LatteDecompilerShaderContext* shaderContext, sint32 _emitTypeConversionSuffix(shaderContext, registerElementDataType, dataType); } +// optimized variant of _emitRegisterAccessCode for raw one channel reads +void _emitRegisterChannelAccessCode(LatteDecompilerShaderContext* shaderContext, sint32 gprIndex, sint32 channel, sint32 dataType) +{ + cemu_assert_debug(gprIndex >= 0 && gprIndex <= 127); + cemu_assert_debug(channel >= 0 && channel < 4); + StringBuf* src = shaderContext->shaderSource; + sint32 registerElementDataType = shaderContext->typeTracker.defaultDataType; + _emitTypeConversionPrefix(shaderContext, registerElementDataType, dataType); + if (shaderContext->typeTracker.useArrayGPRs) + src->add("R"); + else + src->addFmt("R{}", gprIndex); + _appendRegisterTypeSuffix(src, registerElementDataType); + if (shaderContext->typeTracker.useArrayGPRs) + src->addFmt("[{}]", gprIndex); + src->add("."); + src->add(_getElementStrByIndex(channel)); + _emitTypeConversionSuffix(shaderContext, registerElementDataType, dataType); +} + void _emitALURegisterInputAccessCode(LatteDecompilerShaderContext* shaderContext, LatteDecompilerALUInstruction* aluInstruction, sint32 operandIndex) { StringBuf* src = shaderContext->shaderSource; @@ -2129,63 +2149,31 @@ void _emitALUClauseCode(LatteDecompilerShaderContext* shaderContext, LatteDecomp /* * Emits code to access one component (xyzw) of the texture coordinate input vector */ -void _emitTEXSampleCoordInputComponent(LatteDecompilerShaderContext* shaderContext, LatteDecompilerTEXInstruction* texInstruction, sint32 componentIndex, sint32 varType) +void _emitTEXSampleCoordInputComponent(LatteDecompilerShaderContext* shaderContext, LatteDecompilerTEXInstruction* texInstruction, sint32 componentIndex, sint32 interpretSrcAsType) { + cemu_assert(componentIndex >= 0 && componentIndex < 4); + cemu_assert_debug(interpretSrcAsType == LATTE_DECOMPILER_DTYPE_SIGNED_INT || interpretSrcAsType == LATTE_DECOMPILER_DTYPE_FLOAT); StringBuf* src = shaderContext->shaderSource; - if( componentIndex >= 4 ) + sint32 elementSel = texInstruction->textureFetch.srcSel[componentIndex]; + if (elementSel < 4) { - debugBreakpoint(); + _emitRegisterChannelAccessCode(shaderContext, texInstruction->srcGpr, elementSel, interpretSrcAsType); return; } - sint32 elementSel = texInstruction->textureFetch.srcSel[componentIndex]; const char* resultElemTable[4] = {"x","y","z","w"}; - if( varType == LATTE_DECOMPILER_DTYPE_SIGNED_INT ) + if(interpretSrcAsType == LATTE_DECOMPILER_DTYPE_SIGNED_INT ) { - if (elementSel < 4) - { - if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_SIGNED_INT) - src->addFmt("{}.{}", _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[elementSel]); - else if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT) - src->addFmt("floatBitsToInt({}.{})", _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[elementSel]); - else - { - cemu_assert_unimplemented(); - } - } - else if( elementSel == 4 ) + if( elementSel == 4 ) src->add("floatBitsToInt(0.0)"); else if( elementSel == 5 ) src->add("floatBitsToInt(1.0)"); - else - { - cemu_assert_unimplemented(); - } } - else if( varType == LATTE_DECOMPILER_DTYPE_FLOAT ) + else if(interpretSrcAsType == LATTE_DECOMPILER_DTYPE_FLOAT ) { - if (elementSel < 4) - { - if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_SIGNED_INT) - src->addFmt("intBitsToFloat({}.{})", _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[elementSel]); - else if (shaderContext->typeTracker.defaultDataType == LATTE_DECOMPILER_DTYPE_FLOAT) - src->addFmt("{}.{}", _getRegisterVarName(shaderContext, texInstruction->srcGpr), resultElemTable[elementSel]); - else - { - cemu_assert_unimplemented(); - } - } - else if( elementSel == 4 ) - src->addFmt("0.0"); + if( elementSel == 4 ) + src->add("0.0"); else if( elementSel == 5 ) - src->addFmt("1.0"); - else - { - cemu_assert_unimplemented(); - } - } - else - { - cemu_assert_unimplemented(); + src->add("1.0"); } } @@ -2430,10 +2418,6 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt cemu_assert_unimplemented(); src->add("texture("); } - if( texInstruction->textureFetch.srcSel[0] >= 4 ) - cemu_assert_unimplemented(); - if( texInstruction->textureFetch.srcSel[1] >= 4 ) - cemu_assert_unimplemented(); src->addFmt("{}{}, ", _getTextureUnitVariablePrefixName(shaderContext->shader->shaderType), texInstruction->textureFetch.textureIndex); // for textureGather() add shift (todo: depends on rounding mode set in sampler registers?) @@ -2455,7 +2439,7 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt } } - + const sint32 texCoordDataType = (texOpcode == GPU7_TEX_INST_LD) ? LATTE_DECOMPILER_DTYPE_SIGNED_INT : LATTE_DECOMPILER_DTYPE_FLOAT; if(useTexelCoordinates) { // handle integer coordinates for texelFetch @@ -2463,9 +2447,9 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt { src->add("ivec2("); src->add("vec2("); - _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 0, (texOpcode == GPU7_TEX_INST_LD) ? LATTE_DECOMPILER_DTYPE_SIGNED_INT : LATTE_DECOMPILER_DTYPE_FLOAT); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 0, texCoordDataType); src->addFmt(", "); - _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 1, (texOpcode == GPU7_TEX_INST_LD) ? LATTE_DECOMPILER_DTYPE_SIGNED_INT : LATTE_DECOMPILER_DTYPE_FLOAT); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 1, texCoordDataType); src->addFmt(")*uf_tex{}Scale", texInstruction->textureFetch.textureIndex); // close vec2 and scale @@ -2485,7 +2469,7 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt else cemu_assert_debug(false); } - else + else /* useTexelCoordinates == false */ { // float coordinates if ( (texOpcode == GPU7_TEX_INST_SAMPLE_C || texOpcode == GPU7_TEX_INST_SAMPLE_C_L || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ) ) @@ -2549,10 +2533,8 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt else if( texDim == Latte::E_DIM::DIM_CUBEMAP ) { // 2 coords + faceId - if( texInstruction->textureFetch.srcSel[0] >= 4 || texInstruction->textureFetch.srcSel[1] >= 4 ) - { - debugBreakpoint(); - } + cemu_assert_debug(texInstruction->textureFetch.srcSel[0] < 4); + cemu_assert_debug(texInstruction->textureFetch.srcSel[1] < 4); src->add("vec4("); src->addFmt("redcCUBEReverse({},", _getTexGPRAccess(shaderContext, texInstruction->srcGpr, LATTE_DECOMPILER_DTYPE_FLOAT, texInstruction->textureFetch.srcSel[0], texInstruction->textureFetch.srcSel[1], -1, -1, tempBuffer0)); _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 2, LATTE_DECOMPILER_DTYPE_SIGNED_INT); @@ -2567,8 +2549,11 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt else { // 2 coords - src->add(_getTexGPRAccess(shaderContext, texInstruction->srcGpr, LATTE_DECOMPILER_DTYPE_FLOAT, texInstruction->textureFetch.srcSel[0], texInstruction->textureFetch.srcSel[1], -1, -1, tempBuffer0)); - + src->add("vec2("); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 0, LATTE_DECOMPILER_DTYPE_FLOAT); + src->add(","); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 1, LATTE_DECOMPILER_DTYPE_FLOAT); + src->add(")"); // avoid truncate to effectively round downwards on texel edges if (ActiveSettings::ForceSamplerRoundToPrecision()) src->addFmt("+ vec2(1.0)/vec2(textureSize({}{}, 0))/512.0", _getTextureUnitVariablePrefixName(shaderContext->shader->shaderType), texInstruction->textureFetch.textureIndex); @@ -2576,9 +2561,8 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt // lod or lod bias parameter if( texOpcode == GPU7_TEX_INST_SAMPLE_L || texOpcode == GPU7_TEX_INST_SAMPLE_LB || texOpcode == GPU7_TEX_INST_SAMPLE_C_L) { - if( texInstruction->textureFetch.srcSel[3] >= 4 ) - debugBreakpoint(); - src->addFmt(",{}", _getTexGPRAccess(shaderContext, texInstruction->srcGpr, LATTE_DECOMPILER_DTYPE_FLOAT, texInstruction->textureFetch.srcSel[3], -1, -1, -1, tempBuffer0)); + src->add(","); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); } else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ ) { From 646835346c1eb6d29f632843b5e07e90a804d62c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:50:16 +0100 Subject: [PATCH 064/314] Latte: Refactor legacy OpenGL code for shader binding --- src/Cafe/HW/Latte/Core/LatteShader.cpp | 16 +------------ .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 24 +++---------------- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 14 ++++------- .../Renderer/OpenGL/OpenGLRendererCore.cpp | 15 ++++++++++++ .../Renderer/OpenGL/RendererShaderGL.cpp | 5 ---- .../Latte/Renderer/OpenGL/RendererShaderGL.h | 1 - src/Cafe/HW/Latte/Renderer/Renderer.h | 2 -- .../HW/Latte/Renderer/RendererOuputShader.cpp | 6 ----- .../HW/Latte/Renderer/RendererOuputShader.h | 1 - src/Cafe/HW/Latte/Renderer/RendererShader.h | 3 +-- .../Renderer/Vulkan/RendererShaderVk.cpp | 5 ---- .../Latte/Renderer/Vulkan/RendererShaderVk.h | 1 - .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 11 --------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 2 -- 14 files changed, 25 insertions(+), 81 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteShader.cpp b/src/Cafe/HW/Latte/Core/LatteShader.cpp index c0ad06a1..503fb664 100644 --- a/src/Cafe/HW/Latte/Core/LatteShader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShader.cpp @@ -838,7 +838,6 @@ LatteDecompilerShader* LatteShader_CompileSeparablePixelShader(uint64 baseHash, void LatteSHRC_UpdateVertexShader(uint8* vertexShaderPtr, uint32 vertexShaderSize, bool usesGeometryShader) { // todo - should include VTX_SEMANTIC table in state - LatteSHRC_UpdateVSBaseHash(vertexShaderPtr, vertexShaderSize, usesGeometryShader); uint64 vsAuxHash = 0; auto itBaseShader = sVertexShaders.find(_shaderBaseHash_vs); @@ -855,15 +854,13 @@ void LatteSHRC_UpdateVertexShader(uint8* vertexShaderPtr, uint32 vertexShaderSiz LatteGPUState.activeShaderHasError = true; return; } - g_renderer->shader_bind(vertexShader->shader); _activeVertexShader = vertexShader; } void LatteSHRC_UpdateGeometryShader(bool usesGeometryShader, uint8* geometryShaderPtr, uint32 geometryShaderSize, uint8* geometryCopyShader, uint32 geometryCopyShaderSize) { - if (usesGeometryShader == false || _activeVertexShader == nullptr) + if (!usesGeometryShader || !_activeVertexShader) { - g_renderer->shader_unbind(RendererShader::ShaderType::kGeometry); _shaderBaseHash_gs = 0; _activeGeometryShader = nullptr; return; @@ -887,21 +884,11 @@ void LatteSHRC_UpdateGeometryShader(bool usesGeometryShader, uint8* geometryShad LatteGPUState.activeShaderHasError = true; return; } - g_renderer->shader_bind(geometryShader->shader); _activeGeometryShader = geometryShader; } void LatteSHRC_UpdatePixelShader(uint8* pixelShaderPtr, uint32 pixelShaderSize, bool usesGeometryShader) { - if (LatteGPUState.contextRegister[mmVGT_STRMOUT_EN] != 0 && g_renderer->GetType() == RendererAPI::OpenGL) - { - if (_activePixelShader) - { - g_renderer->shader_unbind(RendererShader::ShaderType::kFragment); - _activePixelShader = nullptr; - } - return; - } LatteSHRC_UpdatePSBaseHash(pixelShaderPtr, pixelShaderSize, usesGeometryShader); uint64 psAuxHash = 0; auto itBaseShader = sPixelShaders.find(_shaderBaseHash_ps); @@ -918,7 +905,6 @@ void LatteSHRC_UpdatePixelShader(uint8* pixelShaderPtr, uint32 pixelShaderSize, LatteGPUState.activeShaderHasError = true; return; } - g_renderer->shader_bind(pixelShader->shader); _activePixelShader = pixelShader; } diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 5269be64..01068a3d 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -275,10 +275,6 @@ void OpenGLRenderer::Initialize() cemuLog_log(LogType::Force, "ARB_copy_image: {}", (glCopyImageSubData != NULL) ? "available" : "not supported"); cemuLog_log(LogType::Force, "NV_depth_buffer_float: {}", (glDepthRangedNV != NULL) ? "available" : "not supported"); - // generate default frame buffer - glGenFramebuffers(1, &m_defaultFramebufferId); - catchOpenGLError(); - // enable framebuffer SRGB support glEnable(GL_FRAMEBUFFER_SRGB); @@ -566,10 +562,9 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu sint32 effectiveHeight; LatteTexture_getEffectiveSize(texView->baseTexture, &effectiveWidth, &effectiveHeight, nullptr, 0); - g_renderer->shader_unbind(RendererShader::ShaderType::kVertex); - g_renderer->shader_unbind(RendererShader::ShaderType::kGeometry); - g_renderer->shader_unbind(RendererShader::ShaderType::kFragment); - shader->Bind(); + shader_unbind(RendererShader::ShaderType::kGeometry); + shader_bind(shader->GetVertexShader()); + shader_bind(shader->GetFragmentShader()); shader->SetUniformParameters(*texView, { effectiveWidth, effectiveHeight }, { imageWidth, imageHeight }); // set viewport @@ -1433,31 +1428,25 @@ RendererShader* OpenGLRenderer::shader_create(RendererShader::ShaderType type, u void OpenGLRenderer::shader_bind(RendererShader* shader) { auto shaderGL = (RendererShaderGL*)shader; - GLbitfield shaderBit; - const auto program = shaderGL->GetProgram(); - switch(shader->GetType()) { case RendererShader::ShaderType::kVertex: if (program == prevVertexShaderProgram) return; - shaderBit = GL_VERTEX_SHADER_BIT; prevVertexShaderProgram = program; break; case RendererShader::ShaderType::kFragment: if (program == prevPixelShaderProgram) return; - shaderBit = GL_FRAGMENT_SHADER_BIT; prevPixelShaderProgram = program; break; case RendererShader::ShaderType::kGeometry: if (program == prevGeometryShaderProgram) return; - shaderBit = GL_GEOMETRY_SHADER_BIT; prevGeometryShaderProgram = program; break; @@ -1470,13 +1459,6 @@ void OpenGLRenderer::shader_bind(RendererShader* shader) catchOpenGLError(); } -void OpenGLRenderer::shader_bind(GLuint program, GLbitfield shaderType) -{ - catchOpenGLError(); - glUseProgramStages(m_pipeline, shaderType, program); - catchOpenGLError(); -} - void OpenGLRenderer::shader_unbind(RendererShader::ShaderType shaderType) { switch (shaderType) { diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index 600985ff..b789e2a7 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -127,9 +127,8 @@ public: // shader RendererShader* shader_create(RendererShader::ShaderType type, uint64 baseHash, uint64 auxHash, const std::string& source, bool isGameShader, bool isGfxPackShader) override; - void shader_bind(RendererShader* shader) override; - void shader_bind(GLuint program, GLbitfield shaderType); - void shader_unbind(RendererShader::ShaderType shaderType) override; + void shader_bind(RendererShader* shader); + void shader_unbind(RendererShader::ShaderType shaderType); // streamout void streamout_setupXfbBuffer(uint32 bufferIndex, sint32 ringBufferOffset, uint32 rangeAddr, uint32 rangeSize) override; @@ -165,7 +164,6 @@ private: void texture_syncSliceSpecialBC4(LatteTexture* srcTexture, sint32 srcSliceIndex, sint32 srcMipIndex, LatteTexture* dstTexture, sint32 dstSliceIndex, sint32 dstMipIndex); void texture_syncSliceSpecialIntegerToBC3(LatteTexture* srcTexture, sint32 srcSliceIndex, sint32 srcMipIndex, LatteTexture* dstTexture, sint32 dstSliceIndex, sint32 dstMipIndex); - GLuint m_defaultFramebufferId; GLuint m_pipeline = 0; bool m_isPadViewContext{}; @@ -216,8 +214,6 @@ private: uint32 prevLogicOp = 0; uint32 prevBlendColorConstant[4] = { 0 }; uint8 prevAlphaTestEnable = 0; - uint8 prevAlphaTestFunc = 0; - uint32 prevAlphaTestRefU32 = 0; bool prevDepthEnable = 0; bool prevDepthWriteEnable = 0; Latte::LATTE_DB_DEPTH_CONTROL::E_ZFUNC prevDepthFunc = (Latte::LATTE_DB_DEPTH_CONTROL::E_ZFUNC)-1; @@ -263,9 +259,9 @@ private: std::vector list_queryCacheOcclusion; // cache for unused queries // resource garbage collection - struct bufferCacheReleaseQueueEntry_t + struct BufferCacheReleaseQueueEntry { - bufferCacheReleaseQueueEntry_t(VirtualBufferHeap_t* heap, VirtualBufferHeapEntry_t* entry) : m_heap(heap), m_entry(entry) {}; + BufferCacheReleaseQueueEntry(VirtualBufferHeap_t* heap, VirtualBufferHeapEntry_t* entry) : m_heap(heap), m_entry(entry) {}; void free() { @@ -279,7 +275,7 @@ private: struct { sint32 index; - std::vector bufferCacheEntries; + std::vector bufferCacheEntries; }m_destructionQueues; }; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp index d5cec237..f78b8bd6 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp @@ -912,6 +912,21 @@ void OpenGLRenderer::draw_genericDrawHandler(uint32 baseVertex, uint32 baseInsta { beginPerfMonProfiling(performanceMonitor.gpuTime_dcStageShaderAndUniformMgr); LatteSHRC_UpdateActiveShaders(); + LatteDecompilerShader* vs = (LatteDecompilerShader*)LatteSHRC_GetActiveVertexShader(); + LatteDecompilerShader* gs = (LatteDecompilerShader*)LatteSHRC_GetActiveGeometryShader(); + LatteDecompilerShader* ps = (LatteDecompilerShader*)LatteSHRC_GetActivePixelShader(); + if (vs) + shader_bind(vs->shader); + else + shader_unbind(RendererShader::ShaderType::kVertex); + if (ps && LatteGPUState.contextRegister[mmVGT_STRMOUT_EN] == 0) + shader_bind(ps->shader); + else + shader_unbind(RendererShader::ShaderType::kFragment); + if (gs) + shader_bind(gs->shader); + else + shader_unbind(RendererShader::ShaderType::kGeometry); endPerfMonProfiling(performanceMonitor.gpuTime_dcStageShaderAndUniformMgr); } if (LatteGPUState.activeShaderHasError) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp index 5530b4ec..3d46f206 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp @@ -230,11 +230,6 @@ sint32 RendererShaderGL::GetUniformLocation(const char* name) return glGetUniformLocation(m_program, name); } -void RendererShaderGL::SetUniform1iv(sint32 location, void* data, sint32 count) -{ - glProgramUniform1iv(m_program, location, count, (const GLint*)data); -} - void RendererShaderGL::SetUniform2fv(sint32 location, void* data, sint32 count) { glProgramUniform2fv(m_program, location, count, (const GLfloat*)data); diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.h b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.h index abc62358..60c51cc1 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.h @@ -18,7 +18,6 @@ public: GLuint GetShaderObject() const { cemu_assert_debug(m_isCompiled); return m_shader_object; } sint32 GetUniformLocation(const char* name) override; - void SetUniform1iv(sint32 location, void* data, sint32 count) override; void SetUniform2fv(sint32 location, void* data, sint32 count) override; void SetUniform4iv(sint32 location, void* data, sint32 count) override; diff --git a/src/Cafe/HW/Latte/Renderer/Renderer.h b/src/Cafe/HW/Latte/Renderer/Renderer.h index 61ff10c8..11d102d0 100644 --- a/src/Cafe/HW/Latte/Renderer/Renderer.h +++ b/src/Cafe/HW/Latte/Renderer/Renderer.h @@ -135,8 +135,6 @@ public: // shader virtual RendererShader* shader_create(RendererShader::ShaderType type, uint64 baseHash, uint64 auxHash, const std::string& source, bool compileAsync, bool isGfxPackSource) = 0; - virtual void shader_bind(RendererShader* shader) = 0; - virtual void shader_unbind(RendererShader::ShaderType shaderType) = 0; // streamout virtual void streamout_setupXfbBuffer(uint32 bufferIndex, sint32 ringBufferOffset, uint32 rangeAddr, uint32 rangeSize) = 0; diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp index ae528944..cdbeb3f3 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp @@ -233,12 +233,6 @@ void RendererOutputShader::SetUniformParameters(const LatteTextureView& texture_ } } -void RendererOutputShader::Bind() const -{ - g_renderer->shader_bind(m_vertex_shader); - g_renderer->shader_bind(m_fragment_shader); -} - RendererOutputShader* RendererOutputShader::s_copy_shader; RendererOutputShader* RendererOutputShader::s_copy_shader_ud; diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h index 253990e2..398ac663 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h @@ -18,7 +18,6 @@ public: virtual ~RendererOutputShader() = default; void SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& input_res, const Vector2i& output_res) const; - void Bind() const; RendererShader* GetVertexShader() const { diff --git a/src/Cafe/HW/Latte/Renderer/RendererShader.h b/src/Cafe/HW/Latte/Renderer/RendererShader.h index 1c15211f..e3f254c6 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererShader.h +++ b/src/Cafe/HW/Latte/Renderer/RendererShader.h @@ -19,8 +19,7 @@ public: virtual bool WaitForCompiled() = 0; virtual sint32 GetUniformLocation(const char* name) = 0; - - virtual void SetUniform1iv(sint32 location, void* data, sint32 count) = 0; + virtual void SetUniform2fv(sint32 location, void* data, sint32 count) = 0; virtual void SetUniform4iv(sint32 location, void* data, sint32 count) = 0; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 8460c8b5..970f5517 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -227,11 +227,6 @@ sint32 RendererShaderVk::GetUniformLocation(const char* name) return 0; } -void RendererShaderVk::SetUniform1iv(sint32 location, void* data, sint32 count) -{ - cemu_assert_suspicious(); -} - void RendererShaderVk::SetUniform2fv(sint32 location, void* data, sint32 count) { cemu_assert_suspicious(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h index 207ea3ea..f9c3ede1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h @@ -32,7 +32,6 @@ public: static void Shutdown(); sint32 GetUniformLocation(const char* name) override; - void SetUniform1iv(sint32 location, void* data, sint32 count) override; void SetUniform2fv(sint32 location, void* data, sint32 count) override; void SetUniform4iv(sint32 location, void* data, sint32 count) override; VkShaderModule& GetShaderModule() { return m_shader_module; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 5b4dd739..2ce5dacd 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1090,17 +1090,6 @@ RendererShader* VulkanRenderer::shader_create(RendererShader::ShaderType type, u return new RendererShaderVk(type, baseHash, auxHash, isGameShader, isGfxPackShader, source); } -void VulkanRenderer::shader_bind(RendererShader* shader) -{ - // does nothing on Vulkan - // remove from main render backend and internalize into GL backend -} - -void VulkanRenderer::shader_unbind(RendererShader::ShaderType shaderType) -{ - // does nothing on Vulkan -} - bool VulkanRenderer::CheckDeviceExtensionSupport(const VkPhysicalDevice device, FeatureControl& info) { std::vector availableDeviceExtensions; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 3d68f844..84cae587 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -350,8 +350,6 @@ public: void buffer_bindUniformBuffer(LatteConst::ShaderType shaderType, uint32 bufferIndex, uint32 offset, uint32 size) override; RendererShader* shader_create(RendererShader::ShaderType type, uint64 baseHash, uint64 auxHash, const std::string& source, bool isGameShader, bool isGfxPackShader) override; - void shader_bind(RendererShader* shader) override; - void shader_unbind(RendererShader::ShaderType shaderType) override; void* indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) override; void indexData_uploadIndexMemory(uint32 offset, uint32 size) override; From df282ab230d07629e28dca16b5decea198879baa Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:19:12 +0100 Subject: [PATCH 065/314] Latte: Clean up OpenGL relics in shared render code --- src/Cafe/HW/Latte/Core/Latte.h | 2 +- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 4 - src/Cafe/HW/Latte/Core/LatteTexture.cpp | 14 +- src/Cafe/HW/Latte/Core/LatteTexture.h | 6 +- src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 23 ++- src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteThread.cpp | 8 +- .../Latte/Renderer/OpenGL/LatteTextureGL.cpp | 28 +-- .../HW/Latte/Renderer/OpenGL/LatteTextureGL.h | 6 +- .../Renderer/OpenGL/LatteTextureViewGL.cpp | 2 +- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 147 ++++----------- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 18 +- .../Renderer/OpenGL/OpenGLRendererCore.cpp | 4 +- .../Renderer/OpenGL/OpenGLSurfaceCopy.cpp | 2 +- .../Renderer/OpenGL/TextureReadbackGL.cpp | 4 +- src/Cafe/HW/Latte/Renderer/Renderer.h | 8 +- .../Latte/Renderer/Vulkan/LatteTextureVk.cpp | 4 +- .../HW/Latte/Renderer/Vulkan/LatteTextureVk.h | 2 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 11 +- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 9 +- src/Common/GLInclude/GLInclude.h | 171 ++++++++++++++++++ src/Common/GLInclude/glFunctions.h | 8 + 22 files changed, 267 insertions(+), 216 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/Latte.h b/src/Cafe/HW/Latte/Core/Latte.h index 861d7ddf..dc3cbc91 100644 --- a/src/Cafe/HW/Latte/Core/Latte.h +++ b/src/Cafe/HW/Latte/Core/Latte.h @@ -115,7 +115,7 @@ void LatteTC_RegisterTexture(LatteTexture* tex); void LatteTC_UnregisterTexture(LatteTexture* tex); uint32 LatteTexture_CalculateTextureDataHash(LatteTexture* hostTexture); -void LatteTexture_ReloadData(LatteTexture* hostTexture, uint32 textureUnit); +void LatteTexture_ReloadData(LatteTexture* hostTexture); bool LatteTC_HasTextureChanged(LatteTexture* hostTexture, bool force = false); void LatteTC_ResetTextureChangeTracker(LatteTexture* hostTexture, bool force = false); diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 06015949..abdfda21 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -239,8 +239,6 @@ LatteTextureView* LatteMRT_CreateColorBuffer(MPTR colorBufferPhysMem, uint32 wid textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, false); else textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, 1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false); - // unbind texture - g_renderer->texture_bindAndActivate(nullptr, 0); return textureView; } @@ -253,8 +251,6 @@ LatteTextureView* LatteMRT_CreateDepthBuffer(MPTR depthBufferPhysMem, uint32 wid textureView = LatteTexture_CreateMapping(depthBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, true); LatteMRT::SetDepthAndStencilAttachment(textureView, textureView->baseTexture->hasStencil); - // unbind texture - g_renderer->texture_bindAndActivate(nullptr, 0); return textureView; } diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 42a9d8c6..06afed60 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -985,7 +985,7 @@ void LatteTexture_RecreateTextureWithDifferentMipSliceCount(LatteTexture* textur newDim = Latte::E_DIM::DIM_2D_ARRAY; else if (newDim == Latte::E_DIM::DIM_1D && newDepth > 1) newDim = Latte::E_DIM::DIM_1D_ARRAY; - LatteTextureView* view = LatteTexture_CreateTexture(0, newDim, texture->physAddress, physMipAddr, texture->format, texture->width, texture->height, newDepth, texture->pitch, newMipCount, texture->swizzle, texture->tileMode, texture->isDepth); + LatteTextureView* view = LatteTexture_CreateTexture(newDim, texture->physAddress, physMipAddr, texture->format, texture->width, texture->height, newDepth, texture->pitch, newMipCount, texture->swizzle, texture->tileMode, texture->isDepth); cemu_assert(!(view->baseTexture->mipLevels <= 1 && physMipAddr == MPTR_NULL && newMipCount > 1)); // copy data from old texture if its dynamically updated if (texture->isUpdatedOnGPU) @@ -1112,7 +1112,7 @@ LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, si // create new texture if (allowCreateNewDataTexture == false) return nullptr; - LatteTextureView* view = LatteTexture_CreateTexture(0, dimBase, physAddr, physMipAddr, format, width, height, depth, pitch, firstMip + numMip, swizzle, tileMode, isDepth); + LatteTextureView* view = LatteTexture_CreateTexture(dimBase, physAddr, physMipAddr, format, width, height, depth, pitch, firstMip + numMip, swizzle, tileMode, isDepth); LatteTexture* newTexture = view->baseTexture; LatteTexture_GatherTextureRelations(view->baseTexture); LatteTexture_UpdateTextureFromDynamicChanges(view->baseTexture); @@ -1191,12 +1191,8 @@ LatteTextureView* LatteTC_GetTextureSliceViewOrTryCreate(MPTR srcImagePtr, MPTR void LatteTexture_UpdateDataToLatest(LatteTexture* texture) { if (LatteTC_HasTextureChanged(texture)) - { - g_renderer->texture_rememberBoundTexture(0); - g_renderer->texture_bindAndActivateRawTex(texture, 0); - LatteTexture_ReloadData(texture, 0); - g_renderer->texture_restoreBoundTexture(0); - } + LatteTexture_ReloadData(texture); + if (texture->reloadFromDynamicTextures) { LatteTexture_UpdateCacheFromDynamicTextures(texture); @@ -1245,7 +1241,7 @@ std::vector& LatteTexture::GetAllTextures() return sAllTextures; } -LatteTexture::LatteTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, +LatteTexture::LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { _AddTextureToGlobalList(this); diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.h b/src/Cafe/HW/Latte/Core/LatteTexture.h index 6cdc528e..d5e872e6 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.h +++ b/src/Cafe/HW/Latte/Core/LatteTexture.h @@ -24,11 +24,9 @@ struct LatteSamplerState class LatteTexture { public: - LatteTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); + LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); virtual ~LatteTexture(); - virtual void InitTextureState() {}; - LatteTextureView* GetOrCreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) { for (auto& itr : views) @@ -307,7 +305,7 @@ std::vector LatteTexture_QueryCacheInfo(); float* LatteTexture_getEffectiveTextureScale(LatteConst::ShaderType shaderType, sint32 texUnit); -LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); +LatteTextureView* LatteTexture_CreateTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); void LatteTexture_Delete(LatteTexture* texture); void LatteTextureLoader_writeReadbackTextureToMemory(LatteTextureDefinition* textureData, uint32 sliceIndex, uint32 mipIndex, uint8* linearPixelData); diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index 9cce2526..0260002b 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -32,9 +32,9 @@ void LatteTexture_setEffectiveTextureScale(LatteConst::ShaderType shaderType, si t[1] = v; } -void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 textureUnit, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex); +void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex); -void LatteTexture_ReloadData(LatteTexture* tex, uint32 textureUnit) +void LatteTexture_ReloadData(LatteTexture* tex) { tex->reloadCount++; for(sint32 mip=0; mipmipLevels; mip++) @@ -44,35 +44,35 @@ void LatteTexture_ReloadData(LatteTexture* tex, uint32 textureUnit) { sint32 numSlices = std::max(tex->depth, 1); for(sint32 s=0; sphysAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); + LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); } else if( tex->dim == Latte::E_DIM::DIM_CUBEMAP ) { cemu_assert_debug((tex->depth % 6) == 0); sint32 numFullCubeMaps = tex->depth/6; // number of cubemaps (if numFullCubeMaps is >1 then this texture is a cubemap array) for(sint32 s=0; sphysAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); + LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); } else if( tex->dim == Latte::E_DIM::DIM_3D ) { sint32 mipDepth = std::max(tex->depth>>mip, 1); for(sint32 s=0; sphysAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); + LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); } } else { // load slice 0 - LatteTextureLoader_UpdateTextureSliceData(tex, textureUnit, 0, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); + LatteTextureLoader_UpdateTextureSliceData(tex, 0, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true); } } tex->lastUpdateEventCounter = LatteTexture_getNextUpdateEventCounter(); } -LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) +LatteTextureView* LatteTexture_CreateTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { - const auto tex = g_renderer->texture_createTextureEx(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); + const auto tex = g_renderer->texture_createTextureEx(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); // init slice/mip info array LatteTexture_InitSliceAndMipInfo(tex); LatteTexture_RegisterTextureMemoryOccupancy(tex); @@ -110,7 +110,7 @@ LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM di } } } - LatteTexture_ReloadData(tex, textureUnit); + LatteTexture_ReloadData(tex); LatteTC_MarkTextureStillInUse(tex); LatteTC_RegisterTexture(tex); // create initial view that maps to the whole texture @@ -247,7 +247,7 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u textureView->lastTextureBindIndex = LatteGPUState.textureBindCounter; rendererGL->renderstate_updateTextureSettingsGL(shaderContext, textureView, textureIndex + glBackendBaseTexUnit, word4, textureIndex, isDepthSampler); } - g_renderer->texture_bindOnly(textureView, textureIndex + glBackendBaseTexUnit); + g_renderer->texture_setLatteTexture(textureView, textureIndex + glBackendBaseTexUnit); // update if data changed bool swizzleChanged = false; if (textureView->baseTexture->swizzle != swizzle) @@ -285,9 +285,8 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u textureView->baseTexture->physMipAddress = physMipAddr; } } - g_renderer->texture_bindAndActivateRawTex(textureView->baseTexture, textureIndex + glBackendBaseTexUnit); debug_printf("Reload reason: Data-change when bound as texture (new hash 0x%08x)\n", textureView->baseTexture->texDataHash2); - LatteTexture_ReloadData(textureView->baseTexture, textureIndex + glBackendBaseTexUnit); + LatteTexture_ReloadData(textureView->baseTexture); } LatteTexture* baseTexture = textureView->baseTexture; if (baseTexture->reloadFromDynamicTextures) diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp index 331c1500..862fff06 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp @@ -599,7 +599,7 @@ void LatteTextureLoader_loadTextureDataIntoSlice(LatteTexture* hostTexture, sint } } -void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 textureUnit, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex) +void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex) { LatteTextureLoaderCtx textureLoader = { 0 }; diff --git a/src/Cafe/HW/Latte/Core/LatteThread.cpp b/src/Cafe/HW/Latte/Core/LatteThread.cpp index 897f769c..60b32ec4 100644 --- a/src/Cafe/HW/Latte/Core/LatteThread.cpp +++ b/src/Cafe/HW/Latte/Core/LatteThread.cpp @@ -44,7 +44,7 @@ LatteTextureView* LatteHandleOSScreen_getOrCreateScreenTex(MPTR physAddress, uin LatteTextureView* texView = LatteTextureViewLookupCache::lookup(physAddress, width, height, 1, pitch, 0, 1, 0, 1, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, Latte::E_DIM::DIM_2D); if (texView) return texView; - return LatteTexture_CreateTexture(0, Latte::E_DIM::DIM_2D, physAddress, 0, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, width, height, 1, pitch, 1, 0, Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED, false); + return LatteTexture_CreateTexture(Latte::E_DIM::DIM_2D, physAddress, 0, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, width, height, 1, pitch, 1, 0, Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED, false); } void LatteHandleOSScreen_prepareTextures() @@ -71,8 +71,7 @@ bool LatteHandleOSScreen_TV() const uint32 bufferIndexTV = (bufferDisplayTV); const uint32 bufferIndexDRC = bufferDisplayDRC; - g_renderer->texture_bindAndActivate(osScreenTVTex[bufferIndexTV], 0); - LatteTexture_ReloadData(osScreenTVTex[bufferIndexTV]->baseTexture, 0); + LatteTexture_ReloadData(osScreenTVTex[bufferIndexTV]->baseTexture); // TV screen LatteRenderTarget_copyToBackbuffer(osScreenTVTex[bufferIndexTV]->baseTexture->baseView, false); @@ -94,8 +93,7 @@ bool LatteHandleOSScreen_DRC() const uint32 bufferIndexDRC = bufferDisplayDRC; - g_renderer->texture_bindAndActivate(osScreenDRCTex[bufferIndexDRC], 0); - LatteTexture_ReloadData(osScreenDRCTex[bufferIndexDRC]->baseTexture, 0); + LatteTexture_ReloadData(osScreenDRCTex[bufferIndexDRC]->baseTexture); // GamePad screen LatteRenderTarget_copyToBackbuffer(osScreenDRCTex[bufferIndexDRC]->baseTexture->baseView, true); diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp index c9541470..584af40c 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp @@ -19,20 +19,17 @@ static GLuint _genTextureHandleGL() return texIdPool[texIdPoolIndex - 1]; } -LatteTextureGL::LatteTextureGL(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, +LatteTextureGL::LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) - : LatteTexture(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth) + : LatteTexture(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth) { - GenerateEmptyTextureFromGX2Dim(dim, this->glId_texture, this->glTexTarget); + GenerateEmptyTextureFromGX2Dim(dim, this->glId_texture, this->glTexTarget, true); // set format info FormatInfoGL glFormatInfo; GetOpenGLFormatInfo(isDepth, format, dim, &glFormatInfo); this->glInternalFormat = glFormatInfo.glInternalFormat; this->isAlternativeFormat = glFormatInfo.isUsingAlternativeFormat; this->hasStencil = glFormatInfo.hasStencil; // todo - should get this from the GX2 format? - // bind texture - g_renderer->texture_bindAndActivateRawTex(this, textureUnit); - LatteTextureGL::InitTextureState(); // set debug name bool useGLDebugNames = false; #ifdef CEMU_DEBUG_ASSERT @@ -54,9 +51,8 @@ LatteTextureGL::~LatteTextureGL() catchOpenGLError(); } -void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget) +void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget, bool createForTargetType) { - texId = _genTextureHandleGL(); if (dim == Latte::E_DIM::DIM_2D) texTarget = GL_TEXTURE_2D; else if (dim == Latte::E_DIM::DIM_1D) @@ -73,6 +69,10 @@ void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& te { cemu_assert_unimplemented(); } + if(createForTargetType) + texId = glCreateTextureWrapper(texTarget); // initializes the texture to texTarget (equivalent to calling glGenTextures + glBindTexture) + else + glGenTextures(1, &texId); } LatteTextureView* LatteTextureGL::CreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) @@ -80,18 +80,6 @@ LatteTextureView* LatteTextureGL::CreateView(Latte::E_DIM dim, Latte::E_GX2SURFF return new LatteTextureViewGL(this, dim, format, firstMip, mipCount, firstSlice, sliceCount); } -void LatteTextureGL::InitTextureState() -{ - // init texture with some default parameters (todo - this shouldn't be necessary if we properly set parameters when a texture is used) - catchOpenGLError(); - glTexParameteri(glTexTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(glTexTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(glTexTarget, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(glTexTarget, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(glTexTarget, GL_TEXTURE_COMPARE_MODE, GL_NONE); - catchOpenGLError(); -} - void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, FormatInfoGL* formatInfoOut) { formatInfoOut->isUsingAlternativeFormat = false; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h index fabd1bac..9169bb29 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h @@ -6,14 +6,12 @@ class LatteTextureGL : public LatteTexture { public: - LatteTextureGL(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, + LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); ~LatteTextureGL(); - static void GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget); - - void InitTextureState() override; + static void GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget, bool createForTargetType); protected: LatteTextureView* CreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) override; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp index f33fd7ff..29085642 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp @@ -11,7 +11,7 @@ LatteTextureViewGL::LatteTextureViewGL(LatteTextureGL* texture, Latte::E_DIM dim firstSlice != 0 || firstMip != 0 || mipCount != texture->mipLevels || sliceCount != texture->depth || forceCreateNewTexId) { - LatteTextureGL::GenerateEmptyTextureFromGX2Dim(dim, glTexId, glTexTarget); + LatteTextureGL::GenerateEmptyTextureFromGX2Dim(dim, glTexId, glTexTarget, false); this->glInternalFormat = 0; InitAliasView(); } diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 01068a3d..f09f04f1 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -77,8 +77,6 @@ static const GLenum glAlphaTestFunc[] = GL_ALWAYS }; - - OpenGLRenderer::OpenGLRenderer() { glRendererState.useTextureUploadBuffer = false; @@ -571,7 +569,7 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu glViewportIndexedf(0, imageX, imageY, imageWidth, imageHeight); LatteTextureViewGL* texViewGL = (LatteTextureViewGL*)texView; - g_renderer->texture_bindAndActivate(texView, 0); + texture_bindAndActivate(texView, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, useLinearTexFilter ? GL_LINEAR : GL_NEAREST); texViewGL->samplerState.filterMag = 0xFFFFFFFF; @@ -586,7 +584,7 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu glEnable(GL_FRAMEBUFFER_SRGB); // unbind texture - g_renderer->texture_bindAndActivate(nullptr, 0); + texture_bindAndActivate(nullptr, 0); catchOpenGLError(); @@ -990,8 +988,9 @@ void OpenGLRenderer::texture_destroy(LatteTexture* hostTexture) delete hostTexture; } -void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTexture) +void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTextureGeneric) { + auto hostTexture = (LatteTextureGL*)hostTextureGeneric; cemu_assert_debug(hostTexture->isDataDefined == false); sint32 effectiveBaseWidth = hostTexture->width; sint32 effectiveBaseHeight = hostTexture->height; @@ -1012,25 +1011,25 @@ void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTexture) if (hostTexture->dim == Latte::E_DIM::DIM_2D || hostTexture->dim == Latte::E_DIM::DIM_2D_MSAA) { cemu_assert_debug(effectiveBaseDepth == 1); - glTexStorage2D(GL_TEXTURE_2D, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); + glTextureStorage2DWrapper(GL_TEXTURE_2D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); } else if (hostTexture->dim == Latte::E_DIM::DIM_1D) { cemu_assert_debug(effectiveBaseHeight == 1); cemu_assert_debug(effectiveBaseDepth == 1); - glTexStorage1D(GL_TEXTURE_1D, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth); + glTextureStorage1DWrapper(GL_TEXTURE_1D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth); } else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) { - glTexStorage3D(GL_TEXTURE_2D_ARRAY, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + glTextureStorage3DWrapper(GL_TEXTURE_2D_ARRAY, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); } else if (hostTexture->dim == Latte::E_DIM::DIM_3D) { - glTexStorage3D(GL_TEXTURE_3D, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + glTextureStorage3DWrapper(GL_TEXTURE_3D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); } else if (hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) { - glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); + glTextureStorage3DWrapper(GL_TEXTURE_CUBE_MAP_ARRAY, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); } else { @@ -1042,7 +1041,6 @@ void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTexture) void OpenGLRenderer_texture_loadSlice_normal(LatteTexture* hostTextureGeneric, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 imageSize) { auto hostTexture = (LatteTextureGL*)hostTextureGeneric; - sint32 effectiveWidth = width; sint32 effectiveHeight = height; sint32 effectiveDepth = depth; @@ -1053,58 +1051,37 @@ void OpenGLRenderer_texture_loadSlice_normal(LatteTexture* hostTextureGeneric, s LatteTextureGL::GetOpenGLFormatInfo(hostTexture->isDepth, hostTexture->overwriteInfo.hasFormatOverwrite ? (Latte::E_GX2SURFFMT)hostTexture->overwriteInfo.format : hostTexture->format, hostTexture->dim, &glFormatInfo); // upload slice catchOpenGLError(); + if (mipIndex >= hostTexture->maxPossibleMipLevels) + { + cemuLog_logDebug(LogType::Force, "2D texture mip level allocated out of range"); + return; + } if (hostTexture->dim == Latte::E_DIM::DIM_2D || hostTexture->dim == Latte::E_DIM::DIM_2D_MSAA) { if (glFormatInfo.glIsCompressed) - { - if (glCompressedTextureSubImage2D) - glCompressedTextureSubImage2D(hostTexture->glId_texture, mipIndex, 0, 0, effectiveWidth, effectiveHeight, glFormatInfo.glInternalFormat, imageSize, pixelData); - else - glCompressedTexSubImage2D(GL_TEXTURE_2D, mipIndex, 0, 0, effectiveWidth, effectiveHeight, glFormatInfo.glInternalFormat, imageSize, pixelData); - } + glCompressedTextureSubImage2DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, 0, effectiveWidth, effectiveHeight, glFormatInfo.glInternalFormat, imageSize, pixelData); else - { - if (mipIndex < hostTexture->maxPossibleMipLevels) - glTexSubImage2D(GL_TEXTURE_2D, mipIndex, 0, 0, effectiveWidth, effectiveHeight, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); - else - cemuLog_logDebug(LogType::Force, "2D texture mip level allocated out of range"); - } + glTextureSubImage2DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, 0, effectiveWidth, effectiveHeight, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); } else if (hostTexture->dim == Latte::E_DIM::DIM_1D) { - if (glFormatInfo.glIsCompressed == true) - cemu_assert_unimplemented(); - glTexSubImage1D(GL_TEXTURE_1D, mipIndex, 0, width, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); + if (glFormatInfo.glIsCompressed) + glCompressedTextureSubImage1DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, width, glFormatInfo.glInternalFormat, imageSize, pixelData); + else + glTextureSubImage1DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, width, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); } - else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) + else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA || + hostTexture->dim == Latte::E_DIM::DIM_3D || + hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) { if (glFormatInfo.glIsCompressed) - glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glInternalFormat, imageSize, pixelData); + glCompressedTextureSubImage3DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glInternalFormat, imageSize, pixelData); else - glTexSubImage3D(GL_TEXTURE_2D_ARRAY, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_3D) - { - if (glFormatInfo.glIsCompressed) - glCompressedTexSubImage3D(GL_TEXTURE_3D, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glInternalFormat, imageSize, pixelData); - else - glTexSubImage3D(GL_TEXTURE_3D, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) - { - if (glFormatInfo.glIsCompressed) - glCompressedTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mipIndex, 0, 0, sliceIndex, width, height, 1, glFormatInfo.glInternalFormat, imageSize, pixelData); - else - glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mipIndex, 0, 0, sliceIndex, width, height, 1, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); - } - else - { - cemu_assert_debug(false); + glTextureSubImage3DWrapper(hostTexture->glTexTarget, hostTexture->glId_texture, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, glFormatInfo.glSuppliedFormat, glFormatInfo.glSuppliedFormatType, pixelData); } catchOpenGLError(); } - // use persistent buffers to upload data void OpenGLRenderer_texture_loadSlice_viaBuffers(LatteTexture* hostTexture, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 imageSize) { @@ -1220,10 +1197,10 @@ void OpenGLRenderer::texture_clearSlice(LatteTexture* hostTextureGeneric, sint32 glClearTexSubImage(hostTexture->glId_texture, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, formatInfoGL.glSuppliedFormat, formatInfoGL.glSuppliedFormatType, NULL); } -LatteTexture* OpenGLRenderer::texture_createTextureEx(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, +LatteTexture* OpenGLRenderer::texture_createTextureEx(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { - return new LatteTextureGL(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); + return new LatteTextureGL(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); } @@ -1239,42 +1216,18 @@ void OpenGLRenderer::texture_setActiveTextureUnit(sint32 index) void OpenGLRenderer::texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit) { const auto textureViewGL = (LatteTextureViewGL*)textureView; - cemu_assert_debug(textureUnit < (sizeof(LatteBoundTexturesBackup) / sizeof(LatteBoundTexturesBackup[0]))); // don't call glBindTexture if the texture is already bound - if (LatteBoundTextures[textureUnit] == textureViewGL) + if (m_latteBoundTextures[textureUnit] == textureViewGL) { texture_setActiveTextureUnit(textureUnit); return; // already bound } // bind - LatteBoundTextures[textureUnit] = textureViewGL; + m_latteBoundTextures[textureUnit] = textureViewGL; texture_setActiveTextureUnit(textureUnit); if (textureViewGL) { glBindTexture(textureViewGL->glTexTarget, textureViewGL->glTexId); - texUnitTexId[textureUnit] = textureViewGL->glTexId; - texUnitTexTarget[textureUnit] = textureViewGL->glTexTarget; - } -} - -void OpenGLRenderer::texture_bindAndActivateRawTex(LatteTexture* texture, uint32 textureUnit) -{ - cemu_assert_debug(textureUnit < (sizeof(LatteBoundTexturesBackup) / sizeof(LatteBoundTexturesBackup[0]))); - // don't call glBindTexture if the texture is already bound - if (LatteBoundTextures[textureUnit] == texture) - { - texture_setActiveTextureUnit(textureUnit); - return; // already bound - } - // bind - LatteBoundTextures[textureUnit] = texture; - texture_setActiveTextureUnit(textureUnit); - if (texture) - { - auto textureGL = (LatteTextureGL*)texture; - glBindTexture(textureGL->glTexTarget, textureGL->glId_texture); - texUnitTexId[textureUnit] = textureGL->glId_texture; - texUnitTexTarget[textureUnit] = textureGL->glTexTarget; } } @@ -1282,18 +1235,18 @@ void OpenGLRenderer::texture_notifyDelete(LatteTextureView* textureView) { for (uint32 i = 0; i < Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3; i++) { - if (LatteBoundTextures[i] == textureView) - LatteBoundTextures[i] = nullptr; + if (m_latteBoundTextures[i] == textureView) + m_latteBoundTextures[i] = nullptr; } } -// similar to _bindAndActivate() but doesn't call _setActiveTextureUnit() if texture is already bound -void OpenGLRenderer::texture_bindOnly(LatteTextureView* textureView1, uint32 textureUnit) +// set Latte texture, on the OpenGL renderer this behaves like _bindAndActivate() but doesn't call _setActiveTextureUnit() if the texture is already bound +void OpenGLRenderer::texture_setLatteTexture(LatteTextureView* textureView1, uint32 textureUnit) { auto textureView = ((LatteTextureViewGL*)textureView1); cemu_assert_debug(textureUnit < Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3); - if (LatteBoundTextures[textureUnit] == textureView) + if (m_latteBoundTextures[textureUnit] == textureView) return; if (textureView == nullptr) return; @@ -1301,45 +1254,17 @@ void OpenGLRenderer::texture_bindOnly(LatteTextureView* textureView1, uint32 tex if (glBindTextureUnit) { glBindTextureUnit(textureUnit, textureView->glTexId); - LatteBoundTextures[textureUnit] = textureView; - texUnitTexId[textureUnit] = textureView->glTexId; - texUnitTexTarget[textureUnit] = textureView->glTexTarget; + m_latteBoundTextures[textureUnit] = textureView; activeTextureUnit = -1; } else { texture_setActiveTextureUnit(textureUnit); glBindTexture(textureView->glTexTarget, textureView->glTexId); - LatteBoundTextures[textureUnit] = textureView; - texUnitTexId[textureUnit] = textureView->glTexId; - texUnitTexTarget[textureUnit] = textureView->glTexTarget; + m_latteBoundTextures[textureUnit] = textureView; } } -void OpenGLRenderer::texture_rememberBoundTexture(uint32 textureUnit) -{ - cemu_assert_debug(texUnitBackupSlotUsed[textureUnit] == false); - texUnitBackupSlotUsed[textureUnit] = true; - LatteBoundTexturesBackup[textureUnit] = LatteBoundTextures[textureUnit]; - texUnitTexIdBackup[textureUnit] = texUnitTexId[textureUnit]; - texUnitTexTargetBackup[textureUnit] = texUnitTexTarget[textureUnit]; -} - -void OpenGLRenderer::texture_restoreBoundTexture(uint32 textureUnit) -{ - cemu_assert_debug(texUnitBackupSlotUsed[textureUnit] == true); - texUnitBackupSlotUsed[textureUnit] = false; - if (LatteBoundTextures[textureUnit] == LatteBoundTexturesBackup[textureUnit]) - { - return; // already bound - } - LatteBoundTextures[textureUnit] = LatteBoundTexturesBackup[textureUnit]; - texUnitTexId[textureUnit] = texUnitTexIdBackup[textureUnit]; - texUnitTexTarget[textureUnit] = texUnitTexTargetBackup[textureUnit]; - texture_setActiveTextureUnit(textureUnit); - glBindTexture(texUnitTexTargetBackup[textureUnit], texUnitTexIdBackup[textureUnit]); -} - void OpenGLRenderer::texture_copyImageSubData(LatteTexture* src, sint32 srcMip, sint32 effectiveSrcX, sint32 effectiveSrcY, sint32 srcSlice, LatteTexture* dst, sint32 dstMip, sint32 effectiveDstX, sint32 effectiveDstY, sint32 dstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight, sint32 srcDepth) { diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index b789e2a7..8a4b1a1d 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -79,13 +79,10 @@ public: void texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) override; void texture_clearDepthSlice(LatteTexture* hostTexture, uint32 sliceIndex, sint32 mipIndex, bool clearDepth, bool clearStencil, float depthValue, uint32 stencilValue) override; - LatteTexture* texture_createTextureEx(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) override; + LatteTexture* texture_createTextureEx(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) override; - void texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit) override; - void texture_bindAndActivateRawTex(LatteTexture* texture, uint32 textureUnit) override; - void texture_bindOnly(LatteTextureView* textureView, uint32 textureUnit) override; - void texture_rememberBoundTexture(uint32 textureUnit) override; - void texture_restoreBoundTexture(uint32 textureUnit) override; + void texture_setLatteTexture(LatteTextureView* textureView, uint32 textureUnit) override; + void texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit); void texture_copyImageSubData(LatteTexture* src, sint32 srcMip, sint32 effectiveSrcX, sint32 effectiveSrcY, sint32 srcSlice, LatteTexture* dst, sint32 dstMip, sint32 effectiveDstX, sint32 effectiveDstY, sint32 dstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight, sint32 srcDepth) override; void texture_notifyDelete(LatteTextureView* textureView); @@ -188,14 +185,7 @@ private: bool m_isXfbActive = false; sint32 activeTextureUnit = 0; - void* LatteBoundTextures[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - GLuint texUnitTexId[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - GLenum texUnitTexTarget[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - - void* LatteBoundTexturesBackup[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - GLuint texUnitTexIdBackup[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - GLenum texUnitTexTargetBackup[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; - bool texUnitBackupSlotUsed[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; + void* m_latteBoundTextures[Latte::GPU_LIMITS::NUM_TEXTURES_PER_STAGE * 3]{}; // attribute stream GLuint glAttributeCacheAB{}; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp index f78b8bd6..51d0d206 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp @@ -1342,7 +1342,7 @@ uint32 _correctTextureCompSelGL(Latte::E_GX2SURFFMT format, uint32 compSel) return compSel; } -#define quickBindTexture() if( textureIsActive == false ) { g_renderer->texture_bindAndActivate(hostTextureView, hostTextureUnit); textureIsActive = true; } +#define quickBindTexture() if( textureIsActive == false ) { texture_bindAndActivate(hostTextureView, hostTextureUnit); textureIsActive = true; } uint32 _getGLMinFilter(Latte::LATTE_SQ_TEX_SAMPLER_WORD0_0::E_XY_FILTER filterMin, Latte::LATTE_SQ_TEX_SAMPLER_WORD0_0::E_Z_FILTER filterMip) { @@ -1365,11 +1365,9 @@ uint32 _getGLMinFilter(Latte::LATTE_SQ_TEX_SAMPLER_WORD0_0::E_XY_FILTER filterMi /* * Update channel swizzling and other texture settings for a texture unit * hostTextureView is the texture unit view used on the host side -* The baseGX2TexUnit parameter is used to identify the shader stage in which this texture is accessed */ void OpenGLRenderer::renderstate_updateTextureSettingsGL(LatteDecompilerShader* shaderContext, LatteTextureView* _hostTextureView, uint32 hostTextureUnit, const Latte::LATTE_SQ_TEX_RESOURCE_WORD4_N texUnitWord4, uint32 texUnitIndex, bool isDepthSampler) { - // todo - this is OpenGL-specific, decouple this from the renderer-neutral backend auto hostTextureView = (LatteTextureViewGL*)_hostTextureView; LatteTexture* baseTexture = hostTextureView->baseTexture; diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp index 8c8c36d7..c49a57e4 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp @@ -52,7 +52,7 @@ void OpenGLRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* s LatteTextureView* sourceView = sourceTexture->GetOrCreateView(srcMip, 1, srcSlice, 1); LatteTextureView* destinationView = destinationTexture->GetOrCreateView(dstMip, 1, dstSlice, 1); - g_renderer->texture_bindAndActivate(sourceView, 0); + texture_bindAndActivate(sourceView, 0); catchOpenGLError(); // setup texture attributes _setDepthCompareMode((LatteTextureViewGL*)sourceView, 0); diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/TextureReadbackGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/TextureReadbackGL.cpp index 56011dab..b2966706 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/TextureReadbackGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/TextureReadbackGL.cpp @@ -1,4 +1,5 @@ #include "Cafe/HW/Latte/Renderer/Renderer.h" +#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h" #include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLTextureReadback.h" #include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.h" @@ -93,8 +94,7 @@ LatteTextureReadbackInfoGL::~LatteTextureReadbackInfoGL() void LatteTextureReadbackInfoGL::StartTransfer() { cemu_assert(m_textureView); - - g_renderer->texture_bindAndActivate(m_textureView, 0); + ((OpenGLRenderer*)g_renderer.get())->texture_bindAndActivate(m_textureView, 0); // create unsynchronized buffer glGenBuffers(1, &texImageBufferGL); glBindBuffer(GL_PIXEL_PACK_BUFFER, texImageBufferGL); diff --git a/src/Cafe/HW/Latte/Renderer/Renderer.h b/src/Cafe/HW/Latte/Renderer/Renderer.h index 11d102d0..93edaf8d 100644 --- a/src/Cafe/HW/Latte/Renderer/Renderer.h +++ b/src/Cafe/HW/Latte/Renderer/Renderer.h @@ -110,13 +110,9 @@ public: virtual void texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) = 0; virtual void texture_clearDepthSlice(LatteTexture* hostTexture, uint32 sliceIndex, sint32 mipIndex, bool clearDepth, bool clearStencil, float depthValue, uint32 stencilValue) = 0; - virtual LatteTexture* texture_createTextureEx(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) = 0; + virtual LatteTexture* texture_createTextureEx(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) = 0; - virtual void texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit) = 0; - virtual void texture_bindAndActivateRawTex(LatteTexture* texture, uint32 textureUnit) = 0; - virtual void texture_bindOnly(LatteTextureView* textureView, uint32 textureUnit) = 0; - virtual void texture_rememberBoundTexture(uint32 textureUnit) = 0; - virtual void texture_restoreBoundTexture(uint32 textureUnit) = 0; + virtual void texture_setLatteTexture(LatteTextureView* textureView, uint32 textureUnit) = 0; virtual void texture_copyImageSubData(LatteTexture* src, sint32 srcMip, sint32 effectiveSrcX, sint32 effectiveSrcY, sint32 srcSlice, LatteTexture* dst, sint32 dstMip, sint32 effectiveDstX, sint32 effectiveDstY, sint32 dstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight, sint32 srcDepth) = 0; virtual LatteTextureReadbackInfo* texture_createReadback(LatteTextureView* textureView) = 0; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp index b41760bc..b5f62707 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp @@ -3,9 +3,9 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h" #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" -LatteTextureVk::LatteTextureVk(class VulkanRenderer* vkRenderer, uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, +LatteTextureVk::LatteTextureVk(class VulkanRenderer* vkRenderer, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) - : LatteTexture(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth), m_vkr(vkRenderer) + : LatteTexture(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth), m_vkr(vkRenderer) { vkObjTex = new VKRObjectTexture(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h index 2131ed9c..714c4e17 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h @@ -9,7 +9,7 @@ class LatteTextureVk : public LatteTexture { public: - LatteTextureVk(class VulkanRenderer* vkRenderer, uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, + LatteTextureVk(class VulkanRenderer* vkRenderer, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); ~LatteTextureVk(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 2ce5dacd..44214606 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -3326,18 +3326,13 @@ void VulkanRenderer::texture_loadSlice(LatteTexture* hostTexture, sint32 width, barrier_image(vkTexture, barrierSubresourceRange, VK_IMAGE_LAYOUT_GENERAL); } -LatteTexture* VulkanRenderer::texture_createTextureEx(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, +LatteTexture* VulkanRenderer::texture_createTextureEx(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { - return new LatteTextureVk(this, textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); + return new LatteTextureVk(this, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); } -void VulkanRenderer::texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit) -{ - m_state.boundTexture[textureUnit] = static_cast(textureView); -} - -void VulkanRenderer::texture_bindOnly(LatteTextureView* textureView, uint32 textureUnit) +void VulkanRenderer::texture_setLatteTexture(LatteTextureView* textureView, uint32 textureUnit) { m_state.boundTexture[textureUnit] = static_cast(textureView); } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 84cae587..b61a0b40 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -300,15 +300,10 @@ public: void texture_loadSlice(LatteTexture* hostTexture, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 compressedImageSize) override; - LatteTexture* texture_createTextureEx(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) override; + LatteTexture* texture_createTextureEx(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) override; - void texture_bindAndActivate(LatteTextureView* textureView, uint32 textureUnit) override; - void texture_bindOnly(LatteTextureView* textureView, uint32 textureUnit) override; + void texture_setLatteTexture(LatteTextureView* textureView, uint32 textureUnit) override; - void texture_bindAndActivateRawTex(LatteTexture* texture, uint32 textureUnit) override {}; - - void texture_rememberBoundTexture(uint32 textureUnit) override {}; - void texture_restoreBoundTexture(uint32 textureUnit) override {}; void texture_copyImageSubData(LatteTexture* src, sint32 srcMip, sint32 effectiveSrcX, sint32 effectiveSrcY, sint32 srcSlice, LatteTexture* dst, sint32 dstMip, sint32 effectiveDstX, sint32 effectiveDstY, sint32 dstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight, sint32 srcDepth) override; LatteTextureReadbackInfo* texture_createReadback(LatteTextureView* textureView) override; diff --git a/src/Common/GLInclude/GLInclude.h b/src/Common/GLInclude/GLInclude.h index 6f5d33db..bf7a6bf8 100644 --- a/src/Common/GLInclude/GLInclude.h +++ b/src/Common/GLInclude/GLInclude.h @@ -42,6 +42,177 @@ typedef struct __GLXFBConfigRec *GLXFBConfig; #undef GLFUNC #undef EGLFUNC +// DSA-style helpers with fallback to legacy API if DSA is not supported + +#define DSA_FORCE_DISABLE false // set to true to simulate DSA not being supported + +static GLenum GetGLBindingFromTextureTarget(GLenum texTarget) +{ + switch(texTarget) + { + case GL_TEXTURE_1D: return GL_TEXTURE_BINDING_1D; + case GL_TEXTURE_2D: return GL_TEXTURE_BINDING_2D; + case GL_TEXTURE_3D: return GL_TEXTURE_BINDING_3D; + case GL_TEXTURE_2D_ARRAY: return GL_TEXTURE_BINDING_2D_ARRAY; + case GL_TEXTURE_CUBE_MAP: return GL_TEXTURE_BINDING_CUBE_MAP; + case GL_TEXTURE_CUBE_MAP_ARRAY: return GL_TEXTURE_BINDING_CUBE_MAP_ARRAY; + default: + cemu_assert_unimplemented(); + return 0; + } +} + +static GLuint glCreateTextureWrapper(GLenum target) +{ + GLuint tex; + if (glCreateTextures && !DSA_FORCE_DISABLE) + { + glCreateTextures(target, 1, &tex); + return tex; + } + GLint originalTexture; + glGetIntegerv(GetGLBindingFromTextureTarget(target), &originalTexture); + glGenTextures(1, &tex); + glBindTexture(target, tex); + glBindTexture(target, originalTexture); + return tex; +} + +static void glTextureStorage1DWrapper(GLenum target, GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width) +{ + if (glTextureStorage1D && !DSA_FORCE_DISABLE) + { + glTextureStorage1D(texture, levels, internalformat, width); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexStorage1D(target, levels, internalformat, width); + glBindTexture(target, originalTexture); +} + +static void glTextureStorage2DWrapper(GLenum target, GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) +{ + if (glTextureStorage2D && !DSA_FORCE_DISABLE) + { + glTextureStorage2D(texture, levels, internalformat, width, height); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexStorage2D(target, levels, internalformat, width, height); + glBindTexture(target, originalTexture); +} + +static void glTextureStorage3DWrapper(GLenum target, GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) +{ + if (glTextureStorage3D && !DSA_FORCE_DISABLE) + { + glTextureStorage3D(texture, levels, internalformat, width, height, depth); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexStorage3D(target, levels, internalformat, width, height, depth); + glBindTexture(target, originalTexture); +} + +static void glTextureSubImage1DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels) +{ + if (glTextureSubImage1D && !DSA_FORCE_DISABLE) + { + glTextureSubImage1D(texture, level, xoffset, width, format, type, pixels); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + glBindTexture(target, originalTexture); +} + +static void glCompressedTextureSubImage1DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data) +{ + if (glCompressedTextureSubImage1D && !DSA_FORCE_DISABLE) + { + glCompressedTextureSubImage1D(texture, level, xoffset, width, format, imageSize, data); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, data); + glBindTexture(target, originalTexture); +} + +static void glTextureSubImage2DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) +{ + if (glTextureSubImage2D && !DSA_FORCE_DISABLE) + { + glTextureSubImage2D(texture, level, xoffset, yoffset, width, height, format, type, pixels); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + glBindTexture(target, originalTexture); +} + +static void glCompressedTextureSubImage2DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) +{ + if (glCompressedTextureSubImage2D && !DSA_FORCE_DISABLE) + { + glCompressedTextureSubImage2D(texture, level, xoffset, yoffset, width, height, format, imageSize, data); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + glBindTexture(target, originalTexture); +} + +static void glTextureSubImage3DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) +{ + if(glTextureSubImage3D && !DSA_FORCE_DISABLE) + { + glTextureSubImage3D(texture, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + glBindTexture(target, originalTexture); +} + +static void glCompressedTextureSubImage3DWrapper(GLenum target, GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data) +{ + if(glCompressedTextureSubImage3D && !DSA_FORCE_DISABLE) + { + glCompressedTextureSubImage3D(texture, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); + return; + } + GLenum binding = GetGLBindingFromTextureTarget(target); + GLint originalTexture; + glGetIntegerv(binding, &originalTexture); + glBindTexture(target, texture); + glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); + glBindTexture(target, originalTexture); +} + // this prevents Windows GL.h from being included: #define __gl_h_ #define __GL_H__ diff --git a/src/Common/GLInclude/glFunctions.h b/src/Common/GLInclude/glFunctions.h index 4cf25a6b..76308fdb 100644 --- a/src/Common/GLInclude/glFunctions.h +++ b/src/Common/GLInclude/glFunctions.h @@ -171,10 +171,13 @@ GLFUNC(PFNGLTEXSTORAGE2DPROC, glTexStorage2D) GLFUNC(PFNGLTEXSTORAGE3DPROC, glTexStorage3D) GLFUNC(PFNGLTEXIMAGE3DPROC, glTexImage3D) GLFUNC(PFNGLTEXSUBIMAGE3DPROC, glTexSubImage3D) +GLFUNC(PFNGLCOMPRESSEDTEXIMAGE1DPROC, glCompressedTexImage1D) GLFUNC(PFNGLCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2D) GLFUNC(PFNGLCOMPRESSEDTEXIMAGE3DPROC, glCompressedTexImage3D) +GLFUNC(PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC, glCompressedTexSubImage1D) GLFUNC(PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC, glCompressedTexSubImage2D) GLFUNC(PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedTexSubImage3D) +GLFUNC(PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC, glCompressedTextureSubImage1D) GLFUNC(PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC, glCompressedTextureSubImage2D) GLFUNC(PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC, glCompressedTextureSubImage3D) GLFUNC(PFNGLCOPYIMAGESUBDATAPROC, glCopyImageSubData) @@ -184,12 +187,17 @@ GLFUNC(PFNGLINVALIDATETEXIMAGEPROC, glInvalidateTexImage) // texture DSA +GLFUNC(PFNGLCREATETEXTURESPROC, glCreateTextures) GLFUNC(PFNGLBINDTEXTUREUNITPROC, glBindTextureUnit) GLFUNC(PFNGLGETTEXTURELEVELPARAMETERIVPROC, glGetTextureLevelParameteriv) GLFUNC(PFNGLTEXTUREPARAMETERIPROC, glTextureParameteri) GLFUNC(PFNGLGETTEXTURESUBIMAGEPROC, glGetTextureSubImage) +GLFUNC(PFNGLTEXTURESUBIMAGE1DPROC, glTextureSubImage1D) GLFUNC(PFNGLTEXTURESUBIMAGE2DPROC, glTextureSubImage2D); GLFUNC(PFNGLTEXTURESUBIMAGE3DPROC, glTextureSubImage3D) +GLFUNC(PFNGLTEXTURESTORAGE1DPROC, glTextureStorage1D) +GLFUNC(PFNGLTEXTURESTORAGE2DPROC, glTextureStorage2D) +GLFUNC(PFNGLTEXTURESTORAGE3DPROC, glTextureStorage3D) // instancing / draw From 2167143c17168cc7376b08a8fb3a501c1bc3ab87 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Dec 2023 12:22:59 +0100 Subject: [PATCH 066/314] Latte: Support for SAMPLE_LB --- .../HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp | 4 ++++ .../LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp | 9 +++++++-- .../LegacyShaderDecompiler/LatteDecompilerInternal.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp index 30e3d7a2..cf88b901 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp @@ -666,6 +666,9 @@ void LatteDecompiler_ParseTEXClause(LatteDecompilerShader* shaderContext, LatteD uint32 offsetY = (word2 >> 5) & 0x1F; uint32 offsetZ = (word2 >> 10) & 0x1F; + sint8 lodBias = (word2 >> 21) & 0x7F; + if ((lodBias&0x40) != 0) + lodBias |= 0x80; // bufferID -> Texture index // samplerId -> Sampler index sint32 textureIndex = bufferId - 0x00; @@ -693,6 +696,7 @@ void LatteDecompiler_ParseTEXClause(LatteDecompilerShader* shaderContext, LatteD texInstruction.textureFetch.unnormalized[1] = coordTypeY == 0; texInstruction.textureFetch.unnormalized[2] = coordTypeZ == 0; texInstruction.textureFetch.unnormalized[3] = coordTypeW == 0; + texInstruction.textureFetch.lodBias = (sint8)lodBias; cfInstruction->instructionsTEX.emplace_back(texInstruction); } else if( inst0_4 == GPU7_TEX_INST_SET_CUBEMAP_INDEX ) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index a37ba011..aa7b7162 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -2561,8 +2561,13 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt // lod or lod bias parameter if( texOpcode == GPU7_TEX_INST_SAMPLE_L || texOpcode == GPU7_TEX_INST_SAMPLE_LB || texOpcode == GPU7_TEX_INST_SAMPLE_C_L) { - src->add(","); - _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); + if(texOpcode == GPU7_TEX_INST_SAMPLE_LB) + src->addFmt("{}", (float)texInstruction->textureFetch.lodBias / 16.0f); + else + { + src->add(","); + _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); + } } else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ ) { diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h index 54112ddf..ac2a1fe1 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h @@ -57,6 +57,7 @@ struct LatteDecompilerTEXInstruction sint8 offsetY{}; sint8 offsetZ{}; bool unnormalized[4]{}; // set if texture coordinates are in [0,dim] range instead of [0,1] + sint8 lodBias{}; // divide by 16 to get actual value }textureFetch; // memRead struct From d2ba4e65c5d7802e53faac21922be1bf9347f325 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:09:30 +0100 Subject: [PATCH 067/314] Latte: 1D views are compatible with 1D textures --- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 06afed60..d38af8ec 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -795,6 +795,8 @@ bool IsDimensionCompatibleForView(Latte::E_DIM baseDim, Latte::E_DIM viewDim) bool incompatibleDim = false; if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D) ; + else if (baseDim == Latte::E_DIM::DIM_1D && viewDim == Latte::E_DIM::DIM_1D) + ; else if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D_ARRAY) ; else if (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_CUBEMAP) From bab1616565b8fab99c52e0bedb275ae90a7b53df Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:43:37 +0100 Subject: [PATCH 068/314] nsysnet: Add support for SO_BIO and handle SO_ENOTCONN --- .../libs/nn_olv/nn_olv_UploadCommunityTypes.h | 6 ++---- src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h index 16ebd29a..2c53f118 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.h @@ -256,10 +256,8 @@ namespace nn this->flags = 0; memset(this->titleText, 0, sizeof(this->titleText)); memset(this->description, 0, sizeof(this->description)); - int v2 = 0; - do - memset(this->searchKeys[v2++], 0, sizeof(this->searchKeys[v2++])); - while (v2 < 5); + for (int i = 0; i < 5; i++) + memset(this->searchKeys[i], 0, sizeof(this->searchKeys[0])); } static UploadCommunityDataParam* __ctor(UploadCommunityDataParam* _this) { diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index e0224148..128c19a5 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -13,6 +13,7 @@ #define WSAESHUTDOWN ESHUTDOWN #define WSAECONNABORTED ECONNABORTED #define WSAHOST_NOT_FOUND EAI_NONAME +#define WSAENOTCONN ENOTCONN #define GETLASTERR errno @@ -40,6 +41,7 @@ #define WU_SO_RCVBUF 0x1002 #define WU_SO_LASTERROR 0x1007 #define WU_SO_NBIO 0x1014 +#define WU_SO_BIO 0x1015 #define WU_SO_NONBLOCK 0x1016 #define WU_TCP_NODELAY 0x2004 @@ -53,6 +55,7 @@ #define WU_SO_SUCCESS 0x0000 #define WU_SO_EWOULDBLOCK 0x0006 #define WU_SO_ECONNRESET 0x0008 +#define WU_SO_ENOTCONN 0x0009 #define WU_SO_EINVAL 0x000B #define WU_SO_EINPROGRESS 0x0016 #define WU_SO_EAFNOSUPPORT 0x0021 @@ -148,8 +151,11 @@ sint32 _translateError(sint32 returnCode, sint32 wsaError, sint32 mode = _ERROR_ case WSAESHUTDOWN: _setSockError(WU_SO_ESHUTDOWN); break; + case WSAENOTCONN: + _setSockError(WU_SO_ENOTCONN); + break; default: - cemuLog_logDebug(LogType::Force, "Unhandled wsaError {}\n", wsaError); + cemuLog_logDebug(LogType::Force, "Unhandled wsaError {}", wsaError); _setSockError(99999); // unhandled error } return -1; @@ -157,7 +163,7 @@ sint32 _translateError(sint32 returnCode, sint32 wsaError, sint32 mode = _ERROR_ void nsysnetExport_socketlasterr(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::Socket, "socketlasterr() -> {}", _getSockError()); + cemuLog_logDebug(LogType::Socket, "socketlasterr() -> {}", _getSockError()); osLib_returnFromFunction(hCPU, _getSockError()); } @@ -485,9 +491,9 @@ void nsysnetExport_setsockopt(PPCInterpreter_t* hCPU) if (r != 0) cemu_assert_suspicious(); } - else if (optname == WU_SO_NBIO) + else if (optname == WU_SO_NBIO || optname == WU_SO_BIO) { - // similar to WU_SO_NONBLOCK but always sets non-blocking mode regardless of option value + // similar to WU_SO_NONBLOCK but always sets blocking (_BIO) or non-blocking (_NBIO) mode regardless of option value if (optlen == 4) { sint32 optvalLE = _swapEndianU32(*(uint32*)optval); @@ -498,9 +504,10 @@ void nsysnetExport_setsockopt(PPCInterpreter_t* hCPU) } else cemu_assert_suspicious(); - u_long mode = 1; + bool setNonBlocking = optname == WU_SO_NBIO; + u_long mode = setNonBlocking ? 1 : 0; _socket_nonblock(vs->s, mode); - vs->isNonBlocking = true; + vs->isNonBlocking = setNonBlocking; } else if (optname == WU_SO_NONBLOCK) { From 4405116324fda4895ccdc1ec6bc32ee253b16261 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sun, 24 Dec 2023 00:25:01 +0100 Subject: [PATCH 069/314] GDBStub: Support watchpoints on linux (#1030) * GDBStub: Support watchpoints on linux * GDBStub: Use `TCP_NODELAY` --- src/Cafe/CMakeLists.txt | 1 + .../HW/Espresso/Debugger/GDBBreakpoints.cpp | 304 ++++++++++++++++++ .../HW/Espresso/Debugger/GDBBreakpoints.h | 211 +----------- src/Cafe/HW/Espresso/Debugger/GDBStub.cpp | 8 + src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 31 +- .../ExceptionHandler_posix.cpp | 13 + 6 files changed, 371 insertions(+), 197 deletions(-) create mode 100644 src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.cpp diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 29c5a0b3..9e20bb33 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -40,6 +40,7 @@ add_library(CemuCafe HW/Espresso/Debugger/DebugSymbolStorage.h HW/Espresso/Debugger/GDBStub.h HW/Espresso/Debugger/GDBStub.cpp + HW/Espresso/Debugger/GDBBreakpoints.cpp HW/Espresso/Debugger/GDBBreakpoints.h HW/Espresso/EspressoISA.h HW/Espresso/Interpreter/PPCInterpreterALU.hpp diff --git a/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.cpp b/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.cpp new file mode 100644 index 00000000..675050d3 --- /dev/null +++ b/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.cpp @@ -0,0 +1,304 @@ +#include "GDBBreakpoints.h" +#include "Debugger.h" +#include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h" + +#if defined(ARCH_X86_64) && BOOST_OS_LINUX +#include +#include +#include + +DRType _GetDR(pid_t tid, int drIndex) +{ + size_t drOffset = offsetof(struct user, u_debugreg) + drIndex * sizeof(user::u_debugreg[0]); + + long v; + v = ptrace(PTRACE_PEEKUSER, tid, drOffset, nullptr); + if (v == -1) + perror("ptrace(PTRACE_PEEKUSER)"); + + return (DRType)v; +} + +void _SetDR(pid_t tid, int drIndex, DRType newValue) +{ + size_t drOffset = offsetof(struct user, u_debugreg) + drIndex * sizeof(user::u_debugreg[0]); + + long rc = ptrace(PTRACE_POKEUSER, tid, drOffset, newValue); + if (rc == -1) + perror("ptrace(PTRACE_POKEUSER)"); +} + +DRType _ReadDR6() +{ + pid_t tid = gettid(); + + // linux doesn't let us attach to the current thread / threads in the current thread group + // we have to create a child process which then modifies the debug registers and quits + pid_t child = fork(); + if (child == -1) + { + perror("fork"); + return 0; + } + + if (child == 0) + { + if (ptrace(PTRACE_ATTACH, tid, nullptr, nullptr)) + { + perror("attach"); + _exit(0); + } + + waitpid(tid, NULL, 0); + + uint64_t dr6 = _GetDR(tid, 6); + + if (ptrace(PTRACE_DETACH, tid, nullptr, nullptr)) + perror("detach"); + + // since the status code only uses the lower 8 bits, we have to discard the rest of DR6 + // this should be fine though, since the lower 4 bits of DR6 contain all the bp conditions + _exit(dr6 & 0xff); + } + + // wait for child process + int wstatus; + waitpid(child, &wstatus, 0); + + return (DRType)WEXITSTATUS(wstatus); +} +#endif + +GDBServer::ExecutionBreakpoint::ExecutionBreakpoint(MPTR address, BreakpointType type, bool visible, std::string reason) + : m_address(address), m_removedAfterInterrupt(false), m_reason(std::move(reason)) +{ + if (type == BreakpointType::BP_SINGLE) + { + this->m_pauseThreads = true; + this->m_restoreAfterInterrupt = false; + this->m_deleteAfterAnyInterrupt = false; + this->m_pauseOnNextInterrupt = false; + this->m_visible = visible; + } + else if (type == BreakpointType::BP_PERSISTENT) + { + this->m_pauseThreads = true; + this->m_restoreAfterInterrupt = true; + this->m_deleteAfterAnyInterrupt = false; + this->m_pauseOnNextInterrupt = false; + this->m_visible = visible; + } + else if (type == BreakpointType::BP_RESTORE_POINT) + { + this->m_pauseThreads = false; + this->m_restoreAfterInterrupt = false; + this->m_deleteAfterAnyInterrupt = false; + this->m_pauseOnNextInterrupt = false; + this->m_visible = false; + } + else if (type == BreakpointType::BP_STEP_POINT) + { + this->m_pauseThreads = false; + this->m_restoreAfterInterrupt = false; + this->m_deleteAfterAnyInterrupt = true; + this->m_pauseOnNextInterrupt = true; + this->m_visible = false; + } + + this->m_origOpCode = memory_readU32(address); + memory_writeU32(address, DEBUGGER_BP_T_GDBSTUB_TW); + PPCRecompiler_invalidateRange(address, address + 4); +} + +GDBServer::ExecutionBreakpoint::~ExecutionBreakpoint() +{ + memory_writeU32(this->m_address, this->m_origOpCode); + PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); +} + +uint32 GDBServer::ExecutionBreakpoint::GetVisibleOpCode() const +{ + if (this->m_visible) + return memory_readU32(this->m_address); + else + return this->m_origOpCode; +} + +void GDBServer::ExecutionBreakpoint::RemoveTemporarily() +{ + memory_writeU32(this->m_address, this->m_origOpCode); + PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); + this->m_restoreAfterInterrupt = true; +} + +void GDBServer::ExecutionBreakpoint::Restore() +{ + memory_writeU32(this->m_address, DEBUGGER_BP_T_GDBSTUB_TW); + PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); + this->m_restoreAfterInterrupt = false; +} + +namespace coreinit +{ +#if BOOST_OS_LINUX + std::vector& OSGetSchedulerThreadIds(); +#endif + + std::vector& OSGetSchedulerThreads(); +} + +GDBServer::AccessBreakpoint::AccessBreakpoint(MPTR address, AccessPointType type) + : m_address(address), m_type(type) +{ +#if defined(ARCH_X86_64) && BOOST_OS_WINDOWS + for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) + { + HANDLE hThread = (HANDLE)hThreadNH; + CONTEXT ctx{}; + ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; + SuspendThread(hThread); + GetThreadContext(hThread, &ctx); + + // use BP 2/3 for gdb stub since cemu's internal debugger uses BP 0/1 already + ctx.Dr2 = (DWORD64)memory_getPointerFromVirtualOffset(address); + ctx.Dr3 = (DWORD64)memory_getPointerFromVirtualOffset(address); + // breakpoint 2 + SetBits(ctx.Dr7, 4, 1, 1); // breakpoint #3 enabled: true + SetBits(ctx.Dr7, 24, 2, 1); // breakpoint #3 condition: 1 (write) + SetBits(ctx.Dr7, 26, 2, 3); // breakpoint #3 length: 3 (4 bytes) + // breakpoint 3 + SetBits(ctx.Dr7, 6, 1, 1); // breakpoint #4 enabled: true + SetBits(ctx.Dr7, 28, 2, 3); // breakpoint #4 condition: 3 (read & write) + SetBits(ctx.Dr7, 30, 2, 3); // breakpoint #4 length: 3 (4 bytes) + + SetThreadContext(hThread, &ctx); + ResumeThread(hThread); + } +#elif defined(ARCH_X86_64) && BOOST_OS_LINUX + // linux doesn't let us attach to threads which are in the same thread group as our current thread + // we have to create a child process which then modifies the debug registers and quits + pid_t child = fork(); + if (child == -1) + { + perror("fork"); + return; + } + + if (child == 0) + { + for (pid_t tid : coreinit::OSGetSchedulerThreadIds()) + { + long rc = ptrace(PTRACE_ATTACH, tid, nullptr, nullptr); + if (rc == -1) + perror("ptrace(PTRACE_ATTACH)"); + + waitpid(tid, nullptr, 0); + + DRType dr7 = _GetDR(tid, 7); + // use BP 2/3 for gdb stub since cemu's internal debugger uses BP 0/1 already + DRType dr2 = (uint64)memory_getPointerFromVirtualOffset(address); + DRType dr3 = (uint64)memory_getPointerFromVirtualOffset(address); + // breakpoint 2 + SetBits(dr7, 4, 1, 1); // breakpoint #3 enabled: true + SetBits(dr7, 24, 2, 1); // breakpoint #3 condition: 1 (write) + SetBits(dr7, 26, 2, 3); // breakpoint #3 length: 3 (4 bytes) + // breakpoint 3 + SetBits(dr7, 6, 1, 1); // breakpoint #4 enabled: true + SetBits(dr7, 28, 2, 3); // breakpoint #4 condition: 3 (read & write) + SetBits(dr7, 30, 2, 3); // breakpoint #4 length: 3 (4 bytes) + + _SetDR(tid, 2, dr2); + _SetDR(tid, 3, dr3); + _SetDR(tid, 7, dr7); + + rc = ptrace(PTRACE_DETACH, tid, nullptr, nullptr); + if (rc == -1) + perror("ptrace(PTRACE_DETACH)"); + } + + // exit child process + _exit(0); + } + + // wait for child process + waitpid(child, nullptr, 0); +#else + cemuLog_log(LogType::Force, "Debugger read/write breakpoints are not supported on non-x86 CPUs yet."); +#endif +} + +GDBServer::AccessBreakpoint::~AccessBreakpoint() +{ +#if defined(ARCH_X86_64) && BOOST_OS_WINDOWS + for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) + { + HANDLE hThread = (HANDLE)hThreadNH; + CONTEXT ctx{}; + ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; + SuspendThread(hThread); + GetThreadContext(hThread, &ctx); + + // reset BP 2/3 to zero + ctx.Dr2 = (DWORD64)0; + ctx.Dr3 = (DWORD64)0; + // breakpoint 2 + SetBits(ctx.Dr7, 4, 1, 0); + SetBits(ctx.Dr7, 24, 2, 0); + SetBits(ctx.Dr7, 26, 2, 0); + // breakpoint 3 + SetBits(ctx.Dr7, 6, 1, 0); + SetBits(ctx.Dr7, 28, 2, 0); + SetBits(ctx.Dr7, 30, 2, 0); + SetThreadContext(hThread, &ctx); + ResumeThread(hThread); + } +#elif defined(ARCH_X86_64) && BOOST_OS_LINUX + // linux doesn't let us attach to threads which are in the same thread group as our current thread + // we have to create a child process which then modifies the debug registers and quits + pid_t child = fork(); + if (child == -1) + { + perror("fork"); + return; + } + + if (child == 0) + { + for (pid_t tid : coreinit::OSGetSchedulerThreadIds()) + { + long rc = ptrace(PTRACE_ATTACH, tid, nullptr, nullptr); + if (rc == -1) + perror("ptrace(PTRACE_ATTACH)"); + + waitpid(tid, nullptr, 0); + + DRType dr7 = _GetDR(tid, 7); + // reset BP 2/3 to zero + DRType dr2 = 0; + DRType dr3 = 0; + // breakpoint 2 + SetBits(dr7, 4, 1, 0); + SetBits(dr7, 24, 2, 0); + SetBits(dr7, 26, 2, 0); + // breakpoint 3 + SetBits(dr7, 6, 1, 0); + SetBits(dr7, 28, 2, 0); + SetBits(dr7, 30, 2, 0); + + _SetDR(tid, 2, dr2); + _SetDR(tid, 3, dr3); + _SetDR(tid, 7, dr7); + + rc = ptrace(PTRACE_DETACH, tid, nullptr, nullptr); + if (rc == -1) + perror("ptrace(PTRACE_DETACH)"); + } + + // exit child process + _exit(0); + } + + // wait for child process + waitpid(child, nullptr, 0); +#endif +} diff --git a/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.h b/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.h index b86bd9a6..f94365c2 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.h +++ b/src/Cafe/HW/Espresso/Debugger/GDBBreakpoints.h @@ -1,33 +1,18 @@ +#pragma once +#include "GDBStub.h" #include -#if defined(ARCH_X86_64) && BOOST_OS_LINUX && FALSE -#include -#include -#include +#if defined(ARCH_X86_64) && BOOST_OS_LINUX +#include // helpers for accessing debug register typedef unsigned long DRType; -DRType _GetDR(pid_t tid, int drIndex) -{ - unsigned long v; - v = ptrace (PTRACE_PEEKUSER, tid, offsetof (struct user, u_debugreg[drIndex]), 0); - return (DRType)v; -} - -void _SetDR(pid_t tid, int drIndex, DRType newValue) -{ - unsigned long v = newValue; - ptrace (PTRACE_POKEUSER, tid, offsetof (struct user, u_debugreg[drIndex]), v); -} - +DRType _GetDR(pid_t tid, int drIndex); +void _SetDR(pid_t tid, int drIndex, DRType newValue); +DRType _ReadDR6(); #endif -namespace coreinit -{ - std::vector& OSGetSchedulerThreads(); -} - enum class BreakpointType { BP_SINGLE, @@ -38,59 +23,10 @@ enum class BreakpointType class GDBServer::ExecutionBreakpoint { public: - ExecutionBreakpoint(MPTR address, BreakpointType type, bool visible, std::string reason) - : m_address(address), m_removedAfterInterrupt(false), m_reason(std::move(reason)) - { - if (type == BreakpointType::BP_SINGLE) - { - this->m_pauseThreads = true; - this->m_restoreAfterInterrupt = false; - this->m_deleteAfterAnyInterrupt = false; - this->m_pauseOnNextInterrupt = false; - this->m_visible = visible; - } - else if (type == BreakpointType::BP_PERSISTENT) - { - this->m_pauseThreads = true; - this->m_restoreAfterInterrupt = true; - this->m_deleteAfterAnyInterrupt = false; - this->m_pauseOnNextInterrupt = false; - this->m_visible = visible; - } - else if (type == BreakpointType::BP_RESTORE_POINT) - { - this->m_pauseThreads = false; - this->m_restoreAfterInterrupt = false; - this->m_deleteAfterAnyInterrupt = false; - this->m_pauseOnNextInterrupt = false; - this->m_visible = false; - } - else if (type == BreakpointType::BP_STEP_POINT) - { - this->m_pauseThreads = false; - this->m_restoreAfterInterrupt = false; - this->m_deleteAfterAnyInterrupt = true; - this->m_pauseOnNextInterrupt = true; - this->m_visible = false; - } + ExecutionBreakpoint(MPTR address, BreakpointType type, bool visible, std::string reason); + ~ExecutionBreakpoint(); - this->m_origOpCode = memory_readU32(address); - memory_writeU32(address, DEBUGGER_BP_T_GDBSTUB_TW); - PPCRecompiler_invalidateRange(address, address + 4); - }; - ~ExecutionBreakpoint() - { - memory_writeU32(this->m_address, this->m_origOpCode); - PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); - }; - - [[nodiscard]] uint32 GetVisibleOpCode() const - { - if (this->m_visible) - return memory_readU32(this->m_address); - else - return this->m_origOpCode; - }; + [[nodiscard]] uint32 GetVisibleOpCode() const; [[nodiscard]] bool ShouldBreakThreads() const { return this->m_pauseThreads; @@ -118,18 +54,8 @@ public: return m_reason; }; - void RemoveTemporarily() - { - memory_writeU32(this->m_address, this->m_origOpCode); - PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); - this->m_restoreAfterInterrupt = true; - }; - void Restore() - { - memory_writeU32(this->m_address, DEBUGGER_BP_T_GDBSTUB_TW); - PPCRecompiler_invalidateRange(this->m_address, this->m_address + 4); - this->m_restoreAfterInterrupt = false; - }; + void RemoveTemporarily(); + void Restore(); void PauseOnNextInterrupt() { this->m_pauseOnNextInterrupt = true; @@ -162,115 +88,8 @@ enum class AccessPointType class GDBServer::AccessBreakpoint { public: - AccessBreakpoint(MPTR address, AccessPointType type) - : m_address(address), m_type(type) - { -#if defined(ARCH_X86_64) && BOOST_OS_WINDOWS - for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) - { - HANDLE hThread = (HANDLE)hThreadNH; - CONTEXT ctx{}; - ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; - SuspendThread(hThread); - GetThreadContext(hThread, &ctx); - - // use BP 2/3 for gdb stub since cemu's internal debugger uses BP 0/1 already - ctx.Dr2 = (DWORD64)memory_getPointerFromVirtualOffset(address); - ctx.Dr3 = (DWORD64)memory_getPointerFromVirtualOffset(address); - // breakpoint 2 - SetBits(ctx.Dr7, 4, 1, 1); // breakpoint #3 enabled: true - SetBits(ctx.Dr7, 24, 2, 1); // breakpoint #3 condition: 1 (write) - SetBits(ctx.Dr7, 26, 2, 3); // breakpoint #3 length: 3 (4 bytes) - // breakpoint 3 - SetBits(ctx.Dr7, 6, 1, 1); // breakpoint #4 enabled: true - SetBits(ctx.Dr7, 28, 2, 3); // breakpoint #4 condition: 3 (read & write) - SetBits(ctx.Dr7, 30, 2, 3); // breakpoint #4 length: 3 (4 bytes) - - SetThreadContext(hThread, &ctx); - ResumeThread(hThread); - } - // todo: port the following code to all unix platforms, they seem to differ quite a bit -#elif defined(ARCH_X86_64) && BOOST_OS_LINUX && FALSE - for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) - { - pid_t pid = (pid_t)(uintptr_t)hThreadNH; - ptrace(PTRACE_ATTACH, pid, nullptr, nullptr); - waitpid(pid, nullptr, 0); - - DRType dr7 = _GetDR(pid, 7); - // use BP 2/3 for gdb stub since cemu's internal debugger uses BP 0/1 already - DRType dr2 = (uint64)memory_getPointerFromVirtualOffset(address); - DRType dr3 = (uint64)memory_getPointerFromVirtualOffset(address); - // breakpoint 2 - SetBits(dr7, 4, 1, 1); // breakpoint #3 enabled: true - SetBits(dr7, 24, 2, 1); // breakpoint #3 condition: 1 (write) - SetBits(dr7, 26, 2, 3); // breakpoint #3 length: 3 (4 bytes) - // breakpoint 3 - SetBits(dr7, 6, 1, 1); // breakpoint #4 enabled: true - SetBits(dr7, 28, 2, 3); // breakpoint #4 condition: 3 (read & write) - SetBits(dr7, 30, 2, 3); // breakpoint #4 length: 3 (4 bytes) - - _SetDR(pid, 2, dr2); - _SetDR(pid, 3, dr3); - _SetDR(pid, 7, dr7); - ptrace(PTRACE_DETACH, pid, nullptr, nullptr); - } -#else - cemuLog_log(LogType::Force, "Debugger read/write breakpoints are not supported on non-x86 CPUs yet."); -#endif - }; - ~AccessBreakpoint() - { -#if defined(ARCH_X86_64) && BOOST_OS_WINDOWS - for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) - { - HANDLE hThread = (HANDLE)hThreadNH; - CONTEXT ctx{}; - ctx.ContextFlags = CONTEXT_DEBUG_REGISTERS; - SuspendThread(hThread); - GetThreadContext(hThread, &ctx); - - // reset BP 2/3 to zero - ctx.Dr2 = (DWORD64)0; - ctx.Dr3 = (DWORD64)0; - // breakpoint 2 - SetBits(ctx.Dr7, 4, 1, 0); - SetBits(ctx.Dr7, 24, 2, 0); - SetBits(ctx.Dr7, 26, 2, 0); - // breakpoint 3 - SetBits(ctx.Dr7, 6, 1, 0); - SetBits(ctx.Dr7, 28, 2, 0); - SetBits(ctx.Dr7, 30, 2, 0); - SetThreadContext(hThread, &ctx); - ResumeThread(hThread); - } -#elif defined(ARCH_X86_64) && BOOST_OS_LINUX && FALSE - for (auto& hThreadNH : coreinit::OSGetSchedulerThreads()) - { - pid_t pid = (pid_t)(uintptr_t)hThreadNH; - ptrace(PTRACE_ATTACH, pid, nullptr, nullptr); - waitpid(pid, nullptr, 0); - - DRType dr7 = _GetDR(pid, 7); - // reset BP 2/3 to zero - DRType dr2 = 0; - DRType dr3 = 0; - // breakpoint 2 - SetBits(dr7, 4, 1, 0); - SetBits(dr7, 24, 2, 0); - SetBits(dr7, 26, 2, 0); - // breakpoint 3 - SetBits(dr7, 6, 1, 0); - SetBits(dr7, 28, 2, 0); - SetBits(dr7, 30, 2, 0); - - _SetDR(pid, 2, dr2); - _SetDR(pid, 3, dr3); - _SetDR(pid, 7, dr7); - ptrace(PTRACE_DETACH, pid, nullptr, nullptr); - } -#endif - }; + AccessBreakpoint(MPTR address, AccessPointType type); + ~AccessBreakpoint(); MPTR GetAddress() const { @@ -284,4 +103,4 @@ public: private: const MPTR m_address; const AccessPointType m_type; -}; \ No newline at end of file +}; diff --git a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp index c8308594..6cddae01 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp +++ b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp @@ -263,6 +263,14 @@ bool GDBServer::Initialize() return false; } + int nodelayEnabled = TRUE; + if (setsockopt(m_server_socket, IPPROTO_TCP, TCP_NODELAY, (char*)&nodelayEnabled, sizeof(nodelayEnabled)) == SOCKET_ERROR) + { + closesocket(m_server_socket); + m_server_socket = INVALID_SOCKET; + return false; + } + memset(&m_server_addr, 0, sizeof(m_server_addr)); m_server_addr.sin_family = AF_INET; m_server_addr.sin_addr.s_addr = htonl(INADDR_ANY); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index d9b33dca..3701a4d7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -5,6 +5,7 @@ #include "Cafe/OS/libs/coreinit/coreinit_Time.h" #include "Cafe/OS/libs/coreinit/coreinit_Alarm.h" #include "Cafe/OS/libs/snd_core/ax.h" +#include "Cafe/HW/Espresso/Debugger/GDBStub.h" #include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h" #include "Cafe/HW/Espresso/Recompiler/PPCRecompiler.h" @@ -1153,6 +1154,18 @@ namespace coreinit } } +#if BOOST_OS_LINUX + #include + #include + + std::vector g_schedulerThreadIds; + + std::vector& OSGetSchedulerThreadIds() + { + return g_schedulerThreadIds; + } +#endif + void OSSchedulerCoreEmulationThread(void* _assignedCoreIndex) { SetThreadName(fmt::format("OSSchedulerThread[core={}]", (uintptr_t)_assignedCoreIndex).c_str()); @@ -1160,8 +1173,21 @@ namespace coreinit #if defined(ARCH_X86_64) _mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero #endif + +#if BOOST_OS_LINUX + if (g_gdbstub) + { + // need to allow the GDBStub to attach to our thread + prctl(PR_SET_DUMPABLE, (unsigned long)1); + prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); + } + + pid_t tid = gettid(); + g_schedulerThreadIds.emplace_back(tid); +#endif + t_schedulerFiber = Fiber::PrepareCurrentThread(); - + // create scheduler idle fiber and switch to it g_idleLoopFiber[t_assignedCoreIndex] = new Fiber(__OSThreadCoreIdle, nullptr, nullptr); cemu_assert_debug(PPCInterpreter_getCurrentInstance() == nullptr); @@ -1211,6 +1237,9 @@ namespace coreinit threadItr.join(); sSchedulerThreads.clear(); g_schedulerThreadHandles.clear(); +#if BOOST_OS_LINUX + g_schedulerThreadIds.clear(); +#endif // clean up all fibers for (auto& it : g_idleLoopFiber) { diff --git a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp index 34430e37..cf547110 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp @@ -6,6 +6,9 @@ #include "util/helpers/StringHelpers.h" #include "ExceptionHandler.h" +#include "Cafe/HW/Espresso/Debugger/GDBStub.h" +#include "Cafe/HW/Espresso/Debugger/GDBBreakpoints.h" + #if BOOST_OS_LINUX #include "ELFSymbolTable.h" #endif @@ -61,6 +64,16 @@ void DemangleAndPrintBacktrace(char** backtrace, size_t size) // handle signals that would dump core, print stacktrace and then dump depending on config void handlerDumpingSignal(int sig, siginfo_t *info, void *context) { +#if defined(ARCH_X86_64) && BOOST_OS_LINUX + // Check for hardware breakpoints + if (info->si_signo == SIGTRAP && info->si_code == TRAP_HWBKPT) + { + uint64 dr6 = _ReadDR6(); + g_gdbstub->HandleAccessException(dr6); + return; + } +#endif + if(!CrashLog_Create()) return; // give up if crashlog was already created From 223833cac4512c41a9d53ef630c1bd7b1bb1960c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:37:10 +0100 Subject: [PATCH 070/314] Update libraries --- dependencies/vcpkg | 2 +- .../vcpkg_overlay_ports/sdl2/deps.patch | 13 -- .../vcpkg_overlay_ports/sdl2/portfile.cmake | 130 ------------------ dependencies/vcpkg_overlay_ports/sdl2/usage | 8 -- .../vcpkg_overlay_ports/sdl2/vcpkg.json | 58 -------- .../vcpkg_overlay_ports_linux/sdl2/deps.patch | 13 -- .../sdl2/portfile.cmake | 130 ------------------ .../vcpkg_overlay_ports_linux/sdl2/usage | 8 -- .../vcpkg_overlay_ports_linux/sdl2/vcpkg.json | 58 -------- src/Cafe/CMakeLists.txt | 6 +- vcpkg.json | 2 +- 11 files changed, 5 insertions(+), 423 deletions(-) delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/deps.patch delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/usage delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/usage delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json diff --git a/dependencies/vcpkg b/dependencies/vcpkg index b81bc3a8..53bef899 160000 --- a/dependencies/vcpkg +++ b/dependencies/vcpkg @@ -1 +1 @@ -Subproject commit b81bc3a83fdbdffe80325eeabb2ec735a1f3c29d +Subproject commit 53bef8994c541b6561884a8395ea35715ece75db diff --git a/dependencies/vcpkg_overlay_ports/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports/sdl2/deps.patch deleted file mode 100644 index a8637d8c..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/deps.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake -index 65a98efbe..2f99f28f1 100644 ---- a/cmake/sdlchecks.cmake -+++ b/cmake/sdlchecks.cmake -@@ -352,7 +352,7 @@ endmacro() - # - HAVE_SDL_LOADSO opt - macro(CheckLibSampleRate) - if(SDL_LIBSAMPLERATE) -- find_package(SampleRate QUIET) -+ find_package(SampleRate CONFIG REQUIRED) - if(SampleRate_FOUND AND TARGET SampleRate::samplerate) - set(HAVE_LIBSAMPLERATE TRUE) - set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake deleted file mode 100644 index 39a724c5..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake +++ /dev/null @@ -1,130 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libsdl-org/SDL - REF "release-${VERSION}" - SHA512 90858ae8c5fdddd5e13724e05ad0970e11bbab1df8a0201c3f4ce354dc6018e5d4ab7279402a263c716aacdaa52745f78531dc225d48d790ee9307e2f6198695 - HEAD_REF main - PATCHES - deps.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - vulkan SDL_VULKAN - x11 SDL_X11 - wayland SDL_WAYLAND - samplerate SDL_LIBSAMPLERATE - ibus SDL_IBUS -) - -if ("x11" IN_LIST FEATURES) - message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") -endif() -if ("wayland" IN_LIST FEATURES) - message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") -endif() -if ("ibus" IN_LIST FEATURES) - message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} - OPTIONS ${FEATURE_OPTIONS} - -DSDL_STATIC=${SDL_STATIC} - -DSDL_SHARED=${SDL_SHARED} - -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} - -DSDL_LIBC=ON - -DSDL_TEST=OFF - -DSDL_INSTALL_CMAKEDIR="cmake" - -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON - -DSDL_LIBSAMPLERATE_SHARED=OFF - MAYBE_UNUSED_VARIABLES - SDL_FORCE_STATIC_VCRT -) - -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH cmake) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/share/licenses" - "${CURRENT_PACKAGES_DIR}/share/aclocal" -) - -file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT BINS) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") - endif() - - file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") - foreach(SHARE_FILE ${SHARE_FILES}) - vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") - endforeach() -endif() - -vcpkg_copy_pdbs() - -set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") -set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) -string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") -string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") - endif() -endif() - -if(VCPKG_TARGET_IS_UWP) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "d") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() -endif() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports/sdl2/usage b/dependencies/vcpkg_overlay_ports/sdl2/usage deleted file mode 100644 index 1cddcd46..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/usage +++ /dev/null @@ -1,8 +0,0 @@ -sdl2 provides CMake targets: - - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(main - PRIVATE - $ - $,SDL2::SDL2,SDL2::SDL2-static> - ) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json deleted file mode 100644 index de2eb9b9..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "sdl2", - "version": "2.26.5", - "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", - "homepage": "https://www.libsdl.org/download-2.0.php", - "license": "Zlib", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "base" - ], - "features": { - "base": { - "description": "Base functionality for SDL", - "dependencies": [ - { - "name": "sdl2", - "default-features": false, - "features": [ - "ibus", - "wayland", - "x11" - ], - "platform": "linux" - } - ] - }, - "ibus": { - "description": "Build with ibus IME support", - "supports": "linux" - }, - "samplerate": { - "description": "Use libsamplerate for audio rate conversion", - "dependencies": [ - "libsamplerate" - ] - }, - "vulkan": { - "description": "Vulkan functionality for SDL" - }, - "wayland": { - "description": "Build with Wayland support", - "supports": "linux" - }, - "x11": { - "description": "Build with X11 support", - "supports": "!windows" - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch deleted file mode 100644 index a8637d8c..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake -index 65a98efbe..2f99f28f1 100644 ---- a/cmake/sdlchecks.cmake -+++ b/cmake/sdlchecks.cmake -@@ -352,7 +352,7 @@ endmacro() - # - HAVE_SDL_LOADSO opt - macro(CheckLibSampleRate) - if(SDL_LIBSAMPLERATE) -- find_package(SampleRate QUIET) -+ find_package(SampleRate CONFIG REQUIRED) - if(SampleRate_FOUND AND TARGET SampleRate::samplerate) - set(HAVE_LIBSAMPLERATE TRUE) - set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake deleted file mode 100644 index 39a724c5..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake +++ /dev/null @@ -1,130 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libsdl-org/SDL - REF "release-${VERSION}" - SHA512 90858ae8c5fdddd5e13724e05ad0970e11bbab1df8a0201c3f4ce354dc6018e5d4ab7279402a263c716aacdaa52745f78531dc225d48d790ee9307e2f6198695 - HEAD_REF main - PATCHES - deps.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - vulkan SDL_VULKAN - x11 SDL_X11 - wayland SDL_WAYLAND - samplerate SDL_LIBSAMPLERATE - ibus SDL_IBUS -) - -if ("x11" IN_LIST FEATURES) - message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") -endif() -if ("wayland" IN_LIST FEATURES) - message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") -endif() -if ("ibus" IN_LIST FEATURES) - message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} - OPTIONS ${FEATURE_OPTIONS} - -DSDL_STATIC=${SDL_STATIC} - -DSDL_SHARED=${SDL_SHARED} - -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} - -DSDL_LIBC=ON - -DSDL_TEST=OFF - -DSDL_INSTALL_CMAKEDIR="cmake" - -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON - -DSDL_LIBSAMPLERATE_SHARED=OFF - MAYBE_UNUSED_VARIABLES - SDL_FORCE_STATIC_VCRT -) - -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH cmake) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/share/licenses" - "${CURRENT_PACKAGES_DIR}/share/aclocal" -) - -file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT BINS) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") - endif() - - file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") - foreach(SHARE_FILE ${SHARE_FILES}) - vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") - endforeach() -endif() - -vcpkg_copy_pdbs() - -set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") -set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) -string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") -string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") - endif() -endif() - -if(VCPKG_TARGET_IS_UWP) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "d") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() -endif() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/usage b/dependencies/vcpkg_overlay_ports_linux/sdl2/usage deleted file mode 100644 index 1cddcd46..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/usage +++ /dev/null @@ -1,8 +0,0 @@ -sdl2 provides CMake targets: - - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(main - PRIVATE - $ - $,SDL2::SDL2,SDL2::SDL2-static> - ) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json deleted file mode 100644 index de2eb9b9..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "sdl2", - "version": "2.26.5", - "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", - "homepage": "https://www.libsdl.org/download-2.0.php", - "license": "Zlib", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "base" - ], - "features": { - "base": { - "description": "Base functionality for SDL", - "dependencies": [ - { - "name": "sdl2", - "default-features": false, - "features": [ - "ibus", - "wayland", - "x11" - ], - "platform": "linux" - } - ] - }, - "ibus": { - "description": "Build with ibus IME support", - "supports": "linux" - }, - "samplerate": { - "description": "Use libsamplerate for audio rate conversion", - "dependencies": [ - "libsamplerate" - ] - }, - "vulkan": { - "description": "Vulkan functionality for SDL" - }, - "wayland": { - "description": "Build with Wayland support", - "supports": "linux" - }, - "x11": { - "description": "Build with X11 support", - "supports": "!windows" - } - } -} diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 9e20bb33..20853789 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -535,9 +535,9 @@ endif() if (ENABLE_NSYSHID_LIBUSB) if (ENABLE_VCPKG) - find_package(libusb CONFIG REQUIRED) - target_include_directories(CemuCafe PRIVATE ${LIBUSB_INCLUDE_DIRS}) - target_link_libraries(CemuCafe PRIVATE ${LIBUSB_LIBRARIES}) + find_package(PkgConfig REQUIRED) + pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) + target_link_libraries(CemuCafe PRIVATE PkgConfig::libusb) else () find_package(libusb MODULE REQUIRED) target_link_libraries(CemuCafe PRIVATE libusb::libusb) diff --git a/vcpkg.json b/vcpkg.json index d14a1a8a..48742b4a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "name": "cemu", "version-string": "1.0", - "builtin-baseline": "b81bc3a83fdbdffe80325eeabb2ec735a1f3c29d", + "builtin-baseline": "53bef8994c541b6561884a8395ea35715ece75db", "dependencies": [ "pugixml", "zlib", From 9b0a1d53dc449fedebd5eb6255a312aa334ffad9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 14 Jan 2024 23:40:29 +0100 Subject: [PATCH 071/314] Latte: Fix syntax error in generated GLSL --- .../LatteDecompilerEmitGLSL.cpp | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index aa7b7162..f3d2c7a8 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -246,6 +246,22 @@ static void _appendPVPS(LatteDecompilerShaderContext* shaderContext, StringBuf* _appendChannel(src, aluUnit); } +std::string _FormatFloatAsGLSLConstant(float f) +{ + char floatAsStr[64]; + size_t floatAsStrLen = fmt::format_to_n(floatAsStr, 64, "{:#}", f).size; + size_t floatAsStrLenOrg = floatAsStrLen; + if(floatAsStrLen > 0 && floatAsStr[floatAsStrLen-1] == '.') + { + floatAsStr[floatAsStrLen] = '0'; + floatAsStrLen++; + } + cemu_assert(floatAsStrLen < 50); // constant suspiciously long? + floatAsStr[floatAsStrLen] = '\0'; + cemu_assert_debug(floatAsStrLen >= 3); // shortest possible form is "0.0" + return floatAsStr; +} + // tracks PV/PS and register backups struct ALUClauseTemporariesState { @@ -926,15 +942,7 @@ void _emitOperandInputCode(LatteDecompilerShaderContext* shaderContext, LatteDec exponent -= 127; if ((constVal & 0xFF) == 0 && exponent >= -10 && exponent <= 10) { - char floatAsStr[32]; - size_t floatAsStrLen = fmt::format_to_n(floatAsStr, 32, "{:#}", *(float*)&constVal).size; - if(floatAsStrLen > 0 && floatAsStr[floatAsStrLen-1] == '.') - { - floatAsStr[floatAsStrLen] = '0'; - floatAsStrLen++; - } - cemu_assert_debug(floatAsStrLen >= 3); // shortest possible form is "0.0" - src->add(std::string_view(floatAsStr, floatAsStrLen)); + src->add(_FormatFloatAsGLSLConstant(*(float*)&constVal)); } else src->addFmt("intBitsToFloat(0x{:08x})", constVal); @@ -2561,13 +2569,11 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt // lod or lod bias parameter if( texOpcode == GPU7_TEX_INST_SAMPLE_L || texOpcode == GPU7_TEX_INST_SAMPLE_LB || texOpcode == GPU7_TEX_INST_SAMPLE_C_L) { + src->add(","); if(texOpcode == GPU7_TEX_INST_SAMPLE_LB) - src->addFmt("{}", (float)texInstruction->textureFetch.lodBias / 16.0f); + src->add(_FormatFloatAsGLSLConstant((float)texInstruction->textureFetch.lodBias / 16.0f)); else - { - src->add(","); _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); - } } else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ ) { From f39a5e757b1d82c509c12ba67e88916cf7341573 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 15 Jan 2024 15:14:42 +0100 Subject: [PATCH 072/314] Add "Open MLC folder" option Also updated Patron supporter list --- src/gui/MainWindow.cpp | 14 ++++++++++---- src/gui/MainWindow.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 92594d00..dc9ff0a8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -75,6 +75,7 @@ enum MAINFRAME_MENU_ID_FILE_LOAD = 20100, MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, + MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, MAINFRAME_MENU_ID_FILE_EXIT, MAINFRAME_MENU_ID_FILE_END_EMULATION, MAINFRAME_MENU_ID_FILE_RECENT_0, @@ -166,7 +167,8 @@ EVT_MOVE(MainWindow::OnMove) // file menu EVT_MENU(MAINFRAME_MENU_ID_FILE_LOAD, MainWindow::OnFileMenu) EVT_MENU(MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MainWindow::OnInstallUpdate) -EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, MainWindow::OnOpenCemuFolder) +EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, MainWindow::OnOpenFolder) +EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, MainWindow::OnOpenFolder) EVT_MENU(MAINFRAME_MENU_ID_FILE_EXIT, MainWindow::OnFileExit) EVT_MENU(MAINFRAME_MENU_ID_FILE_END_EMULATION, MainWindow::OnFileMenu) EVT_MENU_RANGE(MAINFRAME_MENU_ID_FILE_RECENT_0 + 0, MAINFRAME_MENU_ID_FILE_RECENT_LAST, MainWindow::OnFileMenu) @@ -684,9 +686,12 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) } } -void MainWindow::OnOpenCemuFolder(wxCommandEvent& event) +void MainWindow::OnOpenFolder(wxCommandEvent& event) { - wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetUserDataPath())); + if(event.GetId() == MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER) + wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetUserDataPath())); + else if(event.GetId() == MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER) + wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetMlcPath())); } void MainWindow::OnInstallUpdate(wxCommandEvent& event) @@ -2015,7 +2020,7 @@ public: , "Faris Leonhart", "MahvZero", "PlaguedGuardian", "Stuffie", "CaptainLester", "Qtech", "Zaurexus", "Leonidas", "Artifesto" , "Alca259", "SirWestofAsh", "Loli Co.", "The Technical Revolutionary", "MegaYama", "mitori", "Seymordius", "Adrian Josh Cruz", "Manuel Hoenings", "Just A Jabb" , "pgantonio", "CannonXIII", "Lonewolf00708", "AlexsDesign.com", "NoskLo", "MrSirHaku", "xElite_V AKA William H. Johnson", "Zalnor", "Pig", "James \"SE4LS\"", "DairyOrange", "Horoko Lawrence", "bloodmc", "Officer Jenny", "Quasar", "Postposterous", "Jake Jackson", "Kaydax", "CthePredatorG" - , "Hengi", "Pyrochaser"}; + , "Hengi", "Pyrochaser", "luma.x3"}; wxString nameListLeft, nameListRight; for (size_t i = 0; i < patreonSupporterNames.size(); i++) @@ -2107,6 +2112,7 @@ void MainWindow::RecreateMenu() } m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder")); + m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, _("&Open MLC folder")); m_fileMenu->AppendSeparator(); m_exitMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_EXIT, _("&Exit")); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 07189b52..25100b72 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -92,7 +92,7 @@ public: void OnMouseWheel(wxMouseEvent& event); void OnClose(wxCloseEvent& event); void OnFileMenu(wxCommandEvent& event); - void OnOpenCemuFolder(wxCommandEvent& event); + void OnOpenFolder(wxCommandEvent& event); void OnLaunchFromFile(wxLaunchGameEvent& event); void OnInstallUpdate(wxCommandEvent& event); void OnFileExit(wxCommandEvent& event); From f58b260cbd566f1f76506246b3b9cd247b1ca511 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:31:59 +0100 Subject: [PATCH 073/314] Fix macos missing dylib file --- src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de9a6600..b7711018 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,7 +78,7 @@ if (MACOS_BUNDLE) set(MACOSX_BUNDLE_BUNDLE_NAME "Cemu") set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${CMAKE_PROJECT_VERSION}) set(MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}) - set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2023 Cemu Project") + set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2024 Cemu Project") set(MACOSX_BUNDLE_CATEGORY "public.app-category.games") set(MACOSX_MINIMUM_SYSTEM_VERSION "12.0") @@ -100,6 +100,9 @@ if (MACOS_BUNDLE) add_custom_command (TARGET CemuBin POST_BUILD COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") + + add_custom_command (TARGET CemuBin POST_BUILD + COMMAND bash -c "install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() set_target_properties(CemuBin PROPERTIES From 7e778042ee0aa053f6daa6a0c23f7ff0c74b5f6e Mon Sep 17 00:00:00 2001 From: Live session user Date: Mon, 15 Jan 2024 17:46:56 -0800 Subject: [PATCH 074/314] Fix macos missing dylib file --- CMakeLists.txt | 2 + dependencies/vcpkg_overlay_ports_mac/.gitkeep | 0 .../libusb/portfile.cmake | 71 +++++++++++++++++++ .../vcpkg_overlay_ports_mac/libusb/usage | 5 ++ .../vcpkg_overlay_ports_mac/libusb/vcpkg.json | 8 +++ src/CMakeLists.txt | 11 ++- 6 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 dependencies/vcpkg_overlay_ports_mac/.gitkeep create mode 100644 dependencies/vcpkg_overlay_ports_mac/libusb/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_mac/libusb/usage create mode 100644 dependencies/vcpkg_overlay_ports_mac/libusb/vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index c988508c..ec6abedc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,8 @@ endif() if (ENABLE_VCPKG) if(UNIX AND NOT APPLE) set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports_linux") + elseif(APPLE) + set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports_mac") else() set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports") endif() diff --git a/dependencies/vcpkg_overlay_ports_mac/.gitkeep b/dependencies/vcpkg_overlay_ports_mac/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dependencies/vcpkg_overlay_ports_mac/libusb/portfile.cmake b/dependencies/vcpkg_overlay_ports_mac/libusb/portfile.cmake new file mode 100644 index 00000000..7b76bba0 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/libusb/portfile.cmake @@ -0,0 +1,71 @@ +set(VCPKG_LIBRARY_LINKAGE dynamic) + +if(VCPKG_TARGET_IS_LINUX) + message("${PORT} currently requires the following tools and libraries from the system package manager:\n autoreconf\n libudev\n\nThese can be installed on Ubuntu systems via apt-get install autoconf libudev-dev") +endif() + +set(VERSION 1.0.26) +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libusb/libusb + REF fcf0c710ef5911ae37fbbf1b39d48a89f6f14e8a # v1.0.26.11791 2023-03-12 + SHA512 0aa6439f7988487adf2a3bff473fec80b5c722a47f117a60696d2aa25c87cc3f20fb6aaca7c66e49be25db6a35eb0bb5f71ed7b211d1b8ee064c5d7f1b985c73 + HEAD_REF master +) + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(LIBUSB_PROJECT_TYPE dll) + else() + set(LIBUSB_PROJECT_TYPE static) + endif() + + # The README.md file in the archive is a symlink to README + # which causes issues with the windows MSBUILD process + file(REMOVE "${SOURCE_PATH}/README.md") + + vcpkg_msbuild_install( + SOURCE_PATH "${SOURCE_PATH}" + PROJECT_SUBPATH msvc/libusb_${LIBUSB_PROJECT_TYPE}.vcxproj + ) + + file(INSTALL "${SOURCE_PATH}/libusb/libusb.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/libusb-1.0") + set(prefix "") + set(exec_prefix [[${prefix}]]) + set(libdir [[${prefix}/lib]]) + set(includedir [[${prefix}/include]]) + configure_file("${SOURCE_PATH}/libusb-1.0.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libusb-1.0.pc" @ONLY) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libusb-1.0.pc" " -lusb-1.0" " -llibusb-1.0") + if(NOT VCPKG_BUILD_TYPE) + set(includedir [[${prefix}/../include]]) + configure_file("${SOURCE_PATH}/libusb-1.0.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libusb-1.0.pc" @ONLY) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libusb-1.0.pc" " -lusb-1.0" " -llibusb-1.0") + endif() +else() + vcpkg_list(SET MAKE_OPTIONS) + vcpkg_list(SET LIBUSB_LINK_LIBRARIES) + if(VCPKG_TARGET_IS_EMSCRIPTEN) + vcpkg_list(APPEND MAKE_OPTIONS BUILD_TRIPLET --host=wasm32) + endif() + if("udev" IN_LIST FEATURES) + vcpkg_list(APPEND MAKE_OPTIONS "--enable-udev") + vcpkg_list(APPEND LIBUSB_LINK_LIBRARIES udev) + else() + vcpkg_list(APPEND MAKE_OPTIONS "--disable-udev") + endif() + vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + AUTOCONFIG + OPTIONS + ${MAKE_OPTIONS} + "--enable-examples-build=no" + "--enable-tests-build=no" + ) + vcpkg_install_make() +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") diff --git a/dependencies/vcpkg_overlay_ports_mac/libusb/usage b/dependencies/vcpkg_overlay_ports_mac/libusb/usage new file mode 100644 index 00000000..87e6e860 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/libusb/usage @@ -0,0 +1,5 @@ +libusb can be imported via CMake FindPkgConfig module: + find_package(PkgConfig REQUIRED) + pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) + + target_link_libraries(main PRIVATE PkgConfig::libusb) diff --git a/dependencies/vcpkg_overlay_ports_mac/libusb/vcpkg.json b/dependencies/vcpkg_overlay_ports_mac/libusb/vcpkg.json new file mode 100644 index 00000000..efc70f3d --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/libusb/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "libusb", + "version": "1.0.26.11791", + "port-version": 7, + "description": "a cross-platform library to access USB devices", + "homepage": "https://github.com/libusb/libusb", + "license": "LGPL-2.1-or-later" +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7711018..7442e37c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,13 +96,10 @@ if (MACOS_BUNDLE) endforeach(folder) add_custom_command (TARGET CemuBin POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib") - - add_custom_command (TARGET CemuBin POST_BUILD - COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") - - add_custom_command (TARGET CemuBin POST_BUILD - COMMAND bash -c "install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") + COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib" + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" + COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}" + COMMAND bash -c "install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() set_target_properties(CemuBin PROPERTIES From f899ab7c34035bc3746112b6459bd15a4a181dd4 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Wed, 17 Jan 2024 01:09:56 +0000 Subject: [PATCH 075/314] Vulkan: Check for 0 size before wayland resize Fixes "Launching games directly with the --title-id argument doesn't work in Wayland" (#999) --- src/gui/canvas/VulkanCanvas.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/canvas/VulkanCanvas.cpp b/src/gui/canvas/VulkanCanvas.cpp index eb56b3c4..8b0c8506 100644 --- a/src/gui/canvas/VulkanCanvas.cpp +++ b/src/gui/canvas/VulkanCanvas.cpp @@ -66,6 +66,10 @@ void VulkanCanvas::OnPaint(wxPaintEvent& event) void VulkanCanvas::OnResize(wxSizeEvent& event) { + const wxSize size = GetSize(); + if (size.GetWidth() == 0 || size.GetHeight() == 0) + return; + #if BOOST_OS_LINUX && HAS_WAYLAND if(m_subsurface) { @@ -73,9 +77,6 @@ void VulkanCanvas::OnResize(wxSizeEvent& event) m_subsurface->setSize(sRect.GetX(), sRect.GetY(), sRect.GetWidth(), sRect.GetHeight()); } #endif - const wxSize size = GetSize(); - if (size.GetWidth() == 0 || size.GetHeight() == 0) - return; const wxRect refreshRect(size); RefreshRect(refreshRect, false); From e53c63b828e856cb4bf11729cdf90fe12544ac9f Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Wed, 17 Jan 2024 01:18:07 +0000 Subject: [PATCH 076/314] Flatpak: Create shortcuts that launch flatpak --- src/gui/components/wxGameList.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 2c78ea3c..5ceaf71f 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1235,6 +1235,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) { const auto title_id = gameInfo.GetBaseTitleId(); const auto title_name = gameInfo.GetTitleName(); auto exe_path = ActiveSettings::GetExecutablePath(); + const char *flatpak_id = getenv("FLATPAK_ID"); // GetExecutablePath returns the AppImage's temporary mount location, instead of its actual path wxString appimage_path; @@ -1292,22 +1293,31 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) { } } } + + std::string desktop_exec_entry; + if (flatpak_id) + desktop_exec_entry = fmt::format("/usr/bin/flatpak run {0} --title-id {1:016x}", flatpak_id, title_id); + else + desktop_exec_entry = fmt::format("{0:?} --title-id {1:016x}", _pathToUtf8(exe_path), title_id); + // 'Icon' accepts spaces in file name, does not accept quoted file paths // 'Exec' does not accept non-escaped spaces, and can accept quoted file paths - const auto desktop_entry_string = + auto desktop_entry_string = fmt::format("[Desktop Entry]\n" "Name={0}\n" "Comment=Play {0} on Cemu\n" - "Exec={1:?} --title-id {2:016x}\n" - "Icon={3}\n" + "Exec={1}\n" + "Icon={2}\n" "Terminal=false\n" "Type=Application\n" - "Categories=Game;", + "Categories=Game;\n", title_name, - _pathToUtf8(exe_path), - title_id, + desktop_exec_entry, _pathToUtf8(icon_path.value_or(""))); + if (flatpak_id) + desktop_entry_string += fmt::format("X-Flatpak={}\n", flatpak_id); + std::ofstream output_stream(output_path); if (!output_stream.good()) { From 72aacbdcecc064ea7c3b158c433e4803496ac296 Mon Sep 17 00:00:00 2001 From: Mike Lothian Date: Fri, 19 Jan 2024 01:03:57 +0000 Subject: [PATCH 077/314] Vulkan: Don't use glslang internal headers Signed-off-by: Mike Lothian --- src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp | 3 +-- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp index e9936c43..72a1be4c 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp @@ -3,7 +3,6 @@ #include "Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h" #include "Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.h" -#include #include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h" #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" @@ -91,4 +90,4 @@ PipelineInfo::~PipelineInfo() // remove from cache VulkanRenderer::GetInstance()->unregisterGraphicsPipeline(this); -} \ No newline at end of file +} diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 44214606..616f57e2 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -26,7 +26,7 @@ #include "Cafe/HW/Latte/Core/LatteTiming.h" // vsync control -#include +#include #include From 18679af4ec641a4c59753d54751dcab257777eef Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Fri, 19 Jan 2024 14:07:17 +0000 Subject: [PATCH 078/314] Ignore Wii U pro controller --- src/input/api/Wiimote/hidapi/HidapiWiimote.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp index a5701f56..db185675 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp @@ -1,9 +1,11 @@ #include "HidapiWiimote.h" +#include static constexpr uint16 WIIMOTE_VENDOR_ID = 0x057e; static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306; static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330; static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22; +static constexpr auto PRO_CONTROLLER_NAME = L"Nintendo RVL-CNT-01-UC"; HidapiWiimote::HidapiWiimote(hid_device* dev, std::string_view path) : m_handle(dev), m_path(path) { @@ -30,6 +32,8 @@ std::vector HidapiWiimote::get_devices() { for (auto it = device_enumeration; it != nullptr; it = it->next){ if (it->product_id != WIIMOTE_PRODUCT_ID && it->product_id != WIIMOTE_MP_PRODUCT_ID) continue; + if (std::wcscmp(it->product_string, PRO_CONTROLLER_NAME) == 0) + continue; auto dev = hid_open_path(it->path); if (!dev){ cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, boost::nowide::narrow(hid_error(nullptr))); From 4e4ac0de51b82c455aec71060c109f9e5a1888d9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 19 Jan 2024 23:32:24 +0100 Subject: [PATCH 079/314] CI: For the Windows build use as many cores as available --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d23faa31..3c01ba7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -183,7 +183,7 @@ jobs: - name: "Build Cemu" run: | cd build - cmake --build . --config ${{ env.BUILD_MODE }} -j 2 + cmake --build . --config ${{ env.BUILD_MODE }} - name: Prepare artifact if: ${{ inputs.deploymode == 'release' }} From ca01e923bf03573d5023feb0f4464ce015910ea6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 20 Jan 2024 00:33:36 +0100 Subject: [PATCH 080/314] Update issue templates --- .../bug-report-feature-request.md | 34 --------- .github/ISSUE_TEMPLATE/config.yml | 2 +- .../ISSUE_TEMPLATE/emulation_bug_report.yaml | 69 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_report.yaml | 28 ++++++++ 4 files changed, 98 insertions(+), 35 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug-report-feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/emulation_bug_report.yaml create mode 100644 .github/ISSUE_TEMPLATE/feature_report.yaml diff --git a/.github/ISSUE_TEMPLATE/bug-report-feature-request.md b/.github/ISSUE_TEMPLATE/bug-report-feature-request.md deleted file mode 100644 index 61bd5d06..00000000 --- a/.github/ISSUE_TEMPLATE/bug-report-feature-request.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: Bug Report / Feature Request -about: Tech support does not belong here. You should only file an issue here if you think you have experienced an actual bug with Cemu or you are requesting a feature you believe would make Cemu better. -title: '' -labels: '' -assignees: '' - ---- - - diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index d33d87ed..d71e22d0 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,4 +2,4 @@ blank_issues_enabled: false contact_links: - name: Cemu Discord url: https://discord.com/invite/5psYsup - about: If you are experiencing an issue with Cemu, and you need tech support, or if you have a general question, try asking in the official Cemu Discord linked here. Piracy is not allowed. + about: If you need technical support with Cemu or have other questions the best place to ask is on the official Cemu Discord linked here diff --git a/.github/ISSUE_TEMPLATE/emulation_bug_report.yaml b/.github/ISSUE_TEMPLATE/emulation_bug_report.yaml new file mode 100644 index 00000000..75928607 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/emulation_bug_report.yaml @@ -0,0 +1,69 @@ +# Docs - https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +name: Bug Report +description: Report an issue with Cemu emulator +title: "Enter a title for the bug report here" +labels: bug +body: + - type: markdown + id: md_readme + attributes: + value: | + ## Important: Read First + + If you discovered a bug you can report it here. Please make sure of the following first: + - That you are using the latest version of Cemu + - Only report something if you are sure it's a bug and not any technical issue on your end. For troubleshooting help see the [links page](https://github.com/cemu-project/Cemu#links) + - Problems specific to a single game should be reported on the [compatibility wiki](https://wiki.cemu.info/wiki/Main_Page) instead + - Verify that your problem isn't already mentioned on the [issue tracker](https://github.com/cemu-project/Cemu/issues) + + Additionally, be aware that graphic packs can also causes issues. There is a separate issue tracker for graphic pack bugs over at the [graphic pack repository](https://github.com/cemu-project/cemu_graphic_packs) + - type: textarea + id: current_behavior + attributes: + label: Current Behavior + description: "What the bug is, in a brief description" + validations: + required: true + - type: textarea + id: expected_behavior + attributes: + label: Expected Behavior + description: "What did you expect to happen?" + validations: + required: true + + - type: textarea + id: steps_to_reproduce + attributes: + label: Steps to Reproduce + description: "How to reproduce the issue" + validations: + required: true + - type: textarea + id: sys_info + attributes: + label: System Info (Optional) + description: "Your PC specifications. Usually only the operating system and graphics card is important. But feel free to add more info." + placeholder: | + Info + OS: Windows 10 + GPU: NVIDIA GeForce RTX 4090 + value: | + OS: + GPU: + - type: textarea + id: emulation_settings + attributes: + label: Emulation Settings (Optional) + description: | + Any non-default settings. You can leave this empty if you didn't change anything other than input settings. + validations: + required: false + - type: textarea + id: logs_files + attributes: + label: "Logs (Optional)" + description: | + "Attach `log.txt` from your Cemu folder (*File > Open Cemu folder*)". + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_report.yaml b/.github/ISSUE_TEMPLATE/feature_report.yaml new file mode 100644 index 00000000..a5d8705c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_report.yaml @@ -0,0 +1,28 @@ +# Docs - https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema +name: Feature suggestion +description: Suggest a new feature +title: "Enter a title for the suggestion here" +labels: feature request +body: + - type: markdown + id: md_readme + attributes: + value: | + ## Important: Read First + + While we appreciate suggestions, it is important to note that we are a very small team and there are already many more ideas than we could ever implement in the near future. Therefore, please only suggest something if you believe it is a great addition and the idea is reasonably unique. + + *Avoid* to create suggestions for: + - Overly obvious features ("Game xyz does not work and should be fixed", "Wiimote support should be improved", "You should add an Android port", "Copy feature xyz from another emulator", "A button to pause/stop emulation") + - Niche features which are only interesting to a tiny percentage of users + - Large scale features ("Add a Metal backend for MacOS", "Add ARM support", "Add savestates") + + Note that this doesn't mean we aren't interested in these ideas, but rather we likely have them planned anyway and it's mostly up to finding the time to implement them. + If you believe your idea is worthwhile even if it doesn't meet all the criteria above, you can still try suggesting it but we might close it. + - type: textarea + id: idea_suggestion + attributes: + label: Your suggestion + description: "Describe what your suggestion is in as much detail as possible" + validations: + required: true From 81acd80a97faa3905d27ad170f16244e17581d2d Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Sun, 18 Feb 2024 15:51:00 +1100 Subject: [PATCH 081/314] Cubeb: Add a default device to the selection (#1017) --- src/audio/CubebAPI.cpp | 13 +++++++++---- src/audio/CubebInputAPI.cpp | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/audio/CubebAPI.cpp b/src/audio/CubebAPI.cpp index 09e45011..2b4aec41 100644 --- a/src/audio/CubebAPI.cpp +++ b/src/audio/CubebAPI.cpp @@ -188,15 +188,20 @@ std::vector CubebAPI::GetDevices() return {}; std::vector result; - result.reserve(devices.count); + result.reserve(devices.count + 1); // Reserve space for the default device + + // Add the default device to the list + auto defaultDevice = std::make_shared(nullptr, "default", L"Default Device"); + result.emplace_back(defaultDevice); + for (size_t i = 0; i < devices.count; ++i) { - //const auto& device = devices.device[i]; + // const auto& device = devices.device[i]; if (devices.device[i].state == CUBEB_DEVICE_STATE_ENABLED) { auto device = std::make_shared(devices.device[i].devid, devices.device[i].device_id, - boost::nowide::widen( - devices.device[i].friendly_name)); + boost::nowide::widen( + devices.device[i].friendly_name)); result.emplace_back(device); } } diff --git a/src/audio/CubebInputAPI.cpp b/src/audio/CubebInputAPI.cpp index de030fdc..c0fa73f4 100644 --- a/src/audio/CubebInputAPI.cpp +++ b/src/audio/CubebInputAPI.cpp @@ -180,15 +180,20 @@ std::vector CubebInputAPI::GetDevices() return {}; std::vector result; - result.reserve(devices.count); + result.reserve(devices.count + 1); // Reserve space for the default device + + // Add the default device to the list + auto defaultDevice = std::make_shared(nullptr, "default", L"Default Device"); + result.emplace_back(defaultDevice); + for (size_t i = 0; i < devices.count; ++i) { - //const auto& device = devices.device[i]; + // const auto& device = devices.device[i]; if (devices.device[i].state == CUBEB_DEVICE_STATE_ENABLED) { auto device = std::make_shared(devices.device[i].devid, devices.device[i].device_id, - boost::nowide::widen( - devices.device[i].friendly_name)); + boost::nowide::widen( + devices.device[i].friendly_name)); result.emplace_back(device); } } From 6a08d04af9c22d2b6ec432b9ac48a299abcfb9f8 Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Sun, 18 Feb 2024 15:52:11 +1100 Subject: [PATCH 082/314] UI: Make Alt+F4/Ctrl+Q more reliable (#1035) --- src/gui/MainWindow.cpp | 14 ++++++++++++++ src/gui/MainWindow.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index dc9ff0a8..d271ca3a 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1485,6 +1485,19 @@ void MainWindow::OnKeyUp(wxKeyEvent& event) g_window_info.has_screenshot_request = true; // async screenshot request } +void MainWindow::OnKeyDown(wxKeyEvent& event) +{ + if ((event.AltDown() && event.GetKeyCode() == WXK_F4) || + (event.CmdDown() && event.GetKeyCode() == 'Q')) + { + Close(true); + } + else + { + event.Skip(); + } +} + void MainWindow::OnChar(wxKeyEvent& event) { if (swkbd_hasKeyboardInputHook()) @@ -1590,6 +1603,7 @@ void MainWindow::CreateCanvas() // key events m_render_canvas->Bind(wxEVT_KEY_UP, &MainWindow::OnKeyUp, this); + m_render_canvas->Bind(wxEVT_KEY_DOWN, &MainWindow::OnKeyDown, this); m_render_canvas->Bind(wxEVT_CHAR, &MainWindow::OnChar, this); m_render_canvas->SetDropTarget(new wxAmiiboDropTarget(this)); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 25100b72..88d2a1d3 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -124,6 +124,7 @@ public: void OnSetWindowTitle(wxCommandEvent& event); void OnKeyUp(wxKeyEvent& event); + void OnKeyDown(wxKeyEvent& event); void OnChar(wxKeyEvent& event); void OnToolsInput(wxCommandEvent& event); From 9bbb7c8b97ff6e5a080984c818b1e66b0f2ce609 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:54:41 -0800 Subject: [PATCH 083/314] Add support for portable directory without build flag (#1071) --- .github/workflows/build.yml | 3 +- CMakeLists.txt | 5 ---- src/gui/CemuApp.cpp | 59 ++++++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c01ba7a..00aac0fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -75,7 +75,7 @@ jobs: - name: "cmake" run: | - cmake -S . -B build ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DPORTABLE=OFF -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja + cmake -S . -B build ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja - name: "Build Cemu" run: | @@ -258,7 +258,6 @@ jobs: cd build cmake .. ${{ env.BUILD_FLAGS }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ - -DPORTABLE=OFF \ -DMACOS_BUNDLE=ON \ -DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \ -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++ \ diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6abedc..6b5f3881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.21.1) option(ENABLE_VCPKG "Enable the vcpkg package manager" ON) -option(PORTABLE "All data created and maintained by Cemu will be in the directory where the executable file is located" ON) option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF) set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version @@ -45,10 +44,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_definitions($<$:CEMU_DEBUG_ASSERT>) # if build type is debug, set CEMU_DEBUG_ASSERT -if(PORTABLE) - add_compile_definitions(PORTABLE) -endif() - set_property(GLOBAL PROPERTY USE_FOLDERS ON) # enable link time optimization for release builds diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 4acc1cf5..fde4bcc0 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -59,33 +59,44 @@ bool CemuApp::OnInit() fs::path user_data_path, config_path, cache_path, data_path; auto standardPaths = wxStandardPaths::Get(); fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); -#ifdef PORTABLE -#if MACOS_BUNDLE - exePath = exePath.parent_path().parent_path().parent_path(); + + // Try a portable path first, if it exists. + user_data_path = config_path = cache_path = data_path = exePath.parent_path() / "portable"; +#if BOOST_OS_MACOS + // If run from an app bundle, use its parent directory. + fs::path appPath = exePath.parent_path().parent_path().parent_path(); + if (appPath.extension() == ".app") + user_data_path = config_path = cache_path = data_path = appPath.parent_path() / "portable"; #endif - user_data_path = config_path = cache_path = data_path = exePath.parent_path(); -#else - SetAppName("Cemu"); - wxString appName=GetAppName(); - #if BOOST_OS_LINUX - standardPaths.SetFileLayout(wxStandardPaths::FileLayout::FileLayout_XDG); - auto getEnvDir = [&](const wxString& varName, const wxString& defaultValue) + + if (!fs::exists(user_data_path)) { - wxString dir; - if (!wxGetEnv(varName, &dir) || dir.empty()) - return defaultValue; - return dir; - }; - wxString homeDir=wxFileName::GetHomeDir(); - user_data_path = (getEnvDir(wxS("XDG_DATA_HOME"), homeDir + wxS("/.local/share")) + "/" + appName).ToStdString(); - config_path = (getEnvDir(wxS("XDG_CONFIG_HOME"), homeDir + wxS("/.config")) + "/" + appName).ToStdString(); - #else - user_data_path = config_path = standardPaths.GetUserDataDir().ToStdString(); - #endif - data_path = standardPaths.GetDataDir().ToStdString(); - cache_path = standardPaths.GetUserDir(wxStandardPaths::Dir::Dir_Cache).ToStdString(); - cache_path /= appName.ToStdString(); +#if BOOST_OS_WINDOWS + user_data_path = config_path = cache_path = data_path = exePath.parent_path(); +#else + SetAppName("Cemu"); + wxString appName=GetAppName(); +#if BOOST_OS_LINUX + standardPaths.SetFileLayout(wxStandardPaths::FileLayout::FileLayout_XDG); + auto getEnvDir = [&](const wxString& varName, const wxString& defaultValue) + { + wxString dir; + if (!wxGetEnv(varName, &dir) || dir.empty()) + return defaultValue; + return dir; + }; + wxString homeDir=wxFileName::GetHomeDir(); + user_data_path = (getEnvDir(wxS("XDG_DATA_HOME"), homeDir + wxS("/.local/share")) + "/" + appName).ToStdString(); + config_path = (getEnvDir(wxS("XDG_CONFIG_HOME"), homeDir + wxS("/.config")) + "/" + appName).ToStdString(); +#else + user_data_path = config_path = standardPaths.GetUserDataDir().ToStdString(); #endif + data_path = standardPaths.GetDataDir().ToStdString(); + cache_path = standardPaths.GetUserDir(wxStandardPaths::Dir::Dir_Cache).ToStdString(); + cache_path /= appName.ToStdString(); +#endif + } + auto failed_write_access = ActiveSettings::LoadOnce(exePath, user_data_path, config_path, cache_path, data_path); for (auto&& path : failed_write_access) wxMessageBox(formatWxString(_("Cemu can't write to {}!"), wxString::FromUTF8(_pathToUtf8(path))), From ed01eaf5f949847d8be16d271abdeafe901e3971 Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Sun, 18 Feb 2024 04:56:36 +0000 Subject: [PATCH 084/314] Gamelist: Add right-click actions for copying title ID, name, and icon (#1089) --- src/gui/components/wxGameList.cpp | 51 +++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 5ceaf71f..88934cd8 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -17,6 +17,8 @@ #include #include #include +#include + #include #include @@ -546,7 +548,12 @@ enum ContextMenuEntries kContextMenuStyleList, kContextMenuStyleIcon, kContextMenuStyleIconSmall, - kContextMenuCreateShortcut + + kContextMenuCreateShortcut, + + kContextMenuCopyTitleName, + kContextMenuCopyTitleId, + kContextMenuCopyTitleImage }; void wxGameList::OnContextMenu(wxContextMenuEvent& event) { @@ -591,6 +598,10 @@ void wxGameList::OnContextMenu(wxContextMenuEvent& event) #if BOOST_OS_LINUX || BOOST_OS_WINDOWS menu.Append(kContextMenuCreateShortcut, _("&Create shortcut")); #endif + menu.AppendSeparator(); + menu.Append(kContextMenuCopyTitleName, _("&Copy Title Name")); + menu.Append(kContextMenuCopyTitleId, _("&Copy Title ID")); + menu.Append(kContextMenuCopyTitleImage, _("&Copy Title Image")); menu.AppendSeparator(); } } @@ -711,10 +722,44 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event) break; } case kContextMenuCreateShortcut: + { #if BOOST_OS_LINUX || BOOST_OS_WINDOWS - CreateShortcut(gameInfo); + CreateShortcut(gameInfo); #endif break; + } + case kContextMenuCopyTitleName: + { + if (wxTheClipboard->Open()) + { + wxTheClipboard->SetData(new wxTextDataObject(gameInfo.GetTitleName())); + wxTheClipboard->Close(); + } + break; + } + case kContextMenuCopyTitleId: + { + if (wxTheClipboard->Open()) + { + wxTheClipboard->SetData(new wxTextDataObject(fmt::format("{:016x}", gameInfo.GetBaseTitleId()))); + wxTheClipboard->Close(); + } + break; + } + case kContextMenuCopyTitleImage: + { + if (wxTheClipboard->Open()) + { + int icon_large; + int icon_small; + if (!QueryIconForTitle(title_id, icon_large, icon_small)) + break; + auto icon = m_image_list->GetBitmap(icon_large); + wxTheClipboard->SetData(new wxBitmapDataObject(icon)); + wxTheClipboard->Close(); + } + break; + } } } } @@ -1042,7 +1087,7 @@ void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event) const auto region_text = fmt::format("{}", gameInfo.GetRegion()); SetItem(index, ColumnRegion, wxGetTranslation(region_text)); - SetItem(index, ColumnTitleID, fmt::format("{:016x}", titleId)); + SetItem(index, ColumnTitleID, fmt::format("{:016x}", baseTitleId)); } else if (m_style == Style::kIcons) { From 8d7fc98275f3eae1f2e105df678956b7540e65eb Mon Sep 17 00:00:00 2001 From: rawdatafeel <108900299+rawdatafeel@users.noreply.github.com> Date: Sat, 17 Feb 2024 23:59:00 -0500 Subject: [PATCH 085/314] Improve BUILD.md (#1093) --- BUILD.md | 153 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 114 insertions(+), 39 deletions(-) diff --git a/BUILD.md b/BUILD.md index e4993ca1..034000ac 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,4 +1,26 @@ -# Build instructions +# Build Instructions + +## Table of Contents + +- [Windows](#windows) +- [Linux](#linux) + - [Dependencies](#dependencies) + - [For Arch and derivatives:](#for-arch-and-derivatives) + - [For Fedora and derivatives:](#for-fedora-and-derivatives) + - [For Ubuntu and derivatives](#for-ubuntu-and-derivatives) + - [Build Cemu](#build-cemu) + - [CMake and Clang](#cmake-and-clang) + - [GCC](#gcc) + - [Debug Build](#debug-build) + - [Troubleshooting Steps](#troubleshooting-steps) + - [Compiling Errors](#compiling-errors) + - [Building Errors](#building-errors) +- [macOS](#macos) + - [On Apple Silicon Macs, Rosetta 2 and the x86_64 version of Homebrew must be used](#on-apple-silicon-macs-rosetta-2-and-the-x86_64-version-of-homebrew-must-be-used) + - [Installing brew](#installing-brew) + - [Installing Dependencies](#installing-dependencies) + - [Build Cemu using CMake and Clang](#build-cemu-using-cmake-and-clang) + - [Updating Cemu and source code](#updating-cemu-and-source-code) ## Windows @@ -19,17 +41,9 @@ Any other IDE should also work as long as it has CMake and MSVC support. CLion a ## Linux -To compile Cemu, a recent enough compiler and STL with C++20 support is required! clang-15 or higher is what we recommend. +To compile Cemu, a recent enough compiler and STL with C++20 support is required! Clang-15 or higher is what we recommend. -### Installing dependencies - -#### For Ubuntu and derivatives: -`sudo apt install -y cmake curl clang-15 freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build` - -You may also need to install `libusb-1.0-0-dev` as a workaround for an issue with the vcpkg hidapi package. - -At step 3 while building, use: - `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` +### Dependencies #### For Arch and derivatives: `sudo pacman -S --needed base-devel clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` @@ -37,39 +51,99 @@ At step 3 while building, use: #### For Fedora and derivatives: `sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel nasm ninja-build perl-core systemd-devel zlib-devel` -### Build Cemu using cmake and clang -1. `git clone --recursive https://github.com/cemu-project/Cemu` -2. `cd Cemu` -3. `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G Ninja` -4. `cmake --build build` -5. You should now have a Cemu executable file in the /bin folder, which you can run using `./bin/Cemu_release`. +#### For Ubuntu and derivatives: +`sudo apt install -y cmake curl clang-15 freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libtool nasm ninja-build` -#### Using GCC -While we build and test Cemu using clang, using GCC might work better with your distro (they should be fairly similar performance/issues wise and should only be considered if compilation is the issue). +You may also need to install `libusb-1.0-0-dev` as a workaround for an issue with the vcpkg hidapi package. -You can use GCC by doing the following: -- make sure you have g++ installed in your system - - installation for Ubuntu and derivatives: `sudo apt install g++` - - installation for Fedora and derivatives: `sudo dnf install gcc-c++` -- replace the step 3 with the following: -`cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -G Ninja` +At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clang), use the following command instead: + `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` -#### Troubleshooting steps - - If step 3 gives you an error about not being able to find ninja, try appending `-DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` to the command and running it again. - - If step 3 fails while compiling the boost-build dependency, it means you don't have a working/good standard library installation. Check the integrity of your system headers and making sure that C++ related packages are installed and intact. - - If step 3 gives a random error, read the `[package-name-and-platform]-out.log` and `[package-name-and-platform]-err.log` for the actual reason to see if you might be lacking the headers from a dependency. - - If step 3 is still failing or if you're not able to find the cause, please make an issue on our Github about it! - - If step 3 fails during rebuild after `git pull` with an error that mentions RPATH, add this to the end of step 3: `-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON` - - If step 4 gives you an error that contains something like `main.cpp.o: in function 'std::__cxx11::basic_string...`, you likely are experiencing a clang-14 issue. This can only be fixed by either lowering the clang version or using GCC, see below. - - If step 4 gives you a different error, you could report it to this repo or try using GCC. Just make sure your standard library and compilers are updated since Cemu uses a lot of modern features! - - If step 4 gives you undefined libdecor_xx, you are likely experiencing an issue with sdl2 package that comes with vcpkg. Delete sdl2 from vcpkg.json in source file and recompile. - - If step 4 gives you `fatal error: 'span' file not found`, then you're either missing `libstdc++` or are using a version that's too old. Install at least v10 with your package manager, eg `sudo apt install libstdc++-10-dev`. See #644. +### Build Cemu + +#### CMake and Clang + +``` +git clone --recursive https://github.com/cemu-project/Cemu +cd Cemu +cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G Ninja +cmake --build build +``` + +#### GCC + +If you are building using GCC, make sure you have g++ installed: +- Installation for Arch and derivatives: `sudo pacman -S gcc` +- Installation for Fedora and derivatives: `sudo dnf install gcc-c++` +- Installation for Ubuntu and derivatives: `sudo apt install g++` + +``` +git clone --recursive https://github.com/cemu-project/Cemu +cd Cemu +cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -G Ninja +cmake --build build +``` + +#### Debug Build + +``` +git clone --recursive https://github.com/cemu-project/Cemu +cd Cemu +cmake -S . -B build -DCMAKE_BUILD_TYPE=debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G Ninja +cmake --build build +``` + +If you are using GCC, replace `cmake -S . -B build -DCMAKE_BUILD_TYPE=debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G Ninja` with `cmake -S . -B build -DCMAKE_BUILD_TYPE=debug -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -G Ninja` + +#### Troubleshooting Steps + +##### Compiling Errors + +This section refers to running `cmake -S...` (truncated). + +* `vcpkg install failed` + * Run the following in the root directory and try running the command again (don't forget to change directories afterwards): + * `cd dependencies/vcpkg && git fetch --unshallow` +* `Please ensure you're using the latest port files with git pull and vcpkg update.` + * Either: + * Update vcpkg by running by the following command: + * `git submodule update --remote dependencies/vcpkg` + * If you are sure vcpkg is up to date, check the following logs: + * `Cemu/dependencies/vcpkg/buildtrees/wxwidgets/config-x64-linux-out.log` + * `Cemu/dependencies/vcpkg/buildtrees/libsystemd/config-x64-linux-dbg-meson-log.txt.log` + * `Cemu/dependencies/vcpkg/buildtrees/libsystemd/config-x64-linux-dbg-out.log` +* Not able to find Ninja. + * Add the following and try running the command again: + * `-DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` +* Compiling failed during the boost-build dependency. + * It means you don't have a working/good standard library installation. Check the integrity of your system headers and making sure that C++ related packages are installed and intact. +* Compiling failed during rebuild after `git pull` with an error that mentions RPATH + * Add the following and try running the command again: + * `-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON` +* If you are getting a random error, read the [package-name-and-platform]-out.log and [package-name-and-platform]-err.log for the actual reason to see if you might be lacking the headers from a dependency. + + +If you are getting a different error than any of the errors listed above, you may either open an issue in this repo or try using [GCC](#gcc). Make sure your standard library and compilers are updated since Cemu uses a lot of modern features! + + +##### Building Errors + +This section refers to running `cmake --build build`. + +* `main.cpp.o: in function 'std::__cxx11::basic_string...` + * You likely are experiencing a clang-14 issue. This can only be fixed by either lowering the clang version or using GCC, see [GCC](#gcc). +* `fatal error: 'span' file not found` + * You're either missing `libstdc++` or are using a version that's too old. Install at least v10 with your package manager, eg `sudo apt install libstdc++-10-dev`. See [#644](https://github.com/cemu-project/Cemu/issues/644). +* `undefined libdecor_xx` + * You are likely experiencing an issue with sdl2 package that comes with vcpkg. Delete sdl2 from vcpkg.json in source file and recompile. + +If you are getting a different error than any of the errors listed above, you may either open an issue in this repo or try using [GCC](#gcc). Make sure your standard library and compilers are updated since Cemu uses a lot of modern features! ## macOS -To compile Cemu, a recent enough compiler and STL with C++20 support is required! LLVM 13 and +To compile Cemu, a recent enough compiler and STL with C++20 support is required! LLVM 13 and below, built in LLVM, and Xcode LLVM don't support the C++20 feature set required. The OpenGL graphics -API isn't support on macOS, Vulkan must be used. Additionally Vulkan must be used through the +API isn't support on macOS, Vulkan must be used. Additionally Vulkan must be used through the Molten-VK compatibility layer ### On Apple Silicon Macs, Rosetta 2 and the x86_64 version of Homebrew must be used @@ -84,11 +158,11 @@ You can skip this section if you have an Intel Mac. Every time you compile, you 1. `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` 2. `eval "$(/usr/local/Homebrew/bin/brew shellenv)"` # set x86_64 brew env -### Installing dependencies +### Installing Dependencies `brew install boost git cmake llvm ninja nasm molten-vk automake libtool` -### Build Cemu using cmake and clang +### Build Cemu using CMake and Clang 1. `git clone --recursive https://github.com/cemu-project/Cemu` 2. `cd Cemu` 3. `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G Ninja` @@ -104,3 +178,4 @@ You can skip this section if you have an Intel Mac. Every time you compile, you 2. Then, you can rebuild Cemu using the steps listed above, according to whether you use Linux or Windows. If CMake complains about Cemu already being compiled or another similar error, try deleting the `CMakeCache.txt` file inside the `build` folder and retry building. + From 3a02490a1f37c7f437b99a2ef459ab886d08d79f Mon Sep 17 00:00:00 2001 From: MoonlightWave-12 <123384363+MoonlightWave-12@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:12:09 +0100 Subject: [PATCH 086/314] BUILD.md: Mention Debian in the build-instructions for Ubuntu (#1096) --- BUILD.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BUILD.md b/BUILD.md index 034000ac..9f3a35be 100644 --- a/BUILD.md +++ b/BUILD.md @@ -6,8 +6,8 @@ - [Linux](#linux) - [Dependencies](#dependencies) - [For Arch and derivatives:](#for-arch-and-derivatives) + - [For Debian, Ubuntu and derivatives](#for-debian-ubuntu-and-derivatives) - [For Fedora and derivatives:](#for-fedora-and-derivatives) - - [For Ubuntu and derivatives](#for-ubuntu-and-derivatives) - [Build Cemu](#build-cemu) - [CMake and Clang](#cmake-and-clang) - [GCC](#gcc) @@ -48,10 +48,7 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required #### For Arch and derivatives: `sudo pacman -S --needed base-devel clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` -#### For Fedora and derivatives: -`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel nasm ninja-build perl-core systemd-devel zlib-devel` - -#### For Ubuntu and derivatives: +#### For Debian, Ubuntu and derivatives: `sudo apt install -y cmake curl clang-15 freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libtool nasm ninja-build` You may also need to install `libusb-1.0-0-dev` as a workaround for an issue with the vcpkg hidapi package. @@ -59,6 +56,9 @@ You may also need to install `libusb-1.0-0-dev` as a workaround for an issue wit At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clang), use the following command instead: `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` +#### For Fedora and derivatives: +`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel nasm ninja-build perl-core systemd-devel zlib-devel` + ### Build Cemu #### CMake and Clang @@ -74,8 +74,8 @@ cmake --build build If you are building using GCC, make sure you have g++ installed: - Installation for Arch and derivatives: `sudo pacman -S gcc` +- Installation for Debian, Ubuntu and derivatives: `sudo apt install g++` - Installation for Fedora and derivatives: `sudo dnf install gcc-c++` -- Installation for Ubuntu and derivatives: `sudo apt install g++` ``` git clone --recursive https://github.com/cemu-project/Cemu From 96bbd3bd259eccb767be3a8a3dd406cdbff4b905 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:03:16 +0100 Subject: [PATCH 087/314] Latte: Avoid assert in texture view check --- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 101 ++++++------------------ 1 file changed, 25 insertions(+), 76 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index d38af8ec..707428af 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -790,81 +790,30 @@ enum VIEWCOMPATIBILITY VIEW_NOT_COMPATIBLE, }; -bool IsDimensionCompatibleForView(Latte::E_DIM baseDim, Latte::E_DIM viewDim) +bool IsDimensionCompatibleForGX2View(Latte::E_DIM baseDim, Latte::E_DIM viewDim) { - bool incompatibleDim = false; - if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D) - ; - else if (baseDim == Latte::E_DIM::DIM_1D && viewDim == Latte::E_DIM::DIM_1D) - ; - else if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D_ARRAY) - ; - else if (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_CUBEMAP) - ; - else if (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_2D_ARRAY) - ; - else if (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_2D_ARRAY) - ; - else if (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_2D) - ; - else if (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_CUBEMAP) - ; - else if (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_2D_ARRAY) - ; - else if (baseDim == Latte::E_DIM::DIM_2D_MSAA && viewDim == Latte::E_DIM::DIM_2D_MSAA) - ; - else if (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_3D) - { - // not compatible on OpenGL - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D_MSAA) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_1D) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_3D) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_2D) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_3D) - { - // incompatible by default, but may be compatible if the view matches the depth of the base texture and starts at mip/slice 0 - incompatibleDim = true; - } - else if ((baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_CUBEMAP) || - (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_2D)) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_2D_MSAA && viewDim == Latte::E_DIM::DIM_2D) - { - // not compatible - incompatibleDim = true; - } - else if (baseDim == Latte::E_DIM::DIM_1D && viewDim == Latte::E_DIM::DIM_2D) - { - // not compatible (probably?) - incompatibleDim = true; - } - else - { - cemu_assert_debug(false); - incompatibleDim = true; - } - return !incompatibleDim; + // Note that some combinations depend on the exact view/slice index and count which we currently ignore (like a 3D view of a 3D texture) + bool isCompatible = + (baseDim == viewDim) || + (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_2D) || + (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D_ARRAY) || + (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_2D) || + (baseDim == Latte::E_DIM::DIM_CUBEMAP && viewDim == Latte::E_DIM::DIM_2D_ARRAY) || + (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_CUBEMAP) || + (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_2D_ARRAY); + if(isCompatible) + return true; + // these combinations have been seen in use by games and are considered incompatible: + // (baseDim == Latte::E_DIM::DIM_2D_ARRAY && viewDim == Latte::E_DIM::DIM_3D) -> Not allowed on OpenGL + // (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_2D_MSAA) + // (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_1D) + // (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_3D) + // (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_2D) + // (baseDim == Latte::E_DIM::DIM_3D && viewDim == Latte::E_DIM::DIM_3D) -> Only compatible if the same depth and shared at mip/slice 0 + // (baseDim == Latte::E_DIM::DIM_2D && viewDim == Latte::E_DIM::DIM_CUBEMAP) + // (baseDim == Latte::E_DIM::DIM_2D_MSAA && viewDim == Latte::E_DIM::DIM_2D) + // (baseDim == Latte::E_DIM::DIM_1D && viewDim == Latte::E_DIM::DIM_2D) + return false; } VIEWCOMPATIBILITY LatteTexture_CanTextureBeRepresentedAsView(LatteTexture* baseTexture, uint32 physAddr, sint32 width, sint32 height, sint32 pitch, Latte::E_DIM dimView, Latte::E_GX2SURFFMT format, bool isDepth, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, sint32& relativeMipIndex, sint32& relativeSliceIndex) @@ -881,7 +830,7 @@ VIEWCOMPATIBILITY LatteTexture_CanTextureBeRepresentedAsView(LatteTexture* baseT return VIEW_NOT_COMPATIBLE; // 3D views are only compatible on Vulkan if they match the base texture in regards to mip and slice count bool isCompatible3DView = dimView == Latte::E_DIM::DIM_3D && baseTexture->dim == dimView && firstSlice == 0 && firstMip == 0 && baseTexture->mipLevels == numMip && baseTexture->depth == numSlice; - if (!isCompatible3DView && !IsDimensionCompatibleForView(baseTexture->dim, dimView)) + if (!isCompatible3DView && !IsDimensionCompatibleForGX2View(baseTexture->dim, dimView)) return VIEW_NOT_COMPATIBLE; if (baseTexture->isDepth && baseTexture->format != format) { @@ -933,7 +882,7 @@ VIEWCOMPATIBILITY LatteTexture_CanTextureBeRepresentedAsView(LatteTexture* baseT if (!LatteTexture_IsTexelSizeCompatibleFormat(baseTexture->format, format) ) return VIEW_NOT_COMPATIBLE; - if (!IsDimensionCompatibleForView(baseTexture->dim, dimView)) + if (!IsDimensionCompatibleForGX2View(baseTexture->dim, dimView)) return VIEW_NOT_COMPATIBLE; if (baseTexture->isDepth && baseTexture->format != format) { From 72ce4838ea79252f9ec0df3f3eeb5959ca6616e6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:07:03 +0100 Subject: [PATCH 088/314] Latte: Optimize uniform register array size for known shaders --- src/Cafe/HW/Latte/Core/LatteShader.cpp | 2 +- .../LatteDecompilerAnalyzer.cpp | 2 +- .../LatteDecompilerEmitGLSLHeader.hpp | 4 ++-- .../LatteDecompilerInternal.h | 18 +++++++++++------- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteShader.cpp b/src/Cafe/HW/Latte/Core/LatteShader.cpp index 503fb664..b59702cd 100644 --- a/src/Cafe/HW/Latte/Core/LatteShader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShader.cpp @@ -652,7 +652,7 @@ LatteDecompilerShader* LatteShader_CreateShaderFromDecompilerOutput(LatteDecompi } else { - shader->uniform.count_uniformRegister = decompilerOutput.uniformOffsetsVK.count_uniformRegister; + shader->uniform.count_uniformRegister = decompilerOutput.uniformOffsetsGL.count_uniformRegister; } // calculate aux hash if (calculateAuxHash) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index 2e837198..cf22f05d 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -787,7 +787,7 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD continue; LatteDecompilerShader::QuickBufferEntry entry; entry.index = i; - entry.size = shaderContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE) * 16; + entry.size = shaderContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(shaderContext->shaderBaseHash, LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE) * 16; shader->list_quickBufferList.push_back(entry); } // get dimension of each used texture diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp index 21cae093..428f8647 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLHeader.hpp @@ -37,7 +37,7 @@ namespace LatteDecompiler } else if (decompilerContext->shader->uniformMode == LATTE_DECOMPILER_UNIFORM_MODE_FULL_CFILE) { - uint32 cfileSize = decompilerContext->analyzer.uniformRegisterAccessTracker.DetermineSize(256); + uint32 cfileSize = decompilerContext->analyzer.uniformRegisterAccessTracker.DetermineSize(decompilerContext->shaderBaseHash, 256); // full or partial uniform register file has to be present if (shaderType == LatteConst::ShaderType::Vertex) shaderSrc->addFmt("uniform ivec4 uf_uniformRegisterVS[{}];" _CRLF, cfileSize); @@ -156,7 +156,7 @@ namespace LatteDecompiler shaderSrc->addFmt("uniform {}{}" _CRLF, _getShaderUniformBlockInterfaceName(decompilerContext->shaderType), i); shaderSrc->add("{" _CRLF); - shaderSrc->addFmt("vec4 {}{}[{}];" _CRLF, _getShaderUniformBlockVariableName(decompilerContext->shaderType), i, decompilerContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE)); + shaderSrc->addFmt("vec4 {}{}[{}];" _CRLF, _getShaderUniformBlockVariableName(decompilerContext->shaderType), i, decompilerContext->analyzer.uniformBufferAccessTracker[i].DetermineSize(decompilerContext->shaderBaseHash, LATTE_GLSL_DYNAMIC_UNIFORM_BLOCK_SIZE)); shaderSrc->add("};" _CRLF _CRLF); shaderSrc->add(_CRLF); } diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h index ac2a1fe1..ed1858ba 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInternal.h @@ -157,19 +157,23 @@ struct LatteDecompilerBufferAccessTracker } } - sint32 DetermineSize(sint32 maximumSize) const + sint32 DetermineSize(uint64 shaderBaseHash, sint32 maximumSize) const { - // here we try to predict the accessed range so we dont have to upload the whole buffer - // potential risky optimization: assume that if there is a fixed-index access on an index higher than any other non-zero relative accesses, it bounds the prior relative access + // here we try to predict the accessed byte range so we dont have to upload the whole buffer + // if no bound can be determined then return maximumSize + // for some known shaders we use hand-tuned values instead of the maximumSize fallback value that those shaders would normally use + if(shaderBaseHash == 0x8ff56afdf1a2f837) // XCX text rendering + return 24; + if(shaderBaseHash == 0x37b9100c1310d3bb) // BotW UI backdrops 1 + return 24; + if(shaderBaseHash == 0xf7ba548c1fefe24a) // BotW UI backdrops 2 + return 30; + sint32 highestAccessIndex = -1; if(hasStaticIndexAccess) - { highestAccessIndex = highestAccessStaticIndex; - } if(hasDynamicIndexAccess) - { return maximumSize; // dynamic index exists and no bound can be determined - } if (highestAccessIndex < 0) return 1; // no access at all? But avoid zero as a size return highestAccessIndex + 1; From a63678c1f40c21151c6daa6f20cbb8fc600ae92a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:10:35 +0100 Subject: [PATCH 089/314] Update SDL2 vcpkg port to 2.30.0 --- .../sdl2/alsa-dep-fix.patch | 13 ++ .../vcpkg_overlay_ports/sdl2/deps.patch | 13 ++ .../vcpkg_overlay_ports/sdl2/portfile.cmake | 137 ++++++++++++++++++ dependencies/vcpkg_overlay_ports/sdl2/usage | 8 + .../vcpkg_overlay_ports/sdl2/vcpkg.json | 68 +++++++++ .../sdl2/alsa-dep-fix.patch | 13 ++ .../vcpkg_overlay_ports_linux/sdl2/deps.patch | 13 ++ .../sdl2/portfile.cmake | 137 ++++++++++++++++++ .../vcpkg_overlay_ports_linux/sdl2/usage | 8 + .../vcpkg_overlay_ports_linux/sdl2/vcpkg.json | 68 +++++++++ .../sdl2/alsa-dep-fix.patch | 13 ++ .../vcpkg_overlay_ports_mac/sdl2/deps.patch | 13 ++ .../sdl2/portfile.cmake | 137 ++++++++++++++++++ .../vcpkg_overlay_ports_mac/sdl2/usage | 8 + .../vcpkg_overlay_ports_mac/sdl2/vcpkg.json | 68 +++++++++ 15 files changed, 717 insertions(+) create mode 100644 dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch create mode 100644 dependencies/vcpkg_overlay_ports/sdl2/deps.patch create mode 100644 dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports/sdl2/usage create mode 100644 dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json create mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/usage create mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json create mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch create mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch create mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/usage create mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json diff --git a/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch new file mode 100644 index 00000000..5b2c77b9 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch @@ -0,0 +1,13 @@ +diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in +index cc8bcf26d..ead829767 100644 +--- a/SDL2Config.cmake.in ++++ b/SDL2Config.cmake.in +@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") + + set(SDL_ALSA @SDL_ALSA@) + set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) +-if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) ++if(SDL_ALSA) + sdlFindALSA() + endif() + unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports/sdl2/deps.patch new file mode 100644 index 00000000..a8637d8c --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/sdl2/deps.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake +index 65a98efbe..2f99f28f1 100644 +--- a/cmake/sdlchecks.cmake ++++ b/cmake/sdlchecks.cmake +@@ -352,7 +352,7 @@ endmacro() + # - HAVE_SDL_LOADSO opt + macro(CheckLibSampleRate) + if(SDL_LIBSAMPLERATE) +- find_package(SampleRate QUIET) ++ find_package(SampleRate CONFIG REQUIRED) + if(SampleRate_FOUND AND TARGET SampleRate::samplerate) + set(HAVE_LIBSAMPLERATE TRUE) + set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake new file mode 100644 index 00000000..22685e6a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake @@ -0,0 +1,137 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libsdl-org/SDL + REF "release-${VERSION}" + SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c + HEAD_REF main + PATCHES + deps.patch + alsa-dep-fix.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + alsa SDL_ALSA + alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA + ibus SDL_IBUS + samplerate SDL_LIBSAMPLERATE + vulkan SDL_VULKAN + wayland SDL_WAYLAND + x11 SDL_X11 + INVERTED_FEATURES + alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA +) + +if ("x11" IN_LIST FEATURES) + message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") +endif() +if ("wayland" IN_LIST FEATURES) + message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") +endif() +if ("ibus" IN_LIST FEATURES) + message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") +endif() + +if(VCPKG_TARGET_IS_UWP) + set(configure_opts WINDOWS_USE_MSBUILD) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + ${configure_opts} + OPTIONS ${FEATURE_OPTIONS} + -DSDL_STATIC=${SDL_STATIC} + -DSDL_SHARED=${SDL_SHARED} + -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} + -DSDL_LIBC=ON + -DSDL_TEST=OFF + -DSDL_INSTALL_CMAKEDIR="cmake" + -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON + -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON + -DSDL_LIBSAMPLERATE_SHARED=OFF + MAYBE_UNUSED_VARIABLES + SDL_FORCE_STATIC_VCRT + PKG_CONFIG_USE_CMAKE_PREFIX_PATH +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH cmake) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/share/licenses" + "${CURRENT_PACKAGES_DIR}/share/aclocal" +) + +file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") +if(NOT BINS) + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/bin" + "${CURRENT_PACKAGES_DIR}/debug/bin" + ) +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") + endif() + + file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") + foreach(SHARE_FILE ${SHARE_FILES}) + vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") + endforeach() +endif() + +vcpkg_copy_pdbs() + +set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") +set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) +string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") +string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") + endif() +endif() + +if(VCPKG_TARGET_IS_UWP) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "d") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports/sdl2/usage b/dependencies/vcpkg_overlay_ports/sdl2/usage new file mode 100644 index 00000000..1cddcd46 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/sdl2/usage @@ -0,0 +1,8 @@ +sdl2 provides CMake targets: + + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(main + PRIVATE + $ + $,SDL2::SDL2,SDL2::SDL2-static> + ) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json new file mode 100644 index 00000000..1f460375 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json @@ -0,0 +1,68 @@ +{ + "name": "sdl2", + "version": "2.30.0", + "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", + "homepage": "https://www.libsdl.org/download-2.0.php", + "license": "Zlib", + "dependencies": [ + { + "name": "dbus", + "default-features": false, + "platform": "linux" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "ibus", + "platform": "linux" + }, + { + "name": "wayland", + "platform": "linux" + }, + { + "name": "x11", + "platform": "linux" + } + ], + "features": { + "alsa": { + "description": "Support for alsa audio", + "dependencies": [ + { + "name": "alsa", + "platform": "linux" + } + ] + }, + "ibus": { + "description": "Build with ibus IME support", + "supports": "linux" + }, + "samplerate": { + "description": "Use libsamplerate for audio rate conversion", + "dependencies": [ + "libsamplerate" + ] + }, + "vulkan": { + "description": "Vulkan functionality for SDL" + }, + "wayland": { + "description": "Build with Wayland support", + "supports": "linux" + }, + "x11": { + "description": "Build with X11 support", + "supports": "!windows" + } + } +} diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch new file mode 100644 index 00000000..5b2c77b9 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch @@ -0,0 +1,13 @@ +diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in +index cc8bcf26d..ead829767 100644 +--- a/SDL2Config.cmake.in ++++ b/SDL2Config.cmake.in +@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") + + set(SDL_ALSA @SDL_ALSA@) + set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) +-if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) ++if(SDL_ALSA) + sdlFindALSA() + endif() + unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch new file mode 100644 index 00000000..a8637d8c --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake +index 65a98efbe..2f99f28f1 100644 +--- a/cmake/sdlchecks.cmake ++++ b/cmake/sdlchecks.cmake +@@ -352,7 +352,7 @@ endmacro() + # - HAVE_SDL_LOADSO opt + macro(CheckLibSampleRate) + if(SDL_LIBSAMPLERATE) +- find_package(SampleRate QUIET) ++ find_package(SampleRate CONFIG REQUIRED) + if(SampleRate_FOUND AND TARGET SampleRate::samplerate) + set(HAVE_LIBSAMPLERATE TRUE) + set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake new file mode 100644 index 00000000..22685e6a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake @@ -0,0 +1,137 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libsdl-org/SDL + REF "release-${VERSION}" + SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c + HEAD_REF main + PATCHES + deps.patch + alsa-dep-fix.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + alsa SDL_ALSA + alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA + ibus SDL_IBUS + samplerate SDL_LIBSAMPLERATE + vulkan SDL_VULKAN + wayland SDL_WAYLAND + x11 SDL_X11 + INVERTED_FEATURES + alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA +) + +if ("x11" IN_LIST FEATURES) + message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") +endif() +if ("wayland" IN_LIST FEATURES) + message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") +endif() +if ("ibus" IN_LIST FEATURES) + message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") +endif() + +if(VCPKG_TARGET_IS_UWP) + set(configure_opts WINDOWS_USE_MSBUILD) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + ${configure_opts} + OPTIONS ${FEATURE_OPTIONS} + -DSDL_STATIC=${SDL_STATIC} + -DSDL_SHARED=${SDL_SHARED} + -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} + -DSDL_LIBC=ON + -DSDL_TEST=OFF + -DSDL_INSTALL_CMAKEDIR="cmake" + -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON + -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON + -DSDL_LIBSAMPLERATE_SHARED=OFF + MAYBE_UNUSED_VARIABLES + SDL_FORCE_STATIC_VCRT + PKG_CONFIG_USE_CMAKE_PREFIX_PATH +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH cmake) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/share/licenses" + "${CURRENT_PACKAGES_DIR}/share/aclocal" +) + +file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") +if(NOT BINS) + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/bin" + "${CURRENT_PACKAGES_DIR}/debug/bin" + ) +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") + endif() + + file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") + foreach(SHARE_FILE ${SHARE_FILES}) + vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") + endforeach() +endif() + +vcpkg_copy_pdbs() + +set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") +set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) +string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") +string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") + endif() +endif() + +if(VCPKG_TARGET_IS_UWP) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "d") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/usage b/dependencies/vcpkg_overlay_ports_linux/sdl2/usage new file mode 100644 index 00000000..1cddcd46 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/sdl2/usage @@ -0,0 +1,8 @@ +sdl2 provides CMake targets: + + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(main + PRIVATE + $ + $,SDL2::SDL2,SDL2::SDL2-static> + ) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json new file mode 100644 index 00000000..1f460375 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json @@ -0,0 +1,68 @@ +{ + "name": "sdl2", + "version": "2.30.0", + "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", + "homepage": "https://www.libsdl.org/download-2.0.php", + "license": "Zlib", + "dependencies": [ + { + "name": "dbus", + "default-features": false, + "platform": "linux" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "ibus", + "platform": "linux" + }, + { + "name": "wayland", + "platform": "linux" + }, + { + "name": "x11", + "platform": "linux" + } + ], + "features": { + "alsa": { + "description": "Support for alsa audio", + "dependencies": [ + { + "name": "alsa", + "platform": "linux" + } + ] + }, + "ibus": { + "description": "Build with ibus IME support", + "supports": "linux" + }, + "samplerate": { + "description": "Use libsamplerate for audio rate conversion", + "dependencies": [ + "libsamplerate" + ] + }, + "vulkan": { + "description": "Vulkan functionality for SDL" + }, + "wayland": { + "description": "Build with Wayland support", + "supports": "linux" + }, + "x11": { + "description": "Build with X11 support", + "supports": "!windows" + } + } +} diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch new file mode 100644 index 00000000..5b2c77b9 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch @@ -0,0 +1,13 @@ +diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in +index cc8bcf26d..ead829767 100644 +--- a/SDL2Config.cmake.in ++++ b/SDL2Config.cmake.in +@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") + + set(SDL_ALSA @SDL_ALSA@) + set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) +-if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) ++if(SDL_ALSA) + sdlFindALSA() + endif() + unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch new file mode 100644 index 00000000..a8637d8c --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake +index 65a98efbe..2f99f28f1 100644 +--- a/cmake/sdlchecks.cmake ++++ b/cmake/sdlchecks.cmake +@@ -352,7 +352,7 @@ endmacro() + # - HAVE_SDL_LOADSO opt + macro(CheckLibSampleRate) + if(SDL_LIBSAMPLERATE) +- find_package(SampleRate QUIET) ++ find_package(SampleRate CONFIG REQUIRED) + if(SampleRate_FOUND AND TARGET SampleRate::samplerate) + set(HAVE_LIBSAMPLERATE TRUE) + set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake new file mode 100644 index 00000000..22685e6a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake @@ -0,0 +1,137 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libsdl-org/SDL + REF "release-${VERSION}" + SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c + HEAD_REF main + PATCHES + deps.patch + alsa-dep-fix.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + alsa SDL_ALSA + alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA + ibus SDL_IBUS + samplerate SDL_LIBSAMPLERATE + vulkan SDL_VULKAN + wayland SDL_WAYLAND + x11 SDL_X11 + INVERTED_FEATURES + alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA +) + +if ("x11" IN_LIST FEATURES) + message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") +endif() +if ("wayland" IN_LIST FEATURES) + message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") +endif() +if ("ibus" IN_LIST FEATURES) + message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") +endif() + +if(VCPKG_TARGET_IS_UWP) + set(configure_opts WINDOWS_USE_MSBUILD) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + ${configure_opts} + OPTIONS ${FEATURE_OPTIONS} + -DSDL_STATIC=${SDL_STATIC} + -DSDL_SHARED=${SDL_SHARED} + -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} + -DSDL_LIBC=ON + -DSDL_TEST=OFF + -DSDL_INSTALL_CMAKEDIR="cmake" + -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON + -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON + -DSDL_LIBSAMPLERATE_SHARED=OFF + MAYBE_UNUSED_VARIABLES + SDL_FORCE_STATIC_VCRT + PKG_CONFIG_USE_CMAKE_PREFIX_PATH +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH cmake) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" + "${CURRENT_PACKAGES_DIR}/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" + "${CURRENT_PACKAGES_DIR}/share/licenses" + "${CURRENT_PACKAGES_DIR}/share/aclocal" +) + +file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") +if(NOT BINS) + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/bin" + "${CURRENT_PACKAGES_DIR}/debug/bin" + ) +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") + endif() + + file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") + foreach(SHARE_FILE ${SHARE_FILES}) + vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") + endforeach() +endif() + +vcpkg_copy_pdbs() + +set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") +set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) +file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) +string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") +string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") + endif() +endif() + +if(VCPKG_TARGET_IS_UWP) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$:d>.lib" "d") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") + endif() +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/usage b/dependencies/vcpkg_overlay_ports_mac/sdl2/usage new file mode 100644 index 00000000..1cddcd46 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/sdl2/usage @@ -0,0 +1,8 @@ +sdl2 provides CMake targets: + + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(main + PRIVATE + $ + $,SDL2::SDL2,SDL2::SDL2-static> + ) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json new file mode 100644 index 00000000..1f460375 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json @@ -0,0 +1,68 @@ +{ + "name": "sdl2", + "version": "2.30.0", + "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", + "homepage": "https://www.libsdl.org/download-2.0.php", + "license": "Zlib", + "dependencies": [ + { + "name": "dbus", + "default-features": false, + "platform": "linux" + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "ibus", + "platform": "linux" + }, + { + "name": "wayland", + "platform": "linux" + }, + { + "name": "x11", + "platform": "linux" + } + ], + "features": { + "alsa": { + "description": "Support for alsa audio", + "dependencies": [ + { + "name": "alsa", + "platform": "linux" + } + ] + }, + "ibus": { + "description": "Build with ibus IME support", + "supports": "linux" + }, + "samplerate": { + "description": "Use libsamplerate for audio rate conversion", + "dependencies": [ + "libsamplerate" + ] + }, + "vulkan": { + "description": "Vulkan functionality for SDL" + }, + "wayland": { + "description": "Build with Wayland support", + "supports": "linux" + }, + "x11": { + "description": "Build with X11 support", + "supports": "!windows" + } + } +} From 8b37e316d0537da9c717cb0698c9141e668d6fff Mon Sep 17 00:00:00 2001 From: Leif Liddy Date: Sat, 24 Feb 2024 20:47:06 +0100 Subject: [PATCH 090/314] BUILD.md: Add llvm package for Fedora (#1101) --- BUILD.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.md b/BUILD.md index 9f3a35be..3ff2254f 100644 --- a/BUILD.md +++ b/BUILD.md @@ -57,7 +57,7 @@ At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clan `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` #### For Fedora and derivatives: -`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel nasm ninja-build perl-core systemd-devel zlib-devel` +`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel` ### Build Cemu @@ -128,7 +128,7 @@ If you are getting a different error than any of the errors listed above, you ma ##### Building Errors -This section refers to running `cmake --build build`. +This section refers to running `cmake --build build`. * `main.cpp.o: in function 'std::__cxx11::basic_string...` * You likely are experiencing a clang-14 issue. This can only be fixed by either lowering the clang version or using GCC, see [GCC](#gcc). From 49c55a3f561eed2da750cbacfcef4fc5ffe1075e Mon Sep 17 00:00:00 2001 From: Simon <113838661+ssievert42@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:37:36 +0100 Subject: [PATCH 091/314] nsyshid: remove stray print statements (#1106) --- src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp | 1 - src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp index 520a0d31..23da5798 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -446,7 +446,6 @@ namespace nsyshid::backend::windows { sprintf(debugOutput + i * 3, "%02x ", data[i]); } - fmt::print("{} Data: {}\n", prefix, debugOutput); cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); } } // namespace nsyshid::backend::windows diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index b21e2a43..ba3e3b96 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -332,7 +332,6 @@ namespace nsyshid { sprintf(debugOutput + i * 3, "%02x ", data[i]); } - fmt::print("{} Data: {}\n", prefix, debugOutput); cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); } From 8f1cd4f9255e16aeddb2e72d35a47f37e1e478bc Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 26 Feb 2024 23:52:33 +0100 Subject: [PATCH 092/314] Vulkan: Update some code to use VK_KHR_synchronization2 --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 30 ++- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 220 +++++++++--------- .../Renderer/Vulkan/VulkanRendererCore.cpp | 35 +-- 3 files changed, 140 insertions(+), 145 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 616f57e2..631f1d0c 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -468,6 +468,15 @@ VulkanRenderer::VulkanRenderer() void* deviceExtensionFeatures = nullptr; + // enable VK_KHR_synchonization_2 + VkPhysicalDeviceSynchronization2FeaturesKHR sync2Feature{}; + { + sync2Feature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR; + sync2Feature.pNext = deviceExtensionFeatures; + deviceExtensionFeatures = &sync2Feature; + sync2Feature.synchronization2 = VK_TRUE; + } + // enable VK_EXT_pipeline_creation_cache_control VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT cacheControlFeature{}; if (m_featureControl.deviceExtensions.pipeline_creation_cache_control) @@ -2852,13 +2861,20 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu ClearColorbuffer(padView); // barrier for input texture - VkMemoryBarrier memoryBarrier{}; - memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; - VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT; - VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - memoryBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; - memoryBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT; - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStage, dstStage, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr); + { + VkMemoryBarrier2 memoryBarrier2{}; + memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; + memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_TRANSFER_BIT_KHR; + memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR; + memoryBarrier2.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT; + memoryBarrier2.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT; + VkDependencyInfo dependencyInfo{}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + dependencyInfo.dependencyFlags = 0; + dependencyInfo.memoryBarrierCount = 1; + dependencyInfo.pMemoryBarriers = &memoryBarrier2; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + } auto pipeline = backbufferBlit_createGraphicsPipeline(m_swapchainDescriptorSetLayout, padView, shader); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index b61a0b40..7565d260 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -728,201 +728,192 @@ private: IMAGE_READ = 0x20, IMAGE_WRITE = 0x40, - }; template - void barrier_calcStageAndMask(VkPipelineStageFlags& stages, VkAccessFlags& accessFlags) + void barrier_calcStageAndMask(VkPipelineStageFlags2& stages, VkAccessFlags2& accessFlags) { stages = 0; accessFlags = 0; if constexpr ((TSyncOp & BUFFER_SHADER_READ) != 0) { - // in theory: VK_ACCESS_INDEX_READ_BIT should be set here too but indices are currently separated - stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT; + // in theory: VK_ACCESS_2_INDEX_READ_BIT should be set here too but indices are currently separated + stages |= VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_2_UNIFORM_READ_BIT | VK_ACCESS_2_SHADER_READ_BIT; } - + if constexpr ((TSyncOp & BUFFER_SHADER_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_SHADER_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_2_SHADER_WRITE_BIT; } if constexpr ((TSyncOp & ANY_TRANSFER) != 0) { - //stages |= VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_HOST_BIT; - //accessFlags |= VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT; - stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; - accessFlags |= VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; - - //accessFlags |= VK_ACCESS_MEMORY_READ_BIT; - //accessFlags |= VK_ACCESS_MEMORY_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; + accessFlags |= VK_ACCESS_2_TRANSFER_READ_BIT | VK_ACCESS_2_TRANSFER_WRITE_BIT; } if constexpr ((TSyncOp & TRANSFER_READ) != 0) { - stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; - accessFlags |= VK_ACCESS_TRANSFER_READ_BIT; - - //accessFlags |= VK_ACCESS_MEMORY_READ_BIT; + stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; + accessFlags |= VK_ACCESS_2_TRANSFER_READ_BIT; } if constexpr ((TSyncOp & TRANSFER_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; - accessFlags |= VK_ACCESS_TRANSFER_WRITE_BIT; - - //accessFlags |= VK_ACCESS_MEMORY_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; + accessFlags |= VK_ACCESS_2_TRANSFER_WRITE_BIT; } if constexpr ((TSyncOp & HOST_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_HOST_BIT; - accessFlags |= VK_ACCESS_HOST_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_HOST_BIT; + accessFlags |= VK_ACCESS_2_HOST_WRITE_BIT; } if constexpr ((TSyncOp & HOST_READ) != 0) { - stages |= VK_PIPELINE_STAGE_HOST_BIT; - accessFlags |= VK_ACCESS_HOST_READ_BIT; + stages |= VK_PIPELINE_STAGE_2_HOST_BIT; + accessFlags |= VK_ACCESS_2_HOST_READ_BIT; } if constexpr ((TSyncOp & IMAGE_READ) != 0) { - stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_SHADER_READ_BIT; + stages |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_2_SHADER_READ_BIT; - stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - accessFlags |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT; + stages |= VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; + accessFlags |= VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT; - stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; - accessFlags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + stages |= VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT; + accessFlags |= VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT; } if constexpr ((TSyncOp & IMAGE_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - accessFlags |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; + accessFlags |= VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; - stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; - accessFlags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT; + accessFlags |= VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; } } template void barrier_bufferRange(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size) { - VkBufferMemoryBarrier bufMemBarrier{}; - bufMemBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + VkBufferMemoryBarrier2 bufMemBarrier{}; + bufMemBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2; bufMemBarrier.pNext = nullptr; bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - VkPipelineStageFlags srcStages = 0; - VkPipelineStageFlags dstStages = 0; - - bufMemBarrier.srcAccessMask = 0; - bufMemBarrier.dstAccessMask = 0; - - barrier_calcStageAndMask(srcStages, bufMemBarrier.srcAccessMask); - barrier_calcStageAndMask(dstStages, bufMemBarrier.dstAccessMask); + barrier_calcStageAndMask(bufMemBarrier.srcStageMask, bufMemBarrier.srcAccessMask); + barrier_calcStageAndMask(bufMemBarrier.dstStageMask, bufMemBarrier.dstAccessMask); bufMemBarrier.buffer = buffer; bufMemBarrier.offset = offset; bufMemBarrier.size = size; - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr); + + VkDependencyInfo depInfo{}; + depInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + depInfo.pNext = nullptr; + depInfo.bufferMemoryBarrierCount = 1; + depInfo.pBufferMemoryBarriers = &bufMemBarrier; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &depInfo); } template void barrier_bufferRange(VkBuffer bufferA, VkDeviceSize offsetA, VkDeviceSize sizeA, VkBuffer bufferB, VkDeviceSize offsetB, VkDeviceSize sizeB) { - VkPipelineStageFlags srcStagesA = 0; - VkPipelineStageFlags dstStagesA = 0; - VkPipelineStageFlags srcStagesB = 0; - VkPipelineStageFlags dstStagesB = 0; + VkBufferMemoryBarrier2 bufMemBarrier2[2] = {}; + bufMemBarrier2[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2_KHR; + bufMemBarrier2[0].pNext = nullptr; + bufMemBarrier2[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier2[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier2[0].buffer = bufferA; + bufMemBarrier2[0].offset = offsetA; + bufMemBarrier2[0].size = sizeA; + barrier_calcStageAndMask(bufMemBarrier2[0].srcStageMask, bufMemBarrier2[0].srcAccessMask); + barrier_calcStageAndMask(bufMemBarrier2[0].dstStageMask, bufMemBarrier2[0].dstAccessMask); - VkBufferMemoryBarrier bufMemBarrier[2]; + bufMemBarrier2[1].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2_KHR; + bufMemBarrier2[1].pNext = nullptr; + bufMemBarrier2[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier2[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier2[1].buffer = bufferB; + bufMemBarrier2[1].offset = offsetB; + bufMemBarrier2[1].size = sizeB; + barrier_calcStageAndMask(bufMemBarrier2[1].srcStageMask, bufMemBarrier2[1].srcAccessMask); + barrier_calcStageAndMask(bufMemBarrier2[1].dstStageMask, bufMemBarrier2[1].dstAccessMask); - bufMemBarrier[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - bufMemBarrier[0].pNext = nullptr; - bufMemBarrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier[0].srcAccessMask = 0; - bufMemBarrier[0].dstAccessMask = 0; - barrier_calcStageAndMask(srcStagesA, bufMemBarrier[0].srcAccessMask); - barrier_calcStageAndMask(dstStagesA, bufMemBarrier[0].dstAccessMask); - bufMemBarrier[0].buffer = bufferA; - bufMemBarrier[0].offset = offsetA; - bufMemBarrier[0].size = sizeA; - - bufMemBarrier[1].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - bufMemBarrier[1].pNext = nullptr; - bufMemBarrier[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier[1].srcAccessMask = 0; - bufMemBarrier[1].dstAccessMask = 0; - barrier_calcStageAndMask(srcStagesB, bufMemBarrier[1].srcAccessMask); - barrier_calcStageAndMask(dstStagesB, bufMemBarrier[1].dstAccessMask); - bufMemBarrier[1].buffer = bufferB; - bufMemBarrier[1].offset = offsetB; - bufMemBarrier[1].size = sizeB; - - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStagesA|srcStagesB, dstStagesA|dstStagesB, 0, 0, nullptr, 2, bufMemBarrier, 0, nullptr); + VkDependencyInfo dependencyInfo = {}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + dependencyInfo.pNext = nullptr; + dependencyInfo.bufferMemoryBarrierCount = 2; + dependencyInfo.pBufferMemoryBarriers = bufMemBarrier2; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); } void barrier_sequentializeTransfer() { - VkMemoryBarrier memBarrier{}; - memBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; - memBarrier.pNext = nullptr; + VkMemoryBarrier2 memoryBarrier2{}; + memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; + memoryBarrier2.pNext = nullptr; + memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT; + memoryBarrier2.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT | VK_ACCESS_2_TRANSFER_WRITE_BIT; + memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT; + memoryBarrier2.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT | VK_ACCESS_2_MEMORY_WRITE_BIT; - VkPipelineStageFlags srcStages = VK_PIPELINE_STAGE_TRANSFER_BIT; - VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; - - memBarrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; - memBarrier.dstAccessMask = 0; - - memBarrier.srcAccessMask |= (VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); - memBarrier.dstAccessMask |= (VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); - - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 1, &memBarrier, 0, nullptr, 0, nullptr); + VkDependencyInfo dependencyInfo{}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + dependencyInfo.pNext = nullptr; + dependencyInfo.memoryBarrierCount = 1; + dependencyInfo.pMemoryBarriers = &memoryBarrier2; + dependencyInfo.bufferMemoryBarrierCount = 0; + dependencyInfo.imageMemoryBarrierCount = 0; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); } void barrier_sequentializeCommand() { - VkPipelineStageFlags srcStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + VkMemoryBarrier2 memoryBarrier = {}; + memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; + memoryBarrier.srcStageMask = VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT_KHR; + memoryBarrier.srcAccessMask = 0; + memoryBarrier.dstStageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT_KHR; + memoryBarrier.dstAccessMask = 0; - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, 0, nullptr); + VkDependencyInfo dependencyInfo = {}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + dependencyInfo.dependencyFlags = 0; + dependencyInfo.memoryBarrierCount = 1; + dependencyInfo.pMemoryBarriers = &memoryBarrier; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); } template void barrier_image(VkImage imageVk, VkImageSubresourceRange& subresourceRange, VkImageLayout oldLayout, VkImageLayout newLayout) { - VkPipelineStageFlags srcStages = 0; - VkPipelineStageFlags dstStages = 0; + VkImageMemoryBarrier2 imageMemBarrier2{}; + imageMemBarrier2.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2; + imageMemBarrier2.oldLayout = oldLayout; + imageMemBarrier2.newLayout = newLayout; + imageMemBarrier2.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + imageMemBarrier2.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + imageMemBarrier2.image = imageVk; + imageMemBarrier2.subresourceRange = subresourceRange; - VkImageMemoryBarrier imageMemBarrier{}; - imageMemBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - imageMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageMemBarrier.srcAccessMask = 0; - imageMemBarrier.dstAccessMask = 0; - barrier_calcStageAndMask(srcStages, imageMemBarrier.srcAccessMask); - barrier_calcStageAndMask(dstStages, imageMemBarrier.dstAccessMask); - imageMemBarrier.image = imageVk; - imageMemBarrier.subresourceRange = subresourceRange; - imageMemBarrier.oldLayout = oldLayout; - imageMemBarrier.newLayout = newLayout; + barrier_calcStageAndMask(imageMemBarrier2.srcStageMask, imageMemBarrier2.srcAccessMask); + barrier_calcStageAndMask(imageMemBarrier2.dstStageMask, imageMemBarrier2.dstAccessMask); - vkCmdPipelineBarrier(m_state.currentCommandBuffer, - srcStages, dstStages, - 0, - 0, NULL, - 0, NULL, - 1, &imageMemBarrier); + VkDependencyInfo dependencyInfo{}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; + dependencyInfo.imageMemoryBarrierCount = 1; + dependencyInfo.pImageMemoryBarriers = &imageMemBarrier2; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); } template @@ -942,7 +933,6 @@ private: vkTexture->SetImageLayout(subresourceRange, newLayout); } - public: bool GetDisableMultithreadedCompilation() const { return m_featureControl.disableMultithreadedCompilation; } bool UseTFViaSSBO() const { return m_featureControl.mode.useTFEmulationViaSSBO; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 320357f1..b6cae7f7 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -1033,29 +1033,18 @@ void VulkanRenderer::sync_inputTexturesChanged() // barrier here if (writeFlushRequired) { - VkMemoryBarrier memoryBarrier{}; - memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; - memoryBarrier.srcAccessMask = 0; - memoryBarrier.dstAccessMask = 0; - - VkPipelineStageFlags srcStage = 0; - VkPipelineStageFlags dstStage = 0; - - // src - srcStage |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - memoryBarrier.srcAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - - srcStage |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; - memoryBarrier.srcAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; - - // dst - dstStage |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - memoryBarrier.dstAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT; - - dstStage |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; - memoryBarrier.dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT; - - vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStage, dstStage, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr); + VkMemoryBarrier2 memoryBarrier2{}; + memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2_KHR; + memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR; + memoryBarrier2.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR; + memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR; + memoryBarrier2.dstAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT_KHR | VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_SHADER_READ_BIT_KHR; + VkDependencyInfo dependencyInfo{}; + dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO_KHR; + dependencyInfo.dependencyFlags = 0; + dependencyInfo.memoryBarrierCount = 1; + dependencyInfo.pMemoryBarriers = &memoryBarrier2; + vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); performanceMonitor.vk.numDrawBarriersPerFrame.increment(); From b8d81283e86f91238a166b25ac46281620a3260b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 27 Feb 2024 00:15:43 +0100 Subject: [PATCH 093/314] Vulkan: Remove unnecessary index buffer for backbuffer drawcall --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 18 +----------------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 7 ------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 631f1d0c..a86d3a1f 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -540,7 +540,6 @@ VulkanRenderer::VulkanRenderer() QueryMemoryInfo(); QueryAvailableFormats(); - CreateBackbufferIndexBuffer(); CreateCommandPool(); CreateCommandBuffers(); CreateDescriptorPool(); @@ -624,7 +623,6 @@ VulkanRenderer::~VulkanRenderer() DeleteNullObjects(); // delete buffers - memoryManager->DeleteBuffer(m_indexBuffer, m_indexBufferMemory); memoryManager->DeleteBuffer(m_uniformVarBuffer, m_uniformVarBufferMemory); memoryManager->DeleteBuffer(m_textureReadbackBuffer, m_textureReadbackBufferMemory); memoryManager->DeleteBuffer(m_xfbRingBuffer, m_xfbRingBufferMemory); @@ -2836,18 +2834,6 @@ void VulkanRenderer::ClearColorImage(LatteTextureVk* vkTexture, uint32 sliceInde vkTexture->SetImageLayout(subresourceRange, outputLayout); } -void VulkanRenderer::CreateBackbufferIndexBuffer() -{ - const VkDeviceSize bufferSize = sizeof(uint16) * 6; - memoryManager->CreateBuffer(bufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, m_indexBuffer, m_indexBufferMemory); - - uint16* data; - vkMapMemory(m_logicalDevice, m_indexBufferMemory, 0, bufferSize, 0, (void**)&data); - const uint16 tmp[] = { 0, 1, 2, 3, 4, 5 }; - std::copy(std::begin(tmp), std::end(tmp), data); - vkUnmapMemory(m_logicalDevice, m_indexBufferMemory); -} - void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutputShader* shader, bool useLinearTexFilter, sint32 imageX, sint32 imageY, sint32 imageWidth, sint32 imageHeight, bool padView, bool clearBackground) { if(!AcquireNextSwapchainImage(!padView)) @@ -2906,11 +2892,9 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu vkCmdBindPipeline(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); m_state.currentPipeline = pipeline; - vkCmdBindIndexBuffer(m_state.currentCommandBuffer, m_indexBuffer, 0, VK_INDEX_TYPE_UINT16); - vkCmdBindDescriptorSets(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &descriptSet, 0, nullptr); - vkCmdDrawIndexed(m_state.currentCommandBuffer, 6, 1, 0, 0, 0); + vkCmdDraw(m_state.currentCommandBuffer, 6, 1, 0, 0); vkCmdEndRenderPass(m_state.currentCommandBuffer); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 7565d260..3e55fc0c 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -548,15 +548,11 @@ private: void sync_RenderPassStoreTextures(CachedFBOVk* fboVk); // command buffer - VkCommandBuffer getCurrentCommandBuffer() const { return m_state.currentCommandBuffer; } // uniform void uniformData_updateUniformVars(uint32 shaderStageIndex, LatteDecompilerShader* shader); - // indices - void CreateBackbufferIndexBuffer(); - // misc void CreatePipelineCache(); VkPipelineShaderStageCreateInfo CreatePipelineShaderStageCreateInfo(VkShaderStageFlagBits stage, VkShaderModule& module, const char* entryName) const; @@ -580,9 +576,6 @@ private: void occlusionQuery_notifyBeginCommandBuffer(); private: - VkBuffer m_indexBuffer = VK_NULL_HANDLE; - VkDeviceMemory m_indexBufferMemory = VK_NULL_HANDLE; - std::vector m_layerNames; VkInstance m_instance = VK_NULL_HANDLE; VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE; From 9f9bc9865f23d3a1f07ce905003b7d5d640aab82 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Mar 2024 03:12:26 +0100 Subject: [PATCH 094/314] Vulkan: Avoid calling vkCmdClearColorImage() on compressed textures This is not allowed according to the spec and can crash drivers. Fixes #1100 --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 58 ++++++++++++------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 1 - 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index a86d3a1f..bb83607f 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1412,8 +1412,7 @@ bool VulkanRenderer::IsSwapchainInfoValid(bool mainWindow) const void VulkanRenderer::CreateNullTexture(NullTexture& nullTex, VkImageType imageType) { - // these are used when the game requests NULL ptr textures or buffers - // texture + // these are used when the game requests NULL ptr textures VkImageCreateInfo imageInfo{}; imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; if (imageType == VK_IMAGE_TYPE_1D) @@ -2818,6 +2817,35 @@ void VulkanRenderer::ClearColorImageRaw(VkImage image, uint32 sliceIndex, uint32 void VulkanRenderer::ClearColorImage(LatteTextureVk* vkTexture, uint32 sliceIndex, uint32 mipIndex, const VkClearColorValue& color, VkImageLayout outputLayout) { + if(vkTexture->isDepth) + { + cemu_assert_suspicious(); + return; + } + if (vkTexture->IsCompressedFormat()) + { + // vkCmdClearColorImage cannot be called on compressed formats + // for now we ignore affected clears but still transition the image to the correct layout + auto imageObj = vkTexture->GetImageObj(); + imageObj->flagForCurrentCommandBuffer(); + VkImageSubresourceLayers subresourceRange{}; + subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + subresourceRange.mipLevel = mipIndex; + subresourceRange.baseArrayLayer = sliceIndex; + subresourceRange.layerCount = 1; + barrier_image(vkTexture, subresourceRange, outputLayout); + if(color.float32[0] == 0.0f && color.float32[1] == 0.0f && color.float32[2] == 0.0f && color.float32[3] == 0.0f) + { + static bool dbgMsgPrinted = false; + if(!dbgMsgPrinted) + { + cemuLog_logDebug(LogType::Force, "Unsupported compressed texture clear to zero"); + dbgMsgPrinted = true; + } + } + return; + } + VkImageSubresourceRange subresourceRange; subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -3154,32 +3182,18 @@ void VulkanRenderer::texture_clearSlice(LatteTexture* hostTexture, sint32 sliceI else { cemu_assert_debug(vkTexture->dim != Latte::E_DIM::DIM_3D); - if (hostTexture->IsCompressedFormat()) - { - auto imageObj = vkTexture->GetImageObj(); - imageObj->flagForCurrentCommandBuffer(); - - cemuLog_logDebug(LogType::Force, "Compressed texture ({}/{} fmt {:04x}) unsupported clear", vkTexture->width, vkTexture->height, (uint32)vkTexture->format); - - VkImageSubresourceLayers subresourceRange{}; - subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - subresourceRange.mipLevel = mipIndex; - subresourceRange.baseArrayLayer = sliceIndex; - subresourceRange.layerCount = 1; - barrier_image(vkTexture, subresourceRange, VK_IMAGE_LAYOUT_GENERAL); - } - else - { - ClearColorImage(vkTexture, sliceIndex, mipIndex, { 0,0,0,0 }, VK_IMAGE_LAYOUT_GENERAL); - } + ClearColorImage(vkTexture, sliceIndex, mipIndex, { 0,0,0,0 }, VK_IMAGE_LAYOUT_GENERAL); } } void VulkanRenderer::texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) { auto vkTexture = (LatteTextureVk*)hostTexture; - cemu_assert_debug(vkTexture->dim != Latte::E_DIM::DIM_3D); - ClearColorImage(vkTexture, sliceIndex, mipIndex, { r,g,b,a }, VK_IMAGE_LAYOUT_GENERAL); + if(vkTexture->dim == Latte::E_DIM::DIM_3D) + { + cemu_assert_unimplemented(); + } + ClearColorImage(vkTexture, sliceIndex, mipIndex, {r, g, b, a}, VK_IMAGE_LAYOUT_GENERAL); } void VulkanRenderer::texture_clearDepthSlice(LatteTexture* hostTexture, uint32 sliceIndex, sint32 mipIndex, bool clearDepth, bool clearStencil, float depthValue, uint32 stencilValue) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 3e55fc0c..d4eda785 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -130,7 +130,6 @@ class VulkanRenderer : public Renderer using QueueFamilyIndices = SwapchainInfoVk::QueueFamilyIndices; static const inline int UNIFORMVAR_RINGBUFFER_SIZE = 1024 * 1024 * 16; // 16MB - static const inline int INDEX_STREAM_BUFFER_SIZE = 16 * 1024 * 1024; // 16 MB static const inline int TEXTURE_READBACK_SIZE = 32 * 1024 * 1024; // 32 MB From ea68f787eb6b8054805502a8b4aabae08ae59d94 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:41:01 +0100 Subject: [PATCH 095/314] Vulkan: For MSAA surface copies make the target MSAA too Fixes #1108 --- src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp | 2 +- src/Cafe/HW/Latte/ISA/LatteReg.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp b/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp index 4f5b24ad..45be6843 100644 --- a/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteSurfaceCopy.cpp @@ -37,7 +37,7 @@ void LatteSurfaceCopy_copySurfaceNew(MPTR srcPhysAddr, MPTR srcMipAddr, uint32 s if (!destinationTexture) { LatteTexture* renderTargetConf = nullptr; - destinationView = LatteTexture_CreateMapping(dstPhysAddr, dstMipAddr, dstWidth, dstHeight, dstDepth, dstPitch, dstTilemode, dstSwizzle, dstLevel, 1, dstSlice, 1, dstSurfaceFormat, dstDim, Latte::E_DIM::DIM_2D, false); + destinationView = LatteTexture_CreateMapping(dstPhysAddr, dstMipAddr, dstWidth, dstHeight, dstDepth, dstPitch, dstTilemode, dstSwizzle, dstLevel, 1, dstSlice, 1, dstSurfaceFormat, dstDim, Latte::IsMSAA(dstDim) ? Latte::E_DIM::DIM_2D_MSAA : Latte::E_DIM::DIM_2D, false); destinationTexture = destinationView->baseTexture; } // copy texture diff --git a/src/Cafe/HW/Latte/ISA/LatteReg.h b/src/Cafe/HW/Latte/ISA/LatteReg.h index d571dc6e..d1a2a028 100644 --- a/src/Cafe/HW/Latte/ISA/LatteReg.h +++ b/src/Cafe/HW/Latte/ISA/LatteReg.h @@ -345,6 +345,11 @@ namespace Latte return IsCompressedFormat((Latte::E_HWSURFFMT)((uint32)format & 0x3F)); } + inline bool IsMSAA(Latte::E_DIM dim) + { + return dim == E_DIM::DIM_2D_MSAA || dim == E_DIM::DIM_2D_ARRAY_MSAA; + } + enum GPU_LIMITS { NUM_VERTEX_BUFFERS = 16, From b390023bc5b04a0b50c6fd2a1bc10feb19a22f59 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:48:59 +0100 Subject: [PATCH 096/314] README.md: Fix minor ambiguity --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e57cb483..dfd35791 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before submitting a pull request, please read and follow our code style guidelin If coding isn't your thing, testing games and making detailed bug reports or updating the (usually outdated) compatibility wiki is also appreciated! -Questions about Cemu's software architecture can also be answered on Discord (through the Matrix bridge). +Questions about Cemu's software architecture can also be answered on Discord (or through the Matrix bridge). ## License Cemu is licensed under [Mozilla Public License 2.0](/LICENSE.txt). Exempt from this are all files in the dependencies directory for which the licenses of the original code apply as well as some individual files in the src folder, as specified in those file headers respectively. From d9e8ca2c833e2b2adf8f1c1cc71f7846fd87b816 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 9 Mar 2024 02:25:40 +0100 Subject: [PATCH 097/314] Revert "Vulkan: Update some code to use VK_KHR_synchronization2" This reverts commit 8f1cd4f9255e16aeddb2e72d35a47f37e1e478bc. We received reports from users stuck with Vulkan drivers from 2019. (E.g. Kepler on Windows). So let's not unnecessarily increase the Vulkan requirement for now and postpone this to after the next stable release --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 30 +-- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 220 +++++++++--------- .../Renderer/Vulkan/VulkanRendererCore.cpp | 35 ++- 3 files changed, 145 insertions(+), 140 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index bb83607f..8711359e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -468,15 +468,6 @@ VulkanRenderer::VulkanRenderer() void* deviceExtensionFeatures = nullptr; - // enable VK_KHR_synchonization_2 - VkPhysicalDeviceSynchronization2FeaturesKHR sync2Feature{}; - { - sync2Feature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR; - sync2Feature.pNext = deviceExtensionFeatures; - deviceExtensionFeatures = &sync2Feature; - sync2Feature.synchronization2 = VK_TRUE; - } - // enable VK_EXT_pipeline_creation_cache_control VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT cacheControlFeature{}; if (m_featureControl.deviceExtensions.pipeline_creation_cache_control) @@ -2875,20 +2866,13 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu ClearColorbuffer(padView); // barrier for input texture - { - VkMemoryBarrier2 memoryBarrier2{}; - memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; - memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_TRANSFER_BIT_KHR; - memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR; - memoryBarrier2.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT; - memoryBarrier2.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT; - VkDependencyInfo dependencyInfo{}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - dependencyInfo.dependencyFlags = 0; - dependencyInfo.memoryBarrierCount = 1; - dependencyInfo.pMemoryBarriers = &memoryBarrier2; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); - } + VkMemoryBarrier memoryBarrier{}; + memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; + VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT; + VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + memoryBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + memoryBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT; + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStage, dstStage, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr); auto pipeline = backbufferBlit_createGraphicsPipeline(m_swapchainDescriptorSetLayout, padView, shader); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index d4eda785..479c9e54 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -720,192 +720,201 @@ private: IMAGE_READ = 0x20, IMAGE_WRITE = 0x40, + }; template - void barrier_calcStageAndMask(VkPipelineStageFlags2& stages, VkAccessFlags2& accessFlags) + void barrier_calcStageAndMask(VkPipelineStageFlags& stages, VkAccessFlags& accessFlags) { stages = 0; accessFlags = 0; if constexpr ((TSyncOp & BUFFER_SHADER_READ) != 0) { - // in theory: VK_ACCESS_2_INDEX_READ_BIT should be set here too but indices are currently separated - stages |= VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_2_UNIFORM_READ_BIT | VK_ACCESS_2_SHADER_READ_BIT; + // in theory: VK_ACCESS_INDEX_READ_BIT should be set here too but indices are currently separated + stages |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT; } - + if constexpr ((TSyncOp & BUFFER_SHADER_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_2_SHADER_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_SHADER_WRITE_BIT; } if constexpr ((TSyncOp & ANY_TRANSFER) != 0) { - stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; - accessFlags |= VK_ACCESS_2_TRANSFER_READ_BIT | VK_ACCESS_2_TRANSFER_WRITE_BIT; + //stages |= VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_HOST_BIT; + //accessFlags |= VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; + accessFlags |= VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + + //accessFlags |= VK_ACCESS_MEMORY_READ_BIT; + //accessFlags |= VK_ACCESS_MEMORY_WRITE_BIT; } if constexpr ((TSyncOp & TRANSFER_READ) != 0) { - stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; - accessFlags |= VK_ACCESS_2_TRANSFER_READ_BIT; + stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; + accessFlags |= VK_ACCESS_TRANSFER_READ_BIT; + + //accessFlags |= VK_ACCESS_MEMORY_READ_BIT; } if constexpr ((TSyncOp & TRANSFER_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT; - accessFlags |= VK_ACCESS_2_TRANSFER_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; + accessFlags |= VK_ACCESS_TRANSFER_WRITE_BIT; + + //accessFlags |= VK_ACCESS_MEMORY_WRITE_BIT; } if constexpr ((TSyncOp & HOST_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_2_HOST_BIT; - accessFlags |= VK_ACCESS_2_HOST_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_HOST_BIT; + accessFlags |= VK_ACCESS_HOST_WRITE_BIT; } if constexpr ((TSyncOp & HOST_READ) != 0) { - stages |= VK_PIPELINE_STAGE_2_HOST_BIT; - accessFlags |= VK_ACCESS_2_HOST_READ_BIT; + stages |= VK_PIPELINE_STAGE_HOST_BIT; + accessFlags |= VK_ACCESS_HOST_READ_BIT; } if constexpr ((TSyncOp & IMAGE_READ) != 0) { - stages |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT; - accessFlags |= VK_ACCESS_2_SHADER_READ_BIT; + stages |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + accessFlags |= VK_ACCESS_SHADER_READ_BIT; - stages |= VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; - accessFlags |= VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT; + stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + accessFlags |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT; - stages |= VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT; - accessFlags |= VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + accessFlags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; } if constexpr ((TSyncOp & IMAGE_WRITE) != 0) { - stages |= VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; - accessFlags |= VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + accessFlags |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - stages |= VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT; - accessFlags |= VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + stages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + accessFlags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; } } template void barrier_bufferRange(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size) { - VkBufferMemoryBarrier2 bufMemBarrier{}; - bufMemBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2; + VkBufferMemoryBarrier bufMemBarrier{}; + bufMemBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; bufMemBarrier.pNext = nullptr; bufMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; bufMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barrier_calcStageAndMask(bufMemBarrier.srcStageMask, bufMemBarrier.srcAccessMask); - barrier_calcStageAndMask(bufMemBarrier.dstStageMask, bufMemBarrier.dstAccessMask); + VkPipelineStageFlags srcStages = 0; + VkPipelineStageFlags dstStages = 0; + + bufMemBarrier.srcAccessMask = 0; + bufMemBarrier.dstAccessMask = 0; + + barrier_calcStageAndMask(srcStages, bufMemBarrier.srcAccessMask); + barrier_calcStageAndMask(dstStages, bufMemBarrier.dstAccessMask); bufMemBarrier.buffer = buffer; bufMemBarrier.offset = offset; bufMemBarrier.size = size; - - VkDependencyInfo depInfo{}; - depInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - depInfo.pNext = nullptr; - depInfo.bufferMemoryBarrierCount = 1; - depInfo.pBufferMemoryBarriers = &bufMemBarrier; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &depInfo); + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 1, &bufMemBarrier, 0, nullptr); } template void barrier_bufferRange(VkBuffer bufferA, VkDeviceSize offsetA, VkDeviceSize sizeA, VkBuffer bufferB, VkDeviceSize offsetB, VkDeviceSize sizeB) { - VkBufferMemoryBarrier2 bufMemBarrier2[2] = {}; - bufMemBarrier2[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2_KHR; - bufMemBarrier2[0].pNext = nullptr; - bufMemBarrier2[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier2[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier2[0].buffer = bufferA; - bufMemBarrier2[0].offset = offsetA; - bufMemBarrier2[0].size = sizeA; - barrier_calcStageAndMask(bufMemBarrier2[0].srcStageMask, bufMemBarrier2[0].srcAccessMask); - barrier_calcStageAndMask(bufMemBarrier2[0].dstStageMask, bufMemBarrier2[0].dstAccessMask); + VkPipelineStageFlags srcStagesA = 0; + VkPipelineStageFlags dstStagesA = 0; + VkPipelineStageFlags srcStagesB = 0; + VkPipelineStageFlags dstStagesB = 0; - bufMemBarrier2[1].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2_KHR; - bufMemBarrier2[1].pNext = nullptr; - bufMemBarrier2[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier2[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - bufMemBarrier2[1].buffer = bufferB; - bufMemBarrier2[1].offset = offsetB; - bufMemBarrier2[1].size = sizeB; - barrier_calcStageAndMask(bufMemBarrier2[1].srcStageMask, bufMemBarrier2[1].srcAccessMask); - barrier_calcStageAndMask(bufMemBarrier2[1].dstStageMask, bufMemBarrier2[1].dstAccessMask); + VkBufferMemoryBarrier bufMemBarrier[2]; - VkDependencyInfo dependencyInfo = {}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - dependencyInfo.pNext = nullptr; - dependencyInfo.bufferMemoryBarrierCount = 2; - dependencyInfo.pBufferMemoryBarriers = bufMemBarrier2; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + bufMemBarrier[0].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + bufMemBarrier[0].pNext = nullptr; + bufMemBarrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier[0].srcAccessMask = 0; + bufMemBarrier[0].dstAccessMask = 0; + barrier_calcStageAndMask(srcStagesA, bufMemBarrier[0].srcAccessMask); + barrier_calcStageAndMask(dstStagesA, bufMemBarrier[0].dstAccessMask); + bufMemBarrier[0].buffer = bufferA; + bufMemBarrier[0].offset = offsetA; + bufMemBarrier[0].size = sizeA; + + bufMemBarrier[1].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + bufMemBarrier[1].pNext = nullptr; + bufMemBarrier[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + bufMemBarrier[1].srcAccessMask = 0; + bufMemBarrier[1].dstAccessMask = 0; + barrier_calcStageAndMask(srcStagesB, bufMemBarrier[1].srcAccessMask); + barrier_calcStageAndMask(dstStagesB, bufMemBarrier[1].dstAccessMask); + bufMemBarrier[1].buffer = bufferB; + bufMemBarrier[1].offset = offsetB; + bufMemBarrier[1].size = sizeB; + + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStagesA|srcStagesB, dstStagesA|dstStagesB, 0, 0, nullptr, 2, bufMemBarrier, 0, nullptr); } void barrier_sequentializeTransfer() { - VkMemoryBarrier2 memoryBarrier2{}; - memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; - memoryBarrier2.pNext = nullptr; - memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_TRANSFER_BIT; - memoryBarrier2.srcAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT | VK_ACCESS_2_TRANSFER_WRITE_BIT; - memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT; - memoryBarrier2.dstAccessMask = VK_ACCESS_2_MEMORY_READ_BIT | VK_ACCESS_2_MEMORY_WRITE_BIT; + VkMemoryBarrier memBarrier{}; + memBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; + memBarrier.pNext = nullptr; - VkDependencyInfo dependencyInfo{}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - dependencyInfo.pNext = nullptr; - dependencyInfo.memoryBarrierCount = 1; - dependencyInfo.pMemoryBarriers = &memoryBarrier2; - dependencyInfo.bufferMemoryBarrierCount = 0; - dependencyInfo.imageMemoryBarrierCount = 0; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + VkPipelineStageFlags srcStages = VK_PIPELINE_STAGE_TRANSFER_BIT; + VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + + memBarrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + memBarrier.dstAccessMask = 0; + + memBarrier.srcAccessMask |= (VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); + memBarrier.dstAccessMask |= (VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT); + + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 1, &memBarrier, 0, nullptr, 0, nullptr); } void barrier_sequentializeCommand() { - VkMemoryBarrier2 memoryBarrier = {}; - memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2; - memoryBarrier.srcStageMask = VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT_KHR; - memoryBarrier.srcAccessMask = 0; - memoryBarrier.dstStageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT_KHR; - memoryBarrier.dstAccessMask = 0; + VkPipelineStageFlags srcStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; - VkDependencyInfo dependencyInfo = {}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - dependencyInfo.dependencyFlags = 0; - dependencyInfo.memoryBarrierCount = 1; - dependencyInfo.pMemoryBarriers = &memoryBarrier; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, 0, nullptr); } template void barrier_image(VkImage imageVk, VkImageSubresourceRange& subresourceRange, VkImageLayout oldLayout, VkImageLayout newLayout) { - VkImageMemoryBarrier2 imageMemBarrier2{}; - imageMemBarrier2.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2; - imageMemBarrier2.oldLayout = oldLayout; - imageMemBarrier2.newLayout = newLayout; - imageMemBarrier2.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageMemBarrier2.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - imageMemBarrier2.image = imageVk; - imageMemBarrier2.subresourceRange = subresourceRange; + VkPipelineStageFlags srcStages = 0; + VkPipelineStageFlags dstStages = 0; - barrier_calcStageAndMask(imageMemBarrier2.srcStageMask, imageMemBarrier2.srcAccessMask); - barrier_calcStageAndMask(imageMemBarrier2.dstStageMask, imageMemBarrier2.dstAccessMask); + VkImageMemoryBarrier imageMemBarrier{}; + imageMemBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + imageMemBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + imageMemBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + imageMemBarrier.srcAccessMask = 0; + imageMemBarrier.dstAccessMask = 0; + barrier_calcStageAndMask(srcStages, imageMemBarrier.srcAccessMask); + barrier_calcStageAndMask(dstStages, imageMemBarrier.dstAccessMask); + imageMemBarrier.image = imageVk; + imageMemBarrier.subresourceRange = subresourceRange; + imageMemBarrier.oldLayout = oldLayout; + imageMemBarrier.newLayout = newLayout; - VkDependencyInfo dependencyInfo{}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO; - dependencyInfo.imageMemoryBarrierCount = 1; - dependencyInfo.pImageMemoryBarriers = &imageMemBarrier2; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + vkCmdPipelineBarrier(m_state.currentCommandBuffer, + srcStages, dstStages, + 0, + 0, NULL, + 0, NULL, + 1, &imageMemBarrier); } template @@ -925,6 +934,7 @@ private: vkTexture->SetImageLayout(subresourceRange, newLayout); } + public: bool GetDisableMultithreadedCompilation() const { return m_featureControl.disableMultithreadedCompilation; } bool UseTFViaSSBO() const { return m_featureControl.mode.useTFEmulationViaSSBO; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index b6cae7f7..320357f1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -1033,18 +1033,29 @@ void VulkanRenderer::sync_inputTexturesChanged() // barrier here if (writeFlushRequired) { - VkMemoryBarrier2 memoryBarrier2{}; - memoryBarrier2.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2_KHR; - memoryBarrier2.srcStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR; - memoryBarrier2.srcAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR; - memoryBarrier2.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR; - memoryBarrier2.dstAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT_KHR | VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT_KHR | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR | VK_ACCESS_2_SHADER_READ_BIT_KHR; - VkDependencyInfo dependencyInfo{}; - dependencyInfo.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO_KHR; - dependencyInfo.dependencyFlags = 0; - dependencyInfo.memoryBarrierCount = 1; - dependencyInfo.pMemoryBarriers = &memoryBarrier2; - vkCmdPipelineBarrier2KHR(m_state.currentCommandBuffer, &dependencyInfo); + VkMemoryBarrier memoryBarrier{}; + memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; + memoryBarrier.srcAccessMask = 0; + memoryBarrier.dstAccessMask = 0; + + VkPipelineStageFlags srcStage = 0; + VkPipelineStageFlags dstStage = 0; + + // src + srcStage |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + memoryBarrier.srcAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + + srcStage |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT; + memoryBarrier.srcAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + + // dst + dstStage |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + memoryBarrier.dstAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT; + + dstStage |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; + memoryBarrier.dstAccessMask |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT; + + vkCmdPipelineBarrier(m_state.currentCommandBuffer, srcStage, dstStage, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr); performanceMonitor.vk.numDrawBarriersPerFrame.increment(); From f69fddc6e50aabf71d1c78e73d7bcd6545b8ab92 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:25:16 +0100 Subject: [PATCH 098/314] TitleManager: Fix crash when sorting by format (#1113) --- src/gui/components/wxTitleManagerList.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index d6ad8118..c02bffb7 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -1143,7 +1143,7 @@ bool wxTitleManagerList::SortFunc(int column, const Type_t& v1, const Type_t& v2 // check column: title id -> type -> path if (column == ColumnTitleId) { - // ensure strong ordering -> use type since only one entry should be now (should be changed if every save for every user is displayed spearately?) + // ensure strong ordering -> use type since only one entry should be now (should be changed if every save for every user is displayed separately?) if (entry1.title_id == entry2.title_id) return SortFunc(ColumnType, v1, v2); @@ -1159,7 +1159,7 @@ bool wxTitleManagerList::SortFunc(int column, const Type_t& v1, const Type_t& v2 } else if (column == ColumnType) { - if(std::underlying_type_t(entry1.type) == std::underlying_type_t(entry2.type)) + if(entry1.type == entry2.type) return SortFunc(-1, v1, v2); return std::underlying_type_t(entry1.type) < std::underlying_type_t(entry2.type); @@ -1178,6 +1178,13 @@ bool wxTitleManagerList::SortFunc(int column, const Type_t& v1, const Type_t& v2 return std::underlying_type_t(entry1.region) < std::underlying_type_t(entry2.region); } + else if (column == ColumnFormat) + { + if(entry1.format == entry2.format) + return SortFunc(ColumnType, v1, v2); + + return std::underlying_type_t(entry1.format) < std::underlying_type_t(entry2.format); + } return false; } From a2d74972d4e0cd3b61dc4deb32566fc385942963 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:55:31 +0100 Subject: [PATCH 099/314] Prevent changing of console language while a game is running (#1114) --- src/gui/MainWindow.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d271ca3a..311ddfb7 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1019,8 +1019,11 @@ void MainWindow::OnConsoleLanguage(wxCommandEvent& event) default: cemu_assert_debug(false); } - m_game_list->DeleteCachedStrings(); - m_game_list->ReloadGameEntries(false); + if (m_game_list) + { + m_game_list->DeleteCachedStrings(); + m_game_list->ReloadGameEntries(false); + } g_config.Save(); } @@ -2159,6 +2162,14 @@ void MainWindow::RecreateMenu() optionsConsoleLanguageMenu->AppendRadioItem(MAINFRAME_MENU_ID_OPTIONS_LANGUAGE_PORTUGUESE, _("&Portuguese"), wxEmptyString)->Check(config.console_language == CafeConsoleLanguage::PT); optionsConsoleLanguageMenu->AppendRadioItem(MAINFRAME_MENU_ID_OPTIONS_LANGUAGE_RUSSIAN, _("&Russian"), wxEmptyString)->Check(config.console_language == CafeConsoleLanguage::RU); optionsConsoleLanguageMenu->AppendRadioItem(MAINFRAME_MENU_ID_OPTIONS_LANGUAGE_TAIWANESE, _("&Taiwanese"), wxEmptyString)->Check(config.console_language == CafeConsoleLanguage::TW); + if(IsGameLaunched()) + { + auto items = optionsConsoleLanguageMenu->GetMenuItems(); + for (auto& item : items) + { + item->Enable(false); + } + } // options submenu wxMenu* optionsMenu = new wxMenu(); From e1435066ee0ccc65e3ec6244c334214243236883 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:57:31 +0100 Subject: [PATCH 100/314] OpenGL: Fix crash related to wxWidgets handling of vsync (#1112) --- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 14 ++++++++++++++ src/Common/GLInclude/GLInclude.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index f09f04f1..8548fa1c 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -24,11 +24,14 @@ #define STRINGIFY2(X) #X #define STRINGIFY(X) STRINGIFY2(X) +namespace CemuGL +{ #define GLFUNC(__type, __name) __type __name; #define EGLFUNC(__type, __name) __type __name; #include "Common/GLInclude/glFunctions.h" #undef GLFUNC #undef EGLFUNC +} #include "config/ActiveSettings.h" #include "config/LaunchSettings.h" @@ -241,6 +244,17 @@ void LoadOpenGLImports() #undef GLFUNC #undef EGLFUNC } + +#if BOOST_OS_LINUX +// dummy function for all code that is statically linked with cemu and attempts to use eglSwapInterval +// used to suppress wxWidgets calls to eglSwapInterval +extern "C" +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + return EGL_TRUE; +} +#endif + #elif BOOST_OS_MACOS void LoadOpenGLImports() { diff --git a/src/Common/GLInclude/GLInclude.h b/src/Common/GLInclude/GLInclude.h index bf7a6bf8..86df0232 100644 --- a/src/Common/GLInclude/GLInclude.h +++ b/src/Common/GLInclude/GLInclude.h @@ -36,6 +36,8 @@ typedef struct __GLXFBConfigRec *GLXFBConfig; #endif +namespace CemuGL +{ #define GLFUNC(__type, __name) extern __type __name; #define EGLFUNC(__type, __name) extern __type __name; #include "glFunctions.h" @@ -213,6 +215,8 @@ static void glCompressedTextureSubImage3DWrapper(GLenum target, GLuint texture, glBindTexture(target, originalTexture); } +} +using namespace CemuGL; // this prevents Windows GL.h from being included: #define __gl_h_ #define __GL_H__ From 788da3cdf73741a10f714772b74b0675e2e98282 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 11 Mar 2024 01:47:31 +0100 Subject: [PATCH 101/314] CafeSystem: Init recompiler after game profile has been loaded (#1115) --- src/Cafe/CafeSystem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 30dab1d4..76f8ae70 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -779,10 +779,10 @@ namespace CafeSystem return r; // setup memory space and PPC recompiler SetupMemorySpace(); - PPCRecompiler_init(); r = SetupExecutable(); // load RPX if (r != STATUS_CODE::SUCCESS) return r; + PPCRecompiler_init(); InitVirtualMlcStorage(); return STATUS_CODE::SUCCESS; } @@ -821,11 +821,11 @@ namespace CafeSystem uint32 h = generateHashFromRawRPXData(execData->data(), execData->size()); sForegroundTitleId = 0xFFFFFFFF00000000ULL | (uint64)h; cemuLog_log(LogType::Force, "Generated placeholder TitleId: {:016x}", sForegroundTitleId); - // setup memory space and ppc recompiler + // setup memory space SetupMemorySpace(); - PPCRecompiler_init(); // load executable SetupExecutable(); + PPCRecompiler_init(); InitVirtualMlcStorage(); return STATUS_CODE::SUCCESS; } From ccabd9315947cedbbf198c1e0dabffe963b67550 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 11 Mar 2024 02:13:53 +0100 Subject: [PATCH 102/314] Linux: Exit on SIGTERM (#1116) --- src/Common/ExceptionHandler/ExceptionHandler_posix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp index cf547110..7afbf191 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler_posix.cpp @@ -155,6 +155,7 @@ void ExceptionHandler_Init() action.sa_handler = handler_SIGINT; sigaction(SIGINT, &action, nullptr); + sigaction(SIGTERM, &action, nullptr); action.sa_flags = SA_SIGINFO; action.sa_handler = nullptr; From bb88b5c36dd145c4d176b26b749c0817c300b2e6 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 11 Mar 2024 02:40:47 +0100 Subject: [PATCH 103/314] Fix crash introduced by #1115 (#1117) * Revert "CafeSystem: Init recompiler after game profile has been loaded (#1115)" * Instead move gameprofile load call --- src/Cafe/CafeSystem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 76f8ae70..75cb1116 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -748,7 +748,6 @@ namespace CafeSystem } } LoadMainExecutable(); - gameProfile_load(); return STATUS_CODE::SUCCESS; } @@ -777,12 +776,13 @@ namespace CafeSystem STATUS_CODE r = LoadAndMountForegroundTitle(titleId); if (r != STATUS_CODE::SUCCESS) return r; + gameProfile_load(); // setup memory space and PPC recompiler SetupMemorySpace(); + PPCRecompiler_init(); r = SetupExecutable(); // load RPX if (r != STATUS_CODE::SUCCESS) return r; - PPCRecompiler_init(); InitVirtualMlcStorage(); return STATUS_CODE::SUCCESS; } @@ -821,11 +821,11 @@ namespace CafeSystem uint32 h = generateHashFromRawRPXData(execData->data(), execData->size()); sForegroundTitleId = 0xFFFFFFFF00000000ULL | (uint64)h; cemuLog_log(LogType::Force, "Generated placeholder TitleId: {:016x}", sForegroundTitleId); - // setup memory space + // setup memory space and ppc recompiler SetupMemorySpace(); + PPCRecompiler_init(); // load executable SetupExecutable(); - PPCRecompiler_init(); InitVirtualMlcStorage(); return STATUS_CODE::SUCCESS; } From 3d0d987d895686d749073006c9eca96aa650b9ac Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Mar 2024 01:10:19 +0100 Subject: [PATCH 104/314] Logging: Introduce logOnce helper For cases where printing a message once is enough and to avoid spamming log.txt --- src/Cemu/Logging/CemuLogging.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 728c8b93..388e51ab 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -7,7 +7,7 @@ enum class LogType : sint32 // note: IDs must be in range 1-64 Force = 63, // always enabled Placeholder = 62, // always disabled - APIErrors = Force, // alias for Force. Logs bad parameters or other API errors in OS libs + APIErrors = Force, // alias for Force. Logs bad parameters or other API usage mistakes or unintended errors in OS libs CoreinitFile = 0, GX2 = 1, @@ -99,6 +99,8 @@ bool cemuLog_log(LogType type, const T* format, TArgs&&... args) return cemuLog_log(type, format_str, std::forward(args)...); } +#define cemuLog_logOnce(...) { static bool _not_first_call = false; if (!_not_first_call) { _not_first_call = true; cemuLog_log(__VA_ARGS__); } } + // same as cemuLog_log, but only outputs in debug mode template bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args) From 0993658c82e89dbda35d29b36a69d1e9e3d47678 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Mar 2024 01:21:04 +0100 Subject: [PATCH 105/314] GX2: Rework GX2Set*UniformReg - Use cafeExportRegister() instead of legacy export - Submit as a single PM4 packet - Add logging for the special case of the size parameter (not sure if this is used by any game?) - Add some extra validation and logging which may be helpful to homebrew devs --- src/Cafe/OS/libs/gx2/GX2.cpp | 3 -- src/Cafe/OS/libs/gx2/GX2.h | 2 -- src/Cafe/OS/libs/gx2/GX2_Shader.cpp | 34 +++++++++++++++++++++ src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp | 35 ---------------------- src/Cafe/OS/libs/nn_act/nn_act.cpp | 2 -- 5 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/Cafe/OS/libs/gx2/GX2.cpp b/src/Cafe/OS/libs/gx2/GX2.cpp index 82aef164..c2ea34a4 100644 --- a/src/Cafe/OS/libs/gx2/GX2.cpp +++ b/src/Cafe/OS/libs/gx2/GX2.cpp @@ -396,16 +396,13 @@ void gx2_load() osLib_addFunction("gx2", "GX2GetCurrentScanBuffer", gx2Export_GX2GetCurrentScanBuffer); // shader stuff - //osLib_addFunction("gx2", "GX2SetVertexShader", gx2Export_GX2SetVertexShader); osLib_addFunction("gx2", "GX2SetPixelShader", gx2Export_GX2SetPixelShader); osLib_addFunction("gx2", "GX2SetGeometryShader", gx2Export_GX2SetGeometryShader); osLib_addFunction("gx2", "GX2SetComputeShader", gx2Export_GX2SetComputeShader); - osLib_addFunction("gx2", "GX2SetVertexUniformReg", gx2Export_GX2SetVertexUniformReg); osLib_addFunction("gx2", "GX2SetVertexUniformBlock", gx2Export_GX2SetVertexUniformBlock); osLib_addFunction("gx2", "GX2RSetVertexUniformBlock", gx2Export_GX2RSetVertexUniformBlock); osLib_addFunction("gx2", "GX2SetPixelUniformBlock", gx2Export_GX2SetPixelUniformBlock); - osLib_addFunction("gx2", "GX2SetPixelUniformReg", gx2Export_GX2SetPixelUniformReg); osLib_addFunction("gx2", "GX2SetGeometryUniformBlock", gx2Export_GX2SetGeometryUniformBlock); osLib_addFunction("gx2", "GX2SetShaderModeEx", gx2Export_GX2SetShaderModeEx); diff --git a/src/Cafe/OS/libs/gx2/GX2.h b/src/Cafe/OS/libs/gx2/GX2.h index 58d98191..a22719f4 100644 --- a/src/Cafe/OS/libs/gx2/GX2.h +++ b/src/Cafe/OS/libs/gx2/GX2.h @@ -18,11 +18,9 @@ void gx2_load(); void gx2Export_GX2SetPixelShader(PPCInterpreter_t* hCPU); void gx2Export_GX2SetGeometryShader(PPCInterpreter_t* hCPU); void gx2Export_GX2SetComputeShader(PPCInterpreter_t* hCPU); -void gx2Export_GX2SetVertexUniformReg(PPCInterpreter_t* hCPU); void gx2Export_GX2SetVertexUniformBlock(PPCInterpreter_t* hCPU); void gx2Export_GX2RSetVertexUniformBlock(PPCInterpreter_t* hCPU); void gx2Export_GX2SetPixelUniformBlock(PPCInterpreter_t* hCPU); -void gx2Export_GX2SetPixelUniformReg(PPCInterpreter_t* hCPU); void gx2Export_GX2SetGeometryUniformBlock(PPCInterpreter_t* hCPU); void gx2Export_GX2SetShaderModeEx(PPCInterpreter_t* hCPU); void gx2Export_GX2CalcGeometryShaderInputRingBufferSize(PPCInterpreter_t* hCPU); diff --git a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp index ad17dc49..d004288b 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp @@ -417,6 +417,37 @@ namespace GX2 } } + void _GX2SubmitUniformReg(uint32 offsetRegBase, uint32 aluRegisterOffset, uint32be* dataWords, uint32 sizeInU32s) + { + if(aluRegisterOffset&0x8000) + { + cemuLog_logDebug(LogType::Force, "_GX2SubmitUniformReg(): Unhandled loop const special case or invalid offset"); + return; + } + if((aluRegisterOffset+sizeInU32s) > 0x400) + { + cemuLog_logOnce(LogType::APIErrors, "GX2SetVertexUniformReg values are out of range (offset {} + size {} must be equal or smaller than 0x400)", aluRegisterOffset, sizeInU32s); + } + if( (sizeInU32s&3) != 0) + { + cemuLog_logOnce(LogType::APIErrors, "GX2Set*UniformReg must be called with a size that is a multiple of 4 (size: {:})", sizeInU32s); + sizeInU32s &= ~3; + } + GX2ReserveCmdSpace(2 + sizeInU32s); + gx2WriteGather_submit(pm4HeaderType3(IT_SET_ALU_CONST, 1 + sizeInU32s), offsetRegBase + aluRegisterOffset); + gx2WriteGather_submitU32AsLEArray((uint32*)dataWords, sizeInU32s); + } + + void GX2SetVertexUniformReg(uint32 offset, uint32 sizeInU32s, uint32be* values) + { + _GX2SubmitUniformReg(0x400, offset, values, sizeInU32s); + } + + void GX2SetPixelUniformReg(uint32 offset, uint32 sizeInU32s, uint32be* values) + { + _GX2SubmitUniformReg(0, offset, values, sizeInU32s); + } + void GX2ShaderInit() { cafeExportRegister("gx2", GX2CalcFetchShaderSizeEx, LogType::GX2); @@ -428,5 +459,8 @@ namespace GX2 cafeExportRegister("gx2", GX2GetPixelShaderStackEntries, LogType::GX2); cafeExportRegister("gx2", GX2SetFetchShader, LogType::GX2); cafeExportRegister("gx2", GX2SetVertexShader, LogType::GX2); + + cafeExportRegister("gx2", GX2SetVertexUniformReg, LogType::GX2); + cafeExportRegister("gx2", GX2SetPixelUniformReg, LogType::GX2); } } \ No newline at end of file diff --git a/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp b/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp index 1cb61a7e..b0a5d2fa 100644 --- a/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_shader_legacy.cpp @@ -270,41 +270,6 @@ void gx2Export_GX2SetComputeShader(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); } -void _GX2SubmitUniformReg(uint32 aluRegisterOffset, MPTR virtualAddress, uint32 count) -{ - uint32* dataWords = (uint32*)memory_getPointerFromVirtualOffset(virtualAddress); - GX2ReserveCmdSpace(2 + (count / 0xFF) * 2 + count); - // write PM4 command(s) - uint32 currentRegisterOffset = aluRegisterOffset; - while (count > 0) - { - uint32 subCount = std::min(count, 0xFFu); // a single command can write at most 0xFF values - gx2WriteGather_submit(pm4HeaderType3(IT_SET_ALU_CONST, 1 + subCount), - currentRegisterOffset); - gx2WriteGather_submitU32AsLEArray(dataWords, subCount); - - dataWords += subCount; - count -= subCount; - currentRegisterOffset += subCount; - } -} - -void gx2Export_GX2SetVertexUniformReg(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2SetVertexUniformReg(0x{:08x},0x{:x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - _GX2SubmitUniformReg(hCPU->gpr[3] + 0x400, hCPU->gpr[5], hCPU->gpr[4]); - cemu_assert_debug((hCPU->gpr[3] + hCPU->gpr[4]) <= 0x400); - osLib_returnFromFunction(hCPU, 0); -} - -void gx2Export_GX2SetPixelUniformReg(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::GX2, "GX2SetPixelUniformReg(0x{:08x},0x{:x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5]); - _GX2SubmitUniformReg(hCPU->gpr[3], hCPU->gpr[5], hCPU->gpr[4]); - cemu_assert_debug((hCPU->gpr[3] + hCPU->gpr[4]) <= 0x400); - osLib_returnFromFunction(hCPU, 0); -} - void _GX2SubmitUniformBlock(uint32 registerBase, uint32 index, MPTR virtualAddress, uint32 size) { GX2ReserveCmdSpace(9); diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index 0fd9df5a..2a9f61bc 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -543,8 +543,6 @@ void nnActExport_GetDefaultAccount(PPCInterpreter_t* hCPU) void nnActExport_GetSlotNo(PPCInterpreter_t* hCPU) { // id of active account - // uint8 GetSlotNo(void); - cemuLog_logDebug(LogType::Force, "nn_act.GetSlotNo()"); osLib_returnFromFunction(hCPU, 1); // 1 is the first slot (0 is invalid) } From dd7cb74cd21202471634e991865be242f8e45c58 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:36:47 +0100 Subject: [PATCH 106/314] Latte: Small refactor and clean up for texture size code --- .gitignore | 1 + src/Cafe/HW/Latte/Core/LatteBufferCache.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteCachedFBO.h | 4 +- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 28 ++++------- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 8 +-- src/Cafe/HW/Latte/Core/LatteTexture.h | 25 +++++++++- src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 50 ++----------------- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 23 ++++----- .../Renderer/OpenGL/OpenGLSurfaceCopy.cpp | 5 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 2 +- .../Renderer/Vulkan/VulkanSurfaceCopy.cpp | 22 +++----- src/Cafe/OS/libs/gx2/GX2_Resource.cpp | 2 +- src/Cemu/Logging/CemuLogging.h | 2 + 13 files changed, 64 insertions(+), 110 deletions(-) diff --git a/.gitignore b/.gitignore index 18f14cf3..c10b38da 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ bin/sdcard/* bin/screenshots/* bin/dump/* bin/cafeLibs/* +bin/keys.txt !bin/shaderCache/info.txt bin/shaderCache/* diff --git a/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp b/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp index 92c2d1b0..716312a3 100644 --- a/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteBufferCache.cpp @@ -309,7 +309,7 @@ public: { if ((rangeBegin & 0xF)) { - cemuLog_logDebug(LogType::Force, "writeStreamout(): RangeBegin not aligned to 16. Begin {:08x} End {:08x}", rangeBegin, rangeEnd); + cemuLog_logDebugOnce(LogType::Force, "writeStreamout(): RangeBegin not aligned to 16. Begin {:08x} End {:08x}", rangeBegin, rangeEnd); rangeBegin = (rangeBegin + 0xF) & ~0xF; rangeEnd = std::max(rangeBegin, rangeEnd); } diff --git a/src/Cafe/HW/Latte/Core/LatteCachedFBO.h b/src/Cafe/HW/Latte/Core/LatteCachedFBO.h index 6d5925fe..5f3aaed4 100644 --- a/src/Cafe/HW/Latte/Core/LatteCachedFBO.h +++ b/src/Cafe/HW/Latte/Core/LatteCachedFBO.h @@ -42,7 +42,7 @@ private: if(colorBuffer[i].texture == nullptr) continue; sint32 effectiveWidth, effectiveHeight; - LatteTexture_getEffectiveSize(colorBuffer[i].texture->baseTexture, &effectiveWidth, &effectiveHeight, nullptr, colorBuffer[i].texture->firstMip); + colorBuffer[i].texture->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, colorBuffer[i].texture->firstMip); if (rtEffectiveSize.x == 0 && rtEffectiveSize.y == 0) { rtEffectiveSize.x = effectiveWidth; @@ -64,7 +64,7 @@ private: if (depthBuffer.texture) { sint32 effectiveWidth, effectiveHeight; - LatteTexture_getEffectiveSize(depthBuffer.texture->baseTexture, &effectiveWidth, &effectiveHeight, nullptr, depthBuffer.texture->firstMip); + depthBuffer.texture->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, depthBuffer.texture->firstMip); if (rtEffectiveSize.x == 0 && rtEffectiveSize.y == 0) { rtEffectiveSize.x = effectiveWidth; diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index abdfda21..8c29ccc5 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -516,14 +516,12 @@ bool LatteMRT::UpdateCurrentFBO() sLatteRenderTargetState.rtUpdateList[sLatteRenderTargetState.rtUpdateListCount] = colorAttachmentView; sLatteRenderTargetState.rtUpdateListCount++; - sint32 colorAttachmentWidth; - sint32 colorAttachmentHeight; - - LatteTexture_getSize(colorAttachmentView->baseTexture, &colorAttachmentWidth, &colorAttachmentHeight, nullptr, colorAttachmentView->firstMip); + sint32 colorAttachmentWidth, colorAttachmentHeight; + colorAttachmentView->baseTexture->GetSize(colorAttachmentWidth, colorAttachmentHeight, colorAttachmentView->firstMip); // set effective size sint32 effectiveWidth, effectiveHeight; - LatteTexture_getEffectiveSize(colorAttachmentView->baseTexture, &effectiveWidth, &effectiveHeight, nullptr, colorAttachmentView->firstMip); + colorAttachmentView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, colorAttachmentView->firstMip); if (rtEffectiveSize->width == 0 && rtEffectiveSize->height == 0) { rtEffectiveSize->width = effectiveWidth; @@ -531,9 +529,7 @@ bool LatteMRT::UpdateCurrentFBO() } else if (rtEffectiveSize->width != effectiveWidth && rtEffectiveSize->height != effectiveHeight) { -#ifdef CEMU_DEBUG_ASSERT - cemuLog_log(LogType::Force, "Color buffer size mismatch ({}x{}). Effective size: {}x{} Real size: {}x{} Mismatching texture: {:08x} {}x{} fmt {:04x}", rtEffectiveSize->width, rtEffectiveSize->height, effectiveWidth, effectiveHeight, colorAttachmentView->baseTexture->width, colorAttachmentView->baseTexture->height, colorAttachmentView->baseTexture->physAddress, colorAttachmentView->baseTexture->width, colorAttachmentView->baseTexture->height, (uint32)colorAttachmentView->baseTexture->format); -#endif + cemuLog_logDebug(LogType::Force, "Color buffer size mismatch ({}x{}). Effective size: {}x{} Real size: {}x{} Mismatching texture: {:08x} {}x{} fmt {:04x}", rtEffectiveSize->width, rtEffectiveSize->height, effectiveWidth, effectiveHeight, colorAttachmentView->baseTexture->width, colorAttachmentView->baseTexture->height, colorAttachmentView->baseTexture->physAddress, colorAttachmentView->baseTexture->width, colorAttachmentView->baseTexture->height, (uint32)colorAttachmentView->baseTexture->format); } // currently the first color attachment defines the size of the current render target if (rtRealSize->width == 0 && rtRealSize->height == 0) @@ -608,15 +604,11 @@ bool LatteMRT::UpdateCurrentFBO() if (depthBufferPhysMem != MPTR_NULL) { - bool depthBufferWasFound = false; LatteTextureView* depthBufferView = LatteTextureViewLookupCache::lookupSliceEx(depthBufferPhysMem, depthBufferWidth, depthBufferHeight, depthBufferPitch, 0, depthBufferViewFirstSlice, depthBufferFormat, true); if (depthBufferView == nullptr) { - // create depth buffer view - if(depthBufferViewFirstSlice == 0) - depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, 1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, 0, 1, depthBufferFormat, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); - else - depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, depthBufferViewFirstSlice+1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, depthBufferViewFirstSlice, 1, depthBufferFormat, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, true); + // create new depth buffer view and if it doesn't exist then also create the texture + depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, depthBufferViewFirstSlice+1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, depthBufferViewFirstSlice, 1, depthBufferFormat, depthBufferViewFirstSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); LatteGPUState.repeatTextureInitialization = true; } else @@ -626,7 +618,7 @@ bool LatteMRT::UpdateCurrentFBO() } // set effective size sint32 effectiveWidth, effectiveHeight; - LatteTexture_getEffectiveSize(depthBufferView->baseTexture, &effectiveWidth, &effectiveHeight, NULL); + depthBufferView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, depthBufferViewFirstSlice); if (rtEffectiveSize->width == 0 && rtEffectiveSize->height == 0) { rtEffectiveSize->width = effectiveWidth; @@ -917,10 +909,8 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa // mark source texture as still in use LatteTC_MarkTextureStillInUse(textureView->baseTexture); - sint32 effectiveWidth; - sint32 effectiveHeight; - sint32 effectiveDepth; - LatteTexture_getEffectiveSize(textureView->baseTexture, &effectiveWidth, &effectiveHeight, &effectiveDepth, 0); + sint32 effectiveWidth, effectiveHeight; + textureView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); _currentOutputImageWidth = effectiveWidth; _currentOutputImageHeight = effectiveHeight; diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 707428af..91a1aa56 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -297,9 +297,9 @@ void LatteTexture_copyData(LatteTexture* srcTexture, LatteTexture* dstTexture, s else { sint32 effectiveWidth_dst, effectiveHeight_dst; - LatteTexture_getEffectiveSize(srcTexture, &effectiveWidth_dst, &effectiveHeight_dst, NULL, 0); + srcTexture->GetEffectiveSize(effectiveWidth_dst, effectiveHeight_dst, 0); sint32 effectiveWidth_src, effectiveHeight_src; - LatteTexture_getEffectiveSize(dstTexture, &effectiveWidth_src, &effectiveHeight_src, NULL, 0); + dstTexture->GetEffectiveSize(effectiveWidth_src, effectiveHeight_src, 0); debug_printf("texture_copyData(): Effective size mismatch\n"); cemuLog_logDebug(LogType::Force, "texture_copyData(): Effective size mismatch (due to texture rule)"); @@ -307,8 +307,6 @@ void LatteTexture_copyData(LatteTexture* srcTexture, LatteTexture* dstTexture, s cemuLog_logDebug(LogType::Force, "Source: origResolution {:04}x{:04} effectiveResolution {:04}x{:04} fmt {:04x} mipIndex {}", srcTexture->width, srcTexture->height, effectiveWidth_src, effectiveHeight_src, (uint32)srcTexture->format, 0); return; } - catchOpenGLError(); - for (sint32 mipIndex = 0; mipIndex < mipCount; mipIndex++) { sint32 sliceCopyWidth = std::max(effectiveCopyWidth >> mipIndex, 1); @@ -323,9 +321,7 @@ void LatteTexture_copyData(LatteTexture* srcTexture, LatteTexture* dstTexture, s LatteTextureSliceMipInfo* dstTexSliceInfo = dstTexture->sliceMipInfo + dstTexture->GetSliceMipArrayIndex(sliceIndex, mipIndex); dstTexSliceInfo->lastDynamicUpdate = srcTexSliceInfo->lastDynamicUpdate; } - catchOpenGLError(); } - catchOpenGLError(); } template diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.h b/src/Cafe/HW/Latte/Core/LatteTexture.h index d5e872e6..b46c1323 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.h +++ b/src/Cafe/HW/Latte/Core/LatteTexture.h @@ -55,6 +55,29 @@ public: bool Is3DTexture() const { return dim == Latte::E_DIM::DIM_3D; }; + void GetSize(sint32& width, sint32& height, sint32 mipLevel) const + { + width = std::max(1, this->width >> mipLevel); + height = std::max(1, this->height >> mipLevel); + } + + // similar to GetSize, but returns the real size of the texture taking into account any resolution overwrite by gfx pack rules + void GetEffectiveSize(sint32& effectiveWidth, sint32& effectiveHeight, sint32 mipLevel) const + { + if( overwriteInfo.hasResolutionOverwrite ) + { + effectiveWidth = overwriteInfo.width; + effectiveHeight = overwriteInfo.height; + } + else + { + effectiveWidth = this->width; + effectiveHeight = this->height; + } + effectiveWidth = std::max(1, effectiveWidth >> mipLevel); + effectiveHeight = std::max(1, effectiveHeight >> mipLevel); + } + sint32 GetMipDepth(sint32 mipIndex) { cemu_assert_debug(mipIndex >= 0 && mipIndex < this->mipLevels); @@ -310,8 +333,6 @@ void LatteTexture_Delete(LatteTexture* texture); void LatteTextureLoader_writeReadbackTextureToMemory(LatteTextureDefinition* textureData, uint32 sliceIndex, uint32 mipIndex, uint8* linearPixelData); -void LatteTexture_getSize(LatteTexture* texture, sint32* width, sint32* height, sint32* depth, sint32 mipLevel); -void LatteTexture_getEffectiveSize(LatteTexture* texture, sint32* effectiveWidth, sint32* effectiveHeight, sint32* effectiveDepth, sint32 mipLevel = 0); sint32 LatteTexture_getEffectiveWidth(LatteTexture* texture); bool LatteTexture_doesEffectiveRescaleRatioMatch(LatteTexture* texture1, sint32 mipLevel1, LatteTexture* texture2, sint32 mipLevel2); void LatteTexture_scaleToEffectiveSize(LatteTexture* texture, sint32* x, sint32* y, sint32 mipLevel); diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index 0260002b..b35f608c 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -206,14 +206,10 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u bool isDepthSampler = shaderContext->textureUsesDepthCompare[textureIndex]; // look for already existing texture - LatteTextureView* textureView; - if (isDepthSampler == false) - textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim); - else - textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, true); - if (textureView == nullptr) + LatteTextureView* textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, isDepthSampler); + if (!textureView) { - // create new mapping + // view not found, create a new mapping which will also create a new texture if necessary textureView = LatteTexture_CreateMapping(physAddr, physMipAddr, width, height, depth, pitch, tileMode, swizzle, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, dim, isDepthSampler); if (textureView == nullptr) continue; @@ -273,9 +269,7 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u // check for changes if (LatteTC_HasTextureChanged(textureView->baseTexture) || swizzleChanged) { -#ifdef CEMU_DEBUG_ASSERT debug_printf("Reload texture 0x%08x res %dx%d memRange %08x-%08x SwizzleChange: %s\n", textureView->baseTexture->physAddress, textureView->baseTexture->width, textureView->baseTexture->height, textureView->baseTexture->texDataPtrLow, textureView->baseTexture->texDataPtrHigh, swizzleChanged ? "yes" : "no"); -#endif // update swizzle / changed mip address if (swizzleChanged) { @@ -338,44 +332,6 @@ void LatteTexture_updateTextures() LatteTexture_updateTexturesForStage(geometryShader, LATTE_CEMU_GS_TEX_UNIT_BASE, LatteGPUState.contextNew.SQ_TEX_START_GS); } -// returns the width, height, depth of the texture -void LatteTexture_getSize(LatteTexture* texture, sint32* width, sint32* height, sint32* depth, sint32 mipLevel) -{ - *width = texture->width; - *height = texture->height; - if (depth != NULL) - *depth = texture->depth; - // handle mip level - *width = std::max(1, *width >> mipLevel); - *height = std::max(1, *height >> mipLevel); - if(texture->Is3DTexture() && depth) - *depth = std::max(1, *depth >> mipLevel); -} - -/* - * Returns the internally used width/height/depth of the texture - * Usually this is the width/height/depth specified by the game, - * unless the texture resolution was redefined via graphic pack texture rules - */ -void LatteTexture_getEffectiveSize(LatteTexture* texture, sint32* effectiveWidth, sint32* effectiveHeight, sint32* effectiveDepth, sint32 mipLevel) -{ - *effectiveWidth = texture->width; - *effectiveHeight = texture->height; - if( effectiveDepth != NULL ) - *effectiveDepth = texture->depth; - if( texture->overwriteInfo.hasResolutionOverwrite ) - { - *effectiveWidth = texture->overwriteInfo.width; - *effectiveHeight = texture->overwriteInfo.height; - if( effectiveDepth != NULL ) - *effectiveDepth = texture->overwriteInfo.depth; - } - // handle mipLevel - // todo: Mip-mapped 3D textures decrease in depth also? - *effectiveWidth = std::max(1, *effectiveWidth >> mipLevel); - *effectiveHeight = std::max(1, *effectiveHeight >> mipLevel); -} - sint32 LatteTexture_getEffectiveWidth(LatteTexture* texture) { if (texture->overwriteInfo.hasResolutionOverwrite) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 8548fa1c..68d7def6 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -569,10 +569,8 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu g_renderer->ClearColorbuffer(padView); } - // calculate effective size - sint32 effectiveWidth; - sint32 effectiveHeight; - LatteTexture_getEffectiveSize(texView->baseTexture, &effectiveWidth, &effectiveHeight, nullptr, 0); + sint32 effectiveWidth, effectiveHeight; + texView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); shader_unbind(RendererShader::ShaderType::kGeometry); shader_bind(shader->GetVertexShader()); @@ -1127,8 +1125,8 @@ void OpenGLRenderer::texture_clearColorSlice(LatteTexture* hostTexture, sint32 s LatteTextureGL* texGL = (LatteTextureGL*)hostTexture; cemu_assert_debug(!texGL->isDepth); - sint32 eWidth, eHeight, eDepth; - LatteTexture_getEffectiveSize(hostTexture, &eWidth, &eHeight, &eDepth, mipIndex); + sint32 eWidth, eHeight; + hostTexture->GetEffectiveSize(eWidth, eHeight, mipIndex); renderstate_resetColorControl(); renderTarget_setViewport(0, 0, eWidth, eHeight, 0.0f, 1.0f); LatteMRT::BindColorBufferOnly(hostTexture->GetOrCreateView(mipIndex, 1, sliceIndex, 1)); @@ -1141,8 +1139,8 @@ void OpenGLRenderer::texture_clearDepthSlice(LatteTexture* hostTexture, uint32 s LatteTextureGL* texGL = (LatteTextureGL*)hostTexture; cemu_assert_debug(texGL->isDepth); - sint32 eWidth, eHeight, eDepth; - LatteTexture_getEffectiveSize(hostTexture, &eWidth, &eHeight, &eDepth, mipIndex); + sint32 eWidth, eHeight; + hostTexture->GetEffectiveSize(eWidth, eHeight, mipIndex); renderstate_resetColorControl(); renderstate_resetDepthControl(); renderTarget_setViewport(0, 0, eWidth, eHeight, 0.0f, 1.0f); @@ -1170,13 +1168,12 @@ void OpenGLRenderer::texture_clearSlice(LatteTexture* hostTextureGeneric, sint32 LatteTextureGL::FormatInfoGL formatInfoGL; LatteTextureGL::GetOpenGLFormatInfo(hostTexture->isDepth, hostTexture->format, hostTexture->dim, &formatInfoGL); // get effective size of mip - sint32 effectiveWidth; - sint32 effectiveHeight; - LatteTexture_getEffectiveSize(hostTexture, &effectiveWidth, &effectiveHeight, nullptr, mipIndex); + sint32 effectiveWidth, effectiveHeight; + hostTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, mipIndex); // on Nvidia glClearTexImage and glClearTexSubImage has bad performance (clearing a 4K texture takes up to 50ms) // clearing with glTextureSubImage2D from a CPU RAM buffer is only slightly slower - // clearing with glTextureSubImage2D from a OpenGL buffer is 10-20% faster than glClearTexImage) + // clearing with glTextureSubImage2D from a OpenGL buffer is 10-20% faster than glClearTexImage // clearing with FBO and glClear is orders of magnitude faster than the other methods // (these are results from 2018, may be different now) @@ -1207,7 +1204,6 @@ void OpenGLRenderer::texture_clearSlice(LatteTexture* hostTextureGeneric, sint32 } if (glClearTexSubImage == nullptr) return; - // clear glClearTexSubImage(hostTexture->glId_texture, mipIndex, 0, 0, sliceIndex, effectiveWidth, effectiveHeight, 1, formatInfoGL.glSuppliedFormat, formatInfoGL.glSuppliedFormatType, NULL); } @@ -1215,7 +1211,6 @@ LatteTexture* OpenGLRenderer::texture_createTextureEx(Latte::E_DIM dim, MPTR phy uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { return new LatteTextureGL(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth); - } void OpenGLRenderer::texture_setActiveTextureUnit(sint32 index) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp index c49a57e4..d578b842 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLSurfaceCopy.cpp @@ -30,9 +30,8 @@ void OpenGLRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* s sint32 effectiveCopyWidth = width; sint32 effectiveCopyHeight = height; LatteTexture_scaleToEffectiveSize(sourceTexture, &effectiveCopyWidth, &effectiveCopyHeight, 0); - sint32 sourceEffectiveWidth; - sint32 sourceEffectiveHeight; - LatteTexture_getEffectiveSize(sourceTexture, &sourceEffectiveWidth, &sourceEffectiveHeight, nullptr, srcMip); + sint32 sourceEffectiveWidth, sourceEffectiveHeight; + sourceTexture->GetEffectiveSize(sourceEffectiveWidth, sourceEffectiveHeight, srcMip); // reset everything renderstate_resetColorControl(); renderstate_resetDepthControl(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 8711359e..5285e4ac 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -764,7 +764,7 @@ void VulkanRenderer::HandleScreenshotRequest(LatteTextureView* texView, bool pad //dumpImage->flagForCurrentCommandBuffer(); int width, height; - LatteTexture_getEffectiveSize(baseImageTex, &width, &height, nullptr, 0); + baseImageTex->GetEffectiveSize(width, height, 0); VkImage image = nullptr; VkDeviceMemory imageMemory = nullptr;; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp index 6d5d9402..d89cdaa1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp @@ -464,9 +464,8 @@ VKRObjectFramebuffer* VulkanRenderer::surfaceCopy_getOrCreateFramebuffer(VkCopyS VKRObjectTextureView* vkObjTextureView = surfaceCopy_createImageView(state.destinationTexture, state.dstSlice, state.dstMip); // create new framebuffer - sint32 effectiveWidth = 0; - sint32 effectiveHeight = 0; - LatteTexture_getEffectiveSize(state.destinationTexture, &effectiveWidth, &effectiveHeight, nullptr, state.dstMip); + sint32 effectiveWidth, effectiveHeight; + state.destinationTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, state.dstMip); std::array fbAttachments; fbAttachments[0] = vkObjTextureView; @@ -595,15 +594,11 @@ void VulkanRenderer::surfaceCopy_viaDrawcall(LatteTextureVk* srcTextureVk, sint3 // get descriptor set VKRObjectDescriptorSet* vkObjDescriptorSet = surfaceCopy_getOrCreateDescriptorSet(copySurfaceState, copySurfacePipelineInfo); - // get extend - sint32 effectiveWidth = 0; - sint32 effectiveHeight = 0; - LatteTexture_getEffectiveSize(dstTextureVk, &effectiveWidth, &effectiveHeight, nullptr, texDstMip); + sint32 dstEffectiveWidth, dstEffectiveHeight; + dstTextureVk->GetEffectiveSize(dstEffectiveWidth, dstEffectiveHeight, texDstMip); - // get extend - sint32 srcEffectiveWidth = 0; - sint32 srcEffectiveHeight = 0; - LatteTexture_getEffectiveSize(srcTextureVk, &srcEffectiveWidth, &srcEffectiveHeight, nullptr, texSrcMip); + sint32 srcEffectiveWidth, srcEffectiveHeight; + srcTextureVk->GetEffectiveSize(srcEffectiveWidth, srcEffectiveHeight, texSrcMip); CopyShaderPushConstantData_t pushConstantData; @@ -878,9 +873,8 @@ void VulkanRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* s sint32 effectiveCopyWidth = width; sint32 effectiveCopyHeight = height; LatteTexture_scaleToEffectiveSize(sourceTexture, &effectiveCopyWidth, &effectiveCopyHeight, 0); - sint32 sourceEffectiveWidth; - sint32 sourceEffectiveHeight; - LatteTexture_getEffectiveSize(sourceTexture, &sourceEffectiveWidth, &sourceEffectiveHeight, nullptr, srcMip); + sint32 sourceEffectiveWidth, sourceEffectiveHeight; + sourceTexture->GetEffectiveSize(sourceEffectiveWidth, sourceEffectiveHeight, srcMip); sint32 texSrcMip = srcMip; sint32 texSrcSlice = srcSlice; diff --git a/src/Cafe/OS/libs/gx2/GX2_Resource.cpp b/src/Cafe/OS/libs/gx2/GX2_Resource.cpp index 70390921..97f51a0d 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Resource.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Resource.cpp @@ -114,7 +114,7 @@ namespace GX2 void GX2RSetStreamOutBuffer(uint32 bufferIndex, GX2StreamOutBuffer* soBuffer) { - // seen in CoD: Ghosts + // seen in CoD: Ghosts and CoD: Black Ops 2 GX2SetStreamOutBuffer(bufferIndex, soBuffer); } diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 388e51ab..bbffd164 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -112,6 +112,8 @@ bool cemuLog_logDebug(LogType type, TFmt format, TArgs&&... args) #endif } +#define cemuLog_logDebugOnce(...) { static bool _not_first_call = false; if (!_not_first_call) { _not_first_call = true; cemuLog_logDebug(__VA_ARGS__); } } + // cafe lib calls bool cemuLog_advancedPPCLoggingEnabled(); From 40d1eaeb72f050916b29396805b8ea990345d418 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:37:44 +0100 Subject: [PATCH 107/314] nn_ac: Refactor and implement more API Doesn't fix any issue as far as I know but it removes some of the unsupported API complaints in debug logging --- src/Cafe/OS/libs/nn_ac/nn_ac.cpp | 189 +++++++++++++++++-------------- 1 file changed, 105 insertions(+), 84 deletions(-) diff --git a/src/Cafe/OS/libs/nn_ac/nn_ac.cpp b/src/Cafe/OS/libs/nn_ac/nn_ac.cpp index bb7d4af6..5f231499 100644 --- a/src/Cafe/OS/libs/nn_ac/nn_ac.cpp +++ b/src/Cafe/OS/libs/nn_ac/nn_ac.cpp @@ -8,83 +8,14 @@ // AC lib (manages internet connection) -#define AC_STATUS_FAILED (-1) -#define AC_STATUS_OK (0) - -void nn_acExport_ConnectAsync(PPCInterpreter_t* hCPU) +enum class AC_STATUS : uint32 { - cemuLog_logDebug(LogType::Force, "nn_ac.ConnectAsync();"); - uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - osLib_returnFromFunction(hCPU, nnResultCode); -} - -void nn_acExport_Connect(PPCInterpreter_t* hCPU) -{ - cemuLog_logDebug(LogType::Force, "nn_ac.Connect();"); - - // Terraria expects this (or GetLastErrorCode) to return 0 on success - // investigate on the actual console - // maybe all success codes are always 0 and dont have any of the other fields set? - - uint32 nnResultCode = 0;// BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); // Splatoon freezes if this function fails? - osLib_returnFromFunction(hCPU, nnResultCode); -} + FAILED = (uint32)-1, + OK = 0, +}; static_assert(TRUE == 1, "TRUE not 1"); -void nn_acExport_IsApplicationConnected(PPCInterpreter_t* hCPU) -{ - //cemuLog_logDebug(LogType::Force, "nn_ac.IsApplicationConnected(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamMEMPTR(connected, uint8, 0); - if (connected) - *connected = TRUE; - //memory_writeU8(hCPU->gpr[3], 1); // always return true regardless of actual online state - - const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - osLib_returnFromFunction(hCPU, nnResultCode); -} - -void nn_acExport_GetConnectStatus(PPCInterpreter_t* hCPU) -{ - ppcDefineParamMEMPTR(status, uint32, 0); - if (status) - *status = AC_STATUS_OK; - - const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - osLib_returnFromFunction(hCPU, nnResultCode); -} - -void nn_acExport_GetLastErrorCode(PPCInterpreter_t* hCPU) -{ - //cemuLog_logDebug(LogType::Force, "nn_ac.GetLastErrorCode();"); - ppcDefineParamMEMPTR(errorCode, uint32, 0); - if (errorCode) - *errorCode = 0; - const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - osLib_returnFromFunction(hCPU, nnResultCode); -} - -void nn_acExport_GetStatus(PPCInterpreter_t* hCPU) -{ - cemuLog_logDebug(LogType::Force, "nn_ac.GetStatus();"); - ppcDefineParamMEMPTR(status, uint32, 0); - if (status) - *status = AC_STATUS_OK; - const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - osLib_returnFromFunction(hCPU, nnResultCode); -} - -void nn_acExport_GetConnectResult(PPCInterpreter_t* hCPU) -{ - // GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status - cemuLog_logDebug(LogType::Force, "nn_ac.GetConnectResult(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamMEMPTR(result, uint32, 0); - const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); - if (result) - *result = nnResultCode; - osLib_returnFromFunction(hCPU, nnResultCode); -} - void _GetLocalIPAndSubnetMaskFallback(uint32& localIp, uint32& subnetMask) { // default to some hardcoded values @@ -227,37 +158,127 @@ void nnAcExport_IsConfigExisting(PPCInterpreter_t* hCPU) namespace nn_ac { + nnResult Initialize() + { + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + } + + nnResult ConnectAsync() + { + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + } + + nnResult IsApplicationConnected(uint8be* connected) + { + if (connected) + *connected = TRUE; + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + } + + uint32 Connect() + { + // Terraria expects this (or GetLastErrorCode) to return 0 on success + // investigate on the actual console + // maybe all success codes are always 0 and dont have any of the other fields set? + uint32 nnResultCode = 0;// BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); // Splatoon freezes if this function fails? + return nnResultCode; + } + + nnResult GetConnectStatus(betype* status) + { + if (status) + *status = AC_STATUS::OK; + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + } + + nnResult GetStatus(betype* status) + { + return GetConnectStatus(status); + } + + nnResult GetLastErrorCode(uint32be* errorCode) + { + if (errorCode) + *errorCode = 0; + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + } + + nnResult GetConnectResult(uint32be* connectResult) + { + const uint32 nnResultCode = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_AC, 0); + if (connectResult) + *connectResult = nnResultCode; + return nnResultCode; + } + + static_assert(sizeof(betype) == 4); + static_assert(sizeof(betype) == 4); + + nnResult ACInitialize() + { + return Initialize(); + } + bool ACIsSuccess(betype* r) { return NN_RESULT_IS_SUCCESS(*r) ? 1 : 0; } - nnResult ACGetConnectStatus(uint32be* connectionStatus) + bool ACIsFailure(betype* r) { + return NN_RESULT_IS_FAILURE(*r) ? 1 : 0; + } - *connectionStatus = 0; // 0 means connected? + nnResult ACGetConnectStatus(betype* connectionStatus) + { + return GetConnectStatus(connectionStatus); + } - return NN_RESULT_SUCCESS; + nnResult ACGetStatus(betype* connectionStatus) + { + return GetStatus(connectionStatus); + } + + nnResult ACConnectAsync() + { + return ConnectAsync(); + } + + nnResult ACIsApplicationConnected(uint32be* connectedU32) + { + uint8be connected = 0; + nnResult r = IsApplicationConnected(&connected); + *connectedU32 = connected; // convert to uint32 + return r; } void load() { + cafeExportRegisterFunc(Initialize, "nn_ac", "Initialize__Q2_2nn2acFv", LogType::Placeholder); + + cafeExportRegisterFunc(Connect, "nn_ac", "Connect__Q2_2nn2acFv", LogType::Placeholder); + cafeExportRegisterFunc(ConnectAsync, "nn_ac", "ConnectAsync__Q2_2nn2acFv", LogType::Placeholder); + + cafeExportRegisterFunc(GetConnectResult, "nn_ac", "GetConnectResult__Q2_2nn2acFPQ2_2nn6Result", LogType::Placeholder); + cafeExportRegisterFunc(GetLastErrorCode, "nn_ac", "GetLastErrorCode__Q2_2nn2acFPUi", LogType::Placeholder); + cafeExportRegisterFunc(GetConnectStatus, "nn_ac", "GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status", LogType::Placeholder); + cafeExportRegisterFunc(GetStatus, "nn_ac", "GetStatus__Q2_2nn2acFPQ3_2nn2ac6Status", LogType::Placeholder); + cafeExportRegisterFunc(IsApplicationConnected, "nn_ac", "IsApplicationConnected__Q2_2nn2acFPb", LogType::Placeholder); + + // AC also offers C-style wrappers + cafeExportRegister("nn_ac", ACInitialize, LogType::Placeholder); cafeExportRegister("nn_ac", ACIsSuccess, LogType::Placeholder); + cafeExportRegister("nn_ac", ACIsFailure, LogType::Placeholder); cafeExportRegister("nn_ac", ACGetConnectStatus, LogType::Placeholder); + cafeExportRegister("nn_ac", ACGetStatus, LogType::Placeholder); + cafeExportRegister("nn_ac", ACConnectAsync, LogType::Placeholder); + cafeExportRegister("nn_ac", ACIsApplicationConnected, LogType::Placeholder); } } void nnAc_load() { - osLib_addFunction("nn_ac", "Connect__Q2_2nn2acFv", nn_acExport_Connect); - osLib_addFunction("nn_ac", "ConnectAsync__Q2_2nn2acFv", nn_acExport_ConnectAsync); - osLib_addFunction("nn_ac", "IsApplicationConnected__Q2_2nn2acFPb", nn_acExport_IsApplicationConnected); - osLib_addFunction("nn_ac", "GetConnectStatus__Q2_2nn2acFPQ3_2nn2ac6Status", nn_acExport_GetConnectStatus); - osLib_addFunction("nn_ac", "GetConnectResult__Q2_2nn2acFPQ2_2nn6Result", nn_acExport_GetConnectResult); - osLib_addFunction("nn_ac", "GetLastErrorCode__Q2_2nn2acFPUi", nn_acExport_GetLastErrorCode); - osLib_addFunction("nn_ac", "GetStatus__Q2_2nn2acFPQ3_2nn2ac6Status", nn_acExport_GetStatus); - osLib_addFunction("nn_ac", "GetAssignedAddress__Q2_2nn2acFPUl", nnAcExport_GetAssignedAddress); osLib_addFunction("nn_ac", "GetAssignedSubnet__Q2_2nn2acFPUl", nnAcExport_GetAssignedSubnet); From 1f9b89116f2bad17f9dbd0017b38e0da181fa4c9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:55:58 +0100 Subject: [PATCH 108/314] Vulkan: Fix crash during shutdown if shaders are still compiling Make sure the async shader compiler threads are stopped before the shaders are deleted --- .../Renderer/Vulkan/RendererShaderVk.cpp | 23 +++++++++---------- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 4 ++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 970f5517..437ef51d 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -129,19 +129,18 @@ class _ShaderVkThreadPool public: void StartThreads() { - if (s_threads.empty()) - { - // create thread pool - m_shutdownThread.store(false); - const uint32 threadCount = 2; - for (uint32 i = 0; i < threadCount; ++i) - s_threads.emplace_back(&_ShaderVkThreadPool::CompilerThreadFunc, this); - } + if (m_threadsActive.exchange(true)) + return; + // create thread pool + const uint32 threadCount = 2; + for (uint32 i = 0; i < threadCount; ++i) + s_threads.emplace_back(&_ShaderVkThreadPool::CompilerThreadFunc, this); } void StopThreads() { - m_shutdownThread.store(true); + if (!m_threadsActive.exchange(false)) + return; for (uint32 i = 0; i < s_threads.size(); ++i) s_compilationQueueCount.increment(); for (auto& it : s_threads) @@ -156,7 +155,7 @@ public: void CompilerThreadFunc() { - while (!m_shutdownThread.load(std::memory_order::relaxed)) + while (m_threadsActive.load(std::memory_order::relaxed)) { s_compilationQueueCount.decrementWithWait(); s_compilationQueueMutex.lock(); @@ -181,7 +180,7 @@ public: } } - bool HasThreadsRunning() const { return !m_shutdownThread; } + bool HasThreadsRunning() const { return m_threadsActive; } public: std::vector s_threads; @@ -191,7 +190,7 @@ public: std::mutex s_compilationQueueMutex; private: - std::atomic m_shutdownThread; + std::atomic m_threadsActive; }ShaderVkThreadPool; RendererShaderVk::RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxHash, bool isGameShader, bool isGfxPackShader, const std::string& glslCode) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 5285e4ac..876baa07 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -600,7 +600,7 @@ VulkanRenderer::~VulkanRenderer() SubmitCommandBuffer(); WaitDeviceIdle(); WaitCommandBufferFinished(GetCurrentCommandBufferId()); - // shut down compilation threads + // make sure compilation threads have been shut down RendererShaderVk::Shutdown(); // shut down pipeline save thread m_destructionRequested = true; @@ -1558,12 +1558,12 @@ void VulkanRenderer::Shutdown() Renderer::Shutdown(); SubmitCommandBuffer(); WaitDeviceIdle(); - if (m_imguiRenderPass != VK_NULL_HANDLE) { vkDestroyRenderPass(m_logicalDevice, m_imguiRenderPass, nullptr); m_imguiRenderPass = VK_NULL_HANDLE; } + RendererShaderVk::Shutdown(); } void VulkanRenderer::UnrecoverableError(const char* errMsg) const From a50e25300d1c3d4eec9ba3085067facff035815f Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:01:37 +0100 Subject: [PATCH 109/314] Vulkan: Remove unused code path for texture copies In 2020 we switched to drawcalls for texture copies replacing the copy-via-buffer path. It's not been used since so lets remove it --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 14 -- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 6 - .../Renderer/Vulkan/VulkanSurfaceCopy.cpp | 127 +----------------- 3 files changed, 1 insertion(+), 146 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 876baa07..c7f8c043 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -577,20 +577,6 @@ VulkanRenderer::VulkanRenderer() for (sint32 i = 0; i < OCCLUSION_QUERY_POOL_SIZE; i++) m_occlusionQueries.list_availableQueryIndices.emplace_back(i); - // enable surface copies via buffer if we have plenty of memory available (otherwise use drawcalls) - size_t availableSurfaceCopyBufferMem = memoryManager->GetTotalMemoryForBufferType(VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - //m_featureControl.mode.useBufferSurfaceCopies = availableSurfaceCopyBufferMem >= 2000ull * 1024ull * 1024ull; // enable if at least 2000MB VRAM - m_featureControl.mode.useBufferSurfaceCopies = false; - - if (m_featureControl.mode.useBufferSurfaceCopies) - { - //cemuLog_log(LogType::Force, "Enable surface copies via buffer"); - } - else - { - //cemuLog_log(LogType::Force, "Disable surface copies via buffer (Requires 2GB. Has only {}MB available)", availableSurfaceCopyBufferMem / 1024ull / 1024ull); - } - // start compilation threads RendererShaderVk::Init(); } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 479c9e54..226edad6 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -311,7 +311,6 @@ public: void surfaceCopy_notifyTextureRelease(LatteTextureVk* hostTexture); private: - void surfaceCopy_viaBuffer(LatteTextureVk* srcTextureVk, sint32 texSrcMip, sint32 texSrcLevel, LatteTextureVk* dstTextureVk, sint32 texDstMip, sint32 texDstLevel, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight); void surfaceCopy_viaDrawcall(LatteTextureVk* srcTextureVk, sint32 texSrcMip, sint32 texSrcSlice, LatteTextureVk* dstTextureVk, sint32 texDstMip, sint32 texDstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight); void surfaceCopy_cleanup(); @@ -328,10 +327,6 @@ private: std::unordered_map m_copySurfacePipelineCache; - VkBuffer m_surfaceCopyBuffer = VK_NULL_HANDLE; - VkDeviceMemory m_surfaceCopyBufferMemory = VK_NULL_HANDLE; - size_t m_surfaceCopyBufferSize{}; - public: // renderer interface void bufferCache_init(const sint32 bufferSize) override; @@ -470,7 +465,6 @@ private: struct { - bool useBufferSurfaceCopies; // if GPU has enough VRAM to spare, allow to use a buffer to copy surfaces (instead of drawcalls) bool useTFEmulationViaSSBO = true; // emulate transform feedback via shader writes to a storage buffer }mode; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp index d89cdaa1..479b7e60 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp @@ -763,110 +763,6 @@ bool vkIsBitCompatibleColorDepthFormat(VkFormat format1, VkFormat format2) return false; } -void VulkanRenderer::surfaceCopy_viaBuffer(LatteTextureVk* srcTextureVk, sint32 texSrcMip, sint32 texSrcSlice, LatteTextureVk* dstTextureVk, sint32 texDstMip, sint32 texDstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight) -{ - cemu_assert_debug(false); // not used currently - - cemu_assert_debug(m_featureControl.mode.useBufferSurfaceCopies); - - if (srcTextureVk->dim == Latte::E_DIM::DIM_3D) - { - cemu_assert_debug(false); - return; - } - if (dstTextureVk->dim == Latte::E_DIM::DIM_3D) - { - cemu_assert_debug(false); - return; - } - - draw_endRenderPass(); - - // calculate buffer size required for copy - VkDeviceSize copySize = std::max(srcTextureVk->getAllocation()->getAllocationSize(), dstTextureVk->getAllocation()->getAllocationSize()); - - // make sure allocated buffer is large enough - if (m_surfaceCopyBuffer == VK_NULL_HANDLE || copySize > m_surfaceCopyBufferSize) - { - if (m_surfaceCopyBuffer != VK_NULL_HANDLE) - { - // free existing buffer - destroyDeviceMemory(m_surfaceCopyBufferMemory); - m_surfaceCopyBufferMemory = VK_NULL_HANDLE; - destroyBuffer(m_surfaceCopyBuffer); - m_surfaceCopyBuffer = VK_NULL_HANDLE; - } - VkDeviceSize allocSize = (copySize + 1024ull * 1024ull - 1ull) & ~(1024ull * 1024ull - 1ull); // align to whole MB - m_surfaceCopyBufferSize = allocSize; - memoryManager->CreateBuffer(m_surfaceCopyBufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, m_surfaceCopyBuffer, m_surfaceCopyBufferMemory); - if (m_surfaceCopyBuffer == VK_NULL_HANDLE) - { - cemuLog_log(LogType::Force, "Vulkan: Failed to allocate surface copy buffer with size {}", allocSize); - return; - } - } - if (m_surfaceCopyBuffer == VK_NULL_HANDLE) - return; - - auto vkObjSrcTexture = srcTextureVk->GetImageObj(); - auto vkObjDstTexture = dstTextureVk->GetImageObj(); - vkObjSrcTexture->flagForCurrentCommandBuffer(); - vkObjDstTexture->flagForCurrentCommandBuffer(); - - VkBufferImageCopy region{}; - region.bufferOffset = 0; - region.bufferRowLength = effectiveCopyWidth; - region.bufferImageHeight = effectiveCopyHeight; - - if (srcTextureVk->isDepth) - region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - else - region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - region.imageSubresource.baseArrayLayer = texSrcSlice; - region.imageSubresource.layerCount = 1; - region.imageSubresource.mipLevel = texSrcMip; - - region.imageOffset = { 0,0,0 }; - region.imageExtent = { (uint32)effectiveCopyWidth, (uint32)effectiveCopyHeight, 1 }; - - // make sure all write operations to the src image have finished - barrier_image(srcTextureVk, region.imageSubresource, VK_IMAGE_LAYOUT_GENERAL); - - vkCmdCopyImageToBuffer(getCurrentCommandBuffer(), vkObjSrcTexture->m_image, VK_IMAGE_LAYOUT_GENERAL, m_surfaceCopyBuffer, 1, ®ion); - - // copy buffer to image - - VkBufferImageCopy imageRegion[2]{}; - sint32 imageRegionCount = 0; - - // color or depth only copy - imageRegion[0].bufferOffset = 0; - imageRegion[0].imageExtent.width = effectiveCopyWidth; - imageRegion[0].imageExtent.height = effectiveCopyHeight; - imageRegion[0].imageExtent.depth = 1; - - imageRegion[0].imageSubresource.mipLevel = texDstMip; - if (dstTextureVk->isDepth) - imageRegion[0].imageSubresource.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - else - imageRegion[0].imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - imageRegion[0].imageSubresource.baseArrayLayer = texDstSlice; - imageRegion[0].imageSubresource.layerCount = 1; - - imageRegionCount = 1; - - // make sure the transfer to the buffer finished - barrier_bufferRange(m_surfaceCopyBuffer, 0, VK_WHOLE_SIZE); - - // make sure all read and write operations to the dst image have finished - barrier_image(dstTextureVk, imageRegion[0].imageSubresource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - vkCmdCopyBufferToImage(m_state.currentCommandBuffer, m_surfaceCopyBuffer, vkObjDstTexture->m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, imageRegionCount, imageRegion); - - // make sure transfer has finished before any other operation - barrier_image(dstTextureVk, imageRegion[0].imageSubresource, VK_IMAGE_LAYOUT_GENERAL); -} - void VulkanRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* sourceTexture, sint32 srcMip, sint32 srcSlice, LatteTexture* destinationTexture, sint32 dstMip, sint32 dstSlice, sint32 width, sint32 height) { // scale copy size to effective size @@ -899,28 +795,7 @@ void VulkanRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* s return; } - VkFormat srcFormatVk = srcTextureVk->GetFormat(); - VkFormat dstFormatVk = dstTextureVk->GetFormat(); - - if ((srcTextureVk->isDepth && !dstTextureVk->isDepth) || - !srcTextureVk->isDepth && dstTextureVk->isDepth) - { - // depth to color or - // color to depth - if (m_featureControl.mode.useBufferSurfaceCopies && vkIsBitCompatibleColorDepthFormat(srcFormatVk, dstFormatVk)) - surfaceCopy_viaBuffer(srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight); - else - surfaceCopy_viaDrawcall(srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight); - } - else - { - // depth to depth or - // color to color - if (m_featureControl.mode.useBufferSurfaceCopies && srcFormatVk == dstFormatVk) - surfaceCopy_viaBuffer(srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight); - else - surfaceCopy_viaDrawcall(srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight); - } + surfaceCopy_viaDrawcall(srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight); } // called whenever a texture is destroyed From 224866c3d218995458d957c1c3777313e289da63 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 12 Mar 2024 01:37:07 +0100 Subject: [PATCH 110/314] CI: Work around a vcpkg issue by checking out an earlier commit --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00aac0fe..f3b834b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: run: | cd dependencies/vcpkg git fetch --unshallow - git pull --all + git checkout 431eb6bda0950874c8d4ed929cc66e15d8aae46f - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} @@ -133,7 +133,7 @@ jobs: run: | cd dependencies/vcpkg git fetch --unshallow - git pull --all + git checkout 431eb6bda0950874c8d4ed929cc66e15d8aae46f - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} From 6fa77feba3ec7437b57b6c4c221cde9eb07cd399 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 12 Mar 2024 05:52:53 +0100 Subject: [PATCH 111/314] Latte: Fix regression in dd7cb74 --- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 8c29ccc5..d7c5408f 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -618,7 +618,7 @@ bool LatteMRT::UpdateCurrentFBO() } // set effective size sint32 effectiveWidth, effectiveHeight; - depthBufferView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, depthBufferViewFirstSlice); + depthBufferView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); if (rtEffectiveSize->width == 0 && rtEffectiveSize->height == 0) { rtEffectiveSize->width = effectiveWidth; diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index b35f608c..4e5c303c 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -206,7 +206,11 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u bool isDepthSampler = shaderContext->textureUsesDepthCompare[textureIndex]; // look for already existing texture - LatteTextureView* textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, isDepthSampler); + LatteTextureView* textureView; + if (isDepthSampler == false) + textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim); + else + textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, true); if (!textureView) { // view not found, create a new mapping which will also create a new texture if necessary From 8bc444bb97cfeb747a66142ad31884323785af32 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:16:52 +0100 Subject: [PATCH 112/314] Latte: Derive framebuffer size from correct mip of depth buffer --- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 4 ++-- src/Cafe/HW/Latte/Core/LatteTextureView.cpp | 3 +-- src/Cafe/HW/Latte/Core/LatteTextureView.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index d7c5408f..f84bbecd 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -618,7 +618,7 @@ bool LatteMRT::UpdateCurrentFBO() } // set effective size sint32 effectiveWidth, effectiveHeight; - depthBufferView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); + depthBufferView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, depthBufferView->firstMip); if (rtEffectiveSize->width == 0 && rtEffectiveSize->height == 0) { rtEffectiveSize->width = effectiveWidth; diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index 4e5c303c..b9ccbac4 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -207,10 +207,10 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u bool isDepthSampler = shaderContext->textureUsesDepthCompare[textureIndex]; // look for already existing texture LatteTextureView* textureView; - if (isDepthSampler == false) + if (!isDepthSampler) textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim); else - textureView = LatteTextureViewLookupCache::lookup(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, true); + textureView = LatteTextureViewLookupCache::lookupWithColorOrDepthType(physAddr, width, height, depth, pitch, viewFirstMip, viewNumMips, viewFirstSlice, viewNumSlices, format, dim, true); if (!textureView) { // view not found, create a new mapping which will also create a new texture if necessary diff --git a/src/Cafe/HW/Latte/Core/LatteTextureView.cpp b/src/Cafe/HW/Latte/Core/LatteTextureView.cpp index cac5bcce..2773a34d 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureView.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureView.cpp @@ -143,7 +143,6 @@ void LatteTextureViewLookupCache::RemoveAll(LatteTextureView* view) } } - LatteTextureView* LatteTextureViewLookupCache::lookup(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim) { // todo - add tileMode param to this and the other lookup functions? @@ -163,7 +162,7 @@ LatteTextureView* LatteTextureViewLookupCache::lookup(MPTR physAddr, sint32 widt return nullptr; } -LatteTextureView* LatteTextureViewLookupCache::lookup(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, bool isDepth) +LatteTextureView* LatteTextureViewLookupCache::lookupWithColorOrDepthType(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, bool isDepth) { cemu_assert_debug(firstSlice == 0); uint32 key = _getViewBucketKey(physAddr, width, height, pitch); diff --git a/src/Cafe/HW/Latte/Core/LatteTextureView.h b/src/Cafe/HW/Latte/Core/LatteTextureView.h index a6d2e16c..abda084a 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureView.h +++ b/src/Cafe/HW/Latte/Core/LatteTextureView.h @@ -41,7 +41,7 @@ public: static void RemoveAll(LatteTextureView* view); static LatteTextureView* lookup(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim); - static LatteTextureView* lookup(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, bool isDepth); + static LatteTextureView* lookupWithColorOrDepthType(MPTR physAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, bool isDepth); static LatteTextureView* lookupSlice(MPTR physAddr, sint32 width, sint32 height, sint32 pitch, sint32 firstMip, sint32 firstSlice, Latte::E_GX2SURFFMT format); static LatteTextureView* lookupSliceMinSize(MPTR physAddr, sint32 minWidth, sint32 minHeight, sint32 pitch, sint32 firstMip, sint32 firstSlice, Latte::E_GX2SURFFMT format); static LatteTextureView* lookupSliceEx(MPTR physAddr, sint32 width, sint32 height, sint32 pitch, sint32 firstMip, sint32 firstSlice, Latte::E_GX2SURFFMT format, bool isDepth); From bc04662525acbab50251a28a0a2b39d95fda7707 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Mar 2024 02:41:42 +0100 Subject: [PATCH 113/314] Latte+GL+VK: Improve handling of gfx pack texture overwrite format Graphic packs can overwrite the format of a texture (e.g. for higher bitdepth to lessen banding) but the code for this wasn't correctly working anymore. - Fixes overwrite format being ignored for texture views on Vulkan backend - Fixes overwrite format not being used for texture views on OpenGL Format aliasing is complicated enough as it is, even without overwrites, so this adds a new rule to make behavior more well defined: If two textures share memory but only one uses an overwrite format, then they are no longer synchronized and are considered separate textures. Bonus fixes for OpenGL: - Use fbo 0 instead of -1 as the default. This silences some warnings in debug output - On OpenGL, bind new framebuffers on handle generation so they are considered created --- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 11 ++++++ .../Latte/Renderer/OpenGL/LatteTextureGL.cpp | 2 +- .../Renderer/OpenGL/LatteTextureViewGL.cpp | 14 ++++--- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 37 ++++++++++--------- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 2 +- .../Renderer/Vulkan/LatteTextureViewVk.cpp | 7 +++- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 91a1aa56..21b49c9a 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -434,6 +434,11 @@ void LatteTexture_SyncSlice(LatteTexture* srcTexture, sint32 srcSliceIndex, sint sint32 dstWidth = dstTexture->width; sint32 dstHeight = dstTexture->height; + if(srcTexture->overwriteInfo.hasFormatOverwrite != dstTexture->overwriteInfo.hasFormatOverwrite) + return; // dont sync: format overwrite state needs to match. Not strictly necessary but it simplifies logic down the road + else if(srcTexture->overwriteInfo.hasFormatOverwrite && srcTexture->overwriteInfo.format != dstTexture->overwriteInfo.format) + return; // both are overwritten but with different formats + if (srcMipIndex == 0 && dstMipIndex == 0 && (srcTexture->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED || srcTexture->tileMode == Latte::E_HWTILEMODE::TM_1D_TILED_THIN1) && srcTexture->height > dstTexture->height && (srcTexture->height % dstTexture->height) == 0) { bool isMatch = srcTexture->tileMode == Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED; @@ -816,6 +821,12 @@ VIEWCOMPATIBILITY LatteTexture_CanTextureBeRepresentedAsView(LatteTexture* baseT { relativeMipIndex = 0; relativeSliceIndex = 0; + if (baseTexture->overwriteInfo.hasFormatOverwrite) + { + // if the base format is overwritten, then we only allow aliasing if the view format matches the base format + if (baseTexture->format != format) + return VIEW_NOT_COMPATIBLE; + } if (LatteTexture_IsFormatViewCompatible(baseTexture->format, format) == false) return VIEW_NOT_COMPATIBLE; if (baseTexture->physAddress == physAddr && baseTexture->pitch == pitch) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp index 584af40c..cd363612 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp @@ -26,7 +26,7 @@ LatteTextureGL::LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipA GenerateEmptyTextureFromGX2Dim(dim, this->glId_texture, this->glTexTarget, true); // set format info FormatInfoGL glFormatInfo; - GetOpenGLFormatInfo(isDepth, format, dim, &glFormatInfo); + GetOpenGLFormatInfo(isDepth, overwriteInfo.hasFormatOverwrite ? (Latte::E_GX2SURFFMT)overwriteInfo.format : format, dim, &glFormatInfo); this->glInternalFormat = glFormatInfo.glInternalFormat; this->isAlternativeFormat = glFormatInfo.isUsingAlternativeFormat; this->hasStencil = glFormatInfo.hasStencil; // todo - should get this from the GX2 format? diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp index 29085642..3e8abe8e 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp @@ -55,12 +55,16 @@ LatteTextureViewGL::~LatteTextureViewGL() void LatteTextureViewGL::InitAliasView() { const auto texture = (LatteTextureGL*)baseTexture; - // get internal format - if (baseTexture->isDepth) + // compute internal format + if(texture->overwriteInfo.hasFormatOverwrite) + { + cemu_assert_debug(format == texture->format); + glInternalFormat = texture->glInternalFormat; // for format overwrite no aliasing is allowed and thus we always inherit the internal format of the base texture + } + else if (baseTexture->isDepth) { // depth is handled differently - cemuLog_logDebug(LogType::Force, "Creating depth view"); - cemu_assert(format == texture->format); // todo + cemu_assert(format == texture->format); // is depth alias with different format intended? glInternalFormat = texture->glInternalFormat; } else @@ -73,7 +77,7 @@ void LatteTextureViewGL::InitAliasView() catchOpenGLError(); if (firstMip >= texture->maxPossibleMipLevels) { - cemuLog_logDebug(LogType::Force, "_createNewView: Out of bounds mip level requested"); + cemuLog_logDebug(LogType::Force, "InitAliasView(): Out of bounds mip level requested"); glTextureView(glTexId, glTexTarget, texture->glId_texture, glInternalFormat, texture->maxPossibleMipLevels - 1, numMip, firstSlice, this->numSlice); } else diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 68d7def6..943e39a0 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -330,13 +330,14 @@ void OpenGLRenderer::Initialize() lock.unlock(); // create framebuffer for fast clearing (avoid glClearTexSubImage on Nvidia) - if (this->m_vendor == GfxVendor::Nvidia || glClearTexSubImage == nullptr) + if (glCreateFramebuffers) + glCreateFramebuffers(1, &glRendererState.clearFBO); + else { - // generate framebuffer - if (glCreateFramebuffers && false) - glCreateFramebuffers(1, &glRendererState.clearFBO); - else - glGenFramebuffers(1, &glRendererState.clearFBO); + glGenFramebuffers(1, &glRendererState.clearFBO); + // bind to initialize + glBindFramebuffer(GL_FRAMEBUFFER_EXT, glRendererState.clearFBO); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); } draw_init(); @@ -425,9 +426,12 @@ void _glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GL return; if (LatteGPUState.glVendor == GLVENDOR_NVIDIA && strstr(message, "Dithering is enabled")) return; - + if (LatteGPUState.glVendor == GLVENDOR_NVIDIA && strstr(message, "Blending is enabled, but is not supported for integer framebuffers")) + return; if (LatteGPUState.glVendor == GLVENDOR_NVIDIA && strstr(message, "does not have a defined base level")) return; + if(LatteGPUState.glVendor == GLVENDOR_NVIDIA && strstr(message, "has depth comparisons disabled, with a texture object")) + return; cemuLog_log(LogType::Force, "GLDEBUG: {}", message); @@ -670,7 +674,10 @@ void OpenGLRenderer::rendertarget_deleteCachedFBO(LatteCachedFBO* cfbo) { auto cfboGL = (CachedFBOGL*)cfbo; if (prevBoundFBO == cfboGL->glId_fbo) - prevBoundFBO = -1; + { + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + prevBoundFBO = 0; + } glDeleteFramebuffers(1, &cfboGL->glId_fbo); } @@ -1013,9 +1020,6 @@ void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTextureGeneri effectiveBaseHeight = hostTexture->overwriteInfo.height; effectiveBaseDepth = hostTexture->overwriteInfo.depth; } - // get format info - LatteTextureGL::FormatInfoGL glFormatInfo; - LatteTextureGL::GetOpenGLFormatInfo(hostTexture->isDepth, hostTexture->overwriteInfo.hasFormatOverwrite ? (Latte::E_GX2SURFFMT)hostTexture->overwriteInfo.format : hostTexture->format, hostTexture->dim, &glFormatInfo); // calculate mip count sint32 mipLevels = std::min(hostTexture->mipLevels, hostTexture->maxPossibleMipLevels); mipLevels = std::max(mipLevels, 1); @@ -1023,25 +1027,25 @@ void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTextureGeneri if (hostTexture->dim == Latte::E_DIM::DIM_2D || hostTexture->dim == Latte::E_DIM::DIM_2D_MSAA) { cemu_assert_debug(effectiveBaseDepth == 1); - glTextureStorage2DWrapper(GL_TEXTURE_2D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); + glTextureStorage2DWrapper(GL_TEXTURE_2D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); } else if (hostTexture->dim == Latte::E_DIM::DIM_1D) { cemu_assert_debug(effectiveBaseHeight == 1); cemu_assert_debug(effectiveBaseDepth == 1); - glTextureStorage1DWrapper(GL_TEXTURE_1D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth); + glTextureStorage1DWrapper(GL_TEXTURE_1D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth); } else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) { - glTextureStorage3DWrapper(GL_TEXTURE_2D_ARRAY, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + glTextureStorage3DWrapper(GL_TEXTURE_2D_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); } else if (hostTexture->dim == Latte::E_DIM::DIM_3D) { - glTextureStorage3DWrapper(GL_TEXTURE_3D, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + glTextureStorage3DWrapper(GL_TEXTURE_3D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); } else if (hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) { - glTextureStorage3DWrapper(GL_TEXTURE_CUBE_MAP_ARRAY, hostTexture->glId_texture, mipLevels, glFormatInfo.glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); + glTextureStorage3DWrapper(GL_TEXTURE_CUBE_MAP_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); } else { @@ -1279,7 +1283,6 @@ void OpenGLRenderer::texture_copyImageSubData(LatteTexture* src, sint32 srcMip, { auto srcGL = (LatteTextureGL*)src; auto dstGL = (LatteTextureGL*)dst; - if ((srcGL->isAlternativeFormat || dstGL->isAlternativeFormat) && (srcGL->glInternalFormat != dstGL->glInternalFormat)) { if (srcGL->format == Latte::E_GX2SURFFMT::R16_G16_B16_A16_UINT && dstGL->format == Latte::E_GX2SURFFMT::BC4_UNORM) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index 8a4b1a1d..026264cf 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -195,7 +195,7 @@ private: GLuint glStreamoutCacheRingBuffer; // cfbo - GLuint prevBoundFBO = -1; + GLuint prevBoundFBO = 0; GLuint glId_fbo = 0; // renderstate diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp index d87d9ea7..aae7e9d1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp @@ -57,7 +57,12 @@ uint32 LatteTextureVk_AdjustTextureCompSel(Latte::E_GX2SURFFMT format, uint32 co LatteTextureViewVk::LatteTextureViewVk(VkDevice device, LatteTextureVk* texture, Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) : LatteTextureView(texture, firstMip, mipCount, firstSlice, sliceCount, dim, format), m_device(device) { - if (dim != texture->dim || format != texture->format) + if(texture->overwriteInfo.hasFormatOverwrite) + { + cemu_assert_debug(format == texture->format); // if format overwrite is used, the texture is no longer taking part in aliasing and the format of any view has to match + m_format = texture->GetFormat(); + } + else if (dim != texture->dim || format != texture->format) { VulkanRenderer::FormatInfoVK texFormatInfo; VulkanRenderer::GetInstance()->GetTextureFormatInfoVK(format, texture->isDepth, dim, 0, 0, &texFormatInfo); From 193767e6cccafd971e9028386fdfe7f8f46b2d21 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 14 Mar 2024 01:04:05 +0100 Subject: [PATCH 114/314] Latte+Vulkan: Code cleanup Besides a general cleanup: - Remove deprecated resource destruction queues - Move functionality from renderer into Latte base classes to deduplicate code --- src/Cafe/HW/Latte/Core/Latte.h | 2 +- .../HW/Latte/Core/LatteCommandProcessor.cpp | 12 +-- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 43 ++------- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 10 +++ src/Cafe/HW/Latte/Core/LatteTexture.h | 2 + src/Cafe/HW/Latte/Core/LatteTextureCache.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp | 2 +- .../Latte/Renderer/OpenGL/LatteTextureGL.cpp | 73 +++++++++++----- .../HW/Latte/Renderer/OpenGL/LatteTextureGL.h | 12 +-- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 51 ----------- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 3 - src/Cafe/HW/Latte/Renderer/Renderer.h | 3 - .../HW/Latte/Renderer/Vulkan/CachedFBOVk.cpp | 4 +- .../Renderer/Vulkan/LatteTextureViewVk.cpp | 6 +- .../Latte/Renderer/Vulkan/LatteTextureVk.cpp | 14 ++- .../HW/Latte/Renderer/Vulkan/LatteTextureVk.h | 5 +- .../Renderer/Vulkan/RendererShaderVk.cpp | 3 +- .../Latte/Renderer/Vulkan/VKRPipelineInfo.cpp | 2 +- .../Vulkan/VulkanPipelineStableCache.cpp | 2 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 87 +------------------ .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 25 +----- .../Renderer/Vulkan/VulkanSurfaceCopy.cpp | 8 +- src/imgui/imgui_impl_vulkan.cpp | 13 +-- 23 files changed, 115 insertions(+), 269 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/Latte.h b/src/Cafe/HW/Latte/Core/Latte.h index dc3cbc91..d9419a6a 100644 --- a/src/Cafe/HW/Latte/Core/Latte.h +++ b/src/Cafe/HW/Latte/Core/Latte.h @@ -98,7 +98,7 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa void LatteRenderTarget_GetCurrentVirtualViewportSize(sint32* viewportWidth, sint32* viewportHeight); void LatteRenderTarget_itHLESwapScanBuffer(); -void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, MPTR colorBufferMPTR, MPTR colorBufferFormat, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferPitch, uint32 colorBufferViewFirstSlice, uint32 colorBufferViewNumSlice, MPTR depthBufferMPTR, MPTR depthBufferFormat, Latte::E_HWTILEMODE depthBufferTileMode, sint32 depthBufferWidth, sint32 depthBufferHeight, sint32 depthBufferPitch, sint32 depthBufferViewFirstSlice, sint32 depthBufferViewNumSlice, float r, float g, float b, float a, float clearDepth, uint32 clearStencil); +void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, MPTR colorBufferMPTR, Latte::E_GX2SURFFMT colorBufferFormat, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferPitch, uint32 colorBufferViewFirstSlice, uint32 colorBufferViewNumSlice, MPTR depthBufferMPTR, Latte::E_GX2SURFFMT depthBufferFormat, Latte::E_HWTILEMODE depthBufferTileMode, sint32 depthBufferWidth, sint32 depthBufferHeight, sint32 depthBufferPitch, sint32 depthBufferViewFirstSlice, sint32 depthBufferViewNumSlice, float r, float g, float b, float a, float clearDepth, uint32 clearStencil); void LatteRenderTarget_itHLECopyColorBufferToScanBuffer(MPTR colorBufferPtr, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferSliceIndex, uint32 colorBufferFormat, uint32 colorBufferPitch, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferSwizzle, uint32 renderTarget); void LatteRenderTarget_unloadAll(); diff --git a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp index 60e5935c..c928f89f 100644 --- a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp +++ b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp @@ -864,8 +864,8 @@ LatteCMDPtr LatteCP_itHLEClearColorDepthStencil(LatteCMDPtr cmd, uint32 nWords) cemu_assert_debug(nWords == 23); uint32 clearMask = LatteReadCMD(); // color (1), depth (2), stencil (4) // color buffer - MPTR colorBufferMPTR = LatteReadCMD(); // MPTR for color buffer (physical address) - MPTR colorBufferFormat = LatteReadCMD(); // format for color buffer + MPTR colorBufferMPTR = LatteReadCMD(); // physical address for color buffer + Latte::E_GX2SURFFMT colorBufferFormat = (Latte::E_GX2SURFFMT)LatteReadCMD(); Latte::E_HWTILEMODE colorBufferTilemode = (Latte::E_HWTILEMODE)LatteReadCMD(); uint32 colorBufferWidth = LatteReadCMD(); uint32 colorBufferHeight = LatteReadCMD(); @@ -873,8 +873,8 @@ LatteCMDPtr LatteCP_itHLEClearColorDepthStencil(LatteCMDPtr cmd, uint32 nWords) uint32 colorBufferViewFirstSlice = LatteReadCMD(); uint32 colorBufferViewNumSlice = LatteReadCMD(); // depth buffer - MPTR depthBufferMPTR = LatteReadCMD(); // MPTR for depth buffer (physical address) - MPTR depthBufferFormat = LatteReadCMD(); // format for depth buffer + MPTR depthBufferMPTR = LatteReadCMD(); // physical address for depth buffer + Latte::E_GX2SURFFMT depthBufferFormat = (Latte::E_GX2SURFFMT)LatteReadCMD(); Latte::E_HWTILEMODE depthBufferTileMode = (Latte::E_HWTILEMODE)LatteReadCMD(); uint32 depthBufferWidth = LatteReadCMD(); uint32 depthBufferHeight = LatteReadCMD(); @@ -893,8 +893,8 @@ LatteCMDPtr LatteCP_itHLEClearColorDepthStencil(LatteCMDPtr cmd, uint32 nWords) LatteRenderTarget_itHLEClearColorDepthStencil( clearMask, - colorBufferMPTR, colorBufferFormat, colorBufferTilemode, colorBufferWidth, colorBufferHeight, colorBufferPitch, colorBufferViewFirstSlice, colorBufferViewNumSlice, - depthBufferMPTR, depthBufferFormat, depthBufferTileMode, depthBufferWidth, depthBufferHeight, depthBufferPitch, depthBufferViewFirstSlice, depthBufferViewNumSlice, + colorBufferMPTR, colorBufferFormat, colorBufferTilemode, colorBufferWidth, colorBufferHeight, colorBufferPitch, colorBufferViewFirstSlice, colorBufferViewNumSlice, + depthBufferMPTR, depthBufferFormat, depthBufferTileMode, depthBufferWidth, depthBufferHeight, depthBufferPitch, depthBufferViewFirstSlice, depthBufferViewNumSlice, r, g, b, a, clearDepth, clearStencil); return cmd; diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index f84bbecd..30069712 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -221,35 +221,9 @@ void LatteMRT::BindDepthBufferOnly(LatteTextureView* view) ApplyCurrentState(); } -/***************************************************/ - -LatteTextureView* LatteMRT_FindColorBufferForClearing(MPTR colorBufferPtr, sint32 colorBufferWidth, sint32 colorBufferHeight, sint32 colorBufferPitch, uint32 format, sint32 sliceIndex, sint32* searchIndex) -{ - LatteTextureView* view = LatteTC_LookupTextureByData(colorBufferPtr, colorBufferWidth, colorBufferHeight, colorBufferPitch, 0, 1, sliceIndex, 1, searchIndex); - if (view == nullptr) - return nullptr; - return view; -} - -LatteTextureView* LatteMRT_CreateColorBuffer(MPTR colorBufferPhysMem, uint32 width, uint32 height, uint32 pitch, Latte::E_GX2SURFFMT format, Latte::E_HWTILEMODE tileMode, uint32 swizzle, uint32 viewSlice) -{ - cemu_assert_debug(colorBufferPhysMem != MPTR_NULL); - LatteTextureView* textureView; - if(viewSlice != 0) - textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, false); - else - textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, 1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false); - return textureView; -} - LatteTextureView* LatteMRT_CreateDepthBuffer(MPTR depthBufferPhysMem, uint32 width, uint32 height, uint32 pitch, Latte::E_HWTILEMODE tileMode, Latte::E_GX2SURFFMT format, uint32 swizzle, sint32 viewSlice) { - LatteTextureView* textureView; - if(viewSlice == 0) - textureView = LatteTexture_CreateMapping(depthBufferPhysMem, MPTR_NULL, width, height, 1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); - else - textureView = LatteTexture_CreateMapping(depthBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, true); - + LatteTextureView* textureView = LatteTexture_CreateMapping(depthBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, viewSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); LatteMRT::SetDepthAndStencilAttachment(textureView, textureView->baseTexture->hasStencil); return textureView; } @@ -605,7 +579,7 @@ bool LatteMRT::UpdateCurrentFBO() if (depthBufferPhysMem != MPTR_NULL) { LatteTextureView* depthBufferView = LatteTextureViewLookupCache::lookupSliceEx(depthBufferPhysMem, depthBufferWidth, depthBufferHeight, depthBufferPitch, 0, depthBufferViewFirstSlice, depthBufferFormat, true); - if (depthBufferView == nullptr) + if (!depthBufferView) { // create new depth buffer view and if it doesn't exist then also create the texture depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, depthBufferViewFirstSlice+1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, depthBufferViewFirstSlice, 1, depthBufferFormat, depthBufferViewFirstSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); @@ -768,7 +742,10 @@ void LatteRenderTarget_applyTextureDepthClear(LatteTexture* texture, uint32 slic LatteTexture_MarkDynamicTextureAsChanged(texture->baseView, sliceIndex, mipIndex, eventCounter); } -void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, MPTR colorBufferMPTR, MPTR colorBufferFormat, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferPitch, uint32 colorBufferViewFirstSlice, uint32 colorBufferViewNumSlice, MPTR depthBufferMPTR, MPTR depthBufferFormat, Latte::E_HWTILEMODE depthBufferTileMode, sint32 depthBufferWidth, sint32 depthBufferHeight, sint32 depthBufferPitch, sint32 depthBufferViewFirstSlice, sint32 depthBufferViewNumSlice, float r, float g, float b, float a, float clearDepth, uint32 clearStencil) +void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, + MPTR colorBufferMPTR, Latte::E_GX2SURFFMT colorBufferFormat, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferPitch, uint32 colorBufferViewFirstSlice, uint32 colorBufferViewNumSlice, + MPTR depthBufferMPTR, Latte::E_GX2SURFFMT depthBufferFormat, Latte::E_HWTILEMODE depthBufferTileMode, sint32 depthBufferWidth, sint32 depthBufferHeight, sint32 depthBufferPitch, sint32 depthBufferViewFirstSlice, sint32 depthBufferViewNumSlice, + float r, float g, float b, float a, float clearDepth, uint32 clearStencil) { uint32 depthBufferMipIndex = 0; // todo uint32 colorBufferMipIndex = 0; // todo @@ -803,13 +780,11 @@ void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, MPTR colorB bool targetFound = false; while (true) { - LatteTextureView* colorView = LatteMRT_FindColorBufferForClearing(colorBufferMPTR, colorBufferWidth, colorBufferHeight, colorBufferPitch, colorBufferFormat, colorBufferViewFirstSlice, &searchIndex); + LatteTextureView* colorView = LatteTC_LookupTextureByData(colorBufferMPTR, colorBufferWidth, colorBufferHeight, colorBufferPitch, 0, 1, colorBufferViewFirstSlice, 1, &searchIndex); if (!colorView) break; - if (Latte::GetFormatBits((Latte::E_GX2SURFFMT)colorBufferFormat) != Latte::GetFormatBits(colorView->baseTexture->format)) - { + if (Latte::GetFormatBits(colorBufferFormat) != Latte::GetFormatBits(colorView->baseTexture->format)) continue; - } if (colorView->baseTexture->pitch == colorBufferPitch && colorView->baseTexture->height == colorBufferHeight) targetFound = true; @@ -821,7 +796,7 @@ void LatteRenderTarget_itHLEClearColorDepthStencil(uint32 clearMask, MPTR colorB { // create new texture with matching format cemu_assert_debug(colorBufferViewNumSlice <= 1); - LatteTextureView* newColorView = LatteMRT_CreateColorBuffer(colorBufferMPTR, colorBufferWidth, colorBufferHeight, colorBufferPitch, (Latte::E_GX2SURFFMT)colorBufferFormat, colorBufferTilemode, colorBufferSwizzle, colorBufferViewFirstSlice); + LatteTextureView* newColorView = LatteTexture_CreateMapping(colorBufferMPTR, MPTR_NULL, colorBufferWidth, colorBufferHeight, colorBufferViewFirstSlice+1, colorBufferPitch, colorBufferTilemode, colorBufferSwizzle, 0, 1, colorBufferViewFirstSlice, 1, colorBufferFormat, colorBufferViewFirstSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false); LatteRenderTarget_applyTextureColorClear(newColorView->baseTexture, colorBufferViewFirstSlice, colorBufferMipIndex, r, g, b, a, eventCounter); } } diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 21b49c9a..d6f576d4 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -1199,6 +1199,15 @@ std::vector& LatteTexture::GetAllTextures() return sAllTextures; } +bool LatteTexture_GX2FormatHasStencil(bool isDepth, Latte::E_GX2SURFFMT format) +{ + if (!isDepth) + return false; + return format == Latte::E_GX2SURFFMT::D24_S8_UNORM || + format == Latte::E_GX2SURFFMT::D24_S8_FLOAT || + format == Latte::E_GX2SURFFMT::D32_S8_FLOAT; +} + LatteTexture::LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) { @@ -1217,6 +1226,7 @@ LatteTexture::LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddre this->mipLevels = mipLevels; this->tileMode = tileMode; this->isDepth = isDepth; + this->hasStencil = LatteTexture_GX2FormatHasStencil(isDepth, format); this->physMipAddress = physMipAddress; this->lastUpdateEventCounter = LatteTexture_getNextUpdateEventCounter(); this->lastWriteEventCounter = LatteTexture_getNextUpdateEventCounter(); diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.h b/src/Cafe/HW/Latte/Core/LatteTexture.h index b46c1323..6c09e840 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.h +++ b/src/Cafe/HW/Latte/Core/LatteTexture.h @@ -27,6 +27,8 @@ public: LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth); virtual ~LatteTexture(); + virtual void AllocateOnHost() = 0; + LatteTextureView* GetOrCreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) { for (auto& itr : views) diff --git a/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp b/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp index a71bd6a6..3145e90e 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureCache.cpp @@ -316,7 +316,7 @@ void LatteTexture_Delete(LatteTexture* texture) delete[] texture->sliceMipInfo; texture->sliceMipInfo = nullptr; } - g_renderer->texture_destroy(texture); + delete texture; } /* diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp index 862fff06..c06a3bf1 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp @@ -621,7 +621,7 @@ void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, uint32 sliceIn if (tex->isDataDefined == false) { - g_renderer->texture_reserveTextureOnGPU(tex); + tex->AllocateOnHost(); tex->isDataDefined = true; // if decoder is not set then clear texture // on Vulkan this is used to make sure the texture is no longer in UNDEFINED layout diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp index cd363612..58805925 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp @@ -5,20 +5,6 @@ #include "config/LaunchSettings.h" -GLuint texIdPool[64]; -sint32 texIdPoolIndex = 64; - -static GLuint _genTextureHandleGL() -{ - if (texIdPoolIndex == 64) - { - glGenTextures(64, texIdPool); - texIdPoolIndex = 0; - } - texIdPoolIndex++; - return texIdPool[texIdPoolIndex - 1]; -} - LatteTextureGL::LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth) : LatteTexture(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth) @@ -29,7 +15,6 @@ LatteTextureGL::LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipA GetOpenGLFormatInfo(isDepth, overwriteInfo.hasFormatOverwrite ? (Latte::E_GX2SURFFMT)overwriteInfo.format : format, dim, &glFormatInfo); this->glInternalFormat = glFormatInfo.glInternalFormat; this->isAlternativeFormat = glFormatInfo.isUsingAlternativeFormat; - this->hasStencil = glFormatInfo.hasStencil; // todo - should get this from the GX2 format? // set debug name bool useGLDebugNames = false; #ifdef CEMU_DEBUG_ASSERT @@ -88,34 +73,34 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma { if (format == Latte::E_GX2SURFFMT::D24_S8_UNORM) { - formatInfoOut->setDepthFormat(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, true); + formatInfoOut->setFormat(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); return; } else if (format == Latte::E_GX2SURFFMT::D24_S8_FLOAT) { - formatInfoOut->setDepthFormat(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, true); + formatInfoOut->setFormat(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV); formatInfoOut->markAsAlternativeFormat(); return; } else if (format == Latte::E_GX2SURFFMT::D32_S8_FLOAT) { - formatInfoOut->setDepthFormat(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, true); + formatInfoOut->setFormat(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV); return; } else if (format == Latte::E_GX2SURFFMT::D32_FLOAT) { - formatInfoOut->setDepthFormat(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false); + formatInfoOut->setFormat(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT); return; } else if (format == Latte::E_GX2SURFFMT::D16_UNORM) { - formatInfoOut->setDepthFormat(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, false); + formatInfoOut->setFormat(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT); return; } // unsupported depth format cemuLog_log(LogType::Force, "OpenGL: Unsupported texture depth format 0x{:04x}", (uint32)format); // use placeholder format - formatInfoOut->setDepthFormat(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, false); + formatInfoOut->setFormat(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT); formatInfoOut->markAsAlternativeFormat(); return; } @@ -496,3 +481,49 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma formatInfoOut->glIsCompressed = glIsCompressed; formatInfoOut->isUsingAlternativeFormat = isUsingAlternativeFormat; } + +void LatteTextureGL::AllocateOnHost() +{ + auto hostTexture = this; + cemu_assert_debug(hostTexture->isDataDefined == false); + sint32 effectiveBaseWidth = hostTexture->width; + sint32 effectiveBaseHeight = hostTexture->height; + sint32 effectiveBaseDepth = hostTexture->depth; + if (hostTexture->overwriteInfo.hasResolutionOverwrite) + { + effectiveBaseWidth = hostTexture->overwriteInfo.width; + effectiveBaseHeight = hostTexture->overwriteInfo.height; + effectiveBaseDepth = hostTexture->overwriteInfo.depth; + } + // calculate mip count + sint32 mipLevels = std::min(hostTexture->mipLevels, hostTexture->maxPossibleMipLevels); + mipLevels = std::max(mipLevels, 1); + // create immutable storage + if (hostTexture->dim == Latte::E_DIM::DIM_2D || hostTexture->dim == Latte::E_DIM::DIM_2D_MSAA) + { + cemu_assert_debug(effectiveBaseDepth == 1); + glTextureStorage2DWrapper(GL_TEXTURE_2D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); + } + else if (hostTexture->dim == Latte::E_DIM::DIM_1D) + { + cemu_assert_debug(effectiveBaseHeight == 1); + cemu_assert_debug(effectiveBaseDepth == 1); + glTextureStorage1DWrapper(GL_TEXTURE_1D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth); + } + else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) + { + glTextureStorage3DWrapper(GL_TEXTURE_2D_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + } + else if (hostTexture->dim == Latte::E_DIM::DIM_3D) + { + glTextureStorage3DWrapper(GL_TEXTURE_3D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); + } + else if (hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) + { + glTextureStorage3DWrapper(GL_TEXTURE_CUBE_MAP_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); + } + else + { + cemu_assert_unimplemented(); + } +} \ No newline at end of file diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h index 9169bb29..abfb0d43 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h @@ -11,6 +11,8 @@ public: ~LatteTextureGL(); + void AllocateOnHost() override; + static void GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget, bool createForTargetType); protected: @@ -23,7 +25,6 @@ public: sint32 glSuppliedFormat; sint32 glSuppliedFormatType; bool glIsCompressed; - bool hasStencil{}; bool isUsingAlternativeFormat{}; void setFormat(sint32 glInternalFormat, sint32 glSuppliedFormat, sint32 glSuppliedFormatType) @@ -34,15 +35,6 @@ public: this->glIsCompressed = false; } - void setDepthFormat(sint32 glInternalFormat, sint32 glSuppliedFormat, sint32 glSuppliedFormatType, bool hasStencil) - { - this->glInternalFormat = glInternalFormat; - this->glSuppliedFormat = glSuppliedFormat; - this->glSuppliedFormatType = glSuppliedFormatType; - this->glIsCompressed = false; - this->hasStencil = hasStencil; - } - void setCompressed(sint32 glInternalFormat, sint32 glSuppliedFormat, sint32 glSuppliedFormatType) { setFormat(glInternalFormat, glSuppliedFormat, glSuppliedFormatType); diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 943e39a0..604744cf 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -1002,57 +1002,6 @@ TextureDecoder* OpenGLRenderer::texture_chooseDecodedFormat(Latte::E_GX2SURFFMT return texDecoder; } -void OpenGLRenderer::texture_destroy(LatteTexture* hostTexture) -{ - delete hostTexture; -} - -void OpenGLRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTextureGeneric) -{ - auto hostTexture = (LatteTextureGL*)hostTextureGeneric; - cemu_assert_debug(hostTexture->isDataDefined == false); - sint32 effectiveBaseWidth = hostTexture->width; - sint32 effectiveBaseHeight = hostTexture->height; - sint32 effectiveBaseDepth = hostTexture->depth; - if (hostTexture->overwriteInfo.hasResolutionOverwrite) - { - effectiveBaseWidth = hostTexture->overwriteInfo.width; - effectiveBaseHeight = hostTexture->overwriteInfo.height; - effectiveBaseDepth = hostTexture->overwriteInfo.depth; - } - // calculate mip count - sint32 mipLevels = std::min(hostTexture->mipLevels, hostTexture->maxPossibleMipLevels); - mipLevels = std::max(mipLevels, 1); - // create immutable storage - if (hostTexture->dim == Latte::E_DIM::DIM_2D || hostTexture->dim == Latte::E_DIM::DIM_2D_MSAA) - { - cemu_assert_debug(effectiveBaseDepth == 1); - glTextureStorage2DWrapper(GL_TEXTURE_2D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_1D) - { - cemu_assert_debug(effectiveBaseHeight == 1); - cemu_assert_debug(effectiveBaseDepth == 1); - glTextureStorage1DWrapper(GL_TEXTURE_1D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY || hostTexture->dim == Latte::E_DIM::DIM_2D_ARRAY_MSAA) - { - glTextureStorage3DWrapper(GL_TEXTURE_2D_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_3D) - { - glTextureStorage3DWrapper(GL_TEXTURE_3D, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, std::max(1, effectiveBaseDepth)); - } - else if (hostTexture->dim == Latte::E_DIM::DIM_CUBEMAP) - { - glTextureStorage3DWrapper(GL_TEXTURE_CUBE_MAP_ARRAY, hostTexture->glId_texture, mipLevels, hostTexture->glInternalFormat, effectiveBaseWidth, effectiveBaseHeight, effectiveBaseDepth); - } - else - { - cemu_assert_unimplemented(); - } -} - // use standard API to upload texture data void OpenGLRenderer_texture_loadSlice_normal(LatteTexture* hostTextureGeneric, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 imageSize) { diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index 026264cf..3a892191 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -66,14 +66,11 @@ public: void renderstate_updateTextureSettingsGL(LatteDecompilerShader* shaderContext, LatteTextureView* _hostTextureView, uint32 hostTextureUnit, const Latte::LATTE_SQ_TEX_RESOURCE_WORD4_N texUnitWord4, uint32 texUnitIndex, bool isDepthSampler); // texture functions - void texture_destroy(LatteTexture* hostTexture) override; - void* texture_acquireTextureUploadBuffer(uint32 size) override; void texture_releaseTextureUploadBuffer(uint8* mem) override; TextureDecoder* texture_chooseDecodedFormat(Latte::E_GX2SURFFMT format, bool isDepth, Latte::E_DIM dim, uint32 width, uint32 height) override; - void texture_reserveTextureOnGPU(LatteTexture* hostTexture) override; void texture_clearSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex) override; void texture_loadSlice(LatteTexture* hostTexture, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 compressedImageSize) override; void texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) override; diff --git a/src/Cafe/HW/Latte/Renderer/Renderer.h b/src/Cafe/HW/Latte/Renderer/Renderer.h index 93edaf8d..2a9a1d1b 100644 --- a/src/Cafe/HW/Latte/Renderer/Renderer.h +++ b/src/Cafe/HW/Latte/Renderer/Renderer.h @@ -97,14 +97,11 @@ public: virtual void rendertarget_bindFramebufferObject(LatteCachedFBO* cfbo) = 0; // texture functions - virtual void texture_destroy(LatteTexture* hostTexture) = 0; - virtual void* texture_acquireTextureUploadBuffer(uint32 size) = 0; virtual void texture_releaseTextureUploadBuffer(uint8* mem) = 0; virtual TextureDecoder* texture_chooseDecodedFormat(Latte::E_GX2SURFFMT format, bool isDepth, Latte::E_DIM dim, uint32 width, uint32 height) = 0; - virtual void texture_reserveTextureOnGPU(LatteTexture* hostTexture) = 0; virtual void texture_clearSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex) = 0; virtual void texture_loadSlice(LatteTexture* hostTexture, sint32 width, sint32 height, sint32 depth, void* pixelData, sint32 sliceIndex, sint32 mipIndex, uint32 compressedImageSize) = 0; virtual void texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) = 0; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.cpp index 66f7ba95..8a999000 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/CachedFBOVk.cpp @@ -44,9 +44,9 @@ CachedFBOVk::~CachedFBOVk() while (!m_usedByPipelines.empty()) delete m_usedByPipelines[0]; auto vkr = VulkanRenderer::GetInstance(); - vkr->releaseDestructibleObject(m_vkrObjFramebuffer); + vkr->ReleaseDestructibleObject(m_vkrObjFramebuffer); m_vkrObjFramebuffer = nullptr; - vkr->releaseDestructibleObject(m_vkrObjRenderPass); + vkr->ReleaseDestructibleObject(m_vkrObjRenderPass); m_vkrObjRenderPass = nullptr; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp index aae7e9d1..f0e2295e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp @@ -79,14 +79,14 @@ LatteTextureViewVk::~LatteTextureViewVk() delete list_descriptorSets[0]; if (m_smallCacheView0) - VulkanRenderer::GetInstance()->releaseDestructibleObject(m_smallCacheView0); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(m_smallCacheView0); if (m_smallCacheView1) - VulkanRenderer::GetInstance()->releaseDestructibleObject(m_smallCacheView1); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(m_smallCacheView1); if (m_fallbackCache) { for (auto& itr : *m_fallbackCache) - VulkanRenderer::GetInstance()->releaseDestructibleObject(itr.second); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(itr.second); delete m_fallbackCache; m_fallbackCache = nullptr; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp index b5f62707..a62741e4 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.cpp @@ -46,7 +46,7 @@ LatteTextureVk::LatteTextureVk(class VulkanRenderer* vkRenderer, Latte::E_DIM di VulkanRenderer::FormatInfoVK texFormatInfo; vkRenderer->GetTextureFormatInfoVK(format, isDepth, dim, effectiveBaseWidth, effectiveBaseHeight, &texFormatInfo); - hasStencil = (texFormatInfo.vkImageAspect & VK_IMAGE_ASPECT_STENCIL_BIT) != 0; + cemu_assert_debug(hasStencil == ((texFormatInfo.vkImageAspect & VK_IMAGE_ASPECT_STENCIL_BIT) != 0)); imageInfo.format = texFormatInfo.vkImageFormat; vkObjTex->m_imageAspect = texFormatInfo.vkImageAspect; @@ -117,7 +117,7 @@ LatteTextureVk::~LatteTextureVk() m_vkr->surfaceCopy_notifyTextureRelease(this); - VulkanRenderer::GetInstance()->releaseDestructibleObject(vkObjTex); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(vkObjTex); vkObjTex = nullptr; } @@ -130,12 +130,8 @@ LatteTextureView* LatteTextureVk::CreateView(Latte::E_DIM dim, Latte::E_GX2SURFF return new LatteTextureViewVk(m_vkr->GetLogicalDevice(), this, dim, format, firstMip, mipCount, firstSlice, sliceCount); } -void LatteTextureVk::setAllocation(struct VkImageMemAllocation* memAllocation) +void LatteTextureVk::AllocateOnHost() { - vkObjTex->m_allocation = memAllocation; -} - -struct VkImageMemAllocation* LatteTextureVk::getAllocation() const -{ - return vkObjTex->m_allocation; + auto allocationInfo = VulkanRenderer::GetInstance()->GetMemoryManager()->imageMemoryAllocate(GetImageObj()->m_image); + vkObjTex->m_allocation = allocationInfo; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h index 714c4e17..612e2e70 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureVk.h @@ -14,14 +14,13 @@ public: ~LatteTextureVk(); + void AllocateOnHost() override; + VKRObjectTexture* GetImageObj() const { return vkObjTex; }; VkFormat GetFormat() const { return vkObjTex->m_format; } VkImageAspectFlags GetImageAspect() const { return vkObjTex->m_imageAspect; } - void setAllocation(struct VkImageMemAllocation* memAllocation); - struct VkImageMemAllocation* getAllocation() const; - VkImageLayout GetImageLayout(VkImageSubresource& subresource) { cemu_assert_debug(subresource.mipLevel < m_layoutsMips); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 437ef51d..15ea6e89 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -207,7 +207,8 @@ RendererShaderVk::RendererShaderVk(ShaderType type, uint64 baseHash, uint64 auxH RendererShaderVk::~RendererShaderVk() { - VulkanRenderer::GetInstance()->destroyShader(this); + while (!list_pipelineInfo.empty()) + delete list_pipelineInfo[0]; } void RendererShaderVk::Init() diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp index 72a1be4c..fd5a5b78 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRPipelineInfo.cpp @@ -84,7 +84,7 @@ PipelineInfo::~PipelineInfo() // queue pipeline for destruction if (m_vkrObjPipeline) { - VulkanRenderer::GetInstance()->releaseDestructibleObject(m_vkrObjPipeline); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(m_vkrObjPipeline); m_vkrObjPipeline = nullptr; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp index 0ee9f023..2be9a2f4 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp @@ -300,7 +300,7 @@ void VulkanPipelineStableCache::LoadPipelineFromCache(std::span fileData) delete pipelineInfo; delete lcr; delete cachedPipeline; - VulkanRenderer::GetInstance()->releaseDestructibleObject(renderPass); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(renderPass); s_spinlockSharedInternal.unlock(); } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index c7f8c043..d0305317 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1803,44 +1803,6 @@ void VulkanRenderer::PreparePresentationFrame(bool mainWindow) AcquireNextSwapchainImage(mainWindow); } -void VulkanRenderer::ProcessDestructionQueues(size_t commandBufferIndex) -{ - auto& current_descriptor_cache = m_destructionQueues.m_cmd_descriptor_set_objects[commandBufferIndex]; - if (!current_descriptor_cache.empty()) - { - assert_dbg(); - //for (const auto& descriptor : current_descriptor_cache) - //{ - // vkFreeDescriptorSets(m_logicalDevice, m_descriptorPool, 1, &descriptor); - // performanceMonitor.vk.numDescriptorSets.decrement(); - //} - - current_descriptor_cache.clear(); - } - - // destroy buffers - for (auto& itr : m_destructionQueues.m_buffers[commandBufferIndex]) - vkDestroyBuffer(m_logicalDevice, itr, nullptr); - m_destructionQueues.m_buffers[commandBufferIndex].clear(); - - // destroy device memory objects - for (auto& itr : m_destructionQueues.m_memory[commandBufferIndex]) - vkFreeMemory(m_logicalDevice, itr, nullptr); - m_destructionQueues.m_memory[commandBufferIndex].clear(); - - // destroy image views - for (auto& itr : m_destructionQueues.m_cmd_image_views[commandBufferIndex]) - vkDestroyImageView(m_logicalDevice, itr, nullptr); - m_destructionQueues.m_cmd_image_views[commandBufferIndex].clear(); - - // destroy host textures - for (auto itr : m_destructionQueues.m_host_textures[commandBufferIndex]) - delete itr; - m_destructionQueues.m_host_textures[commandBufferIndex].clear(); - - ProcessDestructionQueue2(); -} - void VulkanRenderer::InitFirstCommandBuffer() { cemu_assert_debug(m_state.currentCommandBuffer == nullptr); @@ -1869,7 +1831,7 @@ void VulkanRenderer::ProcessFinishedCommandBuffers() VkResult fenceStatus = vkGetFenceStatus(m_logicalDevice, m_cmd_buffer_fences[m_commandBufferSyncIndex]); if (fenceStatus == VK_SUCCESS) { - ProcessDestructionQueues(m_commandBufferSyncIndex); + ProcessDestructionQueue(); m_commandBufferSyncIndex = (m_commandBufferSyncIndex + 1) % m_commandBuffers.size(); memoryManager->cleanupBuffers(m_countCommandBufferFinished); m_countCommandBufferFinished++; @@ -3035,48 +2997,7 @@ TextureDecoder* VulkanRenderer::texture_chooseDecodedFormat(Latte::E_GX2SURFFMT return texFormatInfo.decoder; } -void VulkanRenderer::texture_reserveTextureOnGPU(LatteTexture* hostTexture) -{ - LatteTextureVk* vkTexture = (LatteTextureVk*)hostTexture; - auto allocationInfo = memoryManager->imageMemoryAllocate(vkTexture->GetImageObj()->m_image); - vkTexture->setAllocation(allocationInfo); -} - -void VulkanRenderer::texture_destroy(LatteTexture* hostTexture) -{ - LatteTextureVk* texVk = (LatteTextureVk*)hostTexture; - delete texVk; -} - -void VulkanRenderer::destroyViewDepr(VkImageView imageView) -{ - cemu_assert_debug(false); - - m_destructionQueues.m_cmd_image_views[m_commandBufferIndex].emplace_back(imageView); -} - -void VulkanRenderer::destroyBuffer(VkBuffer buffer) -{ - m_destructionQueues.m_buffers[m_commandBufferIndex].emplace_back(buffer); -} - -void VulkanRenderer::destroyDeviceMemory(VkDeviceMemory mem) -{ - m_destructionQueues.m_memory[m_commandBufferIndex].emplace_back(mem); -} - -void VulkanRenderer::destroyPipelineInfo(PipelineInfo* pipelineInfo) -{ - cemu_assert_debug(false); -} - -void VulkanRenderer::destroyShader(RendererShaderVk* shader) -{ - while (!shader->list_pipelineInfo.empty()) - delete shader->list_pipelineInfo[0]; -} - -void VulkanRenderer::releaseDestructibleObject(VKRDestructibleObject* destructibleObject) +void VulkanRenderer::ReleaseDestructibleObject(VKRDestructibleObject* destructibleObject) { // destroy immediately if possible if (destructibleObject->canDestroy()) @@ -3090,7 +3011,7 @@ void VulkanRenderer::releaseDestructibleObject(VKRDestructibleObject* destructib m_spinlockDestructionQueue.unlock(); } -void VulkanRenderer::ProcessDestructionQueue2() +void VulkanRenderer::ProcessDestructionQueue() { m_spinlockDestructionQueue.lock(); for (auto it = m_destructionQueue.begin(); it != m_destructionQueue.end();) @@ -3139,7 +3060,7 @@ VkDescriptorSetInfo::~VkDescriptorSetInfo() performanceMonitor.vk.numDescriptorDynUniformBuffers.decrement(statsNumDynUniformBuffers); performanceMonitor.vk.numDescriptorStorageBuffers.decrement(statsNumStorageBuffers); - VulkanRenderer::GetInstance()->releaseDestructibleObject(m_vkObjDescriptorSet); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(m_vkObjDescriptorSet); m_vkObjDescriptorSet = nullptr; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 226edad6..e0a4c75b 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -231,7 +231,6 @@ public: void DrawEmptyFrame(bool mainWindow) override; void PreparePresentationFrame(bool mainWindow); - void ProcessDestructionQueues(size_t commandBufferIndex); void InitFirstCommandBuffer(); void ProcessFinishedCommandBuffers(); void WaitForNextFinishedCommandBuffer(); @@ -244,15 +243,9 @@ public: bool HasCommandBufferFinished(uint64 commandBufferId) const; void WaitCommandBufferFinished(uint64 commandBufferId); - // clean up (deprecated) - void destroyViewDepr(VkImageView imageView); - void destroyBuffer(VkBuffer buffer); - void destroyDeviceMemory(VkDeviceMemory mem); - void destroyPipelineInfo(PipelineInfo* pipelineInfo); - void destroyShader(RendererShaderVk* shader); - // clean up (new) - void releaseDestructibleObject(VKRDestructibleObject* destructibleObject); - void ProcessDestructionQueue2(); + // resource destruction queue + void ReleaseDestructibleObject(VKRDestructibleObject* destructibleObject); + void ProcessDestructionQueue(); FSpinlock m_spinlockDestructionQueue; std::vector m_destructionQueue; @@ -290,9 +283,6 @@ public: TextureDecoder* texture_chooseDecodedFormat(Latte::E_GX2SURFFMT format, bool isDepth, Latte::E_DIM dim, uint32 width, uint32 height) override; - void texture_reserveTextureOnGPU(LatteTexture* hostTexture) override; - void texture_destroy(LatteTexture* hostTexture) override; - void texture_clearSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex) override; void texture_clearColorSlice(LatteTexture* hostTexture, sint32 sliceIndex, sint32 mipIndex, float r, float g, float b, float a) override; void texture_clearDepthSlice(LatteTexture* hostTexture, uint32 sliceIndex, sint32 mipIndex, bool clearDepth, bool clearStencil, float depthValue, uint32 stencilValue) override; @@ -634,15 +624,6 @@ private: // command buffer, garbage collection, synchronization static constexpr uint32 kCommandBufferPoolSize = 128; - struct - { - std::array, kCommandBufferPoolSize> m_cmd_descriptor_set_objects; - std::array, kCommandBufferPoolSize> m_cmd_image_views; - std::array, kCommandBufferPoolSize> m_host_textures; - std::array, kCommandBufferPoolSize> m_buffers; - std::array, kCommandBufferPoolSize> m_memory; - }m_destructionQueues; - size_t m_commandBufferIndex = 0; // current buffer being filled size_t m_commandBufferSyncIndex = 0; // latest buffer that finished execution (updated on submit) std::array m_cmd_buffer_fences; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp index 479b7e60..bf33ed90 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp @@ -813,9 +813,9 @@ void VulkanRenderer::surfaceCopy_notifyTextureRelease(LatteTextureVk* hostTextur { if (p) { - VulkanRenderer::GetInstance()->releaseDestructibleObject(p->vkObjDescriptorSet); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(p->vkObjDescriptorSet); p->vkObjDescriptorSet = nullptr; - VulkanRenderer::GetInstance()->releaseDestructibleObject(p->vkObjImageView); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(p->vkObjImageView); p->vkObjImageView = nullptr; } } @@ -829,9 +829,9 @@ void VulkanRenderer::surfaceCopy_notifyTextureRelease(LatteTextureVk* hostTextur { if (p) { - VulkanRenderer::GetInstance()->releaseDestructibleObject(p->vkObjFramebuffer); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(p->vkObjFramebuffer); p->vkObjFramebuffer = nullptr; - VulkanRenderer::GetInstance()->releaseDestructibleObject(p->vkObjImageView); + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(p->vkObjImageView); p->vkObjImageView = nullptr; } } diff --git a/src/imgui/imgui_impl_vulkan.cpp b/src/imgui/imgui_impl_vulkan.cpp index f0006b45..723f153c 100644 --- a/src/imgui/imgui_impl_vulkan.cpp +++ b/src/imgui/imgui_impl_vulkan.cpp @@ -245,18 +245,13 @@ static void check_vk_result(VkResult err) static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& p_buffer_size, size_t new_size, VkBufferUsageFlagBits usage) { - VulkanRenderer* vkRenderer = VulkanRenderer::GetInstance(); - - ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo; + ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo; + vkDeviceWaitIdle(v->Device); // make sure previously created buffer is not in use anymore VkResult err; if (buffer != VK_NULL_HANDLE) - { - vkRenderer->destroyBuffer(buffer); - } + vkDestroyBuffer(v->Device, buffer, v->Allocator); if (buffer_memory != VK_NULL_HANDLE) - { - vkRenderer->destroyDeviceMemory(buffer_memory); - } + vkFreeMemory(v->Device, buffer_memory, v->Allocator); VkDeviceSize vertex_buffer_size_aligned = ((new_size - 1) / g_BufferMemoryAlignment + 1) * g_BufferMemoryAlignment; VkBufferCreateInfo buffer_info = {}; buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; From 731713de3ac97e6cee2504fd6ce3e7ca943fc282 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 14 Mar 2024 03:10:10 +0100 Subject: [PATCH 115/314] OpenGL: Remove "-legacy" flag "Intel legacy mode" was a special mode to workaround various Intel OpenGL driver limitations during the earlier years of Cemu. It's been unmaintained for years and no longer serves a purpose. If we ever bring back compatibility with ancient Intel GPUs it should be done in a more structured way than a blunt yes/no flag. --- src/Cafe/GraphicPack/GraphicPack2.cpp | 3 - src/Cafe/HW/Latte/Core/LatteConst.h | 2 - src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp | 21 +++---- src/Cafe/HW/Latte/Core/LatteThread.cpp | 8 +-- .../Latte/Renderer/OpenGL/LatteTextureGL.cpp | 62 +++++-------------- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 44 +------------ .../Renderer/OpenGL/OpenGLRendererCore.cpp | 2 +- src/Cafe/HW/Latte/Renderer/Renderer.h | 2 - src/config/LaunchSettings.cpp | 2 - src/config/LaunchSettings.h | 2 - src/gui/guiWrapper.cpp | 4 -- 11 files changed, 26 insertions(+), 126 deletions(-) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 365e6e3e..b581316e 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -878,9 +878,6 @@ bool GraphicPack2::Activate() if (m_gfx_vendor.has_value()) { auto vendor = g_renderer->GetVendor(); - if (vendor == GfxVendor::IntelLegacy || vendor == GfxVendor::IntelNoLegacy) - vendor = GfxVendor::Intel; - if (m_gfx_vendor.value() != vendor) return false; } diff --git a/src/Cafe/HW/Latte/Core/LatteConst.h b/src/Cafe/HW/Latte/Core/LatteConst.h index 04c7b888..ebe741e9 100644 --- a/src/Cafe/HW/Latte/Core/LatteConst.h +++ b/src/Cafe/HW/Latte/Core/LatteConst.h @@ -82,8 +82,6 @@ #define GLVENDOR_UNKNOWN (0) #define GLVENDOR_AMD (1) // AMD/ATI #define GLVENDOR_NVIDIA (2) -#define GLVENDOR_INTEL_LEGACY (3) -#define GLVENDOR_INTEL_NOLEGACY (4) #define GLVENDOR_INTEL (5) #define GLVENDOR_APPLE (6) diff --git a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp index b9ccbac4..50aa4d87 100644 --- a/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp @@ -229,21 +229,16 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u // if this texture is bound multiple times then use alternative views if (textureView->lastTextureBindIndex == LatteGPUState.textureBindCounter) { - // Intel driver has issues with textures that have multiple views bound and used by a shader, causes a softlock in BotW - // therefore we disable this on Intel - if (LatteGPUState.glVendor != GLVENDOR_INTEL_NOLEGACY) + LatteTextureViewGL* textureViewGL = (LatteTextureViewGL*)textureView; + // get next unused alternative texture view + while (true) { - LatteTextureViewGL* textureViewGL = (LatteTextureViewGL*)textureView; - // get next unused alternative texture view - while (true) - { - textureViewGL = textureViewGL->GetAlternativeView(); - if (textureViewGL->lastTextureBindIndex != LatteGPUState.textureBindCounter) - break; - } - textureView = textureViewGL; + textureViewGL = textureViewGL->GetAlternativeView(); + if (textureViewGL->lastTextureBindIndex != LatteGPUState.textureBindCounter) + break; } - } + textureView = textureViewGL; + } textureView->lastTextureBindIndex = LatteGPUState.textureBindCounter; rendererGL->renderstate_updateTextureSettingsGL(shaderContext, textureView, textureIndex + glBackendBaseTexUnit, word4, textureIndex, isDepthSampler); } diff --git a/src/Cafe/HW/Latte/Core/LatteThread.cpp b/src/Cafe/HW/Latte/Core/LatteThread.cpp index 60b32ec4..bd312d93 100644 --- a/src/Cafe/HW/Latte/Core/LatteThread.cpp +++ b/src/Cafe/HW/Latte/Core/LatteThread.cpp @@ -140,13 +140,7 @@ int Latte_ThreadEntry() case GfxVendor::AMD: LatteGPUState.glVendor = GLVENDOR_AMD; break; - case GfxVendor::IntelLegacy: - LatteGPUState.glVendor = GLVENDOR_INTEL_LEGACY; - break; - case GfxVendor::IntelNoLegacy: - LatteGPUState.glVendor = GLVENDOR_INTEL_NOLEGACY; - break; - case GfxVendor::Intel: + case GfxVendor::Intel: LatteGPUState.glVendor = GLVENDOR_INTEL; break; case GfxVendor::Nvidia: diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp index 58805925..fb025eba 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp @@ -110,10 +110,6 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma sint32 glInternalFormat; sint32 glSuppliedFormat; sint32 glSuppliedFormatType; - // check if compressed textures should be used - bool allowCompressedGLFormat = true; - if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY) - allowCompressedGLFormat = false; // compressed formats seem to cause more harm than good on Intel // get format information if (format == Latte::E_GX2SURFFMT::R4_G4_UNORM) { @@ -149,20 +145,11 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma else if (format == Latte::E_GX2SURFFMT::BC1_UNORM || format == Latte::E_GX2SURFFMT::BC1_SRGB) { - if (allowCompressedGLFormat) - { - if (format == Latte::E_GX2SURFFMT::BC1_SRGB) - formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, -1, -1); - else - formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -1, -1); - return; - } + if (format == Latte::E_GX2SURFFMT::BC1_SRGB) + formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, -1, -1); else - { - formatInfoOut->setFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT); - formatInfoOut->markAsAlternativeFormat(); - return; - } + formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -1, -1); + return; } else if (format == Latte::E_GX2SURFFMT::BC2_UNORM || format == Latte::E_GX2SURFFMT::BC2_SRGB) { @@ -173,28 +160,18 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma } else if (format == Latte::E_GX2SURFFMT::BC3_UNORM || format == Latte::E_GX2SURFFMT::BC3_SRGB) { - if (allowCompressedGLFormat) - { - if (format == Latte::E_GX2SURFFMT::BC3_SRGB) - formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, -1, -1); - else - formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -1, -1); - return; - } + if (format == Latte::E_GX2SURFFMT::BC3_SRGB) + formatInfoOut->setCompressed(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, -1, -1); else - { - // todo: SRGB support - formatInfoOut->setFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT); - formatInfoOut->markAsAlternativeFormat(); - return; - } + formatInfoOut->setCompressed(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -1, -1); + return; } else if (format == Latte::E_GX2SURFFMT::BC4_UNORM || format == Latte::E_GX2SURFFMT::BC4_SNORM) { + bool allowCompressed = true; if (dim != Latte::E_DIM::DIM_2D && dim != Latte::E_DIM::DIM_2D_ARRAY) - allowCompressedGLFormat = false; // RGTC1 does not support non-2D textures - - if (allowCompressedGLFormat) + allowCompressed = false; // RGTC1 does not support non-2D textures + if (allowCompressed) { if (format == Latte::E_GX2SURFFMT::BC4_UNORM) formatInfoOut->setCompressed(GL_COMPRESSED_RED_RGTC1, -1, -1); @@ -211,20 +188,11 @@ void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT forma } else if (format == Latte::E_GX2SURFFMT::BC5_UNORM || format == Latte::E_GX2SURFFMT::BC5_SNORM) { - if (allowCompressedGLFormat) - { - if (format == Latte::E_GX2SURFFMT::BC5_SNORM) - formatInfoOut->setCompressed(GL_COMPRESSED_SIGNED_RG_RGTC2, -1, -1); - else - formatInfoOut->setCompressed(GL_COMPRESSED_RG_RGTC2, -1, -1); - return; - } + if (format == Latte::E_GX2SURFFMT::BC5_SNORM) + formatInfoOut->setCompressed(GL_COMPRESSED_SIGNED_RG_RGTC2, -1, -1); else - { - formatInfoOut->setFormat(GL_RG16F, GL_RG, GL_FLOAT); - formatInfoOut->markAsAlternativeFormat(); - return; - } + formatInfoOut->setCompressed(GL_COMPRESSED_RG_RGTC2, -1, -1); + return; } else if (format == Latte::E_GX2SURFFMT::R32_FLOAT) { diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 604744cf..28e91b8a 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -407,10 +407,7 @@ void OpenGLRenderer::GetVendorInformation() } else if (memcmp(glVendorString, "Intel", 5) == 0) { - if (LaunchSettings::ForceIntelLegacyEnabled()) - m_vendor = GfxVendor::IntelLegacy; - else - m_vendor = GfxVendor::IntelNoLegacy; + m_vendor = GfxVendor::Intel; return; } } @@ -849,45 +846,6 @@ TextureDecoder* OpenGLRenderer::texture_chooseDecodedFormat(Latte::E_GX2SURFFMT } return nullptr; } - - if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY) - { - if (format == Latte::E_GX2SURFFMT::BC1_UNORM) - { - texDecoder = TextureDecoder_BC1_UNORM_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC1_SRGB) - { - texDecoder = TextureDecoder_BC1_SRGB_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC3_UNORM) - { - texDecoder = TextureDecoder_BC3_UNORM_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC3_SRGB) - { - texDecoder = TextureDecoder_BC3_SRGB_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC4_UNORM) - { - texDecoder = TextureDecoder_BC4_UNORM_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC4_SNORM) - { - cemu_assert_debug(false); // todo - } - else if (format == Latte::E_GX2SURFFMT::BC5_UNORM) - { - texDecoder = TextureDecoder_BC5_UNORM_uncompress::getInstance(); - } - else if (format == Latte::E_GX2SURFFMT::BC5_SNORM) - { - texDecoder = TextureDecoder_BC5_SNORM_uncompress::getInstance(); - } - if (texDecoder) - return texDecoder; - } - if (format == Latte::E_GX2SURFFMT::R4_G4_UNORM) texDecoder = TextureDecoder_R4_G4_UNORM_To_RGBA4::getInstance(); else if (format == Latte::E_GX2SURFFMT::R4_G4_B4_A4_UNORM) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp index 51d0d206..571961f4 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRendererCore.cpp @@ -950,7 +950,7 @@ void OpenGLRenderer::draw_genericDrawHandler(uint32 baseVertex, uint32 baseInsta bool streamoutEnable = LatteGPUState.contextRegister[mmVGT_STRMOUT_EN] != 0; if (streamoutEnable) { - if (glBeginTransformFeedback == nullptr || LatteGPUState.glVendor == GLVENDOR_INTEL_NOLEGACY) + if (glBeginTransformFeedback == nullptr) { cemu_assert_debug(false); return; // transform feedback not supported diff --git a/src/Cafe/HW/Latte/Renderer/Renderer.h b/src/Cafe/HW/Latte/Renderer/Renderer.h index 2a9a1d1b..0b694bb9 100644 --- a/src/Cafe/HW/Latte/Renderer/Renderer.h +++ b/src/Cafe/HW/Latte/Renderer/Renderer.h @@ -21,8 +21,6 @@ enum class GfxVendor Generic, AMD, - IntelLegacy, - IntelNoLegacy, Intel, Nvidia, Apple, diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index fdd4cc65..b7a79a11 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -174,8 +174,6 @@ bool LaunchSettings::HandleCommandline(const std::vector& args) if (vm.count("nsight")) s_nsight_mode = vm["nsight"].as(); - if (vm.count("legacy")) - s_force_intel_legacy = vm["legacy"].as(); if(vm.count("force-interpreter")) s_force_interpreter = vm["force-interpreter"].as(); diff --git a/src/config/LaunchSettings.h b/src/config/LaunchSettings.h index f87dc609..be989e6a 100644 --- a/src/config/LaunchSettings.h +++ b/src/config/LaunchSettings.h @@ -24,7 +24,6 @@ public: static bool GDBStubEnabled() { return s_enable_gdbstub; } static bool NSightModeEnabled() { return s_nsight_mode; } - static bool ForceIntelLegacyEnabled() { return s_force_intel_legacy; } static bool ForceInterpreter() { return s_force_interpreter; }; @@ -44,7 +43,6 @@ private: inline static bool s_enable_gdbstub = false; inline static bool s_nsight_mode = false; - inline static bool s_force_intel_legacy = false; inline static bool s_force_interpreter = false; diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index 68f97590..ce043bab 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -93,10 +93,6 @@ void gui_updateWindowTitles(bool isIdle, bool isLoading, double fps) const char* graphicMode = "[Generic]"; if (LatteGPUState.glVendor == GLVENDOR_AMD) graphicMode = "[AMD GPU]"; - else if (LatteGPUState.glVendor == GLVENDOR_INTEL_LEGACY) - graphicMode = "[Intel GPU - Legacy]"; - else if (LatteGPUState.glVendor == GLVENDOR_INTEL_NOLEGACY) - graphicMode = "[Intel GPU]"; else if (LatteGPUState.glVendor == GLVENDOR_INTEL) graphicMode = "[Intel GPU]"; else if (LatteGPUState.glVendor == GLVENDOR_NVIDIA) From eaa82817dd235b5067002df76b06e66a550ac1d3 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Fri, 15 Mar 2024 23:06:48 +0100 Subject: [PATCH 116/314] Update thread names (#1120) --- src/Cafe/HW/Espresso/Debugger/GDBStub.cpp | 2 +- src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp | 2 +- src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp | 2 ++ .../HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp | 2 ++ src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 1 + src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp | 1 + src/Cafe/IOSU/ODM/iosu_odm.cpp | 2 ++ src/Cafe/IOSU/PDM/iosu_pdm.cpp | 2 ++ src/Cafe/IOSU/nn/iosu_nn_service.cpp | 1 + src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 2 +- src/Cafe/TitleList/SaveList.cpp | 2 ++ src/Cafe/TitleList/TitleList.cpp | 1 + src/Cemu/FileCache/FileCache.cpp | 2 +- src/gui/components/wxGameList.cpp | 1 + src/gui/guiWrapper.cpp | 2 +- src/input/InputManager.cpp | 2 +- src/input/api/DSU/DSUControllerProvider.cpp | 4 ++-- src/input/api/SDL/SDLControllerProvider.cpp | 2 +- src/input/api/Wiimote/WiimoteControllerProvider.cpp | 4 ++-- src/util/helpers/helpers.cpp | 4 +++- 20 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp index 6cddae01..e54fae1b 100644 --- a/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp +++ b/src/Cafe/HW/Espresso/Debugger/GDBStub.cpp @@ -297,7 +297,7 @@ bool GDBServer::Initialize() void GDBServer::ThreadFunc() { - SetThreadName("GDBServer::ThreadFunc"); + SetThreadName("GDBServer"); while (!m_stopRequested) { diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp index f4d063fa..24e87bd1 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompiler.cpp @@ -294,7 +294,7 @@ std::atomic_bool s_recompilerThreadStopSignal{false}; void PPCRecompiler_thread() { - SetThreadName("PPCRecompiler_thread"); + SetThreadName("PPCRecompiler"); while (true) { if(s_recompilerThreadStopSignal) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 15ea6e89..50f2c2d6 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -8,6 +8,7 @@ #include #include +#include bool s_isLoadingShadersVk{ false }; class FileCache* s_spirvCache{nullptr}; @@ -155,6 +156,7 @@ public: void CompilerThreadFunc() { + SetThreadName("vkShaderComp"); while (m_threadsActive.load(std::memory_order::relaxed)) { s_compilationQueueCount.decrementWithWait(); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp index 2be9a2f4..123120d3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp @@ -408,6 +408,7 @@ bool VulkanPipelineStableCache::DeserializePipeline(MemStreamReader& memReader, int VulkanPipelineStableCache::CompilerThread() { + SetThreadName("plCacheCompiler"); while (m_numCompilationThreads != 0) { std::vector pipelineData = m_compilationQueue.pop(); @@ -421,6 +422,7 @@ int VulkanPipelineStableCache::CompilerThread() void VulkanPipelineStableCache::WorkerThread() { + SetThreadName("plCacheWriter"); while (true) { CachedPipeline* job; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index d0305317..d62b61a6 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1986,6 +1986,7 @@ void VulkanRenderer::WaitCommandBufferFinished(uint64 commandBufferId) void VulkanRenderer::PipelineCacheSaveThread(size_t cache_size) { + SetThreadName("vkDriverPlCache"); const auto dir = ActiveSettings::GetCachePath("shaderCache/driver/vk"); if (!fs::exists(dir)) { diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 320357f1..d510140b 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -190,6 +190,7 @@ std::queue g_compilePipelineRequests; void compilePipeline_thread(sint32 threadIndex) { + SetThreadName("compilePl"); #ifdef _WIN32 // one thread runs at normal priority while the others run at lower priority if(threadIndex != 0) diff --git a/src/Cafe/IOSU/ODM/iosu_odm.cpp b/src/Cafe/IOSU/ODM/iosu_odm.cpp index 3dc8e431..aae3c503 100644 --- a/src/Cafe/IOSU/ODM/iosu_odm.cpp +++ b/src/Cafe/IOSU/ODM/iosu_odm.cpp @@ -1,3 +1,4 @@ +#include #include "iosu_odm.h" #include "config/ActiveSettings.h" #include "Common/FileStream.h" @@ -79,6 +80,7 @@ namespace iosu void ODMServiceThread() { + SetThreadName("ODMService"); s_msgQueueId = IOS_CreateMessageQueue(_s_msgBuffer.GetPtr(), _s_msgBuffer.GetCount()); cemu_assert(!IOS_ResultIsError((IOS_ERROR)s_msgQueueId)); IOS_ERROR r = IOS_RegisterResourceManager(s_devicePath.c_str(), s_msgQueueId); diff --git a/src/Cafe/IOSU/PDM/iosu_pdm.cpp b/src/Cafe/IOSU/PDM/iosu_pdm.cpp index e54529a9..d94b1dbf 100644 --- a/src/Cafe/IOSU/PDM/iosu_pdm.cpp +++ b/src/Cafe/IOSU/PDM/iosu_pdm.cpp @@ -1,3 +1,4 @@ +#include #include "iosu_pdm.h" #include "Cafe/CafeSystem.h" #include "config/ActiveSettings.h" @@ -387,6 +388,7 @@ namespace iosu void TimeTrackingThread(uint64 titleId) { + SetThreadName("PlayDiaryThread"); PlayStatsEntry* playStatsEntry = PlayStats_BeginNewTracking(titleId); auto startTime = std::chrono::steady_clock::now(); diff --git a/src/Cafe/IOSU/nn/iosu_nn_service.cpp b/src/Cafe/IOSU/nn/iosu_nn_service.cpp index b3b2d4c9..1fb5c77a 100644 --- a/src/Cafe/IOSU/nn/iosu_nn_service.cpp +++ b/src/Cafe/IOSU/nn/iosu_nn_service.cpp @@ -155,6 +155,7 @@ namespace iosu void IPCService::ServiceThread() { + SetThreadName("IPCService"); m_msgQueueId = IOS_CreateMessageQueue(_m_msgBuffer.GetPtr(), _m_msgBuffer.GetCount()); cemu_assert(!IOS_ResultIsError((IOS_ERROR)m_msgQueueId)); IOS_ERROR r = IOS_RegisterResourceManager(m_devicePath.c_str(), m_msgQueueId); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 3701a4d7..8ce5de07 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -1168,7 +1168,7 @@ namespace coreinit void OSSchedulerCoreEmulationThread(void* _assignedCoreIndex) { - SetThreadName(fmt::format("OSSchedulerThread[core={}]", (uintptr_t)_assignedCoreIndex).c_str()); + SetThreadName(fmt::format("OSSched[core={}]", (uintptr_t)_assignedCoreIndex).c_str()); t_assignedCoreIndex = (sint32)(uintptr_t)_assignedCoreIndex; #if defined(ARCH_X86_64) _mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero diff --git a/src/Cafe/TitleList/SaveList.cpp b/src/Cafe/TitleList/SaveList.cpp index a86e8498..d0c0e3e2 100644 --- a/src/Cafe/TitleList/SaveList.cpp +++ b/src/Cafe/TitleList/SaveList.cpp @@ -1,5 +1,6 @@ #include "SaveList.h" #include +#include std::mutex sSLMutex; fs::path sSLMLCPath; @@ -44,6 +45,7 @@ void CafeSaveList::Refresh() void CafeSaveList::RefreshThreadWorker() { + SetThreadName("SaveListWorker"); // clear save list for (auto& itSaveInfo : sSLList) { diff --git a/src/Cafe/TitleList/TitleList.cpp b/src/Cafe/TitleList/TitleList.cpp index 1cc084b8..c288dd13 100644 --- a/src/Cafe/TitleList/TitleList.cpp +++ b/src/Cafe/TitleList/TitleList.cpp @@ -258,6 +258,7 @@ void CafeTitleList::AddTitleFromPath(fs::path path) bool CafeTitleList::RefreshWorkerThread() { + SetThreadName("TitleListWorker"); while (sTLRefreshRequests.load()) { sTLRefreshRequests.store(0); diff --git a/src/Cemu/FileCache/FileCache.cpp b/src/Cemu/FileCache/FileCache.cpp index aa7770a3..b284b66b 100644 --- a/src/Cemu/FileCache/FileCache.cpp +++ b/src/Cemu/FileCache/FileCache.cpp @@ -50,7 +50,7 @@ struct _FileCacheAsyncWriter private: void FileCacheThread() { - SetThreadName("fileCache_thread"); + SetThreadName("fileCache"); while (true) { std::unique_lock lock(m_fileCacheMutex); diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 88934cd8..8e8f3c4d 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1194,6 +1194,7 @@ void wxGameList::RemoveCache(const std::list& cachePaths, const std::s void wxGameList::AsyncWorkerThread() { + SetThreadName("GameListWorker"); while (m_async_worker_active) { m_async_task_count.decrementWithWait(); diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index ce043bab..d887e89a 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -37,7 +37,7 @@ void _wxLaunch() void gui_create() { - SetThreadName("MainThread"); + SetThreadName("cemu"); #if BOOST_OS_WINDOWS // on Windows wxWidgets there is a bug where wxDirDialog->ShowModal will deadlock in Windows internals somehow // moving the UI thread off the main thread fixes this diff --git a/src/input/InputManager.cpp b/src/input/InputManager.cpp index 4e7848ce..d928e46c 100644 --- a/src/input/InputManager.cpp +++ b/src/input/InputManager.cpp @@ -934,7 +934,7 @@ std::optional InputManager::get_right_down_mouse_info(bool* is_pad) void InputManager::update_thread() { - SetThreadName("InputManager::update_thread"); + SetThreadName("Input_update"); while (!m_update_thread_shutdown.load(std::memory_order::relaxed)) { std::shared_lock lock(m_mutex); diff --git a/src/input/api/DSU/DSUControllerProvider.cpp b/src/input/api/DSU/DSUControllerProvider.cpp index 0fa93e25..37f92774 100644 --- a/src/input/api/DSU/DSUControllerProvider.cpp +++ b/src/input/api/DSU/DSUControllerProvider.cpp @@ -250,7 +250,7 @@ MotionSample DSUControllerProvider::get_motion_sample(uint8_t index) const void DSUControllerProvider::reader_thread() { - SetThreadName("DSUControllerProvider::reader_thread"); + SetThreadName("DSU-reader"); bool first_read = true; while (m_running.load(std::memory_order_relaxed)) { @@ -383,7 +383,7 @@ void DSUControllerProvider::reader_thread() void DSUControllerProvider::writer_thread() { - SetThreadName("DSUControllerProvider::writer_thread"); + SetThreadName("DSU-writer"); while (m_running.load(std::memory_order_relaxed)) { std::unique_lock lock(m_writer_mutex); diff --git a/src/input/api/SDL/SDLControllerProvider.cpp b/src/input/api/SDL/SDLControllerProvider.cpp index 9e0c09b5..9b21b306 100644 --- a/src/input/api/SDL/SDLControllerProvider.cpp +++ b/src/input/api/SDL/SDLControllerProvider.cpp @@ -124,7 +124,7 @@ MotionSample SDLControllerProvider::motion_sample(int diid) void SDLControllerProvider::event_thread() { - SetThreadName("SDLControllerProvider::event_thread"); + SetThreadName("SDL_events"); while (m_running.load(std::memory_order_relaxed)) { SDL_Event event{}; diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.cpp b/src/input/api/Wiimote/WiimoteControllerProvider.cpp index 55f28c01..5aac3fe4 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.cpp +++ b/src/input/api/Wiimote/WiimoteControllerProvider.cpp @@ -143,7 +143,7 @@ WiimoteControllerProvider::WiimoteState WiimoteControllerProvider::get_state(siz void WiimoteControllerProvider::reader_thread() { - SetThreadName("WiimoteControllerProvider::reader_thread"); + SetThreadName("Wiimote-reader"); std::chrono::steady_clock::time_point lastCheck = {}; while (m_running.load(std::memory_order_relaxed)) { @@ -878,7 +878,7 @@ void WiimoteControllerProvider::set_motion_plus(size_t index, bool state) void WiimoteControllerProvider::writer_thread() { - SetThreadName("WiimoteControllerProvider::writer_thread"); + SetThreadName("Wiimote-writer"); while (m_running.load(std::memory_order_relaxed)) { std::unique_lock writer_lock(m_writer_mutex); diff --git a/src/util/helpers/helpers.cpp b/src/util/helpers/helpers.cpp index b556db36..7e22e9fb 100644 --- a/src/util/helpers/helpers.cpp +++ b/src/util/helpers/helpers.cpp @@ -155,7 +155,9 @@ void SetThreadName(const char* name) #elif BOOST_OS_MACOS pthread_setname_np(name); #else - pthread_setname_np(pthread_self(), name); + if(std::strlen(name) > 15) + cemuLog_log(LogType::Force, "Truncating thread name {} because it was longer than 15 characters", name); + pthread_setname_np(pthread_self(), std::string{name}.substr(0,15).c_str()); #endif } From 42d14eec96c6e63ea93cfb7daa49655b7139c997 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:18:02 +0100 Subject: [PATCH 117/314] Minor code improvements (#1124) --- .../LatteDecompilerEmitGLSL.cpp | 2 +- .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 2 -- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 10 +++++----- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 3 +-- src/input/motion/MotionSample.h | 20 +++++++++---------- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index f3d2c7a8..e19535be 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -973,7 +973,7 @@ void _emitOperandInputCode(LatteDecompilerShaderContext* shaderContext, LatteDec } else { - cemuLog_log(LogType::Force, "Unsupported shader ALU operand sel 0x%x\n", aluInstruction->sourceOperand[operandIndex].sel); + cemuLog_log(LogType::Force, "Unsupported shader ALU operand sel {:#x}\n", aluInstruction->sourceOperand[operandIndex].sel); debugBreakpoint(); } diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index 3a892191..313ea3c0 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -30,8 +30,6 @@ public: void Flush(bool waitIdle = false) override; void NotifyLatteCommandProcessorIdle() override; - void UpdateVSyncState(); - void EnableDebugMode() override; void SwapBuffers(bool swapTV = true, bool swapDRC = true) override; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index d62b61a6..02bb1e71 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -706,8 +706,8 @@ SwapchainInfoVk& VulkanRenderer::GetChainInfo(bool mainWindow) const void VulkanRenderer::StopUsingPadAndWait() { - m_destroyPadSwapchainNextAcquire = true; - m_padCloseReadySemaphore.wait(); + m_destroyPadSwapchainNextAcquire.test_and_set(); + m_destroyPadSwapchainNextAcquire.wait(true); } bool VulkanRenderer::IsPadWindowActive() @@ -2557,11 +2557,11 @@ bool VulkanRenderer::AcquireNextSwapchainImage(bool mainWindow) if(!IsSwapchainInfoValid(mainWindow)) return false; - if(!mainWindow && m_destroyPadSwapchainNextAcquire) + if(!mainWindow && m_destroyPadSwapchainNextAcquire.test()) { RecreateSwapchain(mainWindow, true); - m_destroyPadSwapchainNextAcquire = false; - m_padCloseReadySemaphore.notify(); + m_destroyPadSwapchainNextAcquire.clear(); + m_destroyPadSwapchainNextAcquire.notify_all(); return false; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index e0a4c75b..47097dfa 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -414,8 +414,7 @@ private: }m_state; std::unique_ptr m_mainSwapchainInfo{}, m_padSwapchainInfo{}; - Semaphore m_padCloseReadySemaphore; - bool m_destroyPadSwapchainNextAcquire = false; + std::atomic_flag m_destroyPadSwapchainNextAcquire{}; bool IsSwapchainInfoValid(bool mainWindow) const; VkRenderPass m_imguiRenderPass = VK_NULL_HANDLE; diff --git a/src/input/motion/MotionSample.h b/src/input/motion/MotionSample.h index bb47f784..0697711b 100644 --- a/src/input/motion/MotionSample.h +++ b/src/input/motion/MotionSample.h @@ -258,48 +258,48 @@ DRC flat on table, screen facing up. Top pointing away (away from person, pointi 0.03 0.99 -0.13 0.01 0.13 0.99 -Turned 45° to the right: +Turned 45° to the right: 0.71 -0.03 0.71 0.12 0.99 -0.08 -0.70 0.14 0.70 -Turned 45° to the right (top of GamePad pointing right now): +Turned 45° to the right (top of GamePad pointing right now): 0.08 -0.03 1.00 -> Z points towards person 0.15 0.99 0.01 -0.99 0.15 0.09 -> DRC Z-Axis now points towards X-minus -Turned 90° to the right (top of gamepad now pointing towards holder, away from monitor): +Turned 90° to the right (top of gamepad now pointing towards holder, away from monitor): -1.00 -0.01 0.06 0.00 0.99 0.15 -0.06 0.15 -0.99 -Turned 90° to the right (pointing left): +Turned 90° to the right (pointing left): -0.17 -0.01 -0.99 -0.13 0.99 0.02 0.98 0.13 -0.17 -After another 90° we end up in the initial position: +After another 90° we end up in the initial position: 0.99 -0.03 -0.11 0.01 0.99 -0.13 0.12 0.12 0.99 ------ -From initial position, lean the GamePad on its left side. 45° up. So the screen is pointing to the top left +From initial position, lean the GamePad on its left side. 45° up. So the screen is pointing to the top left 0.66 -0.75 -0.03 0.74 0.66 -0.11 0.10 0.05 0.99 -Further 45°, GamePad now on its left, screen pointing left: +Further 45°, GamePad now on its left, screen pointing left: -0.03 -1.00 -0.00 0.99 -0.03 -0.15 0.15 -0.01 0.99 -From initial position, lean the GamePad on its right side. 45° up. So the screen is pointing to the top right +From initial position, lean the GamePad on its right side. 45° up. So the screen is pointing to the top right 0.75 0.65 -0.11 -0.65 0.76 0.07 0.12 0.02 0.99 -From initial position, tilt the GamePad up 90° (bottom side remains in touch with surface): +From initial position, tilt the GamePad up 90° (bottom side remains in touch with surface): 0.99 -0.05 -0.10 -0.10 0.01 -0.99 0.05 1.00 0.01 @@ -309,7 +309,7 @@ From initial position, stand the GamePad on its top side: 0.09 -0.01 1.00 -0.01 -1.00 -0.01 -Rotate GamePad 180° around x axis, so it now lies on its screen (top of GamePad pointing to holder): +Rotate GamePad 180° around x axis, so it now lies on its screen (top of GamePad pointing to holder): 0.99 -0.03 -0.15 -0.04 -1.00 -0.08 -0.15 0.09 -0.99 From 4d609f06b810a6bc686aa783a2b716e3cd280f0e Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:22:48 +0100 Subject: [PATCH 118/314] InputSettings: Fix controller type counter to restore WPAD limit (#1118) --- src/gui/input/InputSettings2.cpp | 32 ++++---------------------------- src/gui/input/InputSettings2.h | 3 --- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 58c168a3..72bf4f7d 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -295,32 +295,6 @@ wxWindow* InputSettings2::initialize_page(size_t index) return page; } -std::pair InputSettings2::get_emulated_controller_types() const -{ - size_t vpad = 0, wpad = 0; - for(size_t i = 0; i < m_notebook->GetPageCount(); ++i) - { - auto* page = m_notebook->GetPage(i); - auto* page_data = (wxControllerPageData*)page->GetClientObject(); - if (!page_data) - continue; - - if (!page_data->ref().m_controller) // = disabled - continue; - - const auto api_type = page_data->ref().m_controller->type(); - if (api_type) - continue; - - if (api_type == EmulatedController::VPAD) - ++vpad; - else - ++wpad; - } - - return std::make_pair(vpad, wpad); -} - std::shared_ptr InputSettings2::get_active_controller() const { auto& page_data = get_current_page_data(); @@ -771,14 +745,16 @@ void InputSettings2::on_emulated_controller_dropdown(wxCommandEvent& event) wxWindowUpdateLocker lock(emulated_controllers); bool is_gamepad_selected = false; + bool is_wpad_selected = false; const auto selected = emulated_controllers->GetSelection(); const auto selected_value = emulated_controllers->GetStringSelection(); if(selected != wxNOT_FOUND) { is_gamepad_selected = selected_value == to_wxString(EmulatedController::type_to_string(EmulatedController::Type::VPAD)); + is_wpad_selected = !is_gamepad_selected && selected != 0; } - const auto [vpad_count, wpad_count] = get_emulated_controller_types(); + const auto [vpad_count, wpad_count] = InputManager::instance().get_controller_count(); emulated_controllers->Clear(); emulated_controllers->AppendString(_("Disabled")); @@ -786,7 +762,7 @@ void InputSettings2::on_emulated_controller_dropdown(wxCommandEvent& event) if (vpad_count < InputManager::kMaxVPADControllers || is_gamepad_selected) emulated_controllers->Append(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::VPAD))); - if (wpad_count < InputManager::kMaxWPADControllers || !is_gamepad_selected) + if (wpad_count < InputManager::kMaxWPADControllers || is_wpad_selected) { emulated_controllers->AppendString(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::Pro))); emulated_controllers->AppendString(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::Classic))); diff --git a/src/gui/input/InputSettings2.h b/src/gui/input/InputSettings2.h index 01313653..1a3c8bb1 100644 --- a/src/gui/input/InputSettings2.h +++ b/src/gui/input/InputSettings2.h @@ -27,9 +27,6 @@ private: wxWindow* initialize_page(size_t index); - // count active controllers - std::pair get_emulated_controller_types() const; - // currently selected controller from active tab std::shared_ptr get_active_controller() const; From 17060752b6d5bc952446e26c4cd4b0d259653ced Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sun, 24 Mar 2024 10:57:08 +0100 Subject: [PATCH 119/314] Vulkan: Several swapchain fixes and refactors (#1132) --- .../Latte/Renderer/Vulkan/SwapchainInfoVk.cpp | 91 +++++++++---------- .../Latte/Renderer/Vulkan/SwapchainInfoVk.h | 25 ++--- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 54 ++++++++--- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 13 ++- 4 files changed, 99 insertions(+), 84 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp index 14b7a17c..b00f5490 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp @@ -1,15 +1,34 @@ #include "SwapchainInfoVk.h" #include "config/CemuConfig.h" +#include "gui/guiWrapper.h" #include "Cafe/HW/Latte/Core/Latte.h" #include "Cafe/HW/Latte/Core/LatteTiming.h" #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" +#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h" -void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDevice) +SwapchainInfoVk::SwapchainInfoVk(bool mainWindow, Vector2i size) : mainWindow(mainWindow), m_desiredExtent(size) { - m_physicalDevice = physicalDevice; - m_logicalDevice = logicalDevice; - const auto details = QuerySwapchainSupport(surface, physicalDevice); + auto& windowHandleInfo = mainWindow ? gui_getWindowInfo().canvas_main : gui_getWindowInfo().canvas_pad; + auto renderer = VulkanRenderer::GetInstance(); + m_instance = renderer->GetVkInstance(); + m_logicalDevice = renderer->GetLogicalDevice(); + m_physicalDevice = renderer->GetPhysicalDevice(); + + m_surface = renderer->CreateFramebufferSurface(m_instance, windowHandleInfo); +} + + +SwapchainInfoVk::~SwapchainInfoVk() +{ + Cleanup(); + if(m_surface != VK_NULL_HANDLE) + vkDestroySurfaceKHR(m_instance, m_surface, nullptr); +} + +void SwapchainInfoVk::Create() +{ + const auto details = QuerySwapchainSupport(m_surface, m_physicalDevice); m_surfaceFormat = ChooseSurfaceFormat(details.formats); m_actualExtent = ChooseSwapExtent(details.capabilities); @@ -20,28 +39,28 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe if(image_count < 2) cemuLog_log(LogType::Force, "Vulkan: Swapchain image count less than 2 may cause problems"); - VkSwapchainCreateInfoKHR create_info = CreateSwapchainCreateInfo(surface, details, m_surfaceFormat, image_count, m_actualExtent); + VkSwapchainCreateInfoKHR create_info = CreateSwapchainCreateInfo(m_surface, details, m_surfaceFormat, image_count, m_actualExtent); create_info.oldSwapchain = nullptr; create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; - VkResult result = vkCreateSwapchainKHR(logicalDevice, &create_info, nullptr, &swapchain); + VkResult result = vkCreateSwapchainKHR(m_logicalDevice, &create_info, nullptr, &m_swapchain); if (result != VK_SUCCESS) UnrecoverableError("Error attempting to create a swapchain"); - result = vkGetSwapchainImagesKHR(logicalDevice, swapchain, &image_count, nullptr); + result = vkGetSwapchainImagesKHR(m_logicalDevice, m_swapchain, &image_count, nullptr); if (result != VK_SUCCESS) UnrecoverableError("Error attempting to retrieve the count of swapchain images"); m_swapchainImages.resize(image_count); - result = vkGetSwapchainImagesKHR(logicalDevice, swapchain, &image_count, m_swapchainImages.data()); + result = vkGetSwapchainImagesKHR(m_logicalDevice, m_swapchain, &image_count, m_swapchainImages.data()); if (result != VK_SUCCESS) UnrecoverableError("Error attempting to retrieve swapchain images"); // create default renderpass VkAttachmentDescription colorAttachment = {}; colorAttachment.format = m_surfaceFormat.format; colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT; - colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; @@ -62,7 +81,7 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe renderPassInfo.pAttachments = &colorAttachment; renderPassInfo.subpassCount = 1; renderPassInfo.pSubpasses = &subpass; - result = vkCreateRenderPass(logicalDevice, &renderPassInfo, nullptr, &m_swapchainRenderPass); + result = vkCreateRenderPass(m_logicalDevice, &renderPassInfo, nullptr, &m_swapchainRenderPass); if (result != VK_SUCCESS) UnrecoverableError("Failed to create renderpass for swapchain"); @@ -84,7 +103,7 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe createInfo.subresourceRange.levelCount = 1; createInfo.subresourceRange.baseArrayLayer = 0; createInfo.subresourceRange.layerCount = 1; - result = vkCreateImageView(logicalDevice, &createInfo, nullptr, &m_swapchainImageViews[i]); + result = vkCreateImageView(m_logicalDevice, &createInfo, nullptr, &m_swapchainImageViews[i]); if (result != VK_SUCCESS) UnrecoverableError("Failed to create imageviews for swapchain"); } @@ -104,7 +123,7 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe framebufferInfo.width = m_actualExtent.width; framebufferInfo.height = m_actualExtent.height; framebufferInfo.layers = 1; - result = vkCreateFramebuffer(logicalDevice, &framebufferInfo, nullptr, &m_swapchainFramebuffers[i]); + result = vkCreateFramebuffer(m_logicalDevice, &framebufferInfo, nullptr, &m_swapchainFramebuffers[i]); if (result != VK_SUCCESS) UnrecoverableError("Failed to create framebuffer for swapchain"); } @@ -114,7 +133,7 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe VkSemaphoreCreateInfo info = {}; info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; for (auto& semaphore : m_presentSemaphores){ - if (vkCreateSemaphore(logicalDevice, &info, nullptr, &semaphore) != VK_SUCCESS) + if (vkCreateSemaphore(m_logicalDevice, &info, nullptr, &semaphore) != VK_SUCCESS) UnrecoverableError("Failed to create semaphore for swapchain present"); } @@ -123,14 +142,14 @@ void SwapchainInfoVk::Create(VkPhysicalDevice physicalDevice, VkDevice logicalDe info = {}; info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; for (auto& semaphore : m_acquireSemaphores){ - if (vkCreateSemaphore(logicalDevice, &info, nullptr, &semaphore) != VK_SUCCESS) + if (vkCreateSemaphore(m_logicalDevice, &info, nullptr, &semaphore) != VK_SUCCESS) UnrecoverableError("Failed to create semaphore for swapchain acquire"); } VkFenceCreateInfo fenceInfo = {}; fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; - result = vkCreateFence(logicalDevice, &fenceInfo, nullptr, &m_imageAvailableFence); + result = vkCreateFence(m_logicalDevice, &fenceInfo, nullptr, &m_imageAvailableFence); if (result != VK_SUCCESS) UnrecoverableError("Failed to create fence for swapchain"); @@ -167,19 +186,20 @@ void SwapchainInfoVk::Cleanup() if (m_imageAvailableFence) { + WaitAvailableFence(); vkDestroyFence(m_logicalDevice, m_imageAvailableFence, nullptr); m_imageAvailableFence = nullptr; } - if (swapchain) + if (m_swapchain) { - vkDestroySwapchainKHR(m_logicalDevice, swapchain, nullptr); - swapchain = VK_NULL_HANDLE; + vkDestroySwapchainKHR(m_logicalDevice, m_swapchain, nullptr); + m_swapchain = VK_NULL_HANDLE; } } bool SwapchainInfoVk::IsValid() const { - return swapchain && !m_acquireSemaphores.empty(); + return m_swapchain && !m_acquireSemaphores.empty(); } void SwapchainInfoVk::WaitAvailableFence() @@ -207,7 +227,7 @@ bool SwapchainInfoVk::AcquireImage(uint64 timeout) ResetAvailableFence(); VkSemaphore acquireSemaphore = m_acquireSemaphores[m_acquireIndex]; - VkResult result = vkAcquireNextImageKHR(m_logicalDevice, swapchain, timeout, acquireSemaphore, m_imageAvailableFence, &swapchainImageIndex); + VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, timeout, acquireSemaphore, m_imageAvailableFence, &swapchainImageIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) m_shouldRecreate = true; if (result < 0) @@ -231,35 +251,6 @@ void SwapchainInfoVk::UnrecoverableError(const char* errMsg) throw std::runtime_error(errMsg); } -SwapchainInfoVk::QueueFamilyIndices SwapchainInfoVk::FindQueueFamilies(VkSurfaceKHR surface, VkPhysicalDevice device) -{ - uint32_t queueFamilyCount = 0; - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr); - - std::vector queueFamilies(queueFamilyCount); - vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies.data()); - - QueueFamilyIndices indices; - for (int i = 0; i < (int)queueFamilies.size(); ++i) - { - const auto& queueFamily = queueFamilies[i]; - if (queueFamily.queueCount > 0 && queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) - indices.graphicsFamily = i; - - VkBool32 presentSupport = false; - const VkResult result = vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport); - if (result != VK_SUCCESS) - throw std::runtime_error(fmt::format("Error while attempting to check if a surface supports presentation: {}", result)); - - if (queueFamily.queueCount > 0 && presentSupport) - indices.presentFamily = i; - - if (indices.IsComplete()) - break; - } - - return indices; -} SwapchainInfoVk::SwapchainSupportDetails SwapchainInfoVk::QuerySwapchainSupport(VkSurfaceKHR surface, const VkPhysicalDevice& device) { @@ -391,7 +382,7 @@ VkSwapchainCreateInfoKHR SwapchainInfoVk::CreateSwapchainCreateInfo(VkSurfaceKHR createInfo.imageArrayLayers = 1; createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - const QueueFamilyIndices indices = FindQueueFamilies(surface, m_physicalDevice); + const VulkanRenderer::QueueFamilyIndices indices = VulkanRenderer::GetInstance()->FindQueueFamilies(surface, m_physicalDevice); m_swapchainQueueFamilyIndices = { (uint32)indices.graphicsFamily, (uint32)indices.presentFamily }; if (indices.graphicsFamily != indices.presentFamily) { diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h index 26dbc7d1..0e8c2ade 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h @@ -14,14 +14,6 @@ struct SwapchainInfoVk SYNC_AND_LIMIT = 3, // synchronize emulated vsync events to monitor vsync. But skip events if rate higher than virtual vsync period }; - struct QueueFamilyIndices - { - int32_t graphicsFamily = -1; - int32_t presentFamily = -1; - - bool IsComplete() const { return graphicsFamily >= 0 && presentFamily >= 0; } - }; - struct SwapchainSupportDetails { VkSurfaceCapabilitiesKHR capabilities; @@ -30,7 +22,7 @@ struct SwapchainInfoVk }; void Cleanup(); - void Create(VkPhysicalDevice physicalDevice, VkDevice logicalDevice); + void Create(); bool IsValid() const; @@ -45,8 +37,6 @@ struct SwapchainInfoVk static void UnrecoverableError(const char* errMsg); - // todo: move this function somewhere more sensible. Not directly swapchain related - static QueueFamilyIndices FindQueueFamilies(VkSurfaceKHR surface, VkPhysicalDevice device); static SwapchainSupportDetails QuerySwapchainSupport(VkSurfaceKHR surface, const VkPhysicalDevice& device); VkPresentModeKHR ChoosePresentMode(const std::vector& modes); @@ -61,14 +51,10 @@ struct SwapchainInfoVk return m_actualExtent; } - SwapchainInfoVk(VkSurfaceKHR surface, bool mainWindow) - : surface(surface), mainWindow(mainWindow) {} + SwapchainInfoVk(bool mainWindow, Vector2i size); SwapchainInfoVk(const SwapchainInfoVk&) = delete; SwapchainInfoVk(SwapchainInfoVk&&) noexcept = default; - ~SwapchainInfoVk() - { - Cleanup(); - } + ~SwapchainInfoVk(); bool mainWindow{}; @@ -77,11 +63,12 @@ struct SwapchainInfoVk VSync m_vsyncState = VSync::Immediate; bool hasDefinedSwapchainImage{}; // indicates if the swapchain image is in a defined state + VkInstance m_instance{}; VkPhysicalDevice m_physicalDevice{}; VkDevice m_logicalDevice{}; - VkSurfaceKHR surface{}; + VkSurfaceKHR m_surface{}; VkSurfaceFormatKHR m_surfaceFormat{}; - VkSwapchainKHR swapchain{}; + VkSwapchainKHR m_swapchain{}; Vector2i m_desiredExtent{}; uint32 swapchainImageIndex = (uint32)-1; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 02bb1e71..e0ebda2a 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -167,6 +167,7 @@ std::vector VulkanRenderer::GetDevices() result.emplace_back(physDeviceProps.properties.deviceName, physDeviceIDProps.deviceUUID); } } + vkDestroySurfaceKHR(instance, surface, nullptr); } catch (...) { @@ -441,7 +442,7 @@ VulkanRenderer::VulkanRenderer() } // create logical device - m_indices = SwapchainInfoVk::FindQueueFamilies(surface, m_physicalDevice); + m_indices = FindQueueFamilies(surface, m_physicalDevice); std::set uniqueQueueFamilies = { m_indices.graphicsFamily, m_indices.presentFamily }; std::vector queueCreateInfos = CreateQueueCreateInfos(uniqueQueueFamilies); VkPhysicalDeviceFeatures deviceFeatures = {}; @@ -510,7 +511,7 @@ VulkanRenderer::VulkanRenderer() PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT = reinterpret_cast(vkGetInstanceProcAddr(m_instance, "vkCreateDebugUtilsMessengerEXT")); VkDebugUtilsMessengerCreateInfoEXT debugCallback{}; - debugCallback.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; + debugCallback.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; debugCallback.pNext = nullptr; debugCallback.flags = 0; debugCallback.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; @@ -673,24 +674,19 @@ VulkanRenderer* VulkanRenderer::GetInstance() void VulkanRenderer::InitializeSurface(const Vector2i& size, bool mainWindow) { - auto& windowHandleInfo = mainWindow ? gui_getWindowInfo().canvas_main : gui_getWindowInfo().canvas_pad; - - const auto surface = CreateFramebufferSurface(m_instance, windowHandleInfo); if (mainWindow) { - m_mainSwapchainInfo = std::make_unique(surface, mainWindow); - m_mainSwapchainInfo->m_desiredExtent = size; - m_mainSwapchainInfo->Create(m_physicalDevice, m_logicalDevice); + m_mainSwapchainInfo = std::make_unique(mainWindow, size); + m_mainSwapchainInfo->Create(); // aquire first command buffer InitFirstCommandBuffer(); } else { - m_padSwapchainInfo = std::make_unique(surface, mainWindow); - m_padSwapchainInfo->m_desiredExtent = size; + m_padSwapchainInfo = std::make_unique(mainWindow, size); // todo: figure out a way to exclusively create swapchain on main LatteThread - m_padSwapchainInfo->Create(m_physicalDevice, m_logicalDevice); + m_padSwapchainInfo->Create(); } } @@ -1074,6 +1070,36 @@ RendererShader* VulkanRenderer::shader_create(RendererShader::ShaderType type, u return new RendererShaderVk(type, baseHash, auxHash, isGameShader, isGfxPackShader, source); } +VulkanRenderer::QueueFamilyIndices VulkanRenderer::FindQueueFamilies(VkSurfaceKHR surface, VkPhysicalDevice device) +{ + uint32_t queueFamilyCount = 0; + vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr); + + std::vector queueFamilies(queueFamilyCount); + vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies.data()); + + QueueFamilyIndices indices; + for (int i = 0; i < (int)queueFamilies.size(); ++i) + { + const auto& queueFamily = queueFamilies[i]; + if (queueFamily.queueCount > 0 && queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) + indices.graphicsFamily = i; + + VkBool32 presentSupport = false; + const VkResult result = vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport); + if (result != VK_SUCCESS) + throw std::runtime_error(fmt::format("Error while attempting to check if a surface supports presentation: {}", result)); + + if (queueFamily.queueCount > 0 && presentSupport) + indices.presentFamily = i; + + if (indices.IsComplete()) + break; + } + + return indices; +} + bool VulkanRenderer::CheckDeviceExtensionSupport(const VkPhysicalDevice device, FeatureControl& info) { std::vector availableDeviceExtensions; @@ -1215,7 +1241,7 @@ std::vector VulkanRenderer::CheckInstanceExtensionSupport(FeatureCo bool VulkanRenderer::IsDeviceSuitable(VkSurfaceKHR surface, const VkPhysicalDevice& device) { - if (!SwapchainInfoVk::FindQueueFamilies(surface, device).IsComplete()) + if (!FindQueueFamilies(surface, device).IsComplete()) return false; // check API version (using Vulkan 1.0 way of querying properties) @@ -2605,7 +2631,7 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate) chainInfo.m_desiredExtent = size; if(!skipCreate) { - chainInfo.Create(m_physicalDevice, m_logicalDevice); + chainInfo.Create(); } if (mainWindow) @@ -2675,7 +2701,7 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) VkPresentInfoKHR presentInfo = {}; presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; presentInfo.swapchainCount = 1; - presentInfo.pSwapchains = &chainInfo.swapchain; + presentInfo.pSwapchains = &chainInfo.m_swapchain; presentInfo.pImageIndices = &chainInfo.swapchainImageIndex; // wait on command buffer semaphore presentInfo.waitSemaphoreCount = 1; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 47097dfa..2491d052 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -127,7 +127,6 @@ class VulkanRenderer : public Renderer friend class PipelineCompiler; using VSync = SwapchainInfoVk::VSync; - using QueueFamilyIndices = SwapchainInfoVk::QueueFamilyIndices; static const inline int UNIFORMVAR_RINGBUFFER_SIZE = 1024 * 1024 * 16; // 16MB @@ -421,6 +420,18 @@ private: VkDescriptorPool m_descriptorPool; + public: + struct QueueFamilyIndices + { + int32_t graphicsFamily = -1; + int32_t presentFamily = -1; + + bool IsComplete() const { return graphicsFamily >= 0 && presentFamily >= 0; } + }; + static QueueFamilyIndices FindQueueFamilies(VkSurfaceKHR surface, VkPhysicalDevice device); + + private: + struct FeatureControl { struct From 241915e1a6bfd92e4ffd0d6961a178335300e83f Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Sun, 24 Mar 2024 10:11:18 +0000 Subject: [PATCH 120/314] Gamelist: Display title long names + improvements for shortcuts (#1126) - Windows icons are stored as .ico files to %LOCALAPPDATA%/Cemu/icons/ - Long title names chosen as some games (NSMBU + NSLU) add trailing dots for their shortnames - Long title names have their newlines replaced with spaces at parsing - Linux shortcut paths are saved with UTF-8 encoding - Game titles are copied and saved with UTF-8 encoding --- src/Cafe/TitleList/ParsedMetaXml.h | 7 +- src/Cafe/TitleList/TitleInfo.cpp | 4 +- src/gui/CemuApp.cpp | 7 +- src/gui/components/wxGameList.cpp | 272 ++++++++++++++++------------- 4 files changed, 168 insertions(+), 122 deletions(-) diff --git a/src/Cafe/TitleList/ParsedMetaXml.h b/src/Cafe/TitleList/ParsedMetaXml.h index 7537d603..f1aee37e 100644 --- a/src/Cafe/TitleList/ParsedMetaXml.h +++ b/src/Cafe/TitleList/ParsedMetaXml.h @@ -90,8 +90,11 @@ struct ParsedMetaXml else if (boost::starts_with(name, "longname_")) { const sint32 index = GetLanguageIndex(name.substr(std::size("longname_") - 1)); - if (index != -1) - parsedMetaXml->m_long_name[index] = child.text().as_string(); + if (index != -1){ + std::string longname = child.text().as_string(); + std::replace_if(longname.begin(), longname.end(), [](char c) { return c == '\r' || c == '\n';}, ' '); + parsedMetaXml->m_long_name[index] = longname; + } } else if (boost::starts_with(name, L"shortname_")) { diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index ff457575..d23e1d0a 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -637,9 +637,9 @@ std::string TitleInfo::GetMetaTitleName() const if (m_parsedMetaXml) { std::string titleNameCfgLanguage; - titleNameCfgLanguage = m_parsedMetaXml->GetShortName(GetConfig().console_language); + titleNameCfgLanguage = m_parsedMetaXml->GetLongName(GetConfig().console_language); if (titleNameCfgLanguage.empty()) //Get English Title - titleNameCfgLanguage = m_parsedMetaXml->GetShortName(CafeConsoleLanguage::EN); + titleNameCfgLanguage = m_parsedMetaXml->GetLongName(CafeConsoleLanguage::EN); if (titleNameCfgLanguage.empty()) //Unknown Title titleNameCfgLanguage = "Unknown Title"; return titleNameCfgLanguage; diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index fde4bcc0..7f11d4c6 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -59,7 +59,12 @@ bool CemuApp::OnInit() fs::path user_data_path, config_path, cache_path, data_path; auto standardPaths = wxStandardPaths::Get(); fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); - +#if BOOST_OS_LINUX + // GetExecutablePath returns the AppImage's temporary mount location + wxString appImagePath; + if (wxGetEnv(("APPIMAGE"), &appImagePath)) + exePath = wxHelper::MakeFSPath(appImagePath); +#endif // Try a portable path first, if it exists. user_data_path = config_path = cache_path = data_path = exePath.parent_path() / "portable"; #if BOOST_OS_MACOS diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 8e8f3c4d..73bcd98d 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -19,7 +19,6 @@ #include #include - #include #include @@ -526,7 +525,6 @@ void wxGameList::OnKeyDown(wxListEvent& event) } } - enum ContextMenuEntries { kContextMenuRefreshGames = wxID_HIGHEST + 1, @@ -732,7 +730,7 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event) { if (wxTheClipboard->Open()) { - wxTheClipboard->SetData(new wxTextDataObject(gameInfo.GetTitleName())); + wxTheClipboard->SetData(new wxTextDataObject(wxString::FromUTF8(gameInfo.GetTitleName()))); wxTheClipboard->Close(); } break; @@ -1276,129 +1274,169 @@ void wxGameList::DeleteCachedStrings() m_name_cache.clear(); } -#if BOOST_OS_LINUX || BOOST_OS_WINDOWS -void wxGameList::CreateShortcut(GameInfo2& gameInfo) { - const auto title_id = gameInfo.GetBaseTitleId(); - const auto title_name = gameInfo.GetTitleName(); - auto exe_path = ActiveSettings::GetExecutablePath(); - const char *flatpak_id = getenv("FLATPAK_ID"); - - // GetExecutablePath returns the AppImage's temporary mount location, instead of its actual path - wxString appimage_path; - if (wxGetEnv(("APPIMAGE"), &appimage_path)) { - exe_path = appimage_path.utf8_string(); - } - #if BOOST_OS_LINUX - const wxString desktop_entry_name = wxString::Format("%s.desktop", title_name); - wxFileDialog entry_dialog(this, _("Choose desktop entry location"), "~/.local/share/applications", desktop_entry_name, - "Desktop file (*.desktop)|*.desktop", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT); -#elif BOOST_OS_WINDOWS - // Get '%APPDATA%\Microsoft\Windows\Start Menu\Programs' path - PWSTR user_shortcut_folder; - SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &user_shortcut_folder); - const wxString shortcut_name = wxString::Format("%s.lnk", title_name); - wxFileDialog entry_dialog(this, _("Choose shortcut location"), _pathToUtf8(user_shortcut_folder), shortcut_name, - "Shortcut (*.lnk)|*.lnk", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT); -#endif - const auto result = entry_dialog.ShowModal(); - if (result == wxID_CANCEL) - return; - const auto output_path = entry_dialog.GetPath(); +void wxGameList::CreateShortcut(GameInfo2& gameInfo) +{ + const auto titleId = gameInfo.GetBaseTitleId(); + const auto titleName = wxString::FromUTF8(gameInfo.GetTitleName()); + auto exePath = ActiveSettings::GetExecutablePath(); + const char* flatpakId = getenv("FLATPAK_ID"); -#if BOOST_OS_LINUX - std::optional icon_path; - // Obtain and convert icon - { - m_icon_cache_mtx.lock(); - const auto icon_iter = m_icon_cache.find(title_id); - const auto result_index = (icon_iter != m_icon_cache.cend()) ? std::optional(icon_iter->second.first) : std::nullopt; - m_icon_cache_mtx.unlock(); + const wxString desktopEntryName = wxString::Format("%s.desktop", titleName); + wxFileDialog entryDialog(this, _("Choose desktop entry location"), "~/.local/share/applications", desktopEntryName, + "Desktop file (*.desktop)|*.desktop", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT); + const auto result = entryDialog.ShowModal(); + if (result == wxID_CANCEL) + return; + const auto output_path = entryDialog.GetPath(); - // In most cases it should find it - if (!result_index){ - wxMessageBox(_("Icon is yet to load, so will not be used by the shortcut"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); - } - else { - const fs::path out_icon_dir = ActiveSettings::GetUserDataPath("icons"); + std::optional iconPath; + // Obtain and convert icon + [&]() + { + int iconIndex, smallIconIndex; - if (!fs::exists(out_icon_dir) && !fs::create_directories(out_icon_dir)){ - wxMessageBox(_("Cannot access the icon directory, the shortcut will have no icon"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); - } - else { - icon_path = out_icon_dir / fmt::format("{:016x}.png", gameInfo.GetBaseTitleId()); + if (!QueryIconForTitle(titleId, iconIndex, smallIconIndex)) + { + cemuLog_log(LogType::Force, "Icon hasn't loaded"); + return; + } + const fs::path outIconDir = ActiveSettings::GetUserDataPath("icons"); - auto image = m_image_list->GetIcon(result_index.value()).ConvertToImage(); + if (!fs::exists(outIconDir) && !fs::create_directories(outIconDir)) + { + cemuLog_log(LogType::Force, "Failed to create icon directory"); + return; + } - wxFileOutputStream png_file(_pathToUtf8(icon_path.value())); - wxPNGHandler pngHandler; - if (!pngHandler.SaveFile(&image, png_file, false)) { - icon_path = std::nullopt; - wxMessageBox(_("The icon was unable to be saved, the shortcut will have no icon"), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); - } - } - } - } + iconPath = outIconDir / fmt::format("{:016x}.png", gameInfo.GetBaseTitleId()); + wxFileOutputStream pngFileStream(_pathToUtf8(iconPath.value())); - std::string desktop_exec_entry; - if (flatpak_id) - desktop_exec_entry = fmt::format("/usr/bin/flatpak run {0} --title-id {1:016x}", flatpak_id, title_id); - else - desktop_exec_entry = fmt::format("{0:?} --title-id {1:016x}", _pathToUtf8(exe_path), title_id); + auto image = m_image_list->GetIcon(iconIndex).ConvertToImage(); + wxPNGHandler pngHandler; + if (!pngHandler.SaveFile(&image, pngFileStream, false)) + { + iconPath = std::nullopt; + cemuLog_log(LogType::Force, "Icon failed to save"); + } + }(); - // 'Icon' accepts spaces in file name, does not accept quoted file paths - // 'Exec' does not accept non-escaped spaces, and can accept quoted file paths - auto desktop_entry_string = - fmt::format("[Desktop Entry]\n" - "Name={0}\n" - "Comment=Play {0} on Cemu\n" - "Exec={1}\n" - "Icon={2}\n" - "Terminal=false\n" - "Type=Application\n" - "Categories=Game;\n", - title_name, - desktop_exec_entry, - _pathToUtf8(icon_path.value_or(""))); + std::string desktopExecEntry = flatpakId ? fmt::format("/usr/bin/flatpak run {0} --title-id {1:016x}", flatpakId, titleId) + : fmt::format("{0:?} --title-id {1:016x}", _pathToUtf8(exePath), titleId); - if (flatpak_id) - desktop_entry_string += fmt::format("X-Flatpak={}\n", flatpak_id); + // 'Icon' accepts spaces in file name, does not accept quoted file paths + // 'Exec' does not accept non-escaped spaces, and can accept quoted file paths + auto desktopEntryString = fmt::format( + "[Desktop Entry]\n" + "Name={0}\n" + "Comment=Play {0} on Cemu\n" + "Exec={1}\n" + "Icon={2}\n" + "Terminal=false\n" + "Type=Application\n" + "Categories=Game;\n", + titleName.utf8_string(), + desktopExecEntry, + _pathToUtf8(iconPath.value_or(""))); - std::ofstream output_stream(output_path); - if (!output_stream.good()) - { - auto errorMsg = formatWxString(_("Failed to save desktop entry to {}"), output_path.utf8_string()); - wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); - return; - } - output_stream << desktop_entry_string; + if (flatpakId) + desktopEntryString += fmt::format("X-Flatpak={}\n", flatpakId); -#elif BOOST_OS_WINDOWS - IShellLinkW *shell_link; - HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast(&shell_link)); - if (SUCCEEDED(hres)) - { - const auto description = wxString::Format("Play %s on Cemu", title_name); - const auto args = wxString::Format("-t %016llx", title_id); - - shell_link->SetPath(exe_path.wstring().c_str()); - shell_link->SetDescription(description.wc_str()); - shell_link->SetArguments(args.wc_str()); - shell_link->SetWorkingDirectory(exe_path.parent_path().wstring().c_str()); - // Use icon from Cemu exe for now since we can't embed icons into the shortcut - // in the future we could convert and store icons in AppData or ProgramData - shell_link->SetIconLocation(exe_path.wstring().c_str(), 0); - - IPersistFile *shell_link_file; - // save the shortcut - hres = shell_link->QueryInterface(IID_IPersistFile, reinterpret_cast(&shell_link_file)); - if (SUCCEEDED(hres)) - { - hres = shell_link_file->Save(output_path.wc_str(), TRUE); - shell_link_file->Release(); - } - shell_link->Release(); - } -#endif + std::ofstream outputStream(output_path.utf8_string()); + if (!outputStream.good()) + { + auto errorMsg = formatWxString(_("Failed to save desktop entry to {}"), output_path.utf8_string()); + wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + return; + } + outputStream << desktopEntryString; } -#endif +#elif BOOST_OS_WINDOWS +void wxGameList::CreateShortcut(GameInfo2& gameInfo) +{ + const auto titleId = gameInfo.GetBaseTitleId(); + const auto titleName = wxString::FromUTF8(gameInfo.GetTitleName()); + auto exePath = ActiveSettings::GetExecutablePath(); + + // Get '%APPDATA%\Microsoft\Windows\Start Menu\Programs' path + PWSTR userShortcutFolder; + SHGetKnownFolderPath(FOLDERID_Programs, 0, NULL, &userShortcutFolder); + const wxString shortcutName = wxString::Format("%s.lnk", titleName); + wxFileDialog shortcutDialog(this, _("Choose shortcut location"), _pathToUtf8(userShortcutFolder), shortcutName, + "Shortcut (*.lnk)|*.lnk", wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT); + + const auto result = shortcutDialog.ShowModal(); + if (result == wxID_CANCEL) + return; + const auto outputPath = shortcutDialog.GetPath(); + + std::optional icon_path = std::nullopt; + [&]() + { + int iconIdx; + int smallIconIdx; + if (!QueryIconForTitle(titleId, iconIdx, smallIconIdx)) + { + cemuLog_log(LogType::Force, "Icon hasn't loaded"); + return; + } + const auto icon = m_image_list->GetIcon(iconIdx); + PWSTR localAppData; + const auto hres = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &localAppData); + wxBitmap bitmap{}; + auto folder = fs::path(localAppData) / "Cemu" / "icons"; + if (!SUCCEEDED(hres) || (!fs::exists(folder) && !fs::create_directories(folder))) + { + cemuLog_log(LogType::Force, "Failed to create icon directory"); + return; + } + if (!bitmap.CopyFromIcon(icon)) + { + cemuLog_log(LogType::Force, "Failed to copy icon"); + return; + } + + icon_path = folder / fmt::format("{:016x}.ico", titleId); + auto stream = wxFileOutputStream(_pathToUtf8(*icon_path)); + auto image = bitmap.ConvertToImage(); + wxICOHandler icohandler{}; + if (!icohandler.SaveFile(&image, stream, false)) + { + icon_path = std::nullopt; + cemuLog_log(LogType::Force, "Icon failed to save"); + } + }(); + + IShellLinkW* shellLink; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast(&shellLink)); + if (SUCCEEDED(hres)) + { + const auto description = wxString::Format("Play %s on Cemu", titleName); + const auto args = wxString::Format("-t %016llx", titleId); + + shellLink->SetPath(exePath.wstring().c_str()); + shellLink->SetDescription(description.wc_str()); + shellLink->SetArguments(args.wc_str()); + shellLink->SetWorkingDirectory(exePath.parent_path().wstring().c_str()); + + if (icon_path) + shellLink->SetIconLocation(icon_path->wstring().c_str(), 0); + else + shellLink->SetIconLocation(exePath.wstring().c_str(), 0); + + IPersistFile* shellLinkFile; + // save the shortcut + hres = shellLink->QueryInterface(IID_IPersistFile, reinterpret_cast(&shellLinkFile)); + if (SUCCEEDED(hres)) + { + hres = shellLinkFile->Save(outputPath.wc_str(), TRUE); + shellLinkFile->Release(); + } + shellLink->Release(); + } + if (!SUCCEEDED(hres)) { + auto errorMsg = formatWxString(_("Failed to save shortcut to {}"), outputPath); + wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + } +} +#endif \ No newline at end of file From 4d148b369660db629c225bf1ff0e354d025e7902 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Mon, 25 Mar 2024 21:34:40 +0100 Subject: [PATCH 121/314] Add supported locales to macOS plist (#1133) --- src/resource/MacOSXBundleInfo.plist.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/resource/MacOSXBundleInfo.plist.in b/src/resource/MacOSXBundleInfo.plist.in index 98064735..ccd1c922 100644 --- a/src/resource/MacOSXBundleInfo.plist.in +++ b/src/resource/MacOSXBundleInfo.plist.in @@ -30,6 +30,28 @@ ${MACOSX_BUNDLE_CATEGORY} LSMinimumSystemVersion ${MACOSX_MINIMUM_SYSTEM_VERSION} + CFBundleLocalizations + + ca + de + en + es + fr + he + hu + it + ja + ko + nb + nl + pl + pt + ru + sv + tr + uk + zh + CFBundleDocumentTypes From 4b7d2f88ae044a590dfa7faeadee1e03047492f0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 25 Mar 2024 21:02:37 +0100 Subject: [PATCH 122/314] Latte: Enable colorbuffer optimization if gfx packs are aware The optimization for colorbuffer resolution introduced in PR #706 is now enabled. This optimization changes the resolution of certain framebuffer textures, which may conflict with the texture resolution rules set by some graphic packs. As a result, if a graphic pack that specifies texture resolution rules is in use, the optimization will automatically be turned off to prevent any issues. To circumvent this, graphic packs can now include the setting "colorbufferOptimizationAware = true" in their rules.txt. This setting indicates that the pack has been updated to handle the resolution changes introduced by the optimization. Cemu will allow the optimization to remain enabled if resolution packs have this flag set. --- src/Cafe/GraphicPack/GraphicPack2.cpp | 4 ++++ src/Cafe/GraphicPack/GraphicPack2.h | 3 +++ src/Cafe/HW/Latte/Core/Latte.h | 2 ++ src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 21 ++++++++++---------- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 7 ++++--- src/Cafe/HW/Latte/Core/LatteThread.cpp | 17 ++++++++++++++++ 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index b581316e..27d423b9 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -280,6 +280,10 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) m_enabled = m_default_enabled; } + auto option_allowRendertargetSizeOptimization = rules.FindOption("colorbufferOptimizationAware"); + if (option_allowRendertargetSizeOptimization) + m_allowRendertargetSizeOptimization = boost::iequals(*option_allowRendertargetSizeOptimization, "true") || boost::iequals(*option_allowRendertargetSizeOptimization, "1"); + auto option_vendorFilter = rules.FindOption("vendorFilter"); if (option_vendorFilter) { diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index 6b07cce9..9b6a86d4 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -113,6 +113,7 @@ public: const std::string& GetVirtualPath() const { return m_virtualPath; } // returns the path in the gfx tree hierarchy const std::string& GetDescription() const { return m_description; } bool IsDefaultEnabled() const { return m_default_enabled; } + bool AllowRendertargetSizeOptimization() const { return m_allowRendertargetSizeOptimization; } void SetEnabled(bool state) { m_enabled = state; } @@ -217,6 +218,8 @@ private: bool m_default_enabled = false; + bool m_allowRendertargetSizeOptimization = false; // gfx pack supports framebuffers with non-padded sizes, which is an optional optimization introduced with Cemu 2.0-74 + // filter std::optional m_renderer_api; std::optional m_gfx_vendor; diff --git a/src/Cafe/HW/Latte/Core/Latte.h b/src/Cafe/HW/Latte/Core/Latte.h index d9419a6a..e8cb2be4 100644 --- a/src/Cafe/HW/Latte/Core/Latte.h +++ b/src/Cafe/HW/Latte/Core/Latte.h @@ -25,6 +25,8 @@ struct LatteGPUState_t // context control uint32 contextControl0; uint32 contextControl1; + // optional features + bool allowFramebufferSizeOptimization{false}; // allow using scissor box as size hint to determine non-padded rendertarget size // draw context struct { diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 30069712..f165e257 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -267,14 +267,15 @@ LatteTextureView* LatteMRT::GetColorAttachmentTexture(uint32 index, bool createN // colorbuffer width/height has to be padded to 8/32 alignment but the actual resolution might be smaller // use the scissor box as a clue to figure out the original resolution if possible -#if 0 - uint32 scissorBoxWidth = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_X(); - uint32 scissorBoxHeight = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_Y(); - if (((scissorBoxWidth + 7) & ~7) == colorBufferWidth) - colorBufferWidth = scissorBoxWidth; - if (((colorBufferHeight + 31) & ~31) == colorBufferHeight) - colorBufferHeight = scissorBoxHeight; -#endif + if(LatteGPUState.allowFramebufferSizeOptimization) + { + uint32 scissorBoxWidth = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_X(); + uint32 scissorBoxHeight = LatteGPUState.contextNew.PA_SC_GENERIC_SCISSOR_BR.get_BR_Y(); + if (((scissorBoxWidth + 7) & ~7) == colorBufferWidth) + colorBufferWidth = scissorBoxWidth; + if (((colorBufferHeight + 31) & ~31) == colorBufferHeight) + colorBufferHeight = scissorBoxHeight; + } // log resolution changes if the above heuristic takes effect // this is useful to find resolutions which need to be updated in gfx pack texture rules @@ -303,7 +304,7 @@ LatteTextureView* LatteMRT::GetColorAttachmentTexture(uint32 index, bool createN if (colorBufferView == nullptr) { // create color buffer view - colorBufferView = LatteTexture_CreateMapping(colorBufferPhysMem, 0, colorBufferWidth, colorBufferHeight, (viewFirstSlice + viewNumSlices), colorBufferPitch, colorBufferTileMode, colorBufferSwizzle>>8, viewFirstMip, 1, viewFirstSlice, viewNumSlices, (Latte::E_GX2SURFFMT)colorBufferFormat, (viewFirstSlice + viewNumSlices)>1? Latte::E_DIM::DIM_2D_ARRAY: Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false); + colorBufferView = LatteTexture_CreateMapping(colorBufferPhysMem, 0, colorBufferWidth, colorBufferHeight, (viewFirstSlice + viewNumSlices), colorBufferPitch, colorBufferTileMode, colorBufferSwizzle>>8, viewFirstMip, 1, viewFirstSlice, viewNumSlices, (Latte::E_GX2SURFFMT)colorBufferFormat, (viewFirstSlice + viewNumSlices)>1? Latte::E_DIM::DIM_2D_ARRAY: Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false, true); LatteGPUState.repeatTextureInitialization = true; checkForTextureChanges = false; } @@ -582,7 +583,7 @@ bool LatteMRT::UpdateCurrentFBO() if (!depthBufferView) { // create new depth buffer view and if it doesn't exist then also create the texture - depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, depthBufferViewFirstSlice+1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, depthBufferViewFirstSlice, 1, depthBufferFormat, depthBufferViewFirstSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true); + depthBufferView = LatteTexture_CreateMapping(depthBufferPhysMem, 0, depthBufferWidth, depthBufferHeight, depthBufferViewFirstSlice+1, depthBufferPitch, depthBufferTileMode, depthBufferSwizzle, 0, 1, depthBufferViewFirstSlice, 1, depthBufferFormat, depthBufferViewFirstSlice > 0 ? Latte::E_DIM::DIM_2D_ARRAY : Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, true, true); LatteGPUState.repeatTextureInitialization = true; } else diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index d6f576d4..3754fb19 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -1,5 +1,4 @@ #include "Cafe/HW/Latte/Core/Latte.h" -#include "Cafe/HW/Latte/Core/LatteDraw.h" #include "Cafe/HW/Latte/Core/LatteShader.h" #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" #include "Cafe/HW/Latte/Core/LatteTexture.h" @@ -9,6 +8,8 @@ #include "Cafe/GraphicPack/GraphicPack2.h" +#include + struct TexMemOccupancyEntry { uint32 addrStart; @@ -963,7 +964,7 @@ void LatteTexture_RecreateTextureWithDifferentMipSliceCount(LatteTexture* textur } // create new texture representation -// if allowCreateNewDataTexture is true, a new texture will be created if necessary. If it is false, only existing textures may be used, except if a data-compatible version of the requested texture already exists and it's not view compatible +// if allowCreateNewDataTexture is true, a new texture will be created if necessary. If it is false, only existing textures may be used, except if a data-compatible version of the requested texture already exists and it's not view compatible (todo - we should differentiate between Latte compatible views and renderer compatible) // the returned view will map to the provided mip and slice range within the created texture, this is to match the behavior of lookupSliceEx LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, sint32 width, sint32 height, sint32 depth, sint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, sint32 firstMip, sint32 numMip, sint32 firstSlice, sint32 numSlice, Latte::E_GX2SURFFMT format, Latte::E_DIM dimBase, Latte::E_DIM dimView, bool isDepth, bool allowCreateNewDataTexture) { @@ -980,7 +981,7 @@ LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, si // todo, depth and numSlice are redundant sint32 sliceCount = firstSlice + numSlice; - std::vector list_overlappingTextures; + boost::container::small_vector list_overlappingTextures; for (sint32 sliceIndex = 0; sliceIndex < sliceCount; sliceIndex++) { sint32 mipIndex = 0; diff --git a/src/Cafe/HW/Latte/Core/LatteThread.cpp b/src/Cafe/HW/Latte/Core/LatteThread.cpp index bd312d93..a23bd5be 100644 --- a/src/Cafe/HW/Latte/Core/LatteThread.cpp +++ b/src/Cafe/HW/Latte/Core/LatteThread.cpp @@ -175,6 +175,23 @@ int Latte_ThreadEntry() // before doing anything with game specific shaders, we need to wait for graphic packs to finish loading GraphicPack2::WaitUntilReady(); + // if legacy packs are enabled we cannot use the colorbuffer resolution optimization + LatteGPUState.allowFramebufferSizeOptimization = true; + for(auto& pack : GraphicPack2::GetActiveGraphicPacks()) + { + if(pack->AllowRendertargetSizeOptimization()) + continue; + for(auto& rule : pack->GetTextureRules()) + { + if(rule.filter_settings.width >= 0 || rule.filter_settings.height >= 0 || rule.filter_settings.depth >= 0 || + rule.overwrite_settings.width >= 0 || rule.overwrite_settings.height >= 0 || rule.overwrite_settings.depth >= 0) + { + LatteGPUState.allowFramebufferSizeOptimization = false; + cemuLog_log(LogType::Force, "Graphic pack {} prevents rendertarget size optimization.", pack->GetName()); + break; + } + } + } // load disk shader cache LatteShaderCache_Load(); // init registers From fa4ad9b8c196c0821888c0d882154d10feee673b Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:30:39 +0200 Subject: [PATCH 123/314] Gamelist: Add option to hide the icon column (#604) --- src/config/CemuConfig.cpp | 3 +++ src/config/CemuConfig.h | 2 ++ src/gui/components/wxGameList.cpp | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 1801759a..e4be97a7 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -84,6 +84,8 @@ void CemuConfig::Load(XMLConfigParser& parser) game_list_style = gamelist.get("style", 0); game_list_column_order = gamelist.get("order", ""); + show_icon_column = parser.get("show_icon_column", true); + // return default width if value in config file out of range auto loadColumnSize = [&gamelist] (const char *name, uint32 defaultWidth) { @@ -385,6 +387,7 @@ void CemuConfig::Save(XMLConfigParser& parser) psize.set("x", pad_size.x); psize.set("y", pad_size.y); config.set("pad_maximized", pad_maximized); + config.set("show_icon_column" , show_icon_column); auto gamelist = config.set("GameList"); gamelist.set("style", game_list_style); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index eb552fce..bcaf8467 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -418,6 +418,8 @@ struct CemuConfig ConfigValue did_show_graphic_pack_download{false}; ConfigValue did_show_macos_disclaimer{false}; + ConfigValue show_icon_column{ false }; + int game_list_style = 0; std::string game_list_column_order; struct diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index 73bcd98d..d7c9a4f8 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -88,7 +88,10 @@ wxGameList::wxGameList(wxWindow* parent, wxWindowID id) const auto& config = GetConfig(); InsertColumn(ColumnHiddenName, "", wxLIST_FORMAT_LEFT, 0); - InsertColumn(ColumnIcon, "", wxLIST_FORMAT_LEFT, kListIconWidth); + if(config.show_icon_column) + InsertColumn(ColumnIcon, _("Icon"), wxLIST_FORMAT_LEFT, kListIconWidth); + else + InsertColumn(ColumnIcon, _("Icon"), wxLIST_FORMAT_LEFT, 0); InsertColumn(ColumnName, _("Game"), wxLIST_FORMAT_LEFT, config.column_width.name); InsertColumn(ColumnVersion, _("Version"), wxLIST_FORMAT_RIGHT, config.column_width.version); InsertColumn(ColumnDLC, _("DLC"), wxLIST_FORMAT_RIGHT, config.column_width.dlc); @@ -794,6 +797,7 @@ void wxGameList::OnColumnRightClick(wxListEvent& event) ResetWidth = wxID_HIGHEST + 1, ResetOrder, + ShowIcon, ShowName, ShowVersion, ShowDlc, @@ -810,6 +814,7 @@ void wxGameList::OnColumnRightClick(wxListEvent& event) menu.Append(ResetOrder, _("Reset &order")) ; menu.AppendSeparator(); + menu.AppendCheckItem(ShowIcon, _("Show &icon"))->Check(GetColumnWidth(ColumnIcon) > 0); menu.AppendCheckItem(ShowName, _("Show &name"))->Check(GetColumnWidth(ColumnName) > 0); menu.AppendCheckItem(ShowVersion, _("Show &version"))->Check(GetColumnWidth(ColumnVersion) > 0); menu.AppendCheckItem(ShowDlc, _("Show &dlc"))->Check(GetColumnWidth(ColumnDLC) > 0); @@ -828,6 +833,9 @@ void wxGameList::OnColumnRightClick(wxListEvent& event) switch (event.GetId()) { + case ShowIcon: + config.show_icon_column = menu->IsChecked(ShowIcon); + break; case ShowName: config.column_width.name = menu->IsChecked(ShowName) ? DefaultColumnSize::name : 0; break; @@ -907,7 +915,10 @@ void wxGameList::ApplyGameListColumnWidths() { const auto& config = GetConfig(); wxWindowUpdateLocker lock(this); - SetColumnWidth(ColumnIcon, kListIconWidth); + if(config.show_icon_column) + SetColumnWidth(ColumnIcon, kListIconWidth); + else + SetColumnWidth(ColumnIcon, 0); SetColumnWidth(ColumnName, config.column_width.name); SetColumnWidth(ColumnVersion, config.column_width.version); SetColumnWidth(ColumnDLC, config.column_width.dlc); From 111e383d1b0c2a27001433781e2cba123f991048 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:07:08 +0100 Subject: [PATCH 124/314] coreinit: Fix race condition that causes crash (#1138) --- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 8ce5de07..809d7be4 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -1159,9 +1159,11 @@ namespace coreinit #include std::vector g_schedulerThreadIds; + std::mutex g_schedulerThreadIdsLock; std::vector& OSGetSchedulerThreadIds() { + std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock); return g_schedulerThreadIds; } #endif @@ -1183,7 +1185,10 @@ namespace coreinit } pid_t tid = gettid(); - g_schedulerThreadIds.emplace_back(tid); + { + std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock); + g_schedulerThreadIds.emplace_back(tid); + } #endif t_schedulerFiber = Fiber::PrepareCurrentThread(); @@ -1238,7 +1243,10 @@ namespace coreinit sSchedulerThreads.clear(); g_schedulerThreadHandles.clear(); #if BOOST_OS_LINUX - g_schedulerThreadIds.clear(); + { + std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock); + g_schedulerThreadIds.clear(); + } #endif // clean up all fibers for (auto& it : g_idleLoopFiber) From 4f3d4624f5c73d5f2634b09142f4fb7ea7fba623 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:09:24 +0100 Subject: [PATCH 125/314] GraphicPacksWindow: Disable update button when a game is running (#1137) --- src/gui/DownloadGraphicPacksWindow.cpp | 16 ++++++---------- src/gui/GraphicPacksWindow2.cpp | 10 ++++++++++ src/gui/GraphicPacksWindow2.h | 1 + src/gui/MainWindow.cpp | 10 ++++++++++ src/gui/MainWindow.h | 4 +++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/gui/DownloadGraphicPacksWindow.cpp b/src/gui/DownloadGraphicPacksWindow.cpp index 8189b50a..03f102d2 100644 --- a/src/gui/DownloadGraphicPacksWindow.cpp +++ b/src/gui/DownloadGraphicPacksWindow.cpp @@ -110,14 +110,6 @@ void deleteDownloadedGraphicPacks() void DownloadGraphicPacksWindow::UpdateThread() { - if (CafeSystem::IsTitleRunning()) - { - wxMessageBox(_("Graphic packs cannot be updated while a game is running."), _("Graphic packs"), 5, this->GetParent()); - // cancel update - m_threadState = ThreadFinished; - return; - } - // get github url std::string githubAPIUrl; curlDownloadFileState_t tempDownloadState; @@ -326,8 +318,6 @@ DownloadGraphicPacksWindow::DownloadGraphicPacksWindow(wxWindow* parent) m_downloadState = std::make_unique(); - - m_thread = std::thread(&DownloadGraphicPacksWindow::UpdateThread, this); } DownloadGraphicPacksWindow::~DownloadGraphicPacksWindow() @@ -344,6 +334,12 @@ const std::string& DownloadGraphicPacksWindow::GetException() const int DownloadGraphicPacksWindow::ShowModal() { + if(CafeSystem::IsTitleRunning()) + { + wxMessageBox(_("Graphic packs cannot be updated while a game is running."), _("Graphic packs"), 5, this->GetParent()); + return wxID_CANCEL; + } + m_thread = std::thread(&DownloadGraphicPacksWindow::UpdateThread, this); wxDialog::ShowModal(); return m_threadState == ThreadCanceled ? wxID_CANCEL : wxID_OK; } diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 78b344d5..29f4b865 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -319,6 +319,7 @@ GraphicPacksWindow2::GraphicPacksWindow2(wxWindow* parent, uint64_t title_id_fil SetSizer(main_sizer); + UpdateTitleRunning(CafeSystem::IsTitleRunning()); FillGraphicPackList(); } @@ -676,6 +677,15 @@ void GraphicPacksWindow2::OnInstalledGamesChanged(wxCommandEvent& event) event.Skip(); } +void GraphicPacksWindow2::UpdateTitleRunning(bool running) +{ + m_update_graphicPacks->Enable(!running); + if(running) + m_update_graphicPacks->SetToolTip(_("Graphic packs cannot be updated while a game is running.")); + else + m_update_graphicPacks->SetToolTip(nullptr); +} + void GraphicPacksWindow2::ReloadPack(const GraphicPackPtr& graphic_pack) const { if (graphic_pack->HasShaders() || graphic_pack->HasPatches() || graphic_pack->HasCustomVSyncFrequency()) diff --git a/src/gui/GraphicPacksWindow2.h b/src/gui/GraphicPacksWindow2.h index a068f2b6..a79c62c1 100644 --- a/src/gui/GraphicPacksWindow2.h +++ b/src/gui/GraphicPacksWindow2.h @@ -21,6 +21,7 @@ public: ~GraphicPacksWindow2(); static void RefreshGraphicPacks(); + void UpdateTitleRunning(bool running); private: std::string m_filter; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 311ddfb7..023918bd 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -625,6 +625,7 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE CreateCanvas(); CafeSystem::LaunchForegroundTitle(); RecreateMenu(); + UpdateChildWindowTitleRunningState(); return true; } @@ -683,6 +684,7 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) RecreateMenu(); CreateGameListAndStatusBar(); DoLayout(); + UpdateChildWindowTitleRunningState(); } } @@ -2320,6 +2322,14 @@ void MainWindow::RecreateMenu() SetMenuVisible(false); } +void MainWindow::UpdateChildWindowTitleRunningState() +{ + const bool running = CafeSystem::IsTitleRunning(); + + if(m_graphic_pack_window) + m_graphic_pack_window->UpdateTitleRunning(running); +} + void MainWindow::RestoreSettingsAfterGameExited() { RecreateMenu(); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 88d2a1d3..7191df12 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -21,6 +21,7 @@ class DebuggerWindow2; struct GameEntry; class DiscordPresence; class TitleManager; +class GraphicPacksWindow2; class wxLaunchGameEvent; wxDECLARE_EVENT(wxEVT_LAUNCH_GAME, wxLaunchGameEvent); @@ -146,6 +147,7 @@ public: private: void RecreateMenu(); + void UpdateChildWindowTitleRunningState(); static wxString GetInitialWindowTitle(); void ShowGettingStartedDialog(); @@ -163,7 +165,7 @@ private: MemorySearcherTool* m_toolWindow = nullptr; TitleManager* m_title_manager = nullptr; PadViewFrame* m_padView = nullptr; - wxWindow* m_graphic_pack_window = nullptr; + GraphicPacksWindow2* m_graphic_pack_window = nullptr; wxTimer* m_timer; wxPoint m_mouse_position{}; From 5230fcab374b6180043b0c1397c9d51e0c99b84a Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:14:01 +0100 Subject: [PATCH 126/314] Debugger: Fix infinite loop in symbol storage (#1134) --- src/Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h b/src/Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h index aba6a9b5..0a46951d 100644 --- a/src/Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h +++ b/src/Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h @@ -45,12 +45,17 @@ public: static void ClearRange(MPTR address, uint32 length) { + if (length == 0) + return; s_lock.lock(); - while (length > 0) + for (;;) { auto itr = s_typeStorage.find(address); if (itr != s_typeStorage.end()) s_typeStorage.erase(itr); + + if (length <= 4) + break; address += 4; length -= 4; } @@ -60,4 +65,4 @@ public: private: static FSpinlock s_lock; static std::unordered_map s_typeStorage; -}; \ No newline at end of file +}; From b0b2c257626852f749109aba053c2efcb037b0b8 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Mar 2024 14:44:51 +0100 Subject: [PATCH 127/314] coreinit: Improve accuracy of OSSwitchCoroutine Fixes Injustice: Gods Among Us crashing during boot. --- .../OS/libs/coreinit/coreinit_Coroutine.cpp | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Coroutine.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Coroutine.cpp index b1f4abb7..49c46831 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Coroutine.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Coroutine.cpp @@ -3,9 +3,13 @@ #include "Cafe/HW/Espresso/PPCState.h" #include "Cafe/HW/Espresso/Interpreter/PPCInterpreterInternal.h" #include "Cafe/HW/MMU/MMU.h" +#include "Cafe/OS/RPL/rpl.h" namespace coreinit { + static_assert(sizeof(OSCoroutine) == 0x180); + + static uint32 s_PPCAddrOSSwitchCoroutineAfterOSLoadCoroutine = 0; void coreinitExport_OSInitCoroutine(PPCInterpreter_t* hCPU) { @@ -57,14 +61,30 @@ namespace coreinit void coreinitExport_OSSwitchCoroutine(PPCInterpreter_t* hCPU) { - OSCoroutine* coroutineCurrent = (OSCoroutine*)memory_getPointerFromVirtualOffset(hCPU->gpr[3]); - OSCoroutine* coroutineNext = (OSCoroutine*)memory_getPointerFromVirtualOffsetAllowNull(hCPU->gpr[4]); + // OSSwitchCoroutine is a wrapper for OSSaveCoroutine + OSLoadCoroutine but it has side effects that we need to care about: + // r31 is saved and restored via the stack in OSSwitchCoroutine + // r4 is stored in the r31 field of coroutineCurrent. Injustice: Gods Among Us reads the r31 field and expects it to match coroutineCurrent (0x027183D4 @ EU v16) + OSCoroutine* coroutineCurrent = MEMPTR(hCPU->gpr[3]); + OSCoroutine* coroutineNext = MEMPTR(hCPU->gpr[4]); + hCPU->gpr[1] -= 0x10; + memory_writeU32(hCPU->gpr[1]+0xC, hCPU->gpr[31]); + memory_writeU32(hCPU->gpr[1]+0x14, hCPU->spr.LR); + hCPU->spr.LR = s_PPCAddrOSSwitchCoroutineAfterOSLoadCoroutine; + hCPU->gpr[31] = hCPU->gpr[4]; coreinitCoroutine_OSSaveCoroutine(coroutineCurrent, hCPU); - if (coroutineNext != NULL) - { - coreinitCoroutine_OSLoadCoroutine(coroutineNext, hCPU); - } - osLib_returnFromFunction(hCPU, 0); + hCPU->gpr[3] = hCPU->gpr[31]; + hCPU->gpr[4] = 1; + coreinitCoroutine_OSLoadCoroutine(coroutineNext, hCPU); + hCPU->instructionPointer = hCPU->spr.LR; + } + + void coreinitExport_OSSwitchCoroutineAfterOSLoadCoroutine(PPCInterpreter_t* hCPU) + { + // resuming after OSSaveCoroutine + hCPU->gpr[31] = memory_readU32(hCPU->gpr[1]+0xC); + hCPU->spr.LR = memory_readU32(hCPU->gpr[1]+0x14); + hCPU->gpr[1] += 0x10; + hCPU->instructionPointer = hCPU->spr.LR; } void coreinitExport_OSSwitchFiberEx(PPCInterpreter_t* hCPU) @@ -96,5 +116,7 @@ namespace coreinit osLib_addFunction("coreinit", "OSInitCoroutine", coreinitExport_OSInitCoroutine); osLib_addFunction("coreinit", "OSSwitchCoroutine", coreinitExport_OSSwitchCoroutine); osLib_addFunction("coreinit", "OSSwitchFiberEx", coreinitExport_OSSwitchFiberEx); + + s_PPCAddrOSSwitchCoroutineAfterOSLoadCoroutine = RPLLoader_MakePPCCallable(coreinitExport_OSSwitchCoroutineAfterOSLoadCoroutine); } } \ No newline at end of file From 60adc382056d4272d38673e8045e11f2bca2338d Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:59:13 +0100 Subject: [PATCH 128/314] Latte: Add support for more fence conditions MEM_OP_GREATER is required by Injustice: Gods Among Us --- .../HW/Latte/Core/LatteCommandProcessor.cpp | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp index c928f89f..167911b6 100644 --- a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp +++ b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp @@ -475,18 +475,45 @@ LatteCMDPtr LatteCP_itWaitRegMem(LatteCMDPtr cmd, uint32 nWords) { uint32 fenceMemValue = _swapEndianU32(*fencePtr); fenceMemValue &= fenceMask; - if (compareOp == GPU7_WAIT_MEM_OP_GEQUAL) + if (compareOp == GPU7_WAIT_MEM_OP_LESS) { - // greater or equal - if (fenceMemValue >= fenceValue) + if (fenceMemValue < fenceValue) + break; + } + else if (compareOp == GPU7_WAIT_MEM_OP_LEQUAL) + { + if (fenceMemValue <= fenceValue) break; } else if (compareOp == GPU7_WAIT_MEM_OP_EQUAL) { - // equal if (fenceMemValue == fenceValue) break; } + else if (compareOp == GPU7_WAIT_MEM_OP_NOTEQUAL) + { + if (fenceMemValue != fenceValue) + break; + } + else if (compareOp == GPU7_WAIT_MEM_OP_GEQUAL) + { + if (fenceMemValue >= fenceValue) + break; + } + else if (compareOp == GPU7_WAIT_MEM_OP_GREATER) + { + if (fenceMemValue > fenceValue) + break; + } + else if (compareOp == GPU7_WAIT_MEM_OP_ALWAYS) + { + break; + } + else if (compareOp == GPU7_WAIT_MEM_OP_NEVER) + { + cemuLog_logOnce(LogType::Force, "Latte: WAIT_MEM_OP_NEVER encountered"); + break; + } else assert_dbg(); if (!stalls) From fa8bab2f3978d1fedeffa4c578a876e4c624206b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:01:44 +0100 Subject: [PATCH 129/314] Latte: Add support for LOOP_START_NO_AL shader instruction This instruction is used by Injustice: Gods Among Us and Project Zero Also improved robustness of rendering to be less prone to crashing when a game tries to draw with broken shaders --- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteShaderAssembly.h | 2 +- .../HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp | 6 ++++-- .../LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp | 9 ++++++--- .../LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp | 3 ++- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index f165e257..5b9fc349 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -340,7 +340,7 @@ uint8 LatteMRT::GetActiveColorBufferMask(const LatteDecompilerShader* pixelShade return 0; cemu_assert_debug(colorControlReg.get_DEGAMMA_ENABLE() == false); // not supported // combine color buffer mask with pixel output mask from pixel shader - colorBufferMask &= pixelShader->pixelColorOutputMask; + colorBufferMask &= (pixelShader ? pixelShader->pixelColorOutputMask : 0); // combine color buffer mask with color channel mask from mmCB_TARGET_MASK (disable render buffer if all colors are blocked) uint32 channelTargetMask = lcr.CB_TARGET_MASK.get_MASK(); for (uint32 i = 0; i < 8; i++) diff --git a/src/Cafe/HW/Latte/Core/LatteShaderAssembly.h b/src/Cafe/HW/Latte/Core/LatteShaderAssembly.h index df636689..d2314a53 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderAssembly.h +++ b/src/Cafe/HW/Latte/Core/LatteShaderAssembly.h @@ -12,7 +12,7 @@ #define GPU7_CF_INST_VTX (0x02) // used only in GS copy program? #define GPU7_CF_INST_LOOP_END (0x05) #define GPU7_CF_INST_LOOP_START_DX10 (0x06) -#define GPU7_CF_INST_LOOP_START_NO_AL (0x07) // (Seen in Project Zero) +#define GPU7_CF_INST_LOOP_START_NO_AL (0x07) // (Seen in Project Zero, Injustice: Gods Among Us) #define GPU7_CF_INST_LOOP_BREAK (0x09) #define GPU7_CF_INST_JUMP (0x0A) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp index cf88b901..c3f7c19e 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp @@ -101,7 +101,8 @@ bool LatteDecompiler_ParseCFInstruction(LatteDecompilerShaderContext* shaderCont // ignored (we use ALU/IF/ELSE/PUSH/POP clauses to determine code flow) return true; } - else if (cf_inst23_7 == GPU7_CF_INST_LOOP_START_DX10 || cf_inst23_7 == GPU7_CF_INST_LOOP_END) + else if (cf_inst23_7 == GPU7_CF_INST_LOOP_START_DX10 || cf_inst23_7 == GPU7_CF_INST_LOOP_END || + cf_inst23_7 == GPU7_CF_INST_LOOP_START_NO_AL) { LatteDecompilerCFInstruction& cfInstruction = instructionList.emplace_back(); // set type and address @@ -966,7 +967,8 @@ void LatteDecompiler_ParseClauses(LatteDecompilerShaderContext* decompilerContex { // no sub-instructions } - else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END) + else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END || + cfInstruction.type == GPU7_CF_INST_LOOP_START_NO_AL) { // no sub-instructions } diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index cf22f05d..19604e0c 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -441,7 +441,8 @@ void LatteDecompiler_analyzeSubroutine(LatteDecompilerShaderContext* shaderConte { shaderContext->analyzer.modifiesPixelActiveState = true; } - else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END) + else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END || + cfInstruction.type == GPU7_CF_INST_LOOP_START_NO_AL) { shaderContext->analyzer.modifiesPixelActiveState = true; } @@ -685,7 +686,8 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD { shaderContext->analyzer.modifiesPixelActiveState = true; } - else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END) + else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END || + cfInstruction.type == GPU7_CF_INST_LOOP_START_NO_AL) { shaderContext->analyzer.modifiesPixelActiveState = true; shaderContext->analyzer.hasLoops = true; @@ -929,7 +931,8 @@ void LatteDecompiler_analyze(LatteDecompilerShaderContext* shaderContext, LatteD if (cfCurrentStackDepth < 0) debugBreakpoint(); } - else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END) + else if (cfInstruction.type == GPU7_CF_INST_LOOP_START_DX10 || cfInstruction.type == GPU7_CF_INST_LOOP_END || + cfInstruction.type == GPU7_CF_INST_LOOP_START_NO_AL) { // no effect on stack depth cfInstruction.activeStackDepth = cfCurrentStackDepth; diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index e19535be..7a6605f8 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -3662,7 +3662,8 @@ void LatteDecompiler_emitClauseCode(LatteDecompilerShaderContext* shaderContext, { src->addFmt("{} = {} == true && {} == true;" _CRLF, _getActiveMaskCVarName(shaderContext, cfInstruction->activeStackDepth + 1 - cfInstruction->popCount), _getActiveMaskVarName(shaderContext, cfInstruction->activeStackDepth - cfInstruction->popCount), _getActiveMaskCVarName(shaderContext, cfInstruction->activeStackDepth - cfInstruction->popCount)); } - else if( cfInstruction->type == GPU7_CF_INST_LOOP_START_DX10 ) + else if( cfInstruction->type == GPU7_CF_INST_LOOP_START_DX10 || + cfInstruction->type == GPU7_CF_INST_LOOP_START_NO_AL) { // start of loop // if pixel is disabled, then skip loop diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index d510140b..6500f7d3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -1285,9 +1285,9 @@ void VulkanRenderer::draw_beginSequence() // update shader state LatteSHRC_UpdateActiveShaders(); - if (m_state.drawSequenceSkip) + if (LatteGPUState.activeShaderHasError) { - debug_printf("Skipping drawcalls due to shader error\n"); + cemuLog_logDebugOnce(LogType::Force, "Skipping drawcalls due to shader error"); m_state.drawSequenceSkip = true; cemu_assert_debug(false); return; From 3e467e220e4e407752381f264f405c50eaec1036 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 3 Apr 2024 01:45:50 +0200 Subject: [PATCH 130/314] Logging: Prevent crash for nullptr strings --- src/Cafe/OS/common/OSUtil.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Cafe/OS/common/OSUtil.h b/src/Cafe/OS/common/OSUtil.h index 6801f6af..84e38a6c 100644 --- a/src/Cafe/OS/common/OSUtil.h +++ b/src/Cafe/OS/common/OSUtil.h @@ -140,6 +140,17 @@ static std::tuple cafeExportBuildArgTuple(PPCInterpreter_t* hCPU, R(fn) return std::tuple{ cafeExportGetParamWrapper(hCPU, gprIndex, fprIndex)... }; } +template +T cafeExportGetFormatParamWrapper(PPCInterpreter_t* hCPU, int& gprIndex, int& fprIndex) +{ + T v; + cafeExportParamWrapper::getParamWrapper(hCPU, gprIndex, fprIndex, v); + // if T is char* or const char*, return "null" instead of nullptr since newer fmtlib would throw otherwise + if constexpr (std::is_same_v || std::is_same_v) + return v ? v : (T)"null"; + return v; +} + template using _CAFE_FORMAT_ARG = std::conditional_t, std::conditional_t || std::is_same_v, T, MEMPTR>, T>; @@ -150,7 +161,7 @@ static auto cafeExportBuildFormatTuple(PPCInterpreter_t* hCPU, R(fn)(Args...)) int gprIndex = 0; int fprIndex = 0; return std::tuple<_CAFE_FORMAT_ARG...>{ - cafeExportGetParamWrapper<_CAFE_FORMAT_ARG>(hCPU, gprIndex, fprIndex)... + cafeExportGetFormatParamWrapper<_CAFE_FORMAT_ARG>(hCPU, gprIndex, fprIndex)... }; } From 51072b510c74e078350f70f31386802f2e78159f Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 3 Apr 2024 01:45:05 +0200 Subject: [PATCH 131/314] nn_boss: Large rework with various improvements Lots of internal changes. On the surface this only fixes a crash in Mario & Sonic Rio 2016 (at least what I saw from my testing) but it may affect more games. Summary of changes: - Rewrite code to use newer cafeExportRegisterFunc - Simplify code by merging namespaces and structs of the same types - Correctly set ppc vtables for the virtual boss classes - Fix some wrong function definitions and implement a little bit more of the boss API (mainly constructors and destructors) --- src/Cafe/OS/libs/nn_boss/nn_boss.cpp | 2710 +++++++++++++------------- src/Cemu/Logging/CemuLogging.cpp | 1 + src/Cemu/Logging/CemuLogging.h | 1 + src/gui/MainWindow.cpp | 1 + 4 files changed, 1325 insertions(+), 1388 deletions(-) diff --git a/src/Cafe/OS/libs/nn_boss/nn_boss.cpp b/src/Cafe/OS/libs/nn_boss/nn_boss.cpp index c2d65a5f..f53a6d79 100644 --- a/src/Cafe/OS/libs/nn_boss/nn_boss.cpp +++ b/src/Cafe/OS/libs/nn_boss/nn_boss.cpp @@ -27,13 +27,244 @@ bossBufferVector->buffer = (uint8*)bossRequest; sint32 g_initCounter = 0; bool g_isInitialized = false; - void freeMem(void* mem) + struct VTableEntry { - if(mem) - coreinit::default_MEMFreeToDefaultHeap((uint8*)mem - 8); + uint16be offsetA{0}; + uint16be offsetB{0}; + MEMPTR ptr; + }; + static_assert(sizeof(VTableEntry) == 8); + + #define DTOR_WRAPPER(__TYPE) RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) { dtor(MEMPTR<__TYPE>(hCPU->gpr[3]), hCPU->gpr[4]); osLib_returnFromFunction(hCPU, 0); }) + + constexpr uint32 BOSS_MEM_MAGIC = 0xCAFE4321; + + template + MEMPTR boss_new() + { + uint32 objSize = sizeof(T); + uint32be* basePtr = (uint32be*)coreinit::_weak_MEMAllocFromDefaultHeapEx(objSize + 8, 0x8); + basePtr[0] = BOSS_MEM_MAGIC; + basePtr[1] = objSize; + return (T*)(basePtr+2); } - struct TaskSetting_t + void boss_delete(MEMPTR mem) + { + if(!mem) + return; + uint32be* basePtr = (uint32be*)mem.GetPtr() - 2; + if(basePtr[0] != BOSS_MEM_MAGIC) + { + cemuLog_log(LogType::Force, "nn_boss: Detected memory corruption"); + cemu_assert_suspicious(); + } + coreinit::_weak_MEMFreeToDefaultHeap(basePtr); + } + + Result Initialize() // Initialize__Q2_2nn4bossFv + { + coreinit::OSLockMutex(&g_mutex); + Result result = 0; + if(g_initCounter == 0) + { + g_isInitialized = true; + // IPC init here etc. + result = 0x200080; // init result + } + g_initCounter++; + coreinit::OSUnlockMutex(&g_mutex); + return NN_RESULT_IS_SUCCESS(result) ? 0 : result; + } + + uint32 IsInitialized() // IsInitialized__Q2_2nn4bossFv + { + return g_isInitialized; + } + + void Finalize() // Finalize__Q2_2nn4bossFv + { + coreinit::OSLockMutex(&g_mutex); + if(g_initCounter == 0) + cemuLog_log(LogType::Force, "nn_boss: Finalize() called without corresponding Initialize()"); + if(g_initCounter == 1) + { + g_isInitialized = false; + // IPC deinit here etc. + } + g_initCounter--; + coreinit::OSUnlockMutex(&g_mutex); + } + + uint32 GetBossState(PPCInterpreter_t* hCPU) + { + cemuLog_logDebug(LogType::Force, "nn_boss.GetBossState() - stub"); + return 7; + } + + struct TitleId + { + uint64be u64{}; + + static TitleId* ctor(TitleId* _thisptr, uint64 titleId) + { + if (!_thisptr) + _thisptr = boss_new(); + _thisptr->u64 = titleId; + return _thisptr; + } + + static TitleId* ctor(TitleId* _thisptr) + { + return ctor(_thisptr, 0); + } + + static bool IsValid(TitleId* _thisptr) + { + return _thisptr->u64 != 0; + } + + static TitleId* ctor1(TitleId* _thisptr, uint32 filler, uint64 titleId) + { + return ctor(_thisptr); + } + + static TitleId* ctor2(TitleId* _thisptr, uint32 filler, uint64 titleId) + { + cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_ctor2(0x{:x})", MEMPTR(_thisptr).GetMPTR()); + if (!_thisptr) + { + // _thisptr = new Task_t + assert_dbg(); + } + + _thisptr->u64 = titleId; + return _thisptr; + } + + static TitleId* ctor3(TitleId* _thisptr, TitleId* titleId) + { + cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_cctor(0x{:x})", MEMPTR(_thisptr).GetMPTR()); + if (!_thisptr) + _thisptr = boss_new(); + _thisptr->u64 = titleId->u64; + return _thisptr; + } + + static bool operator_ne(TitleId* _thisptr, TitleId* titleId) + { + cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_operator_ne(0x{:x})", MEMPTR(_thisptr).GetMPTR()); + return _thisptr->u64 != titleId->u64; + } + }; + static_assert(sizeof(TitleId) == 8); + + struct TaskId + { + char id[0x8]{}; + + static TaskId* ctor(TaskId* _thisptr) + { + if(!_thisptr) + _thisptr = boss_new(); + _thisptr->id[0] = '\0'; + return _thisptr; + } + }; + static_assert(sizeof(TaskId) == 8); + + struct Title + { + uint32be accountId{}; // 0x00 + TitleId titleId{}; // 0x8 + MEMPTR vTablePtr{}; // 0x10 + + struct VTable + { + VTableEntry rtti; + VTableEntry dtor; + }; + static inline SysAllocator s_titleVTable; + + static Title* ctor(Title* _this) + { + if (!_this) + _this = boss_new(); + *_this = {}; + _this->vTablePtr = s_titleVTable; + return _this; + } + + static void dtor(Title* _this, uint32 options) + { + if (_this && (options & 1)) + boss_delete(_this); + } + + static void InitVTable() + { + s_titleVTable->rtti.ptr = nullptr; // todo + s_titleVTable->dtor.ptr = DTOR_WRAPPER(Title); + } + }; + static_assert(sizeof(Title) == 0x18); + + struct DirectoryName + { + char name[0x8]{}; + + static DirectoryName* ctor(DirectoryName* _thisptr) + { + if (!_thisptr) + _thisptr = boss_new<DirectoryName>(); + memset(_thisptr->name, 0x00, 0x8); + return _thisptr; + } + + static const char* operator_const_char(DirectoryName* _thisptr) + { + return _thisptr->name; + } + }; + static_assert(sizeof(DirectoryName) == 8); + + struct BossAccount // the actual class name is "Account" and while the boss namespace helps us separate this from Account(.h) we use an alternative name to avoid confusion + { + struct VTable + { + VTableEntry rtti; + VTableEntry dtor; + }; + static inline SysAllocator<VTable> s_VTable; + + uint32be accountId; + MEMPTR<void> vTablePtr; + + static BossAccount* ctor(BossAccount* _this, uint32 accountId) + { + if (!_this) + _this = boss_new<BossAccount>(); + _this->accountId = accountId; + _this->vTablePtr = s_VTable; + return _this; + } + + static void dtor(BossAccount* _this, uint32 options) + { + if(_this && options & 1) + boss_delete(_this); + } + + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(BossAccount); + } + + }; + static_assert(sizeof(BossAccount) == 8); + + struct TaskSetting { static const uint32 kBossCode = 0x7C0; static const uint32 kBossCodeLen = 0x20; @@ -46,8 +277,6 @@ bossBufferVector->buffer = (uint8*)bossRequest; static const uint32 kNbdlFileName = 0x7F8; static const uint32 kFileNameLen = 0x20; - - static const uint32 kURL = 0x48; static const uint32 kURLLen = 0x100; @@ -57,245 +286,75 @@ bossBufferVector->buffer = (uint8*)bossRequest; static const uint32 kServiceToken = 0x590; static const uint32 kServiceTokenLen = 0x200; - uint8 settings[0x1000]; - uint32be uknExt_vTableProbably; // +0x1000 - }; - static_assert(sizeof(TaskSetting_t) == 0x1004); - static_assert(offsetof(TaskSetting_t, uknExt_vTableProbably) == 0x1000, "offsetof(TaskSetting_t, uknExt)"); + MEMPTR<void> vTablePtr; // +0x1000 - struct NetTaskSetting_t : TaskSetting_t + struct VTableTaskSetting + { + VTableEntry rtti; + VTableEntry dtor; + VTableEntry RegisterPreprocess; + VTableEntry unk1; + }; + static inline SysAllocator<VTableTaskSetting> s_VTable; + + static TaskSetting* ctor(TaskSetting* _thisptr) + { + if(!_thisptr) + _thisptr = boss_new<TaskSetting>(); + _thisptr->vTablePtr = s_VTable; + InitializeSetting(_thisptr); + return _thisptr; + } + + static void dtor(TaskSetting* _this, uint32 options) + { + cemuLog_logDebug(LogType::Force, "nn::boss::TaskSetting::dtor(0x{:08x}, 0x{:08x})", MEMPTR(_this).GetMPTR(), options); + if(options & 1) + boss_delete(_this); + } + + static bool IsPrivileged(TaskSetting* _thisptr) + { + const uint16 value = *(uint16be*)&_thisptr->settings[0x28]; + return value == 1 || value == 9 || value == 5; + } + + static void InitializeSetting(TaskSetting* _thisptr) + { + memset(_thisptr, 0x00, sizeof(TaskSetting::settings)); + *(uint32*)&_thisptr->settings[0x0C] = 0; + *(uint8*)&_thisptr->settings[0x2A] = 0x7D; // timeout? + *(uint32*)&_thisptr->settings[0x30] = 0x7080; + *(uint32*)&_thisptr->settings[0x8] = 0; + *(uint32*)&_thisptr->settings[0x38] = 0; + *(uint32*)&_thisptr->settings[0x3C] = 0x76A700; + *(uint32*)&_thisptr->settings[0] = 0x76A700; + } + + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(TaskSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + } + }; + static_assert(sizeof(TaskSetting) == 0x1004); + static_assert(offsetof(TaskSetting, vTablePtr) == 0x1000); + + struct NetTaskSetting : TaskSetting { // 0x188 cert1 + 0x188 cert2 + 0x188 cert3 // 0x190 AddCaCert (3times) char cert[0x80]; // SetConnectionSetting // SetFirstLastModifiedTime - }; - static_assert(sizeof(NetTaskSetting_t) == 0x1004); - struct NbdlTaskSetting_t : NetTaskSetting_t - { - //char fileName[0x20]; // @0x7F8 - }; - static_assert(sizeof(NbdlTaskSetting_t) == 0x1004); + struct VTableNetTaskSetting : public VTableTaskSetting + { }; + static inline SysAllocator<VTableNetTaskSetting> s_VTable; - struct RawUlTaskSetting_t : NetTaskSetting_t - { - static const uint32 kType = 0x12340000; - uint32be ukRaw1; // 0x1004 - uint32be ukRaw2; // 0x1008 - uint32be ukRaw3; // 0x100C - uint8 rawSpace[0x200]; // 0x1010 - }; - static_assert(sizeof(RawUlTaskSetting_t) == 0x1210); - - struct PlayReportSetting_t : RawUlTaskSetting_t - { - static const uint32 kType = 0x12340001; - MEMPTR<void*> ukPlay1; // 0x1210 - uint32be ukPlay2; // 0x1214 - uint32be ukPlay3; // 0x1218 - uint32be ukPlay4; // 0x121C - }; - static_assert(sizeof(PlayReportSetting_t) == 0x1220); - - struct RawDlTaskSetting_t : NetTaskSetting_t - { - static const uint32 kType = 0x12340002; - //char fileName[0x20]; // 0x7F8 - }; - static_assert(sizeof(RawDlTaskSetting_t) == 0x1004); - - struct TitleId_t - { - uint64be u64{}; - }; - static_assert(sizeof(TitleId_t) == 8); - - struct TaskId_t - { - char id[0x8]{}; - }; - static_assert(sizeof(TaskId_t) == 8); - - struct Title_t - { - uint32be accountId{}; // 0x00 - TitleId_t titleId{}; // 0x8 - uint32be someValue = 0x12341000; // 0x10 - }; - static_assert(sizeof(Title_t) == 0x18); - - struct DirectoryName_t - { - char name[0x8]{}; - }; - static_assert(sizeof(DirectoryName_t) == 8); - - struct Account_t - { - uint32be accountId; - uint32be uk1; // global struct - }; - static_assert(sizeof(Account_t) == 8); - - struct Task_t - { - uint32be accountId; // 0x00 - uint32be uk2; // 0x04 - TaskId_t taskId; // 0x08 - TitleId_t titleId; // 0x10 - uint32be ext; // 0x18 - uint32be padding; // 0x1C - }; - static_assert(sizeof(Task_t) == 0x20, "sizeof(Task_t)"); - - namespace TaskId - { - TaskId_t* ctor(TaskId_t* thisptr) - { - if(!thisptr) - { - // thisptr = new TaskId_t - assert_dbg(); - } - - if(thisptr) - { - thisptr->id[0] = 0; - } - - return thisptr; - } - } - - namespace Account - { - Account_t* ctor(Account_t* thisptr, uint32 accountId) - { - if (!thisptr) - { - // thisptr = new TaskId_t - assert_dbg(); - } - - thisptr->accountId = accountId; - thisptr->uk1 = 0x12340010; - return thisptr; - } - } - - namespace TitleId - { - TitleId_t* ctor(TitleId_t* thisptr, uint64 titleId) - { - if (!thisptr) - { - // thisptr = new TaskId_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->u64 = titleId; - } - - return thisptr; - } - - TitleId_t* ctor(TitleId_t* thisptr) - { - return ctor(thisptr, 0); - } - - bool IsValid(TitleId_t* thisptr) - { - return thisptr->u64 != 0; - } - - TitleId_t* ctor1(TitleId_t* thisptr, uint32 filler, uint64 titleId) - { - return ctor(thisptr); - } - - TitleId_t* ctor2(TitleId_t* thisptr, uint32 filler, uint64 titleId) - { - cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_ctor2(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - thisptr->u64 = titleId; - return thisptr; - } - - - TitleId_t* cctor(TitleId_t* thisptr, TitleId_t* titleId) - { - cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_cctor(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - thisptr->u64 = titleId->u64; - - return thisptr; - } - - bool operator_ne(TitleId_t* thisptr, TitleId_t* titleId) - { - cemuLog_logDebug(LogType::Force, "nn_boss_TitleId_operator_ne(0x{:x})", MEMPTR(thisptr).GetMPTR()); - return thisptr->u64 != titleId->u64; - } - } - - namespace TaskSetting - { - bool IsPrivilegedTaskSetting(TaskSetting_t* thisptr) - { - const uint16 value = *(uint16*)&thisptr->settings[0x28]; - return value == 1 || value == 9 || value == 5; - } - - void InitializeSetting(TaskSetting_t* thisptr) - { - memset(thisptr, 0x00, sizeof(TaskSetting_t::settings)); - *(uint32*)&thisptr->settings[0x0C] = 0; - *(uint8*)&thisptr->settings[0x2A] = 0x7D; // timeout? - *(uint32*)&thisptr->settings[0x30] = 0x7080; - *(uint32*)&thisptr->settings[0x8] = 0; - *(uint32*)&thisptr->settings[0x38] = 0; - *(uint32*)&thisptr->settings[0x3C] = 0x76A700; - *(uint32*)&thisptr->settings[0] = 0x76A700; - } - - TaskSetting_t* ctor(TaskSetting_t* thisptr) - { - if(!thisptr) - { - // thisptr = new TaskSetting_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->uknExt_vTableProbably = 0; - InitializeSetting(thisptr); - } - - return thisptr; - } - - - } - - namespace NetTaskSetting - { - Result AddCaCert(NetTaskSetting_t* thisptr, const char* name) + static Result AddCaCert(NetTaskSetting* _thisptr, const char* name) { if(name == nullptr || strnlen(name, 0x80) == 0x80) { @@ -308,1505 +367,1380 @@ bossBufferVector->buffer = (uint8*)bossRequest; return 0xA0220D00; } - NetTaskSetting_t* ctor(NetTaskSetting_t* thisptr) + static NetTaskSetting* ctor(NetTaskSetting* _thisptr) { - if (!thisptr) - { - // thisptr = new NetTaskSetting_t - assert_dbg(); - } - - if (thisptr) - { - TaskSetting::ctor(thisptr); - *(uint32*)&thisptr->settings[0x18C] = 0x78; - thisptr->uknExt_vTableProbably = 0; - } - - return thisptr; + if (!_thisptr) + _thisptr = boss_new<NetTaskSetting>(); + TaskSetting::ctor(_thisptr); + *(uint32*)&_thisptr->settings[0x18C] = 0x78; + _thisptr->vTablePtr = s_VTable; + return _thisptr; } - Result SetServiceToken(NetTaskSetting_t* thisptr, const uint8* serviceToken) + static Result SetServiceToken(NetTaskSetting* _thisptr, const uint8* serviceToken) { - cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_SetServiceToken(0x{:x}, 0x{:x})", MEMPTR(thisptr).GetMPTR(), MEMPTR(serviceToken).GetMPTR()); + cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_SetServiceToken(0x{:x}, 0x{:x})", MEMPTR(_thisptr).GetMPTR(), MEMPTR(serviceToken).GetMPTR()); cemuLog_logDebug(LogType::Force, "\t->{}", fmt::ptr(serviceToken)); - memcpy(&thisptr->settings[TaskSetting_t::kServiceToken], serviceToken, TaskSetting_t::kServiceTokenLen); + memcpy(&_thisptr->settings[TaskSetting::kServiceToken], serviceToken, TaskSetting::kServiceTokenLen); return 0x200080; } - Result AddInternalCaCert(NetTaskSetting_t* thisptr, char certId) + static Result AddInternalCaCert(NetTaskSetting* _thisptr, char certId) { - cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_AddInternalCaCert(0x{:x}, 0x{:x})", MEMPTR(thisptr).GetMPTR(), (int)certId); + cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_AddInternalCaCert(0x{:x}, 0x{:x})", MEMPTR(_thisptr).GetMPTR(), (int)certId); - uint32 location = TaskSetting_t::kCACert; + uint32 location = TaskSetting::kCACert; for(int i = 0; i < 3; ++i) { - if(thisptr->settings[location] == 0) + if(_thisptr->settings[location] == 0) { - thisptr->settings[location] = (uint8)certId; + _thisptr->settings[location] = (uint8)certId; return 0x200080; } - location += TaskSetting_t::kCACert; + location += TaskSetting::kCACert; } - + cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_AddInternalCaCert: can't store certificate"); return 0xA0220D00; } - void SetInternalClientCert(NetTaskSetting_t* thisptr, char certId) + static void SetInternalClientCert(NetTaskSetting* _thisptr, char certId) { - cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_SetInternalClientCert(0x{:x}, 0x{:x})", MEMPTR(thisptr).GetMPTR(), (int)certId); - thisptr->settings[TaskSetting_t::kClientCert] = (uint8)certId; + cemuLog_logDebug(LogType::Force, "nn_boss_NetTaskSetting_SetInternalClientCert(0x{:x}, 0x{:x})", MEMPTR(_thisptr).GetMPTR(), (int)certId); + _thisptr->settings[TaskSetting::kClientCert] = (uint8)certId; } - } - namespace NbdlTaskSetting // : NetTaskSetting + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(NetTaskSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + } + }; + static_assert(sizeof(NetTaskSetting) == 0x1004); + + struct NbdlTaskSetting : NetTaskSetting { - NbdlTaskSetting_t* ctor(NbdlTaskSetting_t* thisptr) + struct VTableNbdlTaskSetting : public VTableNetTaskSetting { - if (!thisptr) - { - // thisptr = new NbdlTaskSetting_t - assert_dbg(); - } + VTableEntry rttiNetTaskSetting; // unknown + }; + static_assert(sizeof(VTableNbdlTaskSetting) == 8*5); + static inline SysAllocator<VTableNbdlTaskSetting> s_VTable; - if (thisptr) - { - NetTaskSetting::ctor(thisptr); - thisptr->uknExt_vTableProbably = 0; - } - - return thisptr; + static NbdlTaskSetting* ctor(NbdlTaskSetting* _thisptr) + { + if (!_thisptr) + _thisptr = boss_new<NbdlTaskSetting>(); + NetTaskSetting::ctor(_thisptr); + _thisptr->vTablePtr = s_VTable; + return _thisptr; } - void export_ctor(PPCInterpreter_t* hCPU) + static Result Initialize(NbdlTaskSetting* _thisptr, const char* bossCode, uint64 directorySizeLimit, const char* directoryName) // Initialize__Q3_2nn4boss15NbdlTaskSettingFPCcLT1 { - ppcDefineParamMEMPTR(thisptr, NbdlTaskSetting_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss_NbdlTaskSetting_ctor"); - ctor(thisptr.GetPtr()); - osLib_returnFromFunction(hCPU, thisptr.GetMPTR()); - } - - void export_Initialize(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(thisptr, NbdlTaskSetting_t, 0); - ppcDefineParamMEMPTR(bossCode, const char, 1); - ppcDefineParamU64(directorySizeLimit, 2); - ppcDefineParamMEMPTR(directoryName, const char, 4); - cemuLog_logDebug(LogType::Force, "nn_boss_NbdlTaskSetting_Initialize(0x{:08x}, {}, 0x{:x}, 0x{:08x})", thisptr.GetMPTR(), bossCode.GetPtr(), directorySizeLimit, directoryName.GetMPTR()); - - if(!bossCode || strnlen(bossCode.GetPtr(), 0x20) == 0x20) - { - osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780)); - return; - } - - if (directoryName && strnlen(directoryName.GetPtr(), 0x8) == 0x8) - { - osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780)); - return; - } - - strncpy((char*)&thisptr->settings[TaskSetting_t::kBossCode], bossCode.GetPtr(), TaskSetting_t::kBossCodeLen); - - *(uint64be*)&thisptr->settings[TaskSetting_t::kDirectorySizeLimit] = directorySizeLimit; // uint64be - if(directoryName) - strncpy((char*)&thisptr->settings[TaskSetting_t::kDirectoryName], directoryName.GetPtr(), TaskSetting_t::kDirectoryNameLen); - - osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_BOSS, 0x80)); - } - - Result SetFileName(NbdlTaskSetting_t* thisptr, const char* fileName) - { - cemuLog_logDebug(LogType::Force, "nn_boss_NbdlTaskSetting_t_SetFileName(0x{:08x}, {})", MEMPTR(thisptr).GetMPTR(), fileName ? fileName : "\"\""); - - if (!fileName || strnlen(fileName, TaskSetting_t::kFileNameLen) == TaskSetting_t::kFileNameLen) - { + if(!bossCode || strnlen(bossCode, TaskSetting::kBossCodeLen) == TaskSetting::kBossCodeLen) return BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780); - } - - strncpy((char*)&thisptr->settings[TaskSetting_t::kNbdlFileName], fileName, TaskSetting_t::kFileNameLen); + + if (directoryName && strnlen(directoryName, TaskSetting::kDirectoryNameLen) == TaskSetting::kDirectoryNameLen) + return BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780); + + strncpy((char*)&_thisptr->settings[TaskSetting::kBossCode], bossCode, TaskSetting::kBossCodeLen); + + *(uint64be*)&_thisptr->settings[TaskSetting::kDirectorySizeLimit] = directorySizeLimit; // uint64be + if(directoryName) + strncpy((char*)&_thisptr->settings[TaskSetting::kDirectoryName], directoryName, TaskSetting::kDirectoryNameLen); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_BOSS, 0x80); } - } - - namespace RawUlTaskSetting - { - RawUlTaskSetting_t* ctor(RawUlTaskSetting_t* thisptr) + static Result SetFileName(NbdlTaskSetting* _thisptr, const char* fileName) { - cemuLog_logDebug(LogType::Force, "nn_boss_RawUlTaskSetting_ctor(0x{:x}) TODO", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new RawUlTaskSetting_t - assert_dbg(); - } + cemuLog_logDebug(LogType::Force, "nn_boss_NbdlTaskSetting_t_SetFileName(0x{:08x}, {})", MEMPTR(_thisptr).GetMPTR(), fileName ? fileName : "\"\""); + if (!fileName || strnlen(fileName, TaskSetting::kFileNameLen) == TaskSetting::kFileNameLen) + return BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780); - if (thisptr) - { - NetTaskSetting::ctor(thisptr); - thisptr->uknExt_vTableProbably = RawUlTaskSetting_t::kType; - thisptr->ukRaw1 = 0; - thisptr->ukRaw2 = 0; - thisptr->ukRaw3 = 0; - memset(thisptr->rawSpace, 0x00, 0x200); - } - - return thisptr; - } - } - - namespace RawDlTaskSetting - { - RawDlTaskSetting_t* ctor(RawDlTaskSetting_t* thisptr) - { - cemuLog_logDebug(LogType::Force, "nn_boss_RawDlTaskSetting_ctor(0x{:x}) TODO", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new RawDlTaskSetting_t - assert_dbg(); - } - - if (thisptr) - { - NetTaskSetting::ctor(thisptr); - thisptr->uknExt_vTableProbably = RawDlTaskSetting_t::kType; - } - - return thisptr; + strncpy((char*)&_thisptr->settings[TaskSetting::kNbdlFileName], fileName, TaskSetting::kFileNameLen); + // also sets byte at +0x817 to zero? + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_BOSS, 0x80); } - Result Initialize(RawDlTaskSetting_t* thisptr, const char* url, bool newArrival, bool led, const char* fileName, const char* directoryName) + static void InitVTable() { - cemuLog_logDebug(LogType::Force, "nn_boss_RawDlTaskSetting_Initialize(0x{:x}, 0x{:x}, {}, {}, 0x{:x}, 0x{:x})", MEMPTR(thisptr).GetMPTR(), MEMPTR(url).GetMPTR(), newArrival, led, MEMPTR(fileName).GetMPTR(), MEMPTR(directoryName).GetMPTR()); + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(NbdlTaskSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + s_VTable->rttiNetTaskSetting.ptr = nullptr; // todo + } + }; + static_assert(sizeof(NbdlTaskSetting) == 0x1004); + + struct RawUlTaskSetting : NetTaskSetting + { + uint32be ukRaw1; // 0x1004 + uint32be ukRaw2; // 0x1008 + uint32be ukRaw3; // 0x100C + uint8 rawSpace[0x200]; // 0x1010 + + struct VTableRawUlTaskSetting : public VTableNetTaskSetting + { + VTableEntry rttiNetTaskSetting; // unknown + }; + static_assert(sizeof(VTableRawUlTaskSetting) == 8*5); + static inline SysAllocator<VTableRawUlTaskSetting> s_VTable; + + static RawUlTaskSetting* ctor(RawUlTaskSetting* _thisptr) + { + if (!_thisptr) + _thisptr = boss_new<RawUlTaskSetting>(); + NetTaskSetting::ctor(_thisptr); + _thisptr->vTablePtr = s_VTable; + _thisptr->ukRaw1 = 0; + _thisptr->ukRaw2 = 0; + _thisptr->ukRaw3 = 0; + memset(_thisptr->rawSpace, 0x00, 0x200); + return _thisptr; + } + + static void dtor(RawUlTaskSetting* _this, uint32 options) + { + cemuLog_logDebug(LogType::Force, "nn::boss::RawUlTaskSetting::dtor() is todo"); + } + + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(RawUlTaskSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + s_VTable->rttiNetTaskSetting.ptr = nullptr; // todo + } + }; + static_assert(sizeof(RawUlTaskSetting) == 0x1210); + + struct RawDlTaskSetting : NetTaskSetting + { + struct VTableRawDlTaskSetting : public VTableNetTaskSetting + { + VTableEntry rttiNetTaskSetting; // unknown + }; + static_assert(sizeof(VTableRawDlTaskSetting) == 8*5); + static inline SysAllocator<VTableRawDlTaskSetting> s_VTable; + + static RawDlTaskSetting* ctor(RawDlTaskSetting* _thisptr) + { + cemuLog_logDebug(LogType::Force, "nn_boss_RawDlTaskSetting_ctor(0x{:x}) TODO", MEMPTR(_thisptr).GetMPTR()); + if (!_thisptr) + _thisptr = boss_new<RawDlTaskSetting>(); + NetTaskSetting::ctor(_thisptr); + _thisptr->vTablePtr = s_VTable; + return _thisptr; + } + + static Result Initialize(RawDlTaskSetting* _thisptr, const char* url, bool newArrival, bool led, const char* fileName, const char* directoryName) + { + cemuLog_logDebug(LogType::Force, "nn_boss_RawDlTaskSetting_Initialize(0x{:x}, 0x{:x}, {}, {}, 0x{:x}, 0x{:x})", MEMPTR(_thisptr).GetMPTR(), MEMPTR(url).GetMPTR(), newArrival, led, MEMPTR(fileName).GetMPTR(), MEMPTR(directoryName).GetMPTR()); if (!url) { return 0xC0203780; } - if (strnlen(url, TaskSetting_t::kURLLen) == TaskSetting_t::kURLLen) + if (strnlen(url, TaskSetting::kURLLen) == TaskSetting::kURLLen) { return 0xC0203780; } cemuLog_logDebug(LogType::Force, "\t-> url: {}", url); - if (fileName && strnlen(fileName, TaskSetting_t::kFileNameLen) == TaskSetting_t::kFileNameLen) + if (fileName && strnlen(fileName, TaskSetting::kFileNameLen) == TaskSetting::kFileNameLen) { return 0xC0203780; } - if (directoryName && strnlen(directoryName, TaskSetting_t::kDirectoryNameLen) == TaskSetting_t::kDirectoryNameLen) + if (directoryName && strnlen(directoryName, TaskSetting::kDirectoryNameLen) == TaskSetting::kDirectoryNameLen) { return 0xC0203780; } - strncpy((char*)thisptr + TaskSetting_t::kURL, url, TaskSetting_t::kURLLen); - thisptr->settings[0x147] = '\0'; + strncpy((char*)_thisptr + TaskSetting::kURL, url, TaskSetting::kURLLen); + _thisptr->settings[0x147] = '\0'; if (fileName) - strncpy((char*)thisptr + 0x7D0, fileName, TaskSetting_t::kFileNameLen); + strncpy((char*)_thisptr + 0x7D0, fileName, TaskSetting::kFileNameLen); else - strncpy((char*)thisptr + 0x7D0, "rawcontent.dat", TaskSetting_t::kFileNameLen); - thisptr->settings[0x7EF] = '\0'; + strncpy((char*)_thisptr + 0x7D0, "rawcontent.dat", TaskSetting::kFileNameLen); + _thisptr->settings[0x7EF] = '\0'; - cemuLog_logDebug(LogType::Force, "\t-> filename: {}", (char*)thisptr + 0x7D0); + cemuLog_logDebug(LogType::Force, "\t-> filename: {}", (char*)_thisptr + 0x7D0); if (directoryName) { - strncpy((char*)thisptr + 0x7C8, directoryName, TaskSetting_t::kDirectoryNameLen); - thisptr->settings[0x7CF] = '\0'; - cemuLog_logDebug(LogType::Force, "\t-> directoryName: {}", (char*)thisptr + 0x7C8); + strncpy((char*)_thisptr + 0x7C8, directoryName, TaskSetting::kDirectoryNameLen); + _thisptr->settings[0x7CF] = '\0'; + cemuLog_logDebug(LogType::Force, "\t-> directoryName: {}", (char*)_thisptr + 0x7C8); } - thisptr->settings[0x7C0] = newArrival; - thisptr->settings[0x7C1] = led; - *(uint16be*)&thisptr->settings[0x28] = 0x3; + _thisptr->settings[0x7C0] = newArrival; + _thisptr->settings[0x7C1] = led; + *(uint16be*)&_thisptr->settings[0x28] = 0x3; return 0x200080; } - } - namespace PlayReportSetting // : NetTaskSetting - { - void export_ctor(PPCInterpreter_t* hCPU) + static void InitVTable() { - ppcDefineParamMEMPTR(thisptr, PlayReportSetting_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss_PlayReportSetting_ctor TODO"); - if (!thisptr) - { - assert_dbg(); - } + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(RawDlTaskSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + s_VTable->rttiNetTaskSetting.ptr = nullptr; // todo + } + }; + static_assert(sizeof(RawDlTaskSetting) == 0x1004); - if (thisptr) - { - RawUlTaskSetting::ctor(thisptr.GetPtr()); - thisptr->uknExt_vTableProbably = PlayReportSetting_t::kType; - thisptr->ukPlay1 = nullptr; - thisptr->ukPlay2 = 0; - thisptr->ukPlay3 = 0; - thisptr->ukPlay4 = 0; - } + struct PlayReportSetting : RawUlTaskSetting + { + MEMPTR<uint8> ukn1210_ptr; // 0x1210 + uint32be ukn1214_size; // 0x1214 + uint32be ukPlay3; // 0x1218 + uint32be ukPlay4; // 0x121C - osLib_returnFromFunction(hCPU, thisptr.GetMPTR()); + struct VTablePlayReportSetting : public VTableRawUlTaskSetting + {}; + static_assert(sizeof(VTablePlayReportSetting) == 8*5); + static inline SysAllocator<VTablePlayReportSetting> s_VTable; + + static PlayReportSetting* ctor(PlayReportSetting* _this) + { + if(!_this) + _this = boss_new<PlayReportSetting>(); + RawUlTaskSetting::ctor(_this); + _this->vTablePtr = s_VTable; + _this->ukn1210_ptr = nullptr; + _this->ukn1214_size = 0; + _this->ukPlay3 = 0; + _this->ukPlay4 = 0; + return _this; } - void export_Initialize(PPCInterpreter_t* hCPU) + static void dtor(PlayReportSetting* _this, uint32 options) { - ppcDefineParamMEMPTR(thisptr, PlayReportSetting_t, 0); - ppcDefineParamMEMPTR(ptr, void*, 1); - ppcDefineParamU32(value, 2); - ppcDefineParamMEMPTR(directoryName, const char, 4); - //cemuLog_logDebug(LogType::Force, "nn_boss_PlayReportSetting_Initialize(0x{:08x}, {}, 0x{:x}, 0x{:08x})", thisptr.GetMPTR(), ptr.GetPtr(), directorySizeLimit, directoryName.GetMPTR()); + RawUlTaskSetting::dtor(_this, 0); + if(options&1) + boss_delete(_this->ukn1210_ptr.GetPtr()); + } - if(!ptr || value == 0 || value > 0x19000) + static void Initialize(PlayReportSetting* _this, uint8* ptr, uint32 size) + { + if(!ptr || size == 0 || size > 0x19000) { - cemuLog_logDebug(LogType::Force, "nn_boss_PlayReportSetting_Initialize: invalid parameter"); - osLib_returnFromFunction(hCPU, 0); + cemuLog_logDebug(LogType::Force, "nn::boss::PlayReportSetting::Initialize: invalid parameter"); + return; } - *ptr.GetPtr<uint8>() = 0; + *ptr = 0; - *(uint16be*)&thisptr->settings[0x28] = 6; - *(uint16be*)&thisptr->settings[0x2B] |= 0x3; - *(uint16be*)&thisptr->settings[0x2C] |= 0xA; - *(uint32be*)&thisptr->settings[0x7C0] |= 2; - - thisptr->ukPlay1 = ptr; - thisptr->ukPlay2 = value; - thisptr->ukPlay3 = 0; - thisptr->ukPlay4 = 0; + *(uint16be*)&_this->settings[0x28] = 6; + *(uint16be*)&_this->settings[0x2B] |= 0x3; + *(uint16be*)&_this->settings[0x2C] |= 0xA; + *(uint32be*)&_this->settings[0x7C0] |= 2; + + _this->ukn1210_ptr = ptr; + _this->ukn1214_size = size; + _this->ukPlay3 = 0; + _this->ukPlay4 = 0; // TODO - osLib_returnFromFunction(hCPU, 0); } - void export_Set(PPCInterpreter_t* hCPU) + static bool Set(PlayReportSetting* _this, const char* keyname, uint32 value) { - ppcDefineParamMEMPTR(thisptr, PlayReportSetting_t, 0); - ppcDefineParamMEMPTR(key, const char, 1); - ppcDefineParamU32(value, 2); - // TODO - cemuLog_logDebug(LogType::Force, "nn_boss_PlayReportSetting_Set(0x{:08x}, {}, 0x{:x}) TODO", thisptr.GetMPTR(), key.GetPtr(), value); - - osLib_returnFromFunction(hCPU, 1); + return true; } - - } - - namespace Title - { - Title_t* ctor(Title_t* thisptr) + static void InitVTable() { - cemuLog_logDebug(LogType::Force, "nn_boss_Title_ctor(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - *thisptr = {}; - - return thisptr; + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(PlayReportSetting); + s_VTable->RegisterPreprocess.ptr = nullptr; // todo + s_VTable->unk1.ptr = nullptr; // todo + s_VTable->rttiNetTaskSetting.ptr = nullptr; // todo } - } + }; + static_assert(sizeof(PlayReportSetting) == 0x1220); - namespace DirectoryName + struct Task { - DirectoryName_t* ctor(DirectoryName_t* thisptr) + struct VTableTask { - cemuLog_logDebug(LogType::Force, "nn_boss_DirectoryName_ctor(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } + VTableEntry rtti; + VTableEntry dtor; + }; + static inline SysAllocator<VTableTask> s_vTable; - memset(thisptr->name, 0x00, 0x8); + uint32be accountId; // 0x00 + uint32be uk2; // 0x04 + TaskId taskId; // 0x08 + TitleId titleId; // 0x10 + MEMPTR<VTableTask> vTablePtr; // 0x18 + uint32be padding; // 0x1C - return thisptr; - } - - const char* operator_const_char(DirectoryName_t* thisptr) - { - cemuLog_logDebug(LogType::Force, "nn_boss_DirectoryName_operator_const_char(0x{:x})", MEMPTR(thisptr).GetMPTR()); - return thisptr->name; - } - } - - namespace Task - { - - Result Initialize(Task_t* thisptr, const char* taskId, uint32 accountId) + static Result Initialize1(Task* _thisptr, const char* taskId, uint32 accountId) // Initialize__Q3_2nn4boss4TaskFPCcUi { if(!taskId || strnlen(taskId, 0x8) == 8) { return BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_BOSS, 0x3780); } - - thisptr->accountId = accountId; - strncpy(thisptr->taskId.id, taskId, 0x08); + _thisptr->accountId = accountId; + strncpy(_thisptr->taskId.id, taskId, 0x08); return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_BOSS, 0x80); } - Result Initialize(Task_t* thisptr, uint8 slot, const char* taskId) + static Result Initialize2(Task* _thisptr, uint8 slot, const char* taskId) // Initialize__Q3_2nn4boss4TaskFUcPCc { const uint32 accountId = slot == 0 ? 0 : act::GetPersistentIdEx(slot); - return Initialize(thisptr, taskId, accountId); + return Initialize1(_thisptr, taskId, accountId); } - Result Initialize(Task_t* thisptr, const char* taskId) + static Result Initialize3(Task* _thisptr, const char* taskId) // Initialize__Q3_2nn4boss4TaskFPCc { - return Initialize(thisptr, taskId, 0); + return Initialize1(_thisptr, taskId, 0); } - void export_Initialize3(PPCInterpreter_t* hCPU) + static Task* ctor2(Task* _thisptr, const char* taskId, uint32 accountId) // __ct__Q3_2nn4boss4TaskFPCcUi { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(taskId, const char, 1); - ppcDefineParamU32(accountId, 2); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Initialize3(0x{:08x}, {}, 0x{:x})", thisptr.GetMPTR(), taskId.GetPtr(), accountId); - const Result result = Initialize(thisptr.GetPtr(), taskId.GetPtr(), accountId); - osLib_returnFromFunction(hCPU, result); + if (!_thisptr) + _thisptr = boss_new<Task>(); + _thisptr->accountId = 0; + _thisptr->vTablePtr = s_vTable; + TaskId::ctor(&_thisptr->taskId); + TitleId::ctor(&_thisptr->titleId, 0); + auto r = Initialize1(_thisptr, taskId, accountId); + cemu_assert_debug(NN_RESULT_IS_SUCCESS(r)); + return _thisptr; } - void export_Initialize2(PPCInterpreter_t* hCPU) + static Task* ctor1(Task* _thisptr, uint8 slot, const char* taskId) // __ct__Q3_2nn4boss4TaskFUcPCc { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamU8(slotId, 1); - ppcDefineParamMEMPTR(taskId, const char, 2); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Initialize2(0x{:08x}, {}, {})", thisptr.GetMPTR(), slotId, taskId.GetPtr()); - const Result result = Initialize(thisptr.GetPtr(), slotId, taskId.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - void export_Initialize1(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(taskId, const char, 1); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Initialize1(0x{:08x}, {})", thisptr.GetMPTR(), taskId.GetPtr()); - const Result result = Initialize(thisptr.GetPtr(), taskId.GetPtr()); - osLib_returnFromFunction(hCPU, result); + if (!_thisptr) + _thisptr = boss_new<Task>(); + _thisptr->accountId = 0; + _thisptr->vTablePtr = s_vTable; + TaskId::ctor(&_thisptr->taskId); + TitleId::ctor(&_thisptr->titleId, 0); + auto r = Initialize2(_thisptr, slot, taskId); + cemu_assert_debug(NN_RESULT_IS_SUCCESS(r)); + return _thisptr; } - - Task_t* ctor(Task_t* thisptr, const char* taskId, uint32 accountId) + static Task* ctor3(Task* _thisptr, const char* taskId) // __ct__Q3_2nn4boss4TaskFPCc { - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->accountId = 0; - thisptr->ext = 0; // dword_10002174 - TaskId::ctor(&thisptr->taskId); - TitleId::ctor(&thisptr->titleId, 0); - cemu_assert_debug(NN_RESULT_IS_SUCCESS(Initialize(thisptr, taskId, accountId))); - } - - return thisptr; + if (!_thisptr) + _thisptr = boss_new<Task>(); + _thisptr->accountId = 0; + _thisptr->vTablePtr = s_vTable; + TaskId::ctor(&_thisptr->taskId); + TitleId::ctor(&_thisptr->titleId, 0); + auto r = Initialize3(_thisptr, taskId); + cemu_assert_debug(NN_RESULT_IS_SUCCESS(r)); + return _thisptr; } - Task_t* ctor(Task_t* thisptr, uint8 slot, const char* taskId) + static Task* ctor4(Task* _thisptr) // __ct__Q3_2nn4boss4TaskFv { - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->accountId = 0; - thisptr->ext = 0; // dword_10002174 - TaskId::ctor(&thisptr->taskId); - TitleId::ctor(&thisptr->titleId, 0); - cemu_assert_debug(NN_RESULT_IS_SUCCESS(Initialize(thisptr, slot, taskId))); - } - - return thisptr; + if (!_thisptr) + _thisptr = boss_new<Task>(); + _thisptr->accountId = 0; + _thisptr->vTablePtr = s_vTable; + TaskId::ctor(&_thisptr->taskId); + TitleId::ctor(&_thisptr->titleId, 0); + memset(&_thisptr->taskId, 0x00, sizeof(TaskId)); + return _thisptr; } - Task_t* ctor(Task_t* thisptr, const char* taskId) + static void dtor(Task* _this, uint32 options) // __dt__Q3_2nn4boss4TaskFv { - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->accountId = 0; - thisptr->ext = 0; // dword_10002174 - TaskId::ctor(&thisptr->taskId); - TitleId::ctor(&thisptr->titleId, 0); - cemu_assert_debug(NN_RESULT_IS_SUCCESS(Initialize(thisptr, taskId))); - } - - return thisptr; + cemuLog_logDebug(LogType::Force, "nn::boss::Task::dtor(0x{:08x}, 0x{:08x})", MEMPTR(_this).GetMPTR(), options); + // todo - Task::Finalize + if(options & 1) + boss_delete(_this); } - Task_t* ctor(Task_t* thisptr) + static Result Run(Task* _thisptr, bool isForegroundRun) { - if (!thisptr) - { - // thisptr = new Task_t - assert_dbg(); - } - - if (thisptr) - { - thisptr->accountId = 0; - thisptr->ext = 0; // dword_10002174 - TaskId::ctor(&thisptr->taskId); - TitleId::ctor(&thisptr->titleId, 0); - memset(&thisptr->taskId, 0x00, sizeof(TaskId_t)); - } - - return thisptr; - } - - void export_ctor(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_ctor(0x{:08x})", thisptr.GetMPTR()); - ctor(thisptr.GetPtr()); - osLib_returnFromFunction(hCPU, thisptr.GetMPTR()); - } - - void export_Run(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamU8(isForegroundRun, 1); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Run(0x{:08x}, {})", thisptr.GetMPTR(), isForegroundRun); if (isForegroundRun != 0) { - //peterBreak(); cemuLog_logDebug(LogType::Force, "export_Run foreground run"); } bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_RUN; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->titleId = _thisptr->titleId.u64; bossRequest->bool_parameter = isForegroundRun != 0; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, 0); + return 0; } - void export_StartScheduling(PPCInterpreter_t* hCPU) + static Result StartScheduling(Task* _thisptr, uint8 executeImmediately) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamU8(executeImmediately, 1); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_StartScheduling(0x{:08x}, {})", thisptr.GetMPTR(), executeImmediately); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_START_SCHEDULING; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->titleId = _thisptr->titleId.u64; bossRequest->bool_parameter = executeImmediately != 0; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, 0); + return 0; } - void export_StopScheduling(PPCInterpreter_t* hCPU) + static Result StopScheduling(Task* _thisptr) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_StopScheduling(0x{:08x})", thisptr.GetMPTR()); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_STOP_SCHEDULING; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->titleId = _thisptr->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, 0); + return 0; } - void export_IsRegistered(PPCInterpreter_t* hCPU) + static Result IsRegistered(Task* _thisptr) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_IS_REGISTERED; - bossRequest->accountId = thisptr->accountId; - bossRequest->titleId = thisptr->titleId.u64; - bossRequest->taskId = thisptr->taskId.id; + bossRequest->accountId = _thisptr->accountId; + bossRequest->titleId = _thisptr->titleId.u64; + bossRequest->taskId = _thisptr->taskId.id; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_IsRegistered(0x{:08x}) -> {}", thisptr.GetMPTR(), bossRequest->returnCode); - - osLib_returnFromFunction(hCPU, bossRequest->returnCode); + return bossRequest->returnCode; } - void export_Wait(PPCInterpreter_t* hCPU) + static Result Wait(Task* _thisptr, uint32 timeout, uint32 waitState) // Wait__Q3_2nn4boss4TaskFUiQ3_2nn4boss13TaskWaitState { - // Wait__Q3_2nn4boss4TaskFUiQ3_2nn4boss13TaskWaitState - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamU32(timeout, 1); - ppcDefineParamU32(waitState, 2); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Wait(0x{:08x}, 0x{:x}, {})", thisptr.GetMPTR(), timeout, waitState); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_WAIT; - bossRequest->titleId = thisptr->titleId.u64; - bossRequest->taskId = thisptr->taskId.id; + bossRequest->titleId = _thisptr->titleId.u64; + bossRequest->taskId = _thisptr->taskId.id; bossRequest->timeout = timeout; bossRequest->waitState = waitState; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, bossRequest->returnCode); - - //osLib_returnFromFunction(hCPU, 1); // 0 -> timeout, 1 -> wait condition met + return bossRequest->returnCode; } - void export_RegisterForImmediateRun(PPCInterpreter_t* hCPU) + static Result RegisterForImmediateRun(Task* _thisptr, TaskSetting* settings) // RegisterForImmediateRun__Q3_2nn4boss4TaskFRCQ3_2nn4boss11TaskSetting { - // RegisterForImmediateRun__Q3_2nn4boss4TaskFRCQ3_2nn4boss11TaskSetting - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(settings, TaskSetting_t, 1); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_RegisterForImmediateRun(0x{:08x}, 0x{:08x})", thisptr.GetMPTR(), settings.GetMPTR()); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_REGISTER; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->settings = settings.GetPtr(); + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->settings = settings; bossRequest->uk1 = 0xC00; - if (TaskSetting::IsPrivilegedTaskSetting(settings.GetPtr())) - bossRequest->titleId = thisptr->titleId.u64; + if (TaskSetting::IsPrivileged(settings)) + bossRequest->titleId = _thisptr->titleId.u64; - const sint32 result = __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, result); + Result result = __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); + return result; } - void export_Unregister(PPCInterpreter_t* hCPU) + static Result Unregister(Task* _thisptr) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Unregister(0x{:08x})", thisptr.GetMPTR()); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_UNREGISTER; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->titleId = _thisptr->titleId.u64; const sint32 result = __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, result); + return result; } - void export_Register(PPCInterpreter_t* hCPU) + static Result Register(Task* _thisptr, TaskSetting* settings) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(settings, TaskSetting_t, 1); - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Register(0x{:08x}, 0x{:08x})", thisptr.GetMPTR(), settings.GetMPTR()); - - if (hCPU->gpr[4] == 0) + if (!settings) { - cemuLog_logDebug(LogType::Force, "nn_boss_Task_Register - crash workaround (fix me)"); - osLib_returnFromFunction(hCPU, 0); - return; + cemuLog_logDebug(LogType::Force, "nn_boss_Task_Register - crash workaround (fix me)"); // settings should never be zero + return 0; } bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_REGISTER_FOR_IMMEDIATE_RUN; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->settings = settings.GetPtr(); + bossRequest->accountId = _thisptr->accountId; + bossRequest->taskId = _thisptr->taskId.id; + bossRequest->settings = settings; bossRequest->uk1 = 0xC00; - if(TaskSetting::IsPrivilegedTaskSetting(settings.GetPtr())) - bossRequest->titleId = thisptr->titleId.u64; + if(TaskSetting::IsPrivileged(settings)) + bossRequest->titleId = _thisptr->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - osLib_returnFromFunction(hCPU, bossRequest->returnCode); + return bossRequest->returnCode; } - - - void export_GetTurnState(PPCInterpreter_t* hCPU) + + static uint32 GetTurnState(Task* _this, uint32be* executionCountOut) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(execCount, uint32be, 1); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_GET_TURN_STATE; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _this->accountId; + bossRequest->taskId = _this->taskId.id; + bossRequest->titleId = _this->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - if (execCount) - *execCount = bossRequest->u32.exec_count; + if (executionCountOut) + *executionCountOut = bossRequest->u32.exec_count; - cemuLog_logDebug(LogType::Force, "nn_boss_Task_GetTurnState(0x{:08x}, 0x{:08x}) -> {}", thisptr.GetMPTR(), execCount.GetMPTR(), bossRequest->u32.result); - - osLib_returnFromFunction(hCPU, bossRequest->u32.result); - //osLib_returnFromFunction(hCPU, 7); // 7 -> finished? 0x11 -> Error (Splatoon doesn't like it when we return 0x11 for Nbdl tasks) RETURN FINISHED + return bossRequest->u32.result; + // 7 -> finished? 0x11 -> Error (Splatoon doesn't like it when we return 0x11 for Nbdl tasks) } - void export_GetContentLength(PPCInterpreter_t* hCPU) + static uint64 GetContentLength(Task* _this, uint32be* executionCountOut) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(execCount, uint32be, 1); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_GET_CONTENT_LENGTH; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _this->accountId; + bossRequest->taskId = _this->taskId.id; + bossRequest->titleId = _this->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - if (execCount) - *execCount = bossRequest->u64.exec_count; + if (executionCountOut) + *executionCountOut = bossRequest->u64.exec_count; - cemuLog_logDebug(LogType::Force, "nn_boss_Task_GetContentLength(0x{:08x}, 0x{:08x}) -> 0x{:x}", thisptr.GetMPTR(), execCount.GetMPTR(), bossRequest->u64.result); - - osLib_returnFromFunction64(hCPU, bossRequest->u64.result); + return bossRequest->u64.result; } - void export_GetProcessedLength(PPCInterpreter_t* hCPU) + static uint64 GetProcessedLength(Task* _this, uint32be* executionCountOut) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(execCount, uint32be, 1); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_GET_PROCESSED_LENGTH; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _this->accountId; + bossRequest->taskId = _this->taskId.id; + bossRequest->titleId = _this->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - if (execCount) - *execCount = bossRequest->u64.exec_count; - - cemuLog_logDebug(LogType::Force, "nn_boss_Task_GetProcessedLength(0x{:08x}, 0x{:08x}) -> 0x{:x}", thisptr.GetMPTR(), execCount.GetMPTR(), bossRequest->u64.result); - - osLib_returnFromFunction64(hCPU, bossRequest->u64.result); + if (executionCountOut) + *executionCountOut = bossRequest->u64.exec_count; + return bossRequest->u64.result; } - void export_GetHttpStatusCode(PPCInterpreter_t* hCPU) + static uint32 GetHttpStatusCode(Task* _this, uint32be* executionCountOut) { - ppcDefineParamMEMPTR(thisptr, Task_t, 0); - ppcDefineParamMEMPTR(execCount, uint32be, 1); - bossPrepareRequest(); bossRequest->requestCode = IOSU_NN_BOSS_TASK_GET_HTTP_STATUS_CODE; - bossRequest->accountId = thisptr->accountId; - bossRequest->taskId = thisptr->taskId.id; - bossRequest->titleId = thisptr->titleId.u64; + bossRequest->accountId = _this->accountId; + bossRequest->taskId = _this->taskId.id; + bossRequest->titleId = _this->titleId.u64; __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - if (execCount) - *execCount = bossRequest->u32.exec_count; + if (executionCountOut) + *executionCountOut = bossRequest->u32.exec_count; - cemuLog_logDebug(LogType::Force, "nn_boss_Task_GetHttpStatusCode(0x{:08x}, 0x{:08x}) -> {}", thisptr.GetMPTR(), execCount.GetMPTR(), bossRequest->u32.result); - - osLib_returnFromFunction(hCPU, bossRequest->u32.result); + return bossRequest->u32.result; } - } - struct PrivilegedTask_t : Task_t - { - + static void InitVTable() + { + s_vTable->rtti.ptr = nullptr; // todo + s_vTable->dtor.ptr = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) { Task::dtor(MEMPTR<Task>(hCPU->gpr[3]), hCPU->gpr[4]); osLib_returnFromFunction(hCPU, 0); }); + } }; - static_assert(sizeof(PrivilegedTask_t) == 0x20); - - struct AlmightyTask_t : PrivilegedTask_t + + static_assert(sizeof(Task) == 0x20); + + struct PrivilegedTask : Task { - + struct VTablePrivilegedTask : public VTableTask + { + VTableEntry rttiTask; + }; + static_assert(sizeof(VTablePrivilegedTask) == 8*3); + static inline SysAllocator<VTablePrivilegedTask> s_VTable; + + static PrivilegedTask* ctor(PrivilegedTask* _thisptr) + { + if (!_thisptr) + _thisptr = boss_new<PrivilegedTask>(); + Task::ctor4(_thisptr); + _thisptr->vTablePtr = s_VTable; + return _thisptr; + } + + static void dtor(PrivilegedTask* _this, uint32 options) + { + if(!_this) + return; + Task::dtor(_this, 0); + if(options & 1) + boss_delete(_this); + } + + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(PrivilegedTask); + s_VTable->rttiTask.ptr = nullptr; // todo + } }; - static_assert(sizeof(AlmightyTask_t) == 0x20); - - namespace PrivilegedTask - { - PrivilegedTask_t* ctor(PrivilegedTask_t*thisptr) - { - if (!thisptr) - assert_dbg(); // new - - Task::ctor(thisptr); - thisptr->ext = 0x10003a50; - return thisptr; - } - } + static_assert(sizeof(PrivilegedTask) == 0x20); - namespace AlmightyTask + struct AlmightyTask : PrivilegedTask { - AlmightyTask_t* ctor(AlmightyTask_t* thisptr) - { - if (!thisptr) - assert_dbg(); // new + struct VTableAlmightyTask : public VTablePrivilegedTask + {}; + static_assert(sizeof(VTableAlmightyTask) == 8*3); + static inline SysAllocator<VTableAlmightyTask> s_VTable; - PrivilegedTask::ctor(thisptr); - thisptr->ext = 0x10002a0c; - return thisptr; - } - void dtor(AlmightyTask_t* thisptr) + static AlmightyTask* ctor(AlmightyTask* _thisptr) { - if (thisptr) - freeMem(thisptr); + if (!_thisptr) + _thisptr = boss_new<AlmightyTask>(); + PrivilegedTask::ctor(_thisptr); + _thisptr->vTablePtr = s_VTable; + return _thisptr; } - - uint32 Initialize(AlmightyTask_t* thisptr, TitleId_t* titleId, const char* taskId, uint32 accountId) + + static void dtor(AlmightyTask* _thisptr, uint32 options) { - if (!thisptr) + if (!_thisptr) + return; + PrivilegedTask::dtor(_thisptr, 0); + if(options&1) + boss_delete(_thisptr); + } + + static uint32 Initialize(AlmightyTask* _thisptr, TitleId* titleId, const char* taskId, uint32 accountId) + { + if (!_thisptr) return 0xc0203780; - thisptr->accountId = accountId; - thisptr->titleId.u64 = titleId->u64; - strncpy(thisptr->taskId.id, taskId, 8); - thisptr->taskId.id[7] = 0x00; - + _thisptr->accountId = accountId; + _thisptr->titleId.u64 = titleId->u64; + strncpy(_thisptr->taskId.id, taskId, 8); + _thisptr->taskId.id[7] = 0x00; + return 0x200080; } - } - Result InitializeImpl() - { - // if( Initialize(IpcClientCafe*) ) ... - g_isInitialized = true; - return 0; - } - - void export_IsInitialized(PPCInterpreter_t* hCPU) - { - osLib_returnFromFunction(hCPU, (uint32)g_isInitialized); - } - - Result Initialize() - { - Result result; - coreinit::OSLockMutex(&g_mutex); - - if(g_initCounter != 0 || NN_RESULT_IS_SUCCESS((result=InitializeImpl()))) + static void InitVTable() { - g_initCounter++; - result = 0; + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(AlmightyTask); + s_VTable->rttiTask.ptr = nullptr; // todo + } + }; + static_assert(sizeof(AlmightyTask) == 0x20); + + struct DataName + { + char name[32]; + + static DataName* ctor(DataName* _this) // __ct__Q3_2nn4boss8DataNameFv + { + if(!_this) + _this = boss_new<DataName>(); + memset(_this->name, 0, sizeof(name)); + return _this; } - coreinit::OSUnlockMutex(&g_mutex); - return result; - } + static const char* operator_const_char(DataName* _this) // __opPCc__Q3_2nn4boss8DataNameCFv + { + return _this->name; + } + }; + static_assert(sizeof(DataName) == 0x20); - void export_Initialize(PPCInterpreter_t* hCPU) + struct BossStorageFadEntry { - cemuLog_logDebug(LogType::Force, "nn_boss_Initialize()"); - osLib_returnFromFunction(hCPU, Initialize()); - } - - void export_GetBossState(PPCInterpreter_t* hCPU) - { - cemuLog_logDebug(LogType::Force, "nn_boss.GetBossState() - stub"); - osLib_returnFromFunction(hCPU, 7); - } - - enum StorageKind - { - kStorageKind_NBDL, - kStorageKind_RawDl, + char name[32]; + uint32be fileNameId; + uint32 ukn24; + uint32 ukn28; + uint32 ukn2C; + uint32 ukn30; + uint32be timestampRelated; // guessed }; - namespace Storage +#define FAD_ENTRY_MAX_COUNT 512 + + struct Storage { - struct bossStorage_t + struct VTableStorage { - /* +0x00 */ uint32be accountId; - /* +0x04 */ uint32be storageKind; - /* +0x08 */ uint8 ukn08Array[3]; - /* +0x0B */ char storageName[8]; - uint8 ukn13; - uint8 ukn14; - uint8 ukn15; - uint8 ukn16; - uint8 ukn17; - /* +0x18 */ - nn::boss::TitleId_t titleId; - uint32be ukn20; // pointer to some global struct - uint32be ukn24; + VTableEntry rtti; + VTableEntry dtor; }; - - static_assert(sizeof(bossStorage_t) == 0x28); - static_assert(offsetof(bossStorage_t, storageKind) == 0x04); - static_assert(offsetof(bossStorage_t, ukn08Array) == 0x08); - static_assert(offsetof(bossStorage_t, storageName) == 0x0B); - static_assert(offsetof(bossStorage_t, titleId) == 0x18); + static inline SysAllocator<VTableStorage> s_vTable; - bossStorage_t* ctor(bossStorage_t* thisptr) + enum StorageKind { - cemuLog_logDebug(LogType::Force, "nn_boss_Storage_ctor(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - { - // thisptr = new RawDlTaskSetting_t - assert_dbg(); - } + kStorageKind_NBDL, + kStorageKind_RawDl, + }; - if (thisptr) - { - thisptr->titleId.u64 = 0; - thisptr->ukn20 = 0x10000a64; - } + /* +0x00 */ uint32be accountId; + /* +0x04 */ uint32be storageKind; + /* +0x08 */ uint8 ukn08Array[3]; + /* +0x0B */ char storageName[8]; + uint8 ukn13; + uint8 ukn14; + uint8 ukn15; + uint8 ukn16; + uint8 ukn17; + /* +0x18 */ nn::boss::TitleId titleId; + /* +0x20 */ MEMPTR<VTableStorage> vTablePtr; + /* +0x24 */ uint32be ukn24; - return thisptr; + static nn::boss::Storage* ctor1(nn::boss::Storage* _this) // __ct__Q3_2nn4boss7StorageFv + { + if(!_this) + _this = boss_new<nn::boss::Storage>(); + _this->vTablePtr = s_vTable; + _this->titleId.u64 = 0; + return _this; } - void nnBossStorage_prepareTitleId(bossStorage_t* storage) + static void dtor(nn::boss::Storage* _this, uint32 options) // __dt__Q3_2nn4boss7StorageFv + { + cemuLog_logDebug(LogType::Force, "nn::boss::Storage::dtor(0x{:08x}, 0x{:08x})", MEMPTR(_this).GetMPTR(), options); + Finalize(_this); + if(options & 1) + boss_delete(_this); + } + + static void nnBossStorage_prepareTitleId(Storage* storage) { if (storage->titleId.u64 != 0) return; storage->titleId.u64 = CafeSystem::GetForegroundTitleId(); } - Result Initialize(bossStorage_t* thisptr, const char* dirName, uint32 accountId, StorageKind type) + static Result Initialize(Storage* _thisptr, const char* dirName, uint32 accountId, StorageKind type) { if (!dirName) return 0xC0203780; cemuLog_logDebug(LogType::Force, "boss::Storage::Initialize({}, 0x{:08x}, {})", dirName, accountId, type); - thisptr->storageKind = type; - thisptr->titleId.u64 = 0; + _thisptr->storageKind = type; + _thisptr->titleId.u64 = 0; - memset(thisptr->storageName, 0, 0x8); - strncpy(thisptr->storageName, dirName, 0x8); - thisptr->storageName[7] = '\0'; + memset(_thisptr->storageName, 0, 0x8); + strncpy(_thisptr->storageName, dirName, 0x8); + _thisptr->storageName[7] = '\0'; - thisptr->accountId = accountId; + _thisptr->accountId = accountId; - nnBossStorage_prepareTitleId(thisptr); // usually not done like this + nnBossStorage_prepareTitleId(_thisptr); // usually not done like this return 0x200080; } - Result Initialize2(bossStorage_t* thisptr, const char* dirName, StorageKind type) + static Result Initialize2(Storage* _thisptr, const char* dirName, StorageKind type) { - return Initialize(thisptr, dirName, 0, type); + return Initialize(_thisptr, dirName, 0, type); } - } - using Storage_t = Storage::bossStorage_t; - struct AlmightyStorage_t : Storage_t - { - }; - static_assert(sizeof(AlmightyStorage_t) == 0x28); - - namespace AlmightyStorage - { - AlmightyStorage_t* ctor(AlmightyStorage_t* thisptr) + static void Finalize(Storage* _this) { - cemuLog_logDebug(LogType::Force, "nn_boss_AlmightyStorage_ctor(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) + memset(_this, 0, sizeof(Storage)); // todo - not all fields might be cleared + } + + static Result GetDataList(nn::boss::Storage* storage, DataName* dataList, sint32 maxEntries, uint32be* outputEntryCount, uint32 startIndex) // GetDataList__Q3_2nn4boss7StorageCFPQ3_2nn4boss8DataNameUiPUiT2 + { + // initialize titleId of storage if not already done + nnBossStorage_prepareTitleId(storage); + + cemu_assert_debug(startIndex == 0); // non-zero index is todo + + // load fad.db + BossStorageFadEntry* fadTable = nnBossStorageFad_getTable(storage); + if (fadTable) { - // thisptr = new RawDlTaskSetting_t - assert_dbg(); + sint32 validEntryCount = 0; + for (sint32 i = 0; i < FAD_ENTRY_MAX_COUNT; i++) + { + if( fadTable[i].name[0] == '\0' ) + continue; + memcpy(dataList[validEntryCount].name, fadTable[i].name, 0x20); + validEntryCount++; + if (validEntryCount >= maxEntries) + break; + } + *outputEntryCount = validEntryCount; + free(fadTable); } - - if (thisptr) + else { - Storage::ctor(thisptr); - thisptr->ukn20 = 0x100028a4; + // could not load fad table + *outputEntryCount = 0; } - - return thisptr; + return 0; // todo } - uint32 Initialize(AlmightyStorage_t* thisptr, TitleId_t* titleId, const char* storageName, uint32 accountId, StorageKind storageKind) + static bool Exist(nn::boss::Storage* storage) { - cemuLog_logDebug(LogType::Force, "nn_boss_AlmightyStorage_Initialize(0x{:x})", MEMPTR(thisptr).GetMPTR()); - if (!thisptr) - return 0xc0203780; - - thisptr->accountId = accountId; - thisptr->storageKind = storageKind; - thisptr->titleId.u64 = titleId->u64; - - strncpy(thisptr->storageName, storageName, 8); - thisptr->storageName[0x7] = 0x00; - - return 0x200080; - } - } -} -} - -// Storage - -struct bossDataName_t -{ - char name[32]; -}; - -static_assert(sizeof(bossDataName_t) == 0x20); - -struct bossStorageFadEntry_t -{ - char name[32]; - uint32be fileNameId; - uint32 ukn24; - uint32 ukn28; - uint32 ukn2C; - uint32 ukn30; - uint32be timestampRelated; // guessed -}; - -// __ct__Q3_2nn4boss8DataNameFv -void nnBossDataNameExport_ct(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(dataName, bossDataName_t, 0); - memset(dataName, 0, sizeof(bossDataName_t)); - osLib_returnFromFunction(hCPU, memory_getVirtualOffsetFromPointer(dataName)); -} - -// __opPCc__Q3_2nn4boss8DataNameCFv -void nnBossDataNameExport_opPCc(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(dataName, bossDataName_t, 0); - osLib_returnFromFunction(hCPU, memory_getVirtualOffsetFromPointer(dataName->name)); -} - -void nnBossStorageExport_ct(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(storage, nn::boss::Storage::bossStorage_t, 0); - cemuLog_logDebug(LogType::Force, "Constructor for boss storage called"); - // todo - memset(storage, 0, sizeof(nn::boss::Storage::bossStorage_t)); - osLib_returnFromFunction(hCPU, memory_getVirtualOffsetFromPointer(storage)); -} - -void nnBossStorageExport_exist(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(storage, nn::boss::Storage::bossStorage_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss.Storage_Exist(...) TODO"); - - // todo - osLib_returnFromFunction(hCPU, 1); -} - -#define FAD_ENTRY_MAX_COUNT 512 - -FSCVirtualFile* nnBossStorageFile_open(nn::boss::Storage::bossStorage_t* storage, uint32 fileNameId) -{ - char storageFilePath[1024]; - sprintf(storageFilePath, "/cemuBossStorage/%08x/%08x/user/common/data/%s/%08x", (uint32)(storage->titleId.u64 >> 32), (uint32)(storage->titleId.u64), storage->storageName, fileNameId); - sint32 fscStatus; - FSCVirtualFile* fscStorageFile = fsc_open(storageFilePath, FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION | FSC_ACCESS_FLAG::WRITE_PERMISSION, &fscStatus); - return fscStorageFile; -} - -bossStorageFadEntry_t* nnBossStorageFad_getTable(nn::boss::Storage::bossStorage_t* storage) -{ - const auto accountId = ActiveSettings::GetPersistentId(); - char fadPath[1024]; - sprintf(fadPath, "/cemuBossStorage/%08x/%08x/user/common/%08x/%s/fad.db", (uint32)(storage->titleId.u64 >> 32), (uint32)(storage->titleId.u64), accountId, storage->storageName); - - sint32 fscStatus; - FSCVirtualFile* fscFadFile = fsc_open(fadPath, FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - if (!fscFadFile) - { - return nullptr; - } - // skip first 8 bytes - fsc_setFileSeek(fscFadFile, 8); - // read entries - bossStorageFadEntry_t* fadTable = (bossStorageFadEntry_t*)malloc(sizeof(bossStorageFadEntry_t)*FAD_ENTRY_MAX_COUNT); - memset(fadTable, 0, sizeof(bossStorageFadEntry_t)*FAD_ENTRY_MAX_COUNT); - fsc_readFile(fscFadFile, fadTable, sizeof(bossStorageFadEntry_t)*FAD_ENTRY_MAX_COUNT); - fsc_close(fscFadFile); - return fadTable; -} - -// Find index of entry by name. Returns -1 if not found -sint32 nnBossStorageFad_getIndexByName(bossStorageFadEntry_t* fadTable, char* name) -{ - for (sint32 i = 0; i < FAD_ENTRY_MAX_COUNT; i++) - { - if (fadTable[i].name[0] == '\0') - continue; - if (strncmp(name, fadTable[i].name, 0x20) == 0) - { - return i; - } - } - return -1; -} - -bool nnBossStorageFad_getEntryByName(nn::boss::Storage::bossStorage_t* storage, char* name, bossStorageFadEntry_t* fadEntry) -{ - bossStorageFadEntry_t* fadTable = nnBossStorageFad_getTable(storage); - if (fadTable) - { - sint32 entryIndex = nnBossStorageFad_getIndexByName(fadTable, name); - if (entryIndex >= 0) - { - memcpy(fadEntry, fadTable + entryIndex, sizeof(bossStorageFadEntry_t)); - free(fadTable); + cemuLog_logDebug(LogType::Force, "nn_boss::Storage::Exist() TODO"); return true; } - free(fadTable); - } - return false; -} -void nnBossStorageExport_getDataList(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(storage, nn::boss::Storage::bossStorage_t, 0); - ppcDefineParamStructPtr(dataList, bossDataName_t, 1); - ppcDefineParamS32(maxEntries, 2); - ppcDefineParamU32BEPtr(outputEntryCount, 3); - cemuLog_logDebug(LogType::Force, "boss storage getDataList()"); + /* FAD access */ - // initialize titleId of storage if not already done - nnBossStorage_prepareTitleId(storage); - - // load fad.db - bossStorageFadEntry_t* fadTable = nnBossStorageFad_getTable(storage); - if (fadTable) - { - sint32 validEntryCount = 0; - for (sint32 i = 0; i < FAD_ENTRY_MAX_COUNT; i++) + static FSCVirtualFile* nnBossStorageFile_open(nn::boss::Storage* storage, uint32 fileNameId) { - if( fadTable[i].name[0] == '\0' ) - continue; - memcpy(dataList[validEntryCount].name, fadTable[i].name, 0x20); - validEntryCount++; - if (validEntryCount >= maxEntries) - break; + char storageFilePath[1024]; + sprintf(storageFilePath, "/cemuBossStorage/%08x/%08x/user/common/data/%s/%08x", (uint32)(storage->titleId.u64 >> 32), (uint32)(storage->titleId.u64), storage->storageName, fileNameId); + sint32 fscStatus; + FSCVirtualFile* fscStorageFile = fsc_open(storageFilePath, FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION | FSC_ACCESS_FLAG::WRITE_PERMISSION, &fscStatus); + return fscStorageFile; } - *outputEntryCount = validEntryCount; - free(fadTable); - } - else - { - // could not load fad table - *outputEntryCount = 0; - } - osLib_returnFromFunction(hCPU, 0); // error code -} -// NsData - -typedef struct -{ - /* +0x00 */ char name[0x20]; - /* +0x20 */ nn::boss::Storage::bossStorage_t storage; - /* +0x48 */ uint64 readIndex; - /* +0x50 */ uint32 ukn50; // some pointer to a global struct - /* +0x54 */ uint32 ukn54; -}nsData_t; - -void nnBossNsDataExport_ct(PPCInterpreter_t* hCPU) -{ - cemuLog_logDebug(LogType::Force, "nnBossNsDataExport_ct"); - ppcDefineParamStructPtr(nsData, nsData_t, 0); - if (!nsData) - assert_dbg(); - - - nsData->ukn50 = 0x10000530; - - memset(nsData->name, 0, 0x20); - - nsData->storage.ukn20 = 0x10000798; - nsData->storage.titleId.u64 = 0; - - nsData->readIndex = 0; - - osLib_returnFromFunction(hCPU, memory_getVirtualOffsetFromPointer(nsData)); -} - -void nnBossNsDataExport_initialize(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - ppcDefineParamStructPtr(storage, nn::boss::Storage::bossStorage_t, 1); - ppcDefineParamStr(dataName, 2); - - if(dataName == nullptr) - { - if (storage->storageKind != 1) + static BossStorageFadEntry* nnBossStorageFad_getTable(nn::boss::Storage* storage) { - osLib_returnFromFunction(hCPU, 0xC0203780); - return; + const auto accountId = ActiveSettings::GetPersistentId(); + char fadPath[1024]; + sprintf(fadPath, "/cemuBossStorage/%08x/%08x/user/common/%08x/%s/fad.db", (uint32)(storage->titleId.u64 >> 32), (uint32)(storage->titleId.u64), accountId, storage->storageName); + + sint32 fscStatus; + FSCVirtualFile* fscFadFile = fsc_open(fadPath, FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + if (!fscFadFile) + { + return nullptr; + } + // skip first 8 bytes + fsc_setFileSeek(fscFadFile, 8); + // read entries + BossStorageFadEntry* fadTable = (BossStorageFadEntry*)malloc(sizeof(BossStorageFadEntry)*FAD_ENTRY_MAX_COUNT); + memset(fadTable, 0, sizeof(BossStorageFadEntry)*FAD_ENTRY_MAX_COUNT); + fsc_readFile(fscFadFile, fadTable, sizeof(BossStorageFadEntry)*FAD_ENTRY_MAX_COUNT); + fsc_close(fscFadFile); + return fadTable; } - } - - nsData->storage.accountId = storage->accountId; - nsData->storage.storageKind = storage->storageKind; - memcpy(nsData->storage.ukn08Array, storage->ukn08Array, 3); - memcpy(nsData->storage.storageName, storage->storageName, 8); - - nsData->storage.titleId.u64 = storage->titleId.u64; - - nsData->storage = *storage; - - if (dataName != nullptr || storage->storageKind != 1) - strncpy(nsData->name, dataName, 0x20); - else - strncpy(nsData->name, "rawcontent.dat", 0x20); - nsData->name[0x1F] = '\0'; - - nsData->readIndex = 0; - - cemuLog_logDebug(LogType::Force, "nnBossNsDataExport_initialize: {}", nsData->name); - - osLib_returnFromFunction(hCPU, 0x200080); -} - -std::string nnBossNsDataExport_GetPath(nsData_t* nsData) -{ - uint32 accountId = nsData->storage.accountId; - if (accountId == 0) - accountId = iosuAct_getAccountIdOfCurrentAccount(); - - uint64 title_id = nsData->storage.titleId.u64; - if (title_id == 0) - title_id = CafeSystem::GetForegroundTitleId(); - - fs::path path = fmt::format("cemuBossStorage/{:08x}/{:08x}/user/{:08x}", (uint32)(title_id >> 32), (uint32)(title_id & 0xFFFFFFFF), accountId); - path /= nsData->storage.storageName; - path /= nsData->name; - return path.string(); -} - -void nnBossNsDataExport_DeleteRealFileWithHistory(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - cemuLog_logDebug(LogType::Force, "nn_boss.NsData_DeleteRealFileWithHistory(...)"); - - if (nsData->storage.storageKind == nn::boss::kStorageKind_NBDL) - { - // todo - cemuLog_log(LogType::Force, "BOSS NBDL: Unsupported delete"); - } - else - { - sint32 fscStatus = FSC_STATUS_OK; - std::string filePath = nnBossNsDataExport_GetPath(nsData).c_str(); - fsc_remove((char*)filePath.c_str(), &fscStatus); - if (fscStatus != 0) - cemuLog_log(LogType::Force, "Unhandeled FSC status in BOSS DeleteRealFileWithHistory()"); - } - osLib_returnFromFunction(hCPU, 0); -} - -void nnBossNsDataExport_Exist(PPCInterpreter_t* hCPU) -{ - cemuLog_logDebug(LogType::Force, "nn_boss.NsData_Exist(...)"); - ppcDefineParamStructPtr(nsData, nsData_t, 0); - - bool fileExists = false; - if(nsData->storage.storageKind == nn::boss::kStorageKind_NBDL) - { - // check if name is present in fad table - bossStorageFadEntry_t* fadTable = nnBossStorageFad_getTable(&nsData->storage); - if (fadTable) + // Find index of entry by name. Returns -1 if not found + static sint32 nnBossStorageFad_getIndexByName(BossStorageFadEntry* fadTable, char* name) { - fileExists = nnBossStorageFad_getIndexByName(fadTable, nsData->name) >= 0; - cemuLog_logDebug(LogType::Force, "\t({}) -> {}", nsData->name, fileExists); - free(fadTable); + for (sint32 i = 0; i < FAD_ENTRY_MAX_COUNT; i++) + { + if (fadTable[i].name[0] == '\0') + continue; + if (strncmp(name, fadTable[i].name, 0x20) == 0) + { + return i; + } + } + return -1; } - } - else - { - sint32 fscStatus; - auto fscStorageFile = fsc_open((char*)nnBossNsDataExport_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE, &fscStatus); - if (fscStorageFile != nullptr) + + static bool nnBossStorageFad_getEntryByName(nn::boss::Storage* storage, char* name, BossStorageFadEntry* fadEntry) { - fileExists = true; + BossStorageFadEntry* fadTable = nnBossStorageFad_getTable(storage); + if (fadTable) + { + sint32 entryIndex = nnBossStorageFad_getIndexByName(fadTable, name); + if (entryIndex >= 0) + { + memcpy(fadEntry, fadTable + entryIndex, sizeof(BossStorageFadEntry)); + free(fadTable); + return true; + } + free(fadTable); + } + return false; + } + + static void InitVTable() + { + s_vTable->rtti.ptr = nullptr; // todo + s_vTable->dtor.ptr = DTOR_WRAPPER(Storage); + } + }; + + static_assert(sizeof(Storage) == 0x28); + static_assert(offsetof(Storage, storageKind) == 0x04); + static_assert(offsetof(Storage, ukn08Array) == 0x08); + static_assert(offsetof(Storage, storageName) == 0x0B); + static_assert(offsetof(Storage, titleId) == 0x18); + + struct AlmightyStorage : Storage + { + struct VTableAlmightyStorage : public VTableStorage + { + VTableEntry rttiStorage; + }; + static_assert(sizeof(VTableAlmightyStorage) == 8*3); + static inline SysAllocator<VTableAlmightyStorage> s_VTable; + + static AlmightyStorage* ctor(AlmightyStorage* _thisptr) + { + cemuLog_logDebug(LogType::Force, "nn_boss_AlmightyStorage_ctor(0x{:x})", MEMPTR(_thisptr).GetMPTR()); + if (!_thisptr) + _thisptr = boss_new<AlmightyStorage>(); + Storage::ctor1(_thisptr); + _thisptr->vTablePtr = s_VTable; + return _thisptr; + } + + static uint32 Initialize(AlmightyStorage* _thisptr, TitleId* titleId, const char* storageName, uint32 accountId, StorageKind storageKind) + { + cemuLog_logDebug(LogType::Force, "nn_boss_AlmightyStorage_Initialize(0x{:x})", MEMPTR(_thisptr).GetMPTR()); + if (!_thisptr) + return 0xc0203780; + + _thisptr->accountId = accountId; + _thisptr->storageKind = storageKind; + _thisptr->titleId.u64 = titleId->u64; + + strncpy(_thisptr->storageName, storageName, 8); + _thisptr->storageName[0x7] = 0x00; + + return 0x200080; + } + + static void InitVTable() + { + s_VTable->rtti.ptr = nullptr; // todo + s_VTable->dtor.ptr = DTOR_WRAPPER(AlmightyStorage); + s_VTable->rttiStorage.ptr = nullptr; // todo + } + }; + static_assert(sizeof(AlmightyStorage) == 0x28); + + // NsData + + struct NsData + { + struct VTableNsData + { + VTableEntry rtti; + VTableEntry dtor; + }; + static inline SysAllocator<VTableNsData> s_vTable; + + /* +0x00 */ char name[0x20]; // DataName ? + /* +0x20 */ nn::boss::Storage storage; + /* +0x48 */ uint64 readIndex; + /* +0x50 */ MEMPTR<void> vTablePtr; + /* +0x54 */ uint32 ukn54; + + static NsData* ctor(NsData* _this) + { + if (!_this) + _this = boss_new<NsData>(); + _this->vTablePtr = s_vTable; + memset(_this->name, 0, sizeof(_this->name)); + _this->storage.ctor1(&_this->storage); + _this->readIndex = 0; + return _this; + } + + static void dtor(NsData* _this, uint32 options) // __dt__Q3_2nn4boss6NsDataFv + { + _this->storage.dtor(&_this->storage, 0); + // todo + if(options & 1) + boss_delete(_this); + } + + static Result Initialize(NsData* _this, nn::boss::Storage* storage, const char* dataName) + { + if(dataName == nullptr) + { + if (storage->storageKind != 1) + { + return 0xC0203780; + } + } + + _this->storage.accountId = storage->accountId; + _this->storage.storageKind = storage->storageKind; + + memcpy(_this->storage.ukn08Array, storage->ukn08Array, 3); + memcpy(_this->storage.storageName, storage->storageName, 8); + + _this->storage.titleId.u64 = storage->titleId.u64; + + _this->storage = *storage; + + if (dataName != nullptr || storage->storageKind != 1) + strncpy(_this->name, dataName, 0x20); + else + strncpy(_this->name, "rawcontent.dat", 0x20); + _this->name[0x1F] = '\0'; + + _this->readIndex = 0; + + cemuLog_logDebug(LogType::Force, "initialize: {}", _this->name); + + return 0x200080; + } + + static std::string _GetPath(NsData* nsData) + { + uint32 accountId = nsData->storage.accountId; + if (accountId == 0) + accountId = iosuAct_getAccountIdOfCurrentAccount(); + + uint64 title_id = nsData->storage.titleId.u64; + if (title_id == 0) + title_id = CafeSystem::GetForegroundTitleId(); + + fs::path path = fmt::format("cemuBossStorage/{:08x}/{:08x}/user/{:08x}", (uint32)(title_id >> 32), (uint32)(title_id & 0xFFFFFFFF), accountId); + path /= nsData->storage.storageName; + path /= nsData->name; + return path.string(); + } + + static Result DeleteRealFileWithHistory(NsData* nsData) + { + if (nsData->storage.storageKind == nn::boss::Storage::kStorageKind_NBDL) + { + // todo + cemuLog_log(LogType::Force, "BOSS NBDL: Unsupported delete"); + } + else + { + sint32 fscStatus = FSC_STATUS_OK; + std::string filePath = _GetPath(nsData).c_str(); + fsc_remove((char*)filePath.c_str(), &fscStatus); + if (fscStatus != 0) + cemuLog_log(LogType::Force, "Unhandeled FSC status in BOSS DeleteRealFileWithHistory()"); + } + return 0; + } + + static uint32 Exist(NsData* nsData) + { + bool fileExists = false; + if(nsData->storage.storageKind == nn::boss::Storage::kStorageKind_NBDL) + { + // check if name is present in fad table + BossStorageFadEntry* fadTable = nn::boss::Storage::nnBossStorageFad_getTable(&nsData->storage); + if (fadTable) + { + fileExists = nn::boss::Storage::nnBossStorageFad_getIndexByName(fadTable, nsData->name) >= 0; + cemuLog_logDebug(LogType::Force, "\t({}) -> {}", nsData->name, fileExists); + free(fadTable); + } + } + else + { + sint32 fscStatus; + auto fscStorageFile = fsc_open(_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE, &fscStatus); + if (fscStorageFile != nullptr) + { + fileExists = true; + fsc_close(fscStorageFile); + } + } + return fileExists?1:0; + } + + static uint64 GetSize(NsData* nsData) + { + FSCVirtualFile* fscStorageFile = nullptr; + if (nsData->storage.storageKind == nn::boss::Storage::kStorageKind_NBDL) + { + BossStorageFadEntry fadEntry; + if (nn::boss::Storage::nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + { + cemuLog_log(LogType::Force, "BOSS storage cant find file {}", nsData->name); + return 0; + } + // open file + fscStorageFile = nn::boss::Storage::nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); + } + else + { + sint32 fscStatus; + fscStorageFile = fsc_open(_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + } + + if (fscStorageFile == nullptr) + { + cemuLog_log(LogType::Force, "BOSS storage cant open file alias {}", nsData->name); + return 0; + } + + // get size + const sint32 fileSize = fsc_getFileSize(fscStorageFile); + // close file fsc_close(fscStorageFile); + return fileSize; } - } - osLib_returnFromFunction(hCPU, fileExists?1:0); -} - -void nnBossNsDataExport_getSize(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - - FSCVirtualFile* fscStorageFile = nullptr; - if (nsData->storage.storageKind == nn::boss::kStorageKind_NBDL) - { - bossStorageFadEntry_t fadEntry; - if (nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + static uint64 GetCreatedTime(NsData* nsData) { - cemuLog_log(LogType::Force, "BOSS storage cant find file {}", nsData->name); - osLib_returnFromFunction(hCPU, 0); - return; + cemuLog_logDebug(LogType::Force, "nn_boss.NsData_GetCreatedTime() not implemented. Returning 0"); + uint64 createdTime = 0; + return createdTime; } - // open file - fscStorageFile = nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); - } - else - { - sint32 fscStatus; - fscStorageFile = fsc_open((char*)nnBossNsDataExport_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - } - if (fscStorageFile == nullptr) - { - cemuLog_log(LogType::Force, "BOSS storage cant open file alias {}", nsData->name); - osLib_returnFromFunction(hCPU, 0); - return; - } - - // get size - const sint32 fileSize = fsc_getFileSize(fscStorageFile); - // close file - fsc_close(fscStorageFile); - osLib_returnFromFunction64(hCPU, fileSize); -} - -uint64 nnBossNsData_GetCreatedTime(nsData_t* nsData) -{ - cemuLog_logDebug(LogType::Force, "nn_boss.NsData_GetCreatedTime() not implemented. Returning 0"); - uint64 createdTime = 0; - return createdTime; -} - -uint32 nnBossNsData_read(nsData_t* nsData, uint64* sizeOutBE, void* buffer, sint32 length) -{ - FSCVirtualFile* fscStorageFile = nullptr; - if (nsData->storage.storageKind == nn::boss::kStorageKind_NBDL) - { - bossStorageFadEntry_t fadEntry; - if (nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + static uint32 nnBossNsData_read(NsData* nsData, uint64be* sizeOutBE, void* buffer, sint32 length) { - cemuLog_log(LogType::Force, "BOSS storage cant find file {} for reading", nsData->name); - return 0x80000000; // todo - proper error code + FSCVirtualFile* fscStorageFile = nullptr; + if (nsData->storage.storageKind == nn::boss::Storage::kStorageKind_NBDL) + { + BossStorageFadEntry fadEntry; + if (nn::boss::Storage::nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + { + cemuLog_log(LogType::Force, "BOSS storage cant find file {} for reading", nsData->name); + return 0x80000000; // todo - proper error code + } + // open file + fscStorageFile = nn::boss::Storage::nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); + } + else + { + sint32 fscStatus; + fscStorageFile = fsc_open(_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + } + + if (!fscStorageFile) + { + cemuLog_log(LogType::Force, "BOSS storage cant open file alias {} for reading", nsData->name); + return 0x80000000; // todo - proper error code + } + // get size + sint32 fileSize = fsc_getFileSize(fscStorageFile); + // verify read is within bounds + sint32 readEndOffset = (sint32)_swapEndianU64(nsData->readIndex) + length; + sint32 readBytes = length; + if (readEndOffset > fileSize) + { + readBytes = fileSize - (sint32)_swapEndianU64(nsData->readIndex); + cemu_assert_debug(readBytes != 0); + } + // read + fsc_setFileSeek(fscStorageFile, (uint32)_swapEndianU64(nsData->readIndex)); + fsc_readFile(fscStorageFile, buffer, readBytes); + nsData->readIndex = _swapEndianU64((sint32)_swapEndianU64(nsData->readIndex) + readBytes); + + // close file + fsc_close(fscStorageFile); + if (sizeOutBE) + *sizeOutBE = readBytes; + return 0; } - // open file - fscStorageFile = nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); - } - else - { - sint32 fscStatus; - fscStorageFile = fsc_open((char*)nnBossNsDataExport_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - } - - if (!fscStorageFile) - { - cemuLog_log(LogType::Force, "BOSS storage cant open file alias {} for reading", nsData->name); - return 0x80000000; // todo - proper error code - } - // get size - sint32 fileSize = fsc_getFileSize(fscStorageFile); - // verify read is within bounds - sint32 readEndOffset = (sint32)_swapEndianU64(nsData->readIndex) + length; - sint32 readBytes = length; - if (readEndOffset > fileSize) - { - readBytes = fileSize - (sint32)_swapEndianU64(nsData->readIndex); - cemu_assert_debug(readBytes != 0); - } - // read - fsc_setFileSeek(fscStorageFile, (uint32)_swapEndianU64(nsData->readIndex)); - fsc_readFile(fscStorageFile, buffer, readBytes); - nsData->readIndex = _swapEndianU64((sint32)_swapEndianU64(nsData->readIndex) + readBytes); - - // close file - fsc_close(fscStorageFile); - if (sizeOutBE) - *sizeOutBE = _swapEndianU64(readBytes); - return 0; -} #define NSDATA_SEEK_MODE_BEGINNING (0) -uint32 nnBossNsData_seek(nsData_t* nsData, uint64 seek, uint32 mode) -{ - FSCVirtualFile* fscStorageFile = nullptr; - if (nsData->storage.storageKind == nn::boss::kStorageKind_NBDL) - { - bossStorageFadEntry_t fadEntry; - if (nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + static uint32 nnBossNsData_seek(NsData* nsData, uint64 seek, uint32 mode) { - cemuLog_log(LogType::Force, "BOSS storage cant find file {} for reading", nsData->name); - return 0x80000000; // todo - proper error code + FSCVirtualFile* fscStorageFile = nullptr; + if (nsData->storage.storageKind == nn::boss::Storage::kStorageKind_NBDL) + { + BossStorageFadEntry fadEntry; + if (nn::boss::Storage::nnBossStorageFad_getEntryByName(&nsData->storage, nsData->name, &fadEntry) == false) + { + cemuLog_log(LogType::Force, "BOSS storage cant find file {} for reading", nsData->name); + return 0x80000000; // todo - proper error code + } + // open file + fscStorageFile = nn::boss::Storage::nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); + } + else + { + sint32 fscStatus; + fscStorageFile = fsc_open(_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + } + + if (fscStorageFile == nullptr) + { + cemuLog_log(LogType::Force, "BOSS storage cant open file alias {} for reading", nsData->name); + return 0x80000000; // todo - proper error code + } + // get size + sint32 fileSize = fsc_getFileSize(fscStorageFile); + // handle seek + if (mode == NSDATA_SEEK_MODE_BEGINNING) + { + seek = std::min(seek, (uint64)fileSize); + nsData->readIndex = _swapEndianU64((uint64)seek); + } + else + { + cemu_assert_unimplemented(); + } + fsc_close(fscStorageFile); + return 0; } - // open file - fscStorageFile = nnBossStorageFile_open(&nsData->storage, fadEntry.fileNameId); - } - else - { - sint32 fscStatus; - fscStorageFile = fsc_open((char*)nnBossNsDataExport_GetPath(nsData).c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - } - if (fscStorageFile == nullptr) - { - cemuLog_log(LogType::Force, "BOSS storage cant open file alias {} for reading", nsData->name); - return 0x80000000; // todo - proper error code - } - // get size - sint32 fileSize = fsc_getFileSize(fscStorageFile); - // handle seek - if (mode == NSDATA_SEEK_MODE_BEGINNING) - { - seek = std::min(seek, (uint64)fileSize); - nsData->readIndex = _swapEndianU64((uint64)seek); - } - else - { - cemu_assert_unimplemented(); - } - fsc_close(fscStorageFile); - return 0; + static sint32 Read(NsData* nsData, uint8* buffer, sint32 length) + { + cemuLog_logDebug(LogType::Force, "nsData read (filename {})", nsData->name); + return nnBossNsData_read(nsData, nullptr, buffer, length); + } + + static sint32 ReadWithSizeOut(NsData* nsData, uint64be* sizeOut, uint8* buffer, sint32 length) + { + uint32 r = nnBossNsData_read(nsData, sizeOut, buffer, length); + cemuLog_logDebug(LogType::Force, "nsData readWithSizeOut (filename {} length 0x{:x}) Result: {} Sizeout: {:x}", nsData->name, length, r, _swapEndianU64(*sizeOut)); + return r; + } + + static Result Seek(NsData* nsData, uint64 seekPos, uint32 mode) + { + uint32 r = nnBossNsData_seek(nsData, seekPos, mode); + cemuLog_logDebug(LogType::Force, "nsData seek (filename {} seek 0x{:x}) Result: {}", nsData->name, (uint32)seekPos, r); + return r; + } + + static void InitVTable() + { + s_vTable->rtti.ptr = nullptr; // todo + s_vTable->dtor.ptr = DTOR_WRAPPER(NsData); + } + }; + static_assert(sizeof(NsData) == 0x58); + +} } - -void nnBossNsDataExport_read(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - ppcDefineParamStr(buffer, 1); - ppcDefineParamS32(length, 2); - - cemuLog_logDebug(LogType::Force, "nsData read (filename {})", nsData->name); - - uint32 r = nnBossNsData_read(nsData, nullptr, buffer, length); - - osLib_returnFromFunction(hCPU, r); -} - -void nnBossNsDataExport_readWithSizeOut(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - ppcDefineParamTypePtr(sizeOut, uint64, 1); - ppcDefineParamStr(buffer, 2); - ppcDefineParamS32(length, 3); - - uint32 r = nnBossNsData_read(nsData, sizeOut, buffer, length); - cemuLog_logDebug(LogType::Force, "nsData readWithSizeOut (filename {} length 0x{:x}) Result: {} Sizeout: {:x}", nsData->name, length, r, _swapEndianU64(*sizeOut)); - - osLib_returnFromFunction(hCPU, r); -} - -void nnBossNsDataExport_seek(PPCInterpreter_t* hCPU) -{ - ppcDefineParamStructPtr(nsData, nsData_t, 0); - ppcDefineParamU64(seekPos, 2); - ppcDefineParamU32(mode, 4); - - uint32 r = nnBossNsData_seek(nsData, seekPos, mode); - - cemuLog_logDebug(LogType::Force, "nsData seek (filename {} seek 0x{:x}) Result: {}", nsData->name, (uint32)seekPos, r); - - osLib_returnFromFunction(hCPU, r); -} - void nnBoss_load() { OSInitMutexEx(&nn::boss::g_mutex, nullptr); - osLib_addFunction("nn_boss", "Initialize__Q2_2nn4bossFv", nn::boss::export_Initialize); - osLib_addFunction("nn_boss", "GetBossState__Q2_2nn4bossFv", nn::boss::export_GetBossState); - + nn::boss::g_initCounter = 0; + nn::boss::g_isInitialized = false; + + cafeExportRegisterFunc(nn::boss::GetBossState, "nn_boss", "GetBossState__Q2_2nn4bossFv", LogType::NN_BOSS); + + // boss lib + cafeExportRegisterFunc(nn::boss::Initialize, "nn_boss", "Initialize__Q2_2nn4bossFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::IsInitialized, "nn_boss", "IsInitialized__Q2_2nn4bossFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Finalize, "nn_boss", "Finalize__Q2_2nn4bossFv", LogType::NN_BOSS); + // task - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss4TaskFv", nn::boss::Task::export_ctor); - osLib_addFunction("nn_boss", "Run__Q3_2nn4boss4TaskFb", nn::boss::Task::export_Run); - osLib_addFunction("nn_boss", "Wait__Q3_2nn4boss4TaskFUiQ3_2nn4boss13TaskWaitState", nn::boss::Task::export_Wait); - osLib_addFunction("nn_boss", "GetTurnState__Q3_2nn4boss4TaskCFPUi", nn::boss::Task::export_GetTurnState); - osLib_addFunction("nn_boss", "GetHttpStatusCode__Q3_2nn4boss4TaskCFPUi", nn::boss::Task::export_GetHttpStatusCode); - osLib_addFunction("nn_boss", "GetContentLength__Q3_2nn4boss4TaskCFPUi", nn::boss::Task::export_GetContentLength); - osLib_addFunction("nn_boss", "GetProcessedLength__Q3_2nn4boss4TaskCFPUi", nn::boss::Task::export_GetProcessedLength); - osLib_addFunction("nn_boss", "Register__Q3_2nn4boss4TaskFRQ3_2nn4boss11TaskSetting", nn::boss::Task::export_Register); - osLib_addFunction("nn_boss", "Unregister__Q3_2nn4boss4TaskFv", nn::boss::Task::export_Unregister); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss4TaskFPCc", nn::boss::Task::export_Initialize1); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss4TaskFUcPCc", nn::boss::Task::export_Initialize2); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss4TaskFPCcUi", nn::boss::Task::export_Initialize3); - osLib_addFunction("nn_boss", "IsRegistered__Q3_2nn4boss4TaskCFv", nn::boss::Task::export_IsRegistered); - osLib_addFunction("nn_boss", "RegisterForImmediateRun__Q3_2nn4boss4TaskFRCQ3_2nn4boss11TaskSetting", nn::boss::Task::export_RegisterForImmediateRun); - osLib_addFunction("nn_boss", "StartScheduling__Q3_2nn4boss4TaskFb", nn::boss::Task::export_StartScheduling); - osLib_addFunction("nn_boss", "StopScheduling__Q3_2nn4boss4TaskFv", nn::boss::Task::export_StopScheduling); + nn::boss::Task::InitVTable(); + cafeExportRegisterFunc(nn::boss::Task::ctor1, "nn_boss", "__ct__Q3_2nn4boss4TaskFUcPCc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::ctor2, "nn_boss", "__ct__Q3_2nn4boss4TaskFPCcUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::ctor3, "nn_boss", "__ct__Q3_2nn4boss4TaskFPCc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::ctor4, "nn_boss", "__ct__Q3_2nn4boss4TaskFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::dtor, "nn_boss", "__dt__Q3_2nn4boss4TaskFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Initialize1, "nn_boss", "Initialize__Q3_2nn4boss4TaskFPCcUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Initialize2, "nn_boss", "Initialize__Q3_2nn4boss4TaskFUcPCc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Initialize3, "nn_boss", "Initialize__Q3_2nn4boss4TaskFPCc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Run, "nn_boss", "Run__Q3_2nn4boss4TaskFb", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Wait, "nn_boss", "Wait__Q3_2nn4boss4TaskFUiQ3_2nn4boss13TaskWaitState", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::GetTurnState, "nn_boss", "GetTurnState__Q3_2nn4boss4TaskCFPUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::GetHttpStatusCode, "nn_boss", "GetHttpStatusCode__Q3_2nn4boss4TaskCFPUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::GetContentLength, "nn_boss", "GetContentLength__Q3_2nn4boss4TaskCFPUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::GetProcessedLength, "nn_boss", "GetProcessedLength__Q3_2nn4boss4TaskCFPUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Register, "nn_boss", "Register__Q3_2nn4boss4TaskFRQ3_2nn4boss11TaskSetting", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::Unregister, "nn_boss", "Unregister__Q3_2nn4boss4TaskFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::IsRegistered, "nn_boss", "IsRegistered__Q3_2nn4boss4TaskCFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::RegisterForImmediateRun, "nn_boss", "RegisterForImmediateRun__Q3_2nn4boss4TaskFRCQ3_2nn4boss11TaskSetting", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::StartScheduling, "nn_boss", "StartScheduling__Q3_2nn4boss4TaskFb", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Task::StopScheduling, "nn_boss", "StopScheduling__Q3_2nn4boss4TaskFv", LogType::NN_BOSS); - // Nbdl task setting - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss15NbdlTaskSettingFv", nn::boss::NbdlTaskSetting::export_ctor); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss15NbdlTaskSettingFPCcLT1", nn::boss::NbdlTaskSetting::export_Initialize); - //osLib_addFunction("nn_boss", "SetFileName__Q3_2nn4boss15NbdlTaskSettingFPCc", nn::boss::NbdlTaskSetting::export_SetFileName); - cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::SetFileName, "nn_boss", "SetFileName__Q3_2nn4boss15NbdlTaskSettingFPCc", LogType::Placeholder); + // TaskSetting + nn::boss::TaskSetting::InitVTable(); + cafeExportRegisterFunc(nn::boss::TaskSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss11TaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::TaskSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss11TaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::TaskSetting::IsPrivileged, "nn_boss", "Initialize__Q3_2nn4boss11TaskSettingFPCcUi", LogType::NN_BOSS); + + // NbdlTaskSetting + nn::boss::NbdlTaskSetting::InitVTable(); + cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss15NbdlTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss15NbdlTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::Initialize, "nn_boss", "Initialize__Q3_2nn4boss15NbdlTaskSettingFPCcLT1", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::SetFileName, "nn_boss", "SetFileName__Q3_2nn4boss15NbdlTaskSettingFPCc", LogType::NN_BOSS); - // play task setting - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss17PlayReportSettingFv", nn::boss::PlayReportSetting::export_ctor); - osLib_addFunction("nn_boss", "Set__Q3_2nn4boss17PlayReportSettingFPCcUi", nn::boss::PlayReportSetting::export_Set); - //osLib_addFunction("nn_boss", "Set__Q3_2nn4boss17PlayReportSettingFUiT1", nn::boss::PlayReportSetting::export_Set); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss17PlayReportSettingFPvUi", nn::boss::PlayReportSetting::export_Initialize); + // PlayReportSetting + nn::boss::PlayReportSetting::InitVTable(); + cafeExportRegisterFunc(nn::boss::PlayReportSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss17PlayReportSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::PlayReportSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss17PlayReportSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::PlayReportSetting::Initialize, "nn_boss", "Initialize__Q3_2nn4boss17PlayReportSettingFPvUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::PlayReportSetting::Set, "nn_boss", "Set__Q3_2nn4boss17PlayReportSettingFPCcUi", LogType::NN_BOSS); - cafeExportRegisterFunc(nn::boss::RawDlTaskSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss16RawDlTaskSettingFv", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::RawDlTaskSetting::Initialize, "nn_boss", "Initialize__Q3_2nn4boss16RawDlTaskSettingFPCcbT2N21", LogType::Placeholder); + // RawDlTaskSetting + nn::boss::RawDlTaskSetting::InitVTable(); + cafeExportRegisterFunc(nn::boss::RawDlTaskSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss16RawDlTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::RawDlTaskSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss16RawDlTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::RawDlTaskSetting::Initialize, "nn_boss", "Initialize__Q3_2nn4boss16RawDlTaskSettingFPCcbT2N21", LogType::NN_BOSS); - cafeExportRegisterFunc(nn::boss::NetTaskSetting::SetServiceToken, "nn_boss", "SetServiceToken__Q3_2nn4boss14NetTaskSettingFPCUc", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::NetTaskSetting::AddInternalCaCert, "nn_boss", "AddInternalCaCert__Q3_2nn4boss14NetTaskSettingFSc", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::NetTaskSetting::SetInternalClientCert, "nn_boss", "SetInternalClientCert__Q3_2nn4boss14NetTaskSettingFSc", LogType::Placeholder); + // NetTaskSetting + nn::boss::NetTaskSetting::InitVTable(); + cafeExportRegisterFunc(nn::boss::NetTaskSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss14NetTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NetTaskSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss14NetTaskSettingFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NetTaskSetting::SetServiceToken, "nn_boss", "SetServiceToken__Q3_2nn4boss14NetTaskSettingFPCUc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NetTaskSetting::AddInternalCaCert, "nn_boss", "AddInternalCaCert__Q3_2nn4boss14NetTaskSettingFSc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NetTaskSetting::SetInternalClientCert, "nn_boss", "SetInternalClientCert__Q3_2nn4boss14NetTaskSettingFSc", LogType::NN_BOSS); // Title - cafeExportRegisterFunc(nn::boss::Title::ctor, "nn_boss", "__ct__Q3_2nn4boss5TitleFv", LogType::Placeholder); + nn::boss::Title::InitVTable(); + cafeExportRegisterFunc(nn::boss::Title::ctor, "nn_boss", "__ct__Q3_2nn4boss5TitleFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Title::dtor, "nn_boss", "__dt__Q3_2nn4boss5TitleFv", LogType::NN_BOSS); // cafeExportMakeWrapper<nn::boss::Title::SetNewArrivalFlagOff>("nn_boss", "SetNewArrivalFlagOff__Q3_2nn4boss5TitleFv"); SMM bookmarks // TitleId - cafeExportRegisterFunc(nn::boss::TitleId::ctor1, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFv", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::TitleId::ctor2, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFUL", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::TitleId::cctor, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFRCQ3_2nn4boss7TitleID", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::TitleId::operator_ne, "nn_boss", "__ne__Q3_2nn4boss7TitleIDCFRCQ3_2nn4boss7TitleID", LogType::Placeholder); + cafeExportRegisterFunc(nn::boss::TitleId::ctor1, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::TitleId::ctor2, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFUL", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::TitleId::ctor3, "nn_boss", "__ct__Q3_2nn4boss7TitleIDFRCQ3_2nn4boss7TitleID", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::TitleId::operator_ne, "nn_boss", "__ne__Q3_2nn4boss7TitleIDCFRCQ3_2nn4boss7TitleID", LogType::NN_BOSS); // DataName - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss8DataNameFv", nnBossDataNameExport_ct); - osLib_addFunction("nn_boss", "__opPCc__Q3_2nn4boss8DataNameCFv", nnBossDataNameExport_opPCc); + cafeExportRegisterFunc(nn::boss::DataName::ctor, "nn_boss", "__ct__Q3_2nn4boss8DataNameFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::DataName::operator_const_char, "nn_boss", "__opPCc__Q3_2nn4boss8DataNameCFv", LogType::NN_BOSS); // DirectoryName - cafeExportRegisterFunc(nn::boss::DirectoryName::ctor, "nn_boss", "__ct__Q3_2nn4boss13DirectoryNameFv", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::DirectoryName::operator_const_char, "nn_boss", "__opPCc__Q3_2nn4boss13DirectoryNameCFv", LogType::Placeholder); + cafeExportRegisterFunc(nn::boss::DirectoryName::ctor, "nn_boss", "__ct__Q3_2nn4boss13DirectoryNameFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::DirectoryName::operator_const_char, "nn_boss", "__opPCc__Q3_2nn4boss13DirectoryNameCFv", LogType::NN_BOSS); // Account - cafeExportRegisterFunc(nn::boss::Account::ctor, "nn_boss", "__ct__Q3_2nn4boss7AccountFUi", LogType::Placeholder); - - - // storage - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss7StorageFv", nnBossStorageExport_ct); - //osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss7StorageFPCcQ3_2nn4boss11StorageKind", nnBossStorageExport_initialize); - osLib_addFunction("nn_boss", "Exist__Q3_2nn4boss7StorageCFv", nnBossStorageExport_exist); - osLib_addFunction("nn_boss", "GetDataList__Q3_2nn4boss7StorageCFPQ3_2nn4boss8DataNameUiPUiT2", nnBossStorageExport_getDataList); - osLib_addFunction("nn_boss", "GetDataList__Q3_2nn4boss7StorageCFPQ3_2nn4boss8DataNameUiPUiT2", nnBossStorageExport_getDataList); - cafeExportRegisterFunc(nn::boss::Storage::Initialize, "nn_boss", "Initialize__Q3_2nn4boss7StorageFPCcUiQ3_2nn4boss11StorageKind", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::Storage::Initialize2, "nn_boss", "Initialize__Q3_2nn4boss7StorageFPCcQ3_2nn4boss11StorageKind", LogType::Placeholder); - - // AlmightyStorage - cafeExportRegisterFunc(nn::boss::AlmightyStorage::ctor, "nn_boss", "__ct__Q3_2nn4boss15AlmightyStorageFv", LogType::Placeholder ); - cafeExportRegisterFunc(nn::boss::AlmightyStorage::Initialize, "nn_boss", "Initialize__Q3_2nn4boss15AlmightyStorageFQ3_2nn4boss7TitleIDPCcUiQ3_2nn4boss11StorageKind", LogType::Placeholder ); + nn::boss::BossAccount::InitVTable(); + cafeExportRegisterFunc(nn::boss::BossAccount::ctor, "nn_boss", "__ct__Q3_2nn4boss7AccountFUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::BossAccount::dtor, "nn_boss", "__dt__Q3_2nn4boss7AccountFv", LogType::NN_BOSS); // AlmightyTask - cafeExportRegisterFunc(nn::boss::AlmightyTask::ctor, "nn_boss", "__ct__Q3_2nn4boss12AlmightyTaskFv", LogType::Placeholder); - cafeExportRegisterFunc(nn::boss::AlmightyTask::Initialize, "nn_boss", "Initialize__Q3_2nn4boss12AlmightyTaskFQ3_2nn4boss7TitleIDPCcUi", LogType::Placeholder); - // cafeExportRegisterFunc(nn::boss::AlmightyTask::dtor, "nn_boss", "__dt__Q3_2nn4boss12AlmightyTaskFv", LogType::Placeholder); + nn::boss::AlmightyTask::InitVTable(); + cafeExportRegisterFunc(nn::boss::AlmightyTask::ctor, "nn_boss", "__ct__Q3_2nn4boss12AlmightyTaskFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::AlmightyTask::Initialize, "nn_boss", "Initialize__Q3_2nn4boss12AlmightyTaskFQ3_2nn4boss7TitleIDPCcUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::AlmightyTask::dtor, "nn_boss", "__dt__Q3_2nn4boss12AlmightyTaskFv", LogType::NN_BOSS); + + // Storage + nn::boss::Storage::InitVTable(); + cafeExportRegisterFunc(nn::boss::Storage::ctor1, "nn_boss", "__ct__Q3_2nn4boss7StorageFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::dtor, "nn_boss", "__dt__Q3_2nn4boss7StorageFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::Finalize, "nn_boss", "Finalize__Q3_2nn4boss7StorageFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::Exist, "nn_boss", "Exist__Q3_2nn4boss7StorageCFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::GetDataList, "nn_boss", "GetDataList__Q3_2nn4boss7StorageCFPQ3_2nn4boss8DataNameUiPUiT2", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::Initialize, "nn_boss", "Initialize__Q3_2nn4boss7StorageFPCcUiQ3_2nn4boss11StorageKind", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::Storage::Initialize2, "nn_boss", "Initialize__Q3_2nn4boss7StorageFPCcQ3_2nn4boss11StorageKind", LogType::NN_BOSS); + + // AlmightyStorage + nn::boss::AlmightyStorage::InitVTable(); + cafeExportRegisterFunc(nn::boss::AlmightyStorage::ctor, "nn_boss", "__ct__Q3_2nn4boss15AlmightyStorageFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::AlmightyStorage::Initialize, "nn_boss", "Initialize__Q3_2nn4boss15AlmightyStorageFQ3_2nn4boss7TitleIDPCcUiQ3_2nn4boss11StorageKind", LogType::NN_BOSS); // NsData - osLib_addFunction("nn_boss", "__ct__Q3_2nn4boss6NsDataFv", nnBossNsDataExport_ct); - osLib_addFunction("nn_boss", "Initialize__Q3_2nn4boss6NsDataFRCQ3_2nn4boss7StoragePCc", nnBossNsDataExport_initialize); - osLib_addFunction("nn_boss", "DeleteRealFileWithHistory__Q3_2nn4boss6NsDataFv", nnBossNsDataExport_DeleteRealFileWithHistory); - osLib_addFunction("nn_boss", "Exist__Q3_2nn4boss6NsDataCFv", nnBossNsDataExport_Exist); - osLib_addFunction("nn_boss", "GetSize__Q3_2nn4boss6NsDataCFv", nnBossNsDataExport_getSize); - cafeExportRegisterFunc(nnBossNsData_GetCreatedTime, "nn_boss", "GetCreatedTime__Q3_2nn4boss6NsDataCFv", LogType::Placeholder); - osLib_addFunction("nn_boss", "Read__Q3_2nn4boss6NsDataFPvUi", nnBossNsDataExport_read); - osLib_addFunction("nn_boss", "Read__Q3_2nn4boss6NsDataFPLPvUi", nnBossNsDataExport_readWithSizeOut); - osLib_addFunction("nn_boss", "Seek__Q3_2nn4boss6NsDataFLQ3_2nn4boss12PositionBase", nnBossNsDataExport_seek); - + nn::boss::NsData::InitVTable(); + cafeExportRegisterFunc(nn::boss::NsData::ctor, "nn_boss", "__ct__Q3_2nn4boss6NsDataFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::dtor, "nn_boss", "__dt__Q3_2nn4boss6NsDataFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::Initialize, "nn_boss", "Initialize__Q3_2nn4boss6NsDataFRCQ3_2nn4boss7StoragePCc", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::DeleteRealFileWithHistory, "nn_boss", "DeleteRealFileWithHistory__Q3_2nn4boss6NsDataFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::Exist, "nn_boss", "Exist__Q3_2nn4boss6NsDataCFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::GetSize, "nn_boss", "GetSize__Q3_2nn4boss6NsDataCFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::GetCreatedTime, "nn_boss", "GetCreatedTime__Q3_2nn4boss6NsDataCFv", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::Read, "nn_boss", "Read__Q3_2nn4boss6NsDataFPvUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::ReadWithSizeOut, "nn_boss", "Read__Q3_2nn4boss6NsDataFPLPvUi", LogType::NN_BOSS); + cafeExportRegisterFunc(nn::boss::NsData::Seek, "nn_boss", "Seek__Q3_2nn4boss6NsDataFLQ3_2nn4boss12PositionBase", LogType::NN_BOSS); } diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index 6d596acf..058ab07a 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -44,6 +44,7 @@ const std::map<LogType, std::string> g_logging_window_mapping {LogType::CoreinitThread, "Coreinit Thread"}, {LogType::NN_NFP, "nn::nfp"}, {LogType::NN_FP, "nn::fp"}, + {LogType::NN_BOSS, "nn::boss"}, {LogType::GX2, "GX2"}, {LogType::SoundAPI, "Audio"}, {LogType::InputAPI, "Input"}, diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index bbffd164..fe74a6bc 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -35,6 +35,7 @@ enum class LogType : sint32 NN_OLV = 23, NN_NFP = 13, NN_FP = 24, + NN_BOSS = 25, TextureReadback = 29, diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 023918bd..4d2fb478 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2232,6 +2232,7 @@ void MainWindow::RecreateMenu() debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("&Coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_FP), _("&NN FP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_FP)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_BOSS), _("&NN BOSS"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_BOSS)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("&GX2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("&Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::InputAPI), _("&Input API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::InputAPI)); From 5c0d5a54acf4263631d855f4181462f97a26b426 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 3 Apr 2024 02:39:25 +0200 Subject: [PATCH 132/314] vcpkg/linux: Avoid dependency on liblzma for now Use port of tiff which does not rely on lzma --- .../tiff/FindCMath.patch | 13 +++ .../tiff/portfile.cmake | 86 +++++++++++++++ .../vcpkg_overlay_ports_linux/tiff/usage | 9 ++ .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ++++++++++++++++++ .../vcpkg_overlay_ports_linux/tiff/vcpkg.json | 67 +++++++++++ 5 files changed, 279 insertions(+) create mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/usage create mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in create mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch new file mode 100644 index 00000000..70654cf8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake +index ad92218..dd42aba 100644 +--- a/cmake/FindCMath.cmake ++++ b/cmake/FindCMath.cmake +@@ -31,7 +31,7 @@ include(CheckSymbolExists) + include(CheckLibraryExists) + + check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) +-find_library(CMath_LIBRARY NAMES m) ++find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + + if(NOT CMath_HAVE_LIBC_POW) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake new file mode 100644 index 00000000..426d8af7 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake @@ -0,0 +1,86 @@ +vcpkg_from_gitlab( + GITLAB_URL https://gitlab.com + OUT_SOURCE_PATH SOURCE_PATH + REPO libtiff/libtiff + REF "v${VERSION}" + SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa + HEAD_REF master + PATCHES + FindCMath.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + cxx cxx + jpeg jpeg + jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG + libdeflate libdeflate + libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate + lzma lzma + lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma + tools tiff-tools + webp webp + webp CMAKE_REQUIRE_FIND_PACKAGE_WebP + zip zlib + zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB + zstd zstd + zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON + -Dtiff-docs=OFF + -Dtiff-contrib=OFF + -Dtiff-tests=OFF + -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. + -Djpeg12=OFF + -Dlerc=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON + -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON + -DZSTD_HAVE_DECOMPRESS_STREAM=ON + -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF + OPTIONS_DEBUG + -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. + MAYBE_UNUSED_VARIABLES + CMAKE_DISABLE_FIND_PACKAGE_GLUT + CMAKE_DISABLE_FIND_PACKAGE_OpenGL + ZSTD_HAVE_DECOMPRESS_STREAM +) + +vcpkg_cmake_install() + +# CMake config wasn't packaged in the past and is not yet usable now, +# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 +# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") + +set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") +if(EXISTS "${_file}") + vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") +endif() +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) + +if ("tools" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES + tiffcp + tiffdump + tiffinfo + tiffset + tiffsplit + AUTO_CLEAN + ) +endif() + +vcpkg_copy_pdbs() +file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/usage b/dependencies/vcpkg_overlay_ports_linux/tiff/usage new file mode 100644 index 00000000..d47265b1 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/tiff/usage @@ -0,0 +1,9 @@ +tiff is compatible with built-in CMake targets: + + find_package(TIFF REQUIRED) + target_link_libraries(main PRIVATE TIFF::TIFF) + +tiff provides pkg-config modules: + + # Tag Image File Format (TIFF) library. + libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000..1d04ec7a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,104 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0057 NEW) +set(z_vcpkg_tiff_find_options "") +if("REQUIRED" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "REQUIRED") +endif() +if("QUIET" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "QUIET") +endif() + +_find_package(${ARGS}) + +if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + include(SelectLibraryConfigurations) + set(z_vcpkg_tiff_link_libraries "") + set(z_vcpkg_tiff_libraries "") + if("@webp@") + find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") + list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) + endif() + if("@lzma@") + find_package(LibLZMA ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") + list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) + endif() + if("@jpeg@") + find_package(JPEG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") + list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) + endif() + if("@zstd@") + find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") + if(TARGET zstd::libzstd_shared) + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) + if(WIN32) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) + endif() + get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) + get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(ZSTD) + if(NOT TARGET ZSTD::ZSTD) + add_library(ZSTD::ZSTD INTERFACE IMPORTED) + set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) + endif() + list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) + list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) + unset(z_vcpkg_tiff_zstd) + unset(z_vcpkg_tiff_zstd_configs) + unset(z_vcpkg_config) + unset(z_vcpkg_tiff_zstd_target) + endif() + if("@libdeflate@") + find_package(libdeflate ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_property "IMPORTED_LOCATION_") + if(TARGET libdeflate::libdeflate_shared) + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) + if(WIN32) + set(z_vcpkg_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) + endif() + get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) + get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(Z_VCPKG_DEFLATE) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") + list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) + unset(z_vcpkg_config) + unset(z_vcpkg_libdeflate_configs) + unset(z_vcpkg_libdeflate_target) + unset(z_vcpkg_property) + unset(Z_VCPKG_DEFLATE_FOUND) + endif() + if("@zlib@") + find_package(ZLIB ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") + list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) + endif() + if(UNIX) + list(APPEND z_vcpkg_tiff_link_libraries m) + list(APPEND z_vcpkg_tiff_libraries m) + endif() + + if(TARGET TIFF::TIFF) + set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) + endif() + list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) + unset(z_vcpkg_tiff_link_libraries) + unset(z_vcpkg_tiff_libraries) +endif() +unset(z_vcpkg_tiff_find_options) +cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json new file mode 100644 index 00000000..9b36e1a8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json @@ -0,0 +1,67 @@ +{ + "name": "tiff", + "version": "4.6.0", + "port-version": 2, + "description": "A library that supports the manipulation of TIFF image files", + "homepage": "https://libtiff.gitlab.io/libtiff/", + "license": "libtiff", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "jpeg", + "zip" + ], + "features": { + "cxx": { + "description": "Build C++ libtiffxx library" + }, + "jpeg": { + "description": "Support JPEG compression in TIFF image files", + "dependencies": [ + "libjpeg-turbo" + ] + }, + "libdeflate": { + "description": "Use libdeflate for faster ZIP support", + "dependencies": [ + "libdeflate", + { + "name": "tiff", + "default-features": false, + "features": [ + "zip" + ] + } + ] + }, + "tools": { + "description": "Build tools" + }, + "webp": { + "description": "Support WEBP compression in TIFF image files", + "dependencies": [ + "libwebp" + ] + }, + "zip": { + "description": "Support ZIP/deflate compression in TIFF image files", + "dependencies": [ + "zlib" + ] + }, + "zstd": { + "description": "Support ZSTD compression in TIFF image files", + "dependencies": [ + "zstd" + ] + } + } +} From 85141f17f977157b91b72883d879f50b27f17dda Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:28:00 +0200 Subject: [PATCH 133/314] vcpkg/linux: Avoid dependency on libsystemd/liblzma libsystemd which is required by dbus has an optional dependency on liblzma and since we don't need it we can just strip it out of dbus --- .../dbus/cmake.dep.patch | 15 ++++ .../dbus/getpeereid.patch | 26 ++++++ .../dbus/libsystemd.patch | 15 ++++ .../dbus/pkgconfig.patch | 21 +++++ .../dbus/portfile.cmake | 88 +++++++++++++++++++ .../vcpkg_overlay_ports_linux/dbus/vcpkg.json | 30 +++++++ 6 files changed, 195 insertions(+) create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch new file mode 100644 index 00000000..ac827f0c --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch @@ -0,0 +1,15 @@ +diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt +index 8cde1ffe0..d4d09f223 100644 +--- a/tools/CMakeLists.txt ++++ b/tools/CMakeLists.txt +@@ -91,7 +91,9 @@ endif() + add_executable(dbus-launch ${dbus_launch_SOURCES}) + target_link_libraries(dbus-launch ${DBUS_LIBRARIES}) + if(DBUS_BUILD_X11) +- target_link_libraries(dbus-launch ${X11_LIBRARIES} ) ++ find_package(Threads REQUIRED) ++ target_link_libraries(dbus-launch ${X11_LIBRARIES} ${X11_xcb_LIB} ${X11_Xau_LIB} ${X11_Xdmcp_LIB} Threads::Threads) ++ target_include_directories(dbus-launch PRIVATE ${X11_INCLUDE_DIR}) + endif() + install(TARGETS dbus-launch ${INSTALL_TARGETS_DEFAULT_ARGS}) + diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch new file mode 100644 index 00000000..5cd2309e --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch @@ -0,0 +1,26 @@ +diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake +index b7f3702..e2336ba 100644 +--- a/cmake/ConfigureChecks.cmake ++++ b/cmake/ConfigureChecks.cmake +@@ -51,6 +51,7 @@ check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM) # + check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON) + check_symbol_exists(fstatfs "sys/vfs.h" HAVE_FSTATFS) + check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c ++check_symbol_exists(getpeereid "sys/types.h;unistd.h" HAVE_GETPEEREID) # dbus-sysdeps.c, + check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c + check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_GETPWNAM_R) # dbus-sysdeps-util-unix.c + check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM) +diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake +index 77fc19c..2f25643 100644 +--- a/cmake/config.h.cmake ++++ b/cmake/config.h.cmake +@@ -140,6 +140,9 @@ + /* Define to 1 if you have getgrouplist */ + #cmakedefine HAVE_GETGROUPLIST 1 + ++/* Define to 1 if you have getpeereid */ ++#cmakedefine HAVE_GETPEEREID 1 ++ + /* Define to 1 if you have getpeerucred */ + #cmakedefine HAVE_GETPEERUCRED 1 + diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch new file mode 100644 index 00000000..74193dc4 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d3ec71b..932066a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -141,6 +141,10 @@ if(DBUS_LINUX) + if(ENABLE_SYSTEMD AND SYSTEMD_FOUND) + set(DBUS_BUS_ENABLE_SYSTEMD ON) + set(HAVE_SYSTEMD ${SYSTEMD_FOUND}) ++ pkg_check_modules(SYSTEMD libsystemd IMPORTED_TARGET) ++ set(SYSTEMD_LIBRARIES PkgConfig::SYSTEMD CACHE INTERNAL "") ++ else() ++ set(SYSTEMD_LIBRARIES "" CACHE INTERNAL "") + endif() + option(ENABLE_USER_SESSION "enable user-session semantics for session bus under systemd" OFF) + set(DBUS_ENABLE_USER_SESSION ${ENABLE_USER_SESSION}) diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch new file mode 100644 index 00000000..63581487 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch @@ -0,0 +1,21 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index caef738..b878f42 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -724,11 +724,11 @@ add_custom_target(help-options + # + if(DBUS_ENABLE_PKGCONFIG) + set(PLATFORM_LIBS pthread ${LIBRT}) +- if(PKG_CONFIG_FOUND) +- # convert lists of link libraries into -lstdc++ -lm etc.. +- foreach(LIB ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS}) +- set(LIBDBUS_LIBS "${LIBDBUS_LIBS} -l${LIB}") +- endforeach() ++ if(1) ++ set(LIBDBUS_LIBS "${CMAKE_THREAD_LIBS_INIT}") ++ if(LIBRT) ++ string(APPEND LIBDBUS_LIBS " -lrt") ++ endif() + set(original_prefix "${CMAKE_INSTALL_PREFIX}") + if(DBUS_RELOCATABLE) + set(pkgconfig_prefix "\${pcfiledir}/../..") diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake new file mode 100644 index 00000000..56c7e182 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake @@ -0,0 +1,88 @@ +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) + +vcpkg_from_gitlab( + GITLAB_URL https://gitlab.freedesktop.org/ + OUT_SOURCE_PATH SOURCE_PATH + REPO dbus/dbus + REF "dbus-${VERSION}" + SHA512 8e476b408514e6540c36beb84e8025827c22cda8958b6eb74d22b99c64765eb3cd5a6502aea546e3e5f0534039857b37edee89c659acef40e7cab0939947d4af + HEAD_REF master + PATCHES + cmake.dep.patch + pkgconfig.patch + getpeereid.patch # missing check from configure.ac + libsystemd.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS options + FEATURES + systemd ENABLE_SYSTEMD + x11 DBUS_BUILD_X11 + x11 CMAKE_REQUIRE_FIND_PACKAGE_X11 +) + +unset(ENV{DBUSDIR}) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DDBUS_BUILD_TESTS=OFF + -DDBUS_ENABLE_DOXYGEN_DOCS=OFF + -DDBUS_ENABLE_XML_DOCS=OFF + -DDBUS_INSTALL_SYSTEM_LIBS=OFF + #-DDBUS_SERVICE=ON + -DDBUS_WITH_GLIB=OFF + -DTHREADS_PREFER_PTHREAD_FLAG=ON + -DXSLTPROC_EXECUTABLE=FALSE + "-DCMAKE_INSTALL_SYSCONFDIR=${CURRENT_PACKAGES_DIR}/etc/${PORT}" + "-DWITH_SYSTEMD_SYSTEMUNITDIR=lib/systemd/system" + "-DWITH_SYSTEMD_USERUNITDIR=lib/systemd/user" + ${options} + OPTIONS_RELEASE + -DDBUS_DISABLE_ASSERT=OFF + -DDBUS_ENABLE_STATS=OFF + -DDBUS_ENABLE_VERBOSE_MODE=OFF + MAYBE_UNUSED_VARIABLES + DBUS_BUILD_X11 + DBUS_WITH_GLIB + ENABLE_SYSTEMD + THREADS_PREFER_PTHREAD_FLAG + WITH_SYSTEMD_SYSTEMUNITDIR + WITH_SYSTEMD_USERUNITDIR +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(PACKAGE_NAME "DBus1" CONFIG_PATH "lib/cmake/DBus1") +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/debug/var/" + "${CURRENT_PACKAGES_DIR}/etc" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/services" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/session.d" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/system-services" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.d" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.conf" + "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.conf" + "${CURRENT_PACKAGES_DIR}/share/doc" + "${CURRENT_PACKAGES_DIR}/var" +) + +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<include ignore_missing=\"yes\">${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session.conf</include>" "") +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<includedir>${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session.d</includedir>" "") +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<include ignore_missing=\"yes\">${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session-local.conf</include>" "") + +set(TOOLS daemon launch monitor run-session send test-tool update-activation-environment) +if(VCPKG_TARGET_IS_WINDOWS) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") + file(RENAME "${CURRENT_PACKAGES_DIR}/bin/dbus-env.bat" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/dbus-env.bat") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/${PORT}/dbus-env.bat" "${CURRENT_PACKAGES_DIR}" "%~dp0/../..") +else() + list(APPEND TOOLS cleanup-sockets uuidgen) +endif() +list(TRANSFORM TOOLS PREPEND "dbus-" ) +vcpkg_copy_tools(TOOL_NAMES ${TOOLS} AUTO_CLEAN) + +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json new file mode 100644 index 00000000..853dff05 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json @@ -0,0 +1,30 @@ +{ + "name": "dbus", + "version": "1.15.8", + "port-version": 2, + "description": "D-Bus specification and reference implementation, including libdbus and dbus-daemon", + "homepage": "https://gitlab.freedesktop.org/dbus/dbus", + "license": "AFL-2.1 OR GPL-2.0-or-later", + "supports": "!uwp & !staticcrt", + "dependencies": [ + "expat", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + ], + "features": { + "x11": { + "description": "Build with X11 autolaunch support", + "dependencies": [ + "libx11" + ] + } + } +} From 075eac626b162dd2e23ae337860f4717bf3041fe Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:13:19 +0200 Subject: [PATCH 134/314] ELF: Fix crash due to not allocating recompiler ranges (#1154) --- src/Cafe/OS/RPL/elf.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Cafe/OS/RPL/elf.cpp b/src/Cafe/OS/RPL/elf.cpp index c61afb21..7ee3ba47 100644 --- a/src/Cafe/OS/RPL/elf.cpp +++ b/src/Cafe/OS/RPL/elf.cpp @@ -50,6 +50,10 @@ typedef struct static_assert(sizeof(elfSectionEntry_t) == 0x28, ""); +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ + // Map elf into memory uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) { @@ -68,6 +72,7 @@ uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) uint32 shSize = (uint32)sectionTable[i].shSize; uint32 shOffset = (uint32)sectionTable[i].shOffset; uint32 shType = (uint32)sectionTable[i].shType; + uint32 shFlags = (uint32)sectionTable[i].shFlags; if (shOffset > (uint32)size) { @@ -89,6 +94,8 @@ uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name) } // SHT_NOBITS } + if((shFlags & PF_X) > 0) + PPCRecompiler_allocateRange(shAddr, shSize); } return header->entrypoint; } From fde7230191a07c40b6811eb3275b5e9c68af6cd3 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 6 Apr 2024 14:25:13 +0200 Subject: [PATCH 135/314] vcpkg/windows/mac: Avoid dependency on liblzma via tiff --- .../vcpkg_overlay_ports/tiff/FindCMath.patch | 13 +++ .../vcpkg_overlay_ports/tiff/portfile.cmake | 86 +++++++++++++++ dependencies/vcpkg_overlay_ports/tiff/usage | 9 ++ .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ++++++++++++++++++ .../vcpkg_overlay_ports/tiff/vcpkg.json | 67 +++++++++++ .../tiff/FindCMath.patch | 13 +++ .../tiff/portfile.cmake | 86 +++++++++++++++ .../vcpkg_overlay_ports_mac/tiff/usage | 9 ++ .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ++++++++++++++++++ .../vcpkg_overlay_ports_mac/tiff/vcpkg.json | 67 +++++++++++ 10 files changed, 558 insertions(+) create mode 100644 dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch create mode 100644 dependencies/vcpkg_overlay_ports/tiff/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports/tiff/usage create mode 100644 dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in create mode 100644 dependencies/vcpkg_overlay_ports/tiff/vcpkg.json create mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch create mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake create mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/usage create mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in create mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json diff --git a/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch new file mode 100644 index 00000000..70654cf8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake +index ad92218..dd42aba 100644 +--- a/cmake/FindCMath.cmake ++++ b/cmake/FindCMath.cmake +@@ -31,7 +31,7 @@ include(CheckSymbolExists) + include(CheckLibraryExists) + + check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) +-find_library(CMath_LIBRARY NAMES m) ++find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + + if(NOT CMath_HAVE_LIBC_POW) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake new file mode 100644 index 00000000..426d8af7 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake @@ -0,0 +1,86 @@ +vcpkg_from_gitlab( + GITLAB_URL https://gitlab.com + OUT_SOURCE_PATH SOURCE_PATH + REPO libtiff/libtiff + REF "v${VERSION}" + SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa + HEAD_REF master + PATCHES + FindCMath.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + cxx cxx + jpeg jpeg + jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG + libdeflate libdeflate + libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate + lzma lzma + lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma + tools tiff-tools + webp webp + webp CMAKE_REQUIRE_FIND_PACKAGE_WebP + zip zlib + zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB + zstd zstd + zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON + -Dtiff-docs=OFF + -Dtiff-contrib=OFF + -Dtiff-tests=OFF + -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. + -Djpeg12=OFF + -Dlerc=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON + -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON + -DZSTD_HAVE_DECOMPRESS_STREAM=ON + -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF + OPTIONS_DEBUG + -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. + MAYBE_UNUSED_VARIABLES + CMAKE_DISABLE_FIND_PACKAGE_GLUT + CMAKE_DISABLE_FIND_PACKAGE_OpenGL + ZSTD_HAVE_DECOMPRESS_STREAM +) + +vcpkg_cmake_install() + +# CMake config wasn't packaged in the past and is not yet usable now, +# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 +# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") + +set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") +if(EXISTS "${_file}") + vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") +endif() +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) + +if ("tools" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES + tiffcp + tiffdump + tiffinfo + tiffset + tiffsplit + AUTO_CLEAN + ) +endif() + +vcpkg_copy_pdbs() +file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports/tiff/usage b/dependencies/vcpkg_overlay_ports/tiff/usage new file mode 100644 index 00000000..d47265b1 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/tiff/usage @@ -0,0 +1,9 @@ +tiff is compatible with built-in CMake targets: + + find_package(TIFF REQUIRED) + target_link_libraries(main PRIVATE TIFF::TIFF) + +tiff provides pkg-config modules: + + # Tag Image File Format (TIFF) library. + libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000..1d04ec7a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,104 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0057 NEW) +set(z_vcpkg_tiff_find_options "") +if("REQUIRED" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "REQUIRED") +endif() +if("QUIET" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "QUIET") +endif() + +_find_package(${ARGS}) + +if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + include(SelectLibraryConfigurations) + set(z_vcpkg_tiff_link_libraries "") + set(z_vcpkg_tiff_libraries "") + if("@webp@") + find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") + list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) + endif() + if("@lzma@") + find_package(LibLZMA ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") + list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) + endif() + if("@jpeg@") + find_package(JPEG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") + list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) + endif() + if("@zstd@") + find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") + if(TARGET zstd::libzstd_shared) + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) + if(WIN32) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) + endif() + get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) + get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(ZSTD) + if(NOT TARGET ZSTD::ZSTD) + add_library(ZSTD::ZSTD INTERFACE IMPORTED) + set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) + endif() + list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) + list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) + unset(z_vcpkg_tiff_zstd) + unset(z_vcpkg_tiff_zstd_configs) + unset(z_vcpkg_config) + unset(z_vcpkg_tiff_zstd_target) + endif() + if("@libdeflate@") + find_package(libdeflate ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_property "IMPORTED_LOCATION_") + if(TARGET libdeflate::libdeflate_shared) + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) + if(WIN32) + set(z_vcpkg_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) + endif() + get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) + get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(Z_VCPKG_DEFLATE) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") + list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) + unset(z_vcpkg_config) + unset(z_vcpkg_libdeflate_configs) + unset(z_vcpkg_libdeflate_target) + unset(z_vcpkg_property) + unset(Z_VCPKG_DEFLATE_FOUND) + endif() + if("@zlib@") + find_package(ZLIB ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") + list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) + endif() + if(UNIX) + list(APPEND z_vcpkg_tiff_link_libraries m) + list(APPEND z_vcpkg_tiff_libraries m) + endif() + + if(TARGET TIFF::TIFF) + set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) + endif() + list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) + unset(z_vcpkg_tiff_link_libraries) + unset(z_vcpkg_tiff_libraries) +endif() +unset(z_vcpkg_tiff_find_options) +cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json new file mode 100644 index 00000000..9b36e1a8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json @@ -0,0 +1,67 @@ +{ + "name": "tiff", + "version": "4.6.0", + "port-version": 2, + "description": "A library that supports the manipulation of TIFF image files", + "homepage": "https://libtiff.gitlab.io/libtiff/", + "license": "libtiff", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "jpeg", + "zip" + ], + "features": { + "cxx": { + "description": "Build C++ libtiffxx library" + }, + "jpeg": { + "description": "Support JPEG compression in TIFF image files", + "dependencies": [ + "libjpeg-turbo" + ] + }, + "libdeflate": { + "description": "Use libdeflate for faster ZIP support", + "dependencies": [ + "libdeflate", + { + "name": "tiff", + "default-features": false, + "features": [ + "zip" + ] + } + ] + }, + "tools": { + "description": "Build tools" + }, + "webp": { + "description": "Support WEBP compression in TIFF image files", + "dependencies": [ + "libwebp" + ] + }, + "zip": { + "description": "Support ZIP/deflate compression in TIFF image files", + "dependencies": [ + "zlib" + ] + }, + "zstd": { + "description": "Support ZSTD compression in TIFF image files", + "dependencies": [ + "zstd" + ] + } + } +} diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch new file mode 100644 index 00000000..70654cf8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake +index ad92218..dd42aba 100644 +--- a/cmake/FindCMath.cmake ++++ b/cmake/FindCMath.cmake +@@ -31,7 +31,7 @@ include(CheckSymbolExists) + include(CheckLibraryExists) + + check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) +-find_library(CMath_LIBRARY NAMES m) ++find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + + if(NOT CMath_HAVE_LIBC_POW) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake new file mode 100644 index 00000000..426d8af7 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake @@ -0,0 +1,86 @@ +vcpkg_from_gitlab( + GITLAB_URL https://gitlab.com + OUT_SOURCE_PATH SOURCE_PATH + REPO libtiff/libtiff + REF "v${VERSION}" + SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa + HEAD_REF master + PATCHES + FindCMath.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + cxx cxx + jpeg jpeg + jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG + libdeflate libdeflate + libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate + lzma lzma + lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma + tools tiff-tools + webp webp + webp CMAKE_REQUIRE_FIND_PACKAGE_WebP + zip zlib + zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB + zstd zstd + zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON + -Dtiff-docs=OFF + -Dtiff-contrib=OFF + -Dtiff-tests=OFF + -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. + -Djpeg12=OFF + -Dlerc=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON + -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON + -DZSTD_HAVE_DECOMPRESS_STREAM=ON + -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF + OPTIONS_DEBUG + -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. + MAYBE_UNUSED_VARIABLES + CMAKE_DISABLE_FIND_PACKAGE_GLUT + CMAKE_DISABLE_FIND_PACKAGE_OpenGL + ZSTD_HAVE_DECOMPRESS_STREAM +) + +vcpkg_cmake_install() + +# CMake config wasn't packaged in the past and is not yet usable now, +# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 +# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") + +set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") +if(EXISTS "${_file}") + vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") +endif() +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) + +if ("tools" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES + tiffcp + tiffdump + tiffinfo + tiffset + tiffsplit + AUTO_CLEAN + ) +endif() + +vcpkg_copy_pdbs() +file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/usage b/dependencies/vcpkg_overlay_ports_mac/tiff/usage new file mode 100644 index 00000000..d47265b1 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/tiff/usage @@ -0,0 +1,9 @@ +tiff is compatible with built-in CMake targets: + + find_package(TIFF REQUIRED) + target_link_libraries(main PRIVATE TIFF::TIFF) + +tiff provides pkg-config modules: + + # Tag Image File Format (TIFF) library. + libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000..1d04ec7a --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,104 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0057 NEW) +set(z_vcpkg_tiff_find_options "") +if("REQUIRED" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "REQUIRED") +endif() +if("QUIET" IN_LIST ARGS) + list(APPEND z_vcpkg_tiff_find_options "QUIET") +endif() + +_find_package(${ARGS}) + +if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + include(SelectLibraryConfigurations) + set(z_vcpkg_tiff_link_libraries "") + set(z_vcpkg_tiff_libraries "") + if("@webp@") + find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") + list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) + endif() + if("@lzma@") + find_package(LibLZMA ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") + list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) + endif() + if("@jpeg@") + find_package(JPEG ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") + list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) + endif() + if("@zstd@") + find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") + if(TARGET zstd::libzstd_shared) + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) + if(WIN32) + set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") + set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) + endif() + get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) + get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(ZSTD) + if(NOT TARGET ZSTD::ZSTD) + add_library(ZSTD::ZSTD INTERFACE IMPORTED) + set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) + endif() + list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) + list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) + unset(z_vcpkg_tiff_zstd) + unset(z_vcpkg_tiff_zstd_configs) + unset(z_vcpkg_config) + unset(z_vcpkg_tiff_zstd_target) + endif() + if("@libdeflate@") + find_package(libdeflate ${z_vcpkg_tiff_find_options}) + set(z_vcpkg_property "IMPORTED_LOCATION_") + if(TARGET libdeflate::libdeflate_shared) + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) + if(WIN32) + set(z_vcpkg_property "IMPORTED_IMPLIB_") + endif() + else() + set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) + endif() + get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) + get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(Z_VCPKG_DEFLATE) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") + list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) + unset(z_vcpkg_config) + unset(z_vcpkg_libdeflate_configs) + unset(z_vcpkg_libdeflate_target) + unset(z_vcpkg_property) + unset(Z_VCPKG_DEFLATE_FOUND) + endif() + if("@zlib@") + find_package(ZLIB ${z_vcpkg_tiff_find_options}) + list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") + list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) + endif() + if(UNIX) + list(APPEND z_vcpkg_tiff_link_libraries m) + list(APPEND z_vcpkg_tiff_libraries m) + endif() + + if(TARGET TIFF::TIFF) + set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) + endif() + list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) + unset(z_vcpkg_tiff_link_libraries) + unset(z_vcpkg_tiff_libraries) +endif() +unset(z_vcpkg_tiff_find_options) +cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json new file mode 100644 index 00000000..9b36e1a8 --- /dev/null +++ b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json @@ -0,0 +1,67 @@ +{ + "name": "tiff", + "version": "4.6.0", + "port-version": 2, + "description": "A library that supports the manipulation of TIFF image files", + "homepage": "https://libtiff.gitlab.io/libtiff/", + "license": "libtiff", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "jpeg", + "zip" + ], + "features": { + "cxx": { + "description": "Build C++ libtiffxx library" + }, + "jpeg": { + "description": "Support JPEG compression in TIFF image files", + "dependencies": [ + "libjpeg-turbo" + ] + }, + "libdeflate": { + "description": "Use libdeflate for faster ZIP support", + "dependencies": [ + "libdeflate", + { + "name": "tiff", + "default-features": false, + "features": [ + "zip" + ] + } + ] + }, + "tools": { + "description": "Build tools" + }, + "webp": { + "description": "Support WEBP compression in TIFF image files", + "dependencies": [ + "libwebp" + ] + }, + "zip": { + "description": "Support ZIP/deflate compression in TIFF image files", + "dependencies": [ + "zlib" + ] + }, + "zstd": { + "description": "Support ZSTD compression in TIFF image files", + "dependencies": [ + "zstd" + ] + } + } +} From 74e8d205b07247b851c716ad285d938f4bc277b5 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:18:30 +0200 Subject: [PATCH 136/314] coreinit: Handle SD mounting permission in FSGetMountSource One Piece requires this to not get stuck in an infinite loop on boot. This also sets up initial infrastructure for handling cos.xml permissions --- src/Cafe/CafeSystem.cpp | 21 +++++ src/Cafe/CafeSystem.h | 4 + src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 10 +++ src/Cafe/TitleList/TitleInfo.cpp | 43 +++++++-- src/Cafe/TitleList/TitleInfo.h | 101 ++++++++++++++++++---- 5 files changed, 157 insertions(+), 22 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 75cb1116..bde1611c 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -914,6 +914,27 @@ namespace CafeSystem return sGameInfo_ForegroundTitle.GetBase().GetArgStr(); } + CosCapabilityBits GetForegroundTitleCosCapabilities(CosCapabilityGroup group) + { + if (sLaunchModeIsStandalone) + return CosCapabilityBits::All; + auto& update = sGameInfo_ForegroundTitle.GetUpdate(); + if (update.IsValid()) + { + ParsedCosXml* cosXml = update.GetCosInfo(); + if (cosXml) + return cosXml->GetCapabilityBits(group); + } + auto& base = sGameInfo_ForegroundTitle.GetBase(); + if(base.IsValid()) + { + ParsedCosXml* cosXml = base.GetCosInfo(); + if (cosXml) + return cosXml->GetCapabilityBits(group); + } + return CosCapabilityBits::All; + } + // when switching titles custom parameters can be passed, returns true if override args are used bool GetOverrideArgStr(std::vector<std::string>& args) { diff --git a/src/Cafe/CafeSystem.h b/src/Cafe/CafeSystem.h index 336c2f40..c4043a59 100644 --- a/src/Cafe/CafeSystem.h +++ b/src/Cafe/CafeSystem.h @@ -4,6 +4,9 @@ #include "Cafe/TitleList/TitleId.h" #include "config/CemuConfig.h" +enum class CosCapabilityBits : uint64; +enum class CosCapabilityGroup : uint32; + namespace CafeSystem { class SystemImplementation @@ -41,6 +44,7 @@ namespace CafeSystem std::string GetForegroundTitleName(); std::string GetForegroundTitleArgStr(); uint32 GetForegroundTitleOlvAccesskey(); + CosCapabilityBits GetForegroundTitleCosCapabilities(CosCapabilityGroup group); void ShutdownTitle(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index 1e6eb92b..a007f5ee 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -11,6 +11,8 @@ #include "coreinit_IPC.h" #include "Cafe/Filesystem/fsc.h" #include "coreinit_IPCBuf.h" +#include "Cafe/CafeSystem.h" +#include "Cafe/TitleList/TitleInfo.h" #define FS_CB_PLACEHOLDER_FINISHCMD (MPTR)(0xF122330E) @@ -94,6 +96,14 @@ namespace coreinit // so we can just hard code it. Other mount types are not (yet) supported. if (mountSourceType == MOUNT_TYPE::SD) { + // check for SD card permissions (from cos.xml) + // One Piece relies on failing here, otherwise it will call FSGetMountSource in an infinite loop + CosCapabilityBitsFS perms = static_cast<CosCapabilityBitsFS>(CafeSystem::GetForegroundTitleCosCapabilities(CosCapabilityGroup::FS)); + if(!HAS_FLAG(perms, CosCapabilityBitsFS::SDCARD_MOUNT)) + { + cemuLog_logOnce(LogType::Force, "Title is trying to access SD card mount info without having SD card permissions. This may not be a bug"); + return FS_RESULT::END_ITERATION; + } mountSourceInfo->sourceType = 0; strcpy(mountSourceInfo->path, "/sd"); return FS_RESULT::SUCCESS; diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index d23e1d0a..6d21929e 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -1,13 +1,11 @@ #include "TitleInfo.h" - #include "Cafe/Filesystem/fscDeviceHostFS.h" #include "Cafe/Filesystem/FST/FST.h" - #include "pugixml.hpp" #include "Common/FileStream.h" - #include <zarchive/zarchivereader.h> #include "config/ActiveSettings.h" +#include "util/helpers/helpers.h" // detect format by reading file header/footer CafeTitleFileType DetermineCafeSystemFileType(fs::path filePath) @@ -709,10 +707,41 @@ std::string TitleInfo::GetInstallPath() const { TitleId titleId = GetAppTitleId(); TitleIdParser tip(titleId); - std::string tmp; + std::string tmp; if (tip.IsSystemTitle()) - tmp = fmt::format("sys/title/{:08x}/{:08x}", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); - else - tmp = fmt::format("usr/title/{:08x}/{:08x}", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); + tmp = fmt::format("sys/title/{:08x}/{:08x}", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); + else + tmp = fmt::format("usr/title/{:08x}/{:08x}", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); return tmp; } + +ParsedCosXml* ParsedCosXml::Parse(uint8* xmlData, size_t xmlLen) +{ + pugi::xml_document app_doc; + if (!app_doc.load_buffer_inplace(xmlData, xmlLen)) + return nullptr; + + const auto root = app_doc.child("app"); + if (!root) + return nullptr; + + ParsedCosXml* parsedCos = new ParsedCosXml(); + + auto node = root.child("argstr"); + if (node) + parsedCos->argstr = node.text().as_string(); + + // parse permissions + auto permissionsNode = root.child("permissions"); + for(uint32 permissionIndex = 0; permissionIndex < 19; ++permissionIndex) + { + std::string permissionName = fmt::format("p{}", permissionIndex); + auto permissionNode = permissionsNode.child(permissionName.c_str()); + if (!permissionNode) + break; + parsedCos->permissions[permissionIndex].group = static_cast<CosCapabilityGroup>(ConvertString<uint32>(permissionNode.child("group").text().as_string(), 10)); + parsedCos->permissions[permissionIndex].mask = static_cast<CosCapabilityBits>(ConvertString<uint64>(permissionNode.child("mask").text().as_string(), 16)); + } + + return parsedCos; +} \ No newline at end of file diff --git a/src/Cafe/TitleList/TitleInfo.h b/src/Cafe/TitleList/TitleInfo.h index eca6624d..e9347db7 100644 --- a/src/Cafe/TitleList/TitleInfo.h +++ b/src/Cafe/TitleList/TitleInfo.h @@ -26,29 +26,95 @@ struct ParsedAppXml uint32 sdk_version; }; +enum class CosCapabilityGroup : uint32 +{ + None = 0, + BSP = 1, + DK = 3, + USB = 9, + UHS = 12, + FS = 11, + MCP = 13, + NIM = 14, + ACT = 15, + FPD = 16, + BOSS = 17, + ACP = 18, + PDM = 19, + AC = 20, + NDM = 21, + NSEC = 22 +}; + +enum class CosCapabilityBits : uint64 +{ + All = 0xFFFFFFFFFFFFFFFFull +}; + +enum class CosCapabilityBitsFS : uint64 +{ + ODD_READ = (1llu << 0), + ODD_WRITE = (1llu << 1), + ODD_RAW_OPEN = (1llu << 2), + ODD_MOUNT = (1llu << 3), + SLCCMPT_READ = (1llu << 4), + SLCCMPT_WRITE = (1llu << 5), + SLCCMPT_RAW_OPEN = (1llu << 6), + SLCCMPT_MOUNT = (1llu << 7), + SLC_READ = (1llu << 8), + SLC_WRITE = (1llu << 9), + SLC_RAW_OPEN = (1llu << 10), + SLC_MOUNT = (1llu << 11), + MLC_READ = (1llu << 12), + MLC_WRITE = (1llu << 13), + MLC_RAW_OPEN = (1llu << 14), + MLC_MOUNT = (1llu << 15), + SDCARD_READ = (1llu << 16), + SDCARD_WRITE = (1llu << 17), + SDCARD_RAW_OPEN = (1llu << 18), + SDCARD_MOUNT = (1llu << 19), + HFIO_READ = (1llu << 20), + HFIO_WRITE = (1llu << 21), + HFIO_RAW_OPEN = (1llu << 22), + HFIO_MOUNT = (1llu << 23), + RAMDISK_READ = (1llu << 24), + RAMDISK_WRITE = (1llu << 25), + RAMDISK_RAW_OPEN = (1llu << 26), + RAMDISK_MOUNT = (1llu << 27), + USB_READ = (1llu << 28), + USB_WRITE = (1llu << 29), + USB_RAW_OPEN = (1llu << 30), + USB_MOUNT = (1llu << 31), + OTHER_READ = (1llu << 32), + OTHER_WRITE = (1llu << 33), + OTHER_RAW_OPEN = (1llu << 34), + OTHER_MOUNT = (1llu << 35) +}; +ENABLE_BITMASK_OPERATORS(CosCapabilityBitsFS); + struct ParsedCosXml { + public: + std::string argstr; - static ParsedCosXml* Parse(uint8* xmlData, size_t xmlLen) + struct Permission { - pugi::xml_document app_doc; - if (!app_doc.load_buffer_inplace(xmlData, xmlLen)) - return nullptr; + CosCapabilityGroup group{CosCapabilityGroup::None}; + CosCapabilityBits mask{CosCapabilityBits::All}; + }; + Permission permissions[19]{}; - const auto root = app_doc.child("app"); - if (!root) - return nullptr; + static ParsedCosXml* Parse(uint8* xmlData, size_t xmlLen); - ParsedCosXml* parsedCos = new ParsedCosXml(); - - for (const auto& child : root.children()) + CosCapabilityBits GetCapabilityBits(CosCapabilityGroup group) const + { + for (const auto& perm : permissions) { - std::string_view name = child.name(); - if (name == "argstr") - parsedCos->argstr = child.text().as_string(); + if (perm.group == group) + return perm.mask; } - return parsedCos; + return CosCapabilityBits::All; } }; @@ -151,7 +217,7 @@ public: // cos.xml std::string GetArgStr() const; - // meta.xml also contains a version which seems to match the one from app.xml + // meta.xml also contains a version field which seems to match the one from app.xml // the titleId in meta.xml seems to be the title id of the base game for updates specifically. For AOC content it's the AOC's titleId TitleIdParser::TITLE_TYPE GetTitleType(); @@ -160,6 +226,11 @@ public: return m_parsedMetaXml; } + ParsedCosXml* GetCosInfo() + { + return m_parsedCosXml; + } + std::string GetPrintPath() const; // formatted path including type and WUA subpath. Intended for logging and user-facing information std::string GetInstallPath() const; // installation subpath, relative to storage base. E.g. "usr/title/.../..." or "sys/title/.../..." From efbf712305fe59081d90d566e0ec310ae68c969c Mon Sep 17 00:00:00 2001 From: Maschell <Maschell@gmx.de> Date: Mon, 8 Apr 2024 19:15:49 +0200 Subject: [PATCH 137/314] nn_sl: Stub GetDefaultWhiteListAccessor__Q2_2nn2slFv to avoid crash in Wii U Menu when an online account is used (#1159) --- src/Cafe/CMakeLists.txt | 2 + src/Cafe/OS/common/OSCommon.cpp | 2 + src/Cafe/OS/libs/nn_sl/nn_sl.cpp | 115 +++++++++++++++++++++++++++++++ src/Cafe/OS/libs/nn_sl/nn_sl.h | 1 + src/Cemu/Logging/CemuLogging.h | 1 + 5 files changed, 121 insertions(+) create mode 100644 src/Cafe/OS/libs/nn_sl/nn_sl.cpp create mode 100644 src/Cafe/OS/libs/nn_sl/nn_sl.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 20853789..d64a5998 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -404,6 +404,8 @@ add_library(CemuCafe OS/libs/nn_ndm/nn_ndm.h OS/libs/nn_spm/nn_spm.cpp OS/libs/nn_spm/nn_spm.h + OS/libs/nn_sl/nn_sl.cpp + OS/libs/nn_sl/nn_sl.h OS/libs/nn_nfp/AmiiboCrypto.h OS/libs/nn_nfp/nn_nfp.cpp OS/libs/nn_nfp/nn_nfp.h diff --git a/src/Cafe/OS/common/OSCommon.cpp b/src/Cafe/OS/common/OSCommon.cpp index 5aedd197..a4410028 100644 --- a/src/Cafe/OS/common/OSCommon.cpp +++ b/src/Cafe/OS/common/OSCommon.cpp @@ -13,6 +13,7 @@ #include "Cafe/OS/libs/nn_spm/nn_spm.h" #include "Cafe/OS/libs/nn_ec/nn_ec.h" #include "Cafe/OS/libs/nn_boss/nn_boss.h" +#include "Cafe/OS/libs/nn_sl/nn_sl.h" #include "Cafe/OS/libs/nn_fp/nn_fp.h" #include "Cafe/OS/libs/nn_olv/nn_olv.h" #include "Cafe/OS/libs/nn_idbe/nn_idbe.h" @@ -208,6 +209,7 @@ void osLib_load() nn::ndm::load(); nn::spm::load(); nn::save::load(); + nnSL_load(); nsysnet_load(); nn::fp::load(); nn::olv::load(); diff --git a/src/Cafe/OS/libs/nn_sl/nn_sl.cpp b/src/Cafe/OS/libs/nn_sl/nn_sl.cpp new file mode 100644 index 00000000..b25a91bc --- /dev/null +++ b/src/Cafe/OS/libs/nn_sl/nn_sl.cpp @@ -0,0 +1,115 @@ +#include "Cafe/OS/common/OSCommon.h" +#include "Cafe/OS/libs/coreinit/coreinit_IOS.h" +#include "Cafe/OS/libs/coreinit/coreinit_MEM.h" +#include "config/ActiveSettings.h" +#include "Cafe/CafeSystem.h" + +namespace nn +{ + typedef uint32 Result; + namespace sl + { + struct VTableEntry + { + uint16be offsetA{0}; + uint16be offsetB{0}; + MEMPTR<void> ptr; + }; + static_assert(sizeof(VTableEntry) == 8); + + constexpr uint32 SL_MEM_MAGIC = 0xCAFE4321; + +#define DTOR_WRAPPER(__TYPE) RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) { dtor(MEMPTR<__TYPE>(hCPU->gpr[3]), hCPU->gpr[4]); osLib_returnFromFunction(hCPU, 0); }) + + template<typename T> + MEMPTR<T> sl_new() + { + uint32 objSize = sizeof(T); + uint32be* basePtr = (uint32be*)coreinit::_weak_MEMAllocFromDefaultHeapEx(objSize + 8, 0x8); + basePtr[0] = SL_MEM_MAGIC; + basePtr[1] = objSize; + return (T*)(basePtr + 2); + } + + void sl_delete(MEMPTR<void> mem) + { + if (!mem) + return; + uint32be* basePtr = (uint32be*)mem.GetPtr() - 2; + if (basePtr[0] != SL_MEM_MAGIC) + { + cemuLog_log(LogType::Force, "nn_sl: Detected memory corruption"); + cemu_assert_suspicious(); + } + coreinit::_weak_MEMFreeToDefaultHeap(basePtr); + } + +#pragma pack(1) + struct WhiteList + { + uint32be titleTypes[50]; + uint32be titleTypesCount; + uint32be padding; + uint64be titleIds[50]; + uint32be titleIdCount; + }; + static_assert(sizeof(WhiteList) == 0x264); +#pragma pack() + + struct WhiteListAccessor + { + MEMPTR<void> vTablePtr{}; // 0x00 + + struct VTable + { + VTableEntry rtti; + VTableEntry dtor; + VTableEntry get; + }; + static inline SysAllocator<VTable> s_titleVTable; + + static WhiteListAccessor* ctor(WhiteListAccessor* _this) + { + if (!_this) + _this = sl_new<WhiteListAccessor>(); + *_this = {}; + _this->vTablePtr = s_titleVTable; + return _this; + } + + static void dtor(WhiteListAccessor* _this, uint32 options) + { + if (_this && (options & 1)) + sl_delete(_this); + } + + static void Get(WhiteListAccessor* _this, nn::sl::WhiteList* outWhiteList) + { + *outWhiteList = {}; + } + + static void InitVTable() + { + s_titleVTable->rtti.ptr = nullptr; // todo + s_titleVTable->dtor.ptr = DTOR_WRAPPER(WhiteListAccessor); + s_titleVTable->get.ptr = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) { Get(MEMPTR<WhiteListAccessor>(hCPU->gpr[3]), MEMPTR<WhiteList>(hCPU->gpr[4])); osLib_returnFromFunction(hCPU, 0); }); + } + }; + static_assert(sizeof(WhiteListAccessor) == 0x04); + + SysAllocator<WhiteListAccessor> s_defaultWhiteListAccessor; + + WhiteListAccessor* GetDefaultWhiteListAccessor() + { + return s_defaultWhiteListAccessor; + } + } // namespace sl +} // namespace nn + +void nnSL_load() +{ + nn::sl::WhiteListAccessor::InitVTable(); + nn::sl::WhiteListAccessor::ctor(nn::sl::s_defaultWhiteListAccessor); + + cafeExportRegisterFunc(nn::sl::GetDefaultWhiteListAccessor, "nn_sl", "GetDefaultWhiteListAccessor__Q2_2nn2slFv", LogType::NN_SL); +} diff --git a/src/Cafe/OS/libs/nn_sl/nn_sl.h b/src/Cafe/OS/libs/nn_sl/nn_sl.h new file mode 100644 index 00000000..08d936cb --- /dev/null +++ b/src/Cafe/OS/libs/nn_sl/nn_sl.h @@ -0,0 +1 @@ +void nnSL_load(); \ No newline at end of file diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index fe74a6bc..e789c2ea 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -36,6 +36,7 @@ enum class LogType : sint32 NN_NFP = 13, NN_FP = 24, NN_BOSS = 25, + NN_SL = 26, TextureReadback = 29, From 9b30be02585ac3419973c2cbef30a5300d768d09 Mon Sep 17 00:00:00 2001 From: Maschell <Maschell@gmx.de> Date: Mon, 8 Apr 2024 19:50:57 +0200 Subject: [PATCH 138/314] drmapp: Stub more functions to allow title loading from Wii U Menu (#1161) --- src/Cafe/OS/libs/drmapp/drmapp.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/drmapp/drmapp.cpp b/src/Cafe/OS/libs/drmapp/drmapp.cpp index e1969486..6c57b209 100644 --- a/src/Cafe/OS/libs/drmapp/drmapp.cpp +++ b/src/Cafe/OS/libs/drmapp/drmapp.cpp @@ -9,8 +9,29 @@ namespace drmapp return 1; } + uint32 PatchChkIsFinished() + { + cemuLog_logDebug(LogType::Force, "drmapp.PatchChkIsFinished() - placeholder"); + return 1; + } + + uint32 AocChkIsFinished() + { + cemuLog_logDebug(LogType::Force, "drmapp.AocChkIsFinished() - placeholder"); + return 1; + } + + uint32 TicketChkIsFinished() + { + cemuLog_logDebug(LogType::Force, "drmapp.TicketChkIsFinished__3RplFv() - placeholder"); + return 1; + } + void Initialize() { cafeExportRegisterFunc(NupChkIsFinished, "drmapp", "NupChkIsFinished__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(PatchChkIsFinished, "drmapp", "PatchChkIsFinished__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(AocChkIsFinished, "drmapp", "AocChkIsFinished__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(TicketChkIsFinished, "drmapp", "TicketChkIsFinished__3RplFv", LogType::Placeholder); } -} +} // namespace drmapp From 7b635e7eb87784a21014e8fcf0fdc420cf3a8c8d Mon Sep 17 00:00:00 2001 From: Maschell <Maschell@gmx.de> Date: Mon, 8 Apr 2024 19:51:30 +0200 Subject: [PATCH 139/314] nn_boss: Implement startIndex parameter usage in nn:boss:::GetDataList (#1162) --- src/Cafe/OS/libs/nn_boss/nn_boss.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Cafe/OS/libs/nn_boss/nn_boss.cpp b/src/Cafe/OS/libs/nn_boss/nn_boss.cpp index f53a6d79..2a05fa7a 100644 --- a/src/Cafe/OS/libs/nn_boss/nn_boss.cpp +++ b/src/Cafe/OS/libs/nn_boss/nn_boss.cpp @@ -9,7 +9,7 @@ #include "Cafe/CafeSystem.h" #include "Cafe/Filesystem/fsc.h" -namespace nn +namespace nn { typedef uint32 Result; namespace boss @@ -782,9 +782,9 @@ bossBufferVector->buffer = (uint8*)bossRequest; bossRequest->taskId = _thisptr->taskId.id; bossRequest->titleId = _thisptr->titleId.u64; bossRequest->bool_parameter = isForegroundRun != 0; - + __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - + return 0; } @@ -796,9 +796,9 @@ bossBufferVector->buffer = (uint8*)bossRequest; bossRequest->taskId = _thisptr->taskId.id; bossRequest->titleId = _thisptr->titleId.u64; bossRequest->bool_parameter = executeImmediately != 0; - + __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - + return 0; } @@ -809,9 +809,9 @@ bossBufferVector->buffer = (uint8*)bossRequest; bossRequest->accountId = _thisptr->accountId; bossRequest->taskId = _thisptr->taskId.id; bossRequest->titleId = _thisptr->titleId.u64; - + __depr__IOS_Ioctlv(IOS_DEVICE_BOSS, IOSU_BOSS_REQUEST_CEMU, 1, 1, bossBufferVector); - + return 0; } @@ -1001,7 +1001,7 @@ bossBufferVector->buffer = (uint8*)bossRequest; } }; static_assert(sizeof(PrivilegedTask) == 0x20); - + struct AlmightyTask : PrivilegedTask { struct VTableAlmightyTask : public VTablePrivilegedTask @@ -1169,14 +1169,17 @@ bossBufferVector->buffer = (uint8*)bossRequest; // initialize titleId of storage if not already done nnBossStorage_prepareTitleId(storage); - cemu_assert_debug(startIndex == 0); // non-zero index is todo + if(startIndex >= FAD_ENTRY_MAX_COUNT) { + *outputEntryCount = 0; + return 0; + } // load fad.db BossStorageFadEntry* fadTable = nnBossStorageFad_getTable(storage); if (fadTable) { sint32 validEntryCount = 0; - for (sint32 i = 0; i < FAD_ENTRY_MAX_COUNT; i++) + for (sint32 i = startIndex; i < FAD_ENTRY_MAX_COUNT; i++) { if( fadTable[i].name[0] == '\0' ) continue; @@ -1612,7 +1615,7 @@ bossBufferVector->buffer = (uint8*)bossRequest; }; static_assert(sizeof(NsData) == 0x58); -} +} } void nnBoss_load() { @@ -1663,7 +1666,7 @@ void nnBoss_load() cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::dtor, "nn_boss", "__dt__Q3_2nn4boss15NbdlTaskSettingFv", LogType::NN_BOSS); cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::Initialize, "nn_boss", "Initialize__Q3_2nn4boss15NbdlTaskSettingFPCcLT1", LogType::NN_BOSS); cafeExportRegisterFunc(nn::boss::NbdlTaskSetting::SetFileName, "nn_boss", "SetFileName__Q3_2nn4boss15NbdlTaskSettingFPCc", LogType::NN_BOSS); - + // PlayReportSetting nn::boss::PlayReportSetting::InitVTable(); cafeExportRegisterFunc(nn::boss::PlayReportSetting::ctor, "nn_boss", "__ct__Q3_2nn4boss17PlayReportSettingFv", LogType::NN_BOSS); From 33a74c203574090d563288ea05ffd28323e8c544 Mon Sep 17 00:00:00 2001 From: 47463915 <147349656+47463915@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:33:50 -0300 Subject: [PATCH 140/314] nn_nfp: Avoid current app from showing up as "???" for others in Friend List + View friends' status (#1157) --- src/Cafe/IOSU/legacy/iosu_fpd.cpp | 33 ++++++++++++++++++++++++++----- src/Cafe/IOSU/legacy/iosu_fpd.h | 4 ++-- src/Cemu/nex/nexFriends.cpp | 13 ++++++++++++ src/Cemu/nex/nexFriends.h | 4 ++-- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index 9130b28d..aca1a332 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -214,6 +214,12 @@ namespace iosu friendData->friendExtraData.gameKey.ukn08 = frd->presence.gameKey.ukn; NexPresenceToGameMode(&frd->presence, &friendData->friendExtraData.gameMode); + auto fixed_presence_msg = '\0' + frd->presence.msg; // avoid first character of comment from being cut off + friendData->friendExtraData.gameModeDescription.assignFromUTF8(fixed_presence_msg); + + auto fixed_comment = '\0' + frd->comment.commentString; // avoid first character of comment from being cut off + friendData->friendExtraData.comment.assignFromUTF8(fixed_comment); + // set valid dates friendData->uknDate.year = 2018; friendData->uknDate.day = 1; @@ -750,9 +756,18 @@ namespace iosu { if(numVecIn != 0 || numVecOut != 1) return FPResult_InvalidIPCParam; - SelfPlayingGame selfPlayingGame{0}; - cemuLog_log(LogType::Force, "GetMyPlayingGame is todo"); - return WriteValueOutput<SelfPlayingGame>(vecOut, selfPlayingGame); + GameKey selfPlayingGame + { + CafeSystem::GetForegroundTitleId(), + CafeSystem::GetForegroundTitleVersion(), + {0,0,0,0,0,0} + }; + if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) != 0x00050000) + { + selfPlayingGame.titleId = 0; + selfPlayingGame.ukn08 = 0; + } + return WriteValueOutput<GameKey>(vecOut, selfPlayingGame); } nnResult CallHandler_GetFriendAccountId(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) @@ -1410,8 +1425,16 @@ namespace iosu act::getCountryIndex(currentSlot, &countryCode); // init presence g_fpd.myPresence.isOnline = 1; - g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); - g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); + if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) == 0x00050000) + { + g_fpd.myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); + g_fpd.myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); + } + else + { + g_fpd.myPresence.gameKey.titleId = 0; // icon will not be ??? or invalid to others + g_fpd.myPresence.gameKey.ukn = 0; + } // resolve potential domain to IP address struct addrinfo hints = {0}, *addrs; hints.ai_family = AF_INET; diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.h b/src/Cafe/IOSU/legacy/iosu_fpd.h index 79f524d6..0a6f0885 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.h +++ b/src/Cafe/IOSU/legacy/iosu_fpd.h @@ -94,7 +94,7 @@ namespace iosu /* +0x1EC */ uint8 isOnline; /* +0x1ED */ uint8 _padding1ED[3]; // some other sub struct? - /* +0x1F0 */ char comment[36]; // pops up every few seconds in friend list + /* +0x1F0 */ CafeWideString<0x12> comment; // pops up every few seconds in friend list /* +0x214 */ uint32be _padding214; /* +0x218 */ FPDDate approvalTime; /* +0x220 */ FPDDate lastOnline; @@ -263,4 +263,4 @@ namespace iosu IOSUModule* GetModule(); } -} \ No newline at end of file +} diff --git a/src/Cemu/nex/nexFriends.cpp b/src/Cemu/nex/nexFriends.cpp index 4fae8143..ae87ce44 100644 --- a/src/Cemu/nex/nexFriends.cpp +++ b/src/Cemu/nex/nexFriends.cpp @@ -1,6 +1,7 @@ #include "prudp.h" #include "nex.h" #include "nexFriends.h" +#include "Cafe/CafeSystem.h" static const int NOTIFICATION_SRV_FRIEND_OFFLINE = 0x0A; // the opposite event (friend online) is notified via _PRESENCE_CHANGE static const int NOTIFICATION_SRV_FRIEND_PRESENCE_CHANGE = 0x18; @@ -912,6 +913,18 @@ void NexFriends::markFriendRequestsAsReceived(uint64* messageIdList, sint32 coun void NexFriends::updateMyPresence(nexPresenceV2& myPresence) { this->myPresence = myPresence; + + if (GetTitleIdHigh(CafeSystem::GetForegroundTitleId()) == 0x00050000) + { + myPresence.gameKey.titleId = CafeSystem::GetForegroundTitleId(); + myPresence.gameKey.ukn = CafeSystem::GetForegroundTitleVersion(); + } + else + { + myPresence.gameKey.titleId = 0; // icon will not be ??? or invalid to others + myPresence.gameKey.ukn = 0; + } + if (nexCon == nullptr || nexCon->getState() != nexService::STATE_CONNECTED) { // not connected diff --git a/src/Cemu/nex/nexFriends.h b/src/Cemu/nex/nexFriends.h index 06c75110..1077b0d5 100644 --- a/src/Cemu/nex/nexFriends.h +++ b/src/Cemu/nex/nexFriends.h @@ -431,7 +431,7 @@ public: { nnaInfo.readData(pb); presence.readData(pb); - gameModeMessage.readData(pb); + comment.readData(pb); friendsSinceTimestamp = pb->readU64(); lastOnlineTimestamp = pb->readU64(); ukn6 = pb->readU64(); @@ -439,7 +439,7 @@ public: public: nexNNAInfo nnaInfo; nexPresenceV2 presence; - nexComment gameModeMessage; + nexComment comment; uint64 friendsSinceTimestamp; uint64 lastOnlineTimestamp; uint64 ukn6; From 12eda103876287283442880908425f751d14fd37 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 10 Apr 2024 20:22:17 +0200 Subject: [PATCH 141/314] nn_acp: Implement ACPGetOlvAccesskey + code clean up Added ACPGetOlvAccesskey() which is used by Super Mario Maker iosu acp, nn_acp and nn_save all cross talk with each other and are mostly legacy code. Modernized it a tiny bit and moved functions to where they should be. A larger refactor should be done in the future but for now this works ok --- src/Cafe/CafeSystem.cpp | 1 + src/Cafe/IOSU/legacy/iosu_acp.cpp | 289 ++++++++++++++++++++++----- src/Cafe/IOSU/legacy/iosu_acp.h | 23 +++ src/Cafe/IOSU/legacy/iosu_act.cpp | 12 ++ src/Cafe/IOSU/legacy/iosu_act.h | 1 + src/Cafe/IOSU/nn/iosu_nn_service.h | 4 +- src/Cafe/OS/libs/nn_acp/nn_acp.cpp | 209 ++----------------- src/Cafe/OS/libs/nn_acp/nn_acp.h | 14 +- src/Cafe/OS/libs/nn_save/nn_save.cpp | 10 +- 9 files changed, 314 insertions(+), 249 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index bde1611c..3c62a686 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -530,6 +530,7 @@ namespace CafeSystem { // entries in this list are ordered by initialization order. Shutdown in reverse order iosu::kernel::GetModule(), + iosu::acp::GetModule(), iosu::fpd::GetModule(), iosu::pdm::GetModule(), }; diff --git a/src/Cafe/IOSU/legacy/iosu_acp.cpp b/src/Cafe/IOSU/legacy/iosu_acp.cpp index ef5f7083..f5144ee6 100644 --- a/src/Cafe/IOSU/legacy/iosu_acp.cpp +++ b/src/Cafe/IOSU/legacy/iosu_acp.cpp @@ -8,10 +8,19 @@ #include "Cafe/OS/libs/nn_acp/nn_acp.h" #include "Cafe/OS/libs/coreinit/coreinit_FS.h" #include "Cafe/Filesystem/fsc.h" -#include "Cafe/HW/Espresso/PPCState.h" +//#include "Cafe/HW/Espresso/PPCState.h" + +#include "Cafe/IOSU/iosu_types_common.h" +#include "Cafe/IOSU/nn/iosu_nn_service.h" + +#include "Cafe/IOSU/legacy/iosu_act.h" +#include "Cafe/CafeSystem.h" +#include "config/ActiveSettings.h" #include <inttypes.h> +using ACPDeviceType = iosu::acp::ACPDeviceType; + static_assert(sizeof(acpMetaXml_t) == 0x3440); static_assert(offsetof(acpMetaXml_t, title_id) == 0x0000); static_assert(offsetof(acpMetaXml_t, boss_id) == 0x0008); @@ -506,48 +515,6 @@ namespace iosu return 0; } - sint32 ACPCreateSaveDirEx(uint8 accountSlot, uint64 titleId) - { - uint32 persistentId = 0; - nn::save::GetPersistentIdEx(accountSlot, &persistentId); - - uint32 high = GetTitleIdHigh(titleId) & (~0xC); - uint32 low = GetTitleIdLow(titleId); - - sint32 fscStatus = FSC_STATUS_FILE_NOT_FOUND; - char path[256]; - - sprintf(path, "%susr/boss/", "/vol/storage_mlc01/"); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/", "/vol/storage_mlc01/", high); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/%08x/", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); - fsc_createDir(path, &fscStatus); - - sprintf(path, "%susr/save/%08x/", "/vol/storage_mlc01/", high); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/meta/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/%08x", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); - fsc_createDir(path, &fscStatus); - - // copy xml meta files - nn::acp::CreateSaveMetaFiles(persistentId, titleId); - return 0; - } - int iosuAcp_thread() { SetThreadName("iosuAcp_thread"); @@ -584,7 +551,7 @@ namespace iosu } else if (acpCemuRequest->requestCode == IOSU_ACP_CREATE_SAVE_DIR_EX) { - acpCemuRequest->returnCode = ACPCreateSaveDirEx(acpCemuRequest->accountSlot, acpCemuRequest->titleId); + acpCemuRequest->returnCode = acp::ACPCreateSaveDirEx(acpCemuRequest->accountSlot, acpCemuRequest->titleId); } else cemu_assert_unimplemented(); @@ -610,5 +577,237 @@ namespace iosu return iosuAcp.isInitialized; } + /* Above is the legacy implementation. Below is the new style implementation which also matches the official IPC protocol and works with the real nn_acp.rpl */ -} + namespace acp + { + + uint64 _ACPGetTimestamp() + { + return coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK; + } + + nnResult ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType) + { + if (deviceType == ACPDeviceType::UnknownType) + { + return (nnResult)0xA030FB80; + } + + // create or modify the saveinfo + const auto saveinfoPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/saveinfo.xml", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); + auto saveinfoData = FileStream::LoadIntoMemory(saveinfoPath); + if (saveinfoData && !saveinfoData->empty()) + { + namespace xml = tinyxml2; + xml::XMLDocument doc; + tinyxml2::XMLError xmlError = doc.Parse((const char*)saveinfoData->data(), saveinfoData->size()); + if (xmlError == xml::XML_SUCCESS || xmlError == xml::XML_ERROR_EMPTY_DOCUMENT) + { + xml::XMLNode* child = doc.FirstChild(); + // check for declaration -> <?xml version="1.0" encoding="utf-8"?> + if (!child || !child->ToDeclaration()) + { + xml::XMLDeclaration* decl = doc.NewDeclaration(); + doc.InsertFirstChild(decl); + } + + xml::XMLElement* info = doc.FirstChildElement("info"); + if (!info) + { + info = doc.NewElement("info"); + doc.InsertEndChild(info); + } + + // find node with persistentId + char tmp[64]; + sprintf(tmp, "%08x", persistentId); + bool foundNode = false; + for (xml::XMLElement* account = info->FirstChildElement("account"); account; account = account->NextSiblingElement("account")) + { + if (account->Attribute("persistentId", tmp)) + { + // found the entry! -> update timestamp + xml::XMLElement* timestamp = account->FirstChildElement("timestamp"); + sprintf(tmp, "%" PRIx64, _ACPGetTimestamp()); + if (timestamp) + timestamp->SetText(tmp); + else + { + timestamp = doc.NewElement("timestamp"); + account->InsertFirstChild(timestamp); + } + + foundNode = true; + break; + } + } + + if (!foundNode) + { + tinyxml2::XMLElement* account = doc.NewElement("account"); + { + sprintf(tmp, "%08x", persistentId); + account->SetAttribute("persistentId", tmp); + + tinyxml2::XMLElement* timestamp = doc.NewElement("timestamp"); + { + sprintf(tmp, "%" PRIx64, _ACPGetTimestamp()); + timestamp->SetText(tmp); + } + + account->InsertFirstChild(timestamp); + } + + info->InsertFirstChild(account); + } + + // update file + tinyxml2::XMLPrinter printer; + doc.Print(&printer); + FileStream* fs = FileStream::createFile2(saveinfoPath); + if (fs) + { + fs->writeString(printer.CStr()); + delete fs; + } + } + } + return NN_RESULT_SUCCESS; + } + + void CreateSaveMetaFiles(uint32 persistentId, uint64 titleId) + { + std::string titlePath = CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()); + + sint32 fscStatus; + FSCVirtualFile* fscFile = fsc_open((titlePath + "/meta/meta.xml").c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + if (fscFile) + { + sint32 fileSize = fsc_getFileSize(fscFile); + + std::unique_ptr<uint8[]> fileContent = std::make_unique<uint8[]>(fileSize); + fsc_readFile(fscFile, fileContent.get(), fileSize); + fsc_close(fscFile); + + const auto outPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/meta.xml", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); + + std::ofstream myFile(outPath, std::ios::out | std::ios::binary); + myFile.write((char*)fileContent.get(), fileSize); + myFile.close(); + } + + fscFile = fsc_open((titlePath + "/meta/iconTex.tga").c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + if (fscFile) + { + sint32 fileSize = fsc_getFileSize(fscFile); + + std::unique_ptr<uint8[]> fileContent = std::make_unique<uint8[]>(fileSize); + fsc_readFile(fscFile, fileContent.get(), fileSize); + fsc_close(fscFile); + + const auto outPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/iconTex.tga", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); + + std::ofstream myFile(outPath, std::ios::out | std::ios::binary); + myFile.write((char*)fileContent.get(), fileSize); + myFile.close(); + } + + ACPUpdateSaveTimeStamp(persistentId, titleId, iosu::acp::ACPDeviceType::InternalDeviceType); + } + + + sint32 _ACPCreateSaveDir(uint32 persistentId, uint64 titleId, ACPDeviceType type) + { + uint32 high = GetTitleIdHigh(titleId) & (~0xC); + uint32 low = GetTitleIdLow(titleId); + + sint32 fscStatus = FSC_STATUS_FILE_NOT_FOUND; + char path[256]; + + sprintf(path, "%susr/boss/", "/vol/storage_mlc01/"); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/boss/%08x/", "/vol/storage_mlc01/", high); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/boss/%08x/%08x/", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/boss/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/boss/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/boss/%08x/%08x/user/%08x/", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); + fsc_createDir(path, &fscStatus); + + sprintf(path, "%susr/save/%08x/", "/vol/storage_mlc01/", high); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/save/%08x/%08x/", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/save/%08x/%08x/meta/", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/save/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/save/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); + fsc_createDir(path, &fscStatus); + sprintf(path, "%susr/save/%08x/%08x/user/%08x", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); + fsc_createDir(path, &fscStatus); + + // copy xml meta files + CreateSaveMetaFiles(persistentId, titleId); + return 0; + } + + nnResult ACPCreateSaveDir(uint32 persistentId, ACPDeviceType type) + { + uint64 titleId = CafeSystem::GetForegroundTitleId(); + return _ACPCreateSaveDir(persistentId, titleId, type); + } + + sint32 ACPCreateSaveDirEx(uint8 accountSlot, uint64 titleId) + { + uint32 persistentId = 0; + cemu_assert_debug(accountSlot >= 1 && accountSlot <= 13); // outside valid slot range? + bool r = iosu::act::GetPersistentId(accountSlot, &persistentId); + cemu_assert_debug(r); + return _ACPCreateSaveDir(persistentId, titleId, ACPDeviceType::InternalDeviceType); + } + + nnResult ACPGetOlvAccesskey(uint32be* accessKey) + { + *accessKey = CafeSystem::GetForegroundTitleOlvAccesskey(); + return 0; + } + + class AcpMainService : public iosu::nn::IPCService + { + public: + AcpMainService() : iosu::nn::IPCService("/dev/acp_main") {} + + nnResult ServiceCall(uint32 serviceId, void* request, void* response) override + { + cemuLog_log(LogType::Force, "Unsupported service call to /dev/acp_main"); + cemu_assert_unimplemented(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACP, 0); + } + }; + + AcpMainService gACPMainService; + + class : public ::IOSUModule + { + void TitleStart() override + { + gACPMainService.Start(); + // gACPMainService.SetTimerUpdate(1000); // call TimerUpdate() once a second + } + void TitleStop() override + { + gACPMainService.Stop(); + } + }sIOSUModuleNNACP; + + IOSUModule* GetModule() + { + return static_cast<IOSUModule*>(&sIOSUModuleNNACP); + } + } // namespace acp +} // namespace iosu diff --git a/src/Cafe/IOSU/legacy/iosu_acp.h b/src/Cafe/IOSU/legacy/iosu_acp.h index 18197bd8..a6fb6bfd 100644 --- a/src/Cafe/IOSU/legacy/iosu_acp.h +++ b/src/Cafe/IOSU/legacy/iosu_acp.h @@ -1,5 +1,8 @@ #pragma once +#include "Cafe/IOSU/iosu_types_common.h" +#include "Cafe/OS/libs/nn_common.h" // for nnResult + typedef struct { /* +0x0000 */ uint64 title_id; // parsed via GetHex64 @@ -192,4 +195,24 @@ typedef struct namespace iosu { void iosuAcp_init(); + + namespace acp + { + enum ACPDeviceType + { + UnknownType = 0, + InternalDeviceType = 1, + USBDeviceType = 3, + }; + + class IOSUModule* GetModule(); + + void CreateSaveMetaFiles(uint32 persistentId, uint64 titleId); + nnResult ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType); + + nnResult ACPCreateSaveDir(uint32 persistentId, ACPDeviceType type); + sint32 ACPCreateSaveDirEx(uint8 accountSlot, uint64 titleId); + nnResult ACPGetOlvAccesskey(uint32be* accessKey); + } + } \ No newline at end of file diff --git a/src/Cafe/IOSU/legacy/iosu_act.cpp b/src/Cafe/IOSU/legacy/iosu_act.cpp index ed3a69bd..42856684 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.cpp +++ b/src/Cafe/IOSU/legacy/iosu_act.cpp @@ -240,6 +240,18 @@ namespace iosu return true; } + bool GetPersistentId(uint8 slot, uint32* persistentId) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if(!_actAccountData[accountIndex].isValid) + { + *persistentId = 0; + return false; + } + *persistentId = _actAccountData[accountIndex].persistentId; + return true; + } + class ActService : public iosu::nn::IPCService { public: diff --git a/src/Cafe/IOSU/legacy/iosu_act.h b/src/Cafe/IOSU/legacy/iosu_act.h index 5336f519..d60966d4 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.h +++ b/src/Cafe/IOSU/legacy/iosu_act.h @@ -49,6 +49,7 @@ namespace iosu bool getMii(uint8 slot, FFLData_t* fflData); bool getScreenname(uint8 slot, uint16 screenname[ACT_NICKNAME_LENGTH]); bool getCountryIndex(uint8 slot, uint32* countryIndex); + bool GetPersistentId(uint8 slot, uint32* persistentId); std::string getAccountId2(uint8 slot); diff --git a/src/Cafe/IOSU/nn/iosu_nn_service.h b/src/Cafe/IOSU/nn/iosu_nn_service.h index d50a0794..d7d4cb01 100644 --- a/src/Cafe/IOSU/nn/iosu_nn_service.h +++ b/src/Cafe/IOSU/nn/iosu_nn_service.h @@ -8,7 +8,7 @@ namespace iosu { namespace nn { - // a simple service interface which wraps handle management and Ioctlv/IoctlvAsync + // a simple service interface which wraps handle management and Ioctlv/IoctlvAsync (used by /dev/fpd and others are still to be determined) class IPCSimpleService { public: @@ -88,7 +88,7 @@ namespace iosu uint32be nnResultCode; }; - // a complex service interface which wraps Ioctlv and adds an additional service channel, used by /dev/act, ? + // a complex service interface which wraps Ioctlv and adds an additional service channel, used by /dev/act, /dev/acp_main, ? class IPCService { public: diff --git a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp index 516087a3..61640ae7 100644 --- a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp +++ b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp @@ -17,6 +17,8 @@ #include "Common/FileStream.h" #include "Cafe/CafeSystem.h" +using ACPDeviceType = iosu::acp::ACPDeviceType; + #define acpPrepareRequest() \ StackAllocator<iosuAcpCemuRequest_t> _buf_acpRequest; \ StackAllocator<ioBufferVector_t> _buf_bufferVector; \ @@ -30,12 +32,14 @@ namespace nn { namespace acp { - ACPStatus _ACPConvertResultToACPStatus(uint32* nnResult, const char* functionName, uint32 someConstant) + ACPStatus ACPConvertResultToACPStatus(uint32* nnResult, const char* functionName, uint32 lineNumber) { // todo return ACPStatus::SUCCESS; } + #define _ACPConvertResultToACPStatus(nnResult) ACPConvertResultToACPStatus(nnResult, __func__, __LINE__) + ACPStatus ACPGetApplicationBox(uint32be* applicationBox, uint64 titleId) { // todo @@ -43,6 +47,12 @@ namespace acp return ACPStatus::SUCCESS; } + ACPStatus ACPGetOlvAccesskey(uint32be* accessKey) + { + nnResult r = iosu::acp::ACPGetOlvAccesskey(accessKey); + return _ACPConvertResultToACPStatus(&r); + } + bool sSaveDirMounted{false}; ACPStatus ACPMountSaveDir() @@ -56,7 +66,7 @@ namespace acp const auto mlc = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/user/", high, low); FSCDeviceHostFS_Mount("/vol/save/", _pathToUtf8(mlc), FSC_PRIORITY_BASE); nnResult mountResult = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACP, 0); - return _ACPConvertResultToACPStatus(&mountResult, "ACPMountSaveDir", 0x60); + return _ACPConvertResultToACPStatus(&mountResult); } ACPStatus ACPUnmountSaveDir() @@ -66,201 +76,24 @@ namespace acp return ACPStatus::SUCCESS; } - uint64 _acpGetTimestamp() - { - return coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK; - } - - nnResult __ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType) - { - if (deviceType == UnknownType) - { - return (nnResult)0xA030FB80; - } - - // create or modify the saveinfo - const auto saveinfoPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/saveinfo.xml", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); - auto saveinfoData = FileStream::LoadIntoMemory(saveinfoPath); - if (saveinfoData && !saveinfoData->empty()) - { - namespace xml = tinyxml2; - xml::XMLDocument doc; - tinyxml2::XMLError xmlError = doc.Parse((const char*)saveinfoData->data(), saveinfoData->size()); - if (xmlError == xml::XML_SUCCESS || xmlError == xml::XML_ERROR_EMPTY_DOCUMENT) - { - xml::XMLNode* child = doc.FirstChild(); - // check for declaration -> <?xml version="1.0" encoding="utf-8"?> - if (!child || !child->ToDeclaration()) - { - xml::XMLDeclaration* decl = doc.NewDeclaration(); - doc.InsertFirstChild(decl); - } - - xml::XMLElement* info = doc.FirstChildElement("info"); - if (!info) - { - info = doc.NewElement("info"); - doc.InsertEndChild(info); - } - - // find node with persistentId - char tmp[64]; - sprintf(tmp, "%08x", persistentId); - bool foundNode = false; - for (xml::XMLElement* account = info->FirstChildElement("account"); account; account = account->NextSiblingElement("account")) - { - if (account->Attribute("persistentId", tmp)) - { - // found the entry! -> update timestamp - xml::XMLElement* timestamp = account->FirstChildElement("timestamp"); - sprintf(tmp, "%" PRIx64, _acpGetTimestamp()); - if (timestamp) - timestamp->SetText(tmp); - else - { - timestamp = doc.NewElement("timestamp"); - account->InsertFirstChild(timestamp); - } - - foundNode = true; - break; - } - } - - if (!foundNode) - { - tinyxml2::XMLElement* account = doc.NewElement("account"); - { - sprintf(tmp, "%08x", persistentId); - account->SetAttribute("persistentId", tmp); - - tinyxml2::XMLElement* timestamp = doc.NewElement("timestamp"); - { - sprintf(tmp, "%" PRIx64, _acpGetTimestamp()); - timestamp->SetText(tmp); - } - - account->InsertFirstChild(timestamp); - } - - info->InsertFirstChild(account); - } - - // update file - tinyxml2::XMLPrinter printer; - doc.Print(&printer); - FileStream* fs = FileStream::createFile2(saveinfoPath); - if (fs) - { - fs->writeString(printer.CStr()); - delete fs; - } - } - } - return NN_RESULT_SUCCESS; - } - ACPStatus ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType) { - nnResult r = __ACPUpdateSaveTimeStamp(persistentId, titleId, deviceType); + nnResult r = iosu::acp::ACPUpdateSaveTimeStamp(persistentId, titleId, deviceType); return ACPStatus::SUCCESS; } - void CreateSaveMetaFiles(uint32 persistentId, uint64 titleId) - { - std::string titlePath = CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()); - - sint32 fscStatus; - FSCVirtualFile* fscFile = fsc_open((titlePath + "/meta/meta.xml").c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - if (fscFile) - { - sint32 fileSize = fsc_getFileSize(fscFile); - - std::unique_ptr<uint8[]> fileContent = std::make_unique<uint8[]>(fileSize); - fsc_readFile(fscFile, fileContent.get(), fileSize); - fsc_close(fscFile); - - const auto outPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/meta.xml", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); - - std::ofstream myFile(outPath, std::ios::out | std::ios::binary); - myFile.write((char*)fileContent.get(), fileSize); - myFile.close(); - } - - fscFile = fsc_open((titlePath + "/meta/iconTex.tga").c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); - if (fscFile) - { - sint32 fileSize = fsc_getFileSize(fscFile); - - std::unique_ptr<uint8[]> fileContent = std::make_unique<uint8[]>(fileSize); - fsc_readFile(fscFile, fileContent.get(), fileSize); - fsc_close(fscFile); - - const auto outPath = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/meta/iconTex.tga", GetTitleIdHigh(titleId), GetTitleIdLow(titleId)); - - std::ofstream myFile(outPath, std::ios::out | std::ios::binary); - myFile.write((char*)fileContent.get(), fileSize); - myFile.close(); - } - - ACPUpdateSaveTimeStamp(persistentId, titleId, InternalDeviceType); - } - - nnResult CreateSaveDir(uint32 persistentId, ACPDeviceType type) - { - uint64 titleId = CafeSystem::GetForegroundTitleId(); - uint32 high = GetTitleIdHigh(titleId) & (~0xC); - uint32 low = GetTitleIdLow(titleId); - - sint32 fscStatus = FSC_STATUS_FILE_NOT_FOUND; - char path[256]; - - sprintf(path, "%susr/save/%08x/", "/vol/storage_mlc01/", high); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/meta/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/save/%08x/%08x/user/%08x", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); - fsc_createDir(path, &fscStatus); - - // not sure about this - sprintf(path, "%susr/boss/", "/vol/storage_mlc01/"); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/", "/vol/storage_mlc01/", high); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/common", "/vol/storage_mlc01/", high, low); - fsc_createDir(path, &fscStatus); - sprintf(path, "%susr/boss/%08x/%08x/user/%08x/", "/vol/storage_mlc01/", high, low, persistentId == 0 ? 0x80000001 : persistentId); - fsc_createDir(path, &fscStatus); - - // copy xml meta files - CreateSaveMetaFiles(persistentId, titleId); - - nnResult result = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACP, 0); - return result; - } - - ACPStatus ACPCreateSaveDir(uint32 persistentId, ACPDeviceType type) - { - nnResult result = CreateSaveDir(persistentId, type); - return _ACPConvertResultToACPStatus(&result, "ACPCreateSaveDir", 0x2FA); - } - ACPStatus ACPCheckApplicationDeviceEmulation(uint32be* isEmulated) { *isEmulated = 0; return ACPStatus::SUCCESS; } + ACPStatus ACPCreateSaveDir(uint32 persistentId, ACPDeviceType type) + { + nnResult result = iosu::acp::ACPCreateSaveDir(persistentId, type); + return _ACPConvertResultToACPStatus(&result); + } + nnResult ACPCreateSaveDirEx(uint8 accountSlot, uint64 titleId) { acpPrepareRequest(); @@ -279,7 +112,7 @@ namespace acp ppcDefineParamU8(accountSlot, 0); ppcDefineParamU64(titleId, 2); // index 2 because of alignment -> guessed parameters nnResult result = ACPCreateSaveDirEx(accountSlot, titleId); - osLib_returnFromFunction(hCPU, _ACPConvertResultToACPStatus(&result, "ACPCreateSaveDirEx", 0x300)); + osLib_returnFromFunction(hCPU, _ACPConvertResultToACPStatus(&result)); } void export_ACPGetSaveDataTitleIdList(PPCInterpreter_t* hCPU) @@ -511,6 +344,8 @@ namespace acp cafeExportRegister("nn_acp", ACPGetApplicationBox, LogType::Placeholder); + cafeExportRegister("nn_acp", ACPGetOlvAccesskey, LogType::Placeholder); + osLib_addFunction("nn_acp", "ACPIsOverAgeEx", export_ACPIsOverAgeEx); osLib_addFunction("nn_acp", "ACPGetNetworkTime", export_ACPGetNetworkTime); diff --git a/src/Cafe/OS/libs/nn_acp/nn_acp.h b/src/Cafe/OS/libs/nn_acp/nn_acp.h index cbf36c64..9890a6df 100644 --- a/src/Cafe/OS/libs/nn_acp/nn_acp.h +++ b/src/Cafe/OS/libs/nn_acp/nn_acp.h @@ -1,4 +1,5 @@ #pragma once +#include "Cafe/IOSU/legacy/iosu_acp.h" namespace nn { @@ -9,20 +10,13 @@ namespace acp SUCCESS = 0, }; - enum ACPDeviceType - { - UnknownType = 0, - InternalDeviceType = 1, - USBDeviceType = 3, - }; - - void CreateSaveMetaFiles(uint32 persistentId, uint64 titleId); + using ACPDeviceType = iosu::acp::ACPDeviceType; ACPStatus ACPGetApplicationBox(uint32be* applicationBox, uint64 titleId); ACPStatus ACPMountSaveDir(); ACPStatus ACPUnmountSaveDir(); - ACPStatus ACPCreateSaveDir(uint32 persistentId, ACPDeviceType type); - ACPStatus ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType);; + ACPStatus ACPCreateSaveDir(uint32 persistentId, iosu::acp::ACPDeviceType type); + ACPStatus ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, iosu::acp::ACPDeviceType deviceType); void load(); } diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 78de8291..05e49438 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -72,11 +72,11 @@ namespace save return result != 0; } - bool GetCurrentTitleApplicationBox(acp::ACPDeviceType* deviceType) + bool GetCurrentTitleApplicationBox(nn::acp::ACPDeviceType* deviceType) { if (deviceType) { - *deviceType = acp::InternalDeviceType; + *deviceType = nn::acp::ACPDeviceType::InternalDeviceType; return true; } return false; @@ -84,7 +84,7 @@ namespace save void UpdateSaveTimeStamp(uint32 persistentId) { - acp::ACPDeviceType deviceType; + nn::acp::ACPDeviceType deviceType; if (GetCurrentTitleApplicationBox(&deviceType)) ACPUpdateSaveTimeStamp(persistentId, CafeSystem::GetForegroundTitleId(), deviceType); } @@ -314,7 +314,7 @@ namespace save sprintf(path, "%susr/save/%08x/%08x/meta/", "/vol/storage_mlc01/", high, low); fsc_createDir(path, &fscStatus); - acp::CreateSaveMetaFiles(ActiveSettings::GetPersistentId(), titleId); + iosu::acp::CreateSaveMetaFiles(ActiveSettings::GetPersistentId(), titleId); } return SAVE_STATUS_OK; @@ -669,7 +669,7 @@ namespace save uint32 persistentId; if (GetPersistentIdEx(accountSlot, &persistentId)) { - acp::ACPStatus status = ACPCreateSaveDir(persistentId, acp::InternalDeviceType); + acp::ACPStatus status = nn::acp::ACPCreateSaveDir(persistentId, iosu::acp::ACPDeviceType::InternalDeviceType); result = ConvertACPToSaveStatus(status); } else From d45c2fa6d1ccd008a2ef22d814530894abd691d1 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 10 Apr 2024 20:23:15 +0200 Subject: [PATCH 142/314] erreula: Avoid triggering debug assert in imgui It does not like empty window titles --- src/Cafe/OS/libs/erreula/erreula.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cafe/OS/libs/erreula/erreula.cpp b/src/Cafe/OS/libs/erreula/erreula.cpp index c95816b6..a7f2f35c 100644 --- a/src/Cafe/OS/libs/erreula/erreula.cpp +++ b/src/Cafe/OS/libs/erreula/erreula.cpp @@ -277,10 +277,11 @@ namespace erreula ImGui::SetNextWindowBgAlpha(0.9f); ImGui::PushFont(font); - std::string title = "ErrEula"; + std::string title; if (appearArg.title) title = boost::nowide::narrow(GetText(appearArg.title.GetPtr())); - + if(title.empty()) // ImGui doesn't allow empty titles, so set one if appearArg.title is not set or empty + title = "ErrEula"; if (ImGui::Begin(title.c_str(), nullptr, kPopupFlags)) { const float startx = ImGui::GetWindowSize().x / 2.0f; From bac1ac3b499d84d502fdcec32e2fa5e8b176975c Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 11 Apr 2024 03:06:36 +0200 Subject: [PATCH 143/314] CI: use last vcpkg compatible CMake 3.29.0 (#1167) --- .github/workflows/build.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3b834b4..58a8508d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,6 +55,11 @@ jobs: sudo apt update -qq sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev nasm ninja-build + - name: "Setup cmake" + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.29.0' + - name: "Bootstrap vcpkg" run: | bash ./dependencies/vcpkg/bootstrap-vcpkg.sh @@ -154,6 +159,11 @@ jobs: echo "[INFO] Experimental version ${{ inputs.experimentalversion }}" echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEXPERIMENTAL_VERSION=${{ inputs.experimentalversion }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + - name: "Setup cmake" + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.29.0' + - name: "Bootstrap vcpkg" run: | ./dependencies/vcpkg/bootstrap-vcpkg.bat @@ -234,6 +244,11 @@ jobs: brew update brew install llvm@15 ninja nasm molten-vk automake libtool + - name: "Setup cmake" + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.29.0' + - name: "Bootstrap vcpkg" run: | bash ./dependencies/vcpkg/bootstrap-vcpkg.sh From 391533dbe5eec4c1f8d1f00a05629baf2216b423 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:08:26 -0700 Subject: [PATCH 144/314] Gamelist: Enable icon column by default (#1168) --- src/config/CemuConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index bcaf8467..9f1e7983 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -418,7 +418,7 @@ struct CemuConfig ConfigValue<bool> did_show_graphic_pack_download{false}; ConfigValue<bool> did_show_macos_disclaimer{false}; - ConfigValue<bool> show_icon_column{ false }; + ConfigValue<bool> show_icon_column{ true }; int game_list_style = 0; std::string game_list_column_order; From 84cad8b280afa9db7637ec1fd125d1b59970b548 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 11 Apr 2024 06:41:57 +0200 Subject: [PATCH 145/314] Vulkan: Remove unecessary present fence (#1166) --- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 5 --- .../Latte/Renderer/Vulkan/SwapchainInfoVk.cpp | 39 ++++--------------- .../Latte/Renderer/Vulkan/SwapchainInfoVk.h | 7 +--- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 9 +---- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 1 - 5 files changed, 10 insertions(+), 51 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 5b9fc349..60124c02 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -875,11 +875,6 @@ void LatteRenderTarget_getScreenImageArea(sint32* x, sint32* y, sint32* width, s void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPadView) { - if (g_renderer->GetType() == RendererAPI::Vulkan) - { - ((VulkanRenderer*)g_renderer.get())->PreparePresentationFrame(!isPadView); - } - // make sure texture is updated to latest data in cache LatteTexture_UpdateDataToLatest(textureView->baseTexture); // mark source texture as still in use diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp index b00f5490..75ff02ba 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp @@ -146,13 +146,6 @@ void SwapchainInfoVk::Create() UnrecoverableError("Failed to create semaphore for swapchain acquire"); } - VkFenceCreateInfo fenceInfo = {}; - fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; - fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; - result = vkCreateFence(m_logicalDevice, &fenceInfo, nullptr, &m_imageAvailableFence); - if (result != VK_SUCCESS) - UnrecoverableError("Failed to create fence for swapchain"); - m_acquireIndex = 0; hasDefinedSwapchainImage = false; } @@ -184,12 +177,6 @@ void SwapchainInfoVk::Cleanup() m_swapchainFramebuffers.clear(); - if (m_imageAvailableFence) - { - WaitAvailableFence(); - vkDestroyFence(m_logicalDevice, m_imageAvailableFence, nullptr); - m_imageAvailableFence = nullptr; - } if (m_swapchain) { vkDestroySwapchainKHR(m_logicalDevice, m_swapchain, nullptr); @@ -202,18 +189,6 @@ bool SwapchainInfoVk::IsValid() const return m_swapchain && !m_acquireSemaphores.empty(); } -void SwapchainInfoVk::WaitAvailableFence() -{ - if(m_awaitableFence != VK_NULL_HANDLE) - vkWaitForFences(m_logicalDevice, 1, &m_awaitableFence, VK_TRUE, UINT64_MAX); - m_awaitableFence = VK_NULL_HANDLE; -} - -void SwapchainInfoVk::ResetAvailableFence() const -{ - vkResetFences(m_logicalDevice, 1, &m_imageAvailableFence); -} - VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore() { VkSemaphore ret = m_currentSemaphore; @@ -221,15 +196,18 @@ VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore() return ret; } -bool SwapchainInfoVk::AcquireImage(uint64 timeout) +bool SwapchainInfoVk::AcquireImage() { - WaitAvailableFence(); - ResetAvailableFence(); - VkSemaphore acquireSemaphore = m_acquireSemaphores[m_acquireIndex]; - VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, timeout, acquireSemaphore, m_imageAvailableFence, &swapchainImageIndex); + VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, 1'000'000'000, acquireSemaphore, nullptr, &swapchainImageIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) m_shouldRecreate = true; + if (result == VK_TIMEOUT) + { + swapchainImageIndex = -1; + return false; + } + if (result < 0) { swapchainImageIndex = -1; @@ -238,7 +216,6 @@ bool SwapchainInfoVk::AcquireImage(uint64 timeout) return false; } m_currentSemaphore = acquireSemaphore; - m_awaitableFence = m_imageAvailableFence; m_acquireIndex = (m_acquireIndex + 1) % m_swapchainImages.size(); return true; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h index 0e8c2ade..ceffab41 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h @@ -26,10 +26,7 @@ struct SwapchainInfoVk bool IsValid() const; - void WaitAvailableFence(); - void ResetAvailableFence() const; - - bool AcquireImage(uint64 timeout); + bool AcquireImage(); // retrieve semaphore of last acquire for submitting a wait operation // only one wait operation must be submitted per acquire (which submits a single signal operation) // therefore subsequent calls will return a NULL handle @@ -84,9 +81,7 @@ struct SwapchainInfoVk private: uint32 m_acquireIndex = 0; std::vector<VkSemaphore> m_acquireSemaphores; // indexed by m_acquireIndex - VkFence m_imageAvailableFence{}; VkSemaphore m_currentSemaphore = VK_NULL_HANDLE; - VkFence m_awaitableFence = VK_NULL_HANDLE; std::array<uint32, 2> m_swapchainQueueFamilyIndices; VkExtent2D m_actualExtent{}; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index e0ebda2a..9209e3cd 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1824,11 +1824,6 @@ void VulkanRenderer::DrawEmptyFrame(bool mainWindow) SwapBuffers(mainWindow, !mainWindow); } -void VulkanRenderer::PreparePresentationFrame(bool mainWindow) -{ - AcquireNextSwapchainImage(mainWindow); -} - void VulkanRenderer::InitFirstCommandBuffer() { cemu_assert_debug(m_state.currentCommandBuffer == nullptr); @@ -2599,7 +2594,7 @@ bool VulkanRenderer::AcquireNextSwapchainImage(bool mainWindow) if (!UpdateSwapchainProperties(mainWindow)) return false; - bool result = chainInfo.AcquireImage(UINT64_MAX); + bool result = chainInfo.AcquireImage(); if (!result) return false; @@ -2612,8 +2607,6 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate) SubmitCommandBuffer(); WaitDeviceIdle(); auto& chainInfo = GetChainInfo(mainWindow); - // make sure fence has no signal operation submitted - chainInfo.WaitAvailableFence(); Vector2i size; if (mainWindow) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 2491d052..6df53da4 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -228,7 +228,6 @@ public: uint64 GenUniqueId(); // return unique id (uses incrementing counter) void DrawEmptyFrame(bool mainWindow) override; - void PreparePresentationFrame(bool mainWindow); void InitFirstCommandBuffer(); void ProcessFinishedCommandBuffers(); From d5a8530246a6411c318c8df1dadb2d3e6fd658f7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 13 Apr 2024 10:38:10 +0200 Subject: [PATCH 146/314] nlibcurl: Detect invalid header combo + refactoring Fixes error 106-0526 when opening course world on Super Mario Maker Manually attaching Content-Length header for POST requests is undefined behavior on recent libcurl. To detect the bad case some refactoring was necessary. In general we should try to move away from directly forwarding curl_easy_setopt() to the underlying instance as the behavior is diverging in modern libcurl. Much more refactoring work is required in the future to fix all of this. --- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 404 +++++++++++++++++-------- 1 file changed, 280 insertions(+), 124 deletions(-) diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 53981a5a..318e658e 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -1,4 +1,5 @@ #include "Cafe/OS/common/OSCommon.h" +#include "Cafe/OS/common/OSUtil.h" #include "Cafe/HW/Espresso/PPCCallback.h" #include "nlibcurl.h" @@ -6,6 +7,8 @@ #include "openssl/x509.h" #include "openssl/ssl.h" +#define CURL_STRICTER + #include "curl/curl.h" #include <unordered_map> #include <atomic> @@ -98,6 +101,17 @@ struct MEMPTRHash_t } }; +struct WU_curl_slist +{ + MEMPTR<char> data; + MEMPTR<WU_curl_slist> next; +}; + +enum class WU_CURLcode +{ + placeholder = 0, +}; + struct { sint32 initialized; @@ -110,8 +124,53 @@ struct MEMPTR<curl_calloc_callback> calloc; } g_nlibcurl = {}; +using WU_CURL_off_t = uint64be; -#pragma pack(1) +enum class WU_HTTPREQ : uint32 +{ + HTTPREQ_GET = 0x1, + HTTPREQ_POST = 0x2, + UKN_3 = 0x3, +}; + +struct WU_UserDefined +{ + // starting at 0xD8 (probably) in CURL_t + /* 0x0D8 / +0x00 */ uint32be ukn0D8; + /* 0x0DC / +0x04 */ uint32be ukn0DC; + /* 0x0E0 / +0x08 */ MEMPTR<WU_curl_slist> headers; + /* 0x0E4 / +0x0C */ uint32be ukn0E4; + /* 0x0E8 / +0x10 */ uint32be ukn0E8; + /* 0x0EC / +0x14 */ uint32be ukn0EC; + /* 0x0F0 / +0x18 */ uint32be ukn0F0[4]; + /* 0x100 / +0x28 */ uint32be ukn100[4]; + /* 0x110 / +0x38 */ uint32be ukn110[4]; // +0x40 -> WU_CURL_off_t postfieldsize ? + /* 0x120 / +0x48 */ uint32be ukn120[4]; + /* 0x130 / +0x58 */ uint32be ukn130[4]; + /* 0x140 / +0x68 */ uint32be ukn140[4]; + /* 0x150 / +0x78 */ uint32be ukn150[4]; + /* 0x160 / +0x88 */ uint32be ukn160[4]; + /* 0x170 / +0x98 */ uint32be ukn170[4]; + /* 0x180 / +0xA8 */ uint32be ukn180[4]; + /* 0x190 / +0xB0 */ sint64be infilesize_190{0}; + /* 0x198 / +0xB8 */ uint32be ukn198; + /* 0x19C / +0xBC */ uint32be ukn19C; + /* 0x1A0 / +0xC8 */ uint32be ukn1A0[4]; + /* 0x1B0 / +0xD8 */ uint32be ukn1B0[4]; + /* 0x1C0 / +0xE8 */ uint32be ukn1C0[4]; + /* 0x1D0 / +0xF8 */ uint32be ukn1D0[4]; + /* 0x1E0 / +0x108 */ uint32be ukn1E0; + /* 0x1E4 / +0x108 */ uint32be ukn1E4; + /* 0x1E8 / +0x108 */ uint32be ukn1E8; + /* 0x1EC / +0x108 */ betype<WU_HTTPREQ> httpreq_1EC; + /* 0x1F0 / +0x118 */ uint32be ukn1F0[4]; + + void SetToDefault() + { + memset(this, 0, sizeof(WU_UserDefined)); + httpreq_1EC = WU_HTTPREQ::HTTPREQ_GET; + } +}; struct CURL_t { @@ -137,6 +196,7 @@ struct CURL_t OSThread_t* curlThread; MEMPTR<char> info_redirectUrl; // stores CURLINFO_REDIRECT_URL ptr MEMPTR<char> info_contentType; // stores CURLINFO_CONTENT_TYPE ptr + bool isDirty{true}; // debug struct @@ -149,10 +209,44 @@ struct CURL_t FileStream* file_responseRaw{}; }debug; + // fields below match the actual memory layout, above still needs refactoring + /* 0x78 */ uint32be ukn078; + /* 0x7C */ uint32be ukn07C; + /* 0x80 */ uint32be ukn080; + /* 0x84 */ uint32be ukn084; + /* 0x88 */ uint32be ukn088; + /* 0x8C */ uint32be ukn08C; + /* 0x90 */ uint32be ukn090[4]; + /* 0xA0 */ uint32be ukn0A0[4]; + /* 0xB0 */ uint32be ukn0B0[4]; + /* 0xC0 */ uint32be ukn0C0[4]; + /* 0xD0 */ uint32be ukn0D0; + /* 0xD4 */ uint32be ukn0D4; + /* 0xD8 */ WU_UserDefined set; + /* 0x200 */ uint32be ukn200[4]; + /* 0x210 */ uint32be ukn210[4]; + /* 0x220 */ uint32be ukn220[4]; + /* 0x230 */ uint32be ukn230[4]; + /* 0x240 */ uint32be ukn240[4]; + /* 0x250 */ uint32be ukn250[4]; + /* 0x260 */ uint32be ukn260[4]; + /* 0x270 */ uint32be ukn270[4]; + /* 0x280 */ uint8be ukn280; + /* 0x281 */ uint8be opt_no_body_281; + /* 0x282 */ uint8be ukn282; + /* 0x283 */ uint8be upload_283; }; static_assert(sizeof(CURL_t) <= 0x8698); +static_assert(offsetof(CURL_t, ukn078) == 0x78); +static_assert(offsetof(CURL_t, set) == 0xD8); +static_assert(offsetof(CURL_t, set) + offsetof(WU_UserDefined, headers) == 0xE0); +static_assert(offsetof(CURL_t, set) + offsetof(WU_UserDefined, infilesize_190) == 0x190); +static_assert(offsetof(CURL_t, set) + offsetof(WU_UserDefined, httpreq_1EC) == 0x1EC); +static_assert(offsetof(CURL_t, opt_no_body_281) == 0x281); typedef MEMPTR<CURL_t> CURLPtr; +#pragma pack(1) // may affect structs below, we can probably remove this but lets keep it for now as the code below is fragile + typedef struct { //uint32be specifier; // 0x00 @@ -173,18 +267,12 @@ typedef MEMPTR<CURLSH_t> CURLSHPtr; typedef struct { CURLM* curlm; - std::vector< MEMPTR<CURL> > curl; + std::vector<MEMPTR<CURL_t>> curl; }CURLM_t; static_assert(sizeof(CURLM_t) <= 0x80, "sizeof(CURLM_t)"); typedef MEMPTR<CURLM_t> CURLMPtr; -struct curl_slist_t -{ - MEMPTR<char> data; - MEMPTR<curl_slist_t> next; -}; - -static_assert(sizeof(curl_slist_t) <= 0x8, "sizeof(curl_slist_t)"); +static_assert(sizeof(WU_curl_slist) <= 0x8, "sizeof(curl_slist_t)"); struct CURLMsg_t { @@ -298,6 +386,89 @@ uint32 SendOrderToWorker(CURL_t* curl, QueueOrder order, uint32 arg1 = 0) return result; } +int curl_closesocket(void *clientp, curl_socket_t item); + +void _curl_set_default_parameters(CURL_t* curl) +{ + curl->set.SetToDefault(); + + // default parameters + curl_easy_setopt(curl->curl, CURLOPT_HEADERFUNCTION, header_callback); + curl_easy_setopt(curl->curl, CURLOPT_HEADERDATA, curl); + + curl_easy_setopt(curl->curl, CURLOPT_CLOSESOCKETFUNCTION, curl_closesocket); + curl_easy_setopt(curl->curl, CURLOPT_CLOSESOCKETDATA, nullptr); +} + +void _curl_sync_parameters(CURL_t* curl) +{ + // sync ppc curl to actual curl state + // not all parameters are covered yet, many are still set directly in easy_setopt + bool isPost = curl->set.httpreq_1EC == WU_HTTPREQ::HTTPREQ_POST; + // http request type + if(curl->set.httpreq_1EC == WU_HTTPREQ::HTTPREQ_GET) + { + ::curl_easy_setopt(curl->curl, CURLOPT_HTTPGET, 1); + cemu_assert_debug(curl->opt_no_body_281 == 0); + cemu_assert_debug(curl->upload_283 == 0); + } + else if(curl->set.httpreq_1EC == WU_HTTPREQ::HTTPREQ_POST) + { + ::curl_easy_setopt(curl->curl, CURLOPT_POST, 1); + cemu_assert_debug(curl->upload_283 == 0); + ::curl_easy_setopt(curl->curl, CURLOPT_NOBODY, curl->opt_no_body_281 ? 1 : 0); + } + else + { + cemu_assert_unimplemented(); + } + + // CURLOPT_HTTPHEADER + std::optional<uint64> manualHeaderContentLength; + if (curl->set.headers) + { + struct curl_slist* list = nullptr; + WU_curl_slist* ppcList = curl->set.headers; + while(ppcList) + { + if(isPost) + { + // for recent libcurl manually adding Content-Length header is undefined behavior. Instead CURLOPT_INFILESIZE(_LARGE) should be set + // here we remove Content-Length and instead substitute it with CURLOPT_INFILESIZE (NEX DataStore in Super Mario Maker requires this) + if(strncmp(ppcList->data.GetPtr(), "Content-Length:", 15) == 0) + { + manualHeaderContentLength = std::stoull(ppcList->data.GetPtr() + 15); + ppcList = ppcList->next; + continue; + } + } + + cemuLog_logDebug(LogType::Force, "curl_slist_append: {}", ppcList->data.GetPtr()); + curlDebug_logEasySetOptStr(curl, "CURLOPT_HTTPHEADER", (const char*)ppcList->data.GetPtr()); + list = ::curl_slist_append(list, ppcList->data.GetPtr()); + ppcList = ppcList->next; + } + ::curl_easy_setopt(curl->curl, CURLOPT_HTTPHEADER, list); + // todo - prevent leaking of list (maybe store in host curl object, similar to how our zlib implementation does stuff) + } + else + ::curl_easy_setopt(curl->curl, CURLOPT_HTTPHEADER, nullptr); + + // infile size (post data size) + if (curl->set.infilesize_190) + { + cemu_assert_debug(manualHeaderContentLength == 0); // should not have both? + ::curl_easy_setopt(curl->curl, CURLOPT_INFILESIZE_LARGE, curl->set.infilesize_190); + } + else + { + if(isPost && manualHeaderContentLength > 0) + ::curl_easy_setopt(curl->curl, CURLOPT_INFILESIZE_LARGE, manualHeaderContentLength); + else + ::curl_easy_setopt(curl->curl, CURLOPT_INFILESIZE_LARGE, 0); + } +} + void export_malloc(PPCInterpreter_t* hCPU) { ppcDefineParamU32(size, 0); @@ -340,7 +511,6 @@ void export_realloc(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, result.GetMPTR()); } - CURLcode curl_global_init(uint32 flags) { if (g_nlibcurl.initialized++) @@ -436,6 +606,18 @@ void export_curl_multi_perform(PPCInterpreter_t* hCPU) //cemuLog_logDebug(LogType::Force, "curl_multi_perform(0x{:08x}, 0x{:08x})", curlm.GetMPTR(), runningHandles.GetMPTR()); + //curl_multi_get_handles(curlm->curlm); + + for(auto _curl : curlm->curl) + { + CURL_t* curl = (CURL_t*)_curl.GetPtr(); + if(curl->isDirty) + { + curl->isDirty = false; + _curl_sync_parameters(curl); + } + } + //g_callerQueue = curlm->callerQueue; //g_threadQueue = curlm->threadQueue; int tempRunningHandles = 0; @@ -555,7 +737,7 @@ void export_curl_multi_info_read(PPCInterpreter_t* hCPU) if (msg->easy_handle) { const auto it = find_if(curlm->curl.cbegin(), curlm->curl.cend(), - [msg](const MEMPTR<void>& curl) + [msg](const MEMPTR<CURL_t>& curl) { const MEMPTR<CURL_t> _curl{ curl }; return _curl->curl = msg->easy_handle; @@ -661,26 +843,6 @@ void export_curl_share_cleanup(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); } -int my_trace(CURL *handle, curl_infotype type, char *ptr, size_t size, - void *userp) -{ - FILE* f = (FILE*)userp; - - //if (type == CURLINFO_TEXT) - { - char tmp[1024] = {}; - sprintf(tmp, "0x%p: ", handle); - fwrite(tmp, 1, strlen(tmp), f); - - memcpy(tmp, ptr, std::min(size, (size_t)990)); - fwrite(tmp, 1, std::min(size + 1, (size_t)991), f); - - fflush(f); - - } - return 0; -} - static int curl_closesocket(void *clientp, curl_socket_t item) { nsysnet_notifyCloseSharedSocket((SOCKET)item); @@ -688,36 +850,30 @@ static int curl_closesocket(void *clientp, curl_socket_t item) return 0; } -void export_curl_easy_init(PPCInterpreter_t* hCPU) +CURL_t* curl_easy_init() { if (g_nlibcurl.initialized == 0) { if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) { - osLib_returnFromFunction(hCPU, 0); - return; + return nullptr; } } // Curl_open - CURLPtr result{ PPCCoreCallback(g_nlibcurl.calloc.GetMPTR(), (uint32)1, ppcsizeof<CURL_t>()) }; + MEMPTR<CURL_t> result{ PPCCoreCallback(g_nlibcurl.calloc.GetMPTR(), (uint32)1, ppcsizeof<CURL_t>()) }; cemuLog_logDebug(LogType::Force, "curl_easy_init() -> 0x{:08x}", result.GetMPTR()); if (result) { memset(result.GetPtr(), 0, sizeof(CURL_t)); *result = {}; - result->curl = curl_easy_init(); + result->curl = ::curl_easy_init(); result->curlThread = coreinit::OSGetCurrentThread(); result->info_contentType = nullptr; result->info_redirectUrl = nullptr; - // default parameters - curl_easy_setopt(result->curl, CURLOPT_HEADERFUNCTION, header_callback); - curl_easy_setopt(result->curl, CURLOPT_HEADERDATA, result.GetPtr()); - - curl_easy_setopt(result->curl, CURLOPT_CLOSESOCKETFUNCTION, curl_closesocket); - curl_easy_setopt(result->curl, CURLOPT_CLOSESOCKETDATA, nullptr); + _curl_set_default_parameters(result.GetPtr()); if (g_nlibcurl.proxyConfig) { @@ -725,7 +881,12 @@ void export_curl_easy_init(PPCInterpreter_t* hCPU) } } - osLib_returnFromFunction(hCPU, result.GetMPTR()); + return result; +} + +CURL_t* mw_curl_easy_init() +{ + return curl_easy_init(); } void export_curl_easy_pause(PPCInterpreter_t* hCPU) @@ -971,18 +1132,47 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU) ppcDefineParamU64(parameterU64, 2); CURL* curlObj = curl->curl; + curl->isDirty = true; CURLcode result = CURLE_OK; switch (option) { - case CURLOPT_NOSIGNAL: + case CURLOPT_POST: + { + if(parameter) + { + curl->set.httpreq_1EC = WU_HTTPREQ::HTTPREQ_POST; + curl->opt_no_body_281 = 0; + } + else + curl->set.httpreq_1EC = WU_HTTPREQ::HTTPREQ_GET; + break; + } case CURLOPT_HTTPGET: + { + if (parameter) + { + curl->set.httpreq_1EC = WU_HTTPREQ::HTTPREQ_GET; + curl->opt_no_body_281 = 0; + curl->upload_283 = 0; + } + break; + } + case CURLOPT_INFILESIZE: + { + curl->set.infilesize_190 = (sint64)(sint32)(uint32)parameter.GetBEValue(); + break; + } + case CURLOPT_INFILESIZE_LARGE: + { + curl->set.infilesize_190 = (sint64)(uint64)parameterU64; + break; + } + case CURLOPT_NOSIGNAL: case CURLOPT_FOLLOWLOCATION: case CURLOPT_BUFFERSIZE: case CURLOPT_TIMEOUT: case CURLOPT_CONNECTTIMEOUT_MS: - case CURLOPT_POST: - case CURLOPT_INFILESIZE: case CURLOPT_NOPROGRESS: case CURLOPT_LOW_SPEED_LIMIT: case CURLOPT_LOW_SPEED_TIME: @@ -1068,8 +1258,6 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU) curlSh->curl = curl; shObj = curlSh->curlsh; } - - result = ::curl_easy_setopt(curlObj, CURLOPT_SHARE, shObj); break; } @@ -1101,17 +1289,8 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU) } case CURLOPT_HTTPHEADER: { - struct curl_slist* list = nullptr; - bool isFirst = true; - for (curl_slist_t* ppcList = (curl_slist_t*)parameter.GetPtr(); ppcList; ppcList = ppcList->next.GetPtr()) - { - cemuLog_logDebug(LogType::Force, "curl_slist_append: {}", ppcList->data.GetPtr()); - curlDebug_logEasySetOptStr(curl.GetPtr(), isFirst?"CURLOPT_HTTPHEADER" : "CURLOPT_HTTPHEADER(continue)", (const char*)ppcList->data.GetPtr()); - list = ::curl_slist_append(list, ppcList->data.GetPtr()); - isFirst = false; - } - - result = ::curl_easy_setopt(curlObj, CURLOPT_HTTPHEADER, list); + curl->set.headers = (WU_curl_slist*)parameter.GetPtr(); + result = CURLE_OK; break; } case CURLOPT_SOCKOPTFUNCTION: @@ -1163,15 +1342,18 @@ void export_curl_easy_setopt(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, result); } -void export_curl_easy_perform(PPCInterpreter_t* hCPU) +WU_CURLcode curl_easy_perform(CURL_t* curl) { - ppcDefineParamMEMPTR(curl, CURL_t, 0); - curlDebug_markActiveRequest(curl.GetPtr()); - curlDebug_notifySubmitRequest(curl.GetPtr()); - cemuLog_logDebug(LogType::Force, "curl_easy_perform(0x{:08x})", curl.GetMPTR()); - const uint32 result = SendOrderToWorker(curl.GetPtr(), QueueOrder_Perform); - cemuLog_logDebug(LogType::Force, "curl_easy_perform(0x{:08x}) -> 0x{:x} DONE", curl.GetMPTR(), result); - osLib_returnFromFunction(hCPU, result); + curlDebug_markActiveRequest(curl); + curlDebug_notifySubmitRequest(curl); + + if(curl->isDirty) + { + curl->isDirty = false; + _curl_sync_parameters(curl); + } + const uint32 result = SendOrderToWorker(curl, QueueOrder_Perform); + return static_cast<WU_CURLcode>(result); } void _updateGuestString(CURL_t* curl, MEMPTR<char>& ppcStr, char* hostStr) @@ -1246,14 +1428,6 @@ void export_curl_easy_getinfo(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, result); } - - -void export_curl_global_init(PPCInterpreter_t* hCPU) -{ - ppcDefineParamU32(flags, 0); - osLib_returnFromFunction(hCPU, curl_global_init(flags)); -} - void export_curl_easy_strerror(PPCInterpreter_t* hCPU) { ppcDefineParamU32(code, 0); @@ -1270,21 +1444,16 @@ void export_curl_easy_strerror(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, result.GetMPTR()); } -void export_curl_slist_append(PPCInterpreter_t* hCPU) +WU_curl_slist* curl_slist_append(WU_curl_slist* list, const char* data) { - ppcDefineParamMEMPTR(list, curl_slist_t, 0); - ppcDefineParamMEMPTR(data, const char, 1); - - - MEMPTR<char> dupdata{ PPCCoreCallback(g_nlibcurl.strdup.GetMPTR(), data.GetMPTR()) }; + MEMPTR<char> dupdata{ PPCCoreCallback(g_nlibcurl.strdup.GetMPTR(), data) }; if (!dupdata) { - cemuLog_logDebug(LogType::Force, "curl_slist_append(0x{:08x}, 0x{:08x} [{}]) -> 0x00000000", list.GetMPTR(), data.GetMPTR(), data.GetPtr()); - osLib_returnFromFunction(hCPU, 0); - return; + cemuLog_logDebug(LogType::Force, "curl_slist_append(): Failed to duplicate string"); + return nullptr; } - MEMPTR<curl_slist_t> result{ PPCCoreCallback(g_nlibcurl.malloc.GetMPTR(), ppcsizeof<curl_slist_t>()) }; + MEMPTR<WU_curl_slist> result{ PPCCoreCallback(g_nlibcurl.malloc.GetMPTR(), ppcsizeof<WU_curl_slist>()) }; if (result) { result->data = dupdata; @@ -1293,7 +1462,7 @@ void export_curl_slist_append(PPCInterpreter_t* hCPU) // update last obj of list if (list) { - MEMPTR<curl_slist_t> tmp = list; + MEMPTR<WU_curl_slist> tmp = list; while (tmp->next) { tmp = tmp->next; @@ -1303,38 +1472,24 @@ void export_curl_slist_append(PPCInterpreter_t* hCPU) } } else + { + cemuLog_logDebug(LogType::Force, "curl_slist_append(): Failed to allocate memory"); PPCCoreCallback(g_nlibcurl.free.GetMPTR(), dupdata.GetMPTR()); - - cemuLog_logDebug(LogType::Force, "curl_slist_append(0x{:08x}, 0x{:08x} [{}]) -> 0x{:08x}", list.GetMPTR(), data.GetMPTR(), data.GetPtr(), result.GetMPTR()); + } if(list) - osLib_returnFromFunction(hCPU, list.GetMPTR()); - else - osLib_returnFromFunction(hCPU, result.GetMPTR()); + return list; + return result; } -void export_curl_slist_free_all(PPCInterpreter_t* hCPU) +void curl_slist_free_all(WU_curl_slist* list) { - ppcDefineParamMEMPTR(list, curl_slist_t, 0); - cemuLog_logDebug(LogType::Force, "export_curl_slist_free_all: TODO"); - - osLib_returnFromFunction(hCPU, 0); } -void export_curl_global_init_mem(PPCInterpreter_t* hCPU) +CURLcode curl_global_init_mem(uint32 flags, MEMPTR<curl_malloc_callback> malloc_callback, MEMPTR<curl_free_callback> free_callback, MEMPTR<curl_realloc_callback> realloc_callback, MEMPTR<curl_strdup_callback> strdup_callback, MEMPTR<curl_calloc_callback> calloc_callback) { - ppcDefineParamU32(flags, 0); - ppcDefineParamMEMPTR(m, curl_malloc_callback, 1); - ppcDefineParamMEMPTR(f, curl_free_callback, 2); - ppcDefineParamMEMPTR(r, curl_realloc_callback, 3); - ppcDefineParamMEMPTR(s, curl_strdup_callback, 4); - ppcDefineParamMEMPTR(c, curl_calloc_callback, 5); - - if (!m || !f || !r || !s || !c) - { - osLib_returnFromFunction(hCPU, CURLE_FAILED_INIT); - return; - } + if(!malloc_callback || !free_callback || !realloc_callback || !strdup_callback || !calloc_callback) + return CURLE_FAILED_INIT; CURLcode result = CURLE_OK; if (g_nlibcurl.initialized == 0) @@ -1342,31 +1497,30 @@ void export_curl_global_init_mem(PPCInterpreter_t* hCPU) result = curl_global_init(flags); if (result == CURLE_OK) { - g_nlibcurl.malloc = m; - g_nlibcurl.free = f; - g_nlibcurl.realloc = r; - g_nlibcurl.strdup = s; - g_nlibcurl.calloc = c; + g_nlibcurl.malloc = malloc_callback; + g_nlibcurl.free = free_callback; + g_nlibcurl.realloc = realloc_callback; + g_nlibcurl.strdup = strdup_callback; + g_nlibcurl.calloc = calloc_callback; } } - - cemuLog_logDebug(LogType::Force, "curl_global_init_mem(0x{:x}, 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x}) -> 0x{:08x}", flags, m.GetMPTR(), f.GetMPTR(), r.GetMPTR(), s.GetMPTR(), c.GetMPTR(), result); - osLib_returnFromFunction(hCPU, result); + return result; } void load() { - osLib_addFunction("nlibcurl", "curl_global_init_mem", export_curl_global_init_mem); - osLib_addFunction("nlibcurl", "curl_global_init", export_curl_global_init); + cafeExportRegister("nlibcurl", curl_global_init_mem, LogType::Force); + cafeExportRegister("nlibcurl", curl_global_init, LogType::Force); - osLib_addFunction("nlibcurl", "curl_slist_append", export_curl_slist_append); - osLib_addFunction("nlibcurl", "curl_slist_free_all", export_curl_slist_free_all); + cafeExportRegister("nlibcurl", curl_slist_append, LogType::Force); + cafeExportRegister("nlibcurl", curl_slist_free_all, LogType::Force); osLib_addFunction("nlibcurl", "curl_easy_strerror", export_curl_easy_strerror); osLib_addFunction("nlibcurl", "curl_share_init", export_curl_share_init); osLib_addFunction("nlibcurl", "curl_share_setopt", export_curl_share_setopt); osLib_addFunction("nlibcurl", "curl_share_cleanup", export_curl_share_cleanup); + cafeExportRegister("nlibcurl", mw_curl_easy_init, LogType::Force); osLib_addFunction("nlibcurl", "curl_multi_init", export_curl_multi_init); osLib_addFunction("nlibcurl", "curl_multi_add_handle", export_curl_multi_add_handle); osLib_addFunction("nlibcurl", "curl_multi_perform", export_curl_multi_perform); @@ -1377,12 +1531,14 @@ void load() osLib_addFunction("nlibcurl", "curl_multi_cleanup", export_curl_multi_cleanup); osLib_addFunction("nlibcurl", "curl_multi_timeout", export_curl_multi_timeout); - osLib_addFunction("nlibcurl", "curl_easy_init", export_curl_easy_init); - osLib_addFunction("nlibcurl", "mw_curl_easy_init", export_curl_easy_init); + cafeExportRegister("nlibcurl", curl_easy_init, LogType::Force); osLib_addFunction("nlibcurl", "curl_easy_reset", export_curl_easy_reset); osLib_addFunction("nlibcurl", "curl_easy_setopt", export_curl_easy_setopt); osLib_addFunction("nlibcurl", "curl_easy_getinfo", export_curl_easy_getinfo); - osLib_addFunction("nlibcurl", "curl_easy_perform", export_curl_easy_perform); + cafeExportRegister("nlibcurl", curl_easy_perform, LogType::Force); + + + osLib_addFunction("nlibcurl", "curl_easy_cleanup", export_curl_easy_cleanup); osLib_addFunction("nlibcurl", "curl_easy_pause", export_curl_easy_pause); } From 9c28a728e4c78594e8f274990c0ffe6a3fabc07f Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 13 Apr 2024 10:43:13 +0200 Subject: [PATCH 147/314] prudp: Dont expect sessionId to match for PING+ACK Fixes friend service connection periodically timing-out on Pretendo. Seems that unlike Nintendo's servers, Pretendo doesn't set sessionId for PING ack packets. --- src/Cemu/nex/prudp.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Cemu/nex/prudp.cpp b/src/Cemu/nex/prudp.cpp index 051e4893..4ef50b11 100644 --- a/src/Cemu/nex/prudp.cpp +++ b/src/Cemu/nex/prudp.cpp @@ -452,9 +452,7 @@ prudpIncomingPacket::prudpIncomingPacket(prudpStreamSettings_t* streamSettings, } else { -#ifdef CEMU_DEBUG_ASSERT - assert_dbg(); -#endif + cemu_assert_suspicious(); } } @@ -696,6 +694,8 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) if (currentConnectionState == STATE_CONNECTING) { lastPingTimestamp = prudpGetMSTimestamp(); + if(serverSessionId != 0) + cemuLog_logDebug(LogType::Force, "PRUDP: ServerSessionId is already set"); serverSessionId = incomingPacket->sessionId; currentConnectionState = STATE_CONNECTED; //printf("Connection established. ClientSession %02x ServerSession %02x\n", clientSessionId, serverSessionId); @@ -763,7 +763,6 @@ bool prudpClient::update() sint32 r = recvfrom(socketUdp, (char*)receiveBuffer, sizeof(receiveBuffer), 0, &receiveFrom, &receiveFromLen); if (r >= 0) { - //printf("RECV 0x%04x byte\n", r); // todo: Verify sender (receiveFrom) // calculate packet size sint32 pIdx = 0; @@ -772,18 +771,25 @@ bool prudpClient::update() sint32 packetLength = prudpPacket::calculateSizeFromPacketData(receiveBuffer + pIdx, r - pIdx); if (packetLength <= 0 || (pIdx + packetLength) > r) { - //printf("Invalid packet length\n"); + cemuLog_logDebug(LogType::Force, "PRUDP: Invalid packet length"); break; } prudpIncomingPacket* incomingPacket = new prudpIncomingPacket(&streamSettings, receiveBuffer + pIdx, packetLength); + pIdx += packetLength; if (incomingPacket->hasError()) { + cemuLog_logDebug(LogType::Force, "PRUDP: Packet error"); delete incomingPacket; break; } - if (incomingPacket->type != prudpPacket::TYPE_CON && incomingPacket->sessionId != serverSessionId) + // sessionId validation is complicated and depends on specific flags and type combinations. It does not seem to cover all packet types + bool validateSessionId = serverSessionId != 0; + if((incomingPacket->type == prudpPacket::TYPE_PING && (incomingPacket->flags&prudpPacket::FLAG_ACK) != 0)) + validateSessionId = false; // PING + ack -> disable session id validation. Pretendo's friend server sends PING ack packets without setting the sessionId (it is 0) + if (validateSessionId && incomingPacket->sessionId != serverSessionId) { + cemuLog_logDebug(LogType::Force, "PRUDP: Invalid session id"); delete incomingPacket; continue; // different session } From 6ea42d958ca349944485e04b67d675954892dde3 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:03:02 +0200 Subject: [PATCH 148/314] nlibcurl: Fix compile error --- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 318e658e..0268c7df 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -386,7 +386,12 @@ uint32 SendOrderToWorker(CURL_t* curl, QueueOrder order, uint32 arg1 = 0) return result; } -int curl_closesocket(void *clientp, curl_socket_t item); +static int curl_closesocket(void *clientp, curl_socket_t item) +{ + nsysnet_notifyCloseSharedSocket((SOCKET)item); + closesocket(item); + return 0; +} void _curl_set_default_parameters(CURL_t* curl) { @@ -843,13 +848,6 @@ void export_curl_share_cleanup(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); } -static int curl_closesocket(void *clientp, curl_socket_t item) -{ - nsysnet_notifyCloseSharedSocket((SOCKET)item); - closesocket(item); - return 0; -} - CURL_t* curl_easy_init() { if (g_nlibcurl.initialized == 0) From 10c78ecccef14b352f362db03f6d91f70e9d3e74 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 15 Apr 2024 05:20:39 +0200 Subject: [PATCH 149/314] CI: don't strip debug symbols from binary in AppImage (#1175) --- dist/linux/appimage.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/linux/appimage.sh b/dist/linux/appimage.sh index 60a50329..7bfc4701 100755 --- a/dist/linux/appimage.sh +++ b/dist/linux/appimage.sh @@ -33,6 +33,7 @@ chmod +x AppDir/usr/bin/Cemu cp /usr/lib/x86_64-linux-gnu/{libsepol.so.1,libffi.so.7,libpcre.so.3,libGLU.so.1,libthai.so.0} AppDir/usr/lib export UPD_INFO="gh-releases-zsync|cemu-project|Cemu|ci|Cemu.AppImage.zsync" +export NO_STRIP=1 ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run \ --appdir="${GITHUB_WORKSPACE}"/AppDir/ \ -d "${GITHUB_WORKSPACE}"/AppDir/info.cemu.Cemu.desktop \ From ee36992bd6f1e16f93cd847c293a04555139012d Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 16 Apr 2024 21:38:20 +0200 Subject: [PATCH 150/314] prudp: Improve ping and ack logic Fixes the issue where the friend service connection would always timeout on Pretendo servers The individual changes are: - Outgoing ping packets now use their own incrementing sequenceId (matches official NEX behavior) - If the server sends us a ping packet with NEEDS_ACK, we now respond - Misc smaller refactoring and code clean up - Added PRUDP as a separate logging option --- src/Cemu/Logging/CemuLogging.h | 1 + src/Cemu/nex/nexFriends.cpp | 3 +- src/Cemu/nex/prudp.cpp | 172 +++++++++++++++++++++------------ src/Cemu/nex/prudp.h | 10 +- src/gui/MainWindow.cpp | 1 + 5 files changed, 122 insertions(+), 65 deletions(-) diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index e789c2ea..44e89360 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -42,6 +42,7 @@ enum class LogType : sint32 ProcUi = 39, + PRUDP = 40, }; template <> diff --git a/src/Cemu/nex/nexFriends.cpp b/src/Cemu/nex/nexFriends.cpp index ae87ce44..927418ca 100644 --- a/src/Cemu/nex/nexFriends.cpp +++ b/src/Cemu/nex/nexFriends.cpp @@ -221,7 +221,8 @@ NexFriends::NexFriends(uint32 authServerIp, uint16 authServerPort, const char* a NexFriends::~NexFriends() { - nexCon->destroy(); + if(nexCon) + nexCon->destroy(); } void NexFriends::doAsyncLogin() diff --git a/src/Cemu/nex/prudp.cpp b/src/Cemu/nex/prudp.cpp index 4ef50b11..7c01bec7 100644 --- a/src/Cemu/nex/prudp.cpp +++ b/src/Cemu/nex/prudp.cpp @@ -219,7 +219,7 @@ prudpPacket::prudpPacket(prudpStreamSettings_t* streamSettings, uint8 src, uint8 this->type = type; this->flags = flags; this->sessionId = sessionId; - this->sequenceId = sequenceId; + this->m_sequenceId = sequenceId; this->specifiedPacketSignature = packetSignature; this->streamSettings = streamSettings; this->fragmentIndex = 0; @@ -257,7 +257,7 @@ sint32 prudpPacket::buildData(uint8* output, sint32 maxLength) *(uint16*)(packetBuffer + 0x02) = typeAndFlags; *(uint8*)(packetBuffer + 0x04) = sessionId; *(uint32*)(packetBuffer + 0x05) = packetSignature(); - *(uint16*)(packetBuffer + 0x09) = sequenceId; + *(uint16*)(packetBuffer + 0x09) = m_sequenceId; writeIndex = 0xB; // variable fields if (this->type == TYPE_SYN) @@ -286,7 +286,9 @@ sint32 prudpPacket::buildData(uint8* output, sint32 maxLength) // no data } else - assert_dbg(); + { + cemu_assert_suspicious(); + } // checksum *(uint8*)(packetBuffer + writeIndex) = calculateChecksum(packetBuffer, writeIndex); writeIndex++; @@ -585,7 +587,7 @@ void prudpClient::acknowledgePacket(uint16 sequenceId) auto it = std::begin(list_packetsWithAckReq); while (it != std::end(list_packetsWithAckReq)) { - if (it->packet->sequenceId == sequenceId) + if (it->packet->GetSequenceId() == sequenceId) { delete it->packet; list_packetsWithAckReq.erase(it); @@ -634,16 +636,45 @@ sint32 prudpClient::kerberosEncryptData(uint8* input, sint32 length, uint8* outp void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) { + if(incomingPacket->type == prudpPacket::TYPE_PING) + { + if (incomingPacket->flags&prudpPacket::FLAG_ACK) + { + // ack for our ping packet + if(incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + cemuLog_log(LogType::PRUDP, "[PRUDP] Received unexpected ping packet with both ACK and NEED_ACK set"); + if(m_unacknowledgedPingCount > 0) + { + if(incomingPacket->sequenceId == m_outgoingSequenceId_ping) + { + cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet ACK (unacknowledged count: {})", m_unacknowledgedPingCount); + m_unacknowledgedPingCount = 0; + } + else + { + cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet ACK with wrong sequenceId (expected: {}, received: {})", m_outgoingSequenceId_ping, incomingPacket->sequenceId); + } + } + else + { + cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet ACK which we dont need"); + } + } + else if (incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + { + // other side is asking for ping ack + cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet with NEED_ACK set. Sending ACK back"); + cemu_assert_debug(incomingPacket->packetData.empty()); // todo - echo data? + prudpPacket ackPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_ACK, this->clientSessionId, incomingPacket->sequenceId, 0); + directSendPacket(&ackPacket, dstIp, dstPort); + } + delete incomingPacket; + return; + } + // handle general packet ACK if (incomingPacket->flags&prudpPacket::FLAG_ACK) { - // ack packet acknowledgePacket(incomingPacket->sequenceId); - if ((incomingPacket->type == prudpPacket::TYPE_DATA || incomingPacket->type == prudpPacket::TYPE_PING) && incomingPacket->packetData.empty()) - { - // ack packet - delete incomingPacket; - return; - } } // special cases if (incomingPacket->type == prudpPacket::TYPE_SYN) @@ -680,7 +711,7 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) // set packet specific data (client connection signature) conPacket->setData((uint8*)&this->clientConnectionSignature, sizeof(uint32)); } - // sent packet + // send packet queuePacket(conPacket, dstIp, dstPort); // remember con packet as sent hasSentCon = true; @@ -694,17 +725,28 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) if (currentConnectionState == STATE_CONNECTING) { lastPingTimestamp = prudpGetMSTimestamp(); - if(serverSessionId != 0) - cemuLog_logDebug(LogType::Force, "PRUDP: ServerSessionId is already set"); + cemu_assert_debug(serverSessionId == 0); serverSessionId = incomingPacket->sessionId; currentConnectionState = STATE_CONNECTED; - //printf("Connection established. ClientSession %02x ServerSession %02x\n", clientSessionId, serverSessionId); + cemuLog_log(LogType::PRUDP, "[PRUDP] Connection established. ClientSession {:02x} ServerSession {:02x}", clientSessionId, serverSessionId); } delete incomingPacket; return; } else if (incomingPacket->type == prudpPacket::TYPE_DATA) { + // send ack back if requested + if (incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + { + prudpPacket ackPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, prudpPacket::FLAG_ACK, this->clientSessionId, incomingPacket->sequenceId, 0); + directSendPacket(&ackPacket, dstIp, dstPort); + } + // skip data packets without payload + if (incomingPacket->packetData.empty()) + { + delete incomingPacket; + return; + } // verify some values uint16 seqDist = incomingPacket->sequenceId - incomingSequenceId; if (seqDist >= 0xC000) @@ -719,7 +761,7 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) if (it->sequenceId == incomingPacket->sequenceId) { // already queued (should check other values too, like packet type?) - cemuLog_logDebug(LogType::Force, "Duplicate PRUDP packet received"); + cemuLog_log(LogType::PRUDP, "Duplicate PRUDP packet received"); delete incomingPacket; return; } @@ -738,21 +780,12 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) delete incomingPacket; return; } - - if (incomingPacket->flags&prudpPacket::FLAG_NEED_ACK && incomingPacket->type == prudpPacket::TYPE_DATA) - { - // send ack back - prudpPacket* ackPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, prudpPacket::FLAG_ACK, this->clientSessionId, incomingPacket->sequenceId, 0); - queuePacket(ackPacket, dstIp, dstPort); - } } bool prudpClient::update() { if (currentConnectionState == STATE_DISCONNECTED) - { return false; - } uint32 currentTimestamp = prudpGetMSTimestamp(); // check for incoming packets uint8 receiveBuffer[4096]; @@ -771,25 +804,20 @@ bool prudpClient::update() sint32 packetLength = prudpPacket::calculateSizeFromPacketData(receiveBuffer + pIdx, r - pIdx); if (packetLength <= 0 || (pIdx + packetLength) > r) { - cemuLog_logDebug(LogType::Force, "PRUDP: Invalid packet length"); + cemuLog_log(LogType::Force, "[PRUDP] Invalid packet length"); break; } prudpIncomingPacket* incomingPacket = new prudpIncomingPacket(&streamSettings, receiveBuffer + pIdx, packetLength); - pIdx += packetLength; if (incomingPacket->hasError()) { - cemuLog_logDebug(LogType::Force, "PRUDP: Packet error"); + cemuLog_log(LogType::Force, "[PRUDP] Packet error"); delete incomingPacket; break; } - // sessionId validation is complicated and depends on specific flags and type combinations. It does not seem to cover all packet types - bool validateSessionId = serverSessionId != 0; - if((incomingPacket->type == prudpPacket::TYPE_PING && (incomingPacket->flags&prudpPacket::FLAG_ACK) != 0)) - validateSessionId = false; // PING + ack -> disable session id validation. Pretendo's friend server sends PING ack packets without setting the sessionId (it is 0) - if (validateSessionId && incomingPacket->sessionId != serverSessionId) + if (incomingPacket->type != prudpPacket::TYPE_CON && incomingPacket->sessionId != serverSessionId) { - cemuLog_logDebug(LogType::Force, "PRUDP: Invalid session id"); + cemuLog_log(LogType::PRUDP, "[PRUDP] Invalid session id"); delete incomingPacket; continue; // different session } @@ -816,13 +844,44 @@ bool prudpClient::update() } } // check if we need to send another ping - if (currentConnectionState == STATE_CONNECTED && (currentTimestamp - lastPingTimestamp) >= 20000) + if (currentConnectionState == STATE_CONNECTED) { - // send ping - prudpPacket* pingPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK | prudpPacket::FLAG_RELIABLE, this->clientSessionId, this->outgoingSequenceId, serverConnectionSignature); - this->outgoingSequenceId++; // increase since prudpPacket::FLAG_RELIABLE is set (note: official Wii U friends client sends ping packets without FLAG_RELIABLE) - queuePacket(pingPacket, dstIp, dstPort); - lastPingTimestamp = currentTimestamp; + if(m_unacknowledgedPingCount != 0) // counts how many times we sent a ping packet (for the current sequenceId) without receiving an ack + { + // we are waiting for the ack of the previous ping, but it hasn't arrived yet so send another ping packet + if((currentTimestamp - lastPingTimestamp) >= 1500) + { + cemuLog_log(LogType::PRUDP, "[PRUDP] Resending ping packet (no ack received)"); + if(m_unacknowledgedPingCount >= 10) + { + // too many unacknowledged pings, assume the connection is dead + currentConnectionState = STATE_DISCONNECTED; + cemuLog_log(LogType::PRUDP, "PRUDP: Connection did not receive a ping response in a while. Assuming disconnect"); + return false; + } + // resend the ping packet + prudpPacket* pingPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->clientSessionId, this->m_outgoingSequenceId_ping, serverConnectionSignature); + directSendPacket(pingPacket, dstIp, dstPort); + m_unacknowledgedPingCount++; + delete pingPacket; + lastPingTimestamp = currentTimestamp; + } + } + else + { + if((currentTimestamp - lastPingTimestamp) >= 20000) + { + cemuLog_log(LogType::PRUDP, "[PRUDP] Sending new ping packet with sequenceId {}", this->m_outgoingSequenceId_ping+1); + // start a new ping packet with a new sequenceId. Note that ping packets have their own sequenceId and acknowledgement happens by manually comparing the incoming ping ACK against the last sent sequenceId + // only one unacknowledged ping packet can be in flight at a time. We will resend the same ping packet until we receive an ack + this->m_outgoingSequenceId_ping++; // increment before sending. The first ping has a sequenceId of 1 + prudpPacket* pingPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->clientSessionId, this->m_outgoingSequenceId_ping, serverConnectionSignature); + directSendPacket(pingPacket, dstIp, dstPort); + m_unacknowledgedPingCount++; + delete pingPacket; + lastPingTimestamp = currentTimestamp; + } + } } return false; } @@ -844,6 +903,7 @@ void prudpClient::queuePacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort) { if (packet->requiresAck()) { + cemu_assert_debug(packet->GetType() != prudpPacket::TYPE_PING); // ping packets use their own logic for acks, dont queue them // remember this packet until we receive the ack prudpAckRequired_t ackRequired = { 0 }; ackRequired.packet = packet; @@ -861,16 +921,18 @@ void prudpClient::queuePacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort) void prudpClient::sendDatagram(uint8* input, sint32 length, bool reliable) { - if (reliable == false) + cemu_assert_debug(reliable); // non-reliable packets require testing + if(length >= 0x300) { - assert_dbg(); // todo + cemuLog_logOnce(LogType::Force, "PRUDP: Datagram too long"); } - if (length >= 0x300) - assert_dbg(); // too long, need to split into multiple fragments - // single fragment data packet - prudpPacket* packet = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, prudpPacket::FLAG_NEED_ACK | prudpPacket::FLAG_RELIABLE, clientSessionId, outgoingSequenceId, 0); - outgoingSequenceId++; + uint16 flags = prudpPacket::FLAG_NEED_ACK; + if(reliable) + flags |= prudpPacket::FLAG_RELIABLE; + prudpPacket* packet = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, flags, clientSessionId, outgoingSequenceId, 0); + if(reliable) + outgoingSequenceId++; packet->setFragmentIndex(0); packet->setData(input, length); queuePacket(packet, dstIp, dstPort); @@ -919,13 +981,7 @@ sint32 prudpClient::receiveDatagram(std::vector<uint8>& outputBuffer) } delete incomingPacket; // remove packet from queue - sint32 size = (sint32)queue_incomingPackets.size(); - size--; - for (sint32 i = 0; i < size; i++) - { - queue_incomingPackets[i] = queue_incomingPackets[i + 1]; - } - queue_incomingPackets.resize(size); + queue_incomingPackets.erase(queue_incomingPackets.begin()); // advance expected sequence id this->incomingSequenceId++; return datagramLen; @@ -975,13 +1031,7 @@ sint32 prudpClient::receiveDatagram(std::vector<uint8>& outputBuffer) delete incomingPacket; } // remove packets from queue - sint32 size = (sint32)queue_incomingPackets.size(); - size -= chainLength; - for (sint32 i = 0; i < size; i++) - { - queue_incomingPackets[i] = queue_incomingPackets[i + chainLength]; - } - queue_incomingPackets.resize(size); + queue_incomingPackets.erase(queue_incomingPackets.begin(), queue_incomingPackets.begin() + chainLength); this->incomingSequenceId += chainLength; return writeIndex; } diff --git a/src/Cemu/nex/prudp.h b/src/Cemu/nex/prudp.h index aa68f4f6..5ed5bcb1 100644 --- a/src/Cemu/nex/prudp.h +++ b/src/Cemu/nex/prudp.h @@ -71,15 +71,14 @@ public: void setData(uint8* data, sint32 length); void setFragmentIndex(uint8 fragmentIndex); sint32 buildData(uint8* output, sint32 maxLength); + uint8 GetType() const { return type; } + uint16 GetSequenceId() const { return m_sequenceId; } private: uint32 packetSignature(); uint8 calculateChecksum(uint8* data, sint32 length); -public: - uint16 sequenceId; - private: uint8 src; uint8 dst; @@ -91,6 +90,8 @@ private: prudpStreamSettings_t* streamSettings; std::vector<uint8> packetData; bool isEncrypted; + uint16 m_sequenceId{0}; + }; class prudpIncomingPacket @@ -186,6 +187,9 @@ private: uint16 outgoingSequenceId; uint16 incomingSequenceId; + uint16 m_outgoingSequenceId_ping{0}; + uint8 m_unacknowledgedPingCount{0}; + uint8 clientSessionId; uint8 serverSessionId; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 4d2fb478..da57870c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2232,6 +2232,7 @@ void MainWindow::RecreateMenu() debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("&Coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_FP), _("&NN FP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_FP)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::PRUDP), _("&PRUDP (for NN FP)"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::PRUDP)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_BOSS), _("&NN BOSS"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_BOSS)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("&GX2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("&Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); From e2f972571906b909ad19cb922b1fa5549e3522da Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:22:28 +0200 Subject: [PATCH 151/314] prudp: Code cleanup --- src/Cemu/nex/nex.cpp | 42 +-- src/Cemu/nex/prudp.cpp | 642 ++++++++++++++++++++--------------------- src/Cemu/nex/prudp.h | 148 +++++----- 3 files changed, 410 insertions(+), 422 deletions(-) diff --git a/src/Cemu/nex/nex.cpp b/src/Cemu/nex/nex.cpp index d0857507..973a4395 100644 --- a/src/Cemu/nex/nex.cpp +++ b/src/Cemu/nex/nex.cpp @@ -106,7 +106,7 @@ nexService::nexService() nexService::nexService(prudpClient* con) : nexService() { - if (con->isConnected() == false) + if (con->IsConnected() == false) cemu_assert_suspicious(); this->conNexService = con; bufferReceive = std::vector<uint8>(1024 * 4); @@ -191,7 +191,7 @@ void nexService::processQueuedRequest(queuedRequest_t* queuedRequest) uint32 callId = _currentCallId; _currentCallId++; // check state of connection - if (conNexService->getConnectionState() != prudpClient::STATE_CONNECTED) + if (conNexService->GetConnectionState() != prudpClient::ConnectionState::Connected) { nexServiceResponse_t response = { 0 }; response.isSuccessful = false; @@ -214,7 +214,7 @@ void nexService::processQueuedRequest(queuedRequest_t* queuedRequest) assert_dbg(); memcpy((packetBuffer + 0x0D), &queuedRequest->parameterData.front(), queuedRequest->parameterData.size()); sint32 length = 0xD + (sint32)queuedRequest->parameterData.size(); - conNexService->sendDatagram(packetBuffer, length, true); + conNexService->SendDatagram(packetBuffer, length, true); // remember request nexActiveRequestInfo_t requestInfo = { 0 }; requestInfo.callId = callId; @@ -299,13 +299,13 @@ void nexService::registerForAsyncProcessing() void nexService::updateTemporaryConnections() { // check for connection - conNexService->update(); - if (conNexService->isConnected()) + conNexService->Update(); + if (conNexService->IsConnected()) { if (connectionState == STATE_CONNECTING) connectionState = STATE_CONNECTED; } - if (conNexService->getConnectionState() == prudpClient::STATE_DISCONNECTED) + if (conNexService->GetConnectionState() == prudpClient::ConnectionState::Disconnected) connectionState = STATE_DISCONNECTED; } @@ -356,18 +356,18 @@ void nexService::sendRequestResponse(nexServiceRequest_t* request, uint32 errorC // update length field *(uint32*)response.getDataPtr() = response.getWriteIndex()-4; if(request->nex->conNexService) - request->nex->conNexService->sendDatagram(response.getDataPtr(), response.getWriteIndex(), true); + request->nex->conNexService->SendDatagram(response.getDataPtr(), response.getWriteIndex(), true); } void nexService::updateNexServiceConnection() { - if (conNexService->getConnectionState() == prudpClient::STATE_DISCONNECTED) + if (conNexService->GetConnectionState() == prudpClient::ConnectionState::Disconnected) { this->connectionState = STATE_DISCONNECTED; return; } - conNexService->update(); - sint32 datagramLen = conNexService->receiveDatagram(bufferReceive); + conNexService->Update(); + sint32 datagramLen = conNexService->ReceiveDatagram(bufferReceive); if (datagramLen > 0) { if (nexIsRequest(&bufferReceive[0], datagramLen)) @@ -454,12 +454,12 @@ bool _extractStationUrlParamValue(const char* urlStr, const char* paramName, cha return false; } -void nexServiceAuthentication_parseStationURL(char* urlStr, stationUrl_t* stationUrl) +void nexServiceAuthentication_parseStationURL(char* urlStr, prudpStationUrl* stationUrl) { // example: // prudps:/address=34.210.xxx.xxx;port=60181;CID=1;PID=2;sid=1;stream=10;type=2 - memset(stationUrl, 0, sizeof(stationUrl_t)); + memset(stationUrl, 0, sizeof(prudpStationUrl)); char optionValue[128]; if (_extractStationUrlParamValue(urlStr, "address", optionValue, sizeof(optionValue))) @@ -499,7 +499,7 @@ typedef struct sint32 kerberosTicketSize; uint8 kerberosTicket2[4096]; sint32 kerberosTicket2Size; - stationUrl_t server; + prudpStationUrl server; // progress info bool hasError; bool done; @@ -611,18 +611,18 @@ void nexServiceSecure_handleResponse_RegisterEx(nexService* nex, nexServiceRespo return; } -nexService* nex_secureLogin(authServerInfo_t* authServerInfo, const char* accessKey, const char* nexToken) +nexService* nex_secureLogin(prudpAuthServerInfo* authServerInfo, const char* accessKey, const char* nexToken) { prudpClient* prudpSecureSock = new prudpClient(authServerInfo->server.ip, authServerInfo->server.port, accessKey, authServerInfo); // wait until connected while (true) { - prudpSecureSock->update(); - if (prudpSecureSock->isConnected()) + prudpSecureSock->Update(); + if (prudpSecureSock->IsConnected()) { break; } - if (prudpSecureSock->getConnectionState() == prudpClient::STATE_DISCONNECTED) + if (prudpSecureSock->GetConnectionState() == prudpClient::ConnectionState::Disconnected) { // timeout or disconnected cemuLog_log(LogType::Force, "NEX: Secure login connection time-out"); @@ -638,7 +638,7 @@ nexService* nex_secureLogin(authServerInfo_t* authServerInfo, const char* access nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); char clientStationUrl[256]; - sprintf(clientStationUrl, "prudp:/port=%u;natf=0;natm=0;pmp=0;sid=15;type=2;upnp=0", (uint32)nex->getPRUDPConnection()->getSourcePort()); + sprintf(clientStationUrl, "prudp:/port=%u;natf=0;natm=0;pmp=0;sid=15;type=2;upnp=0", (uint32)nex->getPRUDPConnection()->GetSourcePort()); // station url list packetBuffer.writeU32(1); packetBuffer.writeString(clientStationUrl); @@ -737,9 +737,9 @@ nexService* nex_establishSecureConnection(uint32 authServerIp, uint16 authServer return nullptr; } // auth info - auto authServerInfo = std::make_unique<authServerInfo_t>(); + auto authServerInfo = std::make_unique<prudpAuthServerInfo>(); // decrypt ticket - RC4Ctx_t rc4Ticket; + RC4Ctx rc4Ticket; RC4_initCtx(&rc4Ticket, kerberosKey, 16); RC4_transform(&rc4Ticket, nexAuthService.kerberosTicket2, nexAuthService.kerberosTicket2Size - 16, nexAuthService.kerberosTicket2); nexPacketBuffer packetKerberosTicket(nexAuthService.kerberosTicket2, nexAuthService.kerberosTicket2Size - 16, false); @@ -756,7 +756,7 @@ nexService* nex_establishSecureConnection(uint32 authServerIp, uint16 authServer memcpy(authServerInfo->kerberosKey, kerberosKey, 16); memcpy(authServerInfo->secureKey, secureKey, 16); - memcpy(&authServerInfo->server, &nexAuthService.server, sizeof(stationUrl_t)); + memcpy(&authServerInfo->server, &nexAuthService.server, sizeof(prudpStationUrl)); authServerInfo->userPid = pid; return nex_secureLogin(authServerInfo.get(), accessKey, nexToken); diff --git a/src/Cemu/nex/prudp.cpp b/src/Cemu/nex/prudp.cpp index 7c01bec7..5c773fe7 100644 --- a/src/Cemu/nex/prudp.cpp +++ b/src/Cemu/nex/prudp.cpp @@ -1,72 +1,57 @@ #include "prudp.h" #include "util/crypto/md5.h" -#include<bitset> -#include<random> +#include <bitset> +#include <random> #include <boost/random/uniform_int.hpp> -void swap(unsigned char *a, unsigned char *b) +static void KSA(unsigned char* key, int keyLen, unsigned char* S) { - int tmp = *a; - *a = *b; - *b = tmp; -} - -void KSA(unsigned char *key, int keyLen, unsigned char *S) -{ - int j = 0; - for (int i = 0; i < RC4_N; i++) S[i] = i; - - for (int i = 0; i < RC4_N; i++) + int j = 0; + for (int i = 0; i < RC4_N; i++) { j = (j + S[i] + key[i % keyLen]) % RC4_N; - - swap(&S[i], &S[j]); + std::swap(S[i], S[j]); } } -void PRGA(unsigned char *S, unsigned char* input, int len, unsigned char* output) +static void PRGA(unsigned char* S, unsigned char* input, int len, unsigned char* output) { - int i = 0; - int j = 0; - - for (size_t n = 0; n < len; n++) + for (size_t n = 0; n < len; n++) { - i = (i + 1) % RC4_N; - j = (j + S[i]) % RC4_N; - - swap(&S[i], &S[j]); + int i = (i + 1) % RC4_N; + int j = (j + S[i]) % RC4_N; + std::swap(S[i], S[j]); int rnd = S[(S[i] + S[j]) % RC4_N]; - output[n] = rnd ^ input[n]; } } -void RC4(char* key, unsigned char* input, int len, unsigned char* output) +static void RC4(char* key, unsigned char* input, int len, unsigned char* output) { unsigned char S[RC4_N]; KSA((unsigned char*)key, (int)strlen(key), S); PRGA(S, input, len, output); } -void RC4_initCtx(RC4Ctx_t* rc4Ctx, const char* key) +void RC4_initCtx(RC4Ctx* rc4Ctx, const char* key) { rc4Ctx->i = 0; rc4Ctx->j = 0; KSA((unsigned char*)key, (int)strlen(key), rc4Ctx->S); } -void RC4_initCtx(RC4Ctx_t* rc4Ctx, unsigned char* key, int keyLen) +void RC4_initCtx(RC4Ctx* rc4Ctx, unsigned char* key, int keyLen) { rc4Ctx->i = 0; rc4Ctx->j = 0; KSA(key, keyLen, rc4Ctx->S); } -void RC4_transform(RC4Ctx_t* rc4Ctx, unsigned char* input, int len, unsigned char* output) +void RC4_transform(RC4Ctx* rc4Ctx, unsigned char* input, int len, unsigned char* output) { int i = rc4Ctx->i; int j = rc4Ctx->j; @@ -75,13 +60,10 @@ void RC4_transform(RC4Ctx_t* rc4Ctx, unsigned char* input, int len, unsigned cha { i = (i + 1) % RC4_N; j = (j + rc4Ctx->S[i]) % RC4_N; - - swap(&rc4Ctx->S[i], &rc4Ctx->S[j]); + std::swap(rc4Ctx->S[i], rc4Ctx->S[j]); int rnd = rc4Ctx->S[(rc4Ctx->S[i] + rc4Ctx->S[j]) % RC4_N]; - output[n] = rnd ^ input[n]; } - rc4Ctx->i = i; rc4Ctx->j = j; } @@ -91,34 +73,14 @@ uint32 prudpGetMSTimestamp() return GetTickCount(); } -std::bitset<10000> _portUsageMask; - -uint16 getRandomSrcPRUDPPort() -{ - while (true) - { - sint32 p = rand() % 10000; - if (_portUsageMask.test(p)) - continue; - _portUsageMask.set(p); - return 40000 + p; - } - return 0; -} - -void releasePRUDPPort(uint16 port) -{ - uint32 bitIndex = port - 40000; - _portUsageMask.reset(bitIndex); -} - std::mt19937_64 prudpRG(GetTickCount()); -// workaround for static asserts when using uniform_int_distribution -boost::random::uniform_int_distribution<int> prudpDis8(0, 0xFF); +// workaround for static asserts when using uniform_int_distribution (see https://github.com/cemu-project/Cemu/issues/48) +boost::random::uniform_int_distribution<int> prudpRandomDistribution8(0, 0xFF); +boost::random::uniform_int_distribution<int> prudpRandomDistributionPortGen(0, 10000); uint8 prudp_generateRandomU8() { - return prudpDis8(prudpRG); + return prudpRandomDistribution8(prudpRG); } uint32 prudp_generateRandomU32() @@ -133,7 +95,29 @@ uint32 prudp_generateRandomU32() return v; } -uint8 prudp_calculateChecksum(uint8 checksumBase, uint8* data, sint32 length) +std::bitset<10000> _portUsageMask; + +static uint16 AllocateRandomSrcPRUDPPort() +{ + while (true) + { + sint32 p = prudpRandomDistributionPortGen(prudpRG); + if (_portUsageMask.test(p)) + continue; + _portUsageMask.set(p); + return 40000 + p; + } +} + +static void ReleasePRUDPSrcPort(uint16 port) +{ + cemu_assert_debug(port >= 40000); + uint32 bitIndex = port - 40000; + cemu_assert_debug(_portUsageMask.test(bitIndex)); + _portUsageMask.reset(bitIndex); +} + +static uint8 prudp_calculateChecksum(uint8 checksumBase, uint8* data, sint32 length) { uint32 checksum32 = 0; for (sint32 i = 0; i < length / 4; i++) @@ -141,7 +125,7 @@ uint8 prudp_calculateChecksum(uint8 checksumBase, uint8* data, sint32 length) checksum32 += *(uint32*)(data + i * 4); } uint8 checksum = checksumBase; - for (sint32 i = length&(~3); i < length; i++) + for (sint32 i = length & (~3); i < length; i++) { checksum += data[i]; } @@ -161,16 +145,16 @@ sint32 prudpPacket::calculateSizeFromPacketData(uint8* data, sint32 length) return 0; // get flags fields uint16 typeAndFlags = *(uint16*)(data + 0x02); - uint16 type = (typeAndFlags&0xF); + uint16 type = (typeAndFlags & 0xF); uint16 flags = (typeAndFlags >> 4); - if ((flags&FLAG_HAS_SIZE) == 0) + if ((flags & FLAG_HAS_SIZE) == 0) return length; // without a size field, we cant calculate the length sint32 calculatedSize; if (type == TYPE_SYN) { if (length < (0xB + 0x4 + 2)) return 0; - uint16 payloadSize = *(uint16*)(data+0xB+0x4); + uint16 payloadSize = *(uint16*)(data + 0xB + 0x4); calculatedSize = 0xB + 0x4 + 2 + (sint32)payloadSize + 1; // base header + connection signature (SYN param) + payloadSize field + checksum after payload if (calculatedSize > length) return 0; @@ -212,7 +196,7 @@ sint32 prudpPacket::calculateSizeFromPacketData(uint8* data, sint32 length) return length; } -prudpPacket::prudpPacket(prudpStreamSettings_t* streamSettings, uint8 src, uint8 dst, uint8 type, uint16 flags, uint8 sessionId, uint16 sequenceId, uint32 packetSignature) +prudpPacket::prudpPacket(prudpStreamSettings* streamSettings, uint8 src, uint8 dst, uint8 type, uint16 flags, uint8 sessionId, uint16 sequenceId, uint32 packetSignature) { this->src = src; this->dst = dst; @@ -228,7 +212,7 @@ prudpPacket::prudpPacket(prudpStreamSettings_t* streamSettings, uint8 src, uint8 bool prudpPacket::requiresAck() { - return (flags&FLAG_NEED_ACK) != 0; + return (flags & FLAG_NEED_ACK) != 0; } sint32 prudpPacket::buildData(uint8* output, sint32 maxLength) @@ -352,7 +336,8 @@ prudpIncomingPacket::prudpIncomingPacket() streamSettings = nullptr; } -prudpIncomingPacket::prudpIncomingPacket(prudpStreamSettings_t* streamSettings, uint8* data, sint32 length) : prudpIncomingPacket() +prudpIncomingPacket::prudpIncomingPacket(prudpStreamSettings* streamSettings, uint8* data, sint32 length) + : prudpIncomingPacket() { if (length < 0xB + 1) { @@ -418,7 +403,7 @@ prudpIncomingPacket::prudpIncomingPacket(prudpStreamSettings_t* streamSettings, bool hasPayloadSize = (this->flags & prudpPacket::FLAG_HAS_SIZE) != 0; // verify length - if ((length-readIndex) < 1+(hasPayloadSize?2:0)) + if ((length - readIndex) < 1 + (hasPayloadSize ? 2 : 0)) { // too short isInvalid = true; @@ -475,57 +460,45 @@ void prudpIncomingPacket::decrypt() RC4_transform(&streamSettings->rc4Server, &packetData.front(), (int)packetData.size(), &packetData.front()); } -#define PRUDP_VPORT(__streamType, __port) (((__streamType)<<4) | (__port)) +#define PRUDP_VPORT(__streamType, __port) (((__streamType) << 4) | (__port)) prudpClient::prudpClient() { - currentConnectionState = STATE_CONNECTING; - serverConnectionSignature = 0; - clientConnectionSignature = 0; - hasSentCon = false; - outgoingSequenceId = 0; - incomingSequenceId = 0; + m_currentConnectionState = ConnectionState::Connecting; + m_serverConnectionSignature = 0; + m_clientConnectionSignature = 0; + m_incomingSequenceId = 0; - clientSessionId = 0; - serverSessionId = 0; - - isSecureConnection = false; + m_clientSessionId = 0; + m_serverSessionId = 0; } -prudpClient::~prudpClient() +prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) + : prudpClient() { - if (srcPort != 0) - { - releasePRUDPPort(srcPort); - closesocket(socketUdp); - } -} - -prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) : prudpClient() -{ - this->dstIp = dstIp; - this->dstPort = dstPort; + m_dstIp = dstIp; + m_dstPort = dstPort; // get unused random source port for (sint32 tries = 0; tries < 5; tries++) { - srcPort = getRandomSrcPRUDPPort(); + m_srcPort = AllocateRandomSrcPRUDPPort(); // create and bind udp socket - socketUdp = socket(AF_INET, SOCK_DGRAM, 0); + m_socketUdp = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in udpServer; udpServer.sin_family = AF_INET; udpServer.sin_addr.s_addr = INADDR_ANY; - udpServer.sin_port = htons(srcPort); - if (bind(socketUdp, (struct sockaddr *)&udpServer, sizeof(udpServer)) == SOCKET_ERROR) + udpServer.sin_port = htons(m_srcPort); + if (bind(m_socketUdp, (struct sockaddr*)&udpServer, sizeof(udpServer)) == SOCKET_ERROR) { + ReleasePRUDPSrcPort(m_srcPort); + m_srcPort = 0; if (tries == 4) { cemuLog_log(LogType::Force, "PRUDP: Failed to bind UDP socket"); - currentConnectionState = STATE_DISCONNECTED; - srcPort = 0; + m_currentConnectionState = ConnectionState::Disconnected; return; } - releasePRUDPPort(srcPort); - closesocket(socketUdp); + closesocket(m_socketUdp); continue; } else @@ -533,79 +506,77 @@ prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) : prudpC } // set socket to non-blocking mode #if BOOST_OS_WINDOWS - u_long nonBlockingMode = 1; // 1 to enable non-blocking socket - ioctlsocket(socketUdp, FIONBIO, &nonBlockingMode); + u_long nonBlockingMode = 1; // 1 to enable non-blocking socket + ioctlsocket(m_socketUdp, FIONBIO, &nonBlockingMode); #else int flags = fcntl(socketUdp, F_GETFL); fcntl(socketUdp, F_SETFL, flags | O_NONBLOCK); #endif // generate frequently used parameters - this->vport_src = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0xF); - this->vport_dst = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0x1); + this->m_srcVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0xF); + this->m_dstVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0x1); // set stream settings uint8 checksumBase = 0; for (sint32 i = 0; key[i] != '\0'; i++) { checksumBase += key[i]; } - streamSettings.checksumBase = checksumBase; + m_streamSettings.checksumBase = checksumBase; MD5_CTX md5Ctx; MD5_Init(&md5Ctx); MD5_Update(&md5Ctx, key, (int)strlen(key)); - MD5_Final(streamSettings.accessKeyDigest, &md5Ctx); + MD5_Final(m_streamSettings.accessKeyDigest, &md5Ctx); // init stream ciphers - RC4_initCtx(&streamSettings.rc4Server, "CD&ML"); - RC4_initCtx(&streamSettings.rc4Client, "CD&ML"); + RC4_initCtx(&m_streamSettings.rc4Server, "CD&ML"); + RC4_initCtx(&m_streamSettings.rc4Client, "CD&ML"); // send syn packet - prudpPacket* synPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_SYN, prudpPacket::FLAG_NEED_ACK, 0, 0, 0); - queuePacket(synPacket, dstIp, dstPort); - outgoingSequenceId++; + SendCurrentHandshakePacket(); // set incoming sequence id to 1 - incomingSequenceId = 1; + m_incomingSequenceId = 1; } -prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key, authServerInfo_t* authInfo) : prudpClient(dstIp, dstPort, key) +prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key, prudpAuthServerInfo* authInfo) + : prudpClient(dstIp, dstPort, key) { - RC4_initCtx(&streamSettings.rc4Server, authInfo->secureKey, 16); - RC4_initCtx(&streamSettings.rc4Client, authInfo->secureKey, 16); - this->isSecureConnection = true; - memcpy(&this->authInfo, authInfo, sizeof(authServerInfo_t)); + RC4_initCtx(&m_streamSettings.rc4Server, authInfo->secureKey, 16); + RC4_initCtx(&m_streamSettings.rc4Client, authInfo->secureKey, 16); + this->m_isSecureConnection = true; + memcpy(&this->m_authInfo, authInfo, sizeof(prudpAuthServerInfo)); } -bool prudpClient::isConnected() +prudpClient::~prudpClient() { - return currentConnectionState == STATE_CONNECTED; + if (m_srcPort != 0) + { + ReleasePRUDPSrcPort(m_srcPort); + closesocket(m_socketUdp); + } } -uint8 prudpClient::getConnectionState() +void prudpClient::AcknowledgePacket(uint16 sequenceId) { - return currentConnectionState; -} - -void prudpClient::acknowledgePacket(uint16 sequenceId) -{ - auto it = std::begin(list_packetsWithAckReq); - while (it != std::end(list_packetsWithAckReq)) + auto it = std::begin(m_dataPacketsWithAckReq); + while (it != std::end(m_dataPacketsWithAckReq)) { if (it->packet->GetSequenceId() == sequenceId) { delete it->packet; - list_packetsWithAckReq.erase(it); + m_dataPacketsWithAckReq.erase(it); return; } it++; } } -void prudpClient::sortIncomingDataPacket(prudpIncomingPacket* incomingPacket) +void prudpClient::SortIncomingDataPacket(std::unique_ptr<prudpIncomingPacket> incomingPacket) { uint16 sequenceIdIncomingPacket = incomingPacket->sequenceId; // find insert index sint32 insertIndex = 0; - while (insertIndex < queue_incomingPackets.size() ) + while (insertIndex < m_incomingPacketQueue.size()) { - uint16 seqDif = sequenceIdIncomingPacket - queue_incomingPackets[insertIndex]->sequenceId; - if (seqDif&0x8000) + uint16 seqDif = sequenceIdIncomingPacket - m_incomingPacketQueue[insertIndex]->sequenceId; + if (seqDif & 0x8000) break; // negative seqDif -> insert before current element #ifdef CEMU_DEBUG_ASSERT if (seqDif == 0) @@ -613,39 +584,83 @@ void prudpClient::sortIncomingDataPacket(prudpIncomingPacket* incomingPacket) #endif insertIndex++; } - // insert - sint32 currentSize = (sint32)queue_incomingPackets.size(); - queue_incomingPackets.resize(currentSize+1); - for(sint32 i=currentSize; i>insertIndex; i--) + m_incomingPacketQueue.insert(m_incomingPacketQueue.begin() + insertIndex, std::move(incomingPacket)); + // debug check if packets are really ordered by sequence id +#ifdef CEMU_DEBUG_ASSERT + for (sint32 i = 1; i < m_incomingPacketQueue.size(); i++) { - queue_incomingPackets[i] = queue_incomingPackets[i - 1]; + uint16 seqDif = m_incomingPacketQueue[i]->sequenceId - m_incomingPacketQueue[i - 1]->sequenceId; + if (seqDif & 0x8000) + seqDif = -seqDif; + if (seqDif >= 0x8000) + assert_dbg(); } - queue_incomingPackets[insertIndex] = incomingPacket; +#endif } -sint32 prudpClient::kerberosEncryptData(uint8* input, sint32 length, uint8* output) +sint32 prudpClient::KerberosEncryptData(uint8* input, sint32 length, uint8* output) { - RC4Ctx_t rc4Kerberos; - RC4_initCtx(&rc4Kerberos, this->authInfo.secureKey, 16); + RC4Ctx rc4Kerberos; + RC4_initCtx(&rc4Kerberos, this->m_authInfo.secureKey, 16); memcpy(output, input, length); RC4_transform(&rc4Kerberos, output, length, output); // calculate and append hmac - hmacMD5(this->authInfo.secureKey, 16, output, length, output+length); + hmacMD5(this->m_authInfo.secureKey, 16, output, length, output + length); return length + 16; } -void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) +// (re)sends either CON or SYN based on what stage of the login we are at +// the sequenceId for both is hardcoded for both because we'll never send anything in between +void prudpClient::SendCurrentHandshakePacket() { - if(incomingPacket->type == prudpPacket::TYPE_PING) + if (!m_hasSynAck) { - if (incomingPacket->flags&prudpPacket::FLAG_ACK) + // send syn (with a fixed sequenceId of 0) + prudpPacket synPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_SYN, prudpPacket::FLAG_NEED_ACK, 0, 0, 0); + DirectSendPacket(&synPacket); + } + else + { + // send con (with a fixed sequenceId of 1) + prudpPacket conPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_CON, prudpPacket::FLAG_NEED_ACK | prudpPacket::FLAG_RELIABLE, this->m_clientSessionId, 1, m_serverConnectionSignature); + if (this->m_isSecureConnection) + { + uint8 tempBuffer[512]; + nexPacketBuffer conData(tempBuffer, sizeof(tempBuffer), true); + conData.writeU32(this->m_clientConnectionSignature); + conData.writeBuffer(m_authInfo.secureTicket, m_authInfo.secureTicketLength); + // encrypted request data + uint8 requestData[4 * 3]; + uint8 requestDataEncrypted[4 * 3 + 0x10]; + *(uint32*)(requestData + 0x0) = m_authInfo.userPid; + *(uint32*)(requestData + 0x4) = m_authInfo.server.cid; + *(uint32*)(requestData + 0x8) = prudp_generateRandomU32(); // todo - check value + sint32 encryptedSize = KerberosEncryptData(requestData, sizeof(requestData), requestDataEncrypted); + conData.writeBuffer(requestDataEncrypted, encryptedSize); + conPacket.setData(conData.getDataPtr(), conData.getWriteIndex()); + } + else + { + conPacket.setData((uint8*)&this->m_clientConnectionSignature, sizeof(uint32)); + } + DirectSendPacket(&conPacket); + } + m_lastHandshakeTimestamp = prudpGetMSTimestamp(); + m_handshakeRetryCount++; +} + +void prudpClient::HandleIncomingPacket(std::unique_ptr<prudpIncomingPacket> incomingPacket) +{ + if (incomingPacket->type == prudpPacket::TYPE_PING) + { + if (incomingPacket->flags & prudpPacket::FLAG_ACK) { // ack for our ping packet - if(incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + if (incomingPacket->flags & prudpPacket::FLAG_NEED_ACK) cemuLog_log(LogType::PRUDP, "[PRUDP] Received unexpected ping packet with both ACK and NEED_ACK set"); - if(m_unacknowledgedPingCount > 0) + if (m_unacknowledgedPingCount > 0) { - if(incomingPacket->sequenceId == m_outgoingSequenceId_ping) + if (incomingPacket->sequenceId == m_outgoingSequenceId_ping) { cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet ACK (unacknowledged count: {})", m_unacknowledgedPingCount); m_unacknowledgedPingCount = 0; @@ -660,140 +675,127 @@ void prudpClient::handleIncomingPacket(prudpIncomingPacket* incomingPacket) cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet ACK which we dont need"); } } - else if (incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + else if (incomingPacket->flags & prudpPacket::FLAG_NEED_ACK) { // other side is asking for ping ack cemuLog_log(LogType::PRUDP, "[PRUDP] Received ping packet with NEED_ACK set. Sending ACK back"); - cemu_assert_debug(incomingPacket->packetData.empty()); // todo - echo data? - prudpPacket ackPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_ACK, this->clientSessionId, incomingPacket->sequenceId, 0); - directSendPacket(&ackPacket, dstIp, dstPort); + prudpPacket ackPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_PING, prudpPacket::FLAG_ACK, this->m_clientSessionId, incomingPacket->sequenceId, 0); + if(!incomingPacket->packetData.empty()) + ackPacket.setData(incomingPacket->packetData.data(), incomingPacket->packetData.size()); + DirectSendPacket(&ackPacket); } - delete incomingPacket; return; } - // handle general packet ACK - if (incomingPacket->flags&prudpPacket::FLAG_ACK) + else if (incomingPacket->type == prudpPacket::TYPE_SYN) { - acknowledgePacket(incomingPacket->sequenceId); - } - // special cases - if (incomingPacket->type == prudpPacket::TYPE_SYN) - { - if (hasSentCon == false && incomingPacket->hasData && incomingPacket->packetData.size() == 4) + // syn packet from server is expected to have ACK set + if (!(incomingPacket->flags & prudpPacket::FLAG_ACK)) { - this->serverConnectionSignature = *(uint32*)&incomingPacket->packetData.front(); - this->clientSessionId = prudp_generateRandomU8(); - // generate client session id - this->clientConnectionSignature = prudp_generateRandomU32(); - // send con packet - prudpPacket* conPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_CON, prudpPacket::FLAG_NEED_ACK|prudpPacket::FLAG_RELIABLE, this->clientSessionId, outgoingSequenceId, serverConnectionSignature); - outgoingSequenceId++; - - if (this->isSecureConnection) - { - // set packet specific data (client connection signature) - uint8 tempBuffer[512]; - nexPacketBuffer conData(tempBuffer, sizeof(tempBuffer), true); - conData.writeU32(this->clientConnectionSignature); - conData.writeBuffer(authInfo.secureTicket, authInfo.secureTicketLength); - // encrypted request data - uint8 requestData[4 * 3]; - uint8 requestDataEncrypted[4 * 3 + 0x10]; - *(uint32*)(requestData + 0x0) = authInfo.userPid; - *(uint32*)(requestData + 0x4) = authInfo.server.cid; - *(uint32*)(requestData + 0x8) = prudp_generateRandomU32(); // todo - check value - sint32 encryptedSize = kerberosEncryptData(requestData, sizeof(requestData), requestDataEncrypted); - conData.writeBuffer(requestDataEncrypted, encryptedSize); - conPacket->setData(conData.getDataPtr(), conData.getWriteIndex()); - } - else - { - // set packet specific data (client connection signature) - conPacket->setData((uint8*)&this->clientConnectionSignature, sizeof(uint32)); - } - // send packet - queuePacket(conPacket, dstIp, dstPort); - // remember con packet as sent - hasSentCon = true; + cemuLog_log(LogType::Force, "[PRUDP] Received SYN packet without ACK flag set"); // always log this + return; } - delete incomingPacket; + if (m_hasSynAck || !incomingPacket->hasData || incomingPacket->packetData.size() != 4) + { + // syn already acked or not a valid syn packet + cemuLog_log(LogType::PRUDP, "[PRUDP] Received unexpected SYN packet"); + return; + } + m_hasSynAck = true; + this->m_serverConnectionSignature = *(uint32*)&incomingPacket->packetData.front(); + // generate client session id and connection signature + this->m_clientSessionId = prudp_generateRandomU8(); + this->m_clientConnectionSignature = prudp_generateRandomU32(); + // send con packet + m_handshakeRetryCount = 0; + SendCurrentHandshakePacket(); return; } else if (incomingPacket->type == prudpPacket::TYPE_CON) { - // connected! - if (currentConnectionState == STATE_CONNECTING) + if (!m_hasSynAck || m_hasConAck) { - lastPingTimestamp = prudpGetMSTimestamp(); - cemu_assert_debug(serverSessionId == 0); - serverSessionId = incomingPacket->sessionId; - currentConnectionState = STATE_CONNECTED; - cemuLog_log(LogType::PRUDP, "[PRUDP] Connection established. ClientSession {:02x} ServerSession {:02x}", clientSessionId, serverSessionId); + cemuLog_log(LogType::PRUDP, "[PRUDP] Received unexpected CON packet"); + return; } - delete incomingPacket; + // make sure the packet has the ACK flag set + if (!(incomingPacket->flags & prudpPacket::FLAG_ACK)) + { + cemuLog_log(LogType::Force, "[PRUDP] Received CON packet without ACK flag set"); + return; + } + m_hasConAck = true; + m_handshakeRetryCount = 0; + cemu_assert_debug(m_currentConnectionState == ConnectionState::Connecting); + // connected! + m_lastPingTimestamp = prudpGetMSTimestamp(); + cemu_assert_debug(m_serverSessionId == 0); + m_serverSessionId = incomingPacket->sessionId; + m_currentConnectionState = ConnectionState::Connected; + cemuLog_log(LogType::PRUDP, "[PRUDP] Connection established. ClientSession {:02x} ServerSession {:02x}", m_clientSessionId, m_serverSessionId); return; } else if (incomingPacket->type == prudpPacket::TYPE_DATA) { - // send ack back if requested - if (incomingPacket->flags&prudpPacket::FLAG_NEED_ACK) + // handle ACK + if (incomingPacket->flags & prudpPacket::FLAG_ACK) { - prudpPacket ackPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, prudpPacket::FLAG_ACK, this->clientSessionId, incomingPacket->sequenceId, 0); - directSendPacket(&ackPacket, dstIp, dstPort); + AcknowledgePacket(incomingPacket->sequenceId); + if(!incomingPacket->packetData.empty()) + cemuLog_log(LogType::PRUDP, "[PRUDP] Received ACK data packet with payload"); + return; + } + // send ack back if requested + if (incomingPacket->flags & prudpPacket::FLAG_NEED_ACK) + { + prudpPacket ackPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_DATA, prudpPacket::FLAG_ACK, this->m_clientSessionId, incomingPacket->sequenceId, 0); + DirectSendPacket(&ackPacket); } // skip data packets without payload if (incomingPacket->packetData.empty()) - { - delete incomingPacket; return; - } - // verify some values - uint16 seqDist = incomingPacket->sequenceId - incomingSequenceId; + // verify sequence id + uint16 seqDist = incomingPacket->sequenceId - m_incomingSequenceId; if (seqDist >= 0xC000) { // outdated - delete incomingPacket; return; } // check if packet is already queued - for (auto& it : queue_incomingPackets) + for (auto& it : m_incomingPacketQueue) { if (it->sequenceId == incomingPacket->sequenceId) { // already queued (should check other values too, like packet type?) cemuLog_log(LogType::PRUDP, "Duplicate PRUDP packet received"); - delete incomingPacket; return; } } // put into ordered receive queue - sortIncomingDataPacket(incomingPacket); + SortIncomingDataPacket(std::move(incomingPacket)); } else if (incomingPacket->type == prudpPacket::TYPE_DISCONNECT) { - currentConnectionState = STATE_DISCONNECTED; + m_currentConnectionState = ConnectionState::Disconnected; return; } else { - // ignore unknown packet - delete incomingPacket; - return; + cemuLog_log(LogType::PRUDP, "[PRUDP] Received unknown packet type"); } } -bool prudpClient::update() +bool prudpClient::Update() { - if (currentConnectionState == STATE_DISCONNECTED) + if (m_currentConnectionState == ConnectionState::Disconnected) return false; uint32 currentTimestamp = prudpGetMSTimestamp(); // check for incoming packets uint8 receiveBuffer[4096]; while (true) { - sockaddr receiveFrom = { 0 }; + sockaddr receiveFrom = {0}; socklen_t receiveFromLen = sizeof(receiveFrom); - sint32 r = recvfrom(socketUdp, (char*)receiveBuffer, sizeof(receiveBuffer), 0, &receiveFrom, &receiveFromLen); + sint32 r = recvfrom(m_socketUdp, (char*)receiveBuffer, sizeof(receiveBuffer), 0, &receiveFrom, &receiveFromLen); if (r >= 0) { // todo: Verify sender (receiveFrom) @@ -807,203 +809,195 @@ bool prudpClient::update() cemuLog_log(LogType::Force, "[PRUDP] Invalid packet length"); break; } - prudpIncomingPacket* incomingPacket = new prudpIncomingPacket(&streamSettings, receiveBuffer + pIdx, packetLength); + auto incomingPacket = std::make_unique<prudpIncomingPacket>(&m_streamSettings, receiveBuffer + pIdx, packetLength); pIdx += packetLength; if (incomingPacket->hasError()) { cemuLog_log(LogType::Force, "[PRUDP] Packet error"); - delete incomingPacket; break; } - if (incomingPacket->type != prudpPacket::TYPE_CON && incomingPacket->sessionId != serverSessionId) + if (incomingPacket->type != prudpPacket::TYPE_CON && incomingPacket->sessionId != m_serverSessionId) { cemuLog_log(LogType::PRUDP, "[PRUDP] Invalid session id"); - delete incomingPacket; continue; // different session } - handleIncomingPacket(incomingPacket); + HandleIncomingPacket(std::move(incomingPacket)); } } else break; } // check for ack timeouts - for (auto &it : list_packetsWithAckReq) + for (auto& it : m_dataPacketsWithAckReq) { if ((currentTimestamp - it.lastRetryTimestamp) >= 2300) { if (it.retryCount >= 7) { // after too many retries consider the connection dead - currentConnectionState = STATE_DISCONNECTED; + m_currentConnectionState = ConnectionState::Disconnected; } // resend - directSendPacket(it.packet, dstIp, dstPort); + DirectSendPacket(it.packet); it.lastRetryTimestamp = currentTimestamp; it.retryCount++; } } - // check if we need to send another ping - if (currentConnectionState == STATE_CONNECTED) + if (m_currentConnectionState == ConnectionState::Connecting) { - if(m_unacknowledgedPingCount != 0) // counts how many times we sent a ping packet (for the current sequenceId) without receiving an ack + // check if we need to resend SYN or CON + uint32 timeSinceLastHandshake = currentTimestamp - m_lastHandshakeTimestamp; + if (timeSinceLastHandshake >= 1200) + { + if (m_handshakeRetryCount >= 5) + { + // too many retries, assume the other side doesn't listen + m_currentConnectionState = ConnectionState::Disconnected; + cemuLog_log(LogType::PRUDP, "PRUDP: Failed to connect"); + return false; + } + SendCurrentHandshakePacket(); + } + } + else if (m_currentConnectionState == ConnectionState::Connected) + { + // handle pings + if (m_unacknowledgedPingCount != 0) // counts how many times we sent a ping packet (for the current sequenceId) without receiving an ack { // we are waiting for the ack of the previous ping, but it hasn't arrived yet so send another ping packet - if((currentTimestamp - lastPingTimestamp) >= 1500) + if ((currentTimestamp - m_lastPingTimestamp) >= 1500) { cemuLog_log(LogType::PRUDP, "[PRUDP] Resending ping packet (no ack received)"); - if(m_unacknowledgedPingCount >= 10) + if (m_unacknowledgedPingCount >= 10) { // too many unacknowledged pings, assume the connection is dead - currentConnectionState = STATE_DISCONNECTED; + m_currentConnectionState = ConnectionState::Disconnected; cemuLog_log(LogType::PRUDP, "PRUDP: Connection did not receive a ping response in a while. Assuming disconnect"); return false; } // resend the ping packet - prudpPacket* pingPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->clientSessionId, this->m_outgoingSequenceId_ping, serverConnectionSignature); - directSendPacket(pingPacket, dstIp, dstPort); + prudpPacket pingPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->m_clientSessionId, this->m_outgoingSequenceId_ping, m_serverConnectionSignature); + DirectSendPacket(&pingPacket); m_unacknowledgedPingCount++; - delete pingPacket; - lastPingTimestamp = currentTimestamp; + m_lastPingTimestamp = currentTimestamp; } } else { - if((currentTimestamp - lastPingTimestamp) >= 20000) + if ((currentTimestamp - m_lastPingTimestamp) >= 20000) { - cemuLog_log(LogType::PRUDP, "[PRUDP] Sending new ping packet with sequenceId {}", this->m_outgoingSequenceId_ping+1); + cemuLog_log(LogType::PRUDP, "[PRUDP] Sending new ping packet with sequenceId {}", this->m_outgoingSequenceId_ping + 1); // start a new ping packet with a new sequenceId. Note that ping packets have their own sequenceId and acknowledgement happens by manually comparing the incoming ping ACK against the last sent sequenceId // only one unacknowledged ping packet can be in flight at a time. We will resend the same ping packet until we receive an ack this->m_outgoingSequenceId_ping++; // increment before sending. The first ping has a sequenceId of 1 - prudpPacket* pingPacket = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->clientSessionId, this->m_outgoingSequenceId_ping, serverConnectionSignature); - directSendPacket(pingPacket, dstIp, dstPort); + prudpPacket pingPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->m_clientSessionId, this->m_outgoingSequenceId_ping, m_serverConnectionSignature); + DirectSendPacket(&pingPacket); m_unacknowledgedPingCount++; - delete pingPacket; - lastPingTimestamp = currentTimestamp; + m_lastPingTimestamp = currentTimestamp; } } } return false; } -void prudpClient::directSendPacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort) +void prudpClient::DirectSendPacket(prudpPacket* packet) { uint8 packetBuffer[prudpPacket::PACKET_RAW_SIZE_MAX]; - sint32 len = packet->buildData(packetBuffer, prudpPacket::PACKET_RAW_SIZE_MAX); - sockaddr_in destAddr; destAddr.sin_family = AF_INET; - destAddr.sin_port = htons(dstPort); - destAddr.sin_addr.s_addr = dstIp; - sendto(socketUdp, (const char*)packetBuffer, len, 0, (const sockaddr*)&destAddr, sizeof(destAddr)); + destAddr.sin_port = htons(m_dstPort); + destAddr.sin_addr.s_addr = m_dstIp; + sendto(m_socketUdp, (const char*)packetBuffer, len, 0, (const sockaddr*)&destAddr, sizeof(destAddr)); } -void prudpClient::queuePacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort) +void prudpClient::QueuePacket(prudpPacket* packet) { + cemu_assert_debug(packet->GetType() == prudpPacket::TYPE_DATA); // only data packets should be queued if (packet->requiresAck()) { - cemu_assert_debug(packet->GetType() != prudpPacket::TYPE_PING); // ping packets use their own logic for acks, dont queue them // remember this packet until we receive the ack - prudpAckRequired_t ackRequired = { 0 }; - ackRequired.packet = packet; - ackRequired.initialSendTimestamp = prudpGetMSTimestamp(); - ackRequired.lastRetryTimestamp = ackRequired.initialSendTimestamp; - list_packetsWithAckReq.push_back(ackRequired); - directSendPacket(packet, dstIp, dstPort); + m_dataPacketsWithAckReq.emplace_back(packet, prudpGetMSTimestamp()); + DirectSendPacket(packet); } else { - directSendPacket(packet, dstIp, dstPort); + DirectSendPacket(packet); delete packet; } } -void prudpClient::sendDatagram(uint8* input, sint32 length, bool reliable) +void prudpClient::SendDatagram(uint8* input, sint32 length, bool reliable) { - cemu_assert_debug(reliable); // non-reliable packets require testing - if(length >= 0x300) + cemu_assert_debug(reliable); // non-reliable packets require correct sequenceId handling and testing + cemu_assert_debug(m_hasSynAck && m_hasConAck); // cant send data packets before we are connected + if (length >= 0x300) { - cemuLog_logOnce(LogType::Force, "PRUDP: Datagram too long"); + cemuLog_logOnce(LogType::Force, "PRUDP: Datagram too long. Fragmentation not implemented yet"); } // single fragment data packet uint16 flags = prudpPacket::FLAG_NEED_ACK; - if(reliable) + if (reliable) flags |= prudpPacket::FLAG_RELIABLE; - prudpPacket* packet = new prudpPacket(&streamSettings, vport_src, vport_dst, prudpPacket::TYPE_DATA, flags, clientSessionId, outgoingSequenceId, 0); - if(reliable) - outgoingSequenceId++; + prudpPacket* packet = new prudpPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_DATA, flags, m_clientSessionId, m_outgoingReliableSequenceId, 0); + if (reliable) + m_outgoingReliableSequenceId++; packet->setFragmentIndex(0); packet->setData(input, length); - queuePacket(packet, dstIp, dstPort); + QueuePacket(packet); } -uint16 prudpClient::getSourcePort() +sint32 prudpClient::ReceiveDatagram(std::vector<uint8>& outputBuffer) { - return this->srcPort; -} - -SOCKET prudpClient::getSocket() -{ - if (currentConnectionState == STATE_DISCONNECTED) - { - return INVALID_SOCKET; - } - return this->socketUdp; -} - -sint32 prudpClient::receiveDatagram(std::vector<uint8>& outputBuffer) -{ - if (queue_incomingPackets.empty()) + outputBuffer.clear(); + if (m_incomingPacketQueue.empty()) return -1; - prudpIncomingPacket* incomingPacket = queue_incomingPackets[0]; - if (incomingPacket->sequenceId != this->incomingSequenceId) + prudpIncomingPacket* frontPacket = m_incomingPacketQueue[0].get(); + if (frontPacket->sequenceId != this->m_incomingSequenceId) return -1; - - if (incomingPacket->fragmentIndex == 0) + if (frontPacket->fragmentIndex == 0) { // single-fragment packet // decrypt - incomingPacket->decrypt(); + frontPacket->decrypt(); // read data - sint32 datagramLen = (sint32)incomingPacket->packetData.size(); - if (datagramLen > 0) + if (!frontPacket->packetData.empty()) { - // resize buffer if necessary - if (datagramLen > outputBuffer.size()) - outputBuffer.resize(datagramLen); - // to conserve memory we will also shrink the buffer if it was previously extended beyond 64KB - constexpr size_t BUFFER_TARGET_SIZE = 1024 * 64; - if (datagramLen < BUFFER_TARGET_SIZE && outputBuffer.size() > BUFFER_TARGET_SIZE) + // to conserve memory we will also shrink the buffer if it was previously extended beyond 32KB + constexpr size_t BUFFER_TARGET_SIZE = 1024 * 32; + if (frontPacket->packetData.size() < BUFFER_TARGET_SIZE && outputBuffer.capacity() > BUFFER_TARGET_SIZE) + { outputBuffer.resize(BUFFER_TARGET_SIZE); - // copy datagram to buffer - memcpy(outputBuffer.data(), &incomingPacket->packetData.front(), datagramLen); + outputBuffer.shrink_to_fit(); + outputBuffer.clear(); + } + // write packet data to output buffer + cemu_assert_debug(outputBuffer.empty()); + outputBuffer.insert(outputBuffer.end(), frontPacket->packetData.begin(), frontPacket->packetData.end()); } - delete incomingPacket; - // remove packet from queue - queue_incomingPackets.erase(queue_incomingPackets.begin()); + m_incomingPacketQueue.erase(m_incomingPacketQueue.begin()); // advance expected sequence id - this->incomingSequenceId++; - return datagramLen; + this->m_incomingSequenceId++; + return (sint32)outputBuffer.size(); } else { // multi-fragment packet - if (incomingPacket->fragmentIndex != 1) + if (frontPacket->fragmentIndex != 1) return -1; // first packet of the chain not received yet // verify chain sint32 packetIndex = 1; sint32 chainLength = -1; // if full chain found, set to count of packets - for(sint32 i=1; i<queue_incomingPackets.size(); i++) + for (sint32 i = 1; i < m_incomingPacketQueue.size(); i++) { - uint8 itFragmentIndex = queue_incomingPackets[packetIndex]->fragmentIndex; + uint8 itFragmentIndex = m_incomingPacketQueue[packetIndex]->fragmentIndex; // sequence id must increase by 1 for every packet - if (queue_incomingPackets[packetIndex]->sequenceId != (this->incomingSequenceId+i) ) + if (m_incomingPacketQueue[packetIndex]->sequenceId != (m_incomingSequenceId + i)) return -1; // missing packets // last fragment in chain is marked by fragment index 0 if (itFragmentIndex == 0) { - chainLength = i+1; + chainLength = i + 1; break; } packetIndex++; @@ -1011,29 +1005,17 @@ sint32 prudpClient::receiveDatagram(std::vector<uint8>& outputBuffer) if (chainLength < 1) return -1; // chain not complete // extract data from packet chain - sint32 writeIndex = 0; + cemu_assert_debug(outputBuffer.empty()); for (sint32 i = 0; i < chainLength; i++) { - incomingPacket = queue_incomingPackets[i]; - // decrypt + prudpIncomingPacket* incomingPacket = m_incomingPacketQueue[i].get(); incomingPacket->decrypt(); - // extract data - sint32 datagramLen = (sint32)incomingPacket->packetData.size(); - if (datagramLen > 0) - { - // make sure output buffer can fit the data - if ((writeIndex + datagramLen) > outputBuffer.size()) - outputBuffer.resize(writeIndex + datagramLen + 4 * 1024); - memcpy(outputBuffer.data()+writeIndex, &incomingPacket->packetData.front(), datagramLen); - writeIndex += datagramLen; - } - // free packet memory - delete incomingPacket; + outputBuffer.insert(outputBuffer.end(), incomingPacket->packetData.begin(), incomingPacket->packetData.end()); } // remove packets from queue - queue_incomingPackets.erase(queue_incomingPackets.begin(), queue_incomingPackets.begin() + chainLength); - this->incomingSequenceId += chainLength; - return writeIndex; + m_incomingPacketQueue.erase(m_incomingPacketQueue.begin(), m_incomingPacketQueue.begin() + chainLength); + m_incomingSequenceId += chainLength; + return (sint32)outputBuffer.size(); } return -1; } diff --git a/src/Cemu/nex/prudp.h b/src/Cemu/nex/prudp.h index 5ed5bcb1..3192c833 100644 --- a/src/Cemu/nex/prudp.h +++ b/src/Cemu/nex/prudp.h @@ -4,26 +4,26 @@ #define RC4_N 256 -typedef struct +struct RC4Ctx { unsigned char S[RC4_N]; int i; int j; -}RC4Ctx_t; +}; -void RC4_initCtx(RC4Ctx_t* rc4Ctx, char *key); -void RC4_initCtx(RC4Ctx_t* rc4Ctx, unsigned char* key, int keyLen); -void RC4_transform(RC4Ctx_t* rc4Ctx, unsigned char* input, int len, unsigned char* output); +void RC4_initCtx(RC4Ctx* rc4Ctx, const char* key); +void RC4_initCtx(RC4Ctx* rc4Ctx, unsigned char* key, int keyLen); +void RC4_transform(RC4Ctx* rc4Ctx, unsigned char* input, int len, unsigned char* output); -typedef struct +struct prudpStreamSettings { uint8 checksumBase; // calculated from key uint8 accessKeyDigest[16]; // MD5 hash of key - RC4Ctx_t rc4Client; - RC4Ctx_t rc4Server; -}prudpStreamSettings_t; + RC4Ctx rc4Client; + RC4Ctx rc4Server; +}; -typedef struct +struct prudpStationUrl { uint32 ip; uint16 port; @@ -32,19 +32,17 @@ typedef struct sint32 sid; sint32 stream; sint32 type; -}stationUrl_t; +}; -typedef struct +struct prudpAuthServerInfo { uint32 userPid; uint8 secureKey[16]; uint8 kerberosKey[16]; uint8 secureTicket[1024]; sint32 secureTicketLength; - stationUrl_t server; -}authServerInfo_t; - -uint8 prudp_calculateChecksum(uint8 checksumBase, uint8* data, sint32 length); + prudpStationUrl server; +}; class prudpPacket { @@ -66,7 +64,7 @@ public: static sint32 calculateSizeFromPacketData(uint8* data, sint32 length); - prudpPacket(prudpStreamSettings_t* streamSettings, uint8 src, uint8 dst, uint8 type, uint16 flags, uint8 sessionId, uint16 sequenceId, uint32 packetSignature); + prudpPacket(prudpStreamSettings* streamSettings, uint8 src, uint8 dst, uint8 type, uint16 flags, uint8 sessionId, uint16 sequenceId, uint32 packetSignature); bool requiresAck(); void setData(uint8* data, sint32 length); void setFragmentIndex(uint8 fragmentIndex); @@ -87,7 +85,7 @@ private: uint16 flags; uint8 sessionId; uint32 specifiedPacketSignature; - prudpStreamSettings_t* streamSettings; + prudpStreamSettings* streamSettings; std::vector<uint8> packetData; bool isEncrypted; uint16 m_sequenceId{0}; @@ -97,7 +95,7 @@ private: class prudpIncomingPacket { public: - prudpIncomingPacket(prudpStreamSettings_t* streamSettings, uint8* data, sint32 length); + prudpIncomingPacket(prudpStreamSettings* streamSettings, uint8* data, sint32 length); bool hasError(); @@ -122,83 +120,91 @@ public: private: bool isInvalid = false; - prudpStreamSettings_t* streamSettings = nullptr; - + prudpStreamSettings* streamSettings = nullptr; }; -typedef struct -{ - prudpPacket* packet; - uint32 initialSendTimestamp; - uint32 lastRetryTimestamp; - sint32 retryCount; -}prudpAckRequired_t; - class prudpClient { + struct PacketWithAckRequired + { + PacketWithAckRequired(prudpPacket* packet, uint32 initialSendTimestamp) : + packet(packet), initialSendTimestamp(initialSendTimestamp), lastRetryTimestamp(initialSendTimestamp) { } + prudpPacket* packet; + uint32 initialSendTimestamp; + uint32 lastRetryTimestamp; + sint32 retryCount{0}; + }; public: - static const int STATE_CONNECTING = 0; - static const int STATE_CONNECTED = 1; - static const int STATE_DISCONNECTED = 2; + enum class ConnectionState : uint8 + { + Connecting, + Connected, + Disconnected + }; -public: prudpClient(uint32 dstIp, uint16 dstPort, const char* key); - prudpClient(uint32 dstIp, uint16 dstPort, const char* key, authServerInfo_t* authInfo); + prudpClient(uint32 dstIp, uint16 dstPort, const char* key, prudpAuthServerInfo* authInfo); ~prudpClient(); - bool isConnected(); + bool IsConnected() const { return m_currentConnectionState == ConnectionState::Connected; } + ConnectionState GetConnectionState() const { return m_currentConnectionState; } + uint16 GetSourcePort() const { return m_srcPort; } - uint8 getConnectionState(); - void acknowledgePacket(uint16 sequenceId); - void sortIncomingDataPacket(prudpIncomingPacket* incomingPacket); - void handleIncomingPacket(prudpIncomingPacket* incomingPacket); - bool update(); // check for new incoming packets, returns true if receiveDatagram() should be called + bool Update(); // update connection state and check for incoming packets. Returns true if ReceiveDatagram() should be called - sint32 receiveDatagram(std::vector<uint8>& outputBuffer); - void sendDatagram(uint8* input, sint32 length, bool reliable = true); - - uint16 getSourcePort(); - - SOCKET getSocket(); + sint32 ReceiveDatagram(std::vector<uint8>& outputBuffer); + void SendDatagram(uint8* input, sint32 length, bool reliable = true); private: prudpClient(); - void directSendPacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort); - sint32 kerberosEncryptData(uint8* input, sint32 length, uint8* output); - void queuePacket(prudpPacket* packet, uint32 dstIp, uint16 dstPort); + + void HandleIncomingPacket(std::unique_ptr<prudpIncomingPacket> incomingPacket); + void DirectSendPacket(prudpPacket* packet); + sint32 KerberosEncryptData(uint8* input, sint32 length, uint8* output); + void QueuePacket(prudpPacket* packet); + + void AcknowledgePacket(uint16 sequenceId); + void SortIncomingDataPacket(std::unique_ptr<prudpIncomingPacket> incomingPacket); + + void SendCurrentHandshakePacket(); private: - uint16 srcPort; - uint32 dstIp; - uint16 dstPort; - uint8 vport_src; - uint8 vport_dst; - prudpStreamSettings_t streamSettings; - std::vector<prudpAckRequired_t> list_packetsWithAckReq; - std::vector<prudpIncomingPacket*> queue_incomingPackets; - - // connection - uint8 currentConnectionState; - uint32 serverConnectionSignature; - uint32 clientConnectionSignature; - bool hasSentCon; - uint32 lastPingTimestamp; + uint16 m_srcPort; + uint32 m_dstIp; + uint16 m_dstPort; + uint8 m_srcVPort; + uint8 m_dstVPort; + prudpStreamSettings m_streamSettings; + std::vector<PacketWithAckRequired> m_dataPacketsWithAckReq; + std::vector<std::unique_ptr<prudpIncomingPacket>> m_incomingPacketQueue; - uint16 outgoingSequenceId; - uint16 incomingSequenceId; + // connection handshake state + bool m_hasSynAck{false}; + bool m_hasConAck{false}; + uint32 m_lastHandshakeTimestamp{0}; + uint8 m_handshakeRetryCount{0}; + + // connection + ConnectionState m_currentConnectionState; + uint32 m_serverConnectionSignature; + uint32 m_clientConnectionSignature; + uint32 m_lastPingTimestamp; + + uint16 m_outgoingReliableSequenceId{2}; // 1 is reserved for CON + uint16 m_incomingSequenceId; uint16 m_outgoingSequenceId_ping{0}; uint8 m_unacknowledgedPingCount{0}; - uint8 clientSessionId; - uint8 serverSessionId; + uint8 m_clientSessionId; + uint8 m_serverSessionId; // secure - bool isSecureConnection; - authServerInfo_t authInfo; + bool m_isSecureConnection{false}; + prudpAuthServerInfo m_authInfo; // socket - SOCKET socketUdp; + SOCKET m_socketUdp; }; uint32 prudpGetMSTimestamp(); \ No newline at end of file From 989e2b8c8c14f2cebf86d97eeca5bf7877989c96 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:11:19 +0200 Subject: [PATCH 152/314] prudp: More code cleanup + fix compile error --- src/Cemu/nex/prudp.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Cemu/nex/prudp.cpp b/src/Cemu/nex/prudp.cpp index 5c773fe7..771fe097 100644 --- a/src/Cemu/nex/prudp.cpp +++ b/src/Cemu/nex/prudp.cpp @@ -288,7 +288,7 @@ uint32 prudpPacket::packetSignature() return specifiedPacketSignature; else if (type == TYPE_DATA) { - if (packetData.size() == 0) + if (packetData.empty()) return 0x12345678; HMACMD5Ctx ctx; @@ -307,8 +307,7 @@ uint32 prudpPacket::packetSignature() void prudpPacket::setData(uint8* data, sint32 length) { - packetData.resize(length); - memcpy(&packetData.front(), data, length); + packetData.assign(data, data + length); } void prudpPacket::setFragmentIndex(uint8 fragmentIndex) @@ -509,12 +508,12 @@ prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) u_long nonBlockingMode = 1; // 1 to enable non-blocking socket ioctlsocket(m_socketUdp, FIONBIO, &nonBlockingMode); #else - int flags = fcntl(socketUdp, F_GETFL); - fcntl(socketUdp, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(m_socketUdp, F_GETFL); + fcntl(m_socketUdp, F_SETFL, flags | O_NONBLOCK); #endif // generate frequently used parameters - this->m_srcVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0xF); - this->m_dstVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0x1); + m_srcVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0xF); + m_dstVPort = PRUDP_VPORT(prudpPacket::STREAM_TYPE_SECURE, 0x1); // set stream settings uint8 checksumBase = 0; for (sint32 i = 0; key[i] != '\0'; i++) @@ -540,8 +539,8 @@ prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key, prudpAut { RC4_initCtx(&m_streamSettings.rc4Server, authInfo->secureKey, 16); RC4_initCtx(&m_streamSettings.rc4Client, authInfo->secureKey, 16); - this->m_isSecureConnection = true; - memcpy(&this->m_authInfo, authInfo, sizeof(prudpAuthServerInfo)); + m_isSecureConnection = true; + memcpy(&m_authInfo, authInfo, sizeof(prudpAuthServerInfo)); } prudpClient::~prudpClient() @@ -601,7 +600,7 @@ void prudpClient::SortIncomingDataPacket(std::unique_ptr<prudpIncomingPacket> in sint32 prudpClient::KerberosEncryptData(uint8* input, sint32 length, uint8* output) { RC4Ctx rc4Kerberos; - RC4_initCtx(&rc4Kerberos, this->m_authInfo.secureKey, 16); + RC4_initCtx(&rc4Kerberos, m_authInfo.secureKey, 16); memcpy(output, input, length); RC4_transform(&rc4Kerberos, output, length, output); // calculate and append hmac @@ -627,7 +626,7 @@ void prudpClient::SendCurrentHandshakePacket() { uint8 tempBuffer[512]; nexPacketBuffer conData(tempBuffer, sizeof(tempBuffer), true); - conData.writeU32(this->m_clientConnectionSignature); + conData.writeU32(m_clientConnectionSignature); conData.writeBuffer(m_authInfo.secureTicket, m_authInfo.secureTicketLength); // encrypted request data uint8 requestData[4 * 3]; @@ -641,7 +640,7 @@ void prudpClient::SendCurrentHandshakePacket() } else { - conPacket.setData((uint8*)&this->m_clientConnectionSignature, sizeof(uint32)); + conPacket.setData((uint8*)&m_clientConnectionSignature, sizeof(uint32)); } DirectSendPacket(&conPacket); } @@ -889,7 +888,7 @@ bool prudpClient::Update() cemuLog_log(LogType::PRUDP, "[PRUDP] Sending new ping packet with sequenceId {}", this->m_outgoingSequenceId_ping + 1); // start a new ping packet with a new sequenceId. Note that ping packets have their own sequenceId and acknowledgement happens by manually comparing the incoming ping ACK against the last sent sequenceId // only one unacknowledged ping packet can be in flight at a time. We will resend the same ping packet until we receive an ack - this->m_outgoingSequenceId_ping++; // increment before sending. The first ping has a sequenceId of 1 + m_outgoingSequenceId_ping++; // increment before sending. The first ping has a sequenceId of 1 prudpPacket pingPacket(&m_streamSettings, m_srcVPort, m_dstVPort, prudpPacket::TYPE_PING, prudpPacket::FLAG_NEED_ACK, this->m_clientSessionId, this->m_outgoingSequenceId_ping, m_serverConnectionSignature); DirectSendPacket(&pingPacket); m_unacknowledgedPingCount++; From efbbb817fe1cbe09ee132344b44a0f61f8b8ac96 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:19:06 +0200 Subject: [PATCH 153/314] DownloadManager: Always use Nintendo servers + additional streamlining - Download manager now always uses Nintendo servers. Requires only a valid OTP and SEEPROM dump so you can use it in combination with a Pretendo setup even without a NNID - Account drop down removed from download manager since it's not required - Internally all our API requests now support overriding which service to use - Drop support for act-url and ecs-url command line parameters. Usage of network_services.xml ("custom" option in the UI) is preferred --- src/Cafe/IOSU/legacy/iosu_boss.cpp | 2 +- src/Cafe/IOSU/legacy/iosu_crypto.cpp | 10 - src/Cafe/IOSU/legacy/iosu_crypto.h | 1 - src/Cafe/IOSU/legacy/iosu_nim.cpp | 2 +- src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp | 2 +- .../nn_olv/nn_olv_DownloadCommunityTypes.cpp | 2 +- .../OS/libs/nn_olv/nn_olv_InitializeTypes.cpp | 2 +- .../nn_olv/nn_olv_UploadCommunityTypes.cpp | 2 +- .../nn_olv/nn_olv_UploadFavoriteTypes.cpp | 2 +- .../Tools/DownloadManager/DownloadManager.cpp | 130 ++++------ .../Tools/DownloadManager/DownloadManager.h | 16 +- src/Cemu/napi/napi.h | 23 +- src/Cemu/napi/napi_act.cpp | 49 ++-- src/Cemu/napi/napi_ec.cpp | 229 +++++++++--------- src/Cemu/napi/napi_helper.cpp | 24 +- src/Cemu/napi/napi_helper.h | 4 +- src/Cemu/napi/napi_idbe.cpp | 10 +- src/Cemu/napi/napi_version.cpp | 6 +- src/Cemu/ncrypto/ncrypto.cpp | 18 +- src/Cemu/ncrypto/ncrypto.h | 4 + src/config/ActiveSettings.cpp | 1 - src/config/LaunchSettings.cpp | 37 +-- src/config/LaunchSettings.h | 10 - src/config/NetworkSettings.cpp | 3 - src/config/NetworkSettings.h | 27 ++- src/gui/CemuApp.cpp | 2 +- src/gui/GeneralSettings2.cpp | 8 +- src/gui/TitleManager.cpp | 33 ++- src/gui/TitleManager.h | 2 + 29 files changed, 323 insertions(+), 338 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_boss.cpp b/src/Cafe/IOSU/legacy/iosu_boss.cpp index c2c1eb51..760e5b66 100644 --- a/src/Cafe/IOSU/legacy/iosu_boss.cpp +++ b/src/Cafe/IOSU/legacy/iosu_boss.cpp @@ -498,7 +498,7 @@ namespace iosu curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, task_header_callback); curl_easy_setopt(curl, CURLOPT_HEADERDATA, &(*it)); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 0x3C); - if (GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() == NetworkService::Custom || ActiveSettings::GetNetworkService() == NetworkService::Pretendo) // remove Pretendo Function once SSL is in the Service + if (IsNetworkServiceSSLDisabled(ActiveSettings::GetNetworkService())) { curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,0L); } diff --git a/src/Cafe/IOSU/legacy/iosu_crypto.cpp b/src/Cafe/IOSU/legacy/iosu_crypto.cpp index 80eb2f01..a4f75430 100644 --- a/src/Cafe/IOSU/legacy/iosu_crypto.cpp +++ b/src/Cafe/IOSU/legacy/iosu_crypto.cpp @@ -292,16 +292,6 @@ void iosuCrypto_generateDeviceCertificate() BN_CTX_free(context); } -bool iosuCrypto_hasAllDataForLogin() -{ - if (hasOtpMem == false) - return false; - if (hasSeepromMem == false) - return false; - // todo - check if certificates are available - return true; -} - sint32 iosuCrypto_getDeviceCertificateBase64Encoded(char* output) { iosuCrypto_base64Encode((uint8*)&g_wiiuDeviceCert, sizeof(g_wiiuDeviceCert), output); diff --git a/src/Cafe/IOSU/legacy/iosu_crypto.h b/src/Cafe/IOSU/legacy/iosu_crypto.h index 9f1429c7..d4fc49b9 100644 --- a/src/Cafe/IOSU/legacy/iosu_crypto.h +++ b/src/Cafe/IOSU/legacy/iosu_crypto.h @@ -2,7 +2,6 @@ void iosuCrypto_init(); -bool iosuCrypto_hasAllDataForLogin(); bool iosuCrypto_getDeviceId(uint32* deviceId); void iosuCrypto_getDeviceSerialString(char* serialString); diff --git a/src/Cafe/IOSU/legacy/iosu_nim.cpp b/src/Cafe/IOSU/legacy/iosu_nim.cpp index e7cf97ef..b529640d 100644 --- a/src/Cafe/IOSU/legacy/iosu_nim.cpp +++ b/src/Cafe/IOSU/legacy/iosu_nim.cpp @@ -228,7 +228,7 @@ namespace iosu } } - auto result = NAPI::IDBE_Request(titleId); + auto result = NAPI::IDBE_Request(ActiveSettings::GetNetworkService(), titleId); if (!result) { memset(idbeIconOutput, 0, sizeof(NAPI::IDBEIconDataV0)); diff --git a/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp b/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp index a78494cf..a69f32a3 100644 --- a/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp +++ b/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp @@ -42,7 +42,7 @@ namespace nn void asyncDownloadIconFile(uint64 titleId, nnIdbeEncryptedIcon_t* iconOut, OSThread_t* thread) { - std::vector<uint8> idbeData = NAPI::IDBE_RequestRawEncrypted(titleId); + std::vector<uint8> idbeData = NAPI::IDBE_RequestRawEncrypted(ActiveSettings::GetNetworkService(), titleId); if (idbeData.size() != sizeof(nnIdbeEncryptedIcon_t)) { // icon does not exist or has the wrong size diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp index 1bf2b37d..db1885af 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_DownloadCommunityTypes.cpp @@ -43,7 +43,7 @@ namespace nn return res; CurlRequestHelper req; - req.initate(reqUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); + req.initate(ActiveSettings::GetNetworkService(), reqUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); InitializeOliveRequest(req); StackAllocator<coreinit::OSEvent> requestDoneEvent; diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp index 5e6dba7e..ba657ff7 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_InitializeTypes.cpp @@ -195,7 +195,7 @@ namespace nn break; } - req.initate(requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); + req.initate(ActiveSettings::GetNetworkService(), requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); InitializeOliveRequest(req); StackAllocator<coreinit::OSEvent> requestDoneEvent; diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp index 179d66bd..6f3c43b9 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadCommunityTypes.cpp @@ -50,7 +50,7 @@ namespace nn CurlRequestHelper req; - req.initate(requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); + req.initate(ActiveSettings::GetNetworkService(), requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); InitializeOliveRequest(req); StackAllocator<coreinit::OSEvent> requestDoneEvent; diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp index 307004b9..1e2d40ab 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_UploadFavoriteTypes.cpp @@ -40,7 +40,7 @@ namespace nn snprintf(requestUrl, sizeof(requestUrl), "%s/v1/communities/%lu.favorite", g_DiscoveryResults.apiEndpoint, pParam->communityId.value()); CurlRequestHelper req; - req.initate(requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); + req.initate(ActiveSettings::GetNetworkService(), requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::OLIVE); InitializeOliveRequest(req); StackAllocator<coreinit::OSEvent> requestDoneEvent; diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index 807a4e72..9e683ed1 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -33,14 +33,7 @@ void DownloadManager::downloadTitleVersionList() { if (m_hasTitleVersionList) return; - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; + NAPI::AuthInfo authInfo = GetAuthInfo(false); auto versionListVersionResult = NAPI::TAG_GetVersionListVersion(authInfo); if (!versionListVersionResult.isValid) return; @@ -195,15 +188,7 @@ public: bool DownloadManager::_connect_refreshIASAccountIdAndDeviceToken() { - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; - + NAPI::AuthInfo authInfo = GetAuthInfo(false); // query IAS/ECS account id and device token (if not cached) auto rChallenge = NAPI::IAS_GetChallenge(authInfo); if (rChallenge.apiError != NAPI_RESULT::SUCCESS) @@ -211,7 +196,6 @@ bool DownloadManager::_connect_refreshIASAccountIdAndDeviceToken() auto rRegistrationInfo = NAPI::IAS_GetRegistrationInfo_QueryInfo(authInfo, rChallenge.challenge); if (rRegistrationInfo.apiError != NAPI_RESULT::SUCCESS) return false; - m_iasToken.serviceAccountId = rRegistrationInfo.accountId; m_iasToken.deviceToken = rRegistrationInfo.deviceToken; // store to cache @@ -221,24 +205,13 @@ bool DownloadManager::_connect_refreshIASAccountIdAndDeviceToken() std::vector<uint8> serializedData; if (!storedTokenInfo.serialize(serializedData)) return false; - s_nupFileCache->AddFileAsync({ fmt::format("{}/token_info", m_authInfo.nnidAccountName) }, serializedData.data(), serializedData.size()); + s_nupFileCache->AddFileAsync({ fmt::format("{}/token_info", m_authInfo.cachefileName) }, serializedData.data(), serializedData.size()); return true; } bool DownloadManager::_connect_queryAccountStatusAndServiceURLs() { - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; - - authInfo.IASToken.accountId = m_iasToken.serviceAccountId; - authInfo.IASToken.deviceToken = m_iasToken.deviceToken; - + NAPI::AuthInfo authInfo = GetAuthInfo(true); NAPI::NAPI_ECSGetAccountStatus_Result accountStatusResult = NAPI::ECS_GetAccountStatus(authInfo); if (accountStatusResult.apiError != NAPI_RESULT::SUCCESS) { @@ -291,7 +264,7 @@ void DownloadManager::loadTicketCache() m_ticketCache.clear(); cemu_assert_debug(m_ticketCache.empty()); std::vector<uint8> ticketCacheBlob; - if (!s_nupFileCache->GetFile({ fmt::format("{}/eticket_cache", m_authInfo.nnidAccountName) }, ticketCacheBlob)) + if (!s_nupFileCache->GetFile({ fmt::format("{}/eticket_cache", m_authInfo.cachefileName) }, ticketCacheBlob)) return; MemStreamReader memReader(ticketCacheBlob.data(), ticketCacheBlob.size()); uint8 version = memReader.readBE<uint8>(); @@ -343,23 +316,12 @@ void DownloadManager::storeTicketCache() memWriter.writePODVector(cert); } auto serializedBlob = memWriter.getResult(); - s_nupFileCache->AddFileAsync({ fmt::format("{}/eticket_cache", m_authInfo.nnidAccountName) }, serializedBlob.data(), serializedBlob.size()); + s_nupFileCache->AddFileAsync({ fmt::format("{}/eticket_cache", m_authInfo.cachefileName) }, serializedBlob.data(), serializedBlob.size()); } bool DownloadManager::syncAccountTickets() { - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; - - authInfo.IASToken.accountId = m_iasToken.serviceAccountId; - authInfo.IASToken.deviceToken = m_iasToken.deviceToken; - + NAPI::AuthInfo authInfo = GetAuthInfo(true); // query TIV list from server NAPI::NAPI_ECSAccountListETicketIds_Result resultTicketIds = NAPI::ECS_AccountListETicketIds(authInfo); if (!resultTicketIds.isValid()) @@ -425,19 +387,7 @@ bool DownloadManager::syncAccountTickets() bool DownloadManager::syncSystemTitleTickets() { setStatusMessage(_("Downloading system tickets...").utf8_string(), DLMGR_STATUS_CODE::CONNECTING); - // todo - add GetAuth() function - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; - - authInfo.IASToken.accountId = m_iasToken.serviceAccountId; - authInfo.IASToken.deviceToken = m_iasToken.deviceToken; - + NAPI::AuthInfo authInfo = GetAuthInfo(true); auto querySystemTitleTicket = [&](uint64 titleId) -> void { // check if cached already @@ -520,8 +470,7 @@ bool DownloadManager::syncUpdateTickets() if (findTicketByTitleIdAndVersion(itr.titleId, itr.availableTitleVersion)) continue; - NAPI::AuthInfo dummyAuth; - auto cetkResult = NAPI::CCS_GetCETK(dummyAuth, itr.titleId, itr.availableTitleVersion); + auto cetkResult = NAPI::CCS_GetCETK(GetDownloadMgrNetworkService(), itr.titleId, itr.availableTitleVersion); if (!cetkResult.isValid) continue; NCrypto::ETicketParser ticketParser; @@ -657,7 +606,7 @@ void DownloadManager::_handle_connect() if (s_nupFileCache) { std::vector<uint8> serializationBlob; - if (s_nupFileCache->GetFile({ fmt::format("{}/token_info", m_authInfo.nnidAccountName) }, serializationBlob)) + if (s_nupFileCache->GetFile({ fmt::format("{}/token_info", m_authInfo.cachefileName) }, serializationBlob)) { StoredTokenInfo storedTokenInfo; if (storedTokenInfo.deserialize(serializationBlob)) @@ -683,7 +632,7 @@ void DownloadManager::_handle_connect() if (!_connect_queryAccountStatusAndServiceURLs()) { m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(_("Failed to query account status. Invalid account information?").utf8_string(), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Failed to query account status").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } // load ticket cache and sync @@ -692,7 +641,7 @@ void DownloadManager::_handle_connect() if (!syncTicketCache()) { m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(_("Failed to request tickets (invalid NNID?)").utf8_string(), DLMGR_STATUS_CODE::FAILED); + setStatusMessage(_("Failed to request tickets").utf8_string(), DLMGR_STATUS_CODE::FAILED); return; } searchForIncompleteDownloads(); @@ -713,22 +662,10 @@ void DownloadManager::connect( std::string_view serial, std::string_view deviceCertBase64) { - if (nnidAccountName.empty()) - { - m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(_("This account is not linked with an NNID").utf8_string(), DLMGR_STATUS_CODE::FAILED); - return; - } runManager(); m_authInfo.nnidAccountName = nnidAccountName; m_authInfo.passwordHash = passwordHash; - if (std::all_of(m_authInfo.passwordHash.begin(), m_authInfo.passwordHash.end(), [](uint8 v) { return v == 0; })) - { - cemuLog_log(LogType::Force, "DLMgr: Invalid password hash"); - m_connectState.store(CONNECT_STATE::FAILED); - setStatusMessage(_("Failed. Account does not have password set").utf8_string(), DLMGR_STATUS_CODE::FAILED); - return; - } + m_authInfo.cachefileName = nnidAccountName.empty() ? "DefaultName" : nnidAccountName; m_authInfo.region = region; m_authInfo.country = country; m_authInfo.deviceCertBase64 = deviceCertBase64; @@ -744,6 +681,31 @@ bool DownloadManager::IsConnected() const return m_connectState.load() != CONNECT_STATE::UNINITIALIZED; } +NetworkService DownloadManager::GetDownloadMgrNetworkService() +{ + return NetworkService::Nintendo; +} + +NAPI::AuthInfo DownloadManager::GetAuthInfo(bool withIasToken) +{ + NAPI::AuthInfo authInfo; + authInfo.serviceOverwrite = GetDownloadMgrNetworkService(); + authInfo.accountId = m_authInfo.nnidAccountName; + authInfo.passwordHash = m_authInfo.passwordHash; + authInfo.deviceId = m_authInfo.deviceId; + authInfo.serial = m_authInfo.serial; + authInfo.country = m_authInfo.country; + authInfo.region = m_authInfo.region; + authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; + if(withIasToken) + { + cemu_assert_debug(!m_iasToken.serviceAccountId.empty()); + authInfo.IASToken.accountId = m_iasToken.serviceAccountId; + authInfo.IASToken.deviceToken = m_iasToken.deviceToken; + } + return authInfo; +} + /* package / downloading */ // start/resume/retry download @@ -1022,17 +984,7 @@ void DownloadManager::reportPackageProgress(Package* package, uint32 currentProg void DownloadManager::asyncPackageDownloadTMD(Package* package) { - NAPI::AuthInfo authInfo; - authInfo.accountId = m_authInfo.nnidAccountName; - authInfo.passwordHash = m_authInfo.passwordHash; - authInfo.deviceId = m_authInfo.deviceId; - authInfo.serial = m_authInfo.serial; - authInfo.country = m_authInfo.country; - authInfo.region = m_authInfo.region; - authInfo.deviceCertBase64 = m_authInfo.deviceCertBase64; - authInfo.IASToken.accountId = m_iasToken.serviceAccountId; - authInfo.IASToken.deviceToken = m_iasToken.deviceToken; - + NAPI::AuthInfo authInfo = GetAuthInfo(true); TitleIdParser titleIdParser(package->titleId); NAPI::NAPI_CCSGetTMD_Result tmdResult; if (titleIdParser.GetType() == TitleIdParser::TITLE_TYPE::AOC) @@ -1196,7 +1148,7 @@ void DownloadManager::asyncPackageDownloadContentFile(Package* package, uint16 i setPackageError(package, _("Cannot create file").utf8_string()); return; } - if (!NAPI::CCS_GetContentFile(titleId, contentId, CallbackInfo::writeCallback, &callbackInfoData)) + if (!NAPI::CCS_GetContentFile(GetDownloadMgrNetworkService(), titleId, contentId, CallbackInfo::writeCallback, &callbackInfoData)) { setPackageError(package, _("Download failed").utf8_string()); delete callbackInfoData.fileOutput; @@ -1490,7 +1442,7 @@ void DownloadManager::prepareIDBE(uint64 titleId) if (s_nupFileCache->GetFile({ fmt::format("idbe/{0:016x}", titleId) }, idbeFile) && idbeFile.size() == sizeof(NAPI::IDBEIconDataV0)) return addToCache(titleId, (NAPI::IDBEIconDataV0*)(idbeFile.data())); // not cached, query from server - std::optional<NAPI::IDBEIconDataV0> iconData = NAPI::IDBE_Request(titleId); + std::optional<NAPI::IDBEIconDataV0> iconData = NAPI::IDBE_Request(GetDownloadMgrNetworkService(), titleId); if (!iconData) return; s_nupFileCache->AddFileAsync({ fmt::format("idbe/{0:016x}", titleId) }, (uint8*)&(*iconData), sizeof(NAPI::IDBEIconDataV0)); diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.h b/src/Cemu/Tools/DownloadManager/DownloadManager.h index 1693318c..8f693a3e 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.h +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.h @@ -2,17 +2,14 @@ #include "util/helpers/Semaphore.h" #include "Cemu/ncrypto/ncrypto.h" #include "Cafe/TitleList/TitleId.h" - #include "util/helpers/ConcurrentQueue.h" +#include "config/NetworkSettings.h" -#include <functional> -#include <optional> - -#include <future> - +// forward declarations namespace NAPI { struct IDBEIconDataV0; + struct AuthInfo; } namespace NCrypto @@ -86,7 +83,6 @@ public: bool IsConnected() const; - private: /* connect / login */ @@ -101,6 +97,7 @@ private: struct { + std::string cachefileName; std::string nnidAccountName; std::array<uint8, 32> passwordHash; std::string deviceCertBase64; @@ -122,7 +119,10 @@ private: void _handle_connect(); bool _connect_refreshIASAccountIdAndDeviceToken(); bool _connect_queryAccountStatusAndServiceURLs(); - + + NetworkService GetDownloadMgrNetworkService(); + NAPI::AuthInfo GetAuthInfo(bool withIasToken); + /* idbe cache */ public: void prepareIDBE(uint64 titleId); diff --git a/src/Cemu/napi/napi.h b/src/Cemu/napi/napi.h index ab17a7b3..e1397d62 100644 --- a/src/Cemu/napi/napi.h +++ b/src/Cemu/napi/napi.h @@ -1,6 +1,7 @@ #pragma once -#include <optional> #include "config/CemuConfig.h" // for ConsoleLanguage +#include "config/NetworkSettings.h" // for NetworkService +#include "config/ActiveSettings.h" // for GetNetworkService() enum class NAPI_RESULT { @@ -16,8 +17,6 @@ namespace NAPI // common auth info structure shared by ACT, ECS and IAS service struct AuthInfo { - // todo - constructor for account name + raw password - // nnid std::string accountId; std::array<uint8, 32> passwordHash; @@ -41,9 +40,13 @@ namespace NAPI std::string deviceToken; }IASToken; - // ACT token (for account.nintendo.net requests) - + // service selection, if not set fall back to global setting + std::optional<NetworkService> serviceOverwrite; + NetworkService GetService() const + { + return serviceOverwrite.value_or(ActiveSettings::GetNetworkService()); + } }; bool NAPI_MakeAuthInfoFromCurrentAccount(AuthInfo& authInfo); // helper function. Returns false if online credentials/dumped files are not available @@ -232,9 +235,9 @@ namespace NAPI NAPI_CCSGetTMD_Result CCS_GetTMD(AuthInfo& authInfo, uint64 titleId, uint16 titleVersion); NAPI_CCSGetTMD_Result CCS_GetTMD(AuthInfo& authInfo, uint64 titleId); - NAPI_CCSGetETicket_Result CCS_GetCETK(AuthInfo& authInfo, uint64 titleId, uint16 titleVersion); - bool CCS_GetContentFile(uint64 titleId, uint32 contentId, bool(*cbWriteCallback)(void* userData, const void* ptr, size_t len, bool isLast), void* userData); - NAPI_CCSGetContentH3_Result CCS_GetContentH3File(uint64 titleId, uint32 contentId); + NAPI_CCSGetETicket_Result CCS_GetCETK(NetworkService service, uint64 titleId, uint16 titleVersion); + bool CCS_GetContentFile(NetworkService service, uint64 titleId, uint32 contentId, bool(*cbWriteCallback)(void* userData, const void* ptr, size_t len, bool isLast), void* userData); + NAPI_CCSGetContentH3_Result CCS_GetContentH3File(NetworkService service, uint64 titleId, uint32 contentId); /* IDBE */ @@ -286,8 +289,8 @@ namespace NAPI static_assert(sizeof(IDBEHeader) == 2+32); - std::optional<IDBEIconDataV0> IDBE_Request(uint64 titleId); - std::vector<uint8> IDBE_RequestRawEncrypted(uint64 titleId); // same as IDBE_Request but doesn't strip the header and decrypt the IDBE + std::optional<IDBEIconDataV0> IDBE_Request(NetworkService networkService, uint64 titleId); + std::vector<uint8> IDBE_RequestRawEncrypted(NetworkService networkService, uint64 titleId); // same as IDBE_Request but doesn't strip the header and decrypt the IDBE /* Version list */ diff --git a/src/Cemu/napi/napi_act.cpp b/src/Cemu/napi/napi_act.cpp index 9716c41e..c72d9f47 100644 --- a/src/Cemu/napi/napi_act.cpp +++ b/src/Cemu/napi/napi_act.cpp @@ -14,6 +14,21 @@ namespace NAPI { + std::string _getACTUrl(NetworkService service) + { + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::ACTURL; + case NetworkService::Pretendo: + return PretendoURLs::ACTURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.ACT.GetValue(); + default: + return NintendoURLs::ACTURL; + } + } + struct ACTOauthToken : public _NAPI_CommonResultACT { std::string token; @@ -91,7 +106,7 @@ namespace NAPI struct OAuthTokenCacheEntry { - OAuthTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, std::string_view token, std::string_view refreshToken, uint64 expiresIn) : accountId(accountId), passwordHash(passwordHash), token(token), refreshToken(refreshToken) + OAuthTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, std::string_view token, std::string_view refreshToken, uint64 expiresIn, NetworkService service) : accountId(accountId), passwordHash(passwordHash), token(token), refreshToken(refreshToken), service(service) { expires = HighResolutionTimer::now().getTickInSeconds() + expiresIn; }; @@ -107,10 +122,10 @@ namespace NAPI } std::string accountId; std::array<uint8, 32> passwordHash; - std::string token; std::string refreshToken; uint64 expires; + NetworkService service; }; std::vector<OAuthTokenCacheEntry> g_oauthTokenCache; @@ -122,11 +137,12 @@ namespace NAPI ACTOauthToken result{}; // check cache first + NetworkService service = authInfo.GetService(); g_oauthTokenCacheMtx.lock(); auto cacheItr = g_oauthTokenCache.begin(); while (cacheItr != g_oauthTokenCache.end()) { - if (cacheItr->CheckIfSameAccount(authInfo)) + if (cacheItr->CheckIfSameAccount(authInfo) && cacheItr->service == service) { if (cacheItr->CheckIfExpired()) { @@ -145,7 +161,7 @@ namespace NAPI // token not cached, request from server via oauth2 CurlRequestHelper req; - req.initate(fmt::format("{}/v1/api/oauth20/access_token/generate", LaunchSettings::GetActURLPrefix()), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); + req.initate(authInfo.GetService(), fmt::format("{}/v1/api/oauth20/access_token/generate", _getACTUrl(authInfo.GetService())), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); _ACTSetCommonHeaderParameters(req, authInfo); _ACTSetDeviceParameters(req, authInfo); _ACTSetRegionAndCountryParameters(req, authInfo); @@ -220,7 +236,7 @@ namespace NAPI if (expiration > 0) { g_oauthTokenCacheMtx.lock(); - g_oauthTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, result.token, result.refreshToken, expiration); + g_oauthTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, result.token, result.refreshToken, expiration, service); g_oauthTokenCacheMtx.unlock(); } return result; @@ -230,14 +246,13 @@ namespace NAPI { CurlRequestHelper req; - req.initate(fmt::format("{}/v1/api/people/@me/profile", LaunchSettings::GetActURLPrefix()), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); + req.initate(authInfo.GetService(), fmt::format("{}/v1/api/people/@me/profile", _getACTUrl(authInfo.GetService())), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); _ACTSetCommonHeaderParameters(req, authInfo); _ACTSetDeviceParameters(req, authInfo); // get oauth2 token ACTOauthToken oauthToken = ACT_GetOauthToken_WithCache(authInfo, 0x0005001010001C00, 0x0001C); - cemu_assert_unimplemented(); return true; @@ -245,15 +260,16 @@ namespace NAPI struct NexTokenCacheEntry { - NexTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, uint32 gameServerId, ACTNexToken& nexToken) : accountId(accountId), passwordHash(passwordHash), nexToken(nexToken), gameServerId(gameServerId) {}; + NexTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, NetworkService networkService, uint32 gameServerId, ACTNexToken& nexToken) : accountId(accountId), passwordHash(passwordHash), networkService(networkService), nexToken(nexToken), gameServerId(gameServerId) {}; bool IsMatch(const AuthInfo& authInfo, const uint32 gameServerId) const { - return authInfo.accountId == accountId && authInfo.passwordHash == passwordHash && this->gameServerId == gameServerId; + return authInfo.accountId == accountId && authInfo.passwordHash == passwordHash && authInfo.GetService() == networkService && this->gameServerId == gameServerId; } std::string accountId; std::array<uint8, 32> passwordHash; + NetworkService networkService; uint32 gameServerId; ACTNexToken nexToken; @@ -297,7 +313,7 @@ namespace NAPI } // do request CurlRequestHelper req; - req.initate(fmt::format("{}/v1/api/provider/nex_token/@me?game_server_id={:08X}", LaunchSettings::GetActURLPrefix(), serverId), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); + req.initate(authInfo.GetService(), fmt::format("{}/v1/api/provider/nex_token/@me?game_server_id={:08X}", _getACTUrl(authInfo.GetService()), serverId), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); _ACTSetCommonHeaderParameters(req, authInfo); _ACTSetDeviceParameters(req, authInfo); _ACTSetRegionAndCountryParameters(req, authInfo); @@ -374,21 +390,21 @@ namespace NAPI result.nexToken.port = (uint16)StringHelpers::ToInt(port); result.apiError = NAPI_RESULT::SUCCESS; g_nexTokenCacheMtx.lock(); - g_nexTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, serverId, result.nexToken); + g_nexTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, authInfo.GetService(), serverId, result.nexToken); g_nexTokenCacheMtx.unlock(); return result; } struct IndependentTokenCacheEntry { - IndependentTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, std::string_view clientId, std::string_view independentToken, sint64 expiresIn) : accountId(accountId), passwordHash(passwordHash), clientId(clientId), independentToken(independentToken) + IndependentTokenCacheEntry(std::string_view accountId, std::array<uint8, 32>& passwordHash, NetworkService networkService, std::string_view clientId, std::string_view independentToken, sint64 expiresIn) : accountId(accountId), passwordHash(passwordHash), networkService(networkService), clientId(clientId), independentToken(independentToken) { expires = HighResolutionTimer::now().getTickInSeconds() + expiresIn; }; bool IsMatch(const AuthInfo& authInfo, const std::string_view clientId) const { - return authInfo.accountId == accountId && authInfo.passwordHash == passwordHash && this->clientId == clientId; + return authInfo.accountId == accountId && authInfo.passwordHash == passwordHash && authInfo.GetService() == networkService && this->clientId == clientId; } bool CheckIfExpired() const @@ -398,6 +414,7 @@ namespace NAPI std::string accountId; std::array<uint8, 32> passwordHash; + NetworkService networkService; std::string clientId; sint64 expires; @@ -449,7 +466,7 @@ namespace NAPI } // do request CurlRequestHelper req; - req.initate(fmt::format("{}/v1/api/provider/service_token/@me?client_id={}", LaunchSettings::GetActURLPrefix(), clientId), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); + req.initate(authInfo.GetService(), fmt::format("{}/v1/api/provider/service_token/@me?client_id={}", _getACTUrl(authInfo.GetService()), clientId), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); _ACTSetCommonHeaderParameters(req, authInfo); _ACTSetDeviceParameters(req, authInfo); _ACTSetRegionAndCountryParameters(req, authInfo); @@ -494,7 +511,7 @@ namespace NAPI result.apiError = NAPI_RESULT::SUCCESS; g_IndependentTokenCacheMtx.lock(); - g_IndependentTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, clientId, result.token, 3600); + g_IndependentTokenCache.emplace_back(authInfo.accountId, authInfo.passwordHash, authInfo.GetService(), clientId, result.token, 3600); g_IndependentTokenCacheMtx.unlock(); return result; } @@ -520,7 +537,7 @@ namespace NAPI } // do request CurlRequestHelper req; - req.initate(fmt::format("{}/v1/api/admin/mapped_ids?input_type=user_id&output_type=pid&input={}", LaunchSettings::GetActURLPrefix(), nnid), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); + req.initate(authInfo.GetService(), fmt::format("{}/v1/api/admin/mapped_ids?input_type=user_id&output_type=pid&input={}", _getACTUrl(authInfo.GetService()), nnid), CurlRequestHelper::SERVER_SSL_CONTEXT::ACT); _ACTSetCommonHeaderParameters(req, authInfo); _ACTSetDeviceParameters(req, authInfo); _ACTSetRegionAndCountryParameters(req, authInfo); diff --git a/src/Cemu/napi/napi_ec.cpp b/src/Cemu/napi/napi_ec.cpp index 9bc4bfbf..2c0812e4 100644 --- a/src/Cemu/napi/napi_ec.cpp +++ b/src/Cemu/napi/napi_ec.cpp @@ -16,103 +16,112 @@ namespace NAPI { /* Service URL manager */ - std::string s_serviceURL_ContentPrefixURL; - std::string s_serviceURL_UncachedContentPrefixURL; - std::string s_serviceURL_EcsURL; - std::string s_serviceURL_IasURL; - std::string s_serviceURL_CasURL; - std::string s_serviceURL_NusURL; - - std::string _getNUSUrl() + struct CachedServiceUrls { - if (!s_serviceURL_NusURL.empty()) - return s_serviceURL_NusURL; - switch (ActiveSettings::GetNetworkService()) - { - case NetworkService::Nintendo: - return NintendoURLs::NUSURL; - break; - case NetworkService::Pretendo: - return PretendoURLs::NUSURL; - break; - case NetworkService::Custom: - return GetNetworkConfig().urls.NUS; - break; - default: - return NintendoURLs::NUSURL; - break; - } + std::string s_serviceURL_ContentPrefixURL; + std::string s_serviceURL_UncachedContentPrefixURL; + std::string s_serviceURL_EcsURL; + std::string s_serviceURL_IasURL; + std::string s_serviceURL_CasURL; + std::string s_serviceURL_NusURL; + }; + + std::unordered_map<NetworkService, CachedServiceUrls> s_cachedServiceUrlsMap; + + CachedServiceUrls& GetCachedServiceUrls(NetworkService service) + { + return s_cachedServiceUrlsMap[service]; } - std::string _getIASUrl() + std::string _getNUSUrl(NetworkService service) { - if (!s_serviceURL_IasURL.empty()) - return s_serviceURL_IasURL; - switch (ActiveSettings::GetNetworkService()) - { - case NetworkService::Nintendo: - return NintendoURLs::IASURL; - break; - case NetworkService::Pretendo: - return PretendoURLs::IASURL; - break; - case NetworkService::Custom: - return GetNetworkConfig().urls.IAS; - break; - default: - return NintendoURLs::IASURL; - break; - } + auto& cachedServiceUrls = GetCachedServiceUrls(service); + if (!cachedServiceUrls.s_serviceURL_NusURL.empty()) + return cachedServiceUrls.s_serviceURL_NusURL; + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::NUSURL; + case NetworkService::Pretendo: + return PretendoURLs::NUSURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.NUS; + default: + return NintendoURLs::NUSURL; + } } - std::string _getECSUrl() + std::string _getIASUrl(NetworkService service) + { + auto& cachedServiceUrls = GetCachedServiceUrls(service); + if (!cachedServiceUrls.s_serviceURL_IasURL.empty()) + return cachedServiceUrls.s_serviceURL_IasURL; + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::IASURL; + case NetworkService::Pretendo: + return PretendoURLs::IASURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.IAS; + default: + return NintendoURLs::IASURL; + } + } + + std::string _getECSUrl(NetworkService service) { // this is the first url queried (GetAccountStatus). The others are dynamically set if provided by the server but will fallback to hardcoded defaults otherwise - if (!s_serviceURL_EcsURL.empty()) - return s_serviceURL_EcsURL; - return LaunchSettings::GetServiceURL_ecs(); // by default this is "https://ecs.wup.shop.nintendo.net/ecs/services/ECommerceSOAP" + auto& cachedServiceUrls = GetCachedServiceUrls(service); + if (!cachedServiceUrls.s_serviceURL_EcsURL.empty()) + return cachedServiceUrls.s_serviceURL_EcsURL; + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::ECSURL; + case NetworkService::Pretendo: + return PretendoURLs::ECSURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.ECS; + default: + return NintendoURLs::ECSURL; + } } - std::string _getCCSUncachedUrl() // used for TMD requests + std::string _getCCSUncachedUrl(NetworkService service) // used for TMD requests { - if (!s_serviceURL_UncachedContentPrefixURL.empty()) - return s_serviceURL_UncachedContentPrefixURL; - switch (ActiveSettings::GetNetworkService()) - { - case NetworkService::Nintendo: - return NintendoURLs::CCSUURL; - break; - case NetworkService::Pretendo: - return PretendoURLs::CCSUURL; - break; - case NetworkService::Custom: - return GetNetworkConfig().urls.CCSU; - break; - default: - return NintendoURLs::CCSUURL; - break; - } + auto& cachedServiceUrls = GetCachedServiceUrls(service); + if (!cachedServiceUrls.s_serviceURL_UncachedContentPrefixURL.empty()) + return cachedServiceUrls.s_serviceURL_UncachedContentPrefixURL; + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::CCSUURL; + case NetworkService::Pretendo: + return PretendoURLs::CCSUURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.CCSU; + default: + return NintendoURLs::CCSUURL; + } } - std::string _getCCSUrl() // used for game data downloads + std::string _getCCSUrl(NetworkService service) // used for game data downloads { - if (!s_serviceURL_ContentPrefixURL.empty()) - return s_serviceURL_ContentPrefixURL; - switch (ActiveSettings::GetNetworkService()) - { - case NetworkService::Nintendo: - return NintendoURLs::CCSURL; - break; - case NetworkService::Pretendo: - return PretendoURLs::CCSURL; - break; - case NetworkService::Custom: - return GetNetworkConfig().urls.CCS; - break; - default: - return NintendoURLs::CCSURL; - break; - } + auto& cachedServiceUrls = GetCachedServiceUrls(service); + if (!cachedServiceUrls.s_serviceURL_ContentPrefixURL.empty()) + return cachedServiceUrls.s_serviceURL_ContentPrefixURL; + switch (service) + { + case NetworkService::Nintendo: + return NintendoURLs::CCSURL; + case NetworkService::Pretendo: + return PretendoURLs::CCSURL; + case NetworkService::Custom: + return GetNetworkConfig().urls.CCS; + default: + return NintendoURLs::CCSURL; + } } /* NUS */ @@ -122,8 +131,8 @@ namespace NAPI { NAPI_NUSGetSystemCommonETicket_Result result{}; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("nus", _getNUSUrl(), "GetSystemCommonETicket", "1.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("nus", _getNUSUrl(authInfo.GetService()), "GetSystemCommonETicket", "1.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); soapHelper.SOAP_addRequestField("RegionId", NCrypto::GetRegionAsString(authInfo.region)); @@ -175,8 +184,8 @@ namespace NAPI { NAPI_IASGetChallenge_Result result{}; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("ias", _getIASUrl(), "GetChallenge", "2.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("ias", _getIASUrl(authInfo.GetService()), "GetChallenge", "2.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); // not validated but the generated Challenge is bound to this DeviceId soapHelper.SOAP_addRequestField("Region", NCrypto::GetRegionAsString(authInfo.region)); @@ -200,8 +209,8 @@ namespace NAPI NAPI_IASGetRegistrationInfo_Result IAS_GetRegistrationInfo_QueryInfo(AuthInfo& authInfo, std::string challenge) { NAPI_IASGetRegistrationInfo_Result result; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("ias", _getIASUrl(), "GetRegistrationInfo", "2.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("ias", _getIASUrl(authInfo.GetService()), "GetRegistrationInfo", "2.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); // this must match the DeviceId used to generate Challenge soapHelper.SOAP_addRequestField("Region", NCrypto::GetRegionAsString(authInfo.region)); @@ -301,8 +310,8 @@ namespace NAPI { NAPI_ECSGetAccountStatus_Result result{}; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("ecs", _getECSUrl(), "GetAccountStatus", "2.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("ecs", _getECSUrl(authInfo.GetService()), "GetAccountStatus", "2.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); soapHelper.SOAP_addRequestField("Region", NCrypto::GetRegionAsString(authInfo.region)); @@ -367,19 +376,19 @@ namespace NAPI } // assign service URLs + auto& cachedServiceUrls = GetCachedServiceUrls(authInfo.GetService()); if (!result.serviceURLs.ContentPrefixURL.empty()) - s_serviceURL_ContentPrefixURL = result.serviceURLs.ContentPrefixURL; + cachedServiceUrls.s_serviceURL_ContentPrefixURL = result.serviceURLs.ContentPrefixURL; if (!result.serviceURLs.UncachedContentPrefixURL.empty()) - s_serviceURL_UncachedContentPrefixURL = result.serviceURLs.UncachedContentPrefixURL; + cachedServiceUrls.s_serviceURL_UncachedContentPrefixURL = result.serviceURLs.UncachedContentPrefixURL; if (!result.serviceURLs.IasURL.empty()) - s_serviceURL_IasURL = result.serviceURLs.IasURL; + cachedServiceUrls.s_serviceURL_IasURL = result.serviceURLs.IasURL; if (!result.serviceURLs.CasURL.empty()) - s_serviceURL_CasURL = result.serviceURLs.CasURL; + cachedServiceUrls.s_serviceURL_CasURL = result.serviceURLs.CasURL; if (!result.serviceURLs.NusURL.empty()) - s_serviceURL_NusURL = result.serviceURLs.NusURL; + cachedServiceUrls.s_serviceURL_NusURL = result.serviceURLs.NusURL; if (!result.serviceURLs.EcsURL.empty()) - s_serviceURL_EcsURL = result.serviceURLs.EcsURL; - + cachedServiceUrls.s_serviceURL_EcsURL = result.serviceURLs.EcsURL; return result; } @@ -387,8 +396,8 @@ namespace NAPI { NAPI_ECSAccountListETicketIds_Result result{}; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("ecs", _getECSUrl(), "AccountListETicketIds", "2.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("ecs", _getECSUrl(authInfo.GetService()), "AccountListETicketIds", "2.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); soapHelper.SOAP_addRequestField("Region", NCrypto::GetRegionAsString(authInfo.region)); @@ -446,8 +455,8 @@ namespace NAPI { NAPI_ECSAccountGetETickets_Result result{}; - CurlSOAPHelper soapHelper; - soapHelper.SOAP_initate("ecs", _getECSUrl(), "AccountGetETickets", "2.0"); + CurlSOAPHelper soapHelper(authInfo.GetService()); + soapHelper.SOAP_initate("ecs", _getECSUrl(authInfo.GetService()), "AccountGetETickets", "2.0"); soapHelper.SOAP_addRequestField("DeviceId", fmt::format("{}", authInfo.getDeviceIdWithPlatform())); soapHelper.SOAP_addRequestField("Region", NCrypto::GetRegionAsString(authInfo.region)); @@ -512,7 +521,7 @@ namespace NAPI { NAPI_CCSGetTMD_Result result{}; CurlRequestHelper req; - req.initate(fmt::format("{}/{:016x}/tmd.{}?deviceId={}&accountId={}", _getCCSUncachedUrl(), titleId, titleVersion, authInfo.getDeviceIdWithPlatform(), authInfo.IASToken.accountId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); + req.initate(authInfo.GetService(), fmt::format("{}/{:016x}/tmd.{}?deviceId={}&accountId={}", _getCCSUncachedUrl(authInfo.GetService()), titleId, titleVersion, authInfo.getDeviceIdWithPlatform(), authInfo.IASToken.accountId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); req.setTimeout(180); if (!req.submitRequest(false)) { @@ -528,7 +537,7 @@ namespace NAPI { NAPI_CCSGetTMD_Result result{}; CurlRequestHelper req; - req.initate(fmt::format("{}/{:016x}/tmd?deviceId={}&accountId={}", _getCCSUncachedUrl(), titleId, authInfo.getDeviceIdWithPlatform(), authInfo.IASToken.accountId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); + req.initate(authInfo.GetService(), fmt::format("{}/{:016x}/tmd?deviceId={}&accountId={}", _getCCSUncachedUrl(authInfo.GetService()), titleId, authInfo.getDeviceIdWithPlatform(), authInfo.IASToken.accountId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); req.setTimeout(180); if (!req.submitRequest(false)) { @@ -540,11 +549,11 @@ namespace NAPI return result; } - NAPI_CCSGetETicket_Result CCS_GetCETK(AuthInfo& authInfo, uint64 titleId, uint16 titleVersion) + NAPI_CCSGetETicket_Result CCS_GetCETK(NetworkService service, uint64 titleId, uint16 titleVersion) { NAPI_CCSGetETicket_Result result{}; CurlRequestHelper req; - req.initate(fmt::format("{}/{:016x}/cetk", _getCCSUncachedUrl(), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); + req.initate(service, fmt::format("{}/{:016x}/cetk", _getCCSUncachedUrl(service), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); req.setTimeout(180); if (!req.submitRequest(false)) { @@ -556,10 +565,10 @@ namespace NAPI return result; } - bool CCS_GetContentFile(uint64 titleId, uint32 contentId, bool(*cbWriteCallback)(void* userData, const void* ptr, size_t len, bool isLast), void* userData) + bool CCS_GetContentFile(NetworkService service, uint64 titleId, uint32 contentId, bool(*cbWriteCallback)(void* userData, const void* ptr, size_t len, bool isLast), void* userData) { CurlRequestHelper req; - req.initate(fmt::format("{}/{:016x}/{:08x}", _getCCSUrl(), titleId, contentId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); + req.initate(service, fmt::format("{}/{:016x}/{:08x}", _getCCSUrl(service), titleId, contentId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); req.setWriteCallback(cbWriteCallback, userData); req.setTimeout(0); if (!req.submitRequest(false)) @@ -570,11 +579,11 @@ namespace NAPI return true; } - NAPI_CCSGetContentH3_Result CCS_GetContentH3File(uint64 titleId, uint32 contentId) + NAPI_CCSGetContentH3_Result CCS_GetContentH3File(NetworkService service, uint64 titleId, uint32 contentId) { NAPI_CCSGetContentH3_Result result{}; CurlRequestHelper req; - req.initate(fmt::format("{}/{:016x}/{:08x}.h3", _getCCSUrl(), titleId, contentId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); + req.initate(service, fmt::format("{}/{:016x}/{:08x}.h3", _getCCSUrl(service), titleId, contentId), CurlRequestHelper::SERVER_SSL_CONTEXT::CCS); if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request content hash file {:08x}.h3 for title {:016X}", contentId, titleId)); diff --git a/src/Cemu/napi/napi_helper.cpp b/src/Cemu/napi/napi_helper.cpp index 776baf33..e498d07f 100644 --- a/src/Cemu/napi/napi_helper.cpp +++ b/src/Cemu/napi/napi_helper.cpp @@ -119,7 +119,7 @@ CurlRequestHelper::~CurlRequestHelper() curl_easy_cleanup(m_curl); } -void CurlRequestHelper::initate(std::string url, SERVER_SSL_CONTEXT sslContext) +void CurlRequestHelper::initate(NetworkService service, std::string url, SERVER_SSL_CONTEXT sslContext) { // reset parameters m_headerExtraFields.clear(); @@ -131,8 +131,10 @@ void CurlRequestHelper::initate(std::string url, SERVER_SSL_CONTEXT sslContext) curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 60); // SSL - if (GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() == NetworkService::Custom || ActiveSettings::GetNetworkService() == NetworkService::Pretendo){ //Remove once Pretendo has SSL - curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 1L); + if (IsNetworkServiceSSLDisabled(service)) + { + curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 0L); } else if (sslContext == SERVER_SSL_CONTEXT::ACT || sslContext == SERVER_SSL_CONTEXT::TAGAYA) { @@ -256,18 +258,24 @@ bool CurlRequestHelper::submitRequest(bool isPost) return true; } -CurlSOAPHelper::CurlSOAPHelper() +CurlSOAPHelper::CurlSOAPHelper(NetworkService service) { m_curl = curl_easy_init(); curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, __curlWriteCallback); curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this); // SSL - if (!GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() != NetworkService::Pretendo && ActiveSettings::GetNetworkService() != NetworkService::Custom) { //Remove once Pretendo has SSL - curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_FUNCTION, _sslctx_function_SOAP); - curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_DATA, NULL); + if (!IsNetworkServiceSSLDisabled(service)) + { + curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_FUNCTION, _sslctx_function_SOAP); + curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_DATA, NULL); + curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 1L); } - if(GetConfig().proxy_server.GetValue() != "") + else + { + curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 0L); + } + if (GetConfig().proxy_server.GetValue() != "") { curl_easy_setopt(m_curl, CURLOPT_PROXY, GetConfig().proxy_server.GetValue().c_str()); } diff --git a/src/Cemu/napi/napi_helper.h b/src/Cemu/napi/napi_helper.h index 6403f074..adfe7393 100644 --- a/src/Cemu/napi/napi_helper.h +++ b/src/Cemu/napi/napi_helper.h @@ -38,7 +38,7 @@ public: return m_curl; } - void initate(std::string url, SERVER_SSL_CONTEXT sslContext); + void initate(NetworkService service, std::string url, SERVER_SSL_CONTEXT sslContext); void addHeaderField(const char* fieldName, std::string_view value); void addPostField(const char* fieldName, std::string_view value); void setWriteCallback(bool(*cbWriteCallback)(void* userData, const void* ptr, size_t len, bool isLast), void* userData); @@ -74,7 +74,7 @@ private: class CurlSOAPHelper // todo - make this use CurlRequestHelper { public: - CurlSOAPHelper(); + CurlSOAPHelper(NetworkService service); ~CurlSOAPHelper(); CURL* getCURL() diff --git a/src/Cemu/napi/napi_idbe.cpp b/src/Cemu/napi/napi_idbe.cpp index acf7799c..db7fda20 100644 --- a/src/Cemu/napi/napi_idbe.cpp +++ b/src/Cemu/napi/napi_idbe.cpp @@ -54,11 +54,11 @@ namespace NAPI AES128_CBC_decrypt((uint8*)iconData, (uint8*)iconData, sizeof(IDBEIconDataV0), aesKey, iv); } - std::vector<uint8> IDBE_RequestRawEncrypted(uint64 titleId) + std::vector<uint8> IDBE_RequestRawEncrypted(NetworkService networkService, uint64 titleId) { CurlRequestHelper req; std::string requestUrl; - switch (ActiveSettings::GetNetworkService()) + switch (networkService) { case NetworkService::Pretendo: requestUrl = PretendoURLs::IDBEURL; @@ -72,7 +72,7 @@ namespace NAPI break; } requestUrl.append(fmt::format(fmt::runtime("/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId)); - req.initate(requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + req.initate(networkService, requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); if (!req.submitRequest(false)) { @@ -90,7 +90,7 @@ namespace NAPI return receivedData; } - std::optional<IDBEIconDataV0> IDBE_Request(uint64 titleId) + std::optional<IDBEIconDataV0> IDBE_Request(NetworkService networkService, uint64 titleId) { if (titleId == 0x000500301001500A || titleId == 0x000500301001510A || @@ -101,7 +101,7 @@ namespace NAPI return std::nullopt; } - std::vector<uint8> idbeData = IDBE_RequestRawEncrypted(titleId); + std::vector<uint8> idbeData = IDBE_RequestRawEncrypted(networkService, titleId); if (idbeData.size() < 0x22) return std::nullopt; if (idbeData[0] != 0) diff --git a/src/Cemu/napi/napi_version.cpp b/src/Cemu/napi/napi_version.cpp index 9fc71556..a1f5879c 100644 --- a/src/Cemu/napi/napi_version.cpp +++ b/src/Cemu/napi/napi_version.cpp @@ -18,7 +18,7 @@ namespace NAPI CurlRequestHelper req; std::string requestUrl; - switch (ActiveSettings::GetNetworkService()) + switch (authInfo.GetService()) { case NetworkService::Pretendo: requestUrl = PretendoURLs::TAGAYAURL; @@ -32,7 +32,7 @@ namespace NAPI break; } requestUrl.append(fmt::format(fmt::runtime("/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country)); - req.initate(requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + req.initate(authInfo.GetService(), requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); if (!req.submitRequest(false)) { @@ -63,7 +63,7 @@ namespace NAPI { NAPI_VersionList_Result result; CurlRequestHelper req; - req.initate(fmt::format("https://{}/tagaya/versionlist/{}/{}/list/{}.versionlist", fqdnURL, NCrypto::GetRegionAsString(authInfo.region), authInfo.country, versionListVersion), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + req.initate(authInfo.GetService(), fmt::format("https://{}/tagaya/versionlist/{}/{}/list/{}.versionlist", fqdnURL, NCrypto::GetRegionAsString(authInfo.region), authInfo.country, versionListVersion), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request update list")); diff --git a/src/Cemu/ncrypto/ncrypto.cpp b/src/Cemu/ncrypto/ncrypto.cpp index 8a989d2c..bbda681f 100644 --- a/src/Cemu/ncrypto/ncrypto.cpp +++ b/src/Cemu/ncrypto/ncrypto.cpp @@ -20,7 +20,8 @@ void iosuCrypto_readOtpData(void* output, sint32 wordIndex, sint32 size); void iosuCrypto_readSeepromData(void* output, sint32 wordIndex, sint32 size); -extern bool hasSeepromMem; // remove later +extern bool hasSeepromMem; // remove later (migrate otp/seeprom loading & parsing to this class) +extern bool hasOtpMem; // remove later namespace NCrypto { @@ -792,6 +793,16 @@ namespace NCrypto return (CafeConsoleRegion)seepromRegionU32[3]; } + bool OTP_IsPresent() + { + return hasOtpMem; + } + + bool HasDataForConsoleCert() + { + return SEEPROM_IsPresent() && OTP_IsPresent(); + } + std::string GetRegionAsString(CafeConsoleRegion regionCode) { if (regionCode == CafeConsoleRegion::EUR) @@ -957,6 +968,11 @@ namespace NCrypto return it->second; } + size_t GetCountryCount() + { + return g_countryTable.size(); + } + void unitTests() { base64Tests(); diff --git a/src/Cemu/ncrypto/ncrypto.h b/src/Cemu/ncrypto/ncrypto.h index 51f3d9cb..5f399ad7 100644 --- a/src/Cemu/ncrypto/ncrypto.h +++ b/src/Cemu/ncrypto/ncrypto.h @@ -205,7 +205,11 @@ namespace NCrypto CafeConsoleRegion SEEPROM_GetRegion(); std::string GetRegionAsString(CafeConsoleRegion regionCode); const char* GetCountryAsString(sint32 index); // returns NN if index is not valid or known + size_t GetCountryCount(); bool SEEPROM_IsPresent(); + bool OTP_IsPresent(); + + bool HasDataForConsoleCert(); void unitTests(); } \ No newline at end of file diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index 2049bd65..81662ab5 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -39,7 +39,6 @@ ActiveSettings::LoadOnce( g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring()); g_config.Load(); - LaunchSettings::ChangeNetworkServiceURL(GetConfig().account.active_service); std::string additionalErrorInfo; s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK; return failed_write_access; diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index b7a79a11..1731f500 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -69,11 +69,7 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args) ("account,a", po::value<std::string>(), "Persistent id of account") ("force-interpreter", po::value<bool>()->implicit_value(true), "Force interpreter CPU emulation, disables recompiler") - ("enable-gdbstub", po::value<bool>()->implicit_value(true), "Enable GDB stub to debug executables inside Cemu using an external debugger") - - ("act-url", po::value<std::string>(), "URL prefix for account server") - ("ecs-url", po::value<std::string>(), "URL for ECS service"); - + ("enable-gdbstub", po::value<bool>()->implicit_value(true), "Enable GDB stub to debug executables inside Cemu using an external debugger"); po::options_description hidden{ "Hidden options" }; hidden.add_options() @@ -190,16 +186,6 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args) if (vm.count("output")) log_path = vm["output"].as<std::wstring>(); - // urls - if (vm.count("act-url")) - { - serviceURL_ACT = vm["act-url"].as<std::string>(); - if (serviceURL_ACT.size() > 0 && serviceURL_ACT.back() == '/') - serviceURL_ACT.pop_back(); - } - if (vm.count("ecs-url")) - serviceURL_ECS = vm["ecs-url"].as<std::string>(); - if(!extract_path.empty()) { ExtractorTool(extract_path, output_path, log_path); @@ -280,24 +266,3 @@ bool LaunchSettings::ExtractorTool(std::wstring_view wud_path, std::string_view return true; } - - -void LaunchSettings::ChangeNetworkServiceURL(int ID){ - NetworkService Network = static_cast<NetworkService>(ID); - switch (Network) - { - case NetworkService::Pretendo: - serviceURL_ACT = PretendoURLs::ACTURL; - serviceURL_ECS = PretendoURLs::ECSURL; - break; - case NetworkService::Custom: - serviceURL_ACT = GetNetworkConfig().urls.ACT.GetValue(); - serviceURL_ECS = GetNetworkConfig().urls.ECS.GetValue(); - break; - case NetworkService::Nintendo: - default: - serviceURL_ACT = NintendoURLs::ACTURL; - serviceURL_ECS = NintendoURLs::ECSURL; - break; - } -} diff --git a/src/config/LaunchSettings.h b/src/config/LaunchSettings.h index be989e6a..b0f673a1 100644 --- a/src/config/LaunchSettings.h +++ b/src/config/LaunchSettings.h @@ -29,10 +29,6 @@ public: static std::optional<uint32> GetPersistentId() { return s_persistent_id; } - static std::string GetActURLPrefix() { return serviceURL_ACT; } - static std::string GetServiceURL_ecs() { return serviceURL_ECS; } - static void ChangeNetworkServiceURL(int ID); - private: inline static std::optional<fs::path> s_load_game_file{}; inline static std::optional<uint64> s_load_title_id{}; @@ -48,12 +44,6 @@ private: inline static std::optional<uint32> s_persistent_id{}; - // service URLS - inline static std::string serviceURL_ACT; - inline static std::string serviceURL_ECS; - // todo - npts and other boss urls - - static bool ExtractorTool(std::wstring_view wud_path, std::string_view output_path, std::wstring_view log_path); }; diff --git a/src/config/NetworkSettings.cpp b/src/config/NetworkSettings.cpp index 5cc66a91..b086d0ae 100644 --- a/src/config/NetworkSettings.cpp +++ b/src/config/NetworkSettings.cpp @@ -30,8 +30,6 @@ void NetworkConfig::Load(XMLConfigParser& parser) urls.BOSS = u.get("boss", NintendoURLs::BOSSURL); urls.TAGAYA = u.get("tagaya", NintendoURLs::TAGAYAURL); urls.OLV = u.get("olv", NintendoURLs::OLVURL); - if (static_cast<NetworkService>(GetConfig().account.active_service.GetValue()) == NetworkService::Custom) - LaunchSettings::ChangeNetworkServiceURL(2); } bool NetworkConfig::XMLExists() @@ -41,7 +39,6 @@ bool NetworkConfig::XMLExists() { if (static_cast<NetworkService>(GetConfig().account.active_service.GetValue()) == NetworkService::Custom) { - LaunchSettings::ChangeNetworkServiceURL(0); GetConfig().account.active_service = 0; } return false; diff --git a/src/config/NetworkSettings.h b/src/config/NetworkSettings.h index 26137cdd..be311182 100644 --- a/src/config/NetworkSettings.h +++ b/src/config/NetworkSettings.h @@ -3,13 +3,15 @@ #include "ConfigValue.h" #include "XMLConfig.h" - -enum class NetworkService { -Nintendo, -Pretendo, -Custom, +enum class NetworkService +{ + Nintendo, + Pretendo, + Custom }; -struct NetworkConfig { + +struct NetworkConfig +{ NetworkConfig() { @@ -69,4 +71,15 @@ struct PretendoURLs { typedef XMLDataConfig<NetworkConfig, &NetworkConfig::Load, &NetworkConfig::Save> XMLNetworkConfig_t; extern XMLNetworkConfig_t n_config; -inline NetworkConfig& GetNetworkConfig() { return n_config.data();}; \ No newline at end of file +inline NetworkConfig& GetNetworkConfig() { return n_config.data();}; + +inline bool IsNetworkServiceSSLDisabled(NetworkService service) +{ + if(service == NetworkService::Nintendo) + return false; + else if(service == NetworkService::Pretendo) + return true; + else if(service == NetworkService::Custom) + return GetNetworkConfig().disablesslver.GetValue(); + return false; +} \ No newline at end of file diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 7f11d4c6..505a09c6 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -332,7 +332,7 @@ void CemuApp::CreateDefaultFiles(bool first_start) if (!fs::exists(countryFile)) { std::ofstream file(countryFile); - for (sint32 i = 0; i < 201; i++) + for (sint32 i = 0; i < NCrypto::GetCountryCount(); i++) { const char* countryCode = NCrypto::GetCountryAsString(i); if (boost::iequals(countryCode, "NN")) diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index e33cfbf6..27ce37fa 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -686,8 +686,10 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) if (!NetworkConfig::XMLExists()) m_active_service->Enable(2, false); + m_active_service->SetItemToolTip(0, _("Connect to the official Nintendo Network Service")); + m_active_service->SetItemToolTip(1, _("Connect to the Pretendo Network Service")); + m_active_service->SetItemToolTip(2, _("Connect to a custom Network Service (configured via network_services.xml)")); - m_active_service->SetToolTip(_("Connect to which Network Service")); m_active_service->Bind(wxEVT_RADIOBOX, &GeneralSettings2::OnAccountServiceChanged,this); content->Add(m_active_service, 0, wxEXPAND | wxALL, 5); @@ -762,7 +764,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) m_account_grid->Append(new wxStringProperty(_("Email"), kPropertyEmail)); wxPGChoices countries; - for (int i = 0; i < 195; ++i) + for (int i = 0; i < NCrypto::GetCountryCount(); ++i) { const auto country = NCrypto::GetCountryAsString(i); if (country && (i == 0 || !boost::equals(country, "NN"))) @@ -1948,8 +1950,6 @@ void GeneralSettings2::OnActiveAccountChanged(wxCommandEvent& event) void GeneralSettings2::OnAccountServiceChanged(wxCommandEvent& event) { - LaunchSettings::ChangeNetworkServiceURL(m_active_service->GetSelection()); - UpdateAccountInformation(); } diff --git a/src/gui/TitleManager.cpp b/src/gui/TitleManager.cpp index 669a1aaf..00e7992f 100644 --- a/src/gui/TitleManager.cpp +++ b/src/gui/TitleManager.cpp @@ -31,17 +31,15 @@ #include <wx/dirdlg.h> #include <wx/notebook.h> +#include "Cafe/IOSU/legacy/iosu_crypto.h" #include "config/ActiveSettings.h" #include "gui/dialogs/SaveImport/SaveImportWindow.h" #include "Cafe/Account/Account.h" #include "Cemu/Tools/DownloadManager/DownloadManager.h" #include "gui/CemuApp.h" - #include "Cafe/TitleList/TitleList.h" - -#include "resource/embedded/resources.h" - #include "Cafe/TitleList/SaveList.h" +#include "resource/embedded/resources.h" wxDEFINE_EVENT(wxEVT_TITLE_FOUND, wxCommandEvent); wxDEFINE_EVENT(wxEVT_TITLE_SEARCH_COMPLETE, wxCommandEvent); @@ -155,6 +153,7 @@ wxPanel* TitleManager::CreateDownloadManagerPage() { auto* row = new wxBoxSizer(wxHORIZONTAL); +#if DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN m_account = new wxChoice(panel, wxID_ANY); m_account->SetMinSize({ 250,-1 }); auto accounts = Account::GetAccounts(); @@ -172,6 +171,7 @@ wxPanel* TitleManager::CreateDownloadManagerPage() } row->Add(m_account, 0, wxALL, 5); +#endif m_connect = new wxButton(panel, wxID_ANY, _("Connect")); m_connect->Bind(wxEVT_BUTTON, &TitleManager::OnConnect, this); @@ -180,7 +180,17 @@ wxPanel* TitleManager::CreateDownloadManagerPage() sizer->Add(row, 0, wxEXPAND, 5); } +#if DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN m_status_text = new wxStaticText(panel, wxID_ANY, _("Select an account and press Connect")); +#else + if(!NCrypto::HasDataForConsoleCert()) + { + m_status_text = new wxStaticText(panel, wxID_ANY, _("Valid online files are required to download eShop titles. For more information, go to the Account tab in the General Settings.")); + m_connect->Enable(false); + } + else + m_status_text = new wxStaticText(panel, wxID_ANY, _("Click on Connect to load the list of downloadable titles")); +#endif this->Bind(wxEVT_SET_TEXT, &TitleManager::OnSetStatusText, this); sizer->Add(m_status_text, 0, wxALL, 5); @@ -720,9 +730,10 @@ void TitleManager::OnSaveImport(wxCommandEvent& event) void TitleManager::InitiateConnect() { // init connection to download manager if queued +#if DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN uint32 persistentId = (uint32)(uintptr_t)m_account->GetClientData(m_account->GetSelection()); auto& account = Account::GetAccount(persistentId); - +#endif DownloadManager* dlMgr = DownloadManager::GetInstance(); dlMgr->reset(); m_download_list->SetCurrentDownloadMgr(dlMgr); @@ -742,7 +753,15 @@ void TitleManager::InitiateConnect() TitleManager::Callback_ConnectStatusUpdate, TitleManager::Callback_AddDownloadableTitle, TitleManager::Callback_RemoveDownloadableTitle); - dlMgr->connect(account.GetAccountId(), account.GetAccountPasswordCache(), NCrypto::SEEPROM_GetRegion(), NCrypto::GetCountryAsString(account.GetCountry()), NCrypto::GetDeviceId(), NCrypto::GetSerial(), deviceCertBase64); + std::string accountName; + std::array<uint8, 32> accountPassword; + std::string accountCountry; +#if DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN + accountName = account.GetAccountId(); + accountPassword = account.GetAccountPasswordCache(); + accountCountry.assign(NCrypto::GetCountryAsString(account.GetCountry())); +#endif + dlMgr->connect(accountName, accountPassword, NCrypto::SEEPROM_GetRegion(), accountCountry, NCrypto::GetDeviceId(), NCrypto::GetSerial(), deviceCertBase64); } void TitleManager::OnConnect(wxCommandEvent& event) @@ -787,7 +806,9 @@ void TitleManager::OnDisconnect(wxCommandEvent& event) void TitleManager::SetConnected(bool state) { +#if DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN m_account->Enable(!state); +#endif m_connect->Enable(!state); m_show_titles->Enable(state); diff --git a/src/gui/TitleManager.h b/src/gui/TitleManager.h index 2973618f..ae284040 100644 --- a/src/gui/TitleManager.h +++ b/src/gui/TitleManager.h @@ -8,6 +8,8 @@ #include "Cemu/Tools/DownloadManager/DownloadManager.h" +#define DOWNLOADMGR_HAS_ACCOUNT_DROPDOWN 0 + class wxCheckBox; class wxStaticText; class wxListEvent; From 5be98da0ac5279a4e05eee22f24f3cb807ceb8f5 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:49:49 +0200 Subject: [PATCH 154/314] OpenGL: Fix a crash when GL_VERSION is null (#1187) --- src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index 28e91b8a..cf134a5d 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -386,7 +386,7 @@ void OpenGLRenderer::GetVendorInformation() cemuLog_log(LogType::Force, "GL_RENDERER: {}", glRendererString ? glRendererString : "unknown"); cemuLog_log(LogType::Force, "GL_VERSION: {}", glVersionString ? glVersionString : "unknown"); - if(boost::icontains(glVersionString, "Mesa")) + if(glVersionString && boost::icontains(glVersionString, "Mesa")) { m_vendor = GfxVendor::Mesa; return; From fdf239929ff923eb4b28a16fc4754202391cbc3f Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:24:43 +0200 Subject: [PATCH 155/314] nsysnet: Various improvements (#1188) - Do not raise an assert for unimplemented optnames - recvfrom: src_addr and addrlen can be NULL - getsockopt: Implement SO_TYPE --- src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 86 ++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 17 deletions(-) diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index 128c19a5..88bca8af 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -36,15 +36,46 @@ #define WU_SO_REUSEADDR 0x0004 #define WU_SO_KEEPALIVE 0x0008 +#define WU_SO_DONTROUTE 0x0010 +#define WU_SO_BROADCAST 0x0020 +#define WU_SO_LINGER 0x0080 +#define WU_SO_OOBINLINE 0x0100 +#define WU_SO_TCPSACK 0x0200 #define WU_SO_WINSCALE 0x0400 #define WU_SO_SNDBUF 0x1001 #define WU_SO_RCVBUF 0x1002 +#define WU_SO_SNDLOWAT 0x1003 +#define WU_SO_RCVLOWAT 0x1004 #define WU_SO_LASTERROR 0x1007 +#define WU_SO_TYPE 0x1008 +#define WU_SO_HOPCNT 0x1009 +#define WU_SO_MAXMSG 0x1010 +#define WU_SO_RXDATA 0x1011 +#define WU_SO_TXDATA 0x1012 +#define WU_SO_MYADDR 0x1013 #define WU_SO_NBIO 0x1014 #define WU_SO_BIO 0x1015 #define WU_SO_NONBLOCK 0x1016 +#define WU_SO_UNKNOWN1019 0x1019 // tcp related +#define WU_SO_UNKNOWN101A 0x101A // tcp related +#define WU_SO_UNKNOWN101B 0x101B // tcp related +#define WU_SO_NOSLOWSTART 0x4000 +#define WU_SO_RUSRBUF 0x10000 -#define WU_TCP_NODELAY 0x2004 +#define WU_TCP_ACKDELAYTIME 0x2001 +#define WU_TCP_NOACKDELAY 0x2002 +#define WU_TCP_MAXSEG 0x2003 +#define WU_TCP_NODELAY 0x2004 +#define WU_TCP_UNKNOWN 0x2005 // amount of mss received before sending an ack + +#define WU_IP_TOS 3 +#define WU_IP_TTL 4 +#define WU_IP_MULTICAST_IF 9 +#define WU_IP_MULTICAST_TTL 10 +#define WU_IP_MULTICAST_LOOP 11 +#define WU_IP_ADD_MEMBERSHIP 12 +#define WU_IP_DROP_MEMBERSHIP 13 +#define WU_IP_UNKNOWN 14 #define WU_SOL_SOCKET -1 // this constant differs from Win32 socket API @@ -548,7 +579,7 @@ void nsysnetExport_setsockopt(PPCInterpreter_t* hCPU) } else { - cemuLog_logDebug(LogType::Force, "setsockopt(): Unsupported optname 0x{:08x}", optname); + cemuLog_logDebug(LogType::Force, "setsockopt(WU_SOL_SOCKET): Unsupported optname 0x{:08x}", optname); } } else if (level == WU_IPPROTO_TCP) @@ -564,18 +595,22 @@ void nsysnetExport_setsockopt(PPCInterpreter_t* hCPU) assert_dbg(); } else - assert_dbg(); + { + cemuLog_logDebug(LogType::Force, "setsockopt(WU_IPPROTO_TCP): Unsupported optname 0x{:08x}", optname); + } } else if (level == WU_IPPROTO_IP) { hostLevel = IPPROTO_IP; - if (optname == 0xC) + if (optname == WU_IP_MULTICAST_IF || optname == WU_IP_MULTICAST_TTL || + optname == WU_IP_MULTICAST_LOOP || optname == WU_IP_ADD_MEMBERSHIP || + optname == WU_IP_DROP_MEMBERSHIP) { - // unknown + cemuLog_logDebug(LogType::Socket, "todo: setsockopt() for multicast"); } - else if( optname == 0x4 ) + else if(optname == WU_IP_TTL || optname == WU_IP_TOS) { - cemuLog_logDebug(LogType::Force, "setsockopt with unsupported opname 4 for IPPROTO_IP"); + cemuLog_logDebug(LogType::Force, "setsockopt(WU_IPPROTO_IP): Unsupported optname 0x{:08x}", optname); } else assert_dbg(); @@ -649,6 +684,16 @@ void nsysnetExport_getsockopt(PPCInterpreter_t* hCPU) *(uint32*)optval = _swapEndianU32(optvalLE); // used by Lost Reavers after some loading screens } + else if (optname == WU_SO_TYPE) + { + if (memory_readU32(optlenMPTR) != 4) + assert_dbg(); + int optvalLE = 0; + socklen_t optlenLE = 4; + memory_writeU32(optlenMPTR, 4); + *(uint32*)optval = _swapEndianU32(vs->type); + r = WU_SO_SUCCESS; + } else if (optname == WU_SO_NONBLOCK) { if (memory_readU32(optlenMPTR) != 4) @@ -661,12 +706,12 @@ void nsysnetExport_getsockopt(PPCInterpreter_t* hCPU) } else { - cemu_assert_debug(false); + cemuLog_logDebug(LogType::Force, "getsockopt(WU_SOL_SOCKET): Unsupported optname 0x{:08x}", optname); } } else { - cemu_assert_debug(false); + cemuLog_logDebug(LogType::Force, "getsockopt(): Unsupported level 0x{:08x}", level); } osLib_returnFromFunction(hCPU, r); @@ -1533,7 +1578,7 @@ void nsysnetExport_getaddrinfo(PPCInterpreter_t* hCPU) void nsysnetExport_recvfrom(PPCInterpreter_t* hCPU) { - cemuLog_log(LogType::Socket, "recvfrom({},0x{:08x},{},0x{:x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6]); + cemuLog_log(LogType::Socket, "recvfrom({},0x{:08x},{},0x{:x},0x{:x},0x{:x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7], hCPU->gpr[8]); ppcDefineParamS32(s, 0); ppcDefineParamStr(msg, 1); ppcDefineParamS32(len, 2); @@ -1562,8 +1607,8 @@ void nsysnetExport_recvfrom(PPCInterpreter_t* hCPU) if (vs->isNonBlocking) requestIsNonBlocking = vs->isNonBlocking; - socklen_t fromLenHost = *fromLen; sockaddr fromAddrHost; + socklen_t fromLenHost = sizeof(fromAddrHost); sint32 wsaError = 0; while( true ) @@ -1605,9 +1650,13 @@ void nsysnetExport_recvfrom(PPCInterpreter_t* hCPU) if (r < 0) cemu_assert_debug(false); cemuLog_logDebug(LogType::Force, "recvfrom returned {} bytes", r); - *fromLen = fromLenHost; - fromAddr->sa_family = _swapEndianU16(fromAddrHost.sa_family); - memcpy(fromAddr->sa_data, fromAddrHost.sa_data, 14); + + // fromAddr and fromLen can be NULL + if (fromAddr && fromLen) { + *fromLen = fromLenHost; + fromAddr->sa_family = _swapEndianU16(fromAddrHost.sa_family); + memcpy(fromAddr->sa_data, fromAddrHost.sa_data, 14); + } _setSockError(0); osLib_returnFromFunction(hCPU, r); @@ -1657,9 +1706,12 @@ void nsysnetExport_recvfrom(PPCInterpreter_t* hCPU) assert_dbg(); } - *fromLen = fromLenHost; - fromAddr->sa_family = _swapEndianU16(fromAddrHost.sa_family); - memcpy(fromAddr->sa_data, fromAddrHost.sa_data, 14); + // fromAddr and fromLen can be NULL + if (fromAddr && fromLen) { + *fromLen = fromLenHost; + fromAddr->sa_family = _swapEndianU16(fromAddrHost.sa_family); + memcpy(fromAddr->sa_data, fromAddrHost.sa_data, 14); + } _translateError(r <= 0 ? -1 : 0, wsaError); From b2be3c13df58cd6108d090b892d2801a615fd60d Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:19:15 +0200 Subject: [PATCH 156/314] Add example network_services.xml --- dist/network_services.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 dist/network_services.xml diff --git a/dist/network_services.xml b/dist/network_services.xml new file mode 100644 index 00000000..0c0f2e3e --- /dev/null +++ b/dist/network_services.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<content> + <networkname>CustomExample</networkname> + <disablesslverification>0</disablesslverification> + <urls> + <act>https://account.nintendo.net</act> + <ecs>https://ecs.wup.shop.nintendo.net/ecs/services/ECommerceSOAP</ecs> + <nus>https://nus.wup.shop.nintendo.net/nus/services/NetUpdateSOAP</nus> + <ias>https://ias.wup.shop.nintendo.net/ias/services/IdentityAuthenticationSOAP</ias> + <ccsu>https://ccs.wup.shop.nintendo.net/ccs/download</ccsu> + <ccs>http://ccs.cdn.wup.shop.nintendo.net/ccs/download</ccs> + <idbe>https://idbe-wup.cdn.nintendo.net/icondata</idbe> + <boss>https://npts.app.nintendo.net/p01/tasksheet</boss> + <tagaya>https://tagaya.wup.shop.nintendo.net/tagaya/versionlist</tagaya> + <olv>https://discovery.olv.nintendo.net/v1/endpoint</olv> + </urls> +</content> \ No newline at end of file From c038e758aeac76ed55f8f92bbc22f4815cc7689a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Apr 2024 04:18:17 +0200 Subject: [PATCH 157/314] IOSU: Clean up resource on service shutdown Also set device-dependent thread name --- src/Cafe/IOSU/nn/iosu_nn_service.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Cafe/IOSU/nn/iosu_nn_service.cpp b/src/Cafe/IOSU/nn/iosu_nn_service.cpp index 1fb5c77a..c888b4fb 100644 --- a/src/Cafe/IOSU/nn/iosu_nn_service.cpp +++ b/src/Cafe/IOSU/nn/iosu_nn_service.cpp @@ -155,7 +155,9 @@ namespace iosu void IPCService::ServiceThread() { - SetThreadName("IPCService"); + std::string serviceName = m_devicePath.substr(m_devicePath.find_last_of('/') == std::string::npos ? 0 : m_devicePath.find_last_of('/') + 1); + serviceName.insert(0, "NNsvc_"); + SetThreadName(serviceName.c_str()); m_msgQueueId = IOS_CreateMessageQueue(_m_msgBuffer.GetPtr(), _m_msgBuffer.GetCount()); cemu_assert(!IOS_ResultIsError((IOS_ERROR)m_msgQueueId)); IOS_ERROR r = IOS_RegisterResourceManager(m_devicePath.c_str(), m_msgQueueId); @@ -208,6 +210,7 @@ namespace iosu IOS_ResourceReply(cmd, IOS_ERROR_INVALID); } } + IOS_DestroyMessageQueue(m_msgQueueId); m_threadInitialized = false; } }; From 1c73dc9e1b824f4618e60704b2c1e6682b749ee0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 30 Apr 2024 23:09:00 +0200 Subject: [PATCH 158/314] Implement proc_ui.rpl + stub SYSSwitchToEManual() to avoid softlocks - Full reimplementation of proc_ui.rpl with all 19 exports - Foreground/Background messages now go to the coreinit system message queue as they should (instead of using a hack where proc_ui receives them directly) - Add missing coreinit API needed by proc_ui: OSGetPFID(), OSGetUPID(), OSGetTitleID(), __OSCreateThreadType() - Use big-endian types in OSMessage - Flesh out the stubs for OSDriver_Register and OSDriver_Unregister a bit more since we need to call it from proc_ui. Similiar small tweaks to other coreinit API - Stub sysapp SYSSwitchToEManual() and _SYSSwitchToEManual() in such a way that they will trigger the expected background/foreground transition, avoiding softlocks in games that call these functions --- .gitignore | 1 + src/Cafe/OS/common/OSCommon.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit.cpp | 22 - src/Cafe/OS/libs/coreinit/coreinit_DynLoad.h | 6 + src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Memory.h | 5 + .../libs/coreinit/coreinit_MessageQueue.cpp | 7 + .../OS/libs/coreinit/coreinit_MessageQueue.h | 19 +- src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp | 96 ++ src/Cafe/OS/libs/coreinit/coreinit_Misc.h | 20 + src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 19 +- src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 8 +- src/Cafe/OS/libs/coreinit/coreinit_Time.cpp | 7 +- src/Cafe/OS/libs/coreinit/coreinit_Time.h | 3 +- src/Cafe/OS/libs/gx2/GX2_Misc.h | 2 + src/Cafe/OS/libs/nn_olv/nn_olv.cpp | 3 +- src/Cafe/OS/libs/proc_ui/proc_ui.cpp | 944 +++++++++++++++++- src/Cafe/OS/libs/proc_ui/proc_ui.h | 45 +- src/Cafe/OS/libs/sysapp/sysapp.cpp | 23 + src/Common/CafeString.h | 5 + 21 files changed, 1146 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index c10b38da..67a268aa 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ bin/sdcard/* bin/screenshots/* bin/dump/* bin/cafeLibs/* +bin/portable/* bin/keys.txt !bin/shaderCache/info.txt diff --git a/src/Cafe/OS/common/OSCommon.cpp b/src/Cafe/OS/common/OSCommon.cpp index a4410028..5297f201 100644 --- a/src/Cafe/OS/common/OSCommon.cpp +++ b/src/Cafe/OS/common/OSCommon.cpp @@ -221,5 +221,5 @@ void osLib_load() nsyskbd::nsyskbd_load(); swkbd::load(); camera::load(); - procui_load(); + proc_ui::load(); } diff --git a/src/Cafe/OS/libs/coreinit/coreinit.cpp b/src/Cafe/OS/libs/coreinit/coreinit.cpp index 660f874f..e18d0e8d 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit.cpp @@ -179,27 +179,6 @@ void coreinitExport_OSGetSharedData(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 1); } -typedef struct -{ - MPTR getDriverName; - MPTR ukn04; - MPTR onAcquiredForeground; - MPTR onReleaseForeground; - MPTR ukn10; -}OSDriverCallbacks_t; - -void coreinitExport_OSDriver_Register(PPCInterpreter_t* hCPU) -{ -#ifdef CEMU_DEBUG_ASSERT - cemuLog_log(LogType::Force, "OSDriver_Register(0x{:08x},0x{:08x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7], hCPU->gpr[8]); -#endif - OSDriverCallbacks_t* driverCallbacks = (OSDriverCallbacks_t*)memory_getPointerFromVirtualOffset(hCPU->gpr[5]); - - // todo - - osLib_returnFromFunction(hCPU, 0); -} - namespace coreinit { sint32 OSGetCoreId() @@ -379,7 +358,6 @@ void coreinit_load() coreinit::miscInit(); osLib_addFunction("coreinit", "OSGetSharedData", coreinitExport_OSGetSharedData); osLib_addFunction("coreinit", "UCReadSysConfig", coreinitExport_UCReadSysConfig); - osLib_addFunction("coreinit", "OSDriver_Register", coreinitExport_OSDriver_Register); // async callbacks InitializeAsyncCallback(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.h b/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.h index 0be8226c..2a3172c7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_DynLoad.h @@ -2,6 +2,12 @@ namespace coreinit { + enum class RplEntryReason + { + Loaded = 1, + Unloaded = 2, + }; + uint32 OSDynLoad_SetAllocator(MPTR allocFunc, MPTR freeFunc); void OSDynLoad_SetTLSAllocator(MPTR allocFunc, MPTR freeFunc); uint32 OSDynLoad_GetAllocator(betype<MPTR>* funcAlloc, betype<MPTR>* funcFree); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index a007f5ee..0ca8fb8e 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -837,7 +837,7 @@ namespace coreinit FSAsyncResult* FSGetAsyncResult(OSMessage* msg) { - return (FSAsyncResult*)memory_getPointerFromVirtualOffset(_swapEndianU32(msg->message)); + return (FSAsyncResult*)memory_getPointerFromVirtualOffset(msg->message); } sint32 __FSProcessAsyncResult(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, sint32 fsStatus, uint32 errHandling) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp index 4b147473..cff4ee2b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp @@ -126,7 +126,7 @@ namespace coreinit return physicalAddr; } - void OSMemoryBarrier(PPCInterpreter_t* hCPU) + void OSMemoryBarrier() { // no-op } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Memory.h b/src/Cafe/OS/libs/coreinit/coreinit_Memory.h index cfb3ed06..0a212f61 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Memory.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Memory.h @@ -5,4 +5,9 @@ namespace coreinit void InitializeMemory(); void OSGetMemBound(sint32 memType, MPTR* offsetOutput, uint32* sizeOutput); + + void* OSBlockMove(MEMPTR<void> dst, MEMPTR<void> src, uint32 size, bool flushDC); + void* OSBlockSet(MEMPTR<void> dst, uint32 value, uint32 size); + + void OSMemoryBarrier(); } \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.cpp index 6e6a7bc1..cbcfa4d1 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.cpp @@ -3,6 +3,8 @@ namespace coreinit { + void UpdateSystemMessageQueue(); + void HandleReceivedSystemMessage(OSMessage* msg); SysAllocator<OSMessageQueue> g_systemMessageQueue; SysAllocator<OSMessage, 16> _systemMessageQueueArray; @@ -27,6 +29,9 @@ namespace coreinit bool OSReceiveMessage(OSMessageQueue* msgQueue, OSMessage* msg, uint32 flags) { + bool isSystemMessageQueue = (msgQueue == g_systemMessageQueue); + if(isSystemMessageQueue) + UpdateSystemMessageQueue(); __OSLockScheduler(msgQueue); while (msgQueue->usedCount == (uint32be)0) { @@ -50,6 +55,8 @@ namespace coreinit if (!msgQueue->threadQueueSend.isEmpty()) msgQueue->threadQueueSend.wakeupSingleThreadWaitQueue(true); __OSUnlockScheduler(msgQueue); + if(isSystemMessageQueue) + HandleReceivedSystemMessage(msg); return true; } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.h b/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.h index 6741ab84..35fdc3e7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_MessageQueue.h @@ -3,12 +3,21 @@ namespace coreinit { + enum class SysMessageId : uint32 + { + MsgAcquireForeground = 0xFACEF000, + MsgReleaseForeground = 0xFACEBACC, + MsgExit = 0xD1E0D1E0, + HomeButtonDenied = 0xCCC0FFEE, + NetIoStartOrStop = 0xAAC0FFEE, + }; + struct OSMessage { - MPTR message; - uint32 data0; - uint32 data1; - uint32 data2; + uint32be message; + uint32be data0; + uint32be data1; + uint32be data2; }; struct OSMessageQueue @@ -36,5 +45,7 @@ namespace coreinit bool OSPeekMessage(OSMessageQueue* msgQueue, OSMessage* msg); sint32 OSSendMessage(OSMessageQueue* msgQueue, OSMessage* msg, uint32 flags); + OSMessageQueue* OSGetSystemMessageQueue(); + void InitializeMessageQueue(); }; \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp index 2d7468cf..e2b50661 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp @@ -1,5 +1,6 @@ #include "Cafe/OS/common/OSCommon.h" #include "Cafe/OS/libs/coreinit/coreinit_Misc.h" +#include "Cafe/OS/libs/coreinit/coreinit_MessageQueue.h" #include "Cafe/CafeSystem.h" #include "Cafe/Filesystem/fsc.h" #include <pugixml.hpp> @@ -371,6 +372,23 @@ namespace coreinit return true; } + uint32 OSGetPFID() + { + return 15; // hardcoded as game + } + + uint32 OSGetUPID() + { + return OSGetPFID(); + } + + uint64 s_currentTitleId; + + uint64 OSGetTitleID() + { + return s_currentTitleId; + } + uint32 s_sdkVersion; uint32 __OSGetProcessSDKVersion() @@ -470,9 +488,78 @@ namespace coreinit return 0; } + void OSReleaseForeground() + { + cemuLog_logDebug(LogType::Force, "OSReleaseForeground not implemented"); + } + + bool s_transitionToBackground = false; + bool s_transitionToForeground = false; + + void StartBackgroundForegroundTransition() + { + s_transitionToBackground = true; + s_transitionToForeground = true; + } + + // called at the beginning of OSReceiveMessage if the queue is the system message queue + void UpdateSystemMessageQueue() + { + if(!OSIsInterruptEnabled()) + return; + cemu_assert_debug(!__OSHasSchedulerLock()); + // normally syscall 0x2E is used to get the next message + // for now we just have some preliminary logic here to allow a fake transition to background & foreground + if(s_transitionToBackground) + { + // add transition to background message + OSMessage msg{}; + msg.data0 = stdx::to_underlying(SysMessageId::MsgReleaseForeground); + msg.data1 = 0; // 1 -> System is shutting down 0 -> Begin transitioning to background + OSMessageQueue* systemMessageQueue = coreinit::OSGetSystemMessageQueue(); + if(OSSendMessage(systemMessageQueue, &msg, 0)) + s_transitionToBackground = false; + return; + } + if(s_transitionToForeground) + { + // add transition to foreground message + OSMessage msg{}; + msg.data0 = stdx::to_underlying(SysMessageId::MsgAcquireForeground); + msg.data1 = 1; // ? + msg.data2 = 1; // ? + OSMessageQueue* systemMessageQueue = coreinit::OSGetSystemMessageQueue(); + if(OSSendMessage(systemMessageQueue, &msg, 0)) + s_transitionToForeground = false; + return; + } + } + + // called when OSReceiveMessage returns a message from the system message queue + void HandleReceivedSystemMessage(OSMessage* msg) + { + cemu_assert_debug(!__OSHasSchedulerLock()); + cemuLog_log(LogType::Force, "Receiving message: {:08x}", (uint32)msg->data0); + } + + uint32 OSDriver_Register(uint32 moduleHandle, sint32 priority, OSDriverInterface* driverCallbacks, sint32 driverId, uint32be* outUkn1, uint32be* outUkn2, uint32be* outUkn3) + { + cemuLog_logDebug(LogType::Force, "OSDriver_Register stubbed"); + return 0; + } + + uint32 OSDriver_Deregister(uint32 moduleHandle, sint32 driverId) + { + cemuLog_logDebug(LogType::Force, "OSDriver_Deregister stubbed"); + return 0; + } + void miscInit() { + s_currentTitleId = CafeSystem::GetForegroundTitleId(); s_sdkVersion = CafeSystem::GetForegroundTitleSDKVersion(); + s_transitionToBackground = false; + s_transitionToForeground = false; cafeExportRegister("coreinit", __os_snprintf, LogType::Placeholder); cafeExportRegister("coreinit", OSReport, LogType::Placeholder); @@ -480,6 +567,10 @@ namespace coreinit cafeExportRegister("coreinit", COSWarn, LogType::Placeholder); cafeExportRegister("coreinit", OSLogPrintf, LogType::Placeholder); cafeExportRegister("coreinit", OSConsoleWrite, LogType::Placeholder); + + cafeExportRegister("coreinit", OSGetPFID, LogType::Placeholder); + cafeExportRegister("coreinit", OSGetUPID, LogType::Placeholder); + cafeExportRegister("coreinit", OSGetTitleID, LogType::Placeholder); cafeExportRegister("coreinit", __OSGetProcessSDKVersion, LogType::Placeholder); g_homeButtonMenuEnabled = true; // enabled by default @@ -489,6 +580,11 @@ namespace coreinit cafeExportRegister("coreinit", OSLaunchTitleByPathl, LogType::Placeholder); cafeExportRegister("coreinit", OSRestartGame, LogType::Placeholder); + + cafeExportRegister("coreinit", OSReleaseForeground, LogType::Placeholder); + + cafeExportRegister("coreinit", OSDriver_Register, LogType::Placeholder); + cafeExportRegister("coreinit", OSDriver_Deregister, LogType::Placeholder); } }; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.h b/src/Cafe/OS/libs/coreinit/coreinit_Misc.h index 4a74d490..7abba92f 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.h @@ -2,9 +2,29 @@ namespace coreinit { + uint32 OSGetUPID(); + uint32 OSGetPFID(); + uint64 OSGetTitleID(); uint32 __OSGetProcessSDKVersion(); uint32 OSLaunchTitleByPathl(const char* path, uint32 pathLength, uint32 argc); uint32 OSRestartGame(uint32 argc, MEMPTR<char>* argv); + void OSReleaseForeground(); + + void StartBackgroundForegroundTransition(); + + struct OSDriverInterface + { + MEMPTR<void> getDriverName; + MEMPTR<void> init; + MEMPTR<void> onAcquireForeground; + MEMPTR<void> onReleaseForeground; + MEMPTR<void> done; + }; + static_assert(sizeof(OSDriverInterface) == 0x14); + + uint32 OSDriver_Register(uint32 moduleHandle, sint32 priority, OSDriverInterface* driverCallbacks, sint32 driverId, uint32be* outUkn1, uint32be* outUkn2, uint32be* outUkn3); + uint32 OSDriver_Deregister(uint32 moduleHandle, sint32 driverId); + void miscInit(); }; \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 809d7be4..654e57a8 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -294,9 +294,9 @@ namespace coreinit __OSUnlockScheduler(); } - bool OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop2, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType) + bool OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType) { - OSCreateThreadInternal(thread, entryPoint, memory_getVirtualOffsetFromPointer(stackTop2) - stackSize, stackSize, attr, threadType); + OSCreateThreadInternal(thread, entryPoint, memory_getVirtualOffsetFromPointer(stackTop) - stackSize, stackSize, attr, threadType); thread->context.gpr[3] = _swapEndianU32(numParam); // num arguments thread->context.gpr[4] = _swapEndianU32(memory_getVirtualOffsetFromPointer(ptrParam)); // arguments pointer __OSSetThreadBasePriority(thread, priority); @@ -317,9 +317,15 @@ namespace coreinit return true; } - bool OSCreateThread(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop2, sint32 stackSize, sint32 priority, uint32 attr) + bool OSCreateThread(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr) { - return OSCreateThreadType(thread, entryPoint, numParam, ptrParam, stackTop2, stackSize, priority, attr, OSThread_t::THREAD_TYPE::TYPE_APP); + return OSCreateThreadType(thread, entryPoint, numParam, ptrParam, stackTop, stackSize, priority, attr, OSThread_t::THREAD_TYPE::TYPE_APP); + } + + // alias to OSCreateThreadType, similar to OSCreateThread, but with an additional parameter for the thread type + bool __OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType) + { + return OSCreateThreadType(thread, entryPoint, numParam, ptrParam, stackTop, stackSize, priority, attr, threadType); } bool OSRunThread(OSThread_t* thread, MPTR funcAddress, sint32 numParam, void* ptrParam) @@ -445,12 +451,12 @@ namespace coreinit return currentThread->specificArray[index].GetPtr(); } - void OSSetThreadName(OSThread_t* thread, char* name) + void OSSetThreadName(OSThread_t* thread, const char* name) { thread->threadName = name; } - char* OSGetThreadName(OSThread_t* thread) + const char* OSGetThreadName(OSThread_t* thread) { return thread->threadName.GetPtr(); } @@ -1371,6 +1377,7 @@ namespace coreinit { cafeExportRegister("coreinit", OSCreateThreadType, LogType::CoreinitThread); cafeExportRegister("coreinit", OSCreateThread, LogType::CoreinitThread); + cafeExportRegister("coreinit", __OSCreateThreadType, LogType::CoreinitThread); cafeExportRegister("coreinit", OSExitThread, LogType::CoreinitThread); cafeExportRegister("coreinit", OSGetCurrentThread, LogType::CoreinitThread); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index e619d5b6..b401d96d 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -449,7 +449,7 @@ struct OSThread_t /* +0x578 */ sint32 alarmRelatedUkn; /* +0x57C */ std::array<MEMPTR<void>, 16> specificArray; /* +0x5BC */ betype<THREAD_TYPE> type; - /* +0x5C0 */ MEMPTR<char> threadName; + /* +0x5C0 */ MEMPTR<const char> threadName; /* +0x5C4 */ MPTR waitAlarm; // used only by OSWaitEventWithTimeout/OSSignalEvent ? /* +0x5C8 */ uint32 userStackPointer; @@ -505,6 +505,7 @@ namespace coreinit void* OSGetDefaultThreadStack(sint32 coreIndex, uint32& size); bool OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop2, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType); + bool __OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType); void OSCreateThreadInternal(OSThread_t* thread, uint32 entryPoint, MPTR stackLowerBaseAddr, uint32 stackSize, uint8 affinityMask, OSThread_t::THREAD_TYPE threadType); bool OSRunThread(OSThread_t* thread, MPTR funcAddress, sint32 numParam, void* ptrParam); void OSExitThread(sint32 exitValue); @@ -519,8 +520,8 @@ namespace coreinit bool OSSetThreadPriority(OSThread_t* thread, sint32 newPriority); uint32 OSGetThreadAffinity(OSThread_t* thread); - void OSSetThreadName(OSThread_t* thread, char* name); - char* OSGetThreadName(OSThread_t* thread); + void OSSetThreadName(OSThread_t* thread, const char* name); + const char* OSGetThreadName(OSThread_t* thread); sint32 __OSResumeThreadInternal(OSThread_t* thread, sint32 resumeCount); sint32 OSResumeThread(OSThread_t* thread); @@ -530,6 +531,7 @@ namespace coreinit void OSSuspendThread(OSThread_t* thread); void OSSleepThread(OSThreadQueue* threadQueue); void OSWakeupThread(OSThreadQueue* threadQueue); + bool OSJoinThread(OSThread_t* thread, uint32be* exitValue); void OSTestThreadCancelInternal(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp index 5a75b406..d6fc27b2 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp @@ -22,10 +22,9 @@ namespace coreinit osLib_returnFromFunction(hCPU, (uint32)osTime); } - void export_OSGetTime(PPCInterpreter_t* hCPU) + uint64 OSGetTime() { - uint64 osTime = coreinit_getOSTime(); - osLib_returnFromFunction64(hCPU, osTime); + return coreinit_getOSTime(); } void export_OSGetSystemTime(PPCInterpreter_t* hCPU) @@ -360,7 +359,7 @@ namespace coreinit void InitializeTimeAndCalendar() { - osLib_addFunction("coreinit", "OSGetTime", export_OSGetTime); + cafeExportRegister("coreinit", OSGetTime, LogType::Placeholder); osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); osLib_addFunction("coreinit", "OSGetTick", export_OSGetTick); osLib_addFunction("coreinit", "OSGetSystemTick", export_OSGetSystemTick); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.h b/src/Cafe/OS/libs/coreinit/coreinit_Time.h index f5dcf22e..018e8eb7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.h @@ -45,7 +45,8 @@ namespace coreinit }; void OSTicksToCalendarTime(uint64 ticks, OSCalendarTime_t* calenderStruct); - + uint64 OSGetTime(); + uint64 coreinit_getOSTime(); uint64 coreinit_getTimerTick(); diff --git a/src/Cafe/OS/libs/gx2/GX2_Misc.h b/src/Cafe/OS/libs/gx2/GX2_Misc.h index e6ac8010..38a728c1 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Misc.h +++ b/src/Cafe/OS/libs/gx2/GX2_Misc.h @@ -19,5 +19,7 @@ namespace GX2 void GX2SetTVBuffer(void* imageBuffePtr, uint32 imageBufferSize, E_TVRES tvResolutionMode, uint32 surfaceFormat, E_TVBUFFERMODE bufferMode); void GX2SetTVGamma(float gamma); + void GX2Invalidate(uint32 invalidationFlags, MPTR invalidationAddr, uint32 invalidationSize); + void GX2MiscInit(); }; \ No newline at end of file diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv.cpp index 99c113c4..1916a18d 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv.cpp @@ -9,6 +9,7 @@ #include "Cafe/OS/libs/proc_ui/proc_ui.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h" +#include "Cafe/OS/libs/coreinit/coreinit_Misc.h" namespace nn { @@ -37,7 +38,7 @@ namespace nn void StubPostAppReleaseBackground(PPCInterpreter_t* hCPU) { coreinit::OSSleepTicks(ESPRESSO_TIMER_CLOCK * 2); // Sleep 2s - ProcUI_SendForegroundMessage(); + coreinit::StartBackgroundForegroundTransition(); } sint32 StubPostApp(void* pAnyPostParam) diff --git a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp index 7de8691a..91d15af4 100644 --- a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp +++ b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp @@ -1,57 +1,905 @@ #include "Cafe/OS/common/OSCommon.h" +#include "Cafe/OS/libs/coreinit/coreinit_Alarm.h" +#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" +#include "Cafe/OS/libs/coreinit/coreinit_MessageQueue.h" +#include "Cafe/OS/libs/coreinit/coreinit_Misc.h" +#include "Cafe/OS/libs/coreinit/coreinit_Memory.h" +#include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h" +#include "Cafe/OS/libs/coreinit/coreinit_Time.h" +#include "Cafe/OS/libs/coreinit/coreinit_FG.h" +#include "Cafe/OS/libs/coreinit/coreinit_DynLoad.h" +#include "Cafe/OS/libs/gx2/GX2_Misc.h" +#include "Cafe/OS/RPL/rpl.h" +#include "Common/CafeString.h" #include "proc_ui.h" -#define PROCUI_STATUS_FOREGROUND 0 -#define PROCUI_STATUS_BACKGROUND 1 -#define PROCUI_STATUS_RELEASING 2 -#define PROCUI_STATUS_EXIT 3 +// proc_ui is a utility wrapper to help apps with the transition between foreground and background +// some games (like Xenoblades Chronicles X) bypass proc_ui.rpl and listen to OSGetSystemMessageQueue() directly -uint32 ProcUIProcessMessages() +using namespace coreinit; + +namespace proc_ui { - return PROCUI_STATUS_FOREGROUND; -} + enum class ProcUICoreThreadCommand + { + AcquireForeground = 0x0, + ReleaseForeground = 0x1, + Exit = 0x2, + NetIoStart = 0x3, + NetIoStop = 0x4, + HomeButtonDenied = 0x5, + Initial = 0x6 + }; + + struct ProcUIInternalCallbackEntry + { + coreinit::OSAlarm_t alarm; + uint64be tickDelay; + MEMPTR<void> funcPtr; + MEMPTR<void> userParam; + sint32be priority; + MEMPTR<ProcUIInternalCallbackEntry> next; + }; + static_assert(sizeof(ProcUIInternalCallbackEntry) == 0x70); + + struct ProcUICallbackList + { + MEMPTR<ProcUIInternalCallbackEntry> first; + }; + static_assert(sizeof(ProcUICallbackList) == 0x4); + + std::atomic_bool s_isInitialized; + bool s_isInForeground; + bool s_isInShutdown; + bool s_isForegroundProcess; + bool s_previouslyWasBlocking; + ProcUIStatus s_currentProcUIStatus; + MEMPTR<void> s_saveCallback; // no param and no return value, set by ProcUIInit() + MEMPTR<void> s_saveCallbackEx; // with custom param and return value, set by ProcUIInitEx() + MEMPTR<void> s_saveCallbackExUserParam; + MEMPTR<coreinit::OSMessageQueue> s_systemMessageQueuePtr; + SysAllocator<coreinit::OSEvent> s_eventStateMessageReceived; + SysAllocator<coreinit::OSEvent> s_eventWaitingBeforeReleaseForeground; + SysAllocator<coreinit::OSEvent> s_eventBackgroundThreadGotMessage; + // procUI core threads + uint32 s_coreThreadStackSize; + bool s_coreThreadsCreated; + std::atomic<ProcUICoreThreadCommand> s_commandForCoreThread; + SysAllocator<OSThread_t> s_coreThreadArray[Espresso::CORE_COUNT]; + MEMPTR<void> s_coreThreadStackPerCore[Espresso::CORE_COUNT]; + SysAllocator<CafeString<22>> s_coreThread0NameBuffer; + SysAllocator<CafeString<22>> s_coreThread1NameBuffer; + SysAllocator<CafeString<22>> s_coreThread2NameBuffer; + SysAllocator<coreinit::OSEvent> s_eventCoreThreadsNewCommandReady; + SysAllocator<coreinit::OSEvent> s_eventCoreThreadsCommandDone; + SysAllocator<coreinit::OSRendezvous> s_coreThreadRendezvousA; + SysAllocator<coreinit::OSRendezvous> s_coreThreadRendezvousB; + SysAllocator<coreinit::OSRendezvous> s_coreThreadRendezvousC; + // background thread + MEMPTR<void> s_backgroundThreadStack; + SysAllocator<OSThread_t> s_backgroundThread; + // user defined heap + MEMPTR<void> s_memoryPoolHeapPtr; + MEMPTR<void> s_memAllocPtr; + MEMPTR<void> s_memFreePtr; + // draw done release + bool s_drawDoneReleaseCalled; + // memory storage + MEMPTR<void> s_bucketStorageBasePtr; + MEMPTR<void> s_mem1StorageBasePtr; + // callbacks + ProcUICallbackList s_callbacksType0_AcquireForeground[Espresso::CORE_COUNT]; + ProcUICallbackList s_callbacksType1_ReleaseForeground[Espresso::CORE_COUNT]; + ProcUICallbackList s_callbacksType2_Exit[Espresso::CORE_COUNT]; + ProcUICallbackList s_callbacksType3_NetIoStart[Espresso::CORE_COUNT]; + ProcUICallbackList s_callbacksType4_NetIoStop[Espresso::CORE_COUNT]; + ProcUICallbackList s_callbacksType5_HomeButtonDenied[Espresso::CORE_COUNT]; + ProcUICallbackList* const s_CallbackTables[stdx::to_underlying(ProcUICallbackId::COUNT)] = + {s_callbacksType0_AcquireForeground, s_callbacksType1_ReleaseForeground, s_callbacksType2_Exit, s_callbacksType3_NetIoStart, s_callbacksType4_NetIoStop, s_callbacksType5_HomeButtonDenied}; + ProcUICallbackList s_backgroundCallbackList; + // driver + bool s_driverIsActive; + uint32be s_driverArgUkn1; + uint32be s_driverArgUkn2; + bool s_driverInBackground; + SysAllocator<OSDriverInterface> s_ProcUIDriver; + SysAllocator<CafeString<16>> s_ProcUIDriverName; -uint32 ProcUIInForeground(PPCInterpreter_t* hCPU) -{ - return 1; // true means application is in foreground -} + void* _AllocMem(uint32 size) + { + MEMPTR<void> r{PPCCoreCallback(s_memAllocPtr, size)}; + return r.GetPtr(); + } -struct ProcUICallback -{ - MPTR callback; - void* data; - sint32 priority; + void _FreeMem(void* ptr) + { + PPCCoreCallback(s_memFreePtr.GetMPTR(), ptr); + } + + void ClearCallbacksWithoutMemFree() + { + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + for (sint32 i = 0; i < stdx::to_underlying(ProcUICallbackId::COUNT); i++) + s_CallbackTables[i][coreIndex].first = nullptr; + } + s_backgroundCallbackList.first = nullptr; + } + + void ShutdownThreads() + { + if ( !s_coreThreadsCreated) + return; + s_commandForCoreThread = ProcUICoreThreadCommand::Initial; + coreinit::OSMemoryBarrier(); + OSSignalEvent(&s_eventCoreThreadsNewCommandReady); + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + coreinit::OSJoinThread(&s_coreThreadArray[coreIndex], nullptr); + for (sint32 i = 0; i < stdx::to_underlying(ProcUICallbackId::COUNT); i++) + { + s_CallbackTables[i][coreIndex].first = nullptr; // memory is not cleanly released? + } + } + OSResetEvent(&s_eventCoreThreadsNewCommandReady); + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + _FreeMem(s_coreThreadStackPerCore[coreIndex]); + s_coreThreadStackPerCore[coreIndex] = nullptr; + } + _FreeMem(s_backgroundThreadStack); + s_backgroundThreadStack = nullptr; + s_backgroundCallbackList.first = nullptr; // memory is not cleanly released? + s_coreThreadsCreated = false; + } + + void DoCallbackChain(ProcUIInternalCallbackEntry* entry) + { + while (entry) + { + uint32 r = PPCCoreCallback(entry->funcPtr, entry->userParam); + if ( r ) + cemuLog_log(LogType::APIErrors, "ProcUI: Callback returned error {}\n", r); + entry = entry->next; + } + } + + void AlarmDoBackgroundCallback(PPCInterpreter_t* hCPU) + { + coreinit::OSAlarm_t* arg = MEMPTR<coreinit::OSAlarm_t>(hCPU->gpr[3]); + ProcUIInternalCallbackEntry* entry = (ProcUIInternalCallbackEntry*)arg; + uint32 r = PPCCoreCallback(entry->funcPtr, entry->userParam); + if ( r ) + cemuLog_log(LogType::APIErrors, "ProcUI: Background callback returned error {}\n", r); + osLib_returnFromFunction(hCPU, 0); // return type is void + } + + void StartBackgroundAlarms() + { + ProcUIInternalCallbackEntry* cb = s_backgroundCallbackList.first; + while(cb) + { + coreinit::OSCreateAlarm(&cb->alarm); + uint64 currentTime = coreinit::OSGetTime(); + coreinit::OSSetPeriodicAlarm(&cb->alarm, currentTime, cb->tickDelay, RPLLoader_MakePPCCallable(AlarmDoBackgroundCallback)); + cb = cb->next; + } + } + + void CancelBackgroundAlarms() + { + ProcUIInternalCallbackEntry* entry = s_backgroundCallbackList.first; + while (entry) + { + OSCancelAlarm(&entry->alarm); + entry = entry->next; + } + } + + void ProcUICoreThread(PPCInterpreter_t* hCPU) + { + uint32 coreIndex = hCPU->gpr[3]; + cemu_assert_debug(coreIndex == OSGetCoreId()); + while (true) + { + OSWaitEvent(&s_eventCoreThreadsNewCommandReady); + ProcUIInternalCallbackEntry* cbChain = nullptr; + cemuLog_logDebug(LogType::Force, "ProcUI: Core {} got command {}", coreIndex, (uint32)s_commandForCoreThread.load()); + auto cmd = s_commandForCoreThread.load(); + switch(cmd) + { + case ProcUICoreThreadCommand::Initial: + { + // signal to shut down thread + osLib_returnFromFunction(hCPU, 0); + return; + } + case ProcUICoreThreadCommand::AcquireForeground: + cbChain = s_callbacksType0_AcquireForeground[coreIndex].first; + break; + case ProcUICoreThreadCommand::ReleaseForeground: + cbChain = s_callbacksType1_ReleaseForeground[coreIndex].first; + break; + case ProcUICoreThreadCommand::Exit: + cbChain = s_callbacksType2_Exit[coreIndex].first; + break; + case ProcUICoreThreadCommand::NetIoStart: + cbChain = s_callbacksType3_NetIoStart[coreIndex].first; + break; + case ProcUICoreThreadCommand::NetIoStop: + cbChain = s_callbacksType4_NetIoStop[coreIndex].first; + break; + case ProcUICoreThreadCommand::HomeButtonDenied: + cbChain = s_callbacksType5_HomeButtonDenied[coreIndex].first; + break; + default: + cemu_assert_suspicious(); // invalid command + } + if(cmd == ProcUICoreThreadCommand::AcquireForeground) + { + if (coreIndex == 2) + CancelBackgroundAlarms(); + cbChain = s_callbacksType0_AcquireForeground[coreIndex].first; + } + else if(cmd == ProcUICoreThreadCommand::ReleaseForeground) + { + if (coreIndex == 2) + StartBackgroundAlarms(); + cbChain = s_callbacksType1_ReleaseForeground[coreIndex].first; + } + DoCallbackChain(cbChain); + OSWaitRendezvous(&s_coreThreadRendezvousA, 7); + if ( !coreIndex ) + { + OSInitRendezvous(&s_coreThreadRendezvousC); + OSResetEvent(&s_eventCoreThreadsNewCommandReady); + } + OSWaitRendezvous(&s_coreThreadRendezvousB, 7); + if ( !coreIndex ) + { + OSInitRendezvous(&s_coreThreadRendezvousA); + OSSignalEvent(&s_eventCoreThreadsCommandDone); + } + OSWaitRendezvous(&s_coreThreadRendezvousC, 7); + if ( !coreIndex ) + OSInitRendezvous(&s_coreThreadRendezvousB); + if (cmd == ProcUICoreThreadCommand::ReleaseForeground) + { + OSWaitEvent(&s_eventWaitingBeforeReleaseForeground); + OSReleaseForeground(); + } + } + osLib_returnFromFunction(hCPU, 0); + } + + void RecreateProcUICoreThreads() + { + ShutdownThreads(); + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + s_coreThreadStackPerCore[coreIndex] = _AllocMem(s_coreThreadStackSize); + } + s_backgroundThreadStack = _AllocMem(s_coreThreadStackSize); + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + __OSCreateThreadType(&s_coreThreadArray[coreIndex], RPLLoader_MakePPCCallable(ProcUICoreThread), coreIndex, nullptr, + (uint8*)s_coreThreadStackPerCore[coreIndex].GetPtr() + s_coreThreadStackSize, s_coreThreadStackSize, 16, + (1<<coreIndex), OSThread_t::THREAD_TYPE::TYPE_DRIVER); + OSResumeThread(&s_coreThreadArray[coreIndex]); + } + s_coreThread0NameBuffer->assign("{SYS ProcUI Core 0}"); + s_coreThread1NameBuffer->assign("{SYS ProcUI Core 1}"); + s_coreThread2NameBuffer->assign("{SYS ProcUI Core 2}"); + OSSetThreadName(&s_coreThreadArray[0], s_coreThread0NameBuffer->c_str()); + OSSetThreadName(&s_coreThreadArray[1], s_coreThread1NameBuffer->c_str()); + OSSetThreadName(&s_coreThreadArray[2], s_coreThread2NameBuffer->c_str()); + s_coreThreadsCreated = true; + } + + void _SubmitCommandToCoreThreads(ProcUICoreThreadCommand cmd) + { + s_commandForCoreThread = cmd; + OSMemoryBarrier(); + OSResetEvent(&s_eventCoreThreadsCommandDone); + OSSignalEvent(&s_eventCoreThreadsNewCommandReady); + OSWaitEvent(&s_eventCoreThreadsCommandDone); + } + + void ProcUIInitInternal() + { + if( s_isInitialized.exchange(true) ) + return; + if (!s_memoryPoolHeapPtr) + { + // user didn't specify a custom heap, use default heap instead + s_memAllocPtr = gCoreinitData->MEMAllocFromDefaultHeap.GetMPTR(); + s_memFreePtr = gCoreinitData->MEMFreeToDefaultHeap.GetMPTR(); + } + OSInitEvent(&s_eventStateMessageReceived, OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_MANUAL); + OSInitEvent(&s_eventCoreThreadsNewCommandReady, OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_MANUAL); + OSInitEvent(&s_eventWaitingBeforeReleaseForeground, OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_MANUAL); + OSInitEvent(&s_eventCoreThreadsCommandDone, OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_MANUAL); + OSInitRendezvous(&s_coreThreadRendezvousA); + OSInitRendezvous(&s_coreThreadRendezvousB); + OSInitRendezvous(&s_coreThreadRendezvousC); + OSInitEvent(&s_eventBackgroundThreadGotMessage, OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, OSEvent::EVENT_MODE::MODE_MANUAL); + s_currentProcUIStatus = ProcUIStatus::Foreground; + s_drawDoneReleaseCalled = false; + s_isInForeground = true; + s_coreThreadStackSize = 0x2000; + s_systemMessageQueuePtr = coreinit::OSGetSystemMessageQueue(); + uint32 upid = coreinit::OSGetUPID(); + s_isForegroundProcess = upid == 2 || upid == 15; // either Wii U Menu or game title, both are RAMPID 7 (foreground process) + RecreateProcUICoreThreads(); + ClearCallbacksWithoutMemFree(); + } + + void ProcUIInit(MEMPTR<void> callbackReadyToRelease) + { + s_saveCallback = callbackReadyToRelease; + s_saveCallbackEx = nullptr; + s_saveCallbackExUserParam = nullptr; + ProcUIInitInternal(); + } + + void ProcUIInitEx(MEMPTR<void> callbackReadyToReleaseEx, MEMPTR<void> userParam) + { + s_saveCallback = nullptr; + s_saveCallbackEx = callbackReadyToReleaseEx; + s_saveCallbackExUserParam = userParam; + ProcUIInitInternal(); + } + + void ProcUIShutdown() + { + if (!s_isInitialized.exchange(false)) + return; + if ( !s_isInForeground ) + CancelBackgroundAlarms(); + for (sint32 i = 0; i < Espresso::CORE_COUNT; i++) + OSSetThreadPriority(&s_coreThreadArray[i], 0); + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::Exit); + ProcUIClearCallbacks(); + ShutdownThreads(); + } + + bool ProcUIIsRunning() + { + return s_isInitialized; + } + + bool ProcUIInForeground() + { + return s_isInForeground; + } + + bool ProcUIInShutdown() + { + return s_isInShutdown; + } + + void AddCallbackInternal(void* funcPtr, void* userParam, uint64 tickDelay, sint32 priority, ProcUICallbackList& callbackList) + { + if ( __OSGetProcessSDKVersion() < 21102 ) + { + // in earlier COS versions it was possible/allowed to register a callback before initializing ProcUI + s_memAllocPtr = gCoreinitData->MEMAllocFromDefaultHeap.GetMPTR(); + s_memFreePtr = gCoreinitData->MEMFreeToDefaultHeap.GetMPTR(); + } + else if ( !s_isInitialized ) + { + cemuLog_log(LogType::Force, "ProcUI: Trying to register callback before init"); + cemu_assert_suspicious(); + } + ProcUIInternalCallbackEntry* entry = (ProcUIInternalCallbackEntry*)_AllocMem(sizeof(ProcUIInternalCallbackEntry)); + entry->funcPtr = funcPtr; + entry->userParam = userParam; + entry->tickDelay = tickDelay; + entry->priority = priority; + ProcUIInternalCallbackEntry* cur = callbackList.first; + cur = callbackList.first; + if (!cur || cur->priority > priority) + { + // insert as the first element + entry->next = cur; + callbackList.first = entry; + } + else + { + // find the correct position to insert + while (cur->next && cur->next->priority < priority) + cur = cur->next; + entry->next = cur->next; + cur->next = entry; + } + } + + void ProcUIRegisterCallbackCore(ProcUICallbackId callbackType, void* funcPtr, void* userParam, sint32 priority, uint32 coreIndex) + { + if(callbackType >= ProcUICallbackId::COUNT) + { + cemuLog_log(LogType::Force, "ProcUIRegisterCallback: Invalid callback type {}", stdx::to_underlying(callbackType)); + return; + } + if(callbackType != ProcUICallbackId::AcquireForeground) + priority = -priority; + AddCallbackInternal(funcPtr, userParam, priority, 0, s_CallbackTables[stdx::to_underlying(callbackType)][coreIndex]); + } + + void ProcUIRegisterCallback(ProcUICallbackId callbackType, void* funcPtr, void* userParam, sint32 priority) + { + ProcUIRegisterCallbackCore(callbackType, funcPtr, userParam, priority, OSGetCoreId()); + } + + void ProcUIRegisterBackgroundCallback(void* funcPtr, void* userParam, uint64 tickDelay) + { + AddCallbackInternal(funcPtr, userParam, 0, tickDelay, s_backgroundCallbackList); + } + + void FreeCallbackChain(ProcUICallbackList& callbackList) + { + ProcUIInternalCallbackEntry* entry = callbackList.first; + while (entry) + { + ProcUIInternalCallbackEntry* next = entry->next; + _FreeMem(entry); + entry = next; + } + callbackList.first = nullptr; + } + + void ProcUIClearCallbacks() + { + for (sint32 coreIndex = 0; coreIndex < Espresso::CORE_COUNT; coreIndex++) + { + for (sint32 i = 0; i < stdx::to_underlying(ProcUICallbackId::COUNT); i++) + { + FreeCallbackChain(s_CallbackTables[i][coreIndex]); + } + } + if (!s_isInForeground) + CancelBackgroundAlarms(); + FreeCallbackChain(s_backgroundCallbackList); + } + + void ProcUISetSaveCallback(void* funcPtr, void* userParam) + { + s_saveCallback = nullptr; + s_saveCallbackEx = funcPtr; + s_saveCallbackExUserParam = userParam; + } + + void ProcUISetCallbackStackSize(uint32 newStackSize) + { + s_coreThreadStackSize = newStackSize; + if( s_isInitialized ) + RecreateProcUICoreThreads(); + } + + uint32 ProcUICalcMemorySize(uint32 numCallbacks) + { + // each callback entry is 0x70 bytes with 0x14 bytes of allocator overhead (for ExpHeap). But for some reason proc_ui on 5.5.5 seems to reserve 0x8C0 bytes per callback? + uint32 stackReserveSize = (Espresso::CORE_COUNT + 1) * s_coreThreadStackSize; // 3 core threads + 1 message receive thread + uint32 callbackReserveSize = 0x8C0 * numCallbacks; + return stackReserveSize + callbackReserveSize + 100; + } + + void _MemAllocFromMemoryPool(PPCInterpreter_t* hCPU) + { + uint32 size = hCPU->gpr[3]; + MEMPTR<void> r = MEMAllocFromExpHeapEx((MEMHeapHandle)s_memoryPoolHeapPtr.GetPtr(), size, 4); + osLib_returnFromFunction(hCPU, r.GetMPTR()); + } + + void _FreeToMemoryPoolExpHeap(PPCInterpreter_t* hCPU) + { + MEMPTR<void> mem{hCPU->gpr[3]}; + MEMFreeToExpHeap((MEMHeapHandle)s_memoryPoolHeapPtr.GetPtr(), mem.GetPtr()); + osLib_returnFromFunction(hCPU, 0); + } + + sint32 ProcUISetMemoryPool(void* memBase, uint32 size) + { + s_memAllocPtr = RPLLoader_MakePPCCallable(_MemAllocFromMemoryPool); + s_memFreePtr = RPLLoader_MakePPCCallable(_FreeToMemoryPoolExpHeap); + s_memoryPoolHeapPtr = MEMCreateExpHeapEx(memBase, size, MEM_HEAP_OPTION_THREADSAFE); + return s_memoryPoolHeapPtr ? 0 : -1; + } + + void ProcUISetBucketStorage(void* memBase, uint32 size) + { + MEMPTR<void> fgBase; + uint32be fgFreeSize; + OSGetForegroundBucketFreeArea((MPTR*)&fgBase, (MPTR*)&fgFreeSize); + if(fgFreeSize < size) + cemuLog_log(LogType::Force, "ProcUISetBucketStorage: Buffer size too small"); + s_bucketStorageBasePtr = memBase; + } + + void ProcUISetMEM1Storage(void* memBase, uint32 size) + { + MEMPTR<void> memBound; + uint32be memBoundSize; + OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + if(memBoundSize < size) + cemuLog_log(LogType::Force, "ProcUISetMEM1Storage: Buffer size too small"); + s_mem1StorageBasePtr = memBase; + } + + void ProcUIDrawDoneRelease() + { + s_drawDoneReleaseCalled = true; + } + + OSMessage g_lastMsg; + + void ProcUI_BackgroundThread_ReceiveSingleMessage(PPCInterpreter_t* hCPU) + { + // the background thread receives messages in a loop until the title is either exited or foreground is acquired + while ( true ) + { + OSReceiveMessage(s_systemMessageQueuePtr, &g_lastMsg, OS_MESSAGE_BLOCK); // blocking receive + SysMessageId lastMsgId = static_cast<SysMessageId>((uint32)g_lastMsg.data0); + if(lastMsgId == SysMessageId::MsgExit || lastMsgId == SysMessageId::MsgAcquireForeground) + break; + else if (lastMsgId == SysMessageId::HomeButtonDenied) + { + cemu_assert_suspicious(); // Home button denied should not be sent to background app + } + else if ( lastMsgId == SysMessageId::NetIoStartOrStop ) + { + if (g_lastMsg.data1 ) + { + // NetIo start message + for (sint32 i = 0; i < Espresso::CORE_COUNT; i++) + DoCallbackChain(s_callbacksType3_NetIoStart[i].first); + } + else + { + // NetIo stop message + for (sint32 i = 0; i < Espresso::CORE_COUNT; i++) + DoCallbackChain(s_callbacksType4_NetIoStop[i].first); + } + } + else + { + cemuLog_log(LogType::Force, "ProcUI: BackgroundThread received invalid message 0x{:08x}", lastMsgId); + } + } + OSSignalEvent(&s_eventBackgroundThreadGotMessage); + osLib_returnFromFunction(hCPU, 0); + } + + // handle received message + // if the message is Exit this function returns false, in all other cases it returns true + bool ProcessSysMessage(OSMessage* msg) + { + SysMessageId lastMsgId = static_cast<SysMessageId>((uint32)msg->data0); + if ( lastMsgId == SysMessageId::MsgAcquireForeground ) + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Acquire Foreground message"); + s_isInShutdown = false; + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::AcquireForeground); + s_currentProcUIStatus = ProcUIStatus::Foreground; + s_isInForeground = true; + OSMemoryBarrier(); + OSSignalEvent(&s_eventStateMessageReceived); + return true; + } + else if (lastMsgId == SysMessageId::MsgExit) + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Exit message"); + s_isInShutdown = true; + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::Exit); + for (sint32 i = 0; i < Espresso::CORE_COUNT; i++) + FreeCallbackChain(s_callbacksType2_Exit[i]); + s_currentProcUIStatus = ProcUIStatus::Exit; + OSMemoryBarrier(); + OSSignalEvent(&s_eventStateMessageReceived); + return 0; + } + if (lastMsgId == SysMessageId::MsgReleaseForeground) + { + if (msg->data1 != 0) + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Release Foreground message as part of shutdown initiation"); + s_isInShutdown = true; + } + else + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Release Foreground message"); + } + s_currentProcUIStatus = ProcUIStatus::Releasing; + OSResetEvent(&s_eventStateMessageReceived); + // dont submit a command for the core threads yet, we need to wait for ProcUIDrawDoneRelease() + } + else if (lastMsgId == SysMessageId::HomeButtonDenied) + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Home Button Denied message"); + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::HomeButtonDenied); + } + else if ( lastMsgId == SysMessageId::NetIoStartOrStop ) + { + if (msg->data1 != 0) + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Net IO Start message"); + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::NetIoStart); + } + else + { + cemuLog_logDebug(LogType::Force, "ProcUI: Received Net IO Stop message"); + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::NetIoStop); + } + } + else + { + cemuLog_log(LogType::Force, "ProcUI: Received unknown message 0x{:08x}", (uint32)lastMsgId); + } + return true; + } + + ProcUIStatus ProcUIProcessMessages(bool isBlockingInBackground) + { + OSMessage msg; + if (!s_isInitialized) + { + cemuLog_logOnce(LogType::Force, "ProcUIProcessMessages: ProcUI not initialized"); + cemu_assert_suspicious(); + return ProcUIStatus::Foreground; + } + if ( !isBlockingInBackground && OSGetCoreId() != 2 ) + { + cemuLog_logOnce(LogType::Force, "ProcUIProcessMessages: Non-blocking call must run on core 2"); + } + if (s_previouslyWasBlocking && isBlockingInBackground ) + { + cemuLog_logOnce(LogType::Force, "ProcUIProcessMessages: Cannot switch to blocking mode when in background"); + } + s_currentProcUIStatus = s_isInForeground ? ProcUIStatus::Foreground : ProcUIStatus::Background; + if (s_drawDoneReleaseCalled) + { + s_isInForeground = false; + s_currentProcUIStatus = ProcUIStatus::Background; + _SubmitCommandToCoreThreads(ProcUICoreThreadCommand::ReleaseForeground); + OSResetEvent(&s_eventWaitingBeforeReleaseForeground); + if(s_saveCallback) + PPCCoreCallback(s_saveCallback); + if(s_saveCallbackEx) + PPCCoreCallback(s_saveCallbackEx, s_saveCallbackExUserParam); + if (s_isForegroundProcess && isBlockingInBackground) + { + // start background thread + __OSCreateThreadType(&s_backgroundThread, RPLLoader_MakePPCCallable(ProcUI_BackgroundThread_ReceiveSingleMessage), + 0, nullptr, (uint8*)s_backgroundThreadStack.GetPtr() + s_coreThreadStackSize, s_coreThreadStackSize, + 16, (1<<2), OSThread_t::THREAD_TYPE::TYPE_DRIVER); + OSResumeThread(&s_backgroundThread); + s_previouslyWasBlocking = true; + } + cemuLog_logDebug(LogType::Force, "ProcUI: Releasing foreground"); + OSSignalEvent(&s_eventWaitingBeforeReleaseForeground); + s_drawDoneReleaseCalled = false; + } + if (s_isInForeground || !isBlockingInBackground) + { + // non-blocking mode + if ( OSReceiveMessage(s_systemMessageQueuePtr, &msg, 0) ) + { + s_previouslyWasBlocking = false; + if ( !ProcessSysMessage(&msg) ) + return s_currentProcUIStatus; + // continue below, if we are now in background then ProcUIProcessMessages enters blocking mode + } + } + // blocking mode (if in background and param is true) + while (!s_isInForeground && isBlockingInBackground) + { + if ( !s_isForegroundProcess) + { + OSReceiveMessage(s_systemMessageQueuePtr, &msg, OS_MESSAGE_BLOCK); + s_previouslyWasBlocking = false; + if ( !ProcessSysMessage(&msg) ) + return s_currentProcUIStatus; + } + // this code should only run if the background thread was started? Maybe rearrange the code to make this more clear + OSWaitEvent(&s_eventBackgroundThreadGotMessage); + OSResetEvent(&s_eventBackgroundThreadGotMessage); + OSJoinThread(&s_backgroundThread, nullptr); + msg = g_lastMsg; // g_lastMsg is set by the background thread + s_previouslyWasBlocking = false; + if ( !ProcessSysMessage(&msg) ) + return s_currentProcUIStatus; + } + return s_currentProcUIStatus; + } + + ProcUIStatus ProcUISubProcessMessages(bool isBlockingInBackground) + { + if (isBlockingInBackground) + { + while (s_currentProcUIStatus == ProcUIStatus::Background) + OSWaitEvent(&s_eventStateMessageReceived); + } + return s_currentProcUIStatus; + } + + const char* ProcUIDriver_GetName() + { + s_ProcUIDriverName->assign("ProcUI"); + return s_ProcUIDriverName->c_str(); + } + + void ProcUIDriver_Init(/* parameters unknown */) + { + s_driverIsActive = true; + OSMemoryBarrier(); + } + + void ProcUIDriver_OnDone(/* parameters unknown */) + { + if (s_driverIsActive) + { + ProcUIShutdown(); + s_driverIsActive = false; + OSMemoryBarrier(); + } + } + + void StoreMEM1AndFGBucket() + { + if (s_mem1StorageBasePtr) + { + MEMPTR<void> memBound; + uint32be memBoundSize; + OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSBlockMove(s_mem1StorageBasePtr.GetPtr(), memBound.GetPtr(), memBoundSize, true); + } + if (s_bucketStorageBasePtr) + { + MEMPTR<void> memBound; + uint32be memBoundSize; + OSGetForegroundBucketFreeArea((MPTR*)memBound.GetBEPtr(), (MPTR*)&memBoundSize); + OSBlockMove(s_bucketStorageBasePtr.GetPtr(), memBound.GetPtr(), memBoundSize, true); + } + } + + void RestoreMEM1AndFGBucket() + { + if (s_mem1StorageBasePtr) + { + MEMPTR<void> memBound; + uint32be memBoundSize; + OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSBlockMove(memBound.GetPtr(), s_mem1StorageBasePtr, memBoundSize, true); + GX2::GX2Invalidate(0x40, s_mem1StorageBasePtr.GetMPTR(), memBoundSize); + } + if (s_bucketStorageBasePtr) + { + MEMPTR<void> memBound; + uint32be memBoundSize; + OSGetForegroundBucketFreeArea((MPTR*)memBound.GetBEPtr(), (MPTR*)&memBoundSize); + OSBlockMove(memBound.GetPtr(), s_bucketStorageBasePtr, memBoundSize, true); + GX2::GX2Invalidate(0x40, memBound.GetMPTR(), memBoundSize); + } + } + + void ProcUIDriver_OnAcquiredForeground(/* parameters unknown */) + { + if (s_driverInBackground) + { + ProcUIDriver_Init(); + s_driverInBackground = false; + } + else + { + RestoreMEM1AndFGBucket(); + s_driverIsActive = true; + OSMemoryBarrier(); + } + } + + void ProcUIDriver_OnReleaseForeground(/* parameters unknown */) + { + StoreMEM1AndFGBucket(); + s_driverIsActive = false; + OSMemoryBarrier(); + } + + sint32 rpl_entry(uint32 moduleHandle, RplEntryReason reason) + { + if ( reason == RplEntryReason::Loaded ) + { + s_ProcUIDriver->getDriverName = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) {MEMPTR<const char> namePtr(ProcUIDriver_GetName()); osLib_returnFromFunction(hCPU, namePtr.GetMPTR()); }); + s_ProcUIDriver->init = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) {ProcUIDriver_Init(); osLib_returnFromFunction(hCPU, 0); }); + s_ProcUIDriver->onAcquireForeground = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) {ProcUIDriver_OnAcquiredForeground(); osLib_returnFromFunction(hCPU, 0); }); + s_ProcUIDriver->onReleaseForeground = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) {ProcUIDriver_OnReleaseForeground(); osLib_returnFromFunction(hCPU, 0); }); + s_ProcUIDriver->done = RPLLoader_MakePPCCallable([](PPCInterpreter_t* hCPU) {ProcUIDriver_OnDone(); osLib_returnFromFunction(hCPU, 0); }); + + s_driverIsActive = false; + s_driverArgUkn1 = 0; + s_driverArgUkn2 = 0; + s_driverInBackground = false; + uint32be ukn3; + OSDriver_Register(moduleHandle, 200, &s_ProcUIDriver, 0, &s_driverArgUkn1, &s_driverArgUkn2, &ukn3); + if ( ukn3 ) + { + if ( OSGetForegroundBucket(nullptr, nullptr) ) + { + ProcUIDriver_Init(); + OSMemoryBarrier(); + return 0; + } + s_driverInBackground = true; + } + OSMemoryBarrier(); + } + else if ( reason == RplEntryReason::Unloaded ) + { + ProcUIDriver_OnDone(); + OSDriver_Deregister(moduleHandle, 0); + } + return 0; + } + + void reset() + { + // set variables to their initial state as if the RPL was just loaded + s_isInitialized = false; + s_isInShutdown = false; + s_isInForeground = false; // ProcUIInForeground returns false until ProcUIInit(Ex) is called + s_isForegroundProcess = true; + s_saveCallback = nullptr; + s_saveCallbackEx = nullptr; + s_systemMessageQueuePtr = nullptr; + ClearCallbacksWithoutMemFree(); + s_currentProcUIStatus = ProcUIStatus::Foreground; + s_bucketStorageBasePtr = nullptr; + s_mem1StorageBasePtr = nullptr; + s_drawDoneReleaseCalled = false; + s_previouslyWasBlocking = false; + // core threads + s_coreThreadStackSize = 0; + s_coreThreadsCreated = false; + s_commandForCoreThread = ProcUICoreThreadCommand::Initial; + // background thread + s_backgroundThreadStack = nullptr; + // user defined heap + s_memoryPoolHeapPtr = nullptr; + s_memAllocPtr = nullptr; + s_memFreePtr = nullptr; + // driver + s_driverIsActive = false; + s_driverInBackground = false; + } + + void load() + { + reset(); + + cafeExportRegister("proc_ui", ProcUIInit, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIInitEx, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIShutdown, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIIsRunning, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIInForeground, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIInShutdown, LogType::ProcUi); + + cafeExportRegister("proc_ui", ProcUIRegisterCallbackCore, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIRegisterCallback, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIRegisterBackgroundCallback, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIClearCallbacks, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUISetSaveCallback, LogType::ProcUi); + + cafeExportRegister("proc_ui", ProcUISetCallbackStackSize, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUICalcMemorySize, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUISetMemoryPool, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUISetBucketStorage, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUISetMEM1Storage, LogType::ProcUi); + + cafeExportRegister("proc_ui", ProcUIDrawDoneRelease, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUIProcessMessages, LogType::ProcUi); + cafeExportRegister("proc_ui", ProcUISubProcessMessages, LogType::ProcUi); + + // manually call rpl_entry for now + rpl_entry(-1, RplEntryReason::Loaded); + } }; -std::unordered_map<uint32, ProcUICallback> g_Callbacks; - -uint32 ProcUIRegisterCallback(uint32 message, MPTR callback, void* data, sint32 priority) -{ - g_Callbacks.insert_or_assign(message, ProcUICallback{ .callback = callback, .data = data, .priority = priority }); - return 0; -} - -void ProcUI_SendBackgroundMessage() -{ - if (g_Callbacks.contains(PROCUI_STATUS_BACKGROUND)) - { - ProcUICallback& callback = g_Callbacks[PROCUI_STATUS_BACKGROUND]; - PPCCoreCallback(callback.callback, callback.data); - } -} - -void ProcUI_SendForegroundMessage() -{ - if (g_Callbacks.contains(PROCUI_STATUS_FOREGROUND)) - { - ProcUICallback& callback = g_Callbacks[PROCUI_STATUS_FOREGROUND]; - PPCCoreCallback(callback.callback, callback.data); - } -} - -void procui_load() -{ - cafeExportRegister("proc_ui", ProcUIRegisterCallback, LogType::ProcUi); - cafeExportRegister("proc_ui", ProcUIProcessMessages, LogType::ProcUi); - cafeExportRegister("proc_ui", ProcUIInForeground, LogType::ProcUi); -} \ No newline at end of file diff --git a/src/Cafe/OS/libs/proc_ui/proc_ui.h b/src/Cafe/OS/libs/proc_ui/proc_ui.h index 1cd04fb1..8de7bb4d 100644 --- a/src/Cafe/OS/libs/proc_ui/proc_ui.h +++ b/src/Cafe/OS/libs/proc_ui/proc_ui.h @@ -1,5 +1,44 @@ -void procui_load(); +namespace proc_ui +{ + enum class ProcUIStatus + { + Foreground = 0, + Background = 1, + Releasing = 2, + Exit = 3 + }; -void ProcUI_SendForegroundMessage(); -void ProcUI_SendBackgroundMessage(); \ No newline at end of file + enum class ProcUICallbackId + { + AcquireForeground = 0, + ReleaseForeground = 1, + Exit = 2, + NetIoStart = 3, + NetIoStop = 4, + HomeButtonDenied = 5, + COUNT = 6 + }; + + void ProcUIInit(MEMPTR<void> callbackReadyToRelease); + void ProcUIInitEx(MEMPTR<void> callbackReadyToReleaseEx, MEMPTR<void> userParam); + void ProcUIShutdown(); + bool ProcUIIsRunning(); + bool ProcUIInForeground(); + bool ProcUIInShutdown(); + void ProcUIRegisterCallback(ProcUICallbackId callbackType, void* funcPtr, void* userParam, sint32 priority); + void ProcUIRegisterCallbackCore(ProcUICallbackId callbackType, void* funcPtr, void* userParam, sint32 priority, uint32 coreIndex); + void ProcUIRegisterBackgroundCallback(void* funcPtr, void* userParam, uint64 tickDelay); + void ProcUIClearCallbacks(); + void ProcUISetSaveCallback(void* funcPtr, void* userParam); + void ProcUISetCallbackStackSize(uint32 newStackSize); + uint32 ProcUICalcMemorySize(uint32 numCallbacks); + sint32 ProcUISetMemoryPool(void* memBase, uint32 size); + void ProcUISetBucketStorage(void* memBase, uint32 size); + void ProcUISetMEM1Storage(void* memBase, uint32 size); + void ProcUIDrawDoneRelease(); + ProcUIStatus ProcUIProcessMessages(bool isBlockingInBackground); + ProcUIStatus ProcUISubProcessMessages(bool isBlockingInBackground); + + void load(); +} \ No newline at end of file diff --git a/src/Cafe/OS/libs/sysapp/sysapp.cpp b/src/Cafe/OS/libs/sysapp/sysapp.cpp index 413d535a..ecaa940a 100644 --- a/src/Cafe/OS/libs/sysapp/sysapp.cpp +++ b/src/Cafe/OS/libs/sysapp/sysapp.cpp @@ -639,11 +639,34 @@ namespace sysapp return coreinit::OSRestartGame(argc, argv); } + struct EManualArgs + { + sysStandardArguments_t stdArgs; + uint64be titleId; + }; + static_assert(sizeof(EManualArgs) == 0x10); + + void _SYSSwitchToEManual(EManualArgs* args) + { + // the struct has the titleId at offset 8 and standard args at 0 (total size is most likely 0x10) + cemuLog_log(LogType::Force, "SYSSwitchToEManual called. Opening the manual is not supported"); + coreinit::StartBackgroundForegroundTransition(); + } + + void SYSSwitchToEManual() + { + EManualArgs args{}; + args.titleId = coreinit::OSGetTitleID(); + _SYSSwitchToEManual(&args); + } + void load() { cafeExportRegisterFunc(SYSClearSysArgs, "sysapp", "SYSClearSysArgs", LogType::Placeholder); cafeExportRegisterFunc(_SYSLaunchTitleByPathFromLauncher, "sysapp", "_SYSLaunchTitleByPathFromLauncher", LogType::Placeholder); cafeExportRegisterFunc(SYSRelaunchTitle, "sysapp", "SYSRelaunchTitle", LogType::Placeholder); + cafeExportRegister("sysapp", _SYSSwitchToEManual, LogType::Placeholder); + cafeExportRegister("sysapp", SYSSwitchToEManual, LogType::Placeholder); } } diff --git a/src/Common/CafeString.h b/src/Common/CafeString.h index 45a515b1..d902d721 100644 --- a/src/Common/CafeString.h +++ b/src/Common/CafeString.h @@ -20,6 +20,11 @@ class CafeString // fixed buffer size, null-terminated, PPC char return true; } + const char* c_str() + { + return (const char*)data; + } + uint8be data[N]; }; From e7c6862e19a277d0d8828c99a6874e69eedbd802 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 1 May 2024 01:55:55 +0200 Subject: [PATCH 159/314] DownloadManager: Fix missing updates --- src/Cemu/napi/napi_version.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cemu/napi/napi_version.cpp b/src/Cemu/napi/napi_version.cpp index a1f5879c..5a85dde3 100644 --- a/src/Cemu/napi/napi_version.cpp +++ b/src/Cemu/napi/napi_version.cpp @@ -31,7 +31,7 @@ namespace NAPI requestUrl = NintendoURLs::TAGAYAURL; break; } - requestUrl.append(fmt::format(fmt::runtime("/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country)); + requestUrl.append(fmt::format(fmt::runtime("/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country.empty() ? "NN" : authInfo.country)); req.initate(authInfo.GetService(), requestUrl, CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); if (!req.submitRequest(false)) @@ -63,7 +63,7 @@ namespace NAPI { NAPI_VersionList_Result result; CurlRequestHelper req; - req.initate(authInfo.GetService(), fmt::format("https://{}/tagaya/versionlist/{}/{}/list/{}.versionlist", fqdnURL, NCrypto::GetRegionAsString(authInfo.region), authInfo.country, versionListVersion), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + req.initate(authInfo.GetService(), fmt::format("https://{}/tagaya/versionlist/{}/{}/list/{}.versionlist", fqdnURL, NCrypto::GetRegionAsString(authInfo.region), authInfo.country.empty() ? "NN" : authInfo.country, versionListVersion), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request update list")); From 379950d185852b3c2da14b40e30a872809ad0ac2 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 1 May 2024 05:06:50 +0200 Subject: [PATCH 160/314] coreinit+nn_save: Cleanup some legacy code --- src/Cafe/OS/libs/coreinit/coreinit_FG.cpp | 20 +- src/Cafe/OS/libs/coreinit/coreinit_FG.h | 2 +- src/Cafe/OS/libs/coreinit/coreinit_FS.cpp | 243 +++++++------ src/Cafe/OS/libs/coreinit/coreinit_FS.h | 84 ++--- src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp | 10 +- src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp | 6 +- src/Cafe/OS/libs/coreinit/coreinit_Memory.h | 2 +- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 6 +- src/Cafe/OS/libs/nn_save/nn_save.cpp | 339 ++++++------------ src/Cafe/OS/libs/proc_ui/proc_ui.cpp | 12 +- src/Common/MemPtr.h | 6 - src/Common/StackAllocator.h | 1 - 12 files changed, 282 insertions(+), 449 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp index 15dcd6da..b751a8fd 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp @@ -55,19 +55,18 @@ namespace coreinit { // return full size of foreground bucket area if (offset) - *offset = MEMPTR<void>{ (uint32)MEMORY_FGBUCKET_AREA_ADDR }; + *offset = { (MPTR)MEMORY_FGBUCKET_AREA_ADDR }; if (size) *size = MEMORY_FGBUCKET_AREA_SIZE; // return true if in foreground return true; } - bool OSGetForegroundBucketFreeArea(MPTR* offset, MPTR* size) + bool OSGetForegroundBucketFreeArea(MEMPTR<void>* offset, uint32be* size) { uint8* freeAreaAddr = GetFGMemByArea(FG_BUCKET_AREA_FREE).GetPtr(); - - *offset = _swapEndianU32(memory_getVirtualOffsetFromPointer(freeAreaAddr)); - *size = _swapEndianU32(FG_BUCKET_AREA_FREE_SIZE); + *offset = freeAreaAddr; + *size = FG_BUCKET_AREA_FREE_SIZE; // return true if in foreground return (fgAddr != nullptr); } @@ -82,15 +81,6 @@ namespace coreinit osLib_returnFromFunction(hCPU, r ? 1 : 0); } - void coreinitExport_OSGetForegroundBucketFreeArea(PPCInterpreter_t* hCPU) - { - debug_printf("OSGetForegroundBucketFreeArea(0x%x,0x%x)\n", hCPU->gpr[3], hCPU->gpr[4]); - ppcDefineParamMPTR(areaOutput, 0); - ppcDefineParamMPTR(areaSize, 1); - bool r = OSGetForegroundBucketFreeArea((MPTR*)memory_getPointerFromVirtualOffsetAllowNull(areaOutput), (MPTR*)memory_getPointerFromVirtualOffsetAllowNull(areaSize)); - osLib_returnFromFunction(hCPU, r ? 1 : 0); - } - void InitForegroundBucket() { uint32be fgSize; @@ -194,7 +184,7 @@ namespace coreinit void InitializeFG() { osLib_addFunction("coreinit", "OSGetForegroundBucket", coreinitExport_OSGetForegroundBucket); - osLib_addFunction("coreinit", "OSGetForegroundBucketFreeArea", coreinitExport_OSGetForegroundBucketFreeArea); + cafeExportRegister("coreinit", OSGetForegroundBucket, LogType::CoreinitMem); osLib_addFunction("coreinit", "OSCopyFromClipboard", coreinitExport_OSCopyFromClipboard); } } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FG.h b/src/Cafe/OS/libs/coreinit/coreinit_FG.h index 846001b9..0c2a3ee3 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FG.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_FG.h @@ -9,7 +9,7 @@ namespace coreinit bool __OSResizeCopyData(sint32 length); bool OSGetForegroundBucket(MEMPTR<void>* offset, uint32be* size); - bool OSGetForegroundBucketFreeArea(MPTR* offset, MPTR* size); + bool OSGetForegroundBucketFreeArea(MEMPTR<void>* offset, uint32be* size); void InitForegroundBucket(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp index 0ca8fb8e..0fc8912f 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.cpp @@ -56,7 +56,7 @@ namespace coreinit OSUnlockMutex(&s_fsGlobalMutex); } - void _debugVerifyCommand(const char* stage, FSCmdBlockBody_t* fsCmdBlockBody); + void _debugVerifyCommand(const char* stage, FSCmdBlockBody* fsCmdBlockBody); bool sFSInitialized = true; // this should be false but it seems like some games rely on FSInit being called before main()? Twilight Princess for example reads files before it calls FSInit bool sFSShutdown = false; @@ -194,12 +194,12 @@ namespace coreinit } // return the aligned FSClientBody struct inside a FSClient struct - FSCmdBlockBody_t* __FSGetCmdBlockBody(FSCmdBlock_t* fsCmdBlock) + FSCmdBlockBody* __FSGetCmdBlockBody(FSCmdBlock_t* fsCmdBlock) { // align pointer to 64 bytes if (fsCmdBlock == nullptr) return nullptr; - FSCmdBlockBody_t* fsCmdBlockBody = (FSCmdBlockBody_t*)(((uintptr_t)fsCmdBlock + 0x3F) & ~0x3F); + FSCmdBlockBody* fsCmdBlockBody = (FSCmdBlockBody*)(((uintptr_t)fsCmdBlock + 0x3F) & ~0x3F); fsCmdBlockBody->selfCmdBlock = fsCmdBlock; return fsCmdBlockBody; } @@ -261,8 +261,8 @@ namespace coreinit fsCmdQueueBE->numCommandsInFlight = 0; fsCmdQueueBE->numMaxCommandsInFlight = numMaxCommandsInFlight; coreinit::OSFastMutex_Init(&fsCmdQueueBE->fastMutex, nullptr); - fsCmdQueueBE->firstMPTR = _swapEndianU32(0); - fsCmdQueueBE->lastMPTR = _swapEndianU32(0); + fsCmdQueueBE->first = nullptr; + fsCmdQueueBE->last = nullptr; } void FSInit() @@ -382,74 +382,71 @@ namespace coreinit Semaphore g_semaphoreQueuedCmds; - void __FSQueueCmdByPriority(FSCmdQueue* fsCmdQueueBE, FSCmdBlockBody_t* fsCmdBlockBody, bool stopAtEqualPriority) + void __FSQueueCmdByPriority(FSCmdQueue* fsCmdQueueBE, FSCmdBlockBody* fsCmdBlockBody, bool stopAtEqualPriority) { - MPTR fsCmdBlockBodyMPTR = memory_getVirtualOffsetFromPointer(fsCmdBlockBody); - if (_swapEndianU32(fsCmdQueueBE->firstMPTR) == MPTR_NULL) + if (!fsCmdQueueBE->first) { // queue is currently empty - cemu_assert(fsCmdQueueBE->lastMPTR == MPTR_NULL); - fsCmdQueueBE->firstMPTR = _swapEndianU32(fsCmdBlockBodyMPTR); - fsCmdQueueBE->lastMPTR = _swapEndianU32(fsCmdBlockBodyMPTR); - fsCmdBlockBody->nextMPTR = _swapEndianU32(MPTR_NULL); - fsCmdBlockBody->previousMPTR = _swapEndianU32(MPTR_NULL); + cemu_assert(!fsCmdQueueBE->last); + fsCmdQueueBE->first = fsCmdBlockBody; + fsCmdQueueBE->last = fsCmdBlockBody; + fsCmdBlockBody->next = nullptr; + fsCmdBlockBody->previous = nullptr; return; } // iterate from last to first element as long as iterated priority is lower - FSCmdBlockBody_t* fsCmdBlockBodyItrPrev = NULL; - FSCmdBlockBody_t* fsCmdBlockBodyItr = (FSCmdBlockBody_t*)memory_getPointerFromVirtualOffsetAllowNull(_swapEndianU32(fsCmdQueueBE->lastMPTR)); + FSCmdBlockBody* fsCmdBlockBodyItrPrev = nullptr; + FSCmdBlockBody* fsCmdBlockBodyItr = fsCmdQueueBE->last; while (true) { - if (fsCmdBlockBodyItr == NULL) + if (!fsCmdBlockBodyItr) { // insert at the head of the list - fsCmdQueueBE->firstMPTR = _swapEndianU32(fsCmdBlockBodyMPTR); - fsCmdBlockBody->nextMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBodyItrPrev)); - fsCmdBlockBody->previousMPTR = _swapEndianU32(MPTR_NULL); - fsCmdBlockBodyItrPrev->previousMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBody)); + fsCmdQueueBE->first = fsCmdBlockBody; + fsCmdBlockBody->next = fsCmdBlockBodyItrPrev; + fsCmdBlockBody->previous = nullptr; + fsCmdBlockBodyItrPrev->previous = fsCmdBlockBody; return; } // compare priority if ((stopAtEqualPriority && fsCmdBlockBodyItr->priority >= fsCmdBlockBody->priority) || (stopAtEqualPriority == false && fsCmdBlockBodyItr->priority > fsCmdBlockBody->priority)) { // insert cmd here - if (fsCmdBlockBodyItrPrev != NULL) + if (fsCmdBlockBodyItrPrev) { - fsCmdBlockBody->nextMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBodyItrPrev)); + fsCmdBlockBody->next = fsCmdBlockBodyItrPrev; } else { - fsCmdBlockBody->nextMPTR = _swapEndianU32(MPTR_NULL); - fsCmdQueueBE->lastMPTR = _swapEndianU32(fsCmdBlockBodyMPTR); + fsCmdBlockBody->next = nullptr; + fsCmdQueueBE->last = fsCmdBlockBody; } - fsCmdBlockBody->previousMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBodyItr)); + fsCmdBlockBody->previous = fsCmdBlockBodyItr; if (fsCmdBlockBodyItrPrev) - fsCmdBlockBodyItrPrev->previousMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBody)); - fsCmdBlockBodyItr->nextMPTR = _swapEndianU32(memory_getVirtualOffsetFromPointer(fsCmdBlockBody)); + fsCmdBlockBodyItrPrev->previous = fsCmdBlockBody; + fsCmdBlockBodyItr->next = fsCmdBlockBody; return; } // next fsCmdBlockBodyItrPrev = fsCmdBlockBodyItr; - fsCmdBlockBodyItr = (FSCmdBlockBody_t*)memory_getPointerFromVirtualOffsetAllowNull(_swapEndianU32(fsCmdBlockBodyItr->previousMPTR)); + fsCmdBlockBodyItr = fsCmdBlockBodyItr->previous; } } - FSCmdBlockBody_t* __FSTakeCommandFromQueue(FSCmdQueue* cmdQueue) + FSCmdBlockBody* __FSTakeCommandFromQueue(FSCmdQueue* cmdQueue) { - FSCmdBlockBody_t* dequeuedCmd = nullptr; - if (_swapEndianU32(cmdQueue->firstMPTR) != MPTR_NULL) + if (!cmdQueue->first) + return nullptr; + // dequeue cmd + FSCmdBlockBody* dequeuedCmd = cmdQueue->first; + if (cmdQueue->first == cmdQueue->last) + cmdQueue->last = nullptr; + cmdQueue->first = dequeuedCmd->next; + dequeuedCmd->next = nullptr; + if (dequeuedCmd->next) { - dequeuedCmd = (FSCmdBlockBody_t*)memory_getPointerFromVirtualOffset(_swapEndianU32(cmdQueue->firstMPTR)); - // dequeue cmd - if (cmdQueue->firstMPTR == cmdQueue->lastMPTR) - cmdQueue->lastMPTR = _swapEndianU32(MPTR_NULL); - cmdQueue->firstMPTR = dequeuedCmd->nextMPTR; - dequeuedCmd->nextMPTR = _swapEndianU32(MPTR_NULL); - if (_swapEndianU32(dequeuedCmd->nextMPTR) != MPTR_NULL) - { - FSCmdBlockBody_t* fsCmdBodyNext = (FSCmdBlockBody_t*)memory_getPointerFromVirtualOffset(_swapEndianU32(dequeuedCmd->nextMPTR)); - fsCmdBodyNext->previousMPTR = _swapEndianU32(MPTR_NULL); - } + FSCmdBlockBody* fsCmdBodyNext = dequeuedCmd->next; + fsCmdBodyNext->previous = nullptr; } return dequeuedCmd; } @@ -499,7 +496,7 @@ namespace coreinit FSLockMutex(); if (cmdQueue->numCommandsInFlight < cmdQueue->numMaxCommandsInFlight) { - FSCmdBlockBody_t* dequeuedCommand = __FSTakeCommandFromQueue(cmdQueue); + FSCmdBlockBody* dequeuedCommand = __FSTakeCommandFromQueue(cmdQueue); if (dequeuedCommand) { cmdQueue->numCommandsInFlight += 1; @@ -512,7 +509,7 @@ namespace coreinit FSUnlockMutex(); } - void __FSQueueDefaultFinishFunc(FSCmdBlockBody_t* fsCmdBlockBody, FS_RESULT result) + void __FSQueueDefaultFinishFunc(FSCmdBlockBody* fsCmdBlockBody, FS_RESULT result) { switch ((FSA_CMD_OPERATION_TYPE)fsCmdBlockBody->fsaShimBuffer.operationType.value()) { @@ -594,13 +591,13 @@ namespace coreinit void export___FSQueueDefaultFinishFunc(PPCInterpreter_t* hCPU) { - ppcDefineParamPtr(cmd, FSCmdBlockBody_t, 0); + ppcDefineParamPtr(cmd, FSCmdBlockBody, 0); FS_RESULT result = (FS_RESULT)PPCInterpreter_getCallParamU32(hCPU, 1); __FSQueueDefaultFinishFunc(cmd, static_cast<FS_RESULT>(result)); osLib_returnFromFunction(hCPU, 0); } - void __FSQueueCmd(FSCmdQueue* cmdQueue, FSCmdBlockBody_t* fsCmdBlockBody, MPTR finishCmdFunc) + void __FSQueueCmd(FSCmdQueue* cmdQueue, FSCmdBlockBody* fsCmdBlockBody, MPTR finishCmdFunc) { fsCmdBlockBody->cmdFinishFuncMPTR = finishCmdFunc; FSLockMutex(); @@ -676,7 +673,7 @@ namespace coreinit return FS_RESULT::FATAL_ERROR; } - void __FSCmdSubmitResult(FSCmdBlockBody_t* fsCmdBlockBody, FS_RESULT result) + void __FSCmdSubmitResult(FSCmdBlockBody* fsCmdBlockBody, FS_RESULT result) { _debugVerifyCommand("FSCmdSubmitResult", fsCmdBlockBody); @@ -720,7 +717,7 @@ namespace coreinit void __FSAIoctlResponseCallback(PPCInterpreter_t* hCPU) { ppcDefineParamU32(iosResult, 0); - ppcDefineParamPtr(cmd, FSCmdBlockBody_t, 1); + ppcDefineParamPtr(cmd, FSCmdBlockBody, 1); FSA_RESULT fsaStatus = _FSIosErrorToFSAStatus((IOS_ERROR)iosResult); @@ -754,25 +751,25 @@ namespace coreinit void FSInitCmdBlock(FSCmdBlock_t* fsCmdBlock) { memset(fsCmdBlock, 0x00, sizeof(FSCmdBlock_t)); - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); fsCmdBlockBody->statusCode = _swapEndianU32(FSA_CMD_STATUS_CODE_D900A21); fsCmdBlockBody->priority = 0x10; } - void __FSAsyncToSyncInit(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSAsyncParamsNew_t* asyncParams) + void __FSAsyncToSyncInit(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSAsyncParams* asyncParams) { if (fsClient == nullptr || fsCmdBlock == nullptr || asyncParams == nullptr) assert_dbg(); - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); coreinit::OSInitMessageQueue(&fsCmdBlockBody->syncTaskMsgQueue, fsCmdBlockBody->_syncTaskMsg, 1); asyncParams->userCallback = nullptr; asyncParams->userContext = nullptr; asyncParams->ioMsgQueue = &fsCmdBlockBody->syncTaskMsgQueue; } - void __FSPrepareCmdAsyncResult(FSClientBody_t* fsClientBody, FSCmdBlockBody_t* fsCmdBlockBody, FSAsyncResult* fsCmdBlockAsyncResult, FSAsyncParamsNew_t* fsAsyncParams) + void __FSPrepareCmdAsyncResult(FSClientBody_t* fsClientBody, FSCmdBlockBody* fsCmdBlockBody, FSAsyncResult* fsCmdBlockAsyncResult, FSAsyncParams* fsAsyncParams) { - memcpy(&fsCmdBlockAsyncResult->fsAsyncParamsNew, fsAsyncParams, sizeof(FSAsyncParamsNew_t)); + memcpy(&fsCmdBlockAsyncResult->fsAsyncParamsNew, fsAsyncParams, sizeof(FSAsyncParams)); fsCmdBlockAsyncResult->fsClient = fsClientBody->selfClient; fsCmdBlockAsyncResult->fsCmdBlock = fsCmdBlockBody->selfCmdBlock; @@ -781,7 +778,7 @@ namespace coreinit fsCmdBlockAsyncResult->msgUnion.fsMsg.commandType = _swapEndianU32(8); } - sint32 __FSPrepareCmd(FSClientBody_t* fsClientBody, FSCmdBlockBody_t* fsCmdBlockBody, uint32 errHandling, FSAsyncParamsNew_t* fsAsyncParams) + sint32 __FSPrepareCmd(FSClientBody_t* fsClientBody, FSCmdBlockBody* fsCmdBlockBody, uint32 errHandling, FSAsyncParams* fsAsyncParams) { if (sFSInitialized == false || sFSShutdown == true) return -0x400; @@ -813,18 +810,18 @@ namespace coreinit #define _FSCmdIntro() \ FSClientBody_t* fsClientBody = __FSGetClientBody(fsClient); \ - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); \ + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); \ sint32 fsError = __FSPrepareCmd(fsClientBody, fsCmdBlockBody, errorMask, fsAsyncParams); \ if (fsError != 0) \ return fsError; - void _debugVerifyCommand(const char* stage, FSCmdBlockBody_t* fsCmdBlockBody) + void _debugVerifyCommand(const char* stage, FSCmdBlockBody* fsCmdBlockBody) { if (fsCmdBlockBody->asyncResult.msgUnion.fsMsg.commandType != _swapEndianU32(8)) { cemuLog_log(LogType::Force, "Corrupted FS command detected in stage {}", stage); cemuLog_log(LogType::Force, "Printing CMD block: "); - for (uint32 i = 0; i < (sizeof(FSCmdBlockBody_t) + 31) / 32; i++) + for (uint32 i = 0; i < (sizeof(FSCmdBlockBody) + 31) / 32; i++) { uint8* p = ((uint8*)fsCmdBlockBody) + i * 32; cemuLog_log(LogType::Force, "{:04x}: {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x} | {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x} - {:02x} {:02x} {:02x} {:02x}", @@ -845,7 +842,7 @@ namespace coreinit // a positive result (or zero) means success. Most operations return zero in case of success. Read and write operations return the number of transferred units if (fsStatus >= 0) { - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); OSMessage msg; OSReceiveMessage(&fsCmdBlockBody->syncTaskMsgQueue, &msg, OS_MESSAGE_BLOCK); _debugVerifyCommand("handleAsyncResult", fsCmdBlockBody); @@ -906,12 +903,12 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSOpenFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandleDepr_t* outFileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSOpenFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandlePtr outFileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); if (outFileHandle == nullptr || path == nullptr || mode == nullptr) return -0x400; - fsCmdBlockBody->returnValues.cmdOpenFile.handlePtr = &outFileHandle->fileHandle; + fsCmdBlockBody->returnValues.cmdOpenFile.handlePtr = outFileHandle; fsError = (FSStatus)__FSPrepareCmd_OpenFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, path, mode, 0x660, 0, 0); if (fsError != (FSStatus)FS_RESULT::SUCCESS) return fsError; @@ -919,15 +916,15 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSOpenFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandleDepr_t* fileHandle, uint32 errHandling) + sint32 FSOpenFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandlePtr outFileHandle, uint32 errHandling) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); - sint32 fsAsyncRet = FSOpenFileAsync(fsClient, fsCmdBlock, path, mode, fileHandle, errHandling, &asyncParams); + sint32 fsAsyncRet = FSOpenFileAsync(fsClient, fsCmdBlock, path, mode, outFileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } - sint32 FSOpenFileExAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, uint32 createMode, uint32 openFlag, uint32 preallocSize, FSFileHandleDepr_t* outFileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSOpenFileExAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, uint32 createMode, uint32 openFlag, uint32 preallocSize, FSFileHandlePtr outFileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { if (openFlag != 0) { @@ -938,7 +935,7 @@ namespace coreinit _FSCmdIntro(); if (outFileHandle == nullptr || path == nullptr || mode == nullptr) return -0x400; - fsCmdBlockBody->returnValues.cmdOpenFile.handlePtr = &outFileHandle->fileHandle; + fsCmdBlockBody->returnValues.cmdOpenFile.handlePtr = outFileHandle; FSA_RESULT prepareResult = __FSPrepareCmd_OpenFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, path, mode, createMode, openFlag, preallocSize); if (prepareResult != FSA_RESULT::OK) @@ -948,11 +945,11 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSOpenFileEx(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, uint32 createMode, uint32 openFlag, uint32 preallocSize, FSFileHandleDepr_t* fileHandle, uint32 errHandling) + sint32 FSOpenFileEx(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, uint32 createMode, uint32 openFlag, uint32 preallocSize, FSFileHandlePtr outFileHandle, uint32 errHandling) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); - sint32 fsAsyncRet = FSOpenFileExAsync(fsClient, fsCmdBlock, path, mode, createMode, openFlag, preallocSize, fileHandle, errHandling, &asyncParams); + sint32 fsAsyncRet = FSOpenFileExAsync(fsClient, fsCmdBlock, path, mode, createMode, openFlag, preallocSize, outFileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); } @@ -970,7 +967,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSCloseFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSCloseFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); @@ -984,7 +981,7 @@ namespace coreinit sint32 FSCloseFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errHandling) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSCloseFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); @@ -1004,7 +1001,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSFlushFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSFlushFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); @@ -1018,7 +1015,7 @@ namespace coreinit sint32 FSFlushFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errHandling) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSFlushFileAsync(fsClient, fsCmdBlock, fileHandle, errHandling, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errHandling); @@ -1060,7 +1057,7 @@ namespace coreinit SysAllocator<uint8, 128, 64> _tempFSSpace; - sint32 __FSReadFileAsyncEx(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dest, uint32 size, uint32 count, bool usePos, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 __FSReadFileAsyncEx(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dest, uint32 size, uint32 count, bool usePos, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); if (size == 0 || count == 0 || dest == NULL) @@ -1091,7 +1088,7 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSReadFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSReadFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { cemu_assert_debug(flag == 0); // todo return __FSReadFileAsyncEx(fsClient, fsCmdBlock, dst, size, count, false, 0, fileHandle, flag, errorMask, fsAsyncParams); @@ -1099,13 +1096,13 @@ namespace coreinit sint32 FSReadFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSReadFileAsync(fsClient, fsCmdBlock, dst, size, count, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } - sint32 FSReadFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSReadFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { cemu_assert_debug(flag == 0); // todo sint32 fsStatus = __FSReadFileAsyncEx(fsClient, fsCmdBlock, dst, size, count, true, filePos, fileHandle, flag, errorMask, fsAsyncParams); @@ -1114,7 +1111,7 @@ namespace coreinit sint32 FSReadFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSReadFileWithPosAsync(fsClient, fsCmdBlock, dst, size, count, filePos, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1154,7 +1151,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 __FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dest, uint32 size, uint32 count, bool useFilePos, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 __FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dest, uint32 size, uint32 count, bool useFilePos, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); if (size == 0 || count == 0 || dest == nullptr) @@ -1185,27 +1182,27 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSWriteFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSWriteFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { return __FSWriteFileWithPosAsync(fsClient, fsCmdBlock, src, size, count, false, 0, fileHandle, flag, errorMask, fsAsyncParams); } sint32 FSWriteFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSWriteFileAsync(fsClient, fsCmdBlock, src, size, count, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } - sint32 FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams) { return __FSWriteFileWithPosAsync(fsClient, fsCmdBlock, src, size, count, true, filePos, fileHandle, flag, errorMask, fsAsyncParams); } sint32 FSWriteFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSWriteFileWithPosAsync(fsClient, fsCmdBlock, src, size, count, filePos, fileHandle, flag, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1224,7 +1221,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSSetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSSetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_SetPosFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, fileHandle, filePos); @@ -1237,7 +1234,7 @@ namespace coreinit sint32 FSSetPosFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask) { // used by games: Mario Kart 8 - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSSetPosFileAsync(fsClient, fsCmdBlock, fileHandle, filePos, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1254,7 +1251,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSGetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSGetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // games using this: Darksiders Warmastered Edition _FSCmdIntro(); @@ -1268,7 +1265,7 @@ namespace coreinit sint32 FSGetPosFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetPosFileAsync(fsClient, fsCmdBlock, fileHandle, returnedFilePos, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1302,7 +1299,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSOpenDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSOpenDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); cemu_assert(dirHandleOut && path); @@ -1316,7 +1313,7 @@ namespace coreinit sint32 FSOpenDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSOpenDirAsync(fsClient, fsCmdBlock, path, dirHandleOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1333,7 +1330,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSReadDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSReadDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_ReadDir(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, dirHandle); @@ -1344,9 +1341,9 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParams* fsAsyncParams) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSReadDirAsync(fsClient, fsCmdBlock, dirHandle, dirEntryOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1363,7 +1360,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSCloseDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSCloseDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_CloseDir(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, dirHandle); @@ -1376,7 +1373,7 @@ namespace coreinit sint32 FSCloseDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSCloseDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1396,7 +1393,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSRewindDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSRewindDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_RewindDir(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, dirHandle); @@ -1409,7 +1406,7 @@ namespace coreinit sint32 FSRewindDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSRewindDirAsync(fsClient, fsCmdBlock, dirHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1431,7 +1428,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSAppendFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSAppendFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_AppendFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, size, count, fileHandle, 0); @@ -1444,7 +1441,7 @@ namespace coreinit sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSAppendFileAsync(fsClient, fsCmdBlock, size, count, fileHandle, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1463,7 +1460,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSTruncateFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSTruncateFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); FSA_RESULT prepareResult = __FSPrepareCmd_TruncateFile(&fsCmdBlockBody->fsaShimBuffer, fsClientBody->iosuFSAHandle, fileHandle); @@ -1476,7 +1473,7 @@ namespace coreinit sint32 FSTruncateFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSTruncateFileAsync(fsClient, fsCmdBlock, fileHandle, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1521,7 +1518,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSRenameAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSRenameAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by titles: XCX (via SAVERenameAsync) _FSCmdIntro(); @@ -1540,7 +1537,7 @@ namespace coreinit sint32 FSRename(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSRenameAsync(fsClient, fsCmdBlock, srcPath, dstPath, errorMask, asyncParams.GetPointer()); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1572,7 +1569,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSRemoveAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSRemoveAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by titles: XCX (via SAVERemoveAsync) _FSCmdIntro(); @@ -1591,7 +1588,7 @@ namespace coreinit sint32 FSRemove(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSRemoveAsync(fsClient, fsCmdBlock, filePath, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1624,7 +1621,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by titles: XCX (via SAVEMakeDirAsync) _FSCmdIntro(); @@ -1643,7 +1640,7 @@ namespace coreinit sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSMakeDirAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1674,7 +1671,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSChangeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSChangeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); if (path == NULL) @@ -1692,7 +1689,7 @@ namespace coreinit sint32 FSChangeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSChangeDirAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1710,7 +1707,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSGetCwdAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSGetCwdAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by titles: Super Mario Maker _FSCmdIntro(); @@ -1727,7 +1724,7 @@ namespace coreinit sint32 FSGetCwd(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetCwdAsync(fsClient, fsCmdBlock, dirPathOut, dirPathMaxLen, errorMask, &asyncParams); auto r = __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1758,7 +1755,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSFlushQuotaAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSFlushQuotaAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); @@ -1772,7 +1769,7 @@ namespace coreinit sint32 FSFlushQuota(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t> asyncParams; + StackAllocator<FSAsyncParams> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSFlushQuotaAsync(fsClient, fsCmdBlock, path, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1808,7 +1805,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); cemu_assert(queryString && queryResult); // query string and result must not be null @@ -1822,7 +1819,7 @@ namespace coreinit return (FSStatus)FS_RESULT::SUCCESS; } - sint32 FSGetStatAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSStat_t* statOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSGetStatAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSStat_t* statOut, uint32 errorMask, FSAsyncParams* fsAsyncParams) { sint32 fsStatus = __FSQueryInfoAsync(fsClient, fsCmdBlock, (uint8*)path, FSA_QUERY_TYPE_STAT, statOut, errorMask, fsAsyncParams); return fsStatus; @@ -1830,7 +1827,7 @@ namespace coreinit sint32 FSGetStat(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSStat_t* statOut, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetStatAsync(fsClient, fsCmdBlock, path, statOut, errorMask, &asyncParams); sint32 ret = __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1851,7 +1848,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSGetStatFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, FSStat_t* statOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSGetStatFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, FSStat_t* statOut, uint32 errorMask, FSAsyncParams* fsAsyncParams) { _FSCmdIntro(); cemu_assert(statOut); // statOut must not be null @@ -1867,13 +1864,13 @@ namespace coreinit sint32 FSGetStatFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSFileHandle2 fileHandle, FSStat_t* statOut, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetStatFileAsync(fsClient, fsCmdBlock, fileHandle, statOut, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); } - sint32 FSGetFreeSpaceSizeAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSGetFreeSpaceSizeAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by: Wii U system settings app, Art Academy, Unity (e.g. Snoopy's Grand Adventure), Super Smash Bros sint32 fsStatus = __FSQueryInfoAsync(fsClient, fsCmdBlock, (uint8*)path, FSA_QUERY_TYPE_FREESPACE, returnedFreeSize, errorMask, fsAsyncParams); @@ -1882,7 +1879,7 @@ namespace coreinit sint32 FSGetFreeSpaceSize(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSGetFreeSpaceSizeAsync(fsClient, fsCmdBlock, path, returnedFreeSize, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1902,7 +1899,7 @@ namespace coreinit return FSA_RESULT::OK; } - sint32 FSIsEofAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams) + sint32 FSIsEofAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams) { // used by Paper Monsters Recut _FSCmdIntro(); @@ -1917,7 +1914,7 @@ namespace coreinit sint32 FSIsEof(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask) { - StackAllocator<FSAsyncParamsNew_t, 1> asyncParams; + StackAllocator<FSAsyncParams, 1> asyncParams; __FSAsyncToSyncInit(fsClient, fsCmdBlock, &asyncParams); sint32 fsAsyncRet = FSIsEofAsync(fsClient, fsCmdBlock, fileHandle, errorMask, &asyncParams); return __FSProcessAsyncResult(fsClient, fsCmdBlock, fsAsyncRet, errorMask); @@ -1925,14 +1922,14 @@ namespace coreinit void FSSetUserData(FSCmdBlock_t* fsCmdBlock, void* userData) { - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); if (fsCmdBlockBody) fsCmdBlockBody->userData = userData; } void* FSGetUserData(FSCmdBlock_t* fsCmdBlock) { - FSCmdBlockBody_t* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); + FSCmdBlockBody* fsCmdBlockBody = __FSGetCmdBlockBody(fsCmdBlock); void* userData = nullptr; if (fsCmdBlockBody) userData = fsCmdBlockBody->userData.GetPtr(); @@ -1956,7 +1953,7 @@ namespace coreinit FSClientBody_t* fsClientBody = __FSGetClientBody(fsClient); if (!fsClientBody) return nullptr; - FSCmdBlockBody_t* cmdBlockBody = fsClientBody->currentCmdBlockBody; + FSCmdBlockBody* cmdBlockBody = fsClientBody->currentCmdBlockBody; if (!cmdBlockBody) return nullptr; return cmdBlockBody->selfCmdBlock; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FS.h b/src/Cafe/OS/libs/coreinit/coreinit_FS.h index 2a57f7da..bf12e33c 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FS.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_FS.h @@ -5,33 +5,23 @@ #include "Cafe/IOSU/fsa/iosu_fsa.h" #include "coreinit_MessageQueue.h" -typedef struct -{ - uint32be fileHandle; -} FSFileHandleDepr_t; - +typedef MEMPTR<betype<FSFileHandle2>> FSFileHandlePtr; typedef MEMPTR<betype<FSDirHandle2>> FSDirHandlePtr; typedef uint32 FSAClientHandle; -typedef struct +struct FSAsyncParams { MEMPTR<void> userCallback; MEMPTR<void> userContext; MEMPTR<coreinit::OSMessageQueue> ioMsgQueue; -} FSAsyncParamsNew_t; - -static_assert(sizeof(FSAsyncParamsNew_t) == 0xC); - -typedef struct -{ - MPTR userCallback; // 0x96C - MPTR userContext; - MPTR ioMsgQueue; -} FSAsyncParams_t; // legacy struct. Replace with FSAsyncParamsNew_t +}; +static_assert(sizeof(FSAsyncParams) == 0xC); namespace coreinit { + struct FSCmdBlockBody; + struct FSCmdQueue { enum class QUEUE_FLAG : uint32 @@ -40,8 +30,8 @@ namespace coreinit CANCEL_ALL = (1 << 4), }; - /* +0x00 */ MPTR firstMPTR; - /* +0x04 */ MPTR lastMPTR; + /* +0x00 */ MEMPTR<FSCmdBlockBody> first; + /* +0x04 */ MEMPTR<FSCmdBlockBody> last; /* +0x08 */ OSFastMutex fastMutex; /* +0x34 */ MPTR dequeueHandlerFuncMPTR; /* +0x38 */ uint32be numCommandsInFlight; @@ -108,7 +98,7 @@ namespace coreinit uint8 ukn1460[0x10]; uint8 ukn1470[0x10]; FSCmdQueue fsCmdQueue; - /* +0x14C4 */ MEMPTR<struct FSCmdBlockBody_t> currentCmdBlockBody; // set to currently active cmd + /* +0x14C4 */ MEMPTR<struct FSCmdBlockBody> currentCmdBlockBody; // set to currently active cmd uint32 ukn14C8; uint32 ukn14CC; uint8 ukn14D0[0x10]; @@ -128,7 +118,7 @@ namespace coreinit struct FSAsyncResult { - /* +0x00 */ FSAsyncParamsNew_t fsAsyncParamsNew; + /* +0x00 */ FSAsyncParams fsAsyncParamsNew; // fs message storage struct FSMessage @@ -159,7 +149,7 @@ namespace coreinit uint8 ukn0[0x14]; struct { - MEMPTR<uint32be> handlePtr; + MEMPTR<betype<FSResHandle>> handlePtr; } cmdOpenFile; struct { @@ -205,7 +195,7 @@ namespace coreinit static_assert(sizeof(FSCmdBlockReturnValues_t) == 0x14); - struct FSCmdBlockBody_t + struct FSCmdBlockBody { iosu::fsa::FSAShimBuffer fsaShimBuffer; /* +0x0938 */ MEMPTR<FSClientBody_t> fsClientBody; @@ -213,9 +203,8 @@ namespace coreinit /* +0x0940 */ uint32be cancelState; // bitmask. Bit 0 -> If set command has been canceled FSCmdBlockReturnValues_t returnValues; // link for cmd queue - MPTR nextMPTR; // points towards FSCmdQueue->first - MPTR previousMPTR; // points towards FSCmdQueue->last - + MEMPTR<FSCmdBlockBody> next; + MEMPTR<FSCmdBlockBody> previous; /* +0x960 */ betype<FSA_RESULT> lastFSAStatus; uint32 ukn0964; /* +0x0968 */ uint8 errHandling; // return error flag mask @@ -235,7 +224,6 @@ namespace coreinit uint32 ukn9FC; }; - static_assert(sizeof(FSAsyncParams_t) == 0xC); static_assert(sizeof(FSCmdBlock_t) == 0xA80); #define FSA_CMD_FLAG_SET_POS (1 << 0) @@ -251,7 +239,7 @@ namespace coreinit }; // internal interface - sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errHandling, FSAsyncParamsNew_t* fsAsyncParams); + sint32 __FSQueryInfoAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* queryString, uint32 queryType, void* queryResult, uint32 errHandling, FSAsyncParams* fsAsyncParams); // coreinit exports FS_RESULT FSAddClientEx(FSClient_t* fsClient, uint32 uknR4, uint32 errHandling); @@ -260,52 +248,52 @@ namespace coreinit void FSInitCmdBlock(FSCmdBlock_t* fsCmdBlock); - sint32 FSOpenFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandleDepr_t* fileHandle, uint32 errHandling, FSAsyncParamsNew_t* asyncParams); - sint32 FSOpenFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandleDepr_t* fileHandle, uint32 errHandling); + sint32 FSOpenFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandlePtr outFileHandle, uint32 errHandling, FSAsyncParams* asyncParams); + sint32 FSOpenFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, char* mode, FSFileHandlePtr outFileHandle, uint32 errHandling); - sint32 FSReadFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSReadFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSReadFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask); - sint32 FSReadFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSReadFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSReadFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* dst, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask); - sint32 FSWriteFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSWriteFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSWriteFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 fileHandle, uint32 flag, uint32 errorMask); - sint32 FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSWriteFileWithPosAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSWriteFileWithPos(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, void* src, uint32 size, uint32 count, uint32 filePos, uint32 fileHandle, uint32 flag, uint32 errorMask); - sint32 FSSetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSSetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSSetPosFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 filePos, uint32 errorMask); - sint32 FSGetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSGetPosFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSGetPosFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32be* returnedFilePos, uint32 errorMask); - sint32 FSAppendFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 size, uint32 count, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSAppendFileAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 size, uint32 count, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 size, uint32 count, uint32 errorMask); - sint32 FSIsEofAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSIsEofAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSIsEof(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 fileHandle, uint32 errorMask); - sint32 FSRenameAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSRenameAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSRename(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* srcPath, char* dstPath, uint32 errorMask); - sint32 FSRemoveAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSRemoveAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSRemove(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint8* filePath, uint32 errorMask); - sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSMakeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* dirPath, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSMakeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, uint32 errorMask); - sint32 FSChangeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSChangeDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSChangeDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask); - sint32 FSGetCwdAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSGetCwdAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSGetCwd(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* dirPathOut, sint32 dirPathMaxLen, uint32 errorMask); - sint32 FSGetFreeSpaceSizeAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSGetFreeSpaceSizeAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSGetFreeSpaceSize(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, const char* path, FSLargeSize* returnedFreeSize, uint32 errorMask); - sint32 FSOpenDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSOpenDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSOpenDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, FSDirHandlePtr dirHandleOut, uint32 errorMask); - sint32 FSReadDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); - sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); - sint32 FSCloseDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSReadDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParams* fsAsyncParams); + sint32 FSReadDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, FSDirEntry_t* dirEntryOut, uint32 errorMask, FSAsyncParams* fsAsyncParams); + sint32 FSCloseDirAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSCloseDir(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, FSDirHandle2 dirHandle, uint32 errorMask); - sint32 FSFlushQuotaAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParamsNew_t* fsAsyncParams); + sint32 FSFlushQuotaAsync(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask, FSAsyncParams* fsAsyncParams); sint32 FSFlushQuota(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, char* path, uint32 errorMask); FS_VOLSTATE FSGetVolumeState(FSClient_t* fsClient); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp index dc82f772..83658f3c 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM.cpp @@ -128,7 +128,7 @@ namespace coreinit { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); MEMPTR<void> bucket; uint32be bucketSize; @@ -257,7 +257,7 @@ namespace coreinit { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); MEMPTR<void> bucket; uint32be bucketSize; @@ -593,16 +593,16 @@ namespace coreinit { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); mem1Heap = MEMCreateFrmHeapEx(memBound.GetPtr(), (uint32)memBoundSize, 0); - OSGetForegroundBucketFreeArea((MPTR*)memBound.GetBEPtr(), (MPTR*)&memBoundSize); + OSGetForegroundBucketFreeArea(&memBound, &memBoundSize); memFGHeap = MEMCreateFrmHeapEx(memBound.GetPtr(), (uint32)memBoundSize, 0); } MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(2, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(2, &memBound, &memBoundSize); mem2Heap = MEMDefaultHeap_Init(memBound.GetPtr(), (uint32)memBoundSize); // set DynLoad allocators diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp index cff4ee2b..80ec212d 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Memory.cpp @@ -131,7 +131,7 @@ namespace coreinit // no-op } - void OSGetMemBound(sint32 memType, MPTR* offsetOutput, uint32* sizeOutput) + void OSGetMemBound(sint32 memType, MEMPTR<void>* offsetOutput, uint32be* sizeOutput) { MPTR memAddr = MPTR_NULL; uint32 memSize = 0; @@ -195,9 +195,9 @@ namespace coreinit cemu_assert_debug(false); } if (offsetOutput) - *offsetOutput = _swapEndianU32(memAddr); + *offsetOutput = memAddr; if (sizeOutput) - *sizeOutput = _swapEndianU32(memSize); + *sizeOutput = memSize; } void InitializeMemory() diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Memory.h b/src/Cafe/OS/libs/coreinit/coreinit_Memory.h index 0a212f61..62c9f135 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Memory.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Memory.h @@ -4,7 +4,7 @@ namespace coreinit { void InitializeMemory(); - void OSGetMemBound(sint32 memType, MPTR* offsetOutput, uint32* sizeOutput); + void OSGetMemBound(sint32 memType, MEMPTR<void>* offsetOutput, uint32be* sizeOutput); void* OSBlockMove(MEMPTR<void> dst, MEMPTR<void> src, uint32 size, bool flushDC); void* OSBlockSet(MEMPTR<void> dst, uint32 value, uint32 size); diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 0268c7df..7a8eacb7 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -1401,12 +1401,10 @@ void export_curl_easy_getinfo(PPCInterpreter_t* hCPU) } case CURLINFO_CONTENT_TYPE: { - //cemuLog_logDebug(LogType::Force, "CURLINFO_CONTENT_TYPE not supported"); - //*(uint32*)parameter.GetPtr() = MPTR_NULL; char* contentType = nullptr; result = curl_easy_getinfo(curlObj, CURLINFO_REDIRECT_URL, &contentType); _updateGuestString(curl.GetPtr(), curl->info_contentType, contentType); - *(uint32*)parameter.GetPtr() = curl->info_contentType.GetMPTRBE(); + *(MEMPTR<char>*)parameter.GetPtr() = curl->info_contentType; break; } case CURLINFO_REDIRECT_URL: @@ -1414,7 +1412,7 @@ void export_curl_easy_getinfo(PPCInterpreter_t* hCPU) char* redirectUrl = nullptr; result = curl_easy_getinfo(curlObj, CURLINFO_REDIRECT_URL, &redirectUrl); _updateGuestString(curl.GetPtr(), curl->info_redirectUrl, redirectUrl); - *(uint32*)parameter.GetPtr() = curl->info_redirectUrl.GetMPTRBE(); + *(MEMPTR<char>*)parameter.GetPtr() = curl->info_redirectUrl; break; } default: diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 05e49438..518e4195 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -320,7 +320,7 @@ namespace save return SAVE_STATUS_OK; } - SAVEStatus SAVERemoveAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVERemoveAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -331,7 +331,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSRemoveAsync(client, block, (uint8*)fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSRemoveAsync(client, block, (uint8*)fullPath, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -340,7 +340,7 @@ namespace save return result; } - SAVEStatus SAVEMakeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEMakeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -351,7 +351,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSMakeDirAsync(client, block, fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSMakeDirAsync(client, block, fullPath, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -361,7 +361,7 @@ namespace save return result; } - SAVEStatus SAVEOpenDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEOpenDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -372,7 +372,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams); } else @@ -383,7 +383,7 @@ namespace save return result; } - SAVEStatus SAVEOpenFileAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling, const FSAsyncParamsNew_t* asyncParams) + SAVEStatus SAVEOpenFileAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -394,7 +394,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, hFile, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, outFileHandle, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -404,7 +404,7 @@ namespace save return result; } - SAVEStatus SAVEOpenFileOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling, const FSAsyncParamsNew_t* asyncParams) + SAVEStatus SAVEOpenFileOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { if (strcmp(mode, "r") != 0) return (SAVEStatus)(FS_RESULT::PERMISSION_ERROR); @@ -418,7 +418,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath)) - result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, hFile, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, outFileHandle, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -428,26 +428,10 @@ namespace save return result; } - void export_SAVEOpenFileOtherApplicationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(mode, const char, 6); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 7); - ppcDefineParamU32(errHandling, 8); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParamsNew_t, 9); - - const SAVEStatus result = SAVEOpenFileOtherApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) + SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParamsNew_t asyncParams; + FSAsyncParams asyncParams; asyncParams.ioMsgQueue = nullptr; asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); @@ -456,7 +440,7 @@ namespace save param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); - SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, &asyncParams); + SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { coreinit_suspendThread(currentThread, 1000); @@ -467,113 +451,31 @@ namespace save return status; } - void export_SAVEOpenFileOtherApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(mode, const char, 6); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 7); - ppcDefineParamU32(errHandling, 8); - - const SAVEStatus result = SAVEOpenFileOtherApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFileOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling, const FSAsyncParamsNew_t* asyncParams) + SAVEStatus SAVEOpenFileOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); - return SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, asyncParams); + return SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling, asyncParams); } - void export_SAVEOpenFileOtherNormalApplicationAsync(PPCInterpreter_t* hCPU) + SAVEStatus SAVEOpenFileOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(mode, const char, 5); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 6); - ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParamsNew_t, 8); - - const SAVEStatus result = SAVEOpenFileOtherNormalApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEOpenFileOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) - { - //peterBreak(); - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); - return SAVEOpenFileOtherApplication(client, block, titleId, accountSlot, path, mode, hFile, errHandling); + return SAVEOpenFileOtherApplication(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling); } - void export_SAVEOpenFileOtherNormalApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(mode, const char, 5); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 6); - ppcDefineParamU32(errHandling, 7); - - const SAVEStatus result = SAVEOpenFileOtherNormalApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFileOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling, const FSAsyncParamsNew_t* asyncParams) - { - //peterBreak(); - - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); - return SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, asyncParams); - } - - void export_SAVEOpenFileOtherNormalApplicationVariationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(mode, const char, 6); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 7); - ppcDefineParamU32(errHandling, 8); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParamsNew_t, 9); - - const SAVEStatus result = SAVEOpenFileOtherNormalApplicationVariationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFileOtherNormalApplicationVariation(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) + SAVEStatus SAVEOpenFileOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); - return SAVEOpenFileOtherApplication(client, block, titleId, accountSlot, path, mode, hFile, errHandling); + return SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling, asyncParams); } - void export_SAVEOpenFileOtherNormalApplicationVariation(PPCInterpreter_t* hCPU) + SAVEStatus SAVEOpenFileOtherNormalApplicationVariation(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(mode, const char, 6); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 7); - ppcDefineParamU32(errHandling, 8); - - const SAVEStatus result = SAVEOpenFileOtherNormalApplicationVariation(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); + return SAVEOpenFileOtherApplication(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling); } - SAVEStatus SAVEGetFreeSpaceSizeAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetFreeSpaceSizeAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -583,9 +485,8 @@ namespace save if (GetPersistentIdEx(accountSlot, &persistentId)) { char fullPath[SAVE_MAX_PATH_SIZE]; - // usually a pointer with '\0' instead of nullptr, but it's basically the same if (GetAbsoluteFullPath(persistentId, nullptr, fullPath)) - result = coreinit::FSGetFreeSpaceSizeAsync(client, block, fullPath, freeSize, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSGetFreeSpaceSizeAsync(client, block, fullPath, freeSize, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -595,7 +496,7 @@ namespace save return result; } - SAVEStatus SAVEGetStatAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -606,7 +507,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParamsNew_t*)asyncParams); // FSGetStatAsync(...) + result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParams*)asyncParams); // FSGetStatAsync(...) } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -616,7 +517,7 @@ namespace save return result; } - SAVEStatus SAVEGetStatOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -627,7 +528,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == (FSStatus)FS_RESULT::SUCCESS) - result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParamsNew_t*)asyncParams); // FSGetStatAsync(...) + result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParams*)asyncParams); // FSGetStatAsync(...) } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -637,25 +538,25 @@ namespace save return result; } - SAVEStatus SAVEGetStatOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); } - SAVEStatus SAVEGetStatOtherDemoApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatOtherDemoApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_DEMO_TO_TITLE_ID(uniqueId); return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); } - SAVEStatus SAVEGetStatOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); } - SAVEStatus SAVEGetStatOtherDemoApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEGetStatOtherDemoApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_DEMO_TO_TITLE_ID_VARIATION(uniqueId, variation); return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); @@ -682,14 +583,14 @@ namespace save SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -722,7 +623,7 @@ namespace save ppcDefineParamU8(accountSlot, 2); ppcDefineParamMEMPTR(returnedFreeSize, FSLargeSize, 3); ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 5); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); const SAVEStatus result = SAVEGetFreeSpaceSizeAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, returnedFreeSize.GetPtr(), errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEGetFreeSpaceSizeAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); @@ -743,7 +644,7 @@ namespace save ppcDefineParamU8(accountSlot, 2); ppcDefineParamMEMPTR(path, const char, 3); ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 5); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); const SAVEStatus result = SAVERemoveAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -752,14 +653,14 @@ namespace save SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -784,7 +685,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVERenameAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVERenameAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -798,7 +699,7 @@ namespace save { char fullNewPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, newPath, fullNewPath)) - result = coreinit::FSRenameAsync(client, block, fullOldPath, fullNewPath, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSRenameAsync(client, block, fullOldPath, fullNewPath, errHandling, (FSAsyncParams*)asyncParams); } } else @@ -817,7 +718,7 @@ namespace save ppcDefineParamMEMPTR(oldPath, const char, 3); ppcDefineParamMEMPTR(newPath, const char, 4); ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 6); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); const SAVEStatus result = SAVERenameAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, oldPath.GetPtr(), newPath.GetPtr(), errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVERenameAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, oldPath.GetPtr(), newPath.GetPtr(), errHandling, result); @@ -855,7 +756,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 3); ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 4); ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 6); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); const SAVEStatus result = SAVEOpenDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEOpenDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), hDir.GetMPTR(), @@ -866,14 +767,14 @@ namespace save SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -901,7 +802,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVEOpenDirOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEOpenDirOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -911,7 +812,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath)) - result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -929,7 +830,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 4); ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 7); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 7); const SAVEStatus result = SAVEOpenDirOtherApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEOpenDirOtherApplicationAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), titleId, accountSlot, path.GetPtr(), hDir.GetMPTR(), @@ -940,14 +841,14 @@ namespace save SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -976,7 +877,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVEOpenDirOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEOpenDirOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); @@ -991,7 +892,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 4); ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 7); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 7); const SAVEStatus result = SAVEOpenDirOtherNormalApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -1017,7 +918,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVEOpenDirOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEOpenDirOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); @@ -1033,7 +934,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 5); ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 6); ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 8); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); const SAVEStatus result = SAVEOpenDirOtherNormalApplicationVariationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -1067,7 +968,7 @@ namespace save ppcDefineParamU8(accountSlot, 2); ppcDefineParamMEMPTR(path, const char, 3); ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 5); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); const SAVEStatus result = SAVEMakeDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEMakeDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); @@ -1077,14 +978,14 @@ namespace save SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -1110,26 +1011,10 @@ namespace save osLib_returnFromFunction(hCPU, result); } - void export_SAVEOpenFileAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(mode, const char, 4); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 5); - ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParamsNew_t, 7); - - const SAVEStatus result = SAVEOpenFileAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEOpenFileAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {}, 0x{:08x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetMPTR(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling) + SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParamsNew_t asyncParams; + FSAsyncParams asyncParams; asyncParams.ioMsgQueue = nullptr; asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); @@ -1138,7 +1023,7 @@ namespace save param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; asyncParams.userContext = param.GetPointer(); - SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, hFile, errHandling, &asyncParams); + SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, outFileHandle, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) { coreinit_suspendThread(currentThread, 1000); @@ -1149,21 +1034,6 @@ namespace save return status; } - void export_SAVEOpenFile(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(mode, const char, 4); - ppcDefineParamMEMPTR(hFile, FSFileHandleDepr_t, 5); - ppcDefineParamU32(errHandling, 6); - - const SAVEStatus result = SAVEOpenFile(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetPtr(), errHandling); - cemuLog_log(LogType::Save, "SAVEOpenFile(0x{:08x}, 0x{:08x}, {:x}, {}, {}, 0x{:08x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), mode.GetPtr(), hFile.GetMPTR(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - void export_SAVEInitSaveDir(PPCInterpreter_t* hCPU) { ppcDefineParamU8(accountSlot, 0); @@ -1180,7 +1050,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 3); ppcDefineParamMEMPTR(stat, FSStat_t, 4); ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 6); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); const SAVEStatus result = SAVEGetStatAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEGetStatAsync(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), stat.GetMPTR(), errHandling, result); @@ -1190,14 +1060,14 @@ namespace save SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -1233,7 +1103,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 5); ppcDefineParamMEMPTR(stat, FSStat_t, 6); ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 8); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); const SAVEStatus result = SAVEGetStatOtherApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -1242,14 +1112,14 @@ namespace save SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -1286,7 +1156,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 4); ppcDefineParamMEMPTR(stat, FSStat_t, 5); ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 8); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); const SAVEStatus result = SAVEGetStatOtherNormalApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -1294,8 +1164,6 @@ namespace save SAVEStatus SAVEGetStatOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { - //peterBreak(); - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); return SAVEGetStatOtherApplication(client, block, titleId, accountSlot, path, stat, errHandling); } @@ -1326,7 +1194,7 @@ namespace save ppcDefineParamMEMPTR(path, const char, 5); ppcDefineParamMEMPTR(stat, FSStat_t, 6); ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 8); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); const SAVEStatus result = SAVEGetStatOtherNormalApplicationVariationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); osLib_returnFromFunction(hCPU, result); @@ -1397,7 +1265,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVEChangeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEChangeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -1407,7 +1275,7 @@ namespace save { char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSChangeDirAsync(client, block, fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSChangeDirAsync(client, block, fullPath, errHandling, (FSAsyncParams*)asyncParams); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -1423,7 +1291,7 @@ namespace save ppcDefineParamU8(accountSlot, 2); ppcDefineParamMEMPTR(path, const char, 3); ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 5); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); const SAVEStatus result = SAVEChangeDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEChangeDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); osLib_returnFromFunction(hCPU, result); @@ -1432,14 +1300,14 @@ namespace save SAVEStatus SAVEChangeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -1464,7 +1332,7 @@ namespace save osLib_returnFromFunction(hCPU, result); } - SAVEStatus SAVEFlushQuotaAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling, const FSAsyncParams_t* asyncParams) + SAVEStatus SAVEFlushQuotaAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -1475,7 +1343,7 @@ namespace save char fullPath[SAVE_MAX_PATH_SIZE]; if (GetAbsoluteFullPath(persistentId, nullptr, fullPath)) { - result = coreinit::FSFlushQuotaAsync(client, block, fullPath, errHandling, (FSAsyncParamsNew_t*)asyncParams); + result = coreinit::FSFlushQuotaAsync(client, block, fullPath, errHandling, (FSAsyncParams*)asyncParams); // if(OSGetUPID != 0xF) UpdateSaveTimeStamp(persistentId); } @@ -1493,7 +1361,7 @@ namespace save ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); ppcDefineParamU8(accountSlot, 2); ppcDefineParamU32(errHandling, 3); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams_t, 4); + ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 4); const SAVEStatus result = SAVEFlushQuotaAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, errHandling, asyncParams.GetPtr()); cemuLog_log(LogType::Save, "SAVEFlushQuotaAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); osLib_returnFromFunction(hCPU, result); @@ -1502,14 +1370,14 @@ namespace save SAVEStatus SAVEFlushQuota(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling) { MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams_t asyncParams; - asyncParams.ioMsgQueue = MPTR_NULL; - asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback)); + FSAsyncParams asyncParams; + asyncParams.ioMsgQueue = nullptr; + asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); StackAllocator<AsyncCallbackParam_t> param; param->thread = currentThread; param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetMPTRBE(); + asyncParams.userContext = ¶m; SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams); if (status == (FSStatus)FS_RESULT::SUCCESS) @@ -1553,10 +1421,14 @@ namespace save osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplication", export_SAVEGetStatOtherNormalApplication); osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationVariation", export_SAVEGetStatOtherNormalApplicationVariation); - osLib_addFunction("nn_save", "SAVEOpenFile", export_SAVEOpenFile); - osLib_addFunction("nn_save", "SAVEOpenFileOtherApplication", export_SAVEOpenFileOtherApplication); - osLib_addFunction("nn_save", "SAVEOpenFileOtherNormalApplication", export_SAVEOpenFileOtherNormalApplication); - osLib_addFunction("nn_save", "SAVEOpenFileOtherNormalApplicationVariation", export_SAVEOpenFileOtherNormalApplicationVariation); + cafeExportRegister("nn_save", SAVEOpenFile, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplicationVariation, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplicationVariationAsync, LogType::Save); osLib_addFunction("nn_save", "SAVEOpenDir", export_SAVEOpenDir); osLib_addFunction("nn_save", "SAVEOpenDirOtherApplication", export_SAVEOpenDirOtherApplication); @@ -1578,11 +1450,6 @@ namespace save osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationAsync", export_SAVEGetStatOtherNormalApplicationAsync); osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationVariationAsync", export_SAVEGetStatOtherNormalApplicationVariationAsync); - osLib_addFunction("nn_save", "SAVEOpenFileAsync", export_SAVEOpenFileAsync); - osLib_addFunction("nn_save", "SAVEOpenFileOtherApplicationAsync", export_SAVEOpenFileOtherApplicationAsync); - osLib_addFunction("nn_save", "SAVEOpenFileOtherNormalApplicationAsync", export_SAVEOpenFileOtherNormalApplicationAsync); - osLib_addFunction("nn_save", "SAVEOpenFileOtherNormalApplicationVariationAsync", export_SAVEOpenFileOtherNormalApplicationVariationAsync); - osLib_addFunction("nn_save", "SAVEOpenDirAsync", export_SAVEOpenDirAsync); osLib_addFunction("nn_save", "SAVEOpenDirOtherApplicationAsync", export_SAVEOpenDirOtherApplicationAsync); osLib_addFunction("nn_save", "SAVEOpenDirOtherNormalApplicationAsync", export_SAVEOpenDirOtherNormalApplicationAsync); diff --git a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp index 91d15af4..5560568d 100644 --- a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp +++ b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp @@ -511,7 +511,7 @@ namespace proc_ui { MEMPTR<void> fgBase; uint32be fgFreeSize; - OSGetForegroundBucketFreeArea((MPTR*)&fgBase, (MPTR*)&fgFreeSize); + OSGetForegroundBucketFreeArea(&fgBase, &fgFreeSize); if(fgFreeSize < size) cemuLog_log(LogType::Force, "ProcUISetBucketStorage: Buffer size too small"); s_bucketStorageBasePtr = memBase; @@ -521,7 +521,7 @@ namespace proc_ui { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); if(memBoundSize < size) cemuLog_log(LogType::Force, "ProcUISetMEM1Storage: Buffer size too small"); s_mem1StorageBasePtr = memBase; @@ -751,14 +751,14 @@ namespace proc_ui { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); OSBlockMove(s_mem1StorageBasePtr.GetPtr(), memBound.GetPtr(), memBoundSize, true); } if (s_bucketStorageBasePtr) { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetForegroundBucketFreeArea((MPTR*)memBound.GetBEPtr(), (MPTR*)&memBoundSize); + OSGetForegroundBucketFreeArea(&memBound, &memBoundSize); OSBlockMove(s_bucketStorageBasePtr.GetPtr(), memBound.GetPtr(), memBoundSize, true); } } @@ -769,7 +769,7 @@ namespace proc_ui { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetMemBound(1, (MPTR*)memBound.GetBEPtr(), (uint32*)&memBoundSize); + OSGetMemBound(1, &memBound, &memBoundSize); OSBlockMove(memBound.GetPtr(), s_mem1StorageBasePtr, memBoundSize, true); GX2::GX2Invalidate(0x40, s_mem1StorageBasePtr.GetMPTR(), memBoundSize); } @@ -777,7 +777,7 @@ namespace proc_ui { MEMPTR<void> memBound; uint32be memBoundSize; - OSGetForegroundBucketFreeArea((MPTR*)memBound.GetBEPtr(), (MPTR*)&memBoundSize); + OSGetForegroundBucketFreeArea(&memBound, &memBoundSize); OSBlockMove(memBound.GetPtr(), s_bucketStorageBasePtr, memBoundSize, true); GX2::GX2Invalidate(0x40, memBound.GetMPTR(), memBoundSize); } diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index de787cc1..b2362d0b 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -136,16 +136,10 @@ public: C* GetPtr() const { return (C*)(GetPtr()); } constexpr uint32 GetMPTR() const { return m_value.value(); } - constexpr uint32 GetRawValue() const { return m_value.bevalue(); } // accesses value using host-endianness - constexpr const uint32be& GetBEValue() const { return m_value; } constexpr bool IsNull() const { return m_value == 0; } - constexpr uint32 GetMPTRBE() const { return m_value.bevalue(); } - - uint32be* GetBEPtr() { return &m_value; } - private: uint32be m_value; }; diff --git a/src/Common/StackAllocator.h b/src/Common/StackAllocator.h index a69b7aaa..1dc52d51 100644 --- a/src/Common/StackAllocator.h +++ b/src/Common/StackAllocator.h @@ -28,7 +28,6 @@ public: T* GetPointer() const { return m_ptr; } uint32 GetMPTR() const { return MEMPTR<T>(m_ptr).GetMPTR(); } - uint32 GetMPTRBE() const { return MEMPTR<T>(m_ptr).GetMPTRBE(); } T* operator&() { return GetPointer(); } explicit operator T*() const { return GetPointer(); } From c11d83e9d8980bdc8978001583ddaa5ca0b6529b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 3 May 2024 02:41:05 +0200 Subject: [PATCH 161/314] coreinit: Implement MCP_GetTitleId --- src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp index 14d7a645..330663ac 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MCP.cpp @@ -415,6 +415,12 @@ namespace coreinit return 0; } + uint32 MCP_GetTitleId(uint32 mcpHandle, uint64be* outTitleId) + { + *outTitleId = CafeSystem::GetForegroundTitleId(); + return 0; + } + void InitializeMCP() { osLib_addFunction("coreinit", "MCP_Open", coreinitExport_MCP_Open); @@ -442,6 +448,8 @@ namespace coreinit cafeExportRegister("coreinit", MCP_RightCheckLaunchable, LogType::Placeholder); cafeExportRegister("coreinit", MCP_GetEcoSettings, LogType::Placeholder); + + cafeExportRegister("coreinit", MCP_GetTitleId, LogType::Placeholder); } } From 1b5c885621c8a2e6057cc6c6c0bd557f6da5a327 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 3 May 2024 02:41:39 +0200 Subject: [PATCH 162/314] nn_acp: Implement ACPGetTitleMetaXml --- src/Cafe/OS/libs/nn_acp/nn_acp.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp index 61640ae7..37ea471f 100644 --- a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp +++ b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp @@ -289,6 +289,18 @@ namespace acp osLib_returnFromFunction(hCPU, acpRequest->returnCode); } + uint32 ACPGetTitleMetaXml(uint64 titleId, acpMetaXml_t* acpMetaXml) + { + acpPrepareRequest(); + acpRequest->requestCode = IOSU_ACP_GET_TITLE_META_XML; + acpRequest->ptr = acpMetaXml; + acpRequest->titleId = titleId; + + __depr__IOS_Ioctlv(IOS_DEVICE_ACP_MAIN, IOSU_ACP_REQUEST_CEMU, 1, 1, acpBufferVector); + + return acpRequest->returnCode; + } + void export_ACPIsOverAgeEx(PPCInterpreter_t* hCPU) { ppcDefineParamU32(age, 0); @@ -341,6 +353,7 @@ namespace acp osLib_addFunction("nn_acp", "ACPGetTitleMetaDirByDevice", export_ACPGetTitleMetaDirByDevice); osLib_addFunction("nn_acp", "ACPGetTitleMetaXmlByDevice", export_ACPGetTitleMetaXmlByDevice); + cafeExportRegister("nn_acp", ACPGetTitleMetaXml, LogType::Placeholder); cafeExportRegister("nn_acp", ACPGetApplicationBox, LogType::Placeholder); From 041f29a914b0e0ef88b4dad863cf71a6fdcca84f Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 3 May 2024 02:43:51 +0200 Subject: [PATCH 163/314] nn_act: Implement GetTimeZoneId placeholder --- src/Cafe/OS/libs/nn_act/nn_act.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index 2a9f61bc..af53edd7 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -5,6 +5,7 @@ #include "nn_act.h" #include "Cafe/OS/libs/nn_common.h" #include "Cafe/CafeSystem.h" +#include "Common/CafeString.h" sint32 numAccounts = 1; @@ -140,6 +141,14 @@ namespace act return 0; } + nnResult GetTimeZoneId(CafeString<65>* outTimezoneId) + { + // return a placeholder timezone id for now + // in the future we should emulated this correctly and read the timezone from the account via IOSU + outTimezoneId->assign("Europe/London"); + return 0; + } + sint32 g_initializeCount = 0; // inc in Initialize and dec in Finalize uint32 Initialize() { @@ -162,7 +171,6 @@ namespace act NN_ERROR_CODE errCode = NNResultToErrorCode(*nnResult, NN_RESULT_MODULE_NN_ACT); return errCode; } - } } @@ -691,6 +699,8 @@ void nnAct_load() osLib_addFunction("nn_act", "GetPersistentIdEx__Q2_2nn3actFUc", nnActExport_GetPersistentIdEx); // country osLib_addFunction("nn_act", "GetCountry__Q2_2nn3actFPc", nnActExport_GetCountry); + // timezone + cafeExportRegisterFunc(nn::act::GetTimeZoneId, "nn_act", "GetTimeZoneId__Q2_2nn3actFPc", LogType::Placeholder); // parental osLib_addFunction("nn_act", "EnableParentalControlCheck__Q2_2nn3actFb", nnActExport_EnableParentalControlCheck); From a16c37f0c5b2435a829fc5348c66297d9c762347 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 4 May 2024 07:05:59 +0200 Subject: [PATCH 164/314] coreinit: Rework thread creation New implementation is much closer to console behavior. For example we didn't align the stack which would cause crashes in the Miiverse applet --- src/Cafe/HW/Latte/Core/LatteThread.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit.cpp | 10 +- src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp | 4 +- src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 315 ++++++++++++++---- src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 69 ++-- src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 4 +- src/Cafe/OS/libs/snd_core/ax_ist.cpp | 2 +- .../ExceptionHandler/ExceptionHandler.cpp | 2 +- .../DebugPPCThreadsWindow.cpp | 4 +- 10 files changed, 297 insertions(+), 117 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteThread.cpp b/src/Cafe/HW/Latte/Core/LatteThread.cpp index a23bd5be..8874ecf4 100644 --- a/src/Cafe/HW/Latte/Core/LatteThread.cpp +++ b/src/Cafe/HW/Latte/Core/LatteThread.cpp @@ -187,7 +187,7 @@ int Latte_ThreadEntry() rule.overwrite_settings.width >= 0 || rule.overwrite_settings.height >= 0 || rule.overwrite_settings.depth >= 0) { LatteGPUState.allowFramebufferSizeOptimization = false; - cemuLog_log(LogType::Force, "Graphic pack {} prevents rendertarget size optimization.", pack->GetName()); + cemuLog_log(LogType::Force, "Graphic pack \"{}\" prevents rendertarget size optimization. This warning can be ignored and is intended for graphic pack developers", pack->GetName()); break; } } diff --git a/src/Cafe/OS/libs/coreinit/coreinit.cpp b/src/Cafe/OS/libs/coreinit/coreinit.cpp index e18d0e8d..49d232f8 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit.cpp @@ -35,12 +35,12 @@ #include "Cafe/OS/libs/coreinit/coreinit_MEM_BlockHeap.h" #include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h" -CoreinitSharedData* gCoreinitData = NULL; +CoreinitSharedData* gCoreinitData = nullptr; sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp) { - uint32 stackMinAddr = _swapEndianU32(thread->stackEnd); - uint32 stackMaxAddr = _swapEndianU32(thread->stackBase); + uint32 stackMinAddr = thread->stackEnd.GetMPTR(); + uint32 stackMaxAddr = thread->stackBase.GetMPTR(); sint32 score = 0; uint32 currentStackPtr = sp; @@ -95,8 +95,8 @@ void DebugLogStackTrace(OSThread_t* thread, MPTR sp) // print stack trace uint32 currentStackPtr = highestScoreSP; - uint32 stackMinAddr = _swapEndianU32(thread->stackEnd); - uint32 stackMaxAddr = _swapEndianU32(thread->stackBase); + uint32 stackMinAddr = thread->stackEnd.GetMPTR(); + uint32 stackMaxAddr = thread->stackBase.GetMPTR(); for (sint32 i = 0; i < 20; i++) { uint32 nextStackPtr = memory_readU32(currentStackPtr); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp index 5699e3e7..e2864fb9 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp @@ -22,7 +22,7 @@ namespace coreinit MPTR _iob_lock[GHS_FOPEN_MAX]; uint16be __gh_FOPEN_MAX; MEMPTR<void> ghs_environ; - uint32 ghs_Errno; // exposed by __gh_errno_ptr() or via 'errno' data export + uint32 ghs_Errno; // exposed as 'errno' data export }; SysAllocator<GHSAccessibleData> g_ghs_data; @@ -159,7 +159,7 @@ namespace coreinit void* __gh_errno_ptr() { OSThread_t* currentThread = coreinit::OSGetCurrentThread(); - return ¤tThread->context.error; + return ¤tThread->context.ghs_errno; } void* __get_eh_store_globals() diff --git a/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp b/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp index be3cb300..12d83afc 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_IPC.cpp @@ -204,7 +204,7 @@ namespace coreinit // and a message queue large enough to hold the maximum number of commands (IPC_NUM_RESOURCE_BUFFERS) OSInitMessageQueue(gIPCThreadMsgQueue.GetPtr() + coreIndex, _gIPCThreadSemaphoreStorage.GetPtr() + coreIndex * IPC_NUM_RESOURCE_BUFFERS, IPC_NUM_RESOURCE_BUFFERS); OSThread_t* ipcThread = gIPCThread.GetPtr() + coreIndex; - OSCreateThreadType(ipcThread, PPCInterpreter_makeCallableExportDepr(__IPCDriverThreadFunc), 0, nullptr, _gIPCThreadStack.GetPtr() + 0x4000 * coreIndex + 0x4000, 0x4000, 15, (1 << coreIndex), OSThread_t::THREAD_TYPE::TYPE_DRIVER); + __OSCreateThreadType(ipcThread, PPCInterpreter_makeCallableExportDepr(__IPCDriverThreadFunc), 0, nullptr, _gIPCThreadStack.GetPtr() + 0x4000 * coreIndex + 0x4000, 0x4000, 15, (1 << coreIndex), OSThread_t::THREAD_TYPE::TYPE_DRIVER); sprintf((char*)_gIPCThreadNameStorage.GetPtr()+coreIndex*0x18, "{SYS IPC Core %d}", coreIndex); OSSetThreadName(ipcThread, (char*)_gIPCThreadNameStorage.GetPtr() + coreIndex * 0x18); OSResumeThread(ipcThread); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 654e57a8..533360aa 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -215,14 +215,171 @@ namespace coreinit hCPU->spr.LR = lr; hCPU->gpr[3] = r3; hCPU->gpr[4] = r4; - hCPU->instructionPointer = _swapEndianU32(currentThread->entrypoint); + hCPU->instructionPointer = currentThread->entrypoint.GetMPTR(); } void coreinitExport_OSExitThreadDepr(PPCInterpreter_t* hCPU); - void OSCreateThreadInternal(OSThread_t* thread, uint32 entryPoint, MPTR stackLowerBaseAddr, uint32 stackSize, uint8 affinityMask, OSThread_t::THREAD_TYPE threadType) + void __OSInitContext(OSContext_t* ctx, MEMPTR<void> initialIP, MEMPTR<void> initialStackPointer) + { + ctx->SetContextMagic(); + ctx->gpr[0] = 0; // r0 is left uninitialized on console? + for(auto& it : ctx->gpr) + it = 0; + ctx->gpr[1] = _swapEndianU32(initialStackPointer.GetMPTR()); + ctx->gpr[2] = _swapEndianU32(RPLLoader_GetSDA2Base()); + ctx->gpr[13] = _swapEndianU32(RPLLoader_GetSDA1Base()); + ctx->srr0 = initialIP.GetMPTR(); + ctx->cr = 0; + ctx->ukn0A8 = 0; + ctx->ukn0AC = 0; + ctx->gqr[0] = 0; + ctx->gqr[1] = 0; + ctx->gqr[2] = 0; + ctx->gqr[3] = 0; + ctx->gqr[4] = 0; + ctx->gqr[5] = 0; + ctx->gqr[6] = 0; + ctx->gqr[7] = 0; + ctx->dsi_dar = 0; + ctx->srr1 = 0x9032; + ctx->xer = 0; + ctx->dsi_dsisr = 0; + ctx->upir = 0; + ctx->boostCount = 0; + ctx->state = 0; + for(auto& it : ctx->coretime) + it = 0; + ctx->starttime = 0; + ctx->ghs_errno = 0; + ctx->upmc1 = 0; + ctx->upmc2 = 0; + ctx->upmc3 = 0; + ctx->upmc4 = 0; + ctx->ummcr0 = 0; + ctx->ummcr1 = 0; + } + + void __OSThreadInit(OSThread_t* thread, MEMPTR<void> entrypoint, uint32 argInt, MEMPTR<void> argPtr, MEMPTR<void> stackTop, uint32 stackSize, sint32 priority, uint32 upirCoreIndex, OSThread_t::THREAD_TYPE threadType) + { + thread->effectivePriority = priority; + thread->type = threadType; + thread->basePriority = priority; + thread->SetThreadMagic(); + thread->id = 0x8000; + thread->waitAlarm = nullptr; + thread->entrypoint = entrypoint; + thread->quantumTicks = 0; + if(entrypoint) + { + thread->state = OSThread_t::THREAD_STATE::STATE_READY; + thread->suspendCounter = 1; + } + else + { + thread->state = OSThread_t::THREAD_STATE::STATE_NONE; + thread->suspendCounter = 0; + } + thread->exitValue = (uint32)-1; + thread->requestFlags = OSThread_t::REQUEST_FLAG_BIT::REQUEST_FLAG_NONE; + thread->pendingSuspend = 0; + thread->suspendResult = 0xFFFFFFFF; + thread->coretimeSumQuantumStart = 0; + thread->deallocatorFunc = nullptr; + thread->cleanupCallback = nullptr; + thread->waitingForFastMutex = nullptr; + thread->stateFlags = 0; + thread->waitingForMutex = nullptr; + memset(&thread->crt, 0, sizeof(thread->crt)); + static_assert(sizeof(thread->crt) == 0x1D8); + thread->tlsBlocksMPTR = 0; + thread->numAllocatedTLSBlocks = 0; + thread->tlsStatus = 0; + OSInitThreadQueueEx(&thread->joinQueue, thread); + OSInitThreadQueueEx(&thread->suspendQueue, thread); + thread->mutexQueue.ukn08 = thread; + thread->mutexQueue.ukn0C = 0; + thread->mutexQueue.tail = nullptr; + thread->mutexQueue.head = nullptr; + thread->ownedFastMutex.next = nullptr; + thread->ownedFastMutex.prev = nullptr; + thread->contendedFastMutex.next = nullptr; + thread->contendedFastMutex.prev = nullptr; + + MEMPTR<void> alignedStackTop{MEMPTR<void>(stackTop).GetMPTR() & 0xFFFFFFF8}; + MEMPTR<uint32be> alignedStackTop32{alignedStackTop}; + alignedStackTop32[-1] = 0; + alignedStackTop32[-2] = 0; + + __OSInitContext(&thread->context, MEMPTR<void>(PPCInterpreter_makeCallableExportDepr(threadEntry)), (void*)(alignedStackTop32.GetPtr() - 2)); + thread->stackBase = stackTop; // without alignment + thread->stackEnd = ((uint8*)stackTop.GetPtr() - stackSize); + thread->context.upir = upirCoreIndex; + thread->context.lr = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(coreinitExport_OSExitThreadDepr)); + thread->context.gpr[3] = _swapEndianU32(argInt); + thread->context.gpr[4] = _swapEndianU32(argPtr.GetMPTR()); + + *(uint32be*)((uint8*)stackTop.GetPtr() - stackSize) = 0xDEADBABE; + thread->alarmRelatedUkn = 0; + for(auto& it : thread->specificArray) + it = nullptr; + thread->context.fpscr.fpscr = 4; + for(sint32 i=0; i<32; i++) + { + thread->context.fp_ps0[i] = 0.0; + thread->context.fp_ps1[i] = 0.0; + } + thread->context.gqr[2] = 0x40004; + thread->context.gqr[3] = 0x50005; + thread->context.gqr[4] = 0x60006; + thread->context.gqr[5] = 0x70007; + + for(sint32 i=0; i<Espresso::CORE_COUNT; i++) + thread->context.coretime[i] = 0; + + // currentRunQueue and waitQueueLink is not initialized by COS and instead overwritten without validation + // since we already have integrity checks in other functions, lets initialize it here + for(sint32 i=0; i<Espresso::CORE_COUNT; i++) + thread->currentRunQueue[i] = nullptr; + thread->waitQueueLink.prev = nullptr; + thread->waitQueueLink.next = nullptr; + + thread->wakeTimeRelatedUkn2 = 0; + thread->wakeUpCount = 0; + thread->wakeUpTime = 0; + thread->wakeTimeRelatedUkn1 = 0x7FFFFFFFFFFFFFFF; + thread->quantumTicks = 0; + thread->coretimeSumQuantumStart = 0; + thread->totalCycles = 0; + + for(auto& it : thread->padding68C) + it = 0; + } + + void SetThreadAffinityToCore(OSThread_t* thread, uint32 coreIndex) + { + cemu_assert_debug(coreIndex < 3); + thread->attr &= ~(OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE0 | OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE1 | OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE2 | OSThread_t::ATTR_BIT::ATTR_UKN_010); + thread->context.affinity &= 0xFFFFFFF8; + if (coreIndex == 0) + { + thread->attr |= OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE0; + thread->context.affinity |= (1<<0); + } + else if (coreIndex == 1) + { + thread->attr |= OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE1; + thread->context.affinity |= (1<<1); + } + else // if (coreIndex == 2) + { + thread->attr |= OSThread_t::ATTR_BIT::ATTR_AFFINITY_CORE2; + thread->context.affinity |= (1<<2); + } + } + + void __OSCreateThreadOnActiveThreadWorkaround(OSThread_t* thread) { - cemu_assert_debug(thread != nullptr); // make thread struct mandatory. Caller can always use SysAllocator __OSLockScheduler(); bool isThreadStillActive = __OSIsThreadActive(thread); if (isThreadStillActive) @@ -248,84 +405,97 @@ namespace coreinit } cemu_assert_debug(__OSIsThreadActive(thread) == false); __OSUnlockScheduler(); - memset(thread, 0x00, sizeof(OSThread_t)); - // init signatures - thread->SetMagic(); - thread->type = threadType; - thread->state = (entryPoint != MPTR_NULL) ? OSThread_t::THREAD_STATE::STATE_READY : OSThread_t::THREAD_STATE::STATE_NONE; - thread->entrypoint = _swapEndianU32(entryPoint); - __OSSetThreadBasePriority(thread, 0); - __OSUpdateThreadEffectivePriority(thread); - // untested, but seems to work (Batman Arkham City uses these values to calculate the stack size for duplicated threads) - thread->stackBase = _swapEndianU32(stackLowerBaseAddr + stackSize); // these fields are quite important and lots of games rely on them being accurate (Examples: Darksiders 2, SMW3D, Batman Arkham City) - thread->stackEnd = _swapEndianU32(stackLowerBaseAddr); - // init stackpointer - thread->context.gpr[GPR_SP] = _swapEndianU32(stackLowerBaseAddr + stackSize - 0x20); // how many free bytes should there be at the beginning of the stack? - // init misc stuff - thread->attr = affinityMask; - thread->context.setAffinity(affinityMask); - thread->context.srr0 = PPCInterpreter_makeCallableExportDepr(threadEntry); - thread->context.lr = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(coreinitExport_OSExitThreadDepr)); - thread->id = 0x8000; // Warriors Orochi 3 softlocks if this is zero due to confusing threads (_OSActivateThread should set this?) - // init ugqr - thread->context.gqr[0] = 0x00000000; - thread->context.gqr[1] = 0x00000000; - thread->context.gqr[2] = 0x00040004; - thread->context.gqr[3] = 0x00050005; - thread->context.gqr[4] = 0x00060006; - thread->context.gqr[5] = 0x00070007; - thread->context.gqr[6] = 0x00000000; - thread->context.gqr[7] = 0x00000000; - // init r2 (SDA2) and r3 (SDA) - thread->context.gpr[2] = _swapEndianU32(RPLLoader_GetSDA2Base()); - thread->context.gpr[13] = _swapEndianU32(RPLLoader_GetSDA1Base()); - // GHS related thread init? + } - __OSLockScheduler(); - // if entrypoint is non-zero then put the thread on the active list and suspend it - if (entryPoint != MPTR_NULL) + bool __OSCreateThreadInternal2(OSThread_t* thread, MEMPTR<void> entrypoint, uint32 argInt, MEMPTR<void> argPtr, MEMPTR<void> stackBase, uint32 stackSize, sint32 priority, uint32 attrBits, OSThread_t::THREAD_TYPE threadType) + { + __OSCreateThreadOnActiveThreadWorkaround(thread); + OSThread_t* currentThread = OSGetCurrentThread(); + if (priority < 0 || priority >= 32) { - thread->suspendCounter = 1; - __OSActivateThread(thread); - thread->state = OSThread_t::THREAD_STATE::STATE_READY; + cemuLog_log(LogType::APIErrors, "OSCreateThreadInternal: Thread priority must be in range 0-31"); + return false; + } + if (threadType == OSThread_t::THREAD_TYPE::TYPE_IO) + { + priority = priority + 0x20; + } + else if (threadType == OSThread_t::THREAD_TYPE::TYPE_APP) + { + priority = priority + 0x40; + } + if(attrBits >= 0x20 || stackBase == nullptr || stackSize == 0) + { + cemuLog_logDebug(LogType::APIErrors, "OSCreateThreadInternal: Invalid attributes, stack base or size"); + return false; + } + uint32 im = OSDisableInterrupts(); + __OSLockScheduler(thread); + + uint32 coreIndex = PPCInterpreter_getCurrentInstance() ? OSGetCoreId() : 1; + __OSThreadInit(thread, entrypoint, argInt, argPtr, stackBase, stackSize, priority, coreIndex, threadType); + thread->threadName = nullptr; + thread->context.affinity = attrBits & 7; + thread->attr = attrBits; + if ((attrBits & 7) == 0) // if no explicit affinity is given, use the current core + SetThreadAffinityToCore(thread, OSGetCoreId()); + if(currentThread) + { + for(sint32 i=0; i<Espresso::CORE_COUNT; i++) + { + thread->dsiCallback[i] = currentThread->dsiCallback[i]; + thread->isiCallback[i] = currentThread->isiCallback[i]; + thread->programCallback[i] = currentThread->programCallback[i]; + thread->perfMonCallback[i] = currentThread->perfMonCallback[i]; + thread->alignmentExceptionCallback[i] = currentThread->alignmentExceptionCallback[i]; + } + thread->context.srr1 = thread->context.srr1 | (currentThread->context.srr1 & 0x900); + thread->context.fpscr.fpscr = thread->context.fpscr.fpscr | (currentThread->context.fpscr.fpscr & 0xF8); } else - thread->suspendCounter = 0; - __OSUnlockScheduler(); + { + for(sint32 i=0; i<Espresso::CORE_COUNT; i++) + { + thread->dsiCallback[i] = 0; + thread->isiCallback[i] = 0; + thread->programCallback[i] = 0; + thread->perfMonCallback[i] = 0; + thread->alignmentExceptionCallback[i] = nullptr; + } + } + if (entrypoint) + { + thread->id = 0x8000; + __OSActivateThread(thread); // also handles adding the thread to g_activeThreadQueue + } + __OSUnlockScheduler(thread); + OSRestoreInterrupts(im); + // recompile entry point function + if (entrypoint) + PPCRecompiler_recompileIfUnvisited(entrypoint.GetMPTR()); + return true; } bool OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType) { - OSCreateThreadInternal(thread, entryPoint, memory_getVirtualOffsetFromPointer(stackTop) - stackSize, stackSize, attr, threadType); - thread->context.gpr[3] = _swapEndianU32(numParam); // num arguments - thread->context.gpr[4] = _swapEndianU32(memory_getVirtualOffsetFromPointer(ptrParam)); // arguments pointer - __OSSetThreadBasePriority(thread, priority); - __OSUpdateThreadEffectivePriority(thread); - // set affinity - uint8 affinityMask = 0; - affinityMask = attr & 0x7; - // if no core is selected -> set current one - if (affinityMask == 0) - affinityMask |= (1 << PPCInterpreter_getCoreIndex(PPCInterpreter_getCurrentInstance())); - // set attr - // todo: Support for other attr bits - thread->attr = (affinityMask & 0xFF) | (attr & OSThread_t::ATTR_BIT::ATTR_DETACHED); - thread->context.setAffinity(affinityMask); - // recompile entry point function - if (entryPoint != MPTR_NULL) - PPCRecompiler_recompileIfUnvisited(entryPoint); - return true; + if(threadType != OSThread_t::THREAD_TYPE::TYPE_APP && threadType != OSThread_t::THREAD_TYPE::TYPE_IO) + { + cemuLog_logDebug(LogType::APIErrors, "OSCreateThreadType: Invalid thread type"); + cemu_assert_suspicious(); + return false; + } + return __OSCreateThreadInternal2(thread, MEMPTR<void>(entryPoint), numParam, ptrParam, stackTop, stackSize, priority, attr, threadType); } bool OSCreateThread(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr) { - return OSCreateThreadType(thread, entryPoint, numParam, ptrParam, stackTop, stackSize, priority, attr, OSThread_t::THREAD_TYPE::TYPE_APP); + return __OSCreateThreadInternal2(thread, MEMPTR<void>(entryPoint), numParam, ptrParam, stackTop, stackSize, priority, attr, OSThread_t::THREAD_TYPE::TYPE_APP); } - // alias to OSCreateThreadType, similar to OSCreateThread, but with an additional parameter for the thread type + // similar to OSCreateThreadType, but can be used to create any type of thread bool __OSCreateThreadType(OSThread_t* thread, MPTR entryPoint, sint32 numParam, void* ptrParam, void* stackTop, sint32 stackSize, sint32 priority, uint32 attr, OSThread_t::THREAD_TYPE threadType) { - return OSCreateThreadType(thread, entryPoint, numParam, ptrParam, stackTop, stackSize, priority, attr, threadType); + return __OSCreateThreadInternal2(thread, MEMPTR<void>(entryPoint), numParam, ptrParam, stackTop, stackSize, priority, attr, threadType); } bool OSRunThread(OSThread_t* thread, MPTR funcAddress, sint32 numParam, void* ptrParam) @@ -352,7 +522,7 @@ namespace coreinit // set thread state // todo - this should fully reinitialize the thread? - thread->entrypoint = _swapEndianU32(funcAddress); + thread->entrypoint = funcAddress; thread->context.srr0 = PPCInterpreter_makeCallableExportDepr(threadEntry); thread->context.lr = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(coreinitExport_OSExitThreadDepr)); thread->context.gpr[3] = _swapEndianU32(numParam); @@ -378,10 +548,10 @@ namespace coreinit OSThread_t* currentThread = coreinit::OSGetCurrentThread(); // thread cleanup callback - if (!currentThread->cleanupCallback2.IsNull()) + if (currentThread->cleanupCallback) { currentThread->stateFlags = _swapEndianU32(_swapEndianU32(currentThread->stateFlags) | 0x00000001); - PPCCoreCallback(currentThread->cleanupCallback2.GetMPTR(), currentThread, _swapEndianU32(currentThread->stackEnd)); + PPCCoreCallback(currentThread->cleanupCallback.GetMPTR(), currentThread, currentThread->stackEnd); } // cpp exception cleanup if (gCoreinitData->__cpp_exception_cleanup_ptr != 0 && currentThread->crt.eh_globals != nullptr) @@ -602,7 +772,10 @@ namespace coreinit sint32 previousSuspendCount = thread->suspendCounter; cemu_assert_debug(previousSuspendCount >= 0); if (previousSuspendCount == 0) + { + cemuLog_log(LogType::APIErrors, "OSResumeThread: Resuming thread 0x{:08x} which isn't suspended", MEMPTR<OSThread_t>(thread).GetMPTR()); return 0; + } thread->suspendCounter = previousSuspendCount - resumeCount; if (thread->suspendCounter < 0) thread->suspendCounter = 0; @@ -732,8 +905,8 @@ namespace coreinit void* OSSetThreadCleanupCallback(OSThread_t* thread, void* cleanupCallback) { __OSLockScheduler(); - void* previousFunc = thread->cleanupCallback2.GetPtr(); - thread->cleanupCallback2 = cleanupCallback; + void* previousFunc = thread->cleanupCallback.GetPtr(); + thread->cleanupCallback = cleanupCallback; __OSUnlockScheduler(); return previousFunc; } @@ -1341,7 +1514,7 @@ namespace coreinit void __OSQueueThreadDeallocation(OSThread_t* thread) { uint32 coreIndex = OSGetCoreId(); - TerminatorThread::DeallocatorQueueEntry queueEntry(thread, memory_getPointerFromVirtualOffset(_swapEndianU32(thread->stackEnd)), thread->deallocatorFunc); + TerminatorThread::DeallocatorQueueEntry queueEntry(thread, thread->stackEnd, thread->deallocatorFunc); s_terminatorThreads[coreIndex].queueDeallocators.push(queueEntry); OSSignalSemaphoreInternal(s_terminatorThreads[coreIndex].semaphoreQueuedDeallocators.GetPtr(), false); // do not reschedule here! Current thread must not be interrupted otherwise deallocator will run too early } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index b401d96d..fdbcfea7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -2,9 +2,6 @@ #include "Cafe/HW/Espresso/Const.h" #include "Cafe/OS/libs/coreinit/coreinit_Scheduler.h" -#define OS_CONTEXT_MAGIC_0 'OSCo' -#define OS_CONTEXT_MAGIC_1 'ntxt' - struct OSThread_t; struct OSContextRegFPSCR_t @@ -16,6 +13,9 @@ struct OSContextRegFPSCR_t struct OSContext_t { + static constexpr uint32 OS_CONTEXT_MAGIC_0 = 0x4f53436f; // "OSCo" + static constexpr uint32 OS_CONTEXT_MAGIC_1 = 0x6e747874; // "ntxt" + /* +0x000 */ betype<uint32> magic0; /* +0x004 */ betype<uint32> magic1; /* +0x008 */ uint32 gpr[32]; @@ -36,24 +36,29 @@ struct OSContext_t /* +0x1BC */ uint32 gqr[8]; // GQR/UGQR /* +0x1DC */ uint32be upir; // set to current core index /* +0x1E0 */ uint64be fp_ps1[32]; - /* +0x2E0 */ uint64 uknTime2E0; - /* +0x2E8 */ uint64 uknTime2E8; - /* +0x2F0 */ uint64 uknTime2F0; - /* +0x2F8 */ uint64 uknTime2F8; - /* +0x300 */ uint32 error; // returned by __gh_errno_ptr() (used by socketlasterr) + /* +0x2E0 */ uint64be coretime[3]; + /* +0x2F8 */ uint64be starttime; + /* +0x300 */ uint32be ghs_errno; // returned by __gh_errno_ptr() (used by socketlasterr) /* +0x304 */ uint32be affinity; - /* +0x308 */ uint32 ukn0308; - /* +0x30C */ uint32 ukn030C; - /* +0x310 */ uint32 ukn0310; - /* +0x314 */ uint32 ukn0314; - /* +0x318 */ uint32 ukn0318; - /* +0x31C */ uint32 ukn031C; + /* +0x308 */ uint32be upmc1; + /* +0x30C */ uint32be upmc2; + /* +0x310 */ uint32be upmc3; + /* +0x314 */ uint32be upmc4; + /* +0x318 */ uint32be ummcr0; + /* +0x31C */ uint32be ummcr1; bool checkMagic() { return magic0 == (uint32)OS_CONTEXT_MAGIC_0 && magic1 == (uint32)OS_CONTEXT_MAGIC_1; } + void SetContextMagic() + { + magic0 = OS_CONTEXT_MAGIC_0; + magic1 = OS_CONTEXT_MAGIC_1; + } + + bool hasCoreAffinitySet(uint32 coreIndex) const { return (((uint32)affinity >> coreIndex) & 1) != 0; @@ -361,6 +366,8 @@ namespace coreinit struct OSThread_t { + static constexpr uint32 MAGIC_THREAD = 0x74487244; // "tHrD" + enum class THREAD_TYPE : uint32 { TYPE_DRIVER = 0, @@ -383,7 +390,7 @@ struct OSThread_t ATTR_AFFINITY_CORE1 = 0x2, ATTR_AFFINITY_CORE2 = 0x4, ATTR_DETACHED = 0x8, - // more flags? + ATTR_UKN_010 = 0x10, }; enum REQUEST_FLAG_BIT : uint32 @@ -404,23 +411,21 @@ struct OSThread_t return 0; } - void SetMagic() + void SetThreadMagic() { - context.magic0 = OS_CONTEXT_MAGIC_0; - context.magic1 = OS_CONTEXT_MAGIC_1; - magic = 'tHrD'; + magic = MAGIC_THREAD; } bool IsValidMagic() const { - return magic == 'tHrD' && context.magic0 == OS_CONTEXT_MAGIC_0 && context.magic1 == OS_CONTEXT_MAGIC_1; + return magic == MAGIC_THREAD && context.magic0 == OSContext_t::OS_CONTEXT_MAGIC_0 && context.magic1 == OSContext_t::OS_CONTEXT_MAGIC_1; } /* +0x000 */ OSContext_t context; - /* +0x320 */ uint32be magic; // 'tHrD' + /* +0x320 */ uint32be magic; // "tHrD" (0x74487244) /* +0x324 */ betype<THREAD_STATE> state; /* +0x325 */ uint8 attr; - /* +0x326 */ uint16be id; // Warriors Orochi 3 uses this to identify threads. Seems like this is always set to 0x8000 ? + /* +0x326 */ uint16be id; // Warriors Orochi 3 uses this to identify threads /* +0x328 */ betype<sint32> suspendCounter; /* +0x32C */ sint32be effectivePriority; // effective priority (lower is higher) /* +0x330 */ sint32be basePriority; // base priority (lower is higher) @@ -440,21 +445,21 @@ struct OSThread_t /* +0x38C */ coreinit::OSThreadLink activeThreadChain; // queue of active threads (g_activeThreadQueue) - /* +0x394 */ MPTR stackBase; // upper limit of stack - /* +0x398 */ MPTR stackEnd; // lower limit of stack + /* +0x394 */ MEMPTR<void> stackBase; // upper limit of stack + /* +0x398 */ MEMPTR<void> stackEnd; // lower limit of stack - /* +0x39C */ MPTR entrypoint; + /* +0x39C */ MEMPTR<void> entrypoint; /* +0x3A0 */ crt_t crt; /* +0x578 */ sint32 alarmRelatedUkn; /* +0x57C */ std::array<MEMPTR<void>, 16> specificArray; /* +0x5BC */ betype<THREAD_TYPE> type; /* +0x5C0 */ MEMPTR<const char> threadName; - /* +0x5C4 */ MPTR waitAlarm; // used only by OSWaitEventWithTimeout/OSSignalEvent ? + /* +0x5C4 */ MEMPTR<void> waitAlarm; // used only by OSWaitEventWithTimeout/OSSignalEvent ? /* +0x5C8 */ uint32 userStackPointer; - /* +0x5CC */ MEMPTR<void> cleanupCallback2; + /* +0x5CC */ MEMPTR<void> cleanupCallback; /* +0x5D0 */ MEMPTR<void> deallocatorFunc; /* +0x5D4 */ uint32 stateFlags; // 0x5D4 | various flags? Controls if canceling/suspension is allowed (at cancel points) or not? If 1 -> Cancel/Suspension not allowed, if 0 -> Cancel/Suspension allowed @@ -480,19 +485,21 @@ struct OSThread_t /* +0x660 */ uint32 ukn660; + // todo - some of the members towards the end of the struct were only added in later COS versions. Figure out the mapping between version and members + // TLS /* +0x664 */ uint16 numAllocatedTLSBlocks; /* +0x666 */ sint16 tlsStatus; /* +0x668 */ MPTR tlsBlocksMPTR; - + /* +0x66C */ MEMPTR<coreinit::OSFastMutex> waitingForFastMutex; /* +0x670 */ coreinit::OSFastMutexLink contendedFastMutex; /* +0x678 */ coreinit::OSFastMutexLink ownedFastMutex; + /* +0x680 */ MEMPTR<void> alignmentExceptionCallback[Espresso::CORE_COUNT]; - /* +0x680 */ uint32 padding680[28 / 4]; + /* +0x68C */ uint32 padding68C[20 / 4]; }; - -static_assert(sizeof(OSThread_t) == 0x6A0-4); // todo - determine correct size +static_assert(sizeof(OSThread_t) == 0x6A0); namespace coreinit { diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index 88bca8af..dd7c9189 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -117,10 +117,10 @@ void nsysnetExport_socket_lib_finish(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); // 0 -> Success } -uint32* __gh_errno_ptr() +static uint32be* __gh_errno_ptr() { OSThread_t* osThread = coreinit::OSGetCurrentThread(); - return &osThread->context.error; + return &osThread->context.ghs_errno; } void _setSockError(sint32 errCode) diff --git a/src/Cafe/OS/libs/snd_core/ax_ist.cpp b/src/Cafe/OS/libs/snd_core/ax_ist.cpp index 30cbdbb1..17f247e0 100644 --- a/src/Cafe/OS/libs/snd_core/ax_ist.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_ist.cpp @@ -963,7 +963,7 @@ namespace snd_core OSInitMessageQueue(__AXIstThreadMsgQueue.GetPtr(), __AXIstThreadMsgArray.GetPtr(), 0x10); // create thread uint8 istThreadAttr = 0; - coreinit::OSCreateThreadType(__AXIstThread.GetPtr(), PPCInterpreter_makeCallableExportDepr(AXIst_ThreadEntry), 0, &__AXIstThreadMsgQueue, __AXIstThreadStack.GetPtr() + 0x4000, 0x4000, 14, istThreadAttr, OSThread_t::THREAD_TYPE::TYPE_DRIVER); + coreinit::__OSCreateThreadType(__AXIstThread.GetPtr(), PPCInterpreter_makeCallableExportDepr(AXIst_ThreadEntry), 0, &__AXIstThreadMsgQueue, __AXIstThreadStack.GetPtr() + 0x4000, 0x4000, 14, istThreadAttr, OSThread_t::THREAD_TYPE::TYPE_DRIVER); coreinit::OSResumeThread(__AXIstThread.GetPtr()); } diff --git a/src/Common/ExceptionHandler/ExceptionHandler.cpp b/src/Common/ExceptionHandler/ExceptionHandler.cpp index 5fefc8ca..b6755fd8 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler.cpp @@ -155,7 +155,7 @@ void ExceptionHandler_LogGeneralInfo() const char* threadName = "NULL"; if (!threadItrBE->threadName.IsNull()) threadName = threadItrBE->threadName.GetPtr(); - sprintf(dumpLine, "%08x Ent %08x IP %08x LR %08x %-9s Aff %d%d%d Pri %2d Name %s", threadItrMPTR, _swapEndianU32(threadItrBE->entrypoint), threadItrBE->context.srr0, _swapEndianU32(threadItrBE->context.lr), threadStateStr, (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1, effectivePriority, threadName); + sprintf(dumpLine, "%08x Ent %08x IP %08x LR %08x %-9s Aff %d%d%d Pri %2d Name %s", threadItrMPTR, threadItrBE->entrypoint.GetMPTR(), threadItrBE->context.srr0, _swapEndianU32(threadItrBE->context.lr), threadStateStr, (affinity >> 0) & 1, (affinity >> 1) & 1, (affinity >> 2) & 1, effectivePriority, threadName); // write line to log CrashLog_WriteLine(dumpLine); } diff --git a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index bd71942f..dfbaf76e 100644 --- a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -195,10 +195,10 @@ void DebugPPCThreadsWindow::RefreshThreadList() m_thread_list->InsertItem(item); m_thread_list->SetItemData(item, (long)threadItrMPTR); // entry point - sprintf(tempStr, "%08X", _swapEndianU32(cafeThread->entrypoint)); + sprintf(tempStr, "%08X", cafeThread->entrypoint.GetMPTR()); m_thread_list->SetItem(i, 1, tempStr); // stack base (low) - sprintf(tempStr, "%08X - %08X", _swapEndianU32(cafeThread->stackEnd), _swapEndianU32(cafeThread->stackBase)); + sprintf(tempStr, "%08X - %08X", cafeThread->stackEnd.GetMPTR(), cafeThread->stackBase.GetMPTR()); m_thread_list->SetItem(i, 2, tempStr); // pc RPLStoredSymbol* symbol = rplSymbolStorage_getByAddress(cafeThread->context.srr0); From 91a010fbdd023b3cac85f455fb3c32de3d2c3784 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 4 May 2024 08:05:10 +0200 Subject: [PATCH 165/314] proc_ui: Fix crash due to incorrect version handling Resolves a crash in NEX Remix --- src/Cafe/OS/libs/proc_ui/proc_ui.cpp | 3 +++ src/Cafe/TitleList/TitleInfo.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp index 5560568d..dd9a460f 100644 --- a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp +++ b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp @@ -391,6 +391,9 @@ namespace proc_ui { cemuLog_log(LogType::Force, "ProcUI: Trying to register callback before init"); cemu_assert_suspicious(); + // this shouldn't happen but lets set the memory pointers anyway to prevent a crash in case the user has incorrect meta info + s_memAllocPtr = gCoreinitData->MEMAllocFromDefaultHeap.GetMPTR(); + s_memFreePtr = gCoreinitData->MEMFreeToDefaultHeap.GetMPTR(); } ProcUIInternalCallbackEntry* entry = (ProcUIInternalCallbackEntry*)_AllocMem(sizeof(ProcUIInternalCallbackEntry)); entry->funcPtr = funcPtr; diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index 6d21929e..2f295811 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -563,7 +563,7 @@ bool TitleInfo::ParseAppXml(std::vector<uint8>& appXmlData) else if (name == "group_id") m_parsedAppXml->group_id = (uint32)std::stoull(child.text().as_string(), nullptr, 16); else if (name == "sdk_version") - m_parsedAppXml->sdk_version = (uint32)std::stoull(child.text().as_string(), nullptr, 16); + m_parsedAppXml->sdk_version = (uint32)std::stoull(child.text().as_string(), nullptr, 10); } return true; } From 48d2a8371b3b35b2a4439e1475c694856728f4ec Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 01:27:39 +0200 Subject: [PATCH 166/314] sndcore: Write log message instead of asserting in AXSetDeviceRemixMatrix Fixes a crash in Watch Dogs due to the non-debug assert --- src/Cafe/OS/libs/snd_core/ax_ist.cpp | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Cafe/OS/libs/snd_core/ax_ist.cpp b/src/Cafe/OS/libs/snd_core/ax_ist.cpp index 17f247e0..2ea27cbb 100644 --- a/src/Cafe/OS/libs/snd_core/ax_ist.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_ist.cpp @@ -218,21 +218,36 @@ namespace snd_core // validate parameters if (deviceId == AX_DEV_TV) { - cemu_assert(inputChannelCount <= AX_TV_CHANNEL_COUNT); - cemu_assert(outputChannelCount == 1 || outputChannelCount == 2 || outputChannelCount == 6); + if(inputChannelCount > AX_TV_CHANNEL_COUNT) + { + cemuLog_log(LogType::APIErrors, "AXSetDeviceRemixMatrix: Input channel count must be smaller or equal to 6 for TV device"); + return -7; + } + if(outputChannelCount != 1 && outputChannelCount != 2 && outputChannelCount != 6) + { + // seems like Watch Dogs uses 4 as outputChannelCount for some reason? + cemuLog_log(LogType::APIErrors, "AXSetDeviceRemixMatrix: Output channel count must be 1, 2 or 6 for TV device"); + return -8; + } } else if (deviceId == AX_DEV_DRC) { - cemu_assert(inputChannelCount <= AX_DRC_CHANNEL_COUNT); - cemu_assert(outputChannelCount == 1 || outputChannelCount == 2 || outputChannelCount == 4); - } - else if (deviceId == AX_DEV_RMT) - { - cemu_assert(false); + if(inputChannelCount > AX_DRC_CHANNEL_COUNT) + { + cemuLog_log(LogType::APIErrors, "AXSetDeviceRemixMatrix: Input channel count must be smaller or equal to 4 for DRC device"); + return -7; + } + if(outputChannelCount != 1 && outputChannelCount != 2 && outputChannelCount != 4) + { + cemuLog_log(LogType::APIErrors, "AXSetDeviceRemixMatrix: Output channel count must be 1, 2 or 4 for DRC device"); + return -8; + } } else + { + cemuLog_log(LogType::APIErrors, "AXSetDeviceRemixMatrix: Only TV (0) and DRC (1) device are supported"); return -1; - + } auto matrices = g_remix_matrices.GetPtr(); // test if we already have an entry and just need to update the matrix data From a744670486cf27e14dd884d3a1b2ee04dc05a8cb Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 01:28:08 +0200 Subject: [PATCH 167/314] coreinit: Add export for OSGetForegroundBucketFreeArea --- src/Cafe/OS/libs/coreinit/coreinit_FG.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp b/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp index b751a8fd..e22c3eb3 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_FG.cpp @@ -185,6 +185,7 @@ namespace coreinit { osLib_addFunction("coreinit", "OSGetForegroundBucket", coreinitExport_OSGetForegroundBucket); cafeExportRegister("coreinit", OSGetForegroundBucket, LogType::CoreinitMem); + cafeExportRegister("coreinit", OSGetForegroundBucketFreeArea, LogType::CoreinitMem); osLib_addFunction("coreinit", "OSCopyFromClipboard", coreinitExport_OSCopyFromClipboard); } } From f28043e0e969f5ff5e8ad1e5eea8964ebf6f2523 Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Sat, 4 May 2024 16:34:36 -0700 Subject: [PATCH 168/314] Linux/Mac Auto-Updater (#1145) --- .github/workflows/build.yml | 20 ++++++------ src/CMakeLists.txt | 1 + src/gui/CemuUpdateWindow.cpp | 56 +++++++++++++++++++++++++++----- src/gui/GeneralSettings2.cpp | 10 +++--- src/gui/GettingStartedDialog.cpp | 7 ++-- src/gui/MainWindow.cpp | 8 +++-- src/resource/update.sh | 8 +++++ 7 files changed, 82 insertions(+), 28 deletions(-) create mode 100755 src/resource/update.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58a8508d..d188b4a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: "Checkout repo" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "recursive" fetch-depth: 0 @@ -91,7 +91,7 @@ jobs: run: mv bin/Cemu_release bin/Cemu - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-linux-x64 @@ -102,9 +102,9 @@ jobs: needs: build-ubuntu steps: - name: Checkout Upstream Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-linux-x64 path: bin @@ -121,7 +121,7 @@ jobs: dist/linux/appimage.sh - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: cemu-appimage-x64 path: artifacts @@ -130,7 +130,7 @@ jobs: runs-on: windows-2022 steps: - name: "Checkout repo" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "recursive" @@ -200,7 +200,7 @@ jobs: run: Rename-Item bin/Cemu_release.exe Cemu.exe - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-windows-x64 @@ -210,7 +210,7 @@ jobs: runs-on: macos-12 steps: - name: "Checkout repo" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: "recursive" @@ -289,14 +289,14 @@ jobs: mv bin/Cemu_release.app bin/Cemu_app/Cemu.app mv bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu_release bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu sed -i '' 's/Cemu_release/Cemu/g' bin/Cemu_app/Cemu.app/Contents/Info.plist - chmod a+x bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu + chmod a+x bin/Cemu_app/Cemu.app/Contents/MacOS/{Cemu,update.sh} ln -s /Applications bin/Cemu_app/Applications hdiutil create ./bin/tmp.dmg -ov -volname "Cemu" -fs HFS+ -srcfolder "./bin/Cemu_app" hdiutil convert ./bin/tmp.dmg -format UDZO -o bin/Cemu.dmg rm bin/tmp.dmg - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-macos-x64 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7442e37c..1b78b1fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,6 +98,7 @@ if (MACOS_BUNDLE) add_custom_command (TARGET CemuBin POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib" COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh" COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}" COMMAND bash -c "install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() diff --git a/src/gui/CemuUpdateWindow.cpp b/src/gui/CemuUpdateWindow.cpp index 91394ee2..445c7c17 100644 --- a/src/gui/CemuUpdateWindow.cpp +++ b/src/gui/CemuUpdateWindow.cpp @@ -12,6 +12,11 @@ #include <wx/msgdlg.h> #include <wx/stdpaths.h> +#ifndef BOOST_OS_WINDOWS +#include <unistd.h> +#include <sys/stat.h> +#endif + #include <curl/curl.h> #include <zip.h> #include <boost/tokenizer.hpp> @@ -105,11 +110,11 @@ bool CemuUpdateWindow::QueryUpdateInfo(std::string& downloadUrlOut, std::string& auto* curl = curl_easy_init(); urlStr.append(_curlUrlEscape(curl, BUILD_VERSION_STRING)); #if BOOST_OS_LINUX - urlStr.append("&platform=linux"); + urlStr.append("&platform=linux_appimage_x86"); #elif BOOST_OS_WINDOWS urlStr.append("&platform=windows"); #elif BOOST_OS_MACOS - urlStr.append("&platform=macos_x86"); + urlStr.append("&platform=macos_bundle_x86"); #elif #error Name for current platform is missing @@ -407,7 +412,13 @@ void CemuUpdateWindow::WorkerThread() if (!exists(tmppath)) create_directory(tmppath); +#if BOOST_OS_WINDOWS const auto update_file = tmppath / L"update.zip"; +#elif BOOST_OS_LINUX + const auto update_file = tmppath / L"Cemu.AppImage"; +#elif BOOST_OS_MACOS + const auto update_file = tmppath / L"cemu.dmg"; +#endif if (DownloadCemuZip(url, update_file)) { auto* event = new wxCommandEvent(wxEVT_RESULT); @@ -427,6 +438,7 @@ void CemuUpdateWindow::WorkerThread() // extract std::string cemuFolderName; +#if BOOST_OS_WINDOWS if (!ExtractUpdate(update_file, tmppath, cemuFolderName)) { cemuLog_log(LogType::Force, "Extracting Cemu zip failed"); @@ -437,7 +449,7 @@ void CemuUpdateWindow::WorkerThread() cemuLog_log(LogType::Force, "Cemu folder not found in zip"); break; } - +#endif const auto expected_path = tmppath / cemuFolderName; if (exists(expected_path)) { @@ -472,6 +484,7 @@ void CemuUpdateWindow::WorkerThread() // apply update fs::path exePath = ActiveSettings::GetExecutablePath(); +#if BOOST_OS_WINDOWS std::wstring target_directory = exePath.parent_path().generic_wstring(); if (target_directory[target_directory.size() - 1] == '/') target_directory = target_directory.substr(0, target_directory.size() - 1); // remove trailing / @@ -480,8 +493,19 @@ void CemuUpdateWindow::WorkerThread() const auto exec = ActiveSettings::GetExecutablePath(); const auto target_exe = fs::path(exec).replace_extension("exe.backup"); fs::rename(exec, target_exe); - m_restartFile = exec; - + m_restartFile = exec; +#elif BOOST_OS_LINUX + const char* appimage_path = std::getenv("APPIMAGE"); + const auto target_exe = fs::path(appimage_path).replace_extension("AppImage.backup"); + const char* filePath = update_file.c_str(); + mode_t permissions = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + fs::rename(appimage_path, target_exe); + m_restartFile = appimage_path; + chmod(filePath, permissions); + wxString wxAppPath = wxString::FromUTF8(appimage_path); + wxCopyFile (wxT("/tmp/cemu_update/Cemu.AppImage"), wxAppPath); +#endif +#if BOOST_OS_WINDOWS const auto index = expected_path.wstring().size(); int counter = 0; for (const auto& it : fs::recursive_directory_iterator(expected_path)) @@ -516,7 +540,7 @@ void CemuUpdateWindow::WorkerThread() wxQueueEvent(this, event); } } - +#endif auto* event = new wxCommandEvent(wxEVT_PROGRESS); event->SetInt(m_gaugeMaxValue); wxQueueEvent(this, event); @@ -565,8 +589,24 @@ void CemuUpdateWindow::OnClose(wxCloseEvent& event) exit(0); } -#else - cemuLog_log(LogType::Force, "unimplemented - restart on update"); +#elif BOOST_OS_LINUX + if (m_restartRequired && !m_restartFile.empty() && fs::exists(m_restartFile)) + { + const char* appimage_path = std::getenv("APPIMAGE"); + execlp(appimage_path, appimage_path, (char *)NULL); + + exit(0); + } +#elif BOOST_OS_MACOS + if (m_restartRequired) + { + const auto tmppath = fs::temp_directory_path() / L"cemu_update/Cemu.dmg"; + fs::path exePath = ActiveSettings::GetExecutablePath().parent_path(); + const auto apppath = exePath / L"update.sh"; + execlp("sh", "sh", apppath.c_str(), NULL); + + exit(0); + } #endif } diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 27ce37fa..dab30981 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -166,9 +166,11 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) m_auto_update = new wxCheckBox(box, wxID_ANY, _("Automatically check for updates")); m_auto_update->SetToolTip(_("Automatically checks for new cemu versions on startup")); second_row->Add(m_auto_update, 0, botflag, 5); -#if BOOST_OS_LINUX || BOOST_OS_MACOS - m_auto_update->Disable(); -#endif +#if BOOST_OS_LINUX + if (!std::getenv("APPIMAGE")) { + m_auto_update->Disable(); + } +#endif second_row->AddSpacer(10); m_save_screenshot = new wxCheckBox(box, wxID_ANY, _("Save screenshot")); m_save_screenshot->SetToolTip(_("Pressing the screenshot key (F12) will save a screenshot directly to the screenshots folder")); @@ -2055,4 +2057,4 @@ wxString GeneralSettings2::GetOnlineAccountErrorMessage(OnlineAccountError error default: return "no error"; } -} \ No newline at end of file +} diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index 91cc3a11..bfd206b1 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -146,10 +146,11 @@ wxPanel* GettingStartedDialog::CreatePage2() m_update = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Automatically check for updates")); option_sizer->Add(m_update, 0, wxALL, 5); -#if BOOST_OS_LINUX || BOOST_OS_MACOS - m_update->Disable(); +#if BOOST_OS_LINUX + if (!std::getenv("APPIMAGE")) { + m_update->Disable(); + } #endif - sizer->Add(option_sizer, 1, wxEXPAND, 5); page2_sizer->Add(sizer, 0, wxALL | wxEXPAND, 5); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index da57870c..e8103f9a 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2292,9 +2292,11 @@ void MainWindow::RecreateMenu() // help menu wxMenu* helpMenu = new wxMenu(); m_check_update_menu = helpMenu->Append(MAINFRAME_MENU_ID_HELP_UPDATE, _("&Check for updates")); -#if BOOST_OS_LINUX || BOOST_OS_MACOS - m_check_update_menu->Enable(false); -#endif +#if BOOST_OS_LINUX + if (!std::getenv("APPIMAGE")) { + m_check_update_menu->Enable(false); + } +#endif helpMenu->Append(MAINFRAME_MENU_ID_HELP_GETTING_STARTED, _("&Getting started")); helpMenu->AppendSeparator(); helpMenu->Append(MAINFRAME_MENU_ID_HELP_ABOUT, _("&About Cemu")); diff --git a/src/resource/update.sh b/src/resource/update.sh new file mode 100755 index 00000000..5ff22160 --- /dev/null +++ b/src/resource/update.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +APP=$(cd "$(dirname "0")"/;pwd) +hdiutil attach $TMPDIR/cemu_update/cemu.dmg +cp -rf /Volumes/Cemu/Cemu.app "$APP" +hdiutil detach /Volumes/Cemu/ + +open -n -a "$APP/Cemu.app" From dc480ac00bc6367f9272c490fbf2a7e4cacee218 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sun, 5 May 2024 02:35:01 +0200 Subject: [PATCH 169/314] Add support for WUHB file format (#1190) --- src/Cafe/CMakeLists.txt | 4 + src/Cafe/Filesystem/WUHB/RomFSStructs.h | 40 ++++ src/Cafe/Filesystem/WUHB/WUHBReader.cpp | 224 ++++++++++++++++++++++ src/Cafe/Filesystem/WUHB/WUHBReader.h | 45 +++++ src/Cafe/Filesystem/fsc.h | 3 + src/Cafe/Filesystem/fscDeviceWuhb.cpp | 151 +++++++++++++++ src/Cafe/TitleList/TitleInfo.cpp | 82 ++++++++ src/Cafe/TitleList/TitleInfo.h | 3 + src/Cafe/TitleList/TitleList.cpp | 3 +- src/gui/MainWindow.cpp | 6 +- src/gui/components/wxGameList.cpp | 10 + src/gui/components/wxTitleManagerList.cpp | 5 + src/gui/components/wxTitleManagerList.h | 1 + src/util/helpers/helpers.cpp | 41 ++++ src/util/helpers/helpers.h | 2 + 15 files changed, 617 insertions(+), 3 deletions(-) create mode 100644 src/Cafe/Filesystem/WUHB/RomFSStructs.h create mode 100644 src/Cafe/Filesystem/WUHB/WUHBReader.cpp create mode 100644 src/Cafe/Filesystem/WUHB/WUHBReader.h create mode 100644 src/Cafe/Filesystem/fscDeviceWuhb.cpp diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index d64a5998..851854fc 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -10,6 +10,7 @@ add_library(CemuCafe Filesystem/fscDeviceRedirect.cpp Filesystem/fscDeviceWua.cpp Filesystem/fscDeviceWud.cpp + Filesystem/fscDeviceWuhb.cpp Filesystem/fsc.h Filesystem/FST/FST.cpp Filesystem/FST/FST.h @@ -18,6 +19,9 @@ add_library(CemuCafe Filesystem/FST/KeyCache.h Filesystem/WUD/wud.cpp Filesystem/WUD/wud.h + Filesystem/WUHB/RomFSStructs.h + Filesystem/WUHB/WUHBReader.cpp + Filesystem/WUHB/WUHBReader.h GamePatch.cpp GamePatch.h GameProfile/GameProfile.cpp diff --git a/src/Cafe/Filesystem/WUHB/RomFSStructs.h b/src/Cafe/Filesystem/WUHB/RomFSStructs.h new file mode 100644 index 00000000..59ef503f --- /dev/null +++ b/src/Cafe/Filesystem/WUHB/RomFSStructs.h @@ -0,0 +1,40 @@ +#pragma once + +struct romfs_header_t +{ + uint32 header_magic; + uint32be header_size; + uint64be dir_hash_table_ofs; + uint64be dir_hash_table_size; + uint64be dir_table_ofs; + uint64be dir_table_size; + uint64be file_hash_table_ofs; + uint64be file_hash_table_size; + uint64be file_table_ofs; + uint64be file_table_size; + uint64be file_partition_ofs; +}; + +struct romfs_direntry_t +{ + uint32be parent; + uint32be listNext; // offset to next directory entry in linked list of parent directory (aka "sibling") + uint32be dirListHead; // offset to first entry in linked list of directory entries (aka "child") + uint32be fileListHead; // offset to first entry in linked list of file entries (aka "file") + uint32be hash; + uint32be name_size; + std::string name; +}; + +struct romfs_fentry_t +{ + uint32be parent; + uint32be listNext; // offset to next file entry in linked list of parent directory (aka "sibling") + uint64be offset; + uint64be size; + uint32be hash; + uint32be name_size; + std::string name; +}; + +#define ROMFS_ENTRY_EMPTY 0xFFFFFFFF diff --git a/src/Cafe/Filesystem/WUHB/WUHBReader.cpp b/src/Cafe/Filesystem/WUHB/WUHBReader.cpp new file mode 100644 index 00000000..e7a4c9be --- /dev/null +++ b/src/Cafe/Filesystem/WUHB/WUHBReader.cpp @@ -0,0 +1,224 @@ +#include "WUHBReader.h" +WUHBReader* WUHBReader::FromPath(const fs::path& path) +{ + FileStream* fileIn{FileStream::openFile2(path)}; + if (!fileIn) + return nullptr; + + WUHBReader* ret = new WUHBReader(fileIn); + if (!ret->CheckMagicValue()) + { + delete ret; + return nullptr; + } + + if (!ret->ReadHeader()) + { + delete ret; + return nullptr; + } + + return ret; +} + +static const romfs_direntry_t fallbackDirEntry{ + .parent = ROMFS_ENTRY_EMPTY, + .listNext = ROMFS_ENTRY_EMPTY, + .dirListHead = ROMFS_ENTRY_EMPTY, + .fileListHead = ROMFS_ENTRY_EMPTY, + .hash = ROMFS_ENTRY_EMPTY, + .name_size = 0, + .name = "" +}; +static const romfs_fentry_t fallbackFileEntry{ + .parent = ROMFS_ENTRY_EMPTY, + .listNext = ROMFS_ENTRY_EMPTY, + .offset = 0, + .size = 0, + .hash = ROMFS_ENTRY_EMPTY, + .name_size = 0, + .name = "" +}; +template<bool File> +const WUHBReader::EntryType<File>& WUHBReader::GetFallback() +{ + if constexpr (File) + return fallbackFileEntry; + else + return fallbackDirEntry; +} + +template<bool File> +WUHBReader::EntryType<File> WUHBReader::GetEntry(uint32 offset) const +{ + auto fallback = GetFallback<File>(); + if(offset == ROMFS_ENTRY_EMPTY) + return fallback; + + const char* typeName = File ? "fentry" : "direntry"; + EntryType<File> ret; + if (offset >= (File ? m_header.file_table_size : m_header.dir_table_size)) + { + cemuLog_log(LogType::Force, "WUHB {} offset exceeds table size declared in header", typeName); + return fallback; + } + + // read the entry + m_fileIn->SetPosition((File ? m_header.file_table_ofs : m_header.dir_table_ofs) + offset); + auto read = m_fileIn->readData(&ret, offsetof(EntryType<File>, name)); + if (read != offsetof(EntryType<File>, name)) + { + cemuLog_log(LogType::Force, "failed to read WUHB {} at offset: {}", typeName, offset); + return fallback; + } + + // read the name + ret.name.resize(ret.name_size); + read = m_fileIn->readData(ret.name.data(), ret.name_size); + if (read != ret.name_size) + { + cemuLog_log(LogType::Force, "failed to read WUHB {} name", typeName); + return fallback; + } + + return ret; +} + +romfs_direntry_t WUHBReader::GetDirEntry(uint32 offset) const +{ + return GetEntry<false>(offset); +} +romfs_fentry_t WUHBReader::GetFileEntry(uint32 offset) const +{ + return GetEntry<true>(offset); +} + +uint64 WUHBReader::GetFileSize(uint32 entryOffset) const +{ + return GetFileEntry(entryOffset).size; +} + +uint64 WUHBReader::ReadFromFile(uint32 entryOffset, uint64 fileOffset, uint64 length, void* buffer) const +{ + const auto fileEntry = GetFileEntry(entryOffset); + if (fileOffset >= fileEntry.size) + return 0; + const uint64 readAmount = std::min(length, fileEntry.size - fileOffset); + const uint64 wuhbOffset = m_header.file_partition_ofs + fileEntry.offset + fileOffset; + m_fileIn->SetPosition(wuhbOffset); + return m_fileIn->readData(buffer, readAmount); +} + +uint32 WUHBReader::GetHashTableEntryOffset(uint32 hash, bool isFile) const +{ + const uint64 hash_table_size = (isFile ? m_header.file_hash_table_size : m_header.dir_hash_table_size); + const uint64 hash_table_ofs = (isFile ? m_header.file_hash_table_ofs : m_header.dir_hash_table_ofs); + + const uint64 hash_table_entry_count = hash_table_size / sizeof(uint32); + const uint64 hash_table_entry_offset = hash_table_ofs + (hash % hash_table_entry_count) * sizeof(uint32); + + m_fileIn->SetPosition(hash_table_entry_offset); + uint32 tableOffset; + if (!m_fileIn->readU32(tableOffset)) + { + cemuLog_log(LogType::Force, "failed to read WUHB hash table entry at file offset: {}", hash_table_entry_offset); + return ROMFS_ENTRY_EMPTY; + } + + return uint32be::from_bevalue(tableOffset); +} + +template<bool T> +bool WUHBReader::SearchHashList(uint32& entryOffset, const fs::path& targetName) const +{ + for (;;) + { + if (entryOffset == ROMFS_ENTRY_EMPTY) + return false; + auto entry = GetEntry<T>(entryOffset); + + if (entry.name == targetName) + return true; + entryOffset = entry.hash; + } + return false; +} + +uint32 WUHBReader::Lookup(const std::filesystem::path& path, bool isFile) const +{ + uint32 currentEntryOffset = 0; + auto look = [&](const fs::path& part, bool lookInFileHT) { + const auto partString = part.string(); + currentEntryOffset = GetHashTableEntryOffset(CalcPathHash(currentEntryOffset, partString.c_str(), 0, partString.size()), lookInFileHT); + if (lookInFileHT) + return SearchHashList<true>(currentEntryOffset, part); + else + return SearchHashList<false>(currentEntryOffset, part); + }; + // look for the root entry + if (!look("", false)) + return ROMFS_ENTRY_EMPTY; + + auto it = path.begin(); + while (it != path.end()) + { + fs::path part = *it; + ++it; + // no need to recurse after trailing forward slash (e.g. directory/) + if (part.empty() && !isFile) + break; + // skip leading forward slash + if (part == "/") + continue; + + // if the lookup target is a file and this is the last iteration, look in the file hash table instead. + if (!look(part, it == path.end() && isFile)) + return ROMFS_ENTRY_EMPTY; + } + return currentEntryOffset; +} +bool WUHBReader::CheckMagicValue() const +{ + uint8 magic[4]; + m_fileIn->SetPosition(0); + int read = m_fileIn->readData(magic, 4); + if (read != 4) + { + cemuLog_log(LogType::Force, "Failed to read WUHB magic numbers"); + return false; + } + static_assert(sizeof(magic) == s_headerMagicValue.size()); + return std::memcmp(&magic, s_headerMagicValue.data(), sizeof(magic)) == 0; +} +bool WUHBReader::ReadHeader() +{ + m_fileIn->SetPosition(0); + auto read = m_fileIn->readData(&m_header, sizeof(m_header)); + auto readSuccess = read == sizeof(m_header); + if (!readSuccess) + cemuLog_log(LogType::Force, "Failed to read WUHB header"); + return readSuccess; +} +unsigned char WUHBReader::NormalizeChar(unsigned char c) +{ + if (c >= 'a' && c <= 'z') + { + return c + 'A' - 'a'; + } + else + { + return c; + } +} +uint32 WUHBReader::CalcPathHash(uint32 parent, const char* path, uint32 start, size_t path_len) +{ + cemu_assert(path != nullptr || path_len == 0); + uint32 hash = parent ^ 123456789; + for (uint32 i = 0; i < path_len; i++) + { + hash = (hash >> 5) | (hash << 27); + hash ^= NormalizeChar(path[start + i]); + } + + return hash; +} diff --git a/src/Cafe/Filesystem/WUHB/WUHBReader.h b/src/Cafe/Filesystem/WUHB/WUHBReader.h new file mode 100644 index 00000000..9187f05a --- /dev/null +++ b/src/Cafe/Filesystem/WUHB/WUHBReader.h @@ -0,0 +1,45 @@ +#pragma once +#include <Common/FileStream.h> +#include "RomFSStructs.h" +class WUHBReader +{ + public: + static WUHBReader* FromPath(const fs::path& path); + + romfs_direntry_t GetDirEntry(uint32 offset) const; + romfs_fentry_t GetFileEntry(uint32 offset) const; + + uint64 GetFileSize(uint32 entryOffset) const; + + uint64 ReadFromFile(uint32 entryOffset, uint64 fileOffset, uint64 length, void* buffer) const; + + uint32 Lookup(const std::filesystem::path& path, bool isFile) const; + + private: + WUHBReader(FileStream* file) + : m_fileIn(file) + { + cemu_assert_debug(file != nullptr); + }; + WUHBReader() = delete; + + romfs_header_t m_header; + std::unique_ptr<FileStream> m_fileIn; + constexpr static std::string_view s_headerMagicValue = "WUHB"; + bool ReadHeader(); + bool CheckMagicValue() const; + + static inline unsigned char NormalizeChar(unsigned char c); + static uint32 CalcPathHash(uint32 parent, const char* path, uint32 start, size_t path_len); + + template<bool File> + using EntryType = std::conditional_t<File, romfs_fentry_t, romfs_direntry_t>; + template<bool File> + static const EntryType<File>& GetFallback(); + template<bool File> + EntryType<File> GetEntry(uint32 offset) const; + + template<bool T> + bool SearchHashList(uint32& entryOffset, const fs::path& targetName) const; + uint32 GetHashTableEntryOffset(uint32 hash, bool isFile) const; +}; diff --git a/src/Cafe/Filesystem/fsc.h b/src/Cafe/Filesystem/fsc.h index 09c1f508..a3df2af2 100644 --- a/src/Cafe/Filesystem/fsc.h +++ b/src/Cafe/Filesystem/fsc.h @@ -204,6 +204,9 @@ bool FSCDeviceWUD_Mount(std::string_view mountPath, std::string_view destination // wua device bool FSCDeviceWUA_Mount(std::string_view mountPath, std::string_view destinationBaseDir, class ZArchiveReader* archive, sint32 priority); +// wuhb device +bool FSCDeviceWUHB_Mount(std::string_view mountPath, std::string_view destinationBaseDir, class WUHBReader* wuhbReader, sint32 priority); + // hostFS device bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority); diff --git a/src/Cafe/Filesystem/fscDeviceWuhb.cpp b/src/Cafe/Filesystem/fscDeviceWuhb.cpp new file mode 100644 index 00000000..5e8e6484 --- /dev/null +++ b/src/Cafe/Filesystem/fscDeviceWuhb.cpp @@ -0,0 +1,151 @@ +#include "Filesystem/WUHB/WUHBReader.h" +#include "Cafe/Filesystem/fsc.h" +#include "Cafe/Filesystem/FST/FST.h" + +class FSCDeviceWuhbFileCtx : public FSCVirtualFile +{ + public: + FSCDeviceWuhbFileCtx(WUHBReader* reader, uint32 entryOffset, uint32 fscType) + : m_wuhbReader(reader), m_entryOffset(entryOffset), m_fscType(fscType) + { + cemu_assert(entryOffset != ROMFS_ENTRY_EMPTY); + if (fscType == FSC_TYPE_DIRECTORY) + { + romfs_direntry_t entry = reader->GetDirEntry(entryOffset); + m_dirIterOffset = entry.dirListHead; + m_fileIterOffset = entry.fileListHead; + } + } + sint32 fscGetType() override + { + return m_fscType; + } + uint64 fscQueryValueU64(uint32 id) override + { + if (m_fscType == FSC_TYPE_FILE) + { + if (id == FSC_QUERY_SIZE) + return m_wuhbReader->GetFileSize(m_entryOffset); + else if (id == FSC_QUERY_WRITEABLE) + return 0; // WUHB images are read-only + else + cemu_assert_error(); + } + else + { + cemu_assert_unimplemented(); + } + return 0; + } + uint32 fscWriteData(void* buffer, uint32 size) override + { + cemu_assert_error(); + return 0; + } + uint32 fscReadData(void* buffer, uint32 size) override + { + if (m_fscType != FSC_TYPE_FILE) + return 0; + auto read = m_wuhbReader->ReadFromFile(m_entryOffset, m_seek, size, buffer); + m_seek += read; + return read; + } + void fscSetSeek(uint64 seek) override + { + m_seek = seek; + } + uint64 fscGetSeek() override + { + if (m_fscType != FSC_TYPE_FILE) + return 0; + return m_seek; + } + void fscSetFileLength(uint64 endOffset) override + { + cemu_assert_error(); + } + bool fscDirNext(FSCDirEntry* dirEntry) override + { + if (m_dirIterOffset != ROMFS_ENTRY_EMPTY) + { + romfs_direntry_t entry = m_wuhbReader->GetDirEntry(m_dirIterOffset); + m_dirIterOffset = entry.listNext; + if(entry.name_size > 0) + { + dirEntry->isDirectory = true; + dirEntry->isFile = false; + dirEntry->fileSize = 0; + std::strncpy(dirEntry->path, entry.name.c_str(), FSC_MAX_DIR_NAME_LENGTH); + return true; + } + } + if (m_fileIterOffset != ROMFS_ENTRY_EMPTY) + { + romfs_fentry_t entry = m_wuhbReader->GetFileEntry(m_fileIterOffset); + m_fileIterOffset = entry.listNext; + if(entry.name_size > 0) + { + dirEntry->isDirectory = false; + dirEntry->isFile = true; + dirEntry->fileSize = entry.size; + std::strncpy(dirEntry->path, entry.name.c_str(), FSC_MAX_DIR_NAME_LENGTH); + return true; + } + } + + return false; + } + + private: + WUHBReader* m_wuhbReader{}; + uint32 m_fscType; + uint32 m_entryOffset = ROMFS_ENTRY_EMPTY; + uint32 m_dirIterOffset = ROMFS_ENTRY_EMPTY; + uint32 m_fileIterOffset = ROMFS_ENTRY_EMPTY; + uint64 m_seek = 0; +}; + +class fscDeviceWUHB : public fscDeviceC +{ + FSCVirtualFile* fscDeviceOpenByPath(std::string_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override + { + WUHBReader* reader = (WUHBReader*)ctx; + cemu_assert_debug(!HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::WRITE_PERMISSION)); // writing to WUHB is not supported + + bool isFile; + uint32 table_offset = ROMFS_ENTRY_EMPTY; + + if (table_offset == ROMFS_ENTRY_EMPTY && HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR)) + { + table_offset = reader->Lookup(path, false); + isFile = false; + } + if (table_offset == ROMFS_ENTRY_EMPTY && HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE)) + { + table_offset = reader->Lookup(path, true); + isFile = true; + } + + if (table_offset == ROMFS_ENTRY_EMPTY) + { + *fscStatus = FSC_STATUS_FILE_NOT_FOUND; + return nullptr; + } + + *fscStatus = FSC_STATUS_OK; + return new FSCDeviceWuhbFileCtx(reader, table_offset, isFile ? FSC_TYPE_FILE : FSC_TYPE_DIRECTORY); + } + + // singleton + public: + static fscDeviceWUHB& instance() + { + static fscDeviceWUHB _instance; + return _instance; + } +}; + +bool FSCDeviceWUHB_Mount(std::string_view mountPath, std::string_view destinationBaseDir, WUHBReader* wuhbReader, sint32 priority) +{ + return fsc_mount(mountPath, destinationBaseDir, &fscDeviceWUHB::instance(), wuhbReader, priority) == FSC_STATUS_OK; +} diff --git a/src/Cafe/TitleList/TitleInfo.cpp b/src/Cafe/TitleList/TitleInfo.cpp index 2f295811..12131058 100644 --- a/src/Cafe/TitleList/TitleInfo.cpp +++ b/src/Cafe/TitleList/TitleInfo.cpp @@ -1,9 +1,12 @@ #include "TitleInfo.h" #include "Cafe/Filesystem/fscDeviceHostFS.h" +#include "Cafe/Filesystem/WUHB/WUHBReader.h" #include "Cafe/Filesystem/FST/FST.h" #include "pugixml.hpp" #include "Common/FileStream.h" #include <zarchive/zarchivereader.h> +#include "util/IniParser/IniParser.h" +#include "util/crypto/crc32.h" #include "config/ActiveSettings.h" #include "util/helpers/helpers.h" @@ -97,6 +100,7 @@ TitleInfo::TitleInfo(const TitleInfo::CachedInfo& cachedInfo) m_isValid = false; if (cachedInfo.titleDataFormat != TitleDataFormat::HOST_FS && cachedInfo.titleDataFormat != TitleDataFormat::WIIU_ARCHIVE && + cachedInfo.titleDataFormat != TitleDataFormat::WUHB && cachedInfo.titleDataFormat != TitleDataFormat::WUD && cachedInfo.titleDataFormat != TitleDataFormat::NUS && cachedInfo.titleDataFormat != TitleDataFormat::INVALID_STRUCTURE) @@ -245,6 +249,16 @@ bool TitleInfo::DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataF delete zar; return foundBase; } + else if (boost::iends_with(filenameStr, ".wuhb")) + { + std::unique_ptr<WUHBReader> reader{WUHBReader::FromPath(path)}; + if(reader) + { + formatOut = TitleDataFormat::WUHB; + pathOut = path; + return true; + } + } // note: Since a Wii U archive file (.wua) contains multiple titles we shouldn't auto-detect them here // instead TitleInfo has a second constructor which takes a subpath // unable to determine type by extension, check contents @@ -436,6 +450,23 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder, return false; } } + else if (m_titleFormat == TitleDataFormat::WUHB) + { + if (!m_wuhbreader) + { + m_wuhbreader = WUHBReader::FromPath(m_fullPath); + if (!m_wuhbreader) + return false; + } + bool r = FSCDeviceWUHB_Mount(virtualPath, subfolder, m_wuhbreader, mountPriority); + if (!r) + { + cemuLog_log(LogType::Force, "Failed to mount {} to {}", virtualPath, subfolder); + delete m_wuhbreader; + m_wuhbreader = nullptr; + return false; + } + } else { cemu_assert_unimplemented(); @@ -467,6 +498,12 @@ void TitleInfo::Unmount(std::string_view virtualPath) if (m_mountpoints.empty()) m_zarchive = nullptr; } + if (m_wuhbreader) + { + cemu_assert_debug(m_titleFormat == TitleDataFormat::WUHB); + delete m_wuhbreader; + m_wuhbreader = nullptr; + } } return; } @@ -502,6 +539,20 @@ bool TitleInfo::ParseXmlInfo() auto xmlData = fsc_extractFile(fmt::format("{}meta/meta.xml", mountPath).c_str()); if(xmlData) m_parsedMetaXml = ParsedMetaXml::Parse(xmlData->data(), xmlData->size()); + + if(!m_parsedMetaXml) + { + // meta/meta.ini (WUHB) + auto iniData = fsc_extractFile(fmt::format("{}meta/meta.ini", mountPath).c_str()); + if (iniData) + m_parsedMetaXml = ParseAromaIni(*iniData); + if(m_parsedMetaXml) + { + m_parsedCosXml = new ParsedCosXml{.argstr = "root.rpx"}; + m_parsedAppXml = new ParsedAppXml{m_parsedMetaXml->m_title_id, 0, 0, 0, 0}; + } + } + // code/app.xml xmlData = fsc_extractFile(fmt::format("{}code/app.xml", mountPath).c_str()); if(xmlData) @@ -539,6 +590,34 @@ bool TitleInfo::ParseXmlInfo() return true; } +ParsedMetaXml* TitleInfo::ParseAromaIni(std::span<unsigned char> content) +{ + IniParser parser{content}; + while (parser.NextSection() && parser.GetCurrentSectionName() != "menu") + continue; + if (parser.GetCurrentSectionName() != "menu") + return nullptr; + + auto parsed = std::make_unique<ParsedMetaXml>(); + + const auto author = parser.FindOption("author"); + if (author) + parsed->m_publisher[(size_t)CafeConsoleLanguage::EN] = *author; + + const auto longName = parser.FindOption("longname"); + if (longName) + parsed->m_long_name[(size_t)CafeConsoleLanguage::EN] = *longName; + + const auto shortName = parser.FindOption("shortname"); + if (shortName) + parsed->m_short_name[(size_t)CafeConsoleLanguage::EN] = *shortName; + + auto checksumInput = std::string{*author}.append(*longName).append(*shortName); + parsed->m_title_id = (0x0005000Full<<32) | crc32_calc(checksumInput.data(), checksumInput.length()); + + return parsed.release(); +} + bool TitleInfo::ParseAppXml(std::vector<uint8>& appXmlData) { pugi::xml_document app_doc; @@ -695,6 +774,9 @@ std::string TitleInfo::GetPrintPath() const case TitleDataFormat::WIIU_ARCHIVE: tmp.append(" [WUA]"); break; + case TitleDataFormat::WUHB: + tmp.append(" [WUHB]"); + break; default: break; } diff --git a/src/Cafe/TitleList/TitleInfo.h b/src/Cafe/TitleList/TitleInfo.h index e9347db7..fa5b9c89 100644 --- a/src/Cafe/TitleList/TitleInfo.h +++ b/src/Cafe/TitleList/TitleInfo.h @@ -127,6 +127,7 @@ public: WUD = 2, // WUD or WUX WIIU_ARCHIVE = 3, // Wii U compressed single-file archive (.wua) NUS = 4, // NUS format. Directory with .app files, title.tik and title.tmd + WUHB = 5, // error INVALID_STRUCTURE = 0, }; @@ -265,6 +266,7 @@ private: bool DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataFormat& formatOut); void CalcUID(); void SetInvalidReason(InvalidReason reason); + ParsedMetaXml* ParseAromaIni(std::span<unsigned char> content); bool ParseAppXml(std::vector<uint8>& appXmlData); bool m_isValid{ false }; @@ -277,6 +279,7 @@ private: std::vector<std::pair<sint32, std::string>> m_mountpoints; class FSTVolume* m_wudVolume{}; class ZArchiveReader* m_zarchive{}; + class WUHBReader* m_wuhbreader{}; // xml info bool m_hasParsedXmlFiles{ false }; ParsedMetaXml* m_parsedMetaXml{}; diff --git a/src/Cafe/TitleList/TitleList.cpp b/src/Cafe/TitleList/TitleList.cpp index c288dd13..7b75fac7 100644 --- a/src/Cafe/TitleList/TitleList.cpp +++ b/src/Cafe/TitleList/TitleList.cpp @@ -342,7 +342,8 @@ bool _IsKnownFileNameOrExtension(const fs::path& path) fileExtension == ".wud" || fileExtension == ".wux" || fileExtension == ".iso" || - fileExtension == ".wua"; + fileExtension == ".wua" || + fileExtension == ".wuhb"; // note: To detect extracted titles with RPX we rely on the presence of the content,code,meta directory structure } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e8103f9a..c34c5477 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -643,16 +643,18 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) if (menuId == MAINFRAME_MENU_ID_FILE_LOAD) { const auto wildcard = formatWxString( - "{}|*.wud;*.wux;*.wua;*.iso;*.rpx;*.elf;title.tmd" + "{}|*.wud;*.wux;*.wua;*.wuhb;*.iso;*.rpx;*.elf;title.tmd" "|{}|*.wud;*.wux;*.iso" "|{}|title.tmd" "|{}|*.wua" + "|{}|*.wuhb" "|{}|*.rpx;*.elf" "|{}|*", - _("All Wii U files (*.wud, *.wux, *.wua, *.iso, *.rpx, *.elf)"), + _("All Wii U files (*.wud, *.wux, *.wua, *.wuhb, *.iso, *.rpx, *.elf)"), _("Wii U image (*.wud, *.wux, *.iso, *.wad)"), _("Wii U NUS content"), _("Wii U archive (*.wua)"), + _("Wii U homebrew bundle (*.wuhb)"), _("Wii U executable (*.rpx, *.elf)"), _("All files (*.*)") ); diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index d7c9a4f8..eedfde5d 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1230,6 +1230,16 @@ void wxGameList::AsyncWorkerThread() if(!titleInfo.Mount(tempMountPath, "", FSC_PRIORITY_BASE)) continue; auto tgaData = fsc_extractFile((tempMountPath + "/meta/iconTex.tga").c_str()); + // try iconTex.tga.gz + if (!tgaData) + { + tgaData = fsc_extractFile((tempMountPath + "/meta/iconTex.tga.gz").c_str()); + if (tgaData) + { + auto decompressed = zlibDecompress(*tgaData, 70*1024); + std::swap(tgaData, decompressed); + } + } bool iconSuccessfullyLoaded = false; if (tgaData && tgaData->size() > 16) { diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index c02bffb7..e8efb060 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -948,6 +948,8 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu return _("NUS"); case wxTitleManagerList::EntryFormat::WUA: return _("WUA"); + case wxTitleManagerList::EntryFormat::WUHB: + return _("WUHB"); } return ""; } @@ -1022,6 +1024,9 @@ void wxTitleManagerList::HandleTitleListCallback(CafeTitleListCallbackEvent* evt case TitleInfo::TitleDataFormat::WIIU_ARCHIVE: entryFormat = EntryFormat::WUA; break; + case TitleInfo::TitleDataFormat::WUHB: + entryFormat = EntryFormat::WUHB; + break; case TitleInfo::TitleDataFormat::HOST_FS: default: entryFormat = EntryFormat::Folder; diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index 14721c57..2780a9ce 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -44,6 +44,7 @@ public: WUD, NUS, WUA, + WUHB, }; // sort by column, if -1 will sort by last column or default (=titleid) diff --git a/src/util/helpers/helpers.cpp b/src/util/helpers/helpers.cpp index 7e22e9fb..bac2d446 100644 --- a/src/util/helpers/helpers.cpp +++ b/src/util/helpers/helpers.cpp @@ -11,6 +11,8 @@ #include <boost/random/uniform_int.hpp> +#include <zlib.h> + #if BOOST_OS_WINDOWS #include <TlHelp32.h> @@ -437,3 +439,42 @@ std::string GenerateRandomString(const size_t length, const std::string_view cha return result; } + +std::optional<std::vector<uint8>> zlibDecompress(const std::vector<uint8>& compressed, size_t sizeHint) +{ + int err; + std::vector<uint8> decompressed; + size_t outWritten = 0; + size_t bytesPerIteration = sizeHint; + z_stream stream; + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + stream.avail_in = compressed.size(); + stream.next_in = (Bytef*)compressed.data(); + err = inflateInit2(&stream, 32); // 32 is a zlib magic value to enable header detection + if (err != Z_OK) + return {}; + + do + { + decompressed.resize(decompressed.size() + bytesPerIteration); + const auto availBefore = decompressed.size() - outWritten; + stream.avail_out = availBefore; + stream.next_out = decompressed.data() + outWritten; + err = inflate(&stream, Z_NO_FLUSH); + if (!(err == Z_OK || err == Z_STREAM_END)) + { + inflateEnd(&stream); + return {}; + } + outWritten += availBefore - stream.avail_out; + bytesPerIteration *= 2; + } + while (err != Z_STREAM_END); + + inflateEnd(&stream); + decompressed.resize(stream.total_out); + + return decompressed; +} diff --git a/src/util/helpers/helpers.h b/src/util/helpers/helpers.h index 09b80fed..1edc2e19 100644 --- a/src/util/helpers/helpers.h +++ b/src/util/helpers/helpers.h @@ -257,3 +257,5 @@ bool IsWindows81OrGreater(); bool IsWindows10OrGreater(); fs::path GetParentProcess(); + +std::optional<std::vector<uint8>> zlibDecompress(const std::vector<uint8>& compressed, size_t sizeHint = 32*1024); From 70afe3a03342f3f89fb45089fd23cc1b4dffbe45 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 09:11:08 +0200 Subject: [PATCH 170/314] nlibcurl: Use separte logging type --- src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp | 14 +++++++------- src/Cemu/Logging/CemuLogging.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp index 7a8eacb7..a992665c 100644 --- a/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp +++ b/src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp @@ -1505,18 +1505,18 @@ CURLcode curl_global_init_mem(uint32 flags, MEMPTR<curl_malloc_callback> malloc_ void load() { - cafeExportRegister("nlibcurl", curl_global_init_mem, LogType::Force); - cafeExportRegister("nlibcurl", curl_global_init, LogType::Force); + cafeExportRegister("nlibcurl", curl_global_init_mem, LogType::nlibcurl); + cafeExportRegister("nlibcurl", curl_global_init, LogType::nlibcurl); - cafeExportRegister("nlibcurl", curl_slist_append, LogType::Force); - cafeExportRegister("nlibcurl", curl_slist_free_all, LogType::Force); + cafeExportRegister("nlibcurl", curl_slist_append, LogType::nlibcurl); + cafeExportRegister("nlibcurl", curl_slist_free_all, LogType::nlibcurl); osLib_addFunction("nlibcurl", "curl_easy_strerror", export_curl_easy_strerror); osLib_addFunction("nlibcurl", "curl_share_init", export_curl_share_init); osLib_addFunction("nlibcurl", "curl_share_setopt", export_curl_share_setopt); osLib_addFunction("nlibcurl", "curl_share_cleanup", export_curl_share_cleanup); - cafeExportRegister("nlibcurl", mw_curl_easy_init, LogType::Force); + cafeExportRegister("nlibcurl", mw_curl_easy_init, LogType::nlibcurl); osLib_addFunction("nlibcurl", "curl_multi_init", export_curl_multi_init); osLib_addFunction("nlibcurl", "curl_multi_add_handle", export_curl_multi_add_handle); osLib_addFunction("nlibcurl", "curl_multi_perform", export_curl_multi_perform); @@ -1527,11 +1527,11 @@ void load() osLib_addFunction("nlibcurl", "curl_multi_cleanup", export_curl_multi_cleanup); osLib_addFunction("nlibcurl", "curl_multi_timeout", export_curl_multi_timeout); - cafeExportRegister("nlibcurl", curl_easy_init, LogType::Force); + cafeExportRegister("nlibcurl", curl_easy_init, LogType::nlibcurl); osLib_addFunction("nlibcurl", "curl_easy_reset", export_curl_easy_reset); osLib_addFunction("nlibcurl", "curl_easy_setopt", export_curl_easy_setopt); osLib_addFunction("nlibcurl", "curl_easy_getinfo", export_curl_easy_getinfo); - cafeExportRegister("nlibcurl", curl_easy_perform, LogType::Force); + cafeExportRegister("nlibcurl", curl_easy_perform, LogType::nlibcurl); diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 44e89360..8fbb318c 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -41,6 +41,7 @@ enum class LogType : sint32 TextureReadback = 29, ProcUi = 39, + nlibcurl = 41, PRUDP = 40, }; From dd3ed5650983180ed71640567c588bd21bb43564 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 10:05:35 +0200 Subject: [PATCH 171/314] nn_save: Fix inverted condition preventing accessing other title's saves --- src/Cafe/OS/libs/nn_save/nn_save.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 518e4195..09d4413b 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -118,11 +118,11 @@ namespace save return false; } - SAVEStatus GetAbsoluteFullPathOtherApplication(uint32 persistentId, uint64 titleId, const char* subDir, char* outPath) + FS_RESULT GetAbsoluteFullPathOtherApplication(uint32 persistentId, uint64 titleId, const char* subDir, char* outPath) { uint32be applicationBox; if(acp::ACPGetApplicationBox(&applicationBox, titleId) != acp::ACPStatus::SUCCESS) - return (FSStatus)FS_RESULT::NOT_FOUND; + return FS_RESULT::NOT_FOUND; sint32 written = 0; if(applicationBox == 3) @@ -151,13 +151,13 @@ namespace save cemu_assert_unimplemented(); } else - return (FSStatus)FS_RESULT::NOT_FOUND; + return FS_RESULT::NOT_FOUND; if (written < SAVE_MAX_PATH_SIZE - 1) - return (FSStatus)FS_RESULT::SUCCESS; + return FS_RESULT::SUCCESS; cemu_assert_suspicious(); - return (FSStatus)(FS_RESULT::FATAL_ERROR); + return FS_RESULT::FATAL_ERROR; } typedef struct @@ -417,7 +417,7 @@ namespace save if (GetPersistentIdEx(accountSlot, &persistentId)) { char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath)) + if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS) result = coreinit::FSOpenFileAsync(client, block, fullPath, (char*)mode, outFileHandle, errHandling, (FSAsyncParams*)asyncParams); } else @@ -527,7 +527,7 @@ namespace save if (GetPersistentIdEx(accountSlot, &persistentId)) { char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == (FSStatus)FS_RESULT::SUCCESS) + if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS) result = coreinit::__FSQueryInfoAsync(client, block, (uint8*)fullPath, FSA_QUERY_TYPE_STAT, stat, errHandling, (FSAsyncParams*)asyncParams); // FSGetStatAsync(...) } else @@ -811,7 +811,7 @@ namespace save if (GetPersistentIdEx(accountSlot, &persistentId)) { char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath)) + if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS) result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams); } else From bf37a8281e2dee8b7b9dc04478b99d7a8310ff0b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 14:06:26 +0200 Subject: [PATCH 172/314] CI: Update action versions --- .github/workflows/deploy_experimental_release.yml | 8 ++++---- .github/workflows/deploy_stable_release.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_experimental_release.yml b/.github/workflows/deploy_experimental_release.yml index 3bf86db4..a8c5ec53 100644 --- a/.github/workflows/deploy_experimental_release.yml +++ b/.github/workflows/deploy_experimental_release.yml @@ -15,22 +15,22 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-linux-x64 path: cemu-bin-linux-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-appimage-x64 path: cemu-appimage-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-windows-x64 path: cemu-bin-windows-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-macos-x64 path: cemu-bin-macos-x64 diff --git a/.github/workflows/deploy_stable_release.yml b/.github/workflows/deploy_stable_release.yml index 5be31413..fd339e7d 100644 --- a/.github/workflows/deploy_stable_release.yml +++ b/.github/workflows/deploy_stable_release.yml @@ -17,22 +17,22 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-linux-x64 path: cemu-bin-linux-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-appimage-x64 path: cemu-appimage-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-windows-x64 path: cemu-bin-windows-x64 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: cemu-bin-macos-x64 path: cemu-bin-macos-x64 From bd13d4bdc30b608770f9f7cb7c5ec44f6687f329 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 5 May 2024 17:05:11 +0200 Subject: [PATCH 173/314] nn_act: Make AcquireToken gracefully fail in offline mode + refactor --- src/Cafe/IOSU/legacy/iosu_act.cpp | 500 ++++++++++++++++++----------- src/Cafe/IOSU/legacy/iosu_act.h | 2 +- src/Cafe/OS/libs/nn_act/nn_act.cpp | 10 +- 3 files changed, 310 insertions(+), 202 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_act.cpp b/src/Cafe/IOSU/legacy/iosu_act.cpp index 42856684..a115d6f1 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.cpp +++ b/src/Cafe/IOSU/legacy/iosu_act.cpp @@ -21,14 +21,18 @@ using namespace iosu::kernel; +using NexToken = NAPI::ACTNexToken; +static_assert(sizeof(NexToken) == 0x25C); + struct { bool isInitialized; + std::mutex actMutex; }iosuAct = { }; // account manager -typedef struct +struct actAccountData_t { bool isValid; // options @@ -49,7 +53,12 @@ typedef struct // Mii FFLData_t miiData; uint16le miiNickname[ACT_NICKNAME_LENGTH]; -}actAccountData_t; + + bool IsNetworkAccount() const + { + return isNetworkAccount; // todo - IOSU only checks if accountId is not empty? + } +}; #define IOSU_ACT_ACCOUNT_MAX_COUNT (0xC) @@ -159,161 +168,11 @@ uint32 iosuAct_getAccountIdOfCurrentAccount() // IOSU act API interface -namespace iosu -{ - namespace act - { - uint8 getCurrentAccountSlot() - { - return 1; - } - - bool getPrincipalId(uint8 slot, uint32* principalId) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - { - *principalId = 0; - return false; - } - *principalId = _actAccountData[accountIndex].principalId; - return true; - } - - bool getAccountId(uint8 slot, char* accountId) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - { - *accountId = '\0'; - return false; - } - strcpy(accountId, _actAccountData[accountIndex].accountId); - return true; - } - - // returns empty string if invalid - std::string getAccountId2(uint8 slot) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - return {}; - return {_actAccountData[accountIndex].accountId}; - } - - bool getMii(uint8 slot, FFLData_t* fflData) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - { - return false; - } - memcpy(fflData, &_actAccountData[accountIndex].miiData, sizeof(FFLData_t)); - return true; - } - - // return screenname in little-endian wide characters - bool getScreenname(uint8 slot, uint16 screenname[ACT_NICKNAME_LENGTH]) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - { - screenname[0] = '\0'; - return false; - } - for (sint32 i = 0; i < ACT_NICKNAME_LENGTH; i++) - { - screenname[i] = (uint16)_actAccountData[accountIndex].miiNickname[i]; - } - return true; - } - - bool getCountryIndex(uint8 slot, uint32* countryIndex) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if (_actAccountData[accountIndex].isValid == false) - { - *countryIndex = 0; - return false; - } - *countryIndex = _actAccountData[accountIndex].countryIndex; - return true; - } - - bool GetPersistentId(uint8 slot, uint32* persistentId) - { - sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); - if(!_actAccountData[accountIndex].isValid) - { - *persistentId = 0; - return false; - } - *persistentId = _actAccountData[accountIndex].persistentId; - return true; - } - - class ActService : public iosu::nn::IPCService - { - public: - ActService() : iosu::nn::IPCService("/dev/act") {} - - nnResult ServiceCall(uint32 serviceId, void* request, void* response) override - { - cemuLog_log(LogType::Force, "Unsupported service call to /dev/act"); - cemu_assert_unimplemented(); - return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACT, 0); - } - }; - - ActService gActService; - - void Initialize() - { - gActService.Start(); - } - - void Stop() - { - gActService.Stop(); - } - } -} - - -// IOSU act IO - -typedef struct -{ - /* +0x00 */ uint32be ukn00; - /* +0x04 */ uint32be ukn04; - /* +0x08 */ uint32be ukn08; - /* +0x0C */ uint32be subcommandCode; - /* +0x10 */ uint8 ukn10; - /* +0x11 */ uint8 ukn11; - /* +0x12 */ uint8 ukn12; - /* +0x13 */ uint8 accountSlot; - /* +0x14 */ uint32be unique; // is this command specific? -}cmdActRequest00_t; - -typedef struct -{ - uint32be returnCode; - uint8 transferableIdBase[8]; -}cmdActGetTransferableIDResult_t; - -#define ACT_SUBCMD_GET_TRANSFERABLE_ID 4 -#define ACT_SUBCMD_INITIALIZE 0x14 - -#define _cancelIfAccountDoesNotExist() \ -if (_actAccountData[accountIndex].isValid == false) \ -{ \ - /* account does not exist*/ \ - ioctlReturnValue = 0; \ - actCemuRequest->setACTReturnCode(BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_ACT, NN_ACT_RESULT_ACCOUNT_DOES_NOT_EXIST)); /* 0xA071F480 */ \ - actCemuRequest->resultU64.u64 = 0; \ - iosuIoctl_completeRequest(ioQueueEntry, ioctlReturnValue); \ - continue; \ -} +static const auto ACTResult_Ok = 0; +static const auto ACTResult_InvalidValue = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_ACT, 0x12F00); // 0xC0712F00 +static const auto ACTResult_OutOfRange = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_ACT, 0x12D80); // 0xC0712D80 +static const auto ACTResult_AccountDoesNotExist = BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_ACT, NN_ACT_RESULT_ACCOUNT_DOES_NOT_EXIST); // 0xA071F480 +static const auto ACTResult_NotANetworkAccount = BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_ACT, 0x1FE80); // 0xA071FE80 nnResult ServerActErrorCodeToNNResult(NAPI::ACT_ERROR_CODE ec) { @@ -518,6 +377,291 @@ nnResult ServerActErrorCodeToNNResult(NAPI::ACT_ERROR_CODE ec) return nnResultStatus(NN_RESULT_MODULE_NN_ACT, NN_ERROR_CODE::ACT_UNKNOWN_SERVER_ERROR); } +namespace iosu +{ + namespace act + { + uint8 getCurrentAccountSlot() + { + return 1; + } + + actAccountData_t* GetAccountBySlotNo(uint8 slotNo) + { + // only call this while holding actMutex + uint8 accIndex; + if(slotNo == iosu::act::ACT_SLOT_CURRENT) + { + accIndex = getCurrentAccountSlot() - 1; + cemu_assert_debug(accIndex >= 0 && accIndex < IOSU_ACT_ACCOUNT_MAX_COUNT); + } + else if(slotNo > 0 && slotNo <= IOSU_ACT_ACCOUNT_MAX_COUNT) + accIndex = slotNo - 1; + else + { + return nullptr; + } + if(!_actAccountData[accIndex].isValid) + return nullptr; + return &_actAccountData[accIndex]; + } + + // has ownership of account data + // while any thread has a LockedAccount in non-null state no other thread can access the account data + class LockedAccount + { + public: + LockedAccount(uint8 slotNo) + { + iosuAct.actMutex.lock(); + m_account = GetAccountBySlotNo(slotNo); + if(!m_account) + iosuAct.actMutex.unlock(); + } + + ~LockedAccount() + { + if(m_account) + iosuAct.actMutex.unlock(); + } + + void Release() + { + if(m_account) + iosuAct.actMutex.unlock(); + m_account = nullptr; + } + + actAccountData_t* operator->() + { + return m_account; + } + + actAccountData_t& operator*() + { + return *m_account; + } + + LockedAccount(const LockedAccount&) = delete; + LockedAccount& operator=(const LockedAccount&) = delete; + + operator bool() const { return m_account != nullptr; } + + private: + actAccountData_t* m_account{nullptr}; + }; + + bool getPrincipalId(uint8 slot, uint32* principalId) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + { + *principalId = 0; + return false; + } + *principalId = _actAccountData[accountIndex].principalId; + return true; + } + + bool getAccountId(uint8 slot, char* accountId) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + { + *accountId = '\0'; + return false; + } + strcpy(accountId, _actAccountData[accountIndex].accountId); + return true; + } + + // returns empty string if invalid + std::string getAccountId2(uint8 slot) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + return {}; + return {_actAccountData[accountIndex].accountId}; + } + + bool getMii(uint8 slot, FFLData_t* fflData) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + { + return false; + } + memcpy(fflData, &_actAccountData[accountIndex].miiData, sizeof(FFLData_t)); + return true; + } + + // return screenname in little-endian wide characters + bool getScreenname(uint8 slot, uint16 screenname[ACT_NICKNAME_LENGTH]) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + { + screenname[0] = '\0'; + return false; + } + for (sint32 i = 0; i < ACT_NICKNAME_LENGTH; i++) + { + screenname[i] = (uint16)_actAccountData[accountIndex].miiNickname[i]; + } + return true; + } + + bool getCountryIndex(uint8 slot, uint32* countryIndex) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if (_actAccountData[accountIndex].isValid == false) + { + *countryIndex = 0; + return false; + } + *countryIndex = _actAccountData[accountIndex].countryIndex; + return true; + } + + bool GetPersistentId(uint8 slot, uint32* persistentId) + { + sint32 accountIndex = iosuAct_getAccountIndexBySlot(slot); + if(!_actAccountData[accountIndex].isValid) + { + *persistentId = 0; + return false; + } + *persistentId = _actAccountData[accountIndex].persistentId; + return true; + } + + nnResult AcquireNexToken(uint8 accountSlot, uint64 titleId, uint16 titleVersion, uint32 serverId, uint8* tokenOut, uint32 tokenLen) + { + if (accountSlot != ACT_SLOT_CURRENT) + return ACTResult_InvalidValue; + LockedAccount account(accountSlot); + if (!account) + return ACTResult_AccountDoesNotExist; + if (!account->IsNetworkAccount()) + return ACTResult_NotANetworkAccount; + cemu_assert_debug(ActiveSettings::IsOnlineEnabled()); + if (tokenLen != sizeof(NexToken)) + return ACTResult_OutOfRange; + + NAPI::AuthInfo authInfo; + NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); + NAPI::ACTGetNexTokenResult nexTokenResult = NAPI::ACT_GetNexToken_WithCache(authInfo, titleId, titleVersion, serverId); + if (nexTokenResult.isValid()) + { + memcpy(tokenOut, &nexTokenResult.nexToken, sizeof(NexToken)); + return ACTResult_Ok; + } + else if (nexTokenResult.apiError == NAPI_RESULT::SERVICE_ERROR) + { + nnResult returnCode = ServerActErrorCodeToNNResult(nexTokenResult.serviceError); + cemu_assert_debug((returnCode&0x80000000) != 0); + return returnCode; + } + return nnResultStatus(NN_RESULT_MODULE_NN_ACT, NN_ERROR_CODE::ACT_UNKNOWN_SERVER_ERROR); + } + + nnResult AcquireIndependentServiceToken(uint8 accountSlot, uint64 titleId, uint16 titleVersion, std::string_view clientId, uint8* tokenOut, uint32 tokenLen) + { + static constexpr size_t IndependentTokenMaxLength = 512+1; // 512 bytes + null terminator + if(accountSlot != ACT_SLOT_CURRENT) + return ACTResult_InvalidValue; + LockedAccount account(accountSlot); + if (!account) + return ACTResult_AccountDoesNotExist; + if (!account->IsNetworkAccount()) + return ACTResult_NotANetworkAccount; + cemu_assert_debug(ActiveSettings::IsOnlineEnabled()); + if (tokenLen < IndependentTokenMaxLength) + return ACTResult_OutOfRange; + NAPI::AuthInfo authInfo; + NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); + account.Release(); + NAPI::ACTGetIndependentTokenResult tokenResult = NAPI::ACT_GetIndependentToken_WithCache(authInfo, titleId, titleVersion, clientId); + uint32 returnCode = 0; + if (tokenResult.isValid()) + { + for (size_t i = 0; i < std::min(tokenResult.token.size(), (size_t)IndependentTokenMaxLength); i++) + { + tokenOut[i] = tokenResult.token[i]; + tokenOut[i + 1] = '\0'; + } + returnCode = 0; + } + else + { + returnCode = 0x80000000; // todo - proper error codes + } + return returnCode; + } + + class ActService : public iosu::nn::IPCService + { + public: + ActService() : iosu::nn::IPCService("/dev/act") {} + + nnResult ServiceCall(uint32 serviceId, void* request, void* response) override + { + cemuLog_log(LogType::Force, "Unsupported service call to /dev/act"); + cemu_assert_unimplemented(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACT, 0); + } + }; + + ActService gActService; + + void Initialize() + { + gActService.Start(); + } + + void Stop() + { + gActService.Stop(); + } + } +} + + +// IOSU act IO + +typedef struct +{ + /* +0x00 */ uint32be ukn00; + /* +0x04 */ uint32be ukn04; + /* +0x08 */ uint32be ukn08; + /* +0x0C */ uint32be subcommandCode; + /* +0x10 */ uint8 ukn10; + /* +0x11 */ uint8 ukn11; + /* +0x12 */ uint8 ukn12; + /* +0x13 */ uint8 accountSlot; + /* +0x14 */ uint32be unique; // is this command specific? +}cmdActRequest00_t; + +typedef struct +{ + uint32be returnCode; + uint8 transferableIdBase[8]; +}cmdActGetTransferableIDResult_t; + +#define ACT_SUBCMD_GET_TRANSFERABLE_ID 4 +#define ACT_SUBCMD_INITIALIZE 0x14 + +#define _cancelIfAccountDoesNotExist() \ +if (_actAccountData[accountIndex].isValid == false) \ +{ \ + /* account does not exist*/ \ + ioctlReturnValue = 0; \ + actCemuRequest->setACTReturnCode(BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_ACT, NN_ACT_RESULT_ACCOUNT_DOES_NOT_EXIST)); /* 0xA071F480 */ \ + actCemuRequest->resultU64.u64 = 0; \ + iosuIoctl_completeRequest(ioQueueEntry, ioctlReturnValue); \ + continue; \ +} + int iosuAct_thread() { SetThreadName("iosuAct_thread"); @@ -674,47 +818,13 @@ int iosuAct_thread() } else if (actCemuRequest->requestCode == IOSU_ARC_ACQUIRENEXTOKEN) { - NAPI::AuthInfo authInfo; - NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); - NAPI::ACTGetNexTokenResult nexTokenResult = NAPI::ACT_GetNexToken_WithCache(authInfo, actCemuRequest->titleId, actCemuRequest->titleVersion, actCemuRequest->serverId); - uint32 returnCode = 0; - if (nexTokenResult.isValid()) - { - *(NAPI::ACTNexToken*)actCemuRequest->resultBinary.binBuffer = nexTokenResult.nexToken; - returnCode = NN_RESULT_SUCCESS; - } - else if (nexTokenResult.apiError == NAPI_RESULT::SERVICE_ERROR) - { - returnCode = ServerActErrorCodeToNNResult(nexTokenResult.serviceError); - cemu_assert_debug((returnCode&0x80000000) != 0); - } - else - { - returnCode = nnResultStatus(NN_RESULT_MODULE_NN_ACT, NN_ERROR_CODE::ACT_UNKNOWN_SERVER_ERROR); - } - actCemuRequest->setACTReturnCode(returnCode); + nnResult r = iosu::act::AcquireNexToken(actCemuRequest->accountSlot, actCemuRequest->titleId, actCemuRequest->titleVersion, actCemuRequest->serverId, actCemuRequest->resultBinary.binBuffer, sizeof(NexToken)); + actCemuRequest->setACTReturnCode(r); } else if (actCemuRequest->requestCode == IOSU_ARC_ACQUIREINDEPENDENTTOKEN) { - NAPI::AuthInfo authInfo; - NAPI::NAPI_MakeAuthInfoFromCurrentAccount(authInfo); - NAPI::ACTGetIndependentTokenResult tokenResult = NAPI::ACT_GetIndependentToken_WithCache(authInfo, actCemuRequest->titleId, actCemuRequest->titleVersion, actCemuRequest->clientId); - - uint32 returnCode = 0; - if (tokenResult.isValid()) - { - for (size_t i = 0; i < std::min(tokenResult.token.size(), (size_t)200); i++) - { - actCemuRequest->resultBinary.binBuffer[i] = tokenResult.token[i]; - actCemuRequest->resultBinary.binBuffer[i + 1] = '\0'; - } - returnCode = 0; - } - else - { - returnCode = 0x80000000; // todo - proper error codes - } - actCemuRequest->setACTReturnCode(returnCode); + nnResult r = iosu::act::AcquireIndependentServiceToken(actCemuRequest->accountSlot, actCemuRequest->titleId, actCemuRequest->titleVersion, actCemuRequest->clientId, actCemuRequest->resultBinary.binBuffer, sizeof(actCemuRequest->resultBinary.binBuffer)); + actCemuRequest->setACTReturnCode(r); } else if (actCemuRequest->requestCode == IOSU_ARC_ACQUIREPIDBYNNID) { diff --git a/src/Cafe/IOSU/legacy/iosu_act.h b/src/Cafe/IOSU/legacy/iosu_act.h index d60966d4..8ed408a4 100644 --- a/src/Cafe/IOSU/legacy/iosu_act.h +++ b/src/Cafe/IOSU/legacy/iosu_act.h @@ -53,7 +53,7 @@ namespace iosu std::string getAccountId2(uint8 slot); - const uint8 ACT_SLOT_CURRENT = 0xFE; + static constexpr uint8 ACT_SLOT_CURRENT = 0xFE; void Initialize(); void Stop(); diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index af53edd7..f490ff19 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -114,6 +114,7 @@ namespace act { memset(token, 0, sizeof(independentServiceToken_t)); actPrepareRequest(); + actRequest->accountSlot = iosu::act::ACT_SLOT_CURRENT; actRequest->requestCode = IOSU_ARC_ACQUIREINDEPENDENTTOKEN; actRequest->titleId = CafeSystem::GetForegroundTitleId(); actRequest->titleVersion = CafeSystem::GetForegroundTitleVersion(); @@ -611,6 +612,7 @@ void nnActExport_AcquireNexServiceToken(PPCInterpreter_t* hCPU) ppcDefineParamU32(serverId, 1); memset(token, 0, sizeof(nexServiceToken_t)); actPrepareRequest(); + actRequest->accountSlot = iosu::act::ACT_SLOT_CURRENT; actRequest->requestCode = IOSU_ARC_ACQUIRENEXTOKEN; actRequest->titleId = CafeSystem::GetForegroundTitleId(); actRequest->titleVersion = CafeSystem::GetForegroundTitleVersion(); @@ -627,10 +629,8 @@ void nnActExport_AcquireNexServiceToken(PPCInterpreter_t* hCPU) void nnActExport_AcquireIndependentServiceToken(PPCInterpreter_t* hCPU) { ppcDefineParamMEMPTR(token, independentServiceToken_t, 0); - ppcDefineParamMEMPTR(serviceToken, const char, 1); - uint32 result = nn::act::AcquireIndependentServiceToken(token.GetPtr(), serviceToken.GetPtr(), 0); - cemuLog_logDebug(LogType::Force, "nn_act.AcquireIndependentServiceToken(0x{}, {}) -> {:x}", (void*)token.GetPtr(), serviceToken.GetPtr(), result); - cemuLog_logDebug(LogType::Force, "Token: {}", serviceToken.GetPtr()); + ppcDefineParamMEMPTR(clientId, const char, 1); + uint32 result = nn::act::AcquireIndependentServiceToken(token.GetPtr(), clientId.GetPtr(), 0); osLib_returnFromFunction(hCPU, result); } @@ -640,7 +640,6 @@ void nnActExport_AcquireIndependentServiceToken2(PPCInterpreter_t* hCPU) ppcDefineParamMEMPTR(clientId, const char, 1); ppcDefineParamU32(cacheDurationInSeconds, 2); uint32 result = nn::act::AcquireIndependentServiceToken(token, clientId.GetPtr(), cacheDurationInSeconds); - cemuLog_logDebug(LogType::Force, "Called nn_act.AcquireIndependentServiceToken2"); osLib_returnFromFunction(hCPU, result); } @@ -648,7 +647,6 @@ void nnActExport_AcquireEcServiceToken(PPCInterpreter_t* hCPU) { ppcDefineParamMEMPTR(pEcServiceToken, independentServiceToken_t, 0); uint32 result = nn::act::AcquireIndependentServiceToken(pEcServiceToken.GetPtr(), "71a6f5d6430ea0183e3917787d717c46", 0); - cemuLog_logDebug(LogType::Force, "Called nn_act.AcquireEcServiceToken"); osLib_returnFromFunction(hCPU, result); } From 7d6d4173549a55070683feac33afaad038383813 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Mon, 6 May 2024 02:27:30 +0100 Subject: [PATCH 174/314] Input: Improve setting of dpd_enable_fg (#1127) --- src/input/api/Controller.h | 2 ++ src/input/api/ControllerState.h | 6 ++++++ src/input/api/DSU/DSUController.cpp | 7 +++++++ src/input/api/DSU/DSUController.h | 1 + src/input/api/Wiimote/NativeWiimoteController.cpp | 5 +++++ src/input/api/Wiimote/NativeWiimoteController.h | 1 + src/input/api/Wiimote/WiimoteControllerProvider.cpp | 6 ++++++ src/input/api/Wiimote/WiimoteControllerProvider.h | 2 ++ src/input/emulated/EmulatedController.cpp | 11 +++++++++++ src/input/emulated/EmulatedController.h | 1 + src/input/emulated/WPADController.cpp | 12 +++++++++--- 11 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/input/api/Controller.h b/src/input/api/Controller.h index 8b1c8e62..e2475191 100644 --- a/src/input/api/Controller.h +++ b/src/input/api/Controller.h @@ -2,6 +2,7 @@ #include "input/InputManager.h" #include "input/motion/MotionSample.h" +#include "input/api/ControllerState.h" namespace pugi { @@ -118,6 +119,7 @@ public: virtual bool has_position() { return false; } virtual glm::vec2 get_position() { return {}; } virtual glm::vec2 get_prev_position() { return {}; } + virtual PositionVisibility GetPositionVisibility() {return PositionVisibility::NONE;}; virtual bool has_rumble() { return false; } virtual void start_rumble() {} diff --git a/src/input/api/ControllerState.h b/src/input/api/ControllerState.h index ce79a1e0..65bfec9f 100644 --- a/src/input/api/ControllerState.h +++ b/src/input/api/ControllerState.h @@ -3,6 +3,12 @@ #include <glm/vec2.hpp> #include "util/helpers/fspinlock.h" +enum class PositionVisibility { + NONE = 0, + FULL = 1, + PARTIAL = 2 +}; + // helper class for storing and managing button press states in a thread-safe manner struct ControllerButtonState { diff --git a/src/input/api/DSU/DSUController.cpp b/src/input/api/DSU/DSUController.cpp index f134440c..082f7e39 100644 --- a/src/input/api/DSU/DSUController.cpp +++ b/src/input/api/DSU/DSUController.cpp @@ -93,6 +93,13 @@ glm::vec2 DSUController::get_prev_position() return {}; } +PositionVisibility DSUController::GetPositionVisibility() +{ + const auto state = m_provider->get_prev_state(m_index); + + return (state.data.tpad1.active || state.data.tpad2.active) ? PositionVisibility::FULL : PositionVisibility::NONE; +} + std::string DSUController::get_button_name(uint64 button) const { switch (button) diff --git a/src/input/api/DSU/DSUController.h b/src/input/api/DSU/DSUController.h index 801f609c..e6e2936d 100644 --- a/src/input/api/DSU/DSUController.h +++ b/src/input/api/DSU/DSUController.h @@ -32,6 +32,7 @@ public: bool has_position() override; glm::vec2 get_position() override; glm::vec2 get_prev_position() override; + PositionVisibility GetPositionVisibility() override; std::string get_button_name(uint64 button) const override; diff --git a/src/input/api/Wiimote/NativeWiimoteController.cpp b/src/input/api/Wiimote/NativeWiimoteController.cpp index 3f9e82a5..9aa56d9c 100644 --- a/src/input/api/Wiimote/NativeWiimoteController.cpp +++ b/src/input/api/Wiimote/NativeWiimoteController.cpp @@ -98,6 +98,11 @@ glm::vec2 NativeWiimoteController::get_prev_position() const auto state = m_provider->get_state(m_index); return state.ir_camera.m_prev_position; } +PositionVisibility NativeWiimoteController::GetPositionVisibility() +{ + const auto state = m_provider->get_state(m_index); + return state.ir_camera.m_positionVisibility; +} bool NativeWiimoteController::has_low_battery() { diff --git a/src/input/api/Wiimote/NativeWiimoteController.h b/src/input/api/Wiimote/NativeWiimoteController.h index ed3caa08..8e9c0774 100644 --- a/src/input/api/Wiimote/NativeWiimoteController.h +++ b/src/input/api/Wiimote/NativeWiimoteController.h @@ -40,6 +40,7 @@ public: bool has_position() override; glm::vec2 get_position() override; glm::vec2 get_prev_position() override; + PositionVisibility GetPositionVisibility() override; bool has_motion() override { return true; } bool has_rumble() override { return true; } diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.cpp b/src/input/api/Wiimote/WiimoteControllerProvider.cpp index 5aac3fe4..c80f3fbe 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.cpp +++ b/src/input/api/Wiimote/WiimoteControllerProvider.cpp @@ -766,14 +766,20 @@ void WiimoteControllerProvider::calculate_ir_position(WiimoteState& wiimote_stat ir.middle = ir.position; ir.distance = glm::length(ir.dots[indices.first].pos - ir.dots[indices.second].pos); ir.indices = indices; + ir.m_positionVisibility = PositionVisibility::FULL; } else if (ir.dots[indices.first].visible) { ir.position = ir.middle + (ir.dots[indices.first].pos - ir.prev_dots[indices.first].pos); + ir.m_positionVisibility = PositionVisibility::PARTIAL; } else if (ir.dots[indices.second].visible) { ir.position = ir.middle + (ir.dots[indices.second].pos - ir.prev_dots[indices.second].pos); + ir.m_positionVisibility = PositionVisibility::PARTIAL; + } + else { + ir.m_positionVisibility = PositionVisibility::NONE; } } diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.h b/src/input/api/Wiimote/WiimoteControllerProvider.h index 40fe878a..7629b641 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.h +++ b/src/input/api/Wiimote/WiimoteControllerProvider.h @@ -5,6 +5,7 @@ #include "input/api/Wiimote/WiimoteMessages.h" #include "input/api/ControllerProvider.h" +#include "input/api/ControllerState.h" #include <list> #include <variant> @@ -61,6 +62,7 @@ public: std::array<IRDot, 4> dots{}, prev_dots{}; glm::vec2 position{}, m_prev_position{}; + PositionVisibility m_positionVisibility; glm::vec2 middle {}; float distance = 0; std::pair<sint32, sint32> indices{ 0,1 }; diff --git a/src/input/emulated/EmulatedController.cpp b/src/input/emulated/EmulatedController.cpp index e254db34..ad9b6ac1 100644 --- a/src/input/emulated/EmulatedController.cpp +++ b/src/input/emulated/EmulatedController.cpp @@ -207,6 +207,17 @@ glm::vec2 EmulatedController::get_prev_position() const return {}; } +PositionVisibility EmulatedController::GetPositionVisibility() const +{ + std::shared_lock lock(m_mutex); + for (const auto& controller : m_controllers) + { + if (controller->has_position()) + return controller->GetPositionVisibility(); + } + return PositionVisibility::NONE; +} + void EmulatedController::add_controller(std::shared_ptr<ControllerBase> controller) { controller->connect(); diff --git a/src/input/emulated/EmulatedController.h b/src/input/emulated/EmulatedController.h index b7bd8c6d..907be07e 100644 --- a/src/input/emulated/EmulatedController.h +++ b/src/input/emulated/EmulatedController.h @@ -67,6 +67,7 @@ public: bool has_position() const; glm::vec2 get_position() const; glm::vec2 get_prev_position() const; + PositionVisibility GetPositionVisibility() const; void add_controller(std::shared_ptr<ControllerBase> controller); void remove_controller(const std::shared_ptr<ControllerBase>& controller); diff --git a/src/input/emulated/WPADController.cpp b/src/input/emulated/WPADController.cpp index 819596ab..2eae0f86 100644 --- a/src/input/emulated/WPADController.cpp +++ b/src/input/emulated/WPADController.cpp @@ -1,3 +1,4 @@ +#include <api/Controller.h> #include "input/emulated/WPADController.h" #include "input/emulated/ClassicController.h" @@ -308,10 +309,13 @@ void WPADController::KPADRead(KPADStatus_t& status, const BtnRepeat& repeat) status.mpls.dir.Z.z = attitude[8]; } } - - if (has_position()) + auto visibility = GetPositionVisibility(); + if (has_position() && visibility != PositionVisibility::NONE) { - status.dpd_valid_fg = 1; + if (visibility == PositionVisibility::FULL) + status.dpd_valid_fg = 2; + else + status.dpd_valid_fg = -1; const auto position = get_position(); @@ -324,6 +328,8 @@ void WPADController::KPADRead(KPADStatus_t& status, const BtnRepeat& repeat) status.vec.y = delta.y; status.speed = glm::length(delta); } + else + status.dpd_valid_fg = 0; switch (type()) { From 065fb7eb58855ec2d8c009f2dfabc3e815b91915 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 6 May 2024 09:15:36 +0200 Subject: [PATCH 175/314] coreinit: Add reschedule special case to avoid a deadlock Fixes Just Dance 2019 locking up on boot --- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 533360aa..fbf498db 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -763,6 +763,11 @@ namespace coreinit uint32 coreIndex = OSGetCoreId(); if (!newThread->context.hasCoreAffinitySet(coreIndex)) return false; + // special case: if current and new thread are running only on the same core then reschedule even if priority is equal + // this resolves a deadlock in Just Dance 2019 where one thread would always reacquire the same mutex within it's timeslice, blocking another thread on the same core from acquiring it + if ((1<<coreIndex) == newThread->context.affinity && currentThread->context.affinity == newThread->context.affinity && currentThread->effectivePriority == newThread->effectivePriority) + return true; + // otherwise reschedule if new thread has higher priority return newThread->effectivePriority < currentThread->effectivePriority; } From 3f8722f0a6789065f709daa3d6a636e2334b3bad Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 6 May 2024 18:18:42 +0200 Subject: [PATCH 176/314] Track online-enable and network-service settings per-account instead of globally --- src/config/ActiveSettings.cpp | 12 ++- src/config/CemuConfig.cpp | 58 +++++++++++++- src/config/CemuConfig.h | 10 ++- src/config/NetworkSettings.cpp | 9 ++- src/config/NetworkSettings.h | 4 +- src/gui/GeneralSettings2.cpp | 137 ++++++++++++++++++++------------- src/gui/GeneralSettings2.h | 4 +- src/gui/MainWindow.cpp | 32 -------- 8 files changed, 164 insertions(+), 102 deletions(-) diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index 81662ab5..07e6f16d 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -131,7 +131,12 @@ uint32 ActiveSettings::GetPersistentId() bool ActiveSettings::IsOnlineEnabled() { - return GetConfig().account.online_enabled && Account::GetAccount(GetPersistentId()).IsValidOnlineAccount() && HasRequiredOnlineFiles(); + if(!Account::GetAccount(GetPersistentId()).IsValidOnlineAccount()) + return false; + if(!HasRequiredOnlineFiles()) + return false; + NetworkService networkService = static_cast<NetworkService>(GetConfig().GetAccountNetworkService(GetPersistentId())); + return networkService == NetworkService::Nintendo || networkService == NetworkService::Pretendo || networkService == NetworkService::Custom; } bool ActiveSettings::HasRequiredOnlineFiles() @@ -139,8 +144,9 @@ bool ActiveSettings::HasRequiredOnlineFiles() return s_has_required_online_files; } -NetworkService ActiveSettings::GetNetworkService() { - return static_cast<NetworkService>(GetConfig().account.active_service.GetValue()); +NetworkService ActiveSettings::GetNetworkService() +{ + return GetConfig().GetAccountNetworkService(GetPersistentId()); } bool ActiveSettings::DumpShadersEnabled() diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index e4be97a7..4f1736e2 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -328,8 +328,22 @@ void CemuConfig::Load(XMLConfigParser& parser) // account auto acc = parser.get("Account"); account.m_persistent_id = acc.get("PersistentId", account.m_persistent_id); - account.online_enabled = acc.get("OnlineEnabled", account.online_enabled); - account.active_service = acc.get("ActiveService",account.active_service); + // legacy online settings, we only parse these for upgrading purposes + account.legacy_online_enabled = acc.get("OnlineEnabled", account.legacy_online_enabled); + account.legacy_active_service = acc.get("ActiveService",account.legacy_active_service); + // per-account online setting + auto accService = parser.get("AccountService"); + account.service_select.clear(); + for (auto element = accService.get("SelectedService"); element.valid(); element = accService.get("SelectedService", element)) + { + uint32 persistentId = element.get_attribute<uint32>("PersistentId", 0); + sint32 serviceIndex = element.get_attribute<sint32>("Service", 0); + NetworkService networkService = static_cast<NetworkService>(serviceIndex); + if (persistentId < Account::kMinPersistendId) + continue; + if(networkService == NetworkService::Offline || networkService == NetworkService::Nintendo || networkService == NetworkService::Pretendo || networkService == NetworkService::Custom) + account.service_select.emplace(persistentId, networkService); + } // debug auto debug = parser.get("Debug"); #if BOOST_OS_WINDOWS @@ -512,8 +526,17 @@ void CemuConfig::Save(XMLConfigParser& parser) // account auto acc = config.set("Account"); acc.set("PersistentId", account.m_persistent_id.GetValue()); - acc.set("OnlineEnabled", account.online_enabled.GetValue()); - acc.set("ActiveService",account.active_service.GetValue()); + // legacy online mode setting + acc.set("OnlineEnabled", account.legacy_online_enabled.GetValue()); + acc.set("ActiveService",account.legacy_active_service.GetValue()); + // per-account online setting + auto accService = config.set("AccountService"); + for(auto& it : account.service_select) + { + auto entry = accService.set("SelectedService"); + entry.set_attribute("PersistentId", it.first); + entry.set_attribute("Service", static_cast<sint32>(it.second)); + } // debug auto debug = config.set("Debug"); #if BOOST_OS_WINDOWS @@ -609,3 +632,30 @@ void CemuConfig::AddRecentNfcFile(std::string_view file) while (recent_nfc_files.size() > kMaxRecentEntries) recent_nfc_files.pop_back(); } + +NetworkService CemuConfig::GetAccountNetworkService(uint32 persistentId) +{ + auto it = account.service_select.find(persistentId); + if (it != account.service_select.end()) + { + NetworkService serviceIndex = it->second; + // make sure the returned service is valid + if (serviceIndex != NetworkService::Offline && + serviceIndex != NetworkService::Nintendo && + serviceIndex != NetworkService::Pretendo && + serviceIndex != NetworkService::Custom) + return NetworkService::Offline; + if( static_cast<NetworkService>(serviceIndex) == NetworkService::Custom && !NetworkConfig::XMLExists() ) + return NetworkService::Offline; // custom is selected but no custom config exists + return serviceIndex; + } + // if not found, return the legacy value + if(!account.legacy_online_enabled) + return NetworkService::Offline; + return static_cast<NetworkService>(account.legacy_active_service.GetValue() + 1); // +1 because "Offline" now takes index 0 +} + +void CemuConfig::SetAccountSelectedService(uint32 persistentId, NetworkService serviceIndex) +{ + account.service_select[persistentId] = serviceIndex; +} diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 9f1e7983..cab7a1af 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -8,6 +8,8 @@ #include <wx/language.h> #include <wx/intl.h> +enum class NetworkService; + struct GameEntry { GameEntry() = default; @@ -483,8 +485,9 @@ struct CemuConfig struct { ConfigValueBounds<uint32> m_persistent_id{ Account::kMinPersistendId, Account::kMinPersistendId, 0xFFFFFFFF }; - ConfigValue<bool> online_enabled{false}; - ConfigValue<int> active_service{0}; + ConfigValue<bool> legacy_online_enabled{false}; + ConfigValue<int> legacy_active_service{0}; + std::unordered_map<uint32, NetworkService> service_select; // per-account service index. Key is persistentId }account{}; // input @@ -509,6 +512,9 @@ struct CemuConfig bool GetGameListCustomName(uint64 titleId, std::string& customName); void SetGameListCustomName(uint64 titleId, std::string customName); + NetworkService GetAccountNetworkService(uint32 persistentId); + void SetAccountSelectedService(uint32 persistentId, NetworkService serviceIndex); + private: GameEntry* GetGameEntryByTitleId(uint64 titleId); GameEntry* CreateGameEntry(uint64 titleId); diff --git a/src/config/NetworkSettings.cpp b/src/config/NetworkSettings.cpp index b086d0ae..42dc9996 100644 --- a/src/config/NetworkSettings.cpp +++ b/src/config/NetworkSettings.cpp @@ -34,14 +34,15 @@ void NetworkConfig::Load(XMLConfigParser& parser) bool NetworkConfig::XMLExists() { + static std::optional<bool> s_exists; // caches result of fs::exists + if(s_exists.has_value()) + return *s_exists; std::error_code ec; if (!fs::exists(ActiveSettings::GetConfigPath("network_services.xml"), ec)) { - if (static_cast<NetworkService>(GetConfig().account.active_service.GetValue()) == NetworkService::Custom) - { - GetConfig().account.active_service = 0; - } + s_exists = false; return false; } + s_exists = true; return true; } \ No newline at end of file diff --git a/src/config/NetworkSettings.h b/src/config/NetworkSettings.h index be311182..6e114a0e 100644 --- a/src/config/NetworkSettings.h +++ b/src/config/NetworkSettings.h @@ -5,9 +5,11 @@ enum class NetworkService { + Offline, Nintendo, Pretendo, - Custom + Custom, + COUNT = Custom }; struct NetworkConfig diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index dab30981..c0b54949 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -683,18 +683,6 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) content->Add(m_delete_account, 0, wxEXPAND | wxALL | wxALIGN_RIGHT, 5); m_delete_account->Bind(wxEVT_BUTTON, &GeneralSettings2::OnAccountDelete, this); - wxString choices[] = { _("Nintendo"), _("Pretendo"), _("Custom") }; - m_active_service = new wxRadioBox(online_panel, wxID_ANY, _("Network Service"), wxDefaultPosition, wxDefaultSize, std::size(choices), choices, 3, wxRA_SPECIFY_COLS); - if (!NetworkConfig::XMLExists()) - m_active_service->Enable(2, false); - - m_active_service->SetItemToolTip(0, _("Connect to the official Nintendo Network Service")); - m_active_service->SetItemToolTip(1, _("Connect to the Pretendo Network Service")); - m_active_service->SetItemToolTip(2, _("Connect to a custom Network Service (configured via network_services.xml)")); - - m_active_service->Bind(wxEVT_RADIOBOX, &GeneralSettings2::OnAccountServiceChanged,this); - content->Add(m_active_service, 0, wxEXPAND | wxALL, 5); - box_sizer->Add(content, 1, wxEXPAND, 5); online_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5); @@ -704,17 +692,33 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) m_active_account->Enable(false); m_create_account->Enable(false); m_delete_account->Enable(false); + } + } + + + { + wxString choices[] = { _("Offline"), _("Nintendo"), _("Pretendo"), _("Custom") }; + m_active_service = new wxRadioBox(online_panel, wxID_ANY, _("Network Service"), wxDefaultPosition, wxDefaultSize, std::size(choices), choices, 4, wxRA_SPECIFY_COLS); + if (!NetworkConfig::XMLExists()) + m_active_service->Enable(3, false); + + m_active_service->SetItemToolTip(0, _("Online functionality disabled for this account")); + m_active_service->SetItemToolTip(1, _("Connect to the official Nintendo Network Service")); + m_active_service->SetItemToolTip(2, _("Connect to the Pretendo Network Service")); + m_active_service->SetItemToolTip(3, _("Connect to a custom Network Service (configured via network_services.xml)")); + + m_active_service->Bind(wxEVT_RADIOBOX, &GeneralSettings2::OnAccountServiceChanged,this); + online_panel_sizer->Add(m_active_service, 0, wxEXPAND | wxALL, 5); + + if (CafeSystem::IsTitleRunning()) + { m_active_service->Enable(false); } } - + { - auto* box = new wxStaticBox(online_panel, wxID_ANY, _("Online settings")); + auto* box = new wxStaticBox(online_panel, wxID_ANY, _("Online play requirements")); auto* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); - - m_online_enabled = new wxCheckBox(box, wxID_ANY, _("Enable online mode")); - m_online_enabled->Bind(wxEVT_CHECKBOX, &GeneralSettings2::OnOnlineEnable, this); - box_sizer->Add(m_online_enabled, 0, wxEXPAND | wxALL, 5); auto* row = new wxFlexGridSizer(0, 2, 0, 0); row->SetFlexibleDirection(wxBOTH); @@ -873,6 +877,14 @@ GeneralSettings2::GeneralSettings2(wxWindow* parent, bool game_launched) DisableSettings(game_launched); } +uint32 GeneralSettings2::GetSelectedAccountPersistentId() +{ + const auto active_account = m_active_account->GetSelection(); + if (active_account == wxNOT_FOUND) + return GetConfig().account.m_persistent_id.GetInitValue(); + return dynamic_cast<wxAccountData*>(m_active_account->GetClientObject(active_account))->GetAccount().GetPersistentId(); +} + void GeneralSettings2::StoreConfig() { auto* app = (CemuApp*)wxTheApp; @@ -1038,14 +1050,7 @@ void GeneralSettings2::StoreConfig() config.notification.friends = m_friends_data->GetValue(); // account - const auto active_account = m_active_account->GetSelection(); - if (active_account == wxNOT_FOUND) - config.account.m_persistent_id = config.account.m_persistent_id.GetInitValue(); - else - config.account.m_persistent_id = dynamic_cast<wxAccountData*>(m_active_account->GetClientObject(active_account))->GetAccount().GetPersistentId(); - - config.account.online_enabled = m_online_enabled->GetValue(); - config.account.active_service = m_active_service->GetSelection(); + config.account.m_persistent_id = GetSelectedAccountPersistentId(); // debug config.crash_dump = (CrashDump)m_crash_dump->GetSelection(); @@ -1371,14 +1376,13 @@ void GeneralSettings2::UpdateAccountInformation() { m_account_grid->SetSplitterPosition(100); - m_online_status->SetLabel(_("At least one issue has been found")); - const auto selection = m_active_account->GetSelection(); if(selection == wxNOT_FOUND) { m_validate_online->SetBitmap(wxBITMAP_PNG_FROM_DATA(PNG_ERROR).ConvertToImage().Scale(16, 16)); m_validate_online->SetWindowStyleFlag(m_validate_online->GetWindowStyleFlag() & ~wxBORDER_NONE); ResetAccountInformation(); + m_online_status->SetLabel(_("No account selected")); return; } @@ -1404,11 +1408,26 @@ void GeneralSettings2::UpdateAccountInformation() index = 0; country_property->SetChoiceSelection(index); - const bool online_valid = account.IsValidOnlineAccount() && ActiveSettings::HasRequiredOnlineFiles(); - if (online_valid) + const bool online_fully_valid = account.IsValidOnlineAccount() && ActiveSettings::HasRequiredOnlineFiles(); + if (ActiveSettings::HasRequiredOnlineFiles()) + { + if(account.IsValidOnlineAccount()) + m_online_status->SetLabel(_("Selected account is a valid online account")); + else + m_online_status->SetLabel(_("Selected account is not linked to a NNID or PNID")); + } + else + { + if(NCrypto::OTP_IsPresent() != NCrypto::SEEPROM_IsPresent()) + m_online_status->SetLabel(_("OTP.bin or SEEPROM.bin is missing")); + else if(NCrypto::OTP_IsPresent() && NCrypto::SEEPROM_IsPresent()) + m_online_status->SetLabel(_("OTP and SEEPROM present but no certificate files were found")); + else + m_online_status->SetLabel(_("Online play is not set up. Follow the guide below to get started")); + } + + if(online_fully_valid) { - - m_online_status->SetLabel(_("Your account is a valid online account")); m_validate_online->SetBitmap(wxBITMAP_PNG_FROM_DATA(PNG_CHECK_YES).ConvertToImage().Scale(16, 16)); m_validate_online->SetWindowStyleFlag(m_validate_online->GetWindowStyleFlag() | wxBORDER_NONE); } @@ -1417,7 +1436,28 @@ void GeneralSettings2::UpdateAccountInformation() m_validate_online->SetBitmap(wxBITMAP_PNG_FROM_DATA(PNG_ERROR).ConvertToImage().Scale(16, 16)); m_validate_online->SetWindowStyleFlag(m_validate_online->GetWindowStyleFlag() & ~wxBORDER_NONE); } - + + // enable/disable network service field depending on online requirements + m_active_service->Enable(online_fully_valid && !CafeSystem::IsTitleRunning()); + if(online_fully_valid) + { + NetworkService service = GetConfig().GetAccountNetworkService(account.GetPersistentId()); + m_active_service->SetSelection(static_cast<int>(service)); + // set the config option here for the selected service + // this will guarantee that it's actually written to settings.xml + // allowing us to eventually get rid of the legacy option in the (far) future + GetConfig().SetAccountSelectedService(account.GetPersistentId(), service); + } + else + { + m_active_service->SetSelection(0); // force offline + } + wxString tmp = _("Network service"); + tmp.append(" ("); + tmp.append(wxString::FromUTF8(boost::nowide::narrow(account.GetMiiName()))); + tmp.append(")"); + m_active_service->SetLabel(tmp); + // refresh pane size m_account_grid->InvalidateBestSize(); //m_account_grid->GetParent()->FitInside(); @@ -1663,9 +1703,8 @@ void GeneralSettings2::ApplyConfig() break; } } - - m_online_enabled->SetValue(config.account.online_enabled); - m_active_service->SetSelection(config.account.active_service); + m_active_service->SetSelection((int)config.GetAccountNetworkService(ActiveSettings::GetPersistentId())); + UpdateAccountInformation(); // debug @@ -1673,20 +1712,6 @@ void GeneralSettings2::ApplyConfig() m_gdb_port->SetValue(config.gdb_port.GetValue()); } -void GeneralSettings2::OnOnlineEnable(wxCommandEvent& event) -{ - event.Skip(); - if (!m_online_enabled->GetValue()) - return; - - // show warning if player enables online mode - const auto result = wxMessageBox(_("Please be aware that online mode lets you connect to OFFICIAL servers and therefore there is a risk of getting banned.\nOnly proceed if you are willing to risk losing online access with your Wii U and/or NNID."), - _("Warning"), wxYES_NO | wxCENTRE | wxICON_EXCLAMATION, this); - if (result == wxNO) - m_online_enabled->SetValue(false); -} - - void GeneralSettings2::OnAudioAPISelected(wxCommandEvent& event) { IAudioAPI::AudioAPI api; @@ -1952,6 +1977,9 @@ void GeneralSettings2::OnActiveAccountChanged(wxCommandEvent& event) void GeneralSettings2::OnAccountServiceChanged(wxCommandEvent& event) { + auto& config = GetConfig(); + uint32 peristentId = GetSelectedAccountPersistentId(); + config.SetAccountSelectedService(peristentId, static_cast<NetworkService>(m_active_service->GetSelection())); UpdateAccountInformation(); } @@ -2005,12 +2033,12 @@ void GeneralSettings2::OnShowOnlineValidator(wxCommandEvent& event) err << _("The following error(s) have been found:") << '\n'; if (validator.otp == OnlineValidator::FileState::Missing) - err << _("otp.bin missing in Cemu root directory") << '\n'; + err << _("otp.bin missing in Cemu directory") << '\n'; else if(validator.otp == OnlineValidator::FileState::Corrupted) err << _("otp.bin is invalid") << '\n'; if (validator.seeprom == OnlineValidator::FileState::Missing) - err << _("seeprom.bin missing in Cemu root directory") << '\n'; + err << _("seeprom.bin missing in Cemu directory") << '\n'; else if(validator.seeprom == OnlineValidator::FileState::Corrupted) err << _("seeprom.bin is invalid") << '\n'; @@ -2045,9 +2073,10 @@ void GeneralSettings2::OnShowOnlineValidator(wxCommandEvent& event) wxString GeneralSettings2::GetOnlineAccountErrorMessage(OnlineAccountError error) { - switch (error) { + switch (error) + { case OnlineAccountError::kNoAccountId: - return _("AccountId missing (The account is not connected to a NNID)"); + return _("AccountId missing (The account is not connected to a NNID/PNID)"); case OnlineAccountError::kNoPasswordCached: return _("IsPasswordCacheEnabled is set to false (The remember password option on your Wii U must be enabled for this account before dumping it)"); case OnlineAccountError::kPasswordCacheEmpty: diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index 2846af38..b34c9222 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -71,7 +71,6 @@ private: wxButton* m_create_account, * m_delete_account; wxChoice* m_active_account; wxRadioBox* m_active_service; - wxCheckBox* m_online_enabled; wxCollapsiblePane* m_account_information; wxPropertyGrid* m_account_grid; wxBitmapButton* m_validate_online; @@ -99,10 +98,11 @@ private: void OnMLCPathSelect(wxCommandEvent& event); void OnMLCPathChar(wxKeyEvent& event); void OnShowOnlineValidator(wxCommandEvent& event); - void OnOnlineEnable(wxCommandEvent& event); void OnAccountServiceChanged(wxCommandEvent& event); static wxString GetOnlineAccountErrorMessage(OnlineAccountError error); + uint32 GetSelectedAccountPersistentId(); + // updates cemu audio devices void UpdateAudioDevice(); // refreshes audio device list for dropdown diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c34c5477..097d506e 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -948,38 +948,6 @@ void MainWindow::OnAccountSelect(wxCommandEvent& event) g_config.Save(); } -//void MainWindow::OnConsoleRegion(wxCommandEvent& event) -//{ -// switch (event.GetId()) -// { -// case MAINFRAME_MENU_ID_OPTIONS_REGION_AUTO: -// GetConfig().console_region = ConsoleRegion::Auto; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_JPN: -// GetConfig().console_region = ConsoleRegion::JPN; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_USA: -// GetConfig().console_region = ConsoleRegion::USA; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_EUR: -// GetConfig().console_region = ConsoleRegion::EUR; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_CHN: -// GetConfig().console_region = ConsoleRegion::CHN; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_KOR: -// GetConfig().console_region = ConsoleRegion::KOR; -// break; -// case MAINFRAME_MENU_ID_OPTIONS_REGION_TWN: -// GetConfig().console_region = ConsoleRegion::TWN; -// break; -// default: -// cemu_assert_debug(false); -// } -// -// g_config.Save(); -//} - void MainWindow::OnConsoleLanguage(wxCommandEvent& event) { switch (event.GetId()) From 10d553e1c9ba0b669ee8d4543741eea14725ce24 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Tue, 7 May 2024 11:56:28 +0200 Subject: [PATCH 177/314] zlib125: Implement `deflateInit_` (#1194) --- src/Cafe/OS/libs/zlib125/zlib125.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Cafe/OS/libs/zlib125/zlib125.cpp b/src/Cafe/OS/libs/zlib125/zlib125.cpp index 25df6a9d..aec6e8c3 100644 --- a/src/Cafe/OS/libs/zlib125/zlib125.cpp +++ b/src/Cafe/OS/libs/zlib125/zlib125.cpp @@ -213,6 +213,32 @@ void zlib125Export_inflateReset2(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, r); } +void zlib125Export_deflateInit_(PPCInterpreter_t* hCPU) +{ + ppcDefineParamStructPtr(zstream, z_stream_ppc2, 0); + ppcDefineParamS32(level, 1); + ppcDefineParamStr(version, 2); + ppcDefineParamS32(streamsize, 3); + + z_stream hzs; + zlib125_setupHostZStream(zstream, &hzs, false); + + // setup internal memory allocator if requested + if (zstream->zalloc == nullptr) + zstream->zalloc = PPCInterpreter_makeCallableExportDepr(zlib125_zcalloc); + if (zstream->zfree == nullptr) + zstream->zfree = PPCInterpreter_makeCallableExportDepr(zlib125_zcfree); + + if (streamsize != sizeof(z_stream_ppc2)) + assert_dbg(); + + sint32 r = deflateInit_(&hzs, level, version, sizeof(z_stream)); + + zlib125_setupUpdateZStream(&hzs, zstream); + + osLib_returnFromFunction(hCPU, r); +} + void zlib125Export_deflateInit2_(PPCInterpreter_t* hCPU) { ppcDefineParamStructPtr(zstream, z_stream_ppc2, 0); @@ -345,6 +371,7 @@ namespace zlib osLib_addFunction("zlib125", "inflateReset", zlib125Export_inflateReset); osLib_addFunction("zlib125", "inflateReset2", zlib125Export_inflateReset2); + osLib_addFunction("zlib125", "deflateInit_", zlib125Export_deflateInit_); osLib_addFunction("zlib125", "deflateInit2_", zlib125Export_deflateInit2_); osLib_addFunction("zlib125", "deflateBound", zlib125Export_deflateBound); osLib_addFunction("zlib125", "deflate", zlib125Export_deflate); From b2a6cccc89fd42b63bb718c8e9743cb52fca9008 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Thu, 9 May 2024 12:12:34 +0200 Subject: [PATCH 178/314] nn_act: Implement GetTransferableId (#1197) --- src/Cafe/OS/libs/nn_act/nn_act.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Cafe/OS/libs/nn_act/nn_act.cpp b/src/Cafe/OS/libs/nn_act/nn_act.cpp index f490ff19..f9e74355 100644 --- a/src/Cafe/OS/libs/nn_act/nn_act.cpp +++ b/src/Cafe/OS/libs/nn_act/nn_act.cpp @@ -308,6 +308,22 @@ void nnActExport_GetPrincipalIdEx(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); // ResultSuccess } +void nnActExport_GetTransferableId(PPCInterpreter_t* hCPU) +{ + ppcDefineParamU32(unique, 0); + + cemuLog_logDebug(LogType::Force, "nn_act.GetTransferableId(0x{:08x})", hCPU->gpr[3]); + + uint64 transferableId; + uint32 r = nn::act::GetTransferableIdEx(&transferableId, unique, iosu::act::ACT_SLOT_CURRENT); + if (NN_RESULT_IS_FAILURE(r)) + { + transferableId = 0; + } + + osLib_returnFromFunction64(hCPU, _swapEndianU64(transferableId)); +} + void nnActExport_GetTransferableIdEx(PPCInterpreter_t* hCPU) { ppcDefineParamStructPtr(transferableId, uint64, 0); @@ -691,6 +707,7 @@ void nnAct_load() osLib_addFunction("nn_act", "GetPrincipalId__Q2_2nn3actFv", nnActExport_GetPrincipalId); osLib_addFunction("nn_act", "GetPrincipalIdEx__Q2_2nn3actFPUiUc", nnActExport_GetPrincipalIdEx); // transferable id + osLib_addFunction("nn_act", "GetTransferableId__Q2_2nn3actFUi", nnActExport_GetTransferableId); osLib_addFunction("nn_act", "GetTransferableIdEx__Q2_2nn3actFPULUiUc", nnActExport_GetTransferableIdEx); // persistent id osLib_addFunction("nn_act", "GetPersistentId__Q2_2nn3actFv", nnActExport_GetPersistentId); From 97d8cf4ba330ed671a9b40d8aaab740d7bcbeffb Mon Sep 17 00:00:00 2001 From: Xphalnos <164882787+Xphalnos@users.noreply.github.com> Date: Fri, 10 May 2024 09:32:06 +0200 Subject: [PATCH 179/314] vcpkg: Update libraries (#1198) --- dependencies/vcpkg | 2 +- vcpkg.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies/vcpkg b/dependencies/vcpkg index 53bef899..cbf4a664 160000 --- a/dependencies/vcpkg +++ b/dependencies/vcpkg @@ -1 +1 @@ -Subproject commit 53bef8994c541b6561884a8395ea35715ece75db +Subproject commit cbf4a6641528cee6f172328984576f51698de726 diff --git a/vcpkg.json b/vcpkg.json index 48742b4a..b27a7095 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "name": "cemu", "version-string": "1.0", - "builtin-baseline": "53bef8994c541b6561884a8395ea35715ece75db", + "builtin-baseline": "cbf4a6641528cee6f172328984576f51698de726", "dependencies": [ "pugixml", "zlib", From cf41c3b136ab7272e6801991d081c9d2c69c7143 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 10 May 2024 09:33:32 +0200 Subject: [PATCH 180/314] CI: Use submodule commit of vcpkg --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d188b4a1..a2342c27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,6 @@ jobs: run: | cd dependencies/vcpkg git fetch --unshallow - git checkout 431eb6bda0950874c8d4ed929cc66e15d8aae46f - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} @@ -138,7 +137,6 @@ jobs: run: | cd dependencies/vcpkg git fetch --unshallow - git checkout 431eb6bda0950874c8d4ed929cc66e15d8aae46f - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} @@ -218,7 +216,6 @@ jobs: run: | cd dependencies/vcpkg git fetch --unshallow - git pull --all - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} From 13b90874f9934f0a79a9ab2b9c4e1288ed2e6764 Mon Sep 17 00:00:00 2001 From: splatoon1enjoyer <131005903+splatoon1enjoyer@users.noreply.github.com> Date: Mon, 13 May 2024 14:52:25 +0000 Subject: [PATCH 181/314] Fix commas edge case in strings when parsing an assembly line (#1201) --- src/Cemu/PPCAssembler/ppcAssembler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Cemu/PPCAssembler/ppcAssembler.cpp b/src/Cemu/PPCAssembler/ppcAssembler.cpp index 5bab7b8b..df20b21d 100644 --- a/src/Cemu/PPCAssembler/ppcAssembler.cpp +++ b/src/Cemu/PPCAssembler/ppcAssembler.cpp @@ -2418,6 +2418,9 @@ bool ppcAssembler_assembleSingleInstruction(char const* text, PPCAssemblerInOut* _ppcAssembler_translateAlias(instructionName); // parse operands internalInfo.listOperandStr.clear(); + + bool isInString = false; + while (currentPtr < endPtr) { currentPtr++; @@ -2425,7 +2428,10 @@ bool ppcAssembler_assembleSingleInstruction(char const* text, PPCAssemblerInOut* // find end of operand while (currentPtr < endPtr) { - if (*currentPtr == ',') + if (*currentPtr == '"') + isInString=!isInString; + + if (*currentPtr == ',' && !isInString) break; currentPtr++; } From 84e78088fb2d3d25797032fe963967aa2d1b5af0 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 4 May 2024 14:46:12 +0200 Subject: [PATCH 182/314] PPCCoreCallback: Add support for stack args if GPR limit is reached --- src/Cafe/HW/Espresso/PPCCallback.h | 37 ++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Cafe/HW/Espresso/PPCCallback.h b/src/Cafe/HW/Espresso/PPCCallback.h index 19fcd4d1..3d5393b1 100644 --- a/src/Cafe/HW/Espresso/PPCCallback.h +++ b/src/Cafe/HW/Espresso/PPCCallback.h @@ -5,8 +5,28 @@ struct PPCCoreCallbackData_t { sint32 gprCount = 0; sint32 floatCount = 0; + sint32 stackCount = 0; }; +inline void _PPCCoreCallback_writeGPRArg(PPCCoreCallbackData_t& data, PPCInterpreter_t* hCPU, uint32 value) +{ + if (data.gprCount < 8) + { + hCPU->gpr[3 + data.gprCount] = value; + data.gprCount++; + } + else + { + uint32 stackOffset = 8 + data.stackCount * 4; + + // PPCCore_executeCallbackInternal does -16*4 to save the current stack area + stackOffset -= 16 * 4; + + memory_writeU32(hCPU->gpr[1] + stackOffset, value); + data.stackCount++; + } +} + // callback functions inline uint32 PPCCoreCallback(MPTR function, const PPCCoreCallbackData_t& data) { @@ -16,23 +36,21 @@ inline uint32 PPCCoreCallback(MPTR function, const PPCCoreCallbackData_t& data) template <typename T, typename... TArgs> uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg, TArgs... args) { - cemu_assert_debug(data.gprCount <= 8); - cemu_assert_debug(data.floatCount <= 8); + // TODO float arguments on stack + cemu_assert_debug(data.floatCount < 8); + PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); if constexpr (std::is_pointer_v<T>) { - hCPU->gpr[3 + data.gprCount] = MEMPTR(currentArg).GetMPTR(); - data.gprCount++; + _PPCCoreCallback_writeGPRArg(data, hCPU, MEMPTR(currentArg).GetMPTR()); } else if constexpr (std::is_base_of_v<MEMPTRBase, std::remove_reference_t<T>>) { - hCPU->gpr[3 + data.gprCount] = currentArg.GetMPTR(); - data.gprCount++; + _PPCCoreCallback_writeGPRArg(data, hCPU, currentArg.GetMPTR()); } else if constexpr (std::is_reference_v<T>) { - hCPU->gpr[3 + data.gprCount] = MEMPTR(¤tArg).GetMPTR(); - data.gprCount++; + _PPCCoreCallback_writeGPRArg(data, hCPU, MEMPTR(¤tArg).GetMPTR()); } else if constexpr(std::is_enum_v<T>) { @@ -53,8 +71,7 @@ uint32 PPCCoreCallback(MPTR function, PPCCoreCallbackData_t& data, T currentArg, } else { - hCPU->gpr[3 + data.gprCount] = (uint32)currentArg; - data.gprCount++; + _PPCCoreCallback_writeGPRArg(data, hCPU, (uint32)currentArg); } return PPCCoreCallback(function, data, args...); From 1c6b209692953bcf5a958499ba3ebba0e24d5c6f Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 4 May 2024 14:49:23 +0200 Subject: [PATCH 183/314] Add initial ntag and nfc implementation --- src/Cafe/CMakeLists.txt | 14 + src/Cafe/CafeSystem.cpp | 6 + src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp | 406 +++++++++++++++++ src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h | 31 ++ src/Cafe/OS/libs/nfc/TLV.cpp | 139 ++++++ src/Cafe/OS/libs/nfc/TLV.h | 37 ++ src/Cafe/OS/libs/nfc/TagV0.cpp | 301 +++++++++++++ src/Cafe/OS/libs/nfc/TagV0.h | 39 ++ src/Cafe/OS/libs/nfc/ndef.cpp | 277 ++++++++++++ src/Cafe/OS/libs/nfc/ndef.h | 88 ++++ src/Cafe/OS/libs/nfc/nfc.cpp | 596 +++++++++++++++++++++++++ src/Cafe/OS/libs/nfc/nfc.h | 62 +++ src/Cafe/OS/libs/nfc/stream.cpp | 201 +++++++++ src/Cafe/OS/libs/nfc/stream.h | 139 ++++++ src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp | 83 ++-- src/Cafe/OS/libs/nn_nfp/nn_nfp.h | 8 +- src/Cafe/OS/libs/ntag/ntag.cpp | 438 ++++++++++++++++++ src/Cafe/OS/libs/ntag/ntag.h | 94 ++++ src/Cemu/Logging/CemuLogging.cpp | 2 + src/Cemu/Logging/CemuLogging.h | 3 + src/gui/MainWindow.cpp | 10 +- 21 files changed, 2927 insertions(+), 47 deletions(-) create mode 100644 src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp create mode 100644 src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h create mode 100644 src/Cafe/OS/libs/nfc/TLV.cpp create mode 100644 src/Cafe/OS/libs/nfc/TLV.h create mode 100644 src/Cafe/OS/libs/nfc/TagV0.cpp create mode 100644 src/Cafe/OS/libs/nfc/TagV0.h create mode 100644 src/Cafe/OS/libs/nfc/ndef.cpp create mode 100644 src/Cafe/OS/libs/nfc/ndef.h create mode 100644 src/Cafe/OS/libs/nfc/nfc.cpp create mode 100644 src/Cafe/OS/libs/nfc/nfc.h create mode 100644 src/Cafe/OS/libs/nfc/stream.cpp create mode 100644 src/Cafe/OS/libs/nfc/stream.h create mode 100644 src/Cafe/OS/libs/ntag/ntag.cpp create mode 100644 src/Cafe/OS/libs/ntag/ntag.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 851854fc..b5090dcf 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -218,6 +218,8 @@ add_library(CemuCafe HW/SI/SI.cpp HW/SI/si.h HW/VI/VI.cpp + IOSU/ccr_nfc/iosu_ccr_nfc.cpp + IOSU/ccr_nfc/iosu_ccr_nfc.h IOSU/fsa/fsa_types.h IOSU/fsa/iosu_fsa.cpp IOSU/fsa/iosu_fsa.h @@ -378,6 +380,16 @@ add_library(CemuCafe OS/libs/h264_avc/parser/H264Parser.h OS/libs/mic/mic.cpp OS/libs/mic/mic.h + OS/libs/nfc/ndef.cpp + OS/libs/nfc/ndef.h + OS/libs/nfc/nfc.cpp + OS/libs/nfc/nfc.h + OS/libs/nfc/stream.cpp + OS/libs/nfc/stream.h + OS/libs/nfc/TagV0.cpp + OS/libs/nfc/TagV0.h + OS/libs/nfc/TLV.cpp + OS/libs/nfc/TLV.h OS/libs/nlibcurl/nlibcurl.cpp OS/libs/nlibcurl/nlibcurlDebug.hpp OS/libs/nlibcurl/nlibcurl.h @@ -453,6 +465,8 @@ add_library(CemuCafe OS/libs/nsyskbd/nsyskbd.h OS/libs/nsysnet/nsysnet.cpp OS/libs/nsysnet/nsysnet.h + OS/libs/ntag/ntag.cpp + OS/libs/ntag/ntag.h OS/libs/padscore/padscore.cpp OS/libs/padscore/padscore.h OS/libs/proc_ui/proc_ui.cpp diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 3c62a686..958a5a57 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -35,6 +35,7 @@ #include "Cafe/IOSU/legacy/iosu_boss.h" #include "Cafe/IOSU/legacy/iosu_nim.h" #include "Cafe/IOSU/PDM/iosu_pdm.h" +#include "Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h" // IOSU initializer functions #include "Cafe/IOSU/kernel/iosu_kernel.h" @@ -51,6 +52,8 @@ #include "Cafe/OS/libs/gx2/GX2.h" #include "Cafe/OS/libs/gx2/GX2_Misc.h" #include "Cafe/OS/libs/mic/mic.h" +#include "Cafe/OS/libs/nfc/nfc.h" +#include "Cafe/OS/libs/ntag/ntag.h" #include "Cafe/OS/libs/nn_aoc/nn_aoc.h" #include "Cafe/OS/libs/nn_pdm/nn_pdm.h" #include "Cafe/OS/libs/nn_cmpt/nn_cmpt.h" @@ -533,6 +536,7 @@ namespace CafeSystem iosu::acp::GetModule(), iosu::fpd::GetModule(), iosu::pdm::GetModule(), + iosu::ccr_nfc::GetModule(), }; // initialize all subsystems which are persistent and don't depend on a game running @@ -587,6 +591,8 @@ namespace CafeSystem H264::Initialize(); snd_core::Initialize(); mic::Initialize(); + nfc::Initialize(); + ntag::Initialize(); // init hardware register interfaces HW_SI::Initialize(); } diff --git a/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp new file mode 100644 index 00000000..ff8ba2b1 --- /dev/null +++ b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp @@ -0,0 +1,406 @@ +#include "iosu_ccr_nfc.h" +#include "Cafe/IOSU/kernel/iosu_kernel.h" +#include "util/crypto/aes128.h" +#include <openssl/evp.h> +#include <openssl/hmac.h> + +namespace iosu +{ + namespace ccr_nfc + { + IOSMsgQueueId sCCRNFCMsgQueue; + SysAllocator<iosu::kernel::IOSMessage, 0x20> sCCRNFCMsgQueueMsgBuffer; + std::thread sCCRNFCThread; + + constexpr uint8 sNfcKey[] = { 0xC1, 0x2B, 0x07, 0x10, 0xD7, 0x2C, 0xEB, 0x5D, 0x43, 0x49, 0xB7, 0x43, 0xE3, 0xCA, 0xD2, 0x24 }; + constexpr uint8 sNfcKeyIV[] = { 0x4F, 0xD3, 0x9A, 0x6E, 0x79, 0xFC, 0xEA, 0xAD, 0x99, 0x90, 0x4D, 0xB8, 0xEE, 0x38, 0xE9, 0xDB }; + + constexpr uint8 sUnfixedInfosMagicBytes[] = { 0x00, 0x00, 0xDB, 0x4B, 0x9E, 0x3F, 0x45, 0x27, 0x8F, 0x39, 0x7E, 0xFF, 0x9B, 0x4F, 0xB9, 0x93 }; + constexpr uint8 sLockedSecretMagicBytes[] = { 0xFD, 0xC8, 0xA0, 0x76, 0x94, 0xB8, 0x9E, 0x4C, 0x47, 0xD3, 0x7D, 0xE8, 0xCE, 0x5C, 0x74, 0xC1 }; + constexpr uint8 sUnfixedInfosString[] = { 0x75, 0x6E, 0x66, 0x69, 0x78, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x66, 0x6F, 0x73, 0x00, 0x00, 0x00 }; + constexpr uint8 sLockedSecretString[] = { 0x6C, 0x6F, 0x63, 0x6B, 0x65, 0x64, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x00, 0x00, 0x00 }; + + constexpr uint8 sLockedSecretHmacKey[] = { 0x7F, 0x75, 0x2D, 0x28, 0x73, 0xA2, 0x00, 0x17, 0xFE, 0xF8, 0x5C, 0x05, 0x75, 0x90, 0x4B, 0x6D }; + constexpr uint8 sUnfixedInfosHmacKey[] = { 0x1D, 0x16, 0x4B, 0x37, 0x5B, 0x72, 0xA5, 0x57, 0x28, 0xB9, 0x1D, 0x64, 0xB6, 0xA3, 0xC2, 0x05 }; + + uint8 sLockedSecretInternalKey[0x10]; + uint8 sLockedSecretInternalNonce[0x10]; + uint8 sLockedSecretInternalHmacKey[0x10]; + + uint8 sUnfixedInfosInternalKey[0x10]; + uint8 sUnfixedInfosInternalNonce[0x10]; + uint8 sUnfixedInfosInternalHmacKey[0x10]; + + sint32 __CCRNFCValidateCryptData(CCRNFCCryptData* data, uint32 size, bool validateOffsets) + { + if (!data) + { + return CCR_NFC_ERROR; + } + + if (size != sizeof(CCRNFCCryptData)) + { + return CCR_NFC_ERROR; + } + + if (!validateOffsets) + { + return 0; + } + + // Make sure all offsets are within bounds + if (data->version == 0) + { + if (data->unfixedInfosHmacOffset < 0x1C9 && data->unfixedInfosOffset < 0x1C9 && + data->lockedSecretHmacOffset < 0x1C9 && data->lockedSecretOffset < 0x1C9 && + data->lockedSecretSize < 0x1C9 && data->unfixedInfosSize < 0x1C9) + { + return 0; + } + } + else if (data->version == 2) + { + if (data->unfixedInfosHmacOffset < 0x21D && data->unfixedInfosOffset < 0x21D && + data->lockedSecretHmacOffset < 0x21D && data->lockedSecretOffset < 0x21D && + data->lockedSecretSize < 0x21D && data->unfixedInfosSize < 0x21D) + { + return 0; + } + } + + return CCR_NFC_ERROR; + } + + sint32 CCRNFCAESCTRCrypt(const uint8* key, const void* ivNonce, const void* inData, uint32_t inSize, void* outData, uint32_t outSize) + { + uint8_t tmpIv[0x10]; + memcpy(tmpIv, ivNonce, sizeof(tmpIv)); + + memcpy(outData, inData, inSize); + AES128CTR_transform((uint8*)outData, outSize, (uint8*)key, tmpIv); + return 0; + } + + sint32 __CCRNFCGenerateKey(const uint8* hmacKey, uint32 hmacKeySize, const uint8* name, uint32_t nameSize, const uint8* inData, uint32_t inSize, uint8* outData, uint32_t outSize) + { + if (nameSize != 0xe || outSize != 0x40) + { + return CCR_NFC_ERROR; + } + + // Create a buffer containing 2 counter bytes, the key name, and the key data + uint8_t buffer[0x50]; + buffer[0] = 0; + buffer[1] = 0; + memcpy(buffer + 2, name, nameSize); + memcpy(buffer + nameSize + 2, inData, inSize); + + uint16_t counter = 0; + while (outSize > 0) + { + // Set counter bytes and increment counter + buffer[0] = (counter >> 8) & 0xFF; + buffer[1] = counter & 0xFF; + counter++; + + uint32 dataSize = outSize; + if (!HMAC(EVP_sha256(), hmacKey, hmacKeySize, buffer, sizeof(buffer), outData, &dataSize)) + { + return CCR_NFC_ERROR; + } + + outSize -= 0x20; + outData += 0x20; + } + + return 0; + } + + sint32 __CCRNFCGenerateInternalKeys(const CCRNFCCryptData* in, const uint8* keyGenSalt) + { + uint8_t lockedSecretBuffer[0x40] = { 0 }; + uint8_t unfixedInfosBuffer[0x40] = { 0 }; + uint8_t outBuffer[0x40] = { 0 }; + + // Fill the locked secret buffer + memcpy(lockedSecretBuffer, sLockedSecretMagicBytes, sizeof(sLockedSecretMagicBytes)); + if (in->version == 0) + { + // For Version 0 this is the 16-byte Format Info + memcpy(lockedSecretBuffer + 0x10, in->data + in->uuidOffset, 0x10); + } + else if (in->version == 2) + { + // For Version 2 this is 2 times the 7-byte UID + 1 check byte + memcpy(lockedSecretBuffer + 0x10, in->data + in->uuidOffset, 8); + memcpy(lockedSecretBuffer + 0x18, in->data + in->uuidOffset, 8); + } + else + { + return CCR_NFC_ERROR; + } + // Append key generation salt + memcpy(lockedSecretBuffer + 0x20, keyGenSalt, 0x20); + + // Generate the key output + sint32 res = __CCRNFCGenerateKey(sLockedSecretHmacKey, sizeof(sLockedSecretHmacKey), sLockedSecretString, 0xe, lockedSecretBuffer, sizeof(lockedSecretBuffer), outBuffer, sizeof(outBuffer)); + if (res != 0) + { + return res; + } + + // Unpack the key buffer + memcpy(sLockedSecretInternalKey, outBuffer, 0x10); + memcpy(sLockedSecretInternalNonce, outBuffer + 0x10, 0x10); + memcpy(sLockedSecretInternalHmacKey, outBuffer + 0x20, 0x10); + + // Fill the unfixed infos buffer + memcpy(unfixedInfosBuffer, in->data + in->seedOffset, 2); + memcpy(unfixedInfosBuffer + 2, sUnfixedInfosMagicBytes + 2, 0xe); + if (in->version == 0) + { + // For Version 0 this is the 16-byte Format Info + memcpy(unfixedInfosBuffer + 0x10, in->data + in->uuidOffset, 0x10); + } + else if (in->version == 2) + { + // For Version 2 this is 2 times the 7-byte UID + 1 check byte + memcpy(unfixedInfosBuffer + 0x10, in->data + in->uuidOffset, 8); + memcpy(unfixedInfosBuffer + 0x18, in->data + in->uuidOffset, 8); + } + else + { + return CCR_NFC_ERROR; + } + // Append key generation salt + memcpy(unfixedInfosBuffer + 0x20, keyGenSalt, 0x20); + + // Generate the key output + res = __CCRNFCGenerateKey(sUnfixedInfosHmacKey, sizeof(sUnfixedInfosHmacKey), sUnfixedInfosString, 0xe, unfixedInfosBuffer, sizeof(unfixedInfosBuffer), outBuffer, sizeof(outBuffer)); + if (res != 0) + { + return res; + } + + // Unpack the key buffer + memcpy(sUnfixedInfosInternalKey, outBuffer, 0x10); + memcpy(sUnfixedInfosInternalNonce, outBuffer + 0x10, 0x10); + memcpy(sUnfixedInfosInternalHmacKey, outBuffer + 0x20, 0x10); + + return 0; + } + + sint32 __CCRNFCCryptData(const CCRNFCCryptData* in, CCRNFCCryptData* out, bool decrypt) + { + // Decrypt key generation salt + uint8_t keyGenSalt[0x20]; + sint32 res = CCRNFCAESCTRCrypt(sNfcKey, sNfcKeyIV, in->data + in->keyGenSaltOffset, 0x20, keyGenSalt, sizeof(keyGenSalt)); + if (res != 0) + { + return res; + } + + // Prepare internal keys + res = __CCRNFCGenerateInternalKeys(in, keyGenSalt); + if (res != 0) + { + return res; + } + + if (decrypt) + { + // Only version 0 tags have an encrypted locked secret area + if (in->version == 0) + { + res = CCRNFCAESCTRCrypt(sLockedSecretInternalKey, sLockedSecretInternalNonce, in->data + in->lockedSecretOffset, in->lockedSecretSize, out->data + in->lockedSecretOffset, in->lockedSecretSize); + if (res != 0) + { + return res; + } + } + + // Decrypt unfxied infos + res = CCRNFCAESCTRCrypt(sUnfixedInfosInternalKey, sUnfixedInfosInternalNonce, in->data + in->unfixedInfosOffset, in->unfixedInfosSize, out->data + in->unfixedInfosOffset, in->unfixedInfosSize); + if (res != 0) + { + return res; + } + + // Verify HMACs + uint8_t hmacBuffer[0x20]; + uint32 hmacLen = sizeof(hmacBuffer); + + if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen)) + { + return CCR_NFC_ERROR; + } + + if (memcmp(in->data + in->lockedSecretHmacOffset, hmacBuffer, 0x20) != 0) + { + return CCR_NFC_INVALID_LOCKED_SECRET; + } + + if (in->version == 0) + { + hmacLen = sizeof(hmacBuffer); + res = HMAC(EVP_sha256(), sUnfixedInfosInternalHmacKey, sizeof(sUnfixedInfosInternalHmacKey), out->data + in->unfixedInfosHmacOffset + 0x20, (in->dataSize - in->unfixedInfosHmacOffset) - 0x20, hmacBuffer, &hmacLen) ? 0 : CCR_NFC_ERROR; + } + else + { + hmacLen = sizeof(hmacBuffer); + res = HMAC(EVP_sha256(), sUnfixedInfosInternalHmacKey, sizeof(sUnfixedInfosInternalHmacKey), out->data + in->unfixedInfosHmacOffset + 0x21, (in->dataSize - in->unfixedInfosHmacOffset) - 0x21, hmacBuffer, &hmacLen) ? 0 : CCR_NFC_ERROR; + } + + if (memcmp(in->data + in->unfixedInfosHmacOffset, hmacBuffer, 0x20) != 0) + { + return CCR_NFC_INVALID_UNFIXED_INFOS; + } + } + else + { + uint8_t hmacBuffer[0x20]; + uint32 hmacLen = sizeof(hmacBuffer); + + if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen)) + { + return CCR_NFC_ERROR; + } + + if (memcmp(in->data + in->lockedSecretHmacOffset, hmacBuffer, 0x20) != 0) + { + return CCR_NFC_INVALID_LOCKED_SECRET; + } + + // Only version 0 tags have an encrypted locked secret area + if (in->version == 0) + { + uint32 hmacLen = 0x20; + if (!HMAC(EVP_sha256(), sUnfixedInfosInternalHmacKey, sizeof(sUnfixedInfosInternalHmacKey), out->data + in->unfixedInfosHmacOffset + 0x20, (in->dataSize - in->unfixedInfosHmacOffset) - 0x20, out->data + in->unfixedInfosHmacOffset, &hmacLen)) + { + return CCR_NFC_ERROR; + } + + res = CCRNFCAESCTRCrypt(sLockedSecretInternalKey, sLockedSecretInternalNonce, in->data + in->lockedSecretOffset, in->lockedSecretSize, out->data + in->lockedSecretOffset, in->lockedSecretSize); + if (res != 0) + { + return res; + } + } + else + { + uint32 hmacLen = 0x20; + if (!HMAC(EVP_sha256(), sUnfixedInfosInternalHmacKey, sizeof(sUnfixedInfosInternalHmacKey), out->data + in->unfixedInfosHmacOffset + 0x21, (in->dataSize - in->unfixedInfosHmacOffset) - 0x21, out->data + in->unfixedInfosHmacOffset, &hmacLen)) + { + return CCR_NFC_ERROR; + } + } + + res = CCRNFCAESCTRCrypt(sUnfixedInfosInternalKey, sUnfixedInfosInternalNonce, in->data + in->unfixedInfosOffset, in->unfixedInfosSize, out->data + in->unfixedInfosOffset, in->unfixedInfosSize); + if (res != 0) + { + return res; + } + } + + return res; + } + + void CCRNFCThread() + { + iosu::kernel::IOSMessage msg; + while (true) + { + IOS_ERROR error = iosu::kernel::IOS_ReceiveMessage(sCCRNFCMsgQueue, &msg, 0); + cemu_assert(!IOS_ResultIsError(error)); + + // Check for system exit + if (msg == 0xf00dd00d) + { + return; + } + + IPCCommandBody* cmd = MEMPTR<IPCCommandBody>(msg).GetPtr(); + if (cmd->cmdId == IPCCommandId::IOS_OPEN) + { + iosu::kernel::IOS_ResourceReply(cmd, IOS_ERROR_OK); + } + else if (cmd->cmdId == IPCCommandId::IOS_CLOSE) + { + iosu::kernel::IOS_ResourceReply(cmd, IOS_ERROR_OK); + } + else if (cmd->cmdId == IPCCommandId::IOS_IOCTL) + { + sint32 result; + uint32 requestId = cmd->args[0]; + void* ptrIn = MEMPTR<void>(cmd->args[1]); + uint32 sizeIn = cmd->args[2]; + void* ptrOut = MEMPTR<void>(cmd->args[3]); + uint32 sizeOut = cmd->args[4]; + + if ((result = __CCRNFCValidateCryptData(static_cast<CCRNFCCryptData*>(ptrIn), sizeIn, true)) == 0 && + (result = __CCRNFCValidateCryptData(static_cast<CCRNFCCryptData*>(ptrOut), sizeOut, false)) == 0) + { + // Initialize outData with inData + memcpy(ptrOut, ptrIn, sizeIn); + + switch (requestId) + { + case 1: // encrypt + result = __CCRNFCCryptData(static_cast<CCRNFCCryptData*>(ptrIn), static_cast<CCRNFCCryptData*>(ptrOut), false); + break; + case 2: // decrypt + result = __CCRNFCCryptData(static_cast<CCRNFCCryptData*>(ptrIn), static_cast<CCRNFCCryptData*>(ptrOut), true); + break; + default: + cemuLog_log(LogType::Force, "/dev/ccr_nfc: Unsupported IOCTL requestId"); + cemu_assert_suspicious(); + result = IOS_ERROR_INVALID; + break; + } + } + + iosu::kernel::IOS_ResourceReply(cmd, static_cast<IOS_ERROR>(result)); + } + else + { + cemuLog_log(LogType::Force, "/dev/ccr_nfc: Unsupported IPC cmdId"); + cemu_assert_suspicious(); + iosu::kernel::IOS_ResourceReply(cmd, IOS_ERROR_INVALID); + } + } + } + + class : public ::IOSUModule + { + void SystemLaunch() override + { + sCCRNFCMsgQueue = iosu::kernel::IOS_CreateMessageQueue(sCCRNFCMsgQueueMsgBuffer.GetPtr(), sCCRNFCMsgQueueMsgBuffer.GetCount()); + cemu_assert(!IOS_ResultIsError(static_cast<IOS_ERROR>(sCCRNFCMsgQueue))); + + IOS_ERROR error = iosu::kernel::IOS_RegisterResourceManager("/dev/ccr_nfc", sCCRNFCMsgQueue); + cemu_assert(!IOS_ResultIsError(error)); + + sCCRNFCThread = std::thread(CCRNFCThread); + } + + void SystemExit() override + { + if (sCCRNFCMsgQueue < 0) + { + return; + } + + iosu::kernel::IOS_SendMessage(sCCRNFCMsgQueue, 0xf00dd00d, 0); + sCCRNFCThread.join(); + + iosu::kernel::IOS_DestroyMessageQueue(sCCRNFCMsgQueue); + sCCRNFCMsgQueue = -1; + } + } sIOSUModuleCCRNFC; + + IOSUModule* GetModule() + { + return &sIOSUModuleCCRNFC; + } + } +} diff --git a/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h new file mode 100644 index 00000000..ae99d645 --- /dev/null +++ b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h @@ -0,0 +1,31 @@ +#pragma once +#include "Cafe/IOSU/iosu_types_common.h" + +#define CCR_NFC_ERROR (-0x2F001E) +#define CCR_NFC_INVALID_LOCKED_SECRET (-0x2F0029) +#define CCR_NFC_INVALID_UNFIXED_INFOS (-0x2F002A) + +namespace iosu +{ + namespace ccr_nfc + { + struct CCRNFCCryptData + { + uint32 version; + uint32 dataSize; + uint32 seedOffset; + uint32 keyGenSaltOffset; + uint32 uuidOffset; + uint32 unfixedInfosOffset; + uint32 unfixedInfosSize; + uint32 lockedSecretOffset; + uint32 lockedSecretSize; + uint32 unfixedInfosHmacOffset; + uint32 lockedSecretHmacOffset; + uint8 data[540]; + }; + static_assert(sizeof(CCRNFCCryptData) == 0x248); + + IOSUModule* GetModule(); + } +} diff --git a/src/Cafe/OS/libs/nfc/TLV.cpp b/src/Cafe/OS/libs/nfc/TLV.cpp new file mode 100644 index 00000000..99536428 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/TLV.cpp @@ -0,0 +1,139 @@ +#include "TLV.h" +#include "stream.h" + +#include <cassert> + +TLV::TLV() +{ +} + +TLV::TLV(Tag tag, std::vector<std::byte> value) + : mTag(tag), mValue(std::move(value)) +{ +} + +TLV::~TLV() +{ +} + +std::vector<TLV> TLV::FromBytes(const std::span<std::byte>& data) +{ + bool hasTerminator = false; + std::vector<TLV> tlvs; + SpanStream stream(data, std::endian::big); + + while (stream.GetRemaining() > 0 && !hasTerminator) + { + // Read the tag + uint8_t byte; + stream >> byte; + Tag tag = static_cast<Tag>(byte); + + switch (tag) + { + case TLV::TAG_NULL: + // Don't need to do anything for NULL tags + break; + + case TLV::TAG_TERMINATOR: + tlvs.emplace_back(tag, std::vector<std::byte>{}); + hasTerminator = true; + break; + + default: + { + // Read the length + uint16_t length; + stream >> byte; + length = byte; + + // If the length is 0xff, 2 bytes with length follow + if (length == 0xff) { + stream >> length; + } + + std::vector<std::byte> value; + value.resize(length); + stream.Read(value); + + tlvs.emplace_back(tag, value); + break; + } + } + + if (stream.GetError() != Stream::ERROR_OK) + { + cemuLog_log(LogType::Force, "Error: TLV parsing read past end of stream"); + // Clear tlvs to prevent further havoc while parsing ndef data + tlvs.clear(); + break; + } + } + + // This seems to be okay, at least NTAGs don't add a terminator tag + // if (!hasTerminator) + // { + // cemuLog_log(LogType::Force, "Warning: TLV parsing reached end of stream without terminator tag"); + // } + + return tlvs; +} + +std::vector<std::byte> TLV::ToBytes() const +{ + std::vector<std::byte> bytes; + VectorStream stream(bytes, std::endian::big); + + // Write tag + stream << std::uint8_t(mTag); + + switch (mTag) + { + case TLV::TAG_NULL: + case TLV::TAG_TERMINATOR: + // Nothing to do here + break; + + default: + { + // Write length (decide if as a 8-bit or 16-bit value) + if (mValue.size() >= 0xff) + { + stream << std::uint8_t(0xff); + stream << std::uint16_t(mValue.size()); + } + else + { + stream << std::uint8_t(mValue.size()); + } + + // Write value + stream.Write(mValue); + } + } + + return bytes; +} + +TLV::Tag TLV::GetTag() const +{ + return mTag; +} + +const std::vector<std::byte>& TLV::GetValue() const +{ + return mValue; +} + +void TLV::SetTag(Tag tag) +{ + mTag = tag; +} + +void TLV::SetValue(const std::span<const std::byte>& value) +{ + // Can only write max 16-bit lengths into TLV + cemu_assert(value.size() < 0x10000); + + mValue.assign(value.begin(), value.end()); +} diff --git a/src/Cafe/OS/libs/nfc/TLV.h b/src/Cafe/OS/libs/nfc/TLV.h new file mode 100644 index 00000000..f582128f --- /dev/null +++ b/src/Cafe/OS/libs/nfc/TLV.h @@ -0,0 +1,37 @@ +#pragma once + +#include <cstdint> +#include <span> +#include <vector> + +class TLV +{ +public: + enum Tag + { + TAG_NULL = 0x00, + TAG_LOCK_CTRL = 0x01, + TAG_MEM_CTRL = 0x02, + TAG_NDEF = 0x03, + TAG_PROPRIETARY = 0xFD, + TAG_TERMINATOR = 0xFE, + }; + +public: + TLV(); + TLV(Tag tag, std::vector<std::byte> value); + virtual ~TLV(); + + static std::vector<TLV> FromBytes(const std::span<std::byte>& data); + std::vector<std::byte> ToBytes() const; + + Tag GetTag() const; + const std::vector<std::byte>& GetValue() const; + + void SetTag(Tag tag); + void SetValue(const std::span<const std::byte>& value); + +private: + Tag mTag; + std::vector<std::byte> mValue; +}; diff --git a/src/Cafe/OS/libs/nfc/TagV0.cpp b/src/Cafe/OS/libs/nfc/TagV0.cpp new file mode 100644 index 00000000..8b5a8143 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/TagV0.cpp @@ -0,0 +1,301 @@ +#include "TagV0.h" +#include "TLV.h" + +#include <algorithm> + +namespace +{ + +constexpr std::size_t kTagSize = 512u; +constexpr std::size_t kMaxBlockCount = kTagSize / sizeof(TagV0::Block); + +constexpr std::uint8_t kLockbyteBlock0 = 0xe; +constexpr std::uint8_t kLockbytesStart0 = 0x0; +constexpr std::uint8_t kLockbytesEnd0 = 0x2; +constexpr std::uint8_t kLockbyteBlock1 = 0xf; +constexpr std::uint8_t kLockbytesStart1 = 0x2; +constexpr std::uint8_t kLockbytesEnd1 = 0x8; + +constexpr std::uint8_t kNDEFMagicNumber = 0xe1; + +// These blocks are not part of the locked area +constexpr bool IsBlockLockedOrReserved(std::uint8_t blockIdx) +{ + // Block 0 is the UID + if (blockIdx == 0x0) + { + return true; + } + + // Block 0xd is reserved + if (blockIdx == 0xd) + { + return true; + } + + // Block 0xe and 0xf contains lock / reserved bytes + if (blockIdx == 0xe || blockIdx == 0xf) + { + return true; + } + + return false; +} + +} // namespace + +TagV0::TagV0() +{ +} + +TagV0::~TagV0() +{ +} + +std::shared_ptr<TagV0> TagV0::FromBytes(const std::span<const std::byte>& data) +{ + // Version 0 tags need at least 512 bytes + if (data.size() != kTagSize) + { + cemuLog_log(LogType::Force, "Error: Version 0 tags should be {} bytes in size", kTagSize); + return {}; + } + + std::shared_ptr<TagV0> tag = std::make_shared<TagV0>(); + + // Parse the locked area before continuing + if (!tag->ParseLockedArea(data)) + { + cemuLog_log(LogType::Force, "Error: Failed to parse locked area"); + return {}; + } + + // Now that the locked area is known, parse the data area + std::vector<std::byte> dataArea; + if (!tag->ParseDataArea(data, dataArea)) + { + cemuLog_log(LogType::Force, "Error: Failed to parse data area"); + return {}; + } + + // The first few bytes in the dataArea make up the capability container + std::copy_n(dataArea.begin(), tag->mCapabilityContainer.size(), std::as_writable_bytes(std::span(tag->mCapabilityContainer)).begin()); + if (!tag->ValidateCapabilityContainer()) + { + cemuLog_log(LogType::Force, "Error: Failed to validate capability container"); + return {}; + } + + // The rest of the dataArea contains the TLVs + tag->mTLVs = TLV::FromBytes(std::span(dataArea).subspan(tag->mCapabilityContainer.size())); + if (tag->mTLVs.empty()) + { + cemuLog_log(LogType::Force, "Error: Tag contains no TLVs"); + return {}; + } + + // Look for the NDEF tlv + tag->mNdefTlvIdx = static_cast<size_t>(-1); + for (std::size_t i = 0; i < tag->mTLVs.size(); i++) + { + if (tag->mTLVs[i].GetTag() == TLV::TAG_NDEF) + { + tag->mNdefTlvIdx = i; + break; + } + } + + if (tag->mNdefTlvIdx == static_cast<size_t>(-1)) + { + cemuLog_log(LogType::Force, "Error: Tag contains no NDEF TLV"); + return {}; + } + + // Append locked data + for (const auto& [key, value] : tag->mLockedBlocks) + { + tag->mLockedArea.insert(tag->mLockedArea.end(), value.begin(), value.end()); + } + + return tag; +} + +std::vector<std::byte> TagV0::ToBytes() const +{ + std::vector<std::byte> bytes(kTagSize); + + // Insert locked or reserved blocks + for (const auto& [key, value] : mLockedOrReservedBlocks) + { + std::copy(value.begin(), value.end(), bytes.begin() + key * sizeof(Block)); + } + + // Insert locked area + auto lockedDataIterator = mLockedArea.begin(); + for (const auto& [key, value] : mLockedBlocks) + { + std::copy_n(lockedDataIterator, sizeof(Block), bytes.begin() + key * sizeof(Block)); + lockedDataIterator += sizeof(Block); + } + + // Pack the dataArea into a linear buffer + std::vector<std::byte> dataArea; + const auto ccBytes = std::as_bytes(std::span(mCapabilityContainer)); + dataArea.insert(dataArea.end(), ccBytes.begin(), ccBytes.end()); + for (const TLV& tlv : mTLVs) + { + const auto tlvBytes = tlv.ToBytes(); + dataArea.insert(dataArea.end(), tlvBytes.begin(), tlvBytes.end()); + } + + // Make sure the dataArea is block size aligned + dataArea.resize((dataArea.size() + (sizeof(Block)-1)) & ~(sizeof(Block)-1)); + + // The rest will be the data area + auto dataIterator = dataArea.begin(); + for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) + { + // All blocks which aren't locked make up the dataArea + if (!IsBlockLocked(currentBlock)) + { + std::copy_n(dataIterator, sizeof(Block), bytes.begin() + currentBlock * sizeof(Block)); + dataIterator += sizeof(Block); + } + } + + return bytes; +} + +const TagV0::Block& TagV0::GetUIDBlock() const +{ + return mLockedOrReservedBlocks.at(0); +} + +const std::vector<std::byte>& TagV0::GetNDEFData() const +{ + return mTLVs[mNdefTlvIdx].GetValue(); +} + +const std::vector<std::byte>& TagV0::GetLockedArea() const +{ + return mLockedArea; +} + +void TagV0::SetNDEFData(const std::span<const std::byte>& data) +{ + // Update the ndef value + mTLVs[mNdefTlvIdx].SetValue(data); +} + +bool TagV0::ParseLockedArea(const std::span<const std::byte>& data) +{ + std::uint8_t currentBlock = 0; + + // Start by parsing the first set of lock bytes + for (std::uint8_t i = kLockbytesStart0; i < kLockbytesEnd0; i++) + { + std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock0 * sizeof(Block) + i]); + + // Iterate over the individual bits in the lock byte + for (std::uint8_t j = 0; j < 8; j++) + { + // Is block locked? + if (lockByte & (1u << j)) + { + Block blk; + std::copy_n(data.begin() + currentBlock * sizeof(Block), sizeof(Block), blk.begin()); + + // The lock bytes themselves are not part of the locked area + if (!IsBlockLockedOrReserved(currentBlock)) + { + mLockedBlocks.emplace(currentBlock, blk); + } + else + { + mLockedOrReservedBlocks.emplace(currentBlock, blk); + } + } + + currentBlock++; + } + } + + // Parse the second set of lock bytes + for (std::uint8_t i = kLockbytesStart1; i < kLockbytesEnd1; i++) { + std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock1 * sizeof(Block) + i]); + + // Iterate over the individual bits in the lock byte + for (std::uint8_t j = 0; j < 8; j++) + { + // Is block locked? + if (lockByte & (1u << j)) + { + Block blk; + std::copy_n(data.begin() + currentBlock * sizeof(Block), sizeof(Block), blk.begin()); + + // The lock bytes themselves are not part of the locked area + if (!IsBlockLockedOrReserved(currentBlock)) + { + mLockedBlocks.emplace(currentBlock, blk); + } + else + { + mLockedOrReservedBlocks.emplace(currentBlock, blk); + } + } + + currentBlock++; + } + } + + return true; +} + +bool TagV0::IsBlockLocked(std::uint8_t blockIdx) const +{ + return mLockedBlocks.contains(blockIdx) || IsBlockLockedOrReserved(blockIdx); +} + +bool TagV0::ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea) +{ + for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) + { + // All blocks which aren't locked make up the dataArea + if (!IsBlockLocked(currentBlock)) + { + auto blockOffset = data.begin() + sizeof(Block) * currentBlock; + dataArea.insert(dataArea.end(), blockOffset, blockOffset + sizeof(Block)); + } + } + + return true; +} + +bool TagV0::ValidateCapabilityContainer() +{ + // NDEF Magic Number + std::uint8_t nmn = mCapabilityContainer[0]; + if (nmn != kNDEFMagicNumber) + { + cemuLog_log(LogType::Force, "Error: CC: Invalid NDEF Magic Number"); + return false; + } + + // Version Number + std::uint8_t vno = mCapabilityContainer[1]; + if (vno >> 4 != 1) + { + cemuLog_log(LogType::Force, "Error: CC: Invalid Version Number"); + return false; + } + + // Tag memory size + std::uint8_t tms = mCapabilityContainer[2]; + if (8u * (tms + 1) < kTagSize) + { + cemuLog_log(LogType::Force, "Error: CC: Incomplete tag memory size"); + return false; + } + + return true; +} diff --git a/src/Cafe/OS/libs/nfc/TagV0.h b/src/Cafe/OS/libs/nfc/TagV0.h new file mode 100644 index 00000000..1d0e88d7 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/TagV0.h @@ -0,0 +1,39 @@ +#pragma once + +#include <memory> +#include <span> +#include <map> + +#include "TLV.h" + +class TagV0 +{ +public: + using Block = std::array<std::byte, 0x8>; + +public: + TagV0(); + virtual ~TagV0(); + + static std::shared_ptr<TagV0> FromBytes(const std::span<const std::byte>& data); + std::vector<std::byte> ToBytes() const; + + const Block& GetUIDBlock() const; + const std::vector<std::byte>& GetNDEFData() const; + const std::vector<std::byte>& GetLockedArea() const; + + void SetNDEFData(const std::span<const std::byte>& data); + +private: + bool ParseLockedArea(const std::span<const std::byte>& data); + bool IsBlockLocked(std::uint8_t blockIdx) const; + bool ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea); + bool ValidateCapabilityContainer(); + + std::map<std::uint8_t, Block> mLockedOrReservedBlocks; + std::map<std::uint8_t, Block> mLockedBlocks; + std::array<std::uint8_t, 0x4> mCapabilityContainer; + std::vector<TLV> mTLVs; + std::size_t mNdefTlvIdx; + std::vector<std::byte> mLockedArea; +}; diff --git a/src/Cafe/OS/libs/nfc/ndef.cpp b/src/Cafe/OS/libs/nfc/ndef.cpp new file mode 100644 index 00000000..f8d87fb8 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/ndef.cpp @@ -0,0 +1,277 @@ +#include "ndef.h" + +#include <cassert> + +namespace ndef +{ + + Record::Record() + { + } + + Record::~Record() + { + } + + std::optional<Record> Record::FromStream(Stream& stream) + { + Record rec; + + // Read record header + uint8_t recHdr; + stream >> recHdr; + rec.mFlags = recHdr & ~NDEF_TNF_MASK; + rec.mTNF = static_cast<TypeNameFormat>(recHdr & NDEF_TNF_MASK); + + // Type length + uint8_t typeLen; + stream >> typeLen; + + // Payload length; + uint32_t payloadLen; + if (recHdr & NDEF_SR) + { + uint8_t len; + stream >> len; + payloadLen = len; + } + else + { + stream >> payloadLen; + } + + // Some sane limits for the payload size + if (payloadLen > 2 * 1024 * 1024) + { + return {}; + } + + // ID length + uint8_t idLen = 0; + if (recHdr & NDEF_IL) + { + stream >> idLen; + } + + // Make sure we didn't read past the end of the stream yet + if (stream.GetError() != Stream::ERROR_OK) + { + return {}; + } + + // Type + rec.mType.resize(typeLen); + stream.Read(rec.mType); + + // ID + rec.mID.resize(idLen); + stream.Read(rec.mID); + + // Payload + rec.mPayload.resize(payloadLen); + stream.Read(rec.mPayload); + + // Make sure we didn't read past the end of the stream again + if (stream.GetError() != Stream::ERROR_OK) + { + return {}; + } + + return rec; + } + + std::vector<std::byte> Record::ToBytes(uint8_t flags) const + { + std::vector<std::byte> bytes; + VectorStream stream(bytes, std::endian::big); + + // Combine flags (clear message begin and end flags) + std::uint8_t finalFlags = mFlags & ~(NDEF_MB | NDEF_ME); + finalFlags |= flags; + + // Write flags + tnf + stream << std::uint8_t(finalFlags | std::uint8_t(mTNF)); + + // Type length + stream << std::uint8_t(mType.size()); + + // Payload length + if (IsShort()) + { + stream << std::uint8_t(mPayload.size()); + } + else + { + stream << std::uint32_t(mPayload.size()); + } + + // ID length + if (mFlags & NDEF_IL) + { + stream << std::uint8_t(mID.size()); + } + + // Type + stream.Write(mType); + + // ID + stream.Write(mID); + + // Payload + stream.Write(mPayload); + + return bytes; + } + + Record::TypeNameFormat Record::GetTNF() const + { + return mTNF; + } + + const std::vector<std::byte>& Record::GetID() const + { + return mID; + } + + const std::vector<std::byte>& Record::GetType() const + { + return mType; + } + + const std::vector<std::byte>& Record::GetPayload() const + { + return mPayload; + } + + void Record::SetTNF(TypeNameFormat tnf) + { + mTNF = tnf; + } + + void Record::SetID(const std::span<const std::byte>& id) + { + cemu_assert(id.size() < 0x100); + + if (id.size() > 0) + { + mFlags |= NDEF_IL; + } + else + { + mFlags &= ~NDEF_IL; + } + + mID.assign(id.begin(), id.end()); + } + + void Record::SetType(const std::span<const std::byte>& type) + { + cemu_assert(type.size() < 0x100); + + mType.assign(type.begin(), type.end()); + } + + void Record::SetPayload(const std::span<const std::byte>& payload) + { + // Update short record flag + if (payload.size() < 0xff) + { + mFlags |= NDEF_SR; + } + else + { + mFlags &= ~NDEF_SR; + } + + mPayload.assign(payload.begin(), payload.end()); + } + + bool Record::IsLast() const + { + return mFlags & NDEF_ME; + } + + bool Record::IsShort() const + { + return mFlags & NDEF_SR; + } + + Message::Message() + { + } + + Message::~Message() + { + } + + std::optional<Message> Message::FromBytes(const std::span<const std::byte>& data) + { + Message msg; + SpanStream stream(data, std::endian::big); + + while (stream.GetRemaining() > 0) + { + std::optional<Record> rec = Record::FromStream(stream); + if (!rec) + { + cemuLog_log(LogType::Force, "Warning: Failed to parse NDEF Record #{}." + "Ignoring the remaining {} bytes in NDEF message", msg.mRecords.size(), stream.GetRemaining()); + break; + } + + msg.mRecords.emplace_back(*rec); + + if ((*rec).IsLast() && stream.GetRemaining() > 0) + { + cemuLog_log(LogType::Force, "Warning: Ignoring {} bytes in NDEF message", stream.GetRemaining()); + break; + } + } + + if (msg.mRecords.empty()) + { + return {}; + } + + if (!msg.mRecords.back().IsLast()) + { + cemuLog_log(LogType::Force, "Error: NDEF message missing end record"); + return {}; + } + + return msg; + } + + std::vector<std::byte> Message::ToBytes() const + { + std::vector<std::byte> bytes; + + for (std::size_t i = 0; i < mRecords.size(); i++) + { + std::uint8_t flags = 0; + + // Add message begin flag to first record + if (i == 0) + { + flags |= Record::NDEF_MB; + } + + // Add message end flag to last record + if (i == mRecords.size() - 1) + { + flags |= Record::NDEF_ME; + } + + std::vector<std::byte> recordBytes = mRecords[i].ToBytes(flags); + bytes.insert(bytes.end(), recordBytes.begin(), recordBytes.end()); + } + + return bytes; + } + + void Message::append(const Record& r) + { + mRecords.push_back(r); + } + +} // namespace ndef diff --git a/src/Cafe/OS/libs/nfc/ndef.h b/src/Cafe/OS/libs/nfc/ndef.h new file mode 100644 index 00000000..b5f38b17 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/ndef.h @@ -0,0 +1,88 @@ +#pragma once + +#include <span> +#include <vector> +#include <optional> + +#include "stream.h" + +namespace ndef +{ + + class Record + { + public: + enum HeaderFlag + { + NDEF_IL = 0x08, + NDEF_SR = 0x10, + NDEF_CF = 0x20, + NDEF_ME = 0x40, + NDEF_MB = 0x80, + NDEF_TNF_MASK = 0x07, + }; + + enum TypeNameFormat + { + NDEF_TNF_EMPTY = 0, + NDEF_TNF_WKT = 1, + NDEF_TNF_MEDIA = 2, + NDEF_TNF_URI = 3, + NDEF_TNF_EXT = 4, + NDEF_TNF_UNKNOWN = 5, + NDEF_TNF_UNCHANGED = 6, + NDEF_TNF_RESERVED = 7, + }; + + public: + Record(); + virtual ~Record(); + + static std::optional<Record> FromStream(Stream& stream); + std::vector<std::byte> ToBytes(uint8_t flags = 0) const; + + TypeNameFormat GetTNF() const; + const std::vector<std::byte>& GetID() const; + const std::vector<std::byte>& GetType() const; + const std::vector<std::byte>& GetPayload() const; + + void SetTNF(TypeNameFormat tnf); + void SetID(const std::span<const std::byte>& id); + void SetType(const std::span<const std::byte>& type); + void SetPayload(const std::span<const std::byte>& payload); + + bool IsLast() const; + bool IsShort() const; + + private: + uint8_t mFlags; + TypeNameFormat mTNF; + std::vector<std::byte> mID; + std::vector<std::byte> mType; + std::vector<std::byte> mPayload; + }; + + class Message + { + public: + Message(); + virtual ~Message(); + + static std::optional<Message> FromBytes(const std::span<const std::byte>& data); + std::vector<std::byte> ToBytes() const; + + Record& operator[](int i) { return mRecords[i]; } + const Record& operator[](int i) const { return mRecords[i]; } + + void append(const Record& r); + + auto begin() { return mRecords.begin(); } + auto end() { return mRecords.end(); } + auto begin() const { return mRecords.begin(); } + auto end() const { return mRecords.end(); } + + private: + std::vector<Record> mRecords; + }; + +} // namespace ndef diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp new file mode 100644 index 00000000..21e9e91b --- /dev/null +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -0,0 +1,596 @@ +#include "Cafe/OS/common/OSCommon.h" +#include "Cafe/OS/RPL/rpl.h" +#include "Cafe/OS/libs/nfc/nfc.h" +#include "Cafe/OS/libs/nn_nfp/nn_nfp.h" +#include "Common/FileStream.h" + +#include "TagV0.h" +#include "ndef.h" + +// TODO move errors to header and allow ntag to convert them + +#define NFC_MODE_INVALID -1 +#define NFC_MODE_IDLE 0 +#define NFC_MODE_ACTIVE 1 + +#define NFC_STATE_UNINITIALIZED 0x0 +#define NFC_STATE_INITIALIZED 0x1 +#define NFC_STATE_IDLE 0x2 +#define NFC_STATE_READ 0x3 +#define NFC_STATE_WRITE 0x4 +#define NFC_STATE_ABORT 0x5 +#define NFC_STATE_FORMAT 0x6 +#define NFC_STATE_SET_READ_ONLY 0x7 +#define NFC_STATE_TAG_PRESENT 0x8 +#define NFC_STATE_DETECT 0x9 +#define NFC_STATE_RAW 0xA + +#define NFC_STATUS_COMMAND_COMPLETE 0x1 +#define NFC_STATUS_READY 0x2 +#define NFC_STATUS_HAS_TAG 0x4 + +namespace nfc +{ + struct NFCContext + { + bool isInitialized; + uint32 state; + sint32 mode; + bool hasTag; + + uint32 nfcStatus; + std::chrono::time_point<std::chrono::system_clock> discoveryTimeout; + + MPTR tagDetectCallback; + void* tagDetectContext; + MPTR abortCallback; + void* abortContext; + MPTR rawCallback; + void* rawContext; + MPTR readCallback; + void* readContext; + MPTR writeCallback; + void* writeContext; + MPTR getTagInfoCallback; + + SysAllocator<NFCTagInfo> tagInfo; + + fs::path tagPath; + std::shared_ptr<TagV0> tag; + + ndef::Message writeMessage; + }; + NFCContext gNFCContexts[2]; + + sint32 NFCInit(uint32 chan) + { + return NFCInitEx(chan, 0); + } + + void __NFCClearContext(NFCContext* context) + { + context->isInitialized = false; + context->state = NFC_STATE_UNINITIALIZED; + context->mode = NFC_MODE_IDLE; + context->hasTag = false; + + context->nfcStatus = NFC_STATUS_READY; + context->discoveryTimeout = {}; + + context->tagDetectCallback = MPTR_NULL; + context->tagDetectContext = nullptr; + context->abortCallback = MPTR_NULL; + context->abortContext = nullptr; + context->rawCallback = MPTR_NULL; + context->rawContext = nullptr; + context->readCallback = MPTR_NULL; + context->readContext = nullptr; + context->writeCallback = MPTR_NULL; + context->writeContext = nullptr; + + context->tagPath = ""; + context->tag = {}; + } + + sint32 NFCInitEx(uint32 chan, uint32 powerMode) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + __NFCClearContext(ctx); + ctx->isInitialized = true; + ctx->state = NFC_STATE_INITIALIZED; + + return 0; + } + + sint32 NFCShutdown(uint32 chan) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + __NFCClearContext(ctx); + + return 0; + } + + bool NFCIsInit(uint32 chan) + { + cemu_assert(chan < 2); + + return gNFCContexts[chan].isInitialized; + } + + void __NFCHandleRead(uint32 chan) + { + NFCContext* ctx = &gNFCContexts[chan]; + + ctx->state = NFC_STATE_IDLE; + + sint32 result; + StackAllocator<NFCUid> uid; + bool readOnly = false; + uint32 dataSize = 0; + StackAllocator<uint8_t, 0x200> data; + uint32 lockedDataSize = 0; + StackAllocator<uint8_t, 0x200> lockedData; + + if (ctx->tag) + { + // Try to parse ndef message + auto ndefMsg = ndef::Message::FromBytes(ctx->tag->GetNDEFData()); + if (ndefMsg) + { + // Look for the unknown TNF which contains the data we care about + for (const auto& rec : *ndefMsg) + { + if (rec.GetTNF() == ndef::Record::NDEF_TNF_UNKNOWN) { + dataSize = rec.GetPayload().size(); + cemu_assert(dataSize < 0x200); + memcpy(data.GetPointer(), rec.GetPayload().data(), dataSize); + break; + } + } + + if (dataSize) + { + // Get locked data + lockedDataSize = ctx->tag->GetLockedArea().size(); + memcpy(lockedData.GetPointer(), ctx->tag->GetLockedArea().data(), lockedDataSize); + + // Fill in uid + memcpy(uid.GetPointer(), ctx->tag->GetUIDBlock().data(), sizeof(NFCUid)); + + result = 0; + } + else + { + result = -0xBFE; + } + } + else + { + result = -0xBFE; + } + + // Clear tag status after read + // TODO this is not really nice here + ctx->nfcStatus &= ~NFC_STATUS_HAS_TAG; + ctx->tag = {}; + } + else + { + result = -0x1DD; + } + + PPCCoreCallback(ctx->readCallback, chan, result, uid.GetPointer(), readOnly, dataSize, data.GetPointer(), lockedDataSize, lockedData.GetPointer(), ctx->readContext); + } + + void __NFCHandleWrite(uint32 chan) + { + NFCContext* ctx = &gNFCContexts[chan]; + + ctx->state = NFC_STATE_IDLE; + + // TODO write to file + + PPCCoreCallback(ctx->writeCallback, chan, 0, ctx->writeContext); + } + + void __NFCHandleAbort(uint32 chan) + { + NFCContext* ctx = &gNFCContexts[chan]; + + ctx->state = NFC_STATE_IDLE; + + PPCCoreCallback(ctx->abortCallback, chan, 0, ctx->abortContext); + } + + void __NFCHandleRaw(uint32 chan) + { + NFCContext* ctx = &gNFCContexts[chan]; + + ctx->state = NFC_STATE_IDLE; + + sint32 result; + if (ctx->nfcStatus & NFC_STATUS_HAS_TAG) + { + result = 0; + } + else + { + result = -0x9DD; + } + + // We don't actually send any commands/responses + uint32 responseSize = 0; + void* responseData = nullptr; + + PPCCoreCallback(ctx->rawCallback, chan, result, responseSize, responseData, ctx->rawContext); + } + + void NFCProc(uint32 chan) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!ctx->isInitialized) + { + return; + } + + // Check if the detect callback should be called + if (ctx->nfcStatus & NFC_STATUS_HAS_TAG) + { + if (!ctx->hasTag && ctx->state > NFC_STATE_IDLE && ctx->state != NFC_STATE_ABORT) + { + if (ctx->tagDetectCallback) + { + PPCCoreCallback(ctx->tagDetectCallback, chan, true, ctx->tagDetectContext); + } + + ctx->hasTag = true; + } + } + else + { + if (ctx->hasTag && ctx->state == NFC_STATE_IDLE) + { + if (ctx->tagDetectCallback) + { + PPCCoreCallback(ctx->tagDetectCallback, chan, false, ctx->tagDetectContext); + } + + ctx->hasTag = false; + } + } + + switch (ctx->state) + { + case NFC_STATE_INITIALIZED: + ctx->state = NFC_STATE_IDLE; + break; + case NFC_STATE_IDLE: + break; + case NFC_STATE_READ: + // Do we have a tag or did the timeout expire? + if ((ctx->nfcStatus & NFC_STATUS_HAS_TAG) || ctx->discoveryTimeout < std::chrono::system_clock::now()) + { + __NFCHandleRead(chan); + } + break; + case NFC_STATE_WRITE: + __NFCHandleWrite(chan); + break; + case NFC_STATE_ABORT: + __NFCHandleAbort(chan); + break; + case NFC_STATE_RAW: + // Do we have a tag or did the timeout expire? + if ((ctx->nfcStatus & NFC_STATUS_HAS_TAG) || ctx->discoveryTimeout < std::chrono::system_clock::now()) + { + __NFCHandleRaw(chan); + } + break; + } + } + + sint32 NFCGetMode(uint32 chan) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan) || ctx->state == NFC_STATE_UNINITIALIZED) + { + return NFC_MODE_INVALID; + } + + return ctx->mode; + } + + sint32 NFCSetMode(uint32 chan, sint32 mode) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan)) + { + return -0xAE0; + } + + if (ctx->state == NFC_STATE_UNINITIALIZED) + { + return -0xADF; + } + + ctx->mode = mode; + + return 0; + } + + void NFCSetTagDetectCallback(uint32 chan, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + ctx->tagDetectCallback = callback; + ctx->tagDetectContext = context; + } + + sint32 NFCAbort(uint32 chan, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan)) + { + return -0x6E0; + } + + if (ctx->state <= NFC_STATE_IDLE) + { + return -0x6DF; + } + + ctx->state = NFC_STATE_ABORT; + ctx->abortCallback = callback; + ctx->abortContext = context; + + return 0; + } + + void __NFCGetTagInfoCallback(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(chan, 0); + ppcDefineParamS32(error, 1); + ppcDefineParamU32(responseSize, 2); + ppcDefineParamPtr(responseData, void, 3); + ppcDefineParamPtr(context, void, 4); + + NFCContext* ctx = &gNFCContexts[chan]; + + // TODO convert error + error = error; + if (error == 0 && ctx->tag) + { + // this is usually parsed from response data + ctx->tagInfo->uidSize = sizeof(NFCUid); + memcpy(ctx->tagInfo->uid, ctx->tag->GetUIDBlock().data(), ctx->tagInfo->uidSize); + ctx->tagInfo->technology = NFC_TECHNOLOGY_A; + ctx->tagInfo->protocol = NFC_PROTOCOL_T1T; + } + + PPCCoreCallback(ctx->getTagInfoCallback, chan, error, ctx->tagInfo.GetPtr(), context); + osLib_returnFromFunction(hCPU, 0); + } + + sint32 NFCGetTagInfo(uint32 chan, uint32 discoveryTimeout, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + // Forward this request to nn_nfp, if the title initialized it + // TODO integrate nn_nfp/ntag/nfc + if (nnNfp_isInitialized()) + { + return nn::nfp::NFCGetTagInfo(chan, discoveryTimeout, callback, context); + } + + NFCContext* ctx = &gNFCContexts[chan]; + + ctx->getTagInfoCallback = callback; + + sint32 result = NFCSendRawData(chan, true, discoveryTimeout, 1000U, 0, 0, nullptr, RPLLoader_MakePPCCallable(__NFCGetTagInfoCallback), context); + return result; // TODO convert result + } + + sint32 NFCSendRawData(uint32 chan, bool startDiscovery, uint32 discoveryTimeout, uint32 commandTimeout, uint32 commandSize, uint32 responseSize, void* commandData, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan)) + { + return -0x9E0; + } + + // Only allow discovery + if (!startDiscovery) + { + return -0x9DC; + } + + if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) + { + return -0x9DC; + } + + if (ctx->state != NFC_STATE_IDLE) + { + return -0x9DF; + } + + ctx->state = NFC_STATE_RAW; + ctx->rawCallback = callback; + ctx->rawContext = context; + + // If the discoveryTimeout is 0, no timeout + if (discoveryTimeout == 0) + { + ctx->discoveryTimeout = std::chrono::time_point<std::chrono::system_clock>::max(); + } + else + { + ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); + } + + return 0; + } + + sint32 NFCRead(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan)) + { + return -0x1E0; + } + + if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) + { + return -0x1DC; + } + + if (ctx->state != NFC_STATE_IDLE) + { + return -0x1DF; + } + + cemuLog_log(LogType::NFC, "starting read"); + + ctx->state = NFC_STATE_READ; + ctx->readCallback = callback; + ctx->readContext = context; + + // If the discoveryTimeout is 0, no timeout + if (discoveryTimeout == 0) + { + ctx->discoveryTimeout = std::chrono::time_point<std::chrono::system_clock>::max(); + } + else + { + ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); + } + + // TODO uid filter? + + return 0; + } + + sint32 NFCWrite(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, uint32 size, void* data, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + NFCContext* ctx = &gNFCContexts[chan]; + + if (!NFCIsInit(chan)) + { + return -0x2e0; + } + + if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) + { + return -0x2dc; + } + + if (ctx->state != NFC_STATE_IDLE) + { + return -0x1df; + } + + // Create unknown record which contains the rw area + ndef::Record rec; + rec.SetTNF(ndef::Record::NDEF_TNF_UNKNOWN); + rec.SetPayload(std::span(reinterpret_cast<std::byte*>(data), size)); + + // Create ndef message which contains the record + ndef::Message msg; + msg.append(rec); + ctx->writeMessage = msg; + + ctx->state = NFC_STATE_WRITE; + ctx->writeCallback = callback; + ctx->writeContext = context; + + // If the discoveryTimeout is 0, no timeout + if (discoveryTimeout == 0) + { + ctx->discoveryTimeout = std::chrono::time_point<std::chrono::system_clock>::max(); + } + else + { + ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); + } + + // TODO uid filter? + + return 0; + } + + void Initialize() + { + cafeExportRegister("nfc", NFCInit, LogType::NFC); + cafeExportRegister("nfc", NFCInitEx, LogType::NFC); + cafeExportRegister("nfc", NFCShutdown, LogType::NFC); + cafeExportRegister("nfc", NFCIsInit, LogType::NFC); + cafeExportRegister("nfc", NFCProc, LogType::NFC); + cafeExportRegister("nfc", NFCGetMode, LogType::NFC); + cafeExportRegister("nfc", NFCSetMode, LogType::NFC); + cafeExportRegister("nfc", NFCSetTagDetectCallback, LogType::NFC); + cafeExportRegister("nfc", NFCGetTagInfo, LogType::NFC); + cafeExportRegister("nfc", NFCSendRawData, LogType::NFC); + cafeExportRegister("nfc", NFCAbort, LogType::NFC); + cafeExportRegister("nfc", NFCRead, LogType::NFC); + cafeExportRegister("nfc", NFCWrite, LogType::NFC); + } + + bool TouchTagFromFile(const fs::path& filePath, uint32* nfcError) + { + // Forward this request to nn_nfp, if the title initialized it + // TODO integrate nn_nfp/ntag/nfc + if (nnNfp_isInitialized()) + { + return nnNfp_touchNfcTagFromFile(filePath, nfcError); + } + + NFCContext* ctx = &gNFCContexts[0]; + + auto nfcData = FileStream::LoadIntoMemory(filePath); + if (!nfcData) + { + *nfcError = NFC_ERROR_NO_ACCESS; + return false; + } + + ctx->tag = TagV0::FromBytes(std::as_bytes(std::span(nfcData->data(), nfcData->size()))); + if (!ctx->tag) + { + *nfcError = NFC_ERROR_INVALID_FILE_FORMAT; + return false; + } + + ctx->nfcStatus |= NFC_STATUS_HAS_TAG; + ctx->tagPath = filePath; + + *nfcError = NFC_ERROR_NONE; + return true; + } +} diff --git a/src/Cafe/OS/libs/nfc/nfc.h b/src/Cafe/OS/libs/nfc/nfc.h new file mode 100644 index 00000000..2ebdd2a4 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/nfc.h @@ -0,0 +1,62 @@ +#pragma once + +// CEMU NFC error codes +#define NFC_ERROR_NONE (0) +#define NFC_ERROR_NO_ACCESS (1) +#define NFC_ERROR_INVALID_FILE_FORMAT (2) + +#define NFC_PROTOCOL_T1T 0x1 +#define NFC_PROTOCOL_T2T 0x2 + +#define NFC_TECHNOLOGY_A 0x0 +#define NFC_TECHNOLOGY_B 0x1 +#define NFC_TECHNOLOGY_F 0x2 + +namespace nfc +{ + struct NFCUid + { + /* +0x00 */ uint8 uid[7]; + }; + static_assert(sizeof(NFCUid) == 0x7); + + struct NFCTagInfo + { + /* +0x00 */ uint8 uidSize; + /* +0x01 */ uint8 uid[10]; + /* +0x0B */ uint8 technology; + /* +0x0C */ uint8 protocol; + /* +0x0D */ uint8 reserved[0x20]; + }; + static_assert(sizeof(NFCTagInfo) == 0x2D); + + sint32 NFCInit(uint32 chan); + + sint32 NFCInitEx(uint32 chan, uint32 powerMode); + + sint32 NFCShutdown(uint32 chan); + + bool NFCIsInit(uint32 chan); + + void NFCProc(uint32 chan); + + sint32 NFCGetMode(uint32 chan); + + sint32 NFCSetMode(uint32 chan, sint32 mode); + + void NFCSetTagDetectCallback(uint32 chan, MPTR callback, void* context); + + sint32 NFCGetTagInfo(uint32 chan, uint32 discoveryTimeout, MPTR callback, void* context); + + sint32 NFCSendRawData(uint32 chan, bool startDiscovery, uint32 discoveryTimeout, uint32 commandTimeout, uint32 commandSize, uint32 responseSize, void* commandData, MPTR callback, void* context); + + sint32 NFCAbort(uint32 chan, MPTR callback, void* context); + + sint32 NFCRead(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, MPTR callback, void* context); + + sint32 NFCWrite(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, uint32 size, void* data, MPTR callback, void* context); + + void Initialize(); + + bool TouchTagFromFile(const fs::path& filePath, uint32* nfcError); +} diff --git a/src/Cafe/OS/libs/nfc/stream.cpp b/src/Cafe/OS/libs/nfc/stream.cpp new file mode 100644 index 00000000..73c2880f --- /dev/null +++ b/src/Cafe/OS/libs/nfc/stream.cpp @@ -0,0 +1,201 @@ +#include "stream.h" + +#include <algorithm> + +Stream::Stream(std::endian endianness) + : mError(ERROR_OK), mEndianness(endianness) +{ +} + +Stream::~Stream() +{ +} + +Stream::Error Stream::GetError() const +{ + return mError; +} + +void Stream::SetEndianness(std::endian endianness) +{ + mEndianness = endianness; +} + +std::endian Stream::GetEndianness() const +{ + return mEndianness; +} + +Stream& Stream::operator>>(bool& val) +{ + std::uint8_t i; + *this >> i; + val = !!i; + + return *this; +} + +Stream& Stream::operator>>(float& val) +{ + std::uint32_t i; + *this >> i; + val = std::bit_cast<float>(i); + + return *this; +} + +Stream& Stream::operator>>(double& val) +{ + std::uint64_t i; + *this >> i; + val = std::bit_cast<double>(i); + + return *this; +} + +Stream& Stream::operator<<(bool val) +{ + std::uint8_t i = val; + *this >> i; + + return *this; +} + +Stream& Stream::operator<<(float val) +{ + std::uint32_t i = std::bit_cast<std::uint32_t>(val); + *this >> i; + + return *this; +} + +Stream& Stream::operator<<(double val) +{ + std::uint64_t i = std::bit_cast<std::uint64_t>(val); + *this >> i; + + return *this; +} + +void Stream::SetError(Error error) +{ + mError = error; +} + +bool Stream::NeedsSwap() +{ + return mEndianness != std::endian::native; +} + +VectorStream::VectorStream(std::vector<std::byte>& vector, std::endian endianness) + : Stream(endianness), mVector(vector), mPosition(0) +{ +} + +VectorStream::~VectorStream() +{ +} + +std::size_t VectorStream::Read(const std::span<std::byte>& data) +{ + if (data.size() > GetRemaining()) + { + SetError(ERROR_READ_FAILED); + std::fill(data.begin(), data.end(), std::byte(0)); + return 0; + } + + std::copy_n(mVector.get().begin() + mPosition, data.size(), data.begin()); + mPosition += data.size(); + return data.size(); +} + +std::size_t VectorStream::Write(const std::span<const std::byte>& data) +{ + // Resize vector if not enough bytes remain + if (mPosition + data.size() > mVector.get().size()) + { + mVector.get().resize(mPosition + data.size()); + } + + std::copy(data.begin(), data.end(), mVector.get().begin() + mPosition); + mPosition += data.size(); + return data.size(); +} + +bool VectorStream::SetPosition(std::size_t position) +{ + if (position >= mVector.get().size()) + { + return false; + } + + mPosition = position; + return true; +} + +std::size_t VectorStream::GetPosition() const +{ + return mPosition; +} + +std::size_t VectorStream::GetRemaining() const +{ + return mVector.get().size() - mPosition; +} + +SpanStream::SpanStream(std::span<const std::byte> span, std::endian endianness) + : Stream(endianness), mSpan(std::move(span)), mPosition(0) +{ +} + +SpanStream::~SpanStream() +{ +} + +std::size_t SpanStream::Read(const std::span<std::byte>& data) +{ + if (data.size() > GetRemaining()) + { + SetError(ERROR_READ_FAILED); + std::fill(data.begin(), data.end(), std::byte(0)); + return 0; + } + + std::copy_n(mSpan.begin() + mPosition, data.size(), data.begin()); + mPosition += data.size(); + return data.size(); +} + +std::size_t SpanStream::Write(const std::span<const std::byte>& data) +{ + // Cannot write to const span + SetError(ERROR_WRITE_FAILED); + return 0; +} + +bool SpanStream::SetPosition(std::size_t position) +{ + if (position >= mSpan.size()) + { + return false; + } + + mPosition = position; + return true; +} + +std::size_t SpanStream::GetPosition() const +{ + return mPosition; +} + +std::size_t SpanStream::GetRemaining() const +{ + if (mPosition > mSpan.size()) + { + return 0; + } + + return mSpan.size() - mPosition; +} diff --git a/src/Cafe/OS/libs/nfc/stream.h b/src/Cafe/OS/libs/nfc/stream.h new file mode 100644 index 00000000..e666b480 --- /dev/null +++ b/src/Cafe/OS/libs/nfc/stream.h @@ -0,0 +1,139 @@ +#pragma once + +#include <cstdint> +#include <vector> +#include <span> +#include <bit> + +#include "Common/precompiled.h" + +class Stream +{ +public: + enum Error + { + ERROR_OK, + ERROR_READ_FAILED, + ERROR_WRITE_FAILED, + }; + +public: + Stream(std::endian endianness = std::endian::native); + virtual ~Stream(); + + Error GetError() const; + + void SetEndianness(std::endian endianness); + std::endian GetEndianness() const; + + virtual std::size_t Read(const std::span<std::byte>& data) = 0; + virtual std::size_t Write(const std::span<const std::byte>& data) = 0; + + virtual bool SetPosition(std::size_t position) = 0; + virtual std::size_t GetPosition() const = 0; + + virtual std::size_t GetRemaining() const = 0; + + // Stream read operators + template<std::integral T> + Stream& operator>>(T& val) + { + val = 0; + if (Read(std::as_writable_bytes(std::span(std::addressof(val), 1))) == sizeof(val)) + { + if (NeedsSwap()) + { + if (sizeof(T) == 2) + { + val = _swapEndianU16(val); + } + else if (sizeof(T) == 4) + { + val = _swapEndianU32(val); + } + else if (sizeof(T) == 8) + { + val = _swapEndianU64(val); + } + } + } + + return *this; + } + Stream& operator>>(bool& val); + Stream& operator>>(float& val); + Stream& operator>>(double& val); + + // Stream write operators + template<std::integral T> + Stream& operator<<(T val) + { + if (NeedsSwap()) + { + if (sizeof(T) == 2) + { + val = _swapEndianU16(val); + } + else if (sizeof(T) == 4) + { + val = _swapEndianU32(val); + } + else if (sizeof(T) == 8) + { + val = _swapEndianU64(val); + } + } + + Write(std::as_bytes(std::span(std::addressof(val), 1))); + return *this; + } + Stream& operator<<(bool val); + Stream& operator<<(float val); + Stream& operator<<(double val); + +protected: + void SetError(Error error); + + bool NeedsSwap(); + + Error mError; + std::endian mEndianness; +}; + +class VectorStream : public Stream +{ +public: + VectorStream(std::vector<std::byte>& vector, std::endian endianness = std::endian::native); + virtual ~VectorStream(); + + virtual std::size_t Read(const std::span<std::byte>& data) override; + virtual std::size_t Write(const std::span<const std::byte>& data) override; + + virtual bool SetPosition(std::size_t position) override; + virtual std::size_t GetPosition() const override; + + virtual std::size_t GetRemaining() const override; + +private: + std::reference_wrapper<std::vector<std::byte>> mVector; + std::size_t mPosition; +}; + +class SpanStream : public Stream +{ +public: + SpanStream(std::span<const std::byte> span, std::endian endianness = std::endian::native); + virtual ~SpanStream(); + + virtual std::size_t Read(const std::span<std::byte>& data) override; + virtual std::size_t Write(const std::span<const std::byte>& data) override; + + virtual bool SetPosition(std::size_t position) override; + virtual std::size_t GetPosition() const override; + + virtual std::size_t GetRemaining() const override; + +private: + std::span<const std::byte> mSpan; + std::size_t mPosition; +}; diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp index ad2ea203..10d9e7cb 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp @@ -293,41 +293,6 @@ void nnNfpExport_GetTagInfo(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0)); } -typedef struct -{ - /* +0x00 */ uint8 uidLength; - /* +0x01 */ uint8 uid[0xA]; - /* +0x0B */ uint8 ukn0B; - /* +0x0C */ uint8 ukn0C; - /* +0x0D */ uint8 ukn0D; - // more? -}NFCTagInfoCallbackParam_t; - -uint32 NFCGetTagInfo(uint32 index, uint32 timeout, MPTR functionPtr, void* userParam) -{ - cemuLog_log(LogType::NN_NFP, "NFCGetTagInfo({},{},0x{:08x},0x{:08x})", index, timeout, functionPtr, userParam ? memory_getVirtualOffsetFromPointer(userParam) : 0); - - - cemu_assert(index == 0); - - nnNfpLock(); - - StackAllocator<NFCTagInfoCallbackParam_t> _callbackParam; - NFCTagInfoCallbackParam_t* callbackParam = _callbackParam.GetPointer(); - - memset(callbackParam, 0x00, sizeof(NFCTagInfoCallbackParam_t)); - - memcpy(callbackParam->uid, nfp_data.amiiboProcessedData.uid, nfp_data.amiiboProcessedData.uidLength); - callbackParam->uidLength = (uint8)nfp_data.amiiboProcessedData.uidLength; - - PPCCoreCallback(functionPtr, index, 0, _callbackParam.GetPointer(), userParam); - - nnNfpUnlock(); - - - return 0; // 0 -> success -} - void nnNfpExport_Mount(PPCInterpreter_t* hCPU) { cemuLog_log(LogType::NN_NFP, "Mount()"); @@ -769,6 +734,16 @@ void nnNfp_unloadAmiibo() nnNfpUnlock(); } +bool nnNfp_isInitialized() +{ + return nfp_data.nfpIsInitialized; +} + +// CEMU NFC error codes +#define NFC_ERROR_NONE (0) +#define NFC_ERROR_NO_ACCESS (1) +#define NFC_ERROR_INVALID_FILE_FORMAT (2) + bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError) { AmiiboRawNFCData rawData = { 0 }; @@ -960,6 +935,41 @@ void nnNfpExport_GetNfpState(PPCInterpreter_t* hCPU) namespace nn::nfp { + typedef struct + { + /* +0x00 */ uint8 uidLength; + /* +0x01 */ uint8 uid[0xA]; + /* +0x0B */ uint8 ukn0B; + /* +0x0C */ uint8 ukn0C; + /* +0x0D */ uint8 ukn0D; + // more? + }NFCTagInfoCallbackParam_t; + + uint32 NFCGetTagInfo(uint32 index, uint32 timeout, MPTR functionPtr, void* userParam) + { + cemuLog_log(LogType::NN_NFP, "NFCGetTagInfo({},{},0x{:08x},0x{:08x})", index, timeout, functionPtr, userParam ? memory_getVirtualOffsetFromPointer(userParam) : 0); + + + cemu_assert(index == 0); + + nnNfpLock(); + + StackAllocator<NFCTagInfoCallbackParam_t> _callbackParam; + NFCTagInfoCallbackParam_t* callbackParam = _callbackParam.GetPointer(); + + memset(callbackParam, 0x00, sizeof(NFCTagInfoCallbackParam_t)); + + memcpy(callbackParam->uid, nfp_data.amiiboProcessedData.uid, nfp_data.amiiboProcessedData.uidLength); + callbackParam->uidLength = (uint8)nfp_data.amiiboProcessedData.uidLength; + + PPCCoreCallback(functionPtr, index, 0, _callbackParam.GetPointer(), userParam); + + nnNfpUnlock(); + + + return 0; // 0 -> success + } + uint32 GetErrorCode(uint32 result) { uint32 level = (result >> 0x1b) & 3; @@ -1019,9 +1029,6 @@ namespace nn::nfp nnNfp_load(); // legacy interface, update these to use cafeExportRegister / cafeExportRegisterFunc cafeExportRegisterFunc(nn::nfp::GetErrorCode, "nn_nfp", "GetErrorCode__Q2_2nn3nfpFRCQ2_2nn6Result", LogType::Placeholder); - - // NFC API - cafeExportRegister("nn_nfp", NFCGetTagInfo, LogType::Placeholder); } } diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.h b/src/Cafe/OS/libs/nn_nfp/nn_nfp.h index e8a1c55f..25b36cc9 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.h +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.h @@ -2,12 +2,15 @@ namespace nn::nfp { + uint32 NFCGetTagInfo(uint32 index, uint32 timeout, MPTR functionPtr, void* userParam); + void load(); } void nnNfp_load(); void nnNfp_update(); +bool nnNfp_isInitialized(); bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError); #define NFP_STATE_NONE (0) @@ -18,8 +21,3 @@ bool nnNfp_touchNfcTagFromFile(const fs::path& filePath, uint32* nfcError); #define NFP_STATE_RW_MOUNT (5) #define NFP_STATE_UNEXPECTED (6) #define NFP_STATE_RW_MOUNT_ROM (7) - -// CEMU NFC error codes -#define NFC_ERROR_NONE (0) -#define NFC_ERROR_NO_ACCESS (1) -#define NFC_ERROR_INVALID_FILE_FORMAT (2) diff --git a/src/Cafe/OS/libs/ntag/ntag.cpp b/src/Cafe/OS/libs/ntag/ntag.cpp new file mode 100644 index 00000000..8bdbb66f --- /dev/null +++ b/src/Cafe/OS/libs/ntag/ntag.cpp @@ -0,0 +1,438 @@ +#include "Cafe/OS/common/OSCommon.h" +#include "Cafe/OS/RPL/rpl.h" +#include "Cafe/OS/libs/ntag/ntag.h" +#include "Cafe/OS/libs/nfc/nfc.h" +#include "Cafe/OS/libs/coreinit/coreinit_IPC.h" +#include "Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.h" + +namespace ntag +{ + struct NTAGWriteData + { + + }; + NTAGWriteData gWriteData[2]; + + bool ccrNfcOpened = false; + IOSDevHandle gCcrNfcHandle; + + NTAGFormatSettings gFormatSettings; + + MPTR gDetectCallbacks[2]; + MPTR gAbortCallbacks[2]; + MPTR gReadCallbacks[2]; + MPTR gWriteCallbacks[2]; + + sint32 __NTAGConvertNFCError(sint32 error) + { + // TODO + return error; + } + + sint32 NTAGInit(uint32 chan) + { + return NTAGInitEx(chan); + } + + sint32 NTAGInitEx(uint32 chan) + { + sint32 result = nfc::NFCInitEx(chan, 1); + return __NTAGConvertNFCError(result); + } + + sint32 NTAGShutdown(uint32 chan) + { + sint32 result = nfc::NFCShutdown(chan); + + if (ccrNfcOpened) + { + coreinit::IOS_Close(gCcrNfcHandle); + ccrNfcOpened = false; + } + + gDetectCallbacks[chan] = MPTR_NULL; + gAbortCallbacks[chan] = MPTR_NULL; + gReadCallbacks[chan] = MPTR_NULL; + gWriteCallbacks[chan] = MPTR_NULL; + + return __NTAGConvertNFCError(result); + } + + bool NTAGIsInit(uint32 chan) + { + return nfc::NFCIsInit(chan); + } + + void NTAGProc(uint32 chan) + { + nfc::NFCProc(chan); + } + + void NTAGSetFormatSettings(NTAGFormatSettings* formatSettings) + { + gFormatSettings.version = formatSettings->version; + gFormatSettings.makerCode = _swapEndianU32(formatSettings->makerCode); + gFormatSettings.indentifyCode = _swapEndianU32(formatSettings->indentifyCode); + } + + void __NTAGDetectCallback(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(chan, 0); + ppcDefineParamU32(hasTag, 1); + ppcDefineParamPtr(context, void, 2); + + cemuLog_log(LogType::NTAG, "__NTAGDetectCallback: {} {} {}", chan, hasTag, context); + + PPCCoreCallback(gDetectCallbacks[chan], chan, hasTag, context); + + osLib_returnFromFunction(hCPU, 0); + } + + void NTAGSetTagDetectCallback(uint32 chan, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + gDetectCallbacks[chan] = callback; + nfc::NFCSetTagDetectCallback(chan, RPLLoader_MakePPCCallable(__NTAGDetectCallback), context); + } + + void __NTAGAbortCallback(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(chan, 0); + ppcDefineParamS32(error, 1); + ppcDefineParamPtr(context, void, 2); + + PPCCoreCallback(gAbortCallbacks[chan], chan, __NTAGConvertNFCError(error), context); + + osLib_returnFromFunction(hCPU, 0); + } + + sint32 NTAGAbort(uint32 chan, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + // TODO is it normal that Rumble U calls this? + + gAbortCallbacks[chan] = callback; + sint32 result = nfc::NFCAbort(chan, RPLLoader_MakePPCCallable(__NTAGAbortCallback), context); + return __NTAGConvertNFCError(result); + } + + bool __NTAGRawDataToNfcData(iosu::ccr_nfc::CCRNFCCryptData* raw, iosu::ccr_nfc::CCRNFCCryptData* nfc) + { + memcpy(nfc, raw, sizeof(iosu::ccr_nfc::CCRNFCCryptData)); + + if (raw->version == 0) + { + nfc->version = 0; + nfc->dataSize = 0x1C8; + nfc->seedOffset = 0x25; + nfc->keyGenSaltOffset = 0x1A8; + nfc->uuidOffset = 0x198; + nfc->unfixedInfosOffset = 0x28; + nfc->unfixedInfosSize = 0x120; + nfc->lockedSecretOffset = 0x168; + nfc->lockedSecretSize = 0x30; + nfc->unfixedInfosHmacOffset = 0; + nfc->lockedSecretHmacOffset = 0x148; + } + else if (raw->version == 2) + { + nfc->version = 2; + nfc->dataSize = 0x208; + nfc->seedOffset = 0x29; + nfc->keyGenSaltOffset = 0x1E8; + nfc->uuidOffset = 0x1D4; + nfc->unfixedInfosOffset = 0x2C; + nfc->unfixedInfosSize = 0x188; + nfc->lockedSecretOffset = 0x1DC; + nfc->lockedSecretSize = 0; + nfc->unfixedInfosHmacOffset = 0x8; + nfc->lockedSecretHmacOffset = 0x1B4; + + memcpy(nfc->data + 0x1d4, raw->data, 0x8); + memcpy(nfc->data, raw->data + 0x8, 0x8); + memcpy(nfc->data + 0x28, raw->data + 0x10, 0x4); + memcpy(nfc->data + nfc->unfixedInfosOffset, raw->data + 0x14, 0x20); + memcpy(nfc->data + nfc->lockedSecretHmacOffset, raw->data + 0x34, 0x20); + memcpy(nfc->data + nfc->lockedSecretOffset, raw->data + 0x54, 0xC); + memcpy(nfc->data + nfc->keyGenSaltOffset, raw->data + 0x60, 0x20); + memcpy(nfc->data + nfc->unfixedInfosHmacOffset, raw->data + 0x80, 0x20); + memcpy(nfc->data + nfc->unfixedInfosOffset + 0x20, raw->data + 0xa0, 0x168); + memcpy(nfc->data + 0x208, raw->data + 0x208, 0x14); + } + else + { + return false; + } + + return true; + } + + bool __NTAGNfcDataToRawData(iosu::ccr_nfc::CCRNFCCryptData* nfc, iosu::ccr_nfc::CCRNFCCryptData* raw) + { + memcpy(raw, nfc, sizeof(iosu::ccr_nfc::CCRNFCCryptData)); + + if (nfc->version == 0) + { + raw->version = 0; + raw->dataSize = 0x1C8; + raw->seedOffset = 0x25; + raw->keyGenSaltOffset = 0x1A8; + raw->uuidOffset = 0x198; + raw->unfixedInfosOffset = 0x28; + raw->unfixedInfosSize = 0x120; + raw->lockedSecretOffset = 0x168; + raw->lockedSecretSize = 0x30; + raw->unfixedInfosHmacOffset = 0; + raw->lockedSecretHmacOffset = 0x148; + } + else if (nfc->version == 2) + { + raw->version = 2; + raw->dataSize = 0x208; + raw->seedOffset = 0x11; + raw->keyGenSaltOffset = 0x60; + raw->uuidOffset = 0; + raw->unfixedInfosOffset = 0x14; + raw->unfixedInfosSize = 0x188; + raw->lockedSecretOffset = 0x54; + raw->lockedSecretSize = 0xC; + raw->unfixedInfosHmacOffset = 0x80; + raw->lockedSecretHmacOffset = 0x34; + + memcpy(raw->data + 0x8, nfc->data, 0x8); + memcpy(raw->data + raw->unfixedInfosHmacOffset, nfc->data + 0x8, 0x20); + memcpy(raw->data + 0x10, nfc->data + 0x28, 0x4); + memcpy(raw->data + raw->unfixedInfosOffset, nfc->data + 0x2C, 0x20); + memcpy(raw->data + 0xa0, nfc->data + 0x4C, 0x168); + memcpy(raw->data + raw->lockedSecretHmacOffset, nfc->data + 0x1B4, 0x20); + memcpy(raw->data + raw->uuidOffset, nfc->data + 0x1D4, 0x8); + memcpy(raw->data + raw->lockedSecretOffset, nfc->data + 0x1DC, 0xC); + memcpy(raw->data + raw->keyGenSaltOffset, nfc->data + 0x1E8, 0x20); + memcpy(raw->data + 0x208, nfc->data + 0x208, 0x14); + } + else + { + return false; + } + + return true; + } + + sint32 __NTAGDecryptData(void* decryptedData, void* rawData) + { + StackAllocator<iosu::ccr_nfc::CCRNFCCryptData> nfcRawData, nfcInData, nfcOutData; + + if (!ccrNfcOpened) + { + gCcrNfcHandle = coreinit::IOS_Open("/dev/ccr_nfc", 0); + } + + // Prepare nfc buffer + nfcRawData->version = 0; + memcpy(nfcRawData->data, rawData, 0x1C8); + __NTAGRawDataToNfcData(nfcRawData.GetPointer(), nfcInData.GetPointer()); + + // Decrypt + sint32 result = coreinit::IOS_Ioctl(gCcrNfcHandle, 2, nfcInData.GetPointer(), sizeof(iosu::ccr_nfc::CCRNFCCryptData), nfcOutData.GetPointer(), sizeof(iosu::ccr_nfc::CCRNFCCryptData)); + + // Unpack nfc buffer + __NTAGNfcDataToRawData(nfcOutData.GetPointer(), nfcRawData.GetPointer()); + memcpy(decryptedData, nfcRawData->data, 0x1C8); + + // Convert result + if (result == CCR_NFC_INVALID_UNFIXED_INFOS) + { + return -0x2708; + } + else if (result == CCR_NFC_INVALID_LOCKED_SECRET) + { + return -0x2707; + } + + return result; + } + + sint32 __NTAGValidateHeaders(NTAGNoftHeader* noftHeader, NTAGInfoHeader* infoHeader, NTAGAreaHeader* rwHeader, NTAGAreaHeader* roHeader) + { + // TODO + return 0; + } + + sint32 __NTAGParseHeaders(const uint8* data, NTAGNoftHeader* noftHeader, NTAGInfoHeader* infoHeader, NTAGAreaHeader* rwHeader, NTAGAreaHeader* roHeader) + { + memcpy(noftHeader, data + 0x20, sizeof(NTAGNoftHeader)); + memcpy(infoHeader, data + 0x198, sizeof(NTAGInfoHeader)); + memcpy(rwHeader, data + _swapEndianU16(infoHeader->rwHeaderOffset), sizeof(NTAGAreaHeader)); + memcpy(roHeader, data + _swapEndianU16(infoHeader->roHeaderOffset), sizeof(NTAGAreaHeader)); + return __NTAGValidateHeaders(noftHeader, infoHeader, rwHeader, roHeader); + } + + sint32 __NTAGParseData(void* rawData, void* rwData, void* roData, nfc::NFCUid* uid, uint32 lockedDataSize, NTAGNoftHeader* noftHeader, NTAGInfoHeader* infoHeader, NTAGAreaHeader* rwHeader, NTAGAreaHeader* roHeader) + { + uint8 decryptedData[0x1C8]; + sint32 result = __NTAGDecryptData(decryptedData, rawData); + if (result < 0) + { + return result; + } + + result = __NTAGParseHeaders(decryptedData, noftHeader, infoHeader, rwHeader, roHeader); + if (result < 0) + { + return result; + } + + if (_swapEndianU16(roHeader->size) + 0x70 != lockedDataSize) + { + cemuLog_log(LogType::Force, "Invalid locked area size"); + return -0x270C; + } + + if (memcmp(infoHeader->uid.uid, uid->uid, sizeof(nfc::NFCUid)) != 0) + { + cemuLog_log(LogType::Force, "UID mismatch"); + return -0x270B; + } + + cemu_assert(_swapEndianU16(rwHeader->offset) + _swapEndianU16(rwHeader->size) < 0x200); + cemu_assert(_swapEndianU16(roHeader->offset) + _swapEndianU16(roHeader->size) < 0x200); + + memcpy(rwData, decryptedData + _swapEndianU16(rwHeader->offset), _swapEndianU16(rwHeader->size)); + memcpy(roData, decryptedData + _swapEndianU16(roHeader->offset), _swapEndianU16(roHeader->size)); + + return 0; + } + + void __NTAGReadCallback(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(chan, 0); + ppcDefineParamS32(error, 1); + ppcDefineParamPtr(uid, nfc::NFCUid, 2); + ppcDefineParamU32(readOnly, 3); + ppcDefineParamU32(dataSize, 4); + ppcDefineParamPtr(data, void, 5); + ppcDefineParamU32(lockedDataSize, 6); + ppcDefineParamPtr(lockedData, void, 7); + ppcDefineParamPtr(context, void, 8); + + uint8 rawData[0x1C8]; + StackAllocator<NTAGData> readResult; + StackAllocator<uint8, 0x1C8> rwData; + StackAllocator<uint8, 0x1C8> roData; + NTAGNoftHeader noftHeader; + NTAGInfoHeader infoHeader; + NTAGAreaHeader rwHeader; + NTAGAreaHeader roHeader; + + readResult->readOnly = readOnly; + + error = __NTAGConvertNFCError(error); + if (error == 0) + { + // Copy raw and locked data into a contigous buffer + memcpy(rawData, data, dataSize); + memcpy(rawData + dataSize, lockedData, lockedDataSize); + + error = __NTAGParseData(rawData, rwData.GetPointer(), roData.GetPointer(), uid, lockedDataSize, &noftHeader, &infoHeader, &rwHeader, &roHeader); + if (error == 0) + { + memcpy(readResult->uid.uid, uid->uid, sizeof(uid->uid)); + readResult->rwInfo.data = _swapEndianU32(rwData.GetMPTR()); + readResult->roInfo.data = _swapEndianU32(roData.GetMPTR()); + readResult->rwInfo.makerCode = rwHeader.makerCode; + readResult->rwInfo.size = rwHeader.size; + readResult->roInfo.makerCode = roHeader.makerCode; + readResult->rwInfo.identifyCode = rwHeader.identifyCode; + readResult->roInfo.identifyCode = roHeader.identifyCode; + readResult->formatVersion = infoHeader.formatVersion; + readResult->roInfo.size = roHeader.size; + + cemuLog_log(LogType::NTAG, "__NTAGReadCallback: {} {} {}", chan, error, context); + + PPCCoreCallback(gReadCallbacks[chan], chan, 0, readResult.GetPointer(), context); + osLib_returnFromFunction(hCPU, 0); + return; + } + } + + if (uid) + { + memcpy(readResult->uid.uid, uid->uid, sizeof(uid->uid)); + } + readResult->roInfo.size = 0; + readResult->rwInfo.size = 0; + readResult->roInfo.data = MPTR_NULL; + readResult->formatVersion = 0; + readResult->rwInfo.data = MPTR_NULL; + cemuLog_log(LogType::NTAG, "__NTAGReadCallback: {} {} {}", chan, error, context); + PPCCoreCallback(gReadCallbacks[chan], chan, error, readResult.GetPointer(), context); + osLib_returnFromFunction(hCPU, 0); + } + + sint32 NTAGRead(uint32 chan, uint32 timeout, nfc::NFCUid* uid, nfc::NFCUid* uidMask, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + gReadCallbacks[chan] = callback; + + nfc::NFCUid _uid{}, _uidMask{}; + if (uid && uidMask) + { + memcpy(&_uid, uid, sizeof(*uid)); + memcpy(&_uidMask, uidMask, sizeof(*uidMask)); + } + + sint32 result = nfc::NFCRead(chan, timeout, &_uid, &_uidMask, RPLLoader_MakePPCCallable(__NTAGReadCallback), context); + return __NTAGConvertNFCError(result); + } + + void __NTAGReadBeforeWriteCallback(PPCInterpreter_t* hCPU) + { + osLib_returnFromFunction(hCPU, 0); + } + + sint32 NTAGWrite(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + gWriteCallbacks[chan] = callback; + + nfc::NFCUid _uid{}, _uidMask{}; + if (uid) + { + memcpy(&_uid, uid, sizeof(*uid)); + } + memset(_uidMask.uid, 0xff, sizeof(_uidMask.uid)); + + // TODO save write data + + // TODO we probably don't need to read first here + sint32 result = nfc::NFCRead(chan, timeout, &_uid, &_uidMask, RPLLoader_MakePPCCallable(__NTAGReadBeforeWriteCallback), context); + return __NTAGConvertNFCError(result); + } + + sint32 NTAGFormat(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context) + { + cemu_assert(chan < 2); + + // TODO + return 0; + } + + void Initialize() + { + cafeExportRegister("ntag", NTAGInit, LogType::NTAG); + cafeExportRegister("ntag", NTAGInitEx, LogType::NTAG); + cafeExportRegister("ntag", NTAGShutdown, LogType::NTAG); + cafeExportRegister("ntag", NTAGIsInit, LogType::Placeholder); // disabled logging, since this gets spammed + cafeExportRegister("ntag", NTAGProc, LogType::Placeholder); // disabled logging, since this gets spammed + cafeExportRegister("ntag", NTAGSetFormatSettings, LogType::NTAG); + cafeExportRegister("ntag", NTAGSetTagDetectCallback, LogType::NTAG); + cafeExportRegister("ntag", NTAGAbort, LogType::NTAG); + cafeExportRegister("ntag", NTAGRead, LogType::NTAG); + cafeExportRegister("ntag", NTAGWrite, LogType::NTAG); + cafeExportRegister("ntag", NTAGFormat, LogType::NTAG); + } +} diff --git a/src/Cafe/OS/libs/ntag/ntag.h b/src/Cafe/OS/libs/ntag/ntag.h new file mode 100644 index 00000000..1174e6bc --- /dev/null +++ b/src/Cafe/OS/libs/ntag/ntag.h @@ -0,0 +1,94 @@ +#pragma once +#include "Cafe/OS/libs/nfc/nfc.h" + +namespace ntag +{ + struct NTAGFormatSettings + { + /* +0x00 */ uint8 version; + /* +0x04 */ uint32 makerCode; + /* +0x08 */ uint32 indentifyCode; + /* +0x0C */ uint8 reserved[0x1C]; + }; + static_assert(sizeof(NTAGFormatSettings) == 0x28); + +#pragma pack(1) + struct NTAGNoftHeader + { + /* +0x00 */ uint32 magic; + /* +0x04 */ uint8 version; + /* +0x05 */ uint16 writeCount; + /* +0x07 */ uint8 unknown; + }; + static_assert(sizeof(NTAGNoftHeader) == 0x8); +#pragma pack() + + struct NTAGInfoHeader + { + /* +0x00 */ uint16 rwHeaderOffset; + /* +0x02 */ uint16 rwSize; + /* +0x04 */ uint16 roHeaderOffset; + /* +0x06 */ uint16 roSize; + /* +0x08 */ nfc::NFCUid uid; + /* +0x0F */ uint8 formatVersion; + }; + static_assert(sizeof(NTAGInfoHeader) == 0x10); + + struct NTAGAreaHeader + { + /* +0x00 */ uint16 magic; + /* +0x02 */ uint16 offset; + /* +0x04 */ uint16 size; + /* +0x06 */ uint16 padding; + /* +0x08 */ uint32 makerCode; + /* +0x0C */ uint32 identifyCode; + }; + static_assert(sizeof(NTAGAreaHeader) == 0x10); + + struct NTAGAreaInfo + { + /* +0x00 */ MPTR data; + /* +0x04 */ uint16 size; + /* +0x06 */ uint16 padding; + /* +0x08 */ uint32 makerCode; + /* +0x0C */ uint32 identifyCode; + /* +0x10 */ uint8 reserved[0x20]; + }; + static_assert(sizeof(NTAGAreaInfo) == 0x30); + + struct NTAGData + { + /* +0x00 */ nfc::NFCUid uid; + /* +0x07 */ uint8 readOnly; + /* +0x08 */ uint8 formatVersion; + /* +0x09 */ uint8 padding[3]; + /* +0x0C */ NTAGAreaInfo rwInfo; + /* +0x3C */ NTAGAreaInfo roInfo; + /* +0x6C */ uint8 reserved[0x20]; + }; + static_assert(sizeof(NTAGData) == 0x8C); + + sint32 NTAGInit(uint32 chan); + + sint32 NTAGInitEx(uint32 chan); + + sint32 NTAGShutdown(uint32 chan); + + bool NTAGIsInit(uint32 chan); + + void NTAGProc(uint32 chan); + + void NTAGSetFormatSettings(NTAGFormatSettings* formatSettings); + + void NTAGSetTagDetectCallback(uint32 chan, MPTR callback, void* context); + + sint32 NTAGAbort(uint32 chan, MPTR callback, void* context); + + sint32 NTAGRead(uint32 chan, uint32 timeout, nfc::NFCUid* uid, nfc::NFCUid* uidMask, MPTR callback, void* context); + + sint32 NTAGWrite(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context); + + sint32 NTAGFormat(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context); + + void Initialize(); +} diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index 058ab07a..e49ece94 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -51,6 +51,8 @@ const std::map<LogType, std::string> g_logging_window_mapping {LogType::Socket, "Socket"}, {LogType::Save, "Save"}, {LogType::H264, "H264"}, + {LogType::NFC, "NFC"}, + {LogType::NTAG, "NTAG"}, {LogType::Patches, "Graphic pack patches"}, {LogType::TextureCache, "Texture cache"}, {LogType::TextureReadback, "Texture readback"}, diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 8fbb318c..5fd652b3 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -44,6 +44,9 @@ enum class LogType : sint32 nlibcurl = 41, PRUDP = 40, + + NFC = 41, + NTAG = 42, }; template <> diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 097d506e..cb2e988d 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -12,7 +12,7 @@ #include "audio/audioDebuggerWindow.h" #include "gui/canvas/OpenGLCanvas.h" #include "gui/canvas/VulkanCanvas.h" -#include "Cafe/OS/libs/nn_nfp/nn_nfp.h" +#include "Cafe/OS/libs/nfc/nfc.h" #include "Cafe/OS/libs/swkbd/swkbd.h" #include "gui/debugger/DebuggerWindow2.h" #include "util/helpers/helpers.h" @@ -261,7 +261,7 @@ public: return false; uint32 nfcError; std::string path = filenames[0].utf8_string(); - if (nnNfp_touchNfcTagFromFile(_utf8ToPath(path), &nfcError)) + if (nfc::TouchTagFromFile(_utf8ToPath(path), &nfcError)) { GetConfig().AddRecentNfcFile(path); m_window->UpdateNFCMenu(); @@ -749,7 +749,7 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) return; wxString wxStrFilePath = openFileDialog.GetPath(); uint32 nfcError; - if (nnNfp_touchNfcTagFromFile(_utf8ToPath(wxStrFilePath.utf8_string()), &nfcError) == false) + if (nfc::TouchTagFromFile(_utf8ToPath(wxStrFilePath.utf8_string()), &nfcError) == false) { if (nfcError == NFC_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); @@ -772,7 +772,7 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) if (!path.empty()) { uint32 nfcError = 0; - if (nnNfp_touchNfcTagFromFile(_utf8ToPath(path), &nfcError) == false) + if (nfc::TouchTagFromFile(_utf8ToPath(path), &nfcError) == false) { if (nfcError == NFC_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); @@ -2210,6 +2210,8 @@ void MainWindow::RecreateMenu() debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Socket), _("&Socket API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Socket)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Save), _("&Save API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Save)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::H264), _("&H264 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::H264)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NFC), _("&NFC API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NFC)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NTAG), _("&NTAG API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NTAG)); debugLoggingMenu->AppendSeparator(); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Patches), _("&Graphic pack patches"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Patches)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::TextureCache), _("&Texture cache warnings"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::TextureCache)); From 8e8431113a4128330351674ca59771cf203bf8d9 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Fri, 10 May 2024 00:33:31 +0200 Subject: [PATCH 184/314] ntag: Implement NTAGWrite --- src/Cafe/OS/libs/nfc/ndef.cpp | 1 + src/Cafe/OS/libs/nfc/nfc.cpp | 119 +++++++++++++----- src/Cafe/OS/libs/ntag/ntag.cpp | 214 +++++++++++++++++++++++++++++++-- src/Cafe/OS/libs/ntag/ntag.h | 2 +- 4 files changed, 293 insertions(+), 43 deletions(-) diff --git a/src/Cafe/OS/libs/nfc/ndef.cpp b/src/Cafe/OS/libs/nfc/ndef.cpp index f8d87fb8..32097cfd 100644 --- a/src/Cafe/OS/libs/nfc/ndef.cpp +++ b/src/Cafe/OS/libs/nfc/ndef.cpp @@ -6,6 +6,7 @@ namespace ndef { Record::Record() + : mFlags(0), mTNF(NDEF_TNF_EMPTY) { } diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp index 21e9e91b..f8f67ebd 100644 --- a/src/Cafe/OS/libs/nfc/nfc.cpp +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -39,6 +39,7 @@ namespace nfc bool hasTag; uint32 nfcStatus; + std::chrono::time_point<std::chrono::system_clock> touchTime; std::chrono::time_point<std::chrono::system_clock> discoveryTimeout; MPTR tagDetectCallback; @@ -146,7 +147,8 @@ namespace nfc // Look for the unknown TNF which contains the data we care about for (const auto& rec : *ndefMsg) { - if (rec.GetTNF() == ndef::Record::NDEF_TNF_UNKNOWN) { + if (rec.GetTNF() == ndef::Record::NDEF_TNF_UNKNOWN) + { dataSize = rec.GetPayload().size(); cemu_assert(dataSize < 0x200); memcpy(data.GetPointer(), rec.GetPayload().data(), dataSize); @@ -174,11 +176,6 @@ namespace nfc { result = -0xBFE; } - - // Clear tag status after read - // TODO this is not really nice here - ctx->nfcStatus &= ~NFC_STATUS_HAS_TAG; - ctx->tag = {}; } else { @@ -194,9 +191,42 @@ namespace nfc ctx->state = NFC_STATE_IDLE; - // TODO write to file + sint32 result; - PPCCoreCallback(ctx->writeCallback, chan, 0, ctx->writeContext); + if (ctx->tag) + { + // Update tag NDEF data + ctx->tag->SetNDEFData(ctx->writeMessage.ToBytes()); + + // TODO remove this once writing is confirmed working + fs::path newPath = ctx->tagPath; + if (newPath.extension() != ".bak") + { + newPath += ".bak"; + } + cemuLog_log(LogType::Force, "Saving tag as {}...", newPath.string()); + + // open file for writing + FileStream* fs = FileStream::createFile2(newPath); + if (!fs) + { + result = -0x2DE; + } + else + { + auto tagBytes = ctx->tag->ToBytes(); + fs->writeData(tagBytes.data(), tagBytes.size()); + delete fs; + + result = 0; + } + } + else + { + result = -0x2DD; + } + + PPCCoreCallback(ctx->writeCallback, chan, result, ctx->writeContext); } void __NFCHandleAbort(uint32 chan) @@ -231,6 +261,29 @@ namespace nfc PPCCoreCallback(ctx->rawCallback, chan, result, responseSize, responseData, ctx->rawContext); } + bool __NFCShouldHandleState(NFCContext* ctx) + { + // Always handle abort + if (ctx->state == NFC_STATE_ABORT) + { + return true; + } + + // Do we have a tag? + if (ctx->nfcStatus & NFC_STATUS_HAS_TAG) + { + return true; + } + + // Did the timeout expire? + if (ctx->discoveryTimeout < std::chrono::system_clock::now()) + { + return true; + } + + return false; + } + void NFCProc(uint32 chan) { cemu_assert(chan < 2); @@ -242,6 +295,11 @@ namespace nfc return; } + if (ctx->state == NFC_STATE_INITIALIZED) + { + ctx->state = NFC_STATE_IDLE; + } + // Check if the detect callback should be called if (ctx->nfcStatus & NFC_STATUS_HAS_TAG) { @@ -254,6 +312,14 @@ namespace nfc ctx->hasTag = true; } + + // Check if the tag should be removed again + if (ctx->touchTime + std::chrono::seconds(2) < std::chrono::system_clock::now()) + { + ctx->nfcStatus &= ~NFC_STATUS_HAS_TAG; + ctx->tag = {}; + ctx->tagPath = ""; + } } else { @@ -268,33 +334,25 @@ namespace nfc } } - switch (ctx->state) + if (__NFCShouldHandleState(ctx)) { - case NFC_STATE_INITIALIZED: - ctx->state = NFC_STATE_IDLE; - break; - case NFC_STATE_IDLE: - break; - case NFC_STATE_READ: - // Do we have a tag or did the timeout expire? - if ((ctx->nfcStatus & NFC_STATUS_HAS_TAG) || ctx->discoveryTimeout < std::chrono::system_clock::now()) + switch (ctx->state) { + case NFC_STATE_READ: __NFCHandleRead(chan); - } - break; - case NFC_STATE_WRITE: - __NFCHandleWrite(chan); - break; - case NFC_STATE_ABORT: - __NFCHandleAbort(chan); - break; - case NFC_STATE_RAW: - // Do we have a tag or did the timeout expire? - if ((ctx->nfcStatus & NFC_STATUS_HAS_TAG) || ctx->discoveryTimeout < std::chrono::system_clock::now()) - { + break; + case NFC_STATE_WRITE: + __NFCHandleWrite(chan); + break; + case NFC_STATE_ABORT: + __NFCHandleAbort(chan); + break; + case NFC_STATE_RAW: __NFCHandleRaw(chan); + break; + default: + break; } - break; } } @@ -589,6 +647,7 @@ namespace nfc ctx->nfcStatus |= NFC_STATUS_HAS_TAG; ctx->tagPath = filePath; + ctx->touchTime = std::chrono::system_clock::now(); *nfcError = NFC_ERROR_NONE; return true; diff --git a/src/Cafe/OS/libs/ntag/ntag.cpp b/src/Cafe/OS/libs/ntag/ntag.cpp index 8bdbb66f..18ed798a 100644 --- a/src/Cafe/OS/libs/ntag/ntag.cpp +++ b/src/Cafe/OS/libs/ntag/ntag.cpp @@ -9,7 +9,10 @@ namespace ntag { struct NTAGWriteData { - + uint16 size; + uint8 data[0x1C8]; + nfc::NFCUid uid; + nfc::NFCUid uidMask; }; NTAGWriteData gWriteData[2]; @@ -72,7 +75,7 @@ namespace ntag { gFormatSettings.version = formatSettings->version; gFormatSettings.makerCode = _swapEndianU32(formatSettings->makerCode); - gFormatSettings.indentifyCode = _swapEndianU32(formatSettings->indentifyCode); + gFormatSettings.identifyCode = _swapEndianU32(formatSettings->identifyCode); } void __NTAGDetectCallback(PPCInterpreter_t* hCPU) @@ -220,7 +223,7 @@ namespace ntag return true; } - sint32 __NTAGDecryptData(void* decryptedData, void* rawData) + sint32 __NTAGDecryptData(void* decryptedData, const void* rawData) { StackAllocator<iosu::ccr_nfc::CCRNFCCryptData> nfcRawData, nfcInData, nfcOutData; @@ -256,7 +259,41 @@ namespace ntag sint32 __NTAGValidateHeaders(NTAGNoftHeader* noftHeader, NTAGInfoHeader* infoHeader, NTAGAreaHeader* rwHeader, NTAGAreaHeader* roHeader) { - // TODO + if (infoHeader->formatVersion != gFormatSettings.version || noftHeader->version != 0x1) + { + cemuLog_log(LogType::Force, "Invalid format version"); + return -0x2710; + } + + if (_swapEndianU32(noftHeader->magic) != 0x4E4F4654 /* 'NOFT' */ || + _swapEndianU16(rwHeader->magic) != 0x5257 /* 'RW' */ || + _swapEndianU16(roHeader->magic) != 0x524F /* 'RO' */) + { + cemuLog_log(LogType::Force, "Invalid header magic"); + return -0x270F; + } + + if (_swapEndianU32(rwHeader->makerCode) != gFormatSettings.makerCode || + _swapEndianU32(roHeader->makerCode) != gFormatSettings.makerCode) + { + cemuLog_log(LogType::Force, "Invalid maker code"); + return -0x270E; + } + + if (infoHeader->formatVersion != 0 && + (_swapEndianU32(rwHeader->identifyCode) != gFormatSettings.identifyCode || + _swapEndianU32(roHeader->identifyCode) != gFormatSettings.identifyCode)) + { + cemuLog_log(LogType::Force, "Invalid identify code"); + return -0x2709; + } + + if (_swapEndianU16(rwHeader->size) + _swapEndianU16(roHeader->size) != 0x130) + { + cemuLog_log(LogType::Force, "Invalid data size"); + return -0x270D; + } + return 0; } @@ -264,8 +301,13 @@ namespace ntag { memcpy(noftHeader, data + 0x20, sizeof(NTAGNoftHeader)); memcpy(infoHeader, data + 0x198, sizeof(NTAGInfoHeader)); + + cemu_assert(_swapEndianU16(infoHeader->rwHeaderOffset) + sizeof(NTAGAreaHeader) < 0x200); + cemu_assert(_swapEndianU16(infoHeader->roHeaderOffset) + sizeof(NTAGAreaHeader) < 0x200); + memcpy(rwHeader, data + _swapEndianU16(infoHeader->rwHeaderOffset), sizeof(NTAGAreaHeader)); memcpy(roHeader, data + _swapEndianU16(infoHeader->roHeaderOffset), sizeof(NTAGAreaHeader)); + return __NTAGValidateHeaders(noftHeader, infoHeader, rwHeader, roHeader); } @@ -317,7 +359,7 @@ namespace ntag ppcDefineParamPtr(lockedData, void, 7); ppcDefineParamPtr(context, void, 8); - uint8 rawData[0x1C8]; + uint8 rawData[0x1C8]{}; StackAllocator<NTAGData> readResult; StackAllocator<uint8, 0x1C8> rwData; StackAllocator<uint8, 0x1C8> roData; @@ -331,6 +373,9 @@ namespace ntag error = __NTAGConvertNFCError(error); if (error == 0) { + memset(rwData.GetPointer(), 0, 0x1C8); + memset(roData.GetPointer(), 0, 0x1C8); + // Copy raw and locked data into a contigous buffer memcpy(rawData, data, dataSize); memcpy(rawData + dataSize, lockedData, lockedDataSize); @@ -388,28 +433,173 @@ namespace ntag return __NTAGConvertNFCError(result); } + sint32 __NTAGEncryptData(void* encryptedData, const void* rawData) + { + StackAllocator<iosu::ccr_nfc::CCRNFCCryptData> nfcRawData, nfcInData, nfcOutData; + + if (!ccrNfcOpened) + { + gCcrNfcHandle = coreinit::IOS_Open("/dev/ccr_nfc", 0); + } + + // Prepare nfc buffer + nfcRawData->version = 0; + memcpy(nfcRawData->data, rawData, 0x1C8); + __NTAGRawDataToNfcData(nfcRawData.GetPointer(), nfcInData.GetPointer()); + + // Encrypt + sint32 result = coreinit::IOS_Ioctl(gCcrNfcHandle, 1, nfcInData.GetPointer(), sizeof(iosu::ccr_nfc::CCRNFCCryptData), nfcOutData.GetPointer(), sizeof(iosu::ccr_nfc::CCRNFCCryptData)); + + // Unpack nfc buffer + __NTAGNfcDataToRawData(nfcOutData.GetPointer(), nfcRawData.GetPointer()); + memcpy(encryptedData, nfcRawData->data, 0x1C8); + + return result; + } + + sint32 __NTAGPrepareWriteData(void* outBuffer, uint32 dataSize, const void* data, const void* tagData, NTAGNoftHeader* noftHeader, NTAGAreaHeader* rwHeader) + { + uint8 decryptedBuffer[0x1C8]; + uint8 encryptedBuffer[0x1C8]; + + memcpy(decryptedBuffer, tagData, 0x1C8); + + // Fill the rest of the rw area with random data + if (dataSize < _swapEndianU16(rwHeader->size)) + { + uint8 randomBuffer[0x1C8]; + for (int i = 0; i < sizeof(randomBuffer); i++) + { + randomBuffer[i] = rand() & 0xFF; + } + + memcpy(decryptedBuffer + _swapEndianU16(rwHeader->offset) + dataSize, randomBuffer, _swapEndianU16(rwHeader->size) - dataSize); + } + + // Make sure the data fits into the rw area + if (_swapEndianU16(rwHeader->size) < dataSize) + { + return -0x270D; + } + + // Update write count (check for overflow) + if ((_swapEndianU16(noftHeader->writeCount) & 0x7fff) == 0x7fff) + { + noftHeader->writeCount = _swapEndianU16(_swapEndianU16(noftHeader->writeCount) & 0x8000); + } + else + { + noftHeader->writeCount = _swapEndianU16(_swapEndianU16(noftHeader->writeCount) + 1); + } + + memcpy(decryptedBuffer + 0x20, noftHeader, sizeof(noftHeader)); + memcpy(decryptedBuffer + _swapEndianU16(rwHeader->offset), data, dataSize); + + // Encrypt + sint32 result = __NTAGEncryptData(encryptedBuffer, decryptedBuffer); + if (result < 0) + { + return result; + } + + memcpy(outBuffer, encryptedBuffer, _swapEndianU16(rwHeader->size) + 0x28); + return 0; + } + + void __NTAGWriteCallback(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(chan, 0); + ppcDefineParamS32(error, 1); + ppcDefineParamPtr(context, void, 2); + + PPCCoreCallback(gWriteCallbacks[chan], chan, __NTAGConvertNFCError(error), context); + + osLib_returnFromFunction(hCPU, 0); + } + void __NTAGReadBeforeWriteCallback(PPCInterpreter_t* hCPU) { + ppcDefineParamU32(chan, 0); + ppcDefineParamS32(error, 1); + ppcDefineParamPtr(uid, nfc::NFCUid, 2); + ppcDefineParamU32(readOnly, 3); + ppcDefineParamU32(dataSize, 4); + ppcDefineParamPtr(data, void, 5); + ppcDefineParamU32(lockedDataSize, 6); + ppcDefineParamPtr(lockedData, void, 7); + ppcDefineParamPtr(context, void, 8); + + uint8 rawData[0x1C8]{}; + uint8 rwData[0x1C8]{}; + uint8 roData[0x1C8]{}; + NTAGNoftHeader noftHeader; + NTAGInfoHeader infoHeader; + NTAGAreaHeader rwHeader; + NTAGAreaHeader roHeader; + uint8 writeBuffer[0x1C8]{}; + + error = __NTAGConvertNFCError(error); + if (error == 0) + { + // Copy raw and locked data into a contigous buffer + memcpy(rawData, data, dataSize); + memcpy(rawData + dataSize, lockedData, lockedDataSize); + + error = __NTAGParseData(rawData, rwData, roData, uid, lockedDataSize, &noftHeader, &infoHeader, &rwHeader, &roHeader); + if (error < 0) + { + cemuLog_log(LogType::Force, "Failed to parse data before write"); + PPCCoreCallback(gWriteCallbacks[chan], chan, -0x3E3, context); + osLib_returnFromFunction(hCPU, 0); + return; + } + + // Prepare data + memcpy(rawData + _swapEndianU16(infoHeader.rwHeaderOffset), &rwHeader, sizeof(rwHeader)); + memcpy(rawData + _swapEndianU16(infoHeader.roHeaderOffset), &roHeader, sizeof(roHeader)); + memcpy(rawData + _swapEndianU16(roHeader.offset), roData, _swapEndianU16(roHeader.size)); + error = __NTAGPrepareWriteData(writeBuffer, gWriteData[chan].size, gWriteData[chan].data, rawData, &noftHeader, &rwHeader); + if (error < 0) + { + cemuLog_log(LogType::Force, "Failed to prepare write data"); + PPCCoreCallback(gWriteCallbacks[chan], chan, -0x3E3, context); + osLib_returnFromFunction(hCPU, 0); + return; + } + + // Write data to tag + error = nfc::NFCWrite(chan, 200, &gWriteData[chan].uid, &gWriteData[chan].uidMask, + _swapEndianU16(rwHeader.size) + 0x28, writeBuffer, RPLLoader_MakePPCCallable(__NTAGWriteCallback), context); + if (error >= 0) + { + osLib_returnFromFunction(hCPU, 0); + return; + } + + error = __NTAGConvertNFCError(error); + } + + PPCCoreCallback(gWriteCallbacks[chan], chan, error, context); osLib_returnFromFunction(hCPU, 0); } sint32 NTAGWrite(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context) { cemu_assert(chan < 2); + cemu_assert(rwSize < 0x1C8); gWriteCallbacks[chan] = callback; - nfc::NFCUid _uid{}, _uidMask{}; if (uid) { - memcpy(&_uid, uid, sizeof(*uid)); + memcpy(&gWriteData[chan].uid, uid, sizeof(nfc::NFCUid)); } - memset(_uidMask.uid, 0xff, sizeof(_uidMask.uid)); + memset(&gWriteData[chan].uidMask, 0xff, sizeof(nfc::NFCUid)); - // TODO save write data + gWriteData[chan].size = rwSize; + memcpy(gWriteData[chan].data, rwData, rwSize); - // TODO we probably don't need to read first here - sint32 result = nfc::NFCRead(chan, timeout, &_uid, &_uidMask, RPLLoader_MakePPCCallable(__NTAGReadBeforeWriteCallback), context); + sint32 result = nfc::NFCRead(chan, timeout, &gWriteData[chan].uid, &gWriteData[chan].uidMask, RPLLoader_MakePPCCallable(__NTAGReadBeforeWriteCallback), context); return __NTAGConvertNFCError(result); } @@ -418,7 +608,7 @@ namespace ntag cemu_assert(chan < 2); // TODO - return 0; + return -1; } void Initialize() diff --git a/src/Cafe/OS/libs/ntag/ntag.h b/src/Cafe/OS/libs/ntag/ntag.h index 1174e6bc..697c065e 100644 --- a/src/Cafe/OS/libs/ntag/ntag.h +++ b/src/Cafe/OS/libs/ntag/ntag.h @@ -7,7 +7,7 @@ namespace ntag { /* +0x00 */ uint8 version; /* +0x04 */ uint32 makerCode; - /* +0x08 */ uint32 indentifyCode; + /* +0x08 */ uint32 identifyCode; /* +0x0C */ uint8 reserved[0x1C]; }; static_assert(sizeof(NTAGFormatSettings) == 0x28); From 41fe598e333920196aa8fd6033aaa78172e21655 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Fri, 17 May 2024 14:19:51 +0200 Subject: [PATCH 185/314] nfc: Implement UID filter --- src/Cafe/OS/libs/nfc/nfc.cpp | 118 ++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 42 deletions(-) diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp index f8f67ebd..4505f3b1 100644 --- a/src/Cafe/OS/libs/nfc/nfc.cpp +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -41,6 +41,10 @@ namespace nfc uint32 nfcStatus; std::chrono::time_point<std::chrono::system_clock> touchTime; std::chrono::time_point<std::chrono::system_clock> discoveryTimeout; + struct { + NFCUid uid; + NFCUid mask; + } filter; MPTR tagDetectCallback; void* tagDetectContext; @@ -124,6 +128,19 @@ namespace nfc return gNFCContexts[chan].isInitialized; } + bool __NFCCompareUid(NFCUid* uid, NFCUid* filterUid, NFCUid* filterMask) + { + for (int i = 0; i < sizeof(uid->uid); i++) + { + if ((uid->uid[i] & filterMask->uid[i]) != filterUid->uid[i]) + { + return false; + } + } + + return true; + } + void __NFCHandleRead(uint32 chan) { NFCContext* ctx = &gNFCContexts[chan]; @@ -140,32 +157,38 @@ namespace nfc if (ctx->tag) { - // Try to parse ndef message - auto ndefMsg = ndef::Message::FromBytes(ctx->tag->GetNDEFData()); - if (ndefMsg) + // Compare UID + memcpy(uid.GetPointer(), ctx->tag->GetUIDBlock().data(), sizeof(NFCUid)); + if (__NFCCompareUid(uid.GetPointer(), &ctx->filter.uid, &ctx->filter.mask)) { - // Look for the unknown TNF which contains the data we care about - for (const auto& rec : *ndefMsg) + // Try to parse ndef message + auto ndefMsg = ndef::Message::FromBytes(ctx->tag->GetNDEFData()); + if (ndefMsg) { - if (rec.GetTNF() == ndef::Record::NDEF_TNF_UNKNOWN) + // Look for the unknown TNF which contains the data we care about + for (const auto& rec : *ndefMsg) { - dataSize = rec.GetPayload().size(); - cemu_assert(dataSize < 0x200); - memcpy(data.GetPointer(), rec.GetPayload().data(), dataSize); - break; + if (rec.GetTNF() == ndef::Record::NDEF_TNF_UNKNOWN) + { + dataSize = rec.GetPayload().size(); + cemu_assert(dataSize < 0x200); + memcpy(data.GetPointer(), rec.GetPayload().data(), dataSize); + break; + } } - } - if (dataSize) - { - // Get locked data - lockedDataSize = ctx->tag->GetLockedArea().size(); - memcpy(lockedData.GetPointer(), ctx->tag->GetLockedArea().data(), lockedDataSize); + if (dataSize) + { + // Get locked data + lockedDataSize = ctx->tag->GetLockedArea().size(); + memcpy(lockedData.GetPointer(), ctx->tag->GetLockedArea().data(), lockedDataSize); - // Fill in uid - memcpy(uid.GetPointer(), ctx->tag->GetUIDBlock().data(), sizeof(NFCUid)); - - result = 0; + result = 0; + } + else + { + result = -0xBFE; + } } else { @@ -174,7 +197,7 @@ namespace nfc } else { - result = -0xBFE; + result = -0x1F6; } } else @@ -195,30 +218,39 @@ namespace nfc if (ctx->tag) { - // Update tag NDEF data - ctx->tag->SetNDEFData(ctx->writeMessage.ToBytes()); - - // TODO remove this once writing is confirmed working - fs::path newPath = ctx->tagPath; - if (newPath.extension() != ".bak") + NFCUid uid; + memcpy(&uid, ctx->tag->GetUIDBlock().data(), sizeof(NFCUid)); + if (__NFCCompareUid(&uid, &ctx->filter.uid, &ctx->filter.mask)) { - newPath += ".bak"; - } - cemuLog_log(LogType::Force, "Saving tag as {}...", newPath.string()); + // Update tag NDEF data + ctx->tag->SetNDEFData(ctx->writeMessage.ToBytes()); - // open file for writing - FileStream* fs = FileStream::createFile2(newPath); - if (!fs) - { - result = -0x2DE; + // TODO remove this once writing is confirmed working + fs::path newPath = ctx->tagPath; + if (newPath.extension() != ".bak") + { + newPath += ".bak"; + } + cemuLog_log(LogType::Force, "Saving tag as {}...", newPath.string()); + + // open file for writing + FileStream* fs = FileStream::createFile2(newPath); + if (!fs) + { + result = -0x2DE; + } + else + { + auto tagBytes = ctx->tag->ToBytes(); + fs->writeData(tagBytes.data(), tagBytes.size()); + delete fs; + + result = 0; + } } else { - auto tagBytes = ctx->tag->ToBytes(); - fs->writeData(tagBytes.data(), tagBytes.size()); - delete fs; - - result = 0; + result = -0x2F6; } } else @@ -548,7 +580,8 @@ namespace nfc ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); } - // TODO uid filter? + memcpy(&ctx->filter.uid, uid, sizeof(*uid)); + memcpy(&ctx->filter.mask, uidMask, sizeof(*uidMask)); return 0; } @@ -598,7 +631,8 @@ namespace nfc ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); } - // TODO uid filter? + memcpy(&ctx->filter.uid, uid, sizeof(*uid)); + memcpy(&ctx->filter.mask, uidMask, sizeof(*uidMask)); return 0; } From 8fe69cd0fb6be8d916a963290e7c5525c0848bb5 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 18 May 2024 16:38:52 +0200 Subject: [PATCH 186/314] Properly implement NFC result codes --- src/Cafe/OS/libs/nfc/nfc.cpp | 133 ++++++++++++++++++--------------- src/Cafe/OS/libs/nfc/nfc.h | 36 ++++++++- src/Cafe/OS/libs/ntag/ntag.cpp | 47 ++++++++---- src/Cafe/OS/libs/ntag/ntag.h | 7 ++ src/gui/MainWindow.cpp | 18 ++--- 5 files changed, 153 insertions(+), 88 deletions(-) diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp index 4505f3b1..818c7339 100644 --- a/src/Cafe/OS/libs/nfc/nfc.cpp +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -7,27 +7,25 @@ #include "TagV0.h" #include "ndef.h" -// TODO move errors to header and allow ntag to convert them +#define NFC_MODE_INVALID -1 +#define NFC_MODE_IDLE 0 +#define NFC_MODE_ACTIVE 1 -#define NFC_MODE_INVALID -1 -#define NFC_MODE_IDLE 0 -#define NFC_MODE_ACTIVE 1 +#define NFC_STATE_UNINITIALIZED 0x0 +#define NFC_STATE_INITIALIZED 0x1 +#define NFC_STATE_IDLE 0x2 +#define NFC_STATE_READ 0x3 +#define NFC_STATE_WRITE 0x4 +#define NFC_STATE_ABORT 0x5 +#define NFC_STATE_FORMAT 0x6 +#define NFC_STATE_SET_READ_ONLY 0x7 +#define NFC_STATE_TAG_PRESENT 0x8 +#define NFC_STATE_DETECT 0x9 +#define NFC_STATE_SEND_RAW_DATA 0xA -#define NFC_STATE_UNINITIALIZED 0x0 -#define NFC_STATE_INITIALIZED 0x1 -#define NFC_STATE_IDLE 0x2 -#define NFC_STATE_READ 0x3 -#define NFC_STATE_WRITE 0x4 -#define NFC_STATE_ABORT 0x5 -#define NFC_STATE_FORMAT 0x6 -#define NFC_STATE_SET_READ_ONLY 0x7 -#define NFC_STATE_TAG_PRESENT 0x8 -#define NFC_STATE_DETECT 0x9 -#define NFC_STATE_RAW 0xA - -#define NFC_STATUS_COMMAND_COMPLETE 0x1 -#define NFC_STATUS_READY 0x2 -#define NFC_STATUS_HAS_TAG 0x4 +#define NFC_STATUS_COMMAND_COMPLETE 0x1 +#define NFC_STATUS_READY 0x2 +#define NFC_STATUS_HAS_TAG 0x4 namespace nfc { @@ -107,7 +105,7 @@ namespace nfc ctx->isInitialized = true; ctx->state = NFC_STATE_INITIALIZED; - return 0; + return NFC_RESULT_SUCCESS; } sint32 NFCShutdown(uint32 chan) @@ -118,7 +116,7 @@ namespace nfc __NFCClearContext(ctx); - return 0; + return NFC_RESULT_SUCCESS; } bool NFCIsInit(uint32 chan) @@ -183,26 +181,26 @@ namespace nfc lockedDataSize = ctx->tag->GetLockedArea().size(); memcpy(lockedData.GetPointer(), ctx->tag->GetLockedArea().data(), lockedDataSize); - result = 0; + result = NFC_RESULT_SUCCESS; } else { - result = -0xBFE; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_TAG_PARSE, NFC_RESULT_INVALID_TAG); } } else { - result = -0xBFE; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_TAG_PARSE, NFC_RESULT_INVALID_TAG); } } else { - result = -0x1F6; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_READ, NFC_RESULT_UID_MISMATCH); } } else { - result = -0x1DD; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_READ, NFC_RESULT_NO_TAG); } PPCCoreCallback(ctx->readCallback, chan, result, uid.GetPointer(), readOnly, dataSize, data.GetPointer(), lockedDataSize, lockedData.GetPointer(), ctx->readContext); @@ -231,13 +229,13 @@ namespace nfc { newPath += ".bak"; } - cemuLog_log(LogType::Force, "Saving tag as {}...", newPath.string()); + cemuLog_log(LogType::NFC, "Saving tag as {}...", newPath.string()); // open file for writing FileStream* fs = FileStream::createFile2(newPath); if (!fs) { - result = -0x2DE; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, 0x22); } else { @@ -245,17 +243,17 @@ namespace nfc fs->writeData(tagBytes.data(), tagBytes.size()); delete fs; - result = 0; + result = NFC_RESULT_SUCCESS; } } else { - result = -0x2F6; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, NFC_RESULT_UID_MISMATCH); } } else { - result = -0x2DD; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, NFC_RESULT_NO_TAG); } PPCCoreCallback(ctx->writeCallback, chan, result, ctx->writeContext); @@ -279,11 +277,11 @@ namespace nfc sint32 result; if (ctx->nfcStatus & NFC_STATUS_HAS_TAG) { - result = 0; + result = NFC_RESULT_SUCCESS; } else { - result = -0x9DD; + result = NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_NO_TAG); } // We don't actually send any commands/responses @@ -379,12 +377,15 @@ namespace nfc case NFC_STATE_ABORT: __NFCHandleAbort(chan); break; - case NFC_STATE_RAW: + case NFC_STATE_SEND_RAW_DATA: __NFCHandleRaw(chan); break; default: break; } + + // Return back to idle mode + ctx->mode = NFC_MODE_IDLE; } } @@ -410,17 +411,17 @@ namespace nfc if (!NFCIsInit(chan)) { - return -0xAE0; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SET_MODE, NFC_RESULT_UNINITIALIZED); } if (ctx->state == NFC_STATE_UNINITIALIZED) { - return -0xADF; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SET_MODE, NFC_RESULT_INVALID_STATE); } ctx->mode = mode; - return 0; + return NFC_RESULT_SUCCESS; } void NFCSetTagDetectCallback(uint32 chan, MPTR callback, void* context) @@ -440,19 +441,30 @@ namespace nfc if (!NFCIsInit(chan)) { - return -0x6E0; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_ABORT, NFC_RESULT_UNINITIALIZED); } if (ctx->state <= NFC_STATE_IDLE) { - return -0x6DF; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_ABORT, NFC_RESULT_INVALID_STATE); } ctx->state = NFC_STATE_ABORT; ctx->abortCallback = callback; ctx->abortContext = context; - return 0; + return NFC_RESULT_SUCCESS; + } + + sint32 __NFCConvertGetTagInfoResult(sint32 result) + { + if (result == NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_NO_TAG)) + { + return NFC_MAKE_RESULT(NFC_RESULT_BASE_GET_TAG_INFO, NFC_RESULT_TAG_INFO_TIMEOUT); + } + + // TODO convert the rest of the results + return result; } void __NFCGetTagInfoCallback(PPCInterpreter_t* hCPU) @@ -465,8 +477,7 @@ namespace nfc NFCContext* ctx = &gNFCContexts[chan]; - // TODO convert error - error = error; + error = __NFCConvertGetTagInfoResult(error); if (error == 0 && ctx->tag) { // this is usually parsed from response data @@ -496,7 +507,7 @@ namespace nfc ctx->getTagInfoCallback = callback; sint32 result = NFCSendRawData(chan, true, discoveryTimeout, 1000U, 0, 0, nullptr, RPLLoader_MakePPCCallable(__NFCGetTagInfoCallback), context); - return result; // TODO convert result + return __NFCConvertGetTagInfoResult(result); } sint32 NFCSendRawData(uint32 chan, bool startDiscovery, uint32 discoveryTimeout, uint32 commandTimeout, uint32 commandSize, uint32 responseSize, void* commandData, MPTR callback, void* context) @@ -507,26 +518,26 @@ namespace nfc if (!NFCIsInit(chan)) { - return -0x9E0; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_UNINITIALIZED); } // Only allow discovery if (!startDiscovery) { - return -0x9DC; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_INVALID_MODE); } if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) { - return -0x9DC; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_INVALID_MODE); } if (ctx->state != NFC_STATE_IDLE) { - return -0x9DF; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_SEND_RAW_DATA, NFC_RESULT_INVALID_STATE); } - ctx->state = NFC_STATE_RAW; + ctx->state = NFC_STATE_SEND_RAW_DATA; ctx->rawCallback = callback; ctx->rawContext = context; @@ -540,7 +551,7 @@ namespace nfc ctx->discoveryTimeout = std::chrono::system_clock::now() + std::chrono::milliseconds(discoveryTimeout); } - return 0; + return NFC_RESULT_SUCCESS; } sint32 NFCRead(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, MPTR callback, void* context) @@ -551,21 +562,19 @@ namespace nfc if (!NFCIsInit(chan)) { - return -0x1E0; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_READ, NFC_RESULT_UNINITIALIZED); } if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) { - return -0x1DC; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_READ, NFC_RESULT_INVALID_MODE); } if (ctx->state != NFC_STATE_IDLE) { - return -0x1DF; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_READ, NFC_RESULT_INVALID_STATE); } - cemuLog_log(LogType::NFC, "starting read"); - ctx->state = NFC_STATE_READ; ctx->readCallback = callback; ctx->readContext = context; @@ -583,7 +592,7 @@ namespace nfc memcpy(&ctx->filter.uid, uid, sizeof(*uid)); memcpy(&ctx->filter.mask, uidMask, sizeof(*uidMask)); - return 0; + return NFC_RESULT_SUCCESS; } sint32 NFCWrite(uint32 chan, uint32 discoveryTimeout, NFCUid* uid, NFCUid* uidMask, uint32 size, void* data, MPTR callback, void* context) @@ -594,17 +603,17 @@ namespace nfc if (!NFCIsInit(chan)) { - return -0x2e0; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, NFC_RESULT_UNINITIALIZED); } if (NFCGetMode(chan) == NFC_MODE_ACTIVE && NFCSetMode(chan, NFC_MODE_IDLE) < 0) { - return -0x2dc; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, NFC_RESULT_INVALID_MODE); } if (ctx->state != NFC_STATE_IDLE) { - return -0x1df; + return NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, NFC_RESULT_INVALID_STATE); } // Create unknown record which contains the rw area @@ -634,7 +643,7 @@ namespace nfc memcpy(&ctx->filter.uid, uid, sizeof(*uid)); memcpy(&ctx->filter.mask, uidMask, sizeof(*uidMask)); - return 0; + return NFC_RESULT_SUCCESS; } void Initialize() @@ -668,14 +677,14 @@ namespace nfc auto nfcData = FileStream::LoadIntoMemory(filePath); if (!nfcData) { - *nfcError = NFC_ERROR_NO_ACCESS; + *nfcError = NFC_TOUCH_TAG_ERROR_NO_ACCESS; return false; } ctx->tag = TagV0::FromBytes(std::as_bytes(std::span(nfcData->data(), nfcData->size()))); if (!ctx->tag) { - *nfcError = NFC_ERROR_INVALID_FILE_FORMAT; + *nfcError = NFC_TOUCH_TAG_ERROR_INVALID_FILE_FORMAT; return false; } @@ -683,7 +692,7 @@ namespace nfc ctx->tagPath = filePath; ctx->touchTime = std::chrono::system_clock::now(); - *nfcError = NFC_ERROR_NONE; + *nfcError = NFC_TOUCH_TAG_ERROR_NONE; return true; } } diff --git a/src/Cafe/OS/libs/nfc/nfc.h b/src/Cafe/OS/libs/nfc/nfc.h index 2ebdd2a4..ea959cd1 100644 --- a/src/Cafe/OS/libs/nfc/nfc.h +++ b/src/Cafe/OS/libs/nfc/nfc.h @@ -1,9 +1,39 @@ #pragma once // CEMU NFC error codes -#define NFC_ERROR_NONE (0) -#define NFC_ERROR_NO_ACCESS (1) -#define NFC_ERROR_INVALID_FILE_FORMAT (2) +#define NFC_TOUCH_TAG_ERROR_NONE (0) +#define NFC_TOUCH_TAG_ERROR_NO_ACCESS (1) +#define NFC_TOUCH_TAG_ERROR_INVALID_FILE_FORMAT (2) + +// NFC result base +#define NFC_RESULT_BASE_INIT (-0x100) +#define NFC_RESULT_BASE_READ (-0x200) +#define NFC_RESULT_BASE_WRITE (-0x300) +#define NFC_RESULT_BASE_FORMAT (-0x400) +#define NFC_RESULT_BASE_SET_READ_ONLY (-0x500) +#define NFC_RESULT_BASE_IS_TAG_PRESENT (-0x600) +#define NFC_RESULT_BASE_ABORT (-0x700) +#define NFC_RESULT_BASE_SHUTDOWN (-0x800) +#define NFC_RESULT_BASE_DETECT (-0x900) +#define NFC_RESULT_BASE_SEND_RAW_DATA (-0xA00) +#define NFC_RESULT_BASE_SET_MODE (-0xB00) +#define NFC_RESULT_BASE_TAG_PARSE (-0xC00) +#define NFC_RESULT_BASE_GET_TAG_INFO (-0x1400) + +// NFC result status +#define NFC_RESULT_NO_TAG (0x01) +#define NFC_RESULT_INVALID_TAG (0x02) +#define NFC_RESULT_UID_MISMATCH (0x0A) +#define NFC_RESULT_UNINITIALIZED (0x20) +#define NFC_RESULT_INVALID_STATE (0x21) +#define NFC_RESULT_INVALID_MODE (0x24) +#define NFC_RESULT_TAG_INFO_TIMEOUT (0x7A) + +// Result macros +#define NFC_RESULT_SUCCESS (0) +#define NFC_RESULT_BASE_MASK (0xFFFFFF00) +#define NFC_RESULT_MASK (0x000000FF) +#define NFC_MAKE_RESULT(base, result) ((base) | (result)) #define NFC_PROTOCOL_T1T 0x1 #define NFC_PROTOCOL_T2T 0x2 diff --git a/src/Cafe/OS/libs/ntag/ntag.cpp b/src/Cafe/OS/libs/ntag/ntag.cpp index 18ed798a..24617791 100644 --- a/src/Cafe/OS/libs/ntag/ntag.cpp +++ b/src/Cafe/OS/libs/ntag/ntag.cpp @@ -26,10 +26,27 @@ namespace ntag MPTR gReadCallbacks[2]; MPTR gWriteCallbacks[2]; - sint32 __NTAGConvertNFCError(sint32 error) + sint32 __NTAGConvertNFCResult(sint32 result) { - // TODO - return error; + if (result == NFC_RESULT_SUCCESS) + { + return NTAG_RESULT_SUCCESS; + } + + switch (result & NFC_RESULT_MASK) + { + case NFC_RESULT_UNINITIALIZED: + return NTAG_RESULT_UNINITIALIZED; + case NFC_RESULT_INVALID_STATE: + return NTAG_RESULT_INVALID_STATE; + case NFC_RESULT_NO_TAG: + return NTAG_RESULT_NO_TAG; + case NFC_RESULT_UID_MISMATCH: + return NTAG_RESULT_UID_MISMATCH; + } + + // TODO convert more errors + return NTAG_RESULT_INVALID; } sint32 NTAGInit(uint32 chan) @@ -40,7 +57,7 @@ namespace ntag sint32 NTAGInitEx(uint32 chan) { sint32 result = nfc::NFCInitEx(chan, 1); - return __NTAGConvertNFCError(result); + return __NTAGConvertNFCResult(result); } sint32 NTAGShutdown(uint32 chan) @@ -58,7 +75,7 @@ namespace ntag gReadCallbacks[chan] = MPTR_NULL; gWriteCallbacks[chan] = MPTR_NULL; - return __NTAGConvertNFCError(result); + return __NTAGConvertNFCResult(result); } bool NTAGIsInit(uint32 chan) @@ -105,7 +122,7 @@ namespace ntag ppcDefineParamS32(error, 1); ppcDefineParamPtr(context, void, 2); - PPCCoreCallback(gAbortCallbacks[chan], chan, __NTAGConvertNFCError(error), context); + PPCCoreCallback(gAbortCallbacks[chan], chan, __NTAGConvertNFCResult(error), context); osLib_returnFromFunction(hCPU, 0); } @@ -118,7 +135,7 @@ namespace ntag gAbortCallbacks[chan] = callback; sint32 result = nfc::NFCAbort(chan, RPLLoader_MakePPCCallable(__NTAGAbortCallback), context); - return __NTAGConvertNFCError(result); + return __NTAGConvertNFCResult(result); } bool __NTAGRawDataToNfcData(iosu::ccr_nfc::CCRNFCCryptData* raw, iosu::ccr_nfc::CCRNFCCryptData* nfc) @@ -370,7 +387,7 @@ namespace ntag readResult->readOnly = readOnly; - error = __NTAGConvertNFCError(error); + error = __NTAGConvertNFCResult(error); if (error == 0) { memset(rwData.GetPointer(), 0, 0x1C8); @@ -430,7 +447,7 @@ namespace ntag } sint32 result = nfc::NFCRead(chan, timeout, &_uid, &_uidMask, RPLLoader_MakePPCCallable(__NTAGReadCallback), context); - return __NTAGConvertNFCError(result); + return __NTAGConvertNFCResult(result); } sint32 __NTAGEncryptData(void* encryptedData, const void* rawData) @@ -512,7 +529,7 @@ namespace ntag ppcDefineParamS32(error, 1); ppcDefineParamPtr(context, void, 2); - PPCCoreCallback(gWriteCallbacks[chan], chan, __NTAGConvertNFCError(error), context); + PPCCoreCallback(gWriteCallbacks[chan], chan, __NTAGConvertNFCResult(error), context); osLib_returnFromFunction(hCPU, 0); } @@ -538,7 +555,7 @@ namespace ntag NTAGAreaHeader roHeader; uint8 writeBuffer[0x1C8]{}; - error = __NTAGConvertNFCError(error); + error = __NTAGConvertNFCResult(error); if (error == 0) { // Copy raw and locked data into a contigous buffer @@ -576,7 +593,7 @@ namespace ntag return; } - error = __NTAGConvertNFCError(error); + error = __NTAGConvertNFCResult(error); } PPCCoreCallback(gWriteCallbacks[chan], chan, error, context); @@ -600,7 +617,7 @@ namespace ntag memcpy(gWriteData[chan].data, rwData, rwSize); sint32 result = nfc::NFCRead(chan, timeout, &gWriteData[chan].uid, &gWriteData[chan].uidMask, RPLLoader_MakePPCCallable(__NTAGReadBeforeWriteCallback), context); - return __NTAGConvertNFCError(result); + return __NTAGConvertNFCResult(result); } sint32 NTAGFormat(uint32 chan, uint32 timeout, nfc::NFCUid* uid, uint32 rwSize, void* rwData, MPTR callback, void* context) @@ -608,7 +625,9 @@ namespace ntag cemu_assert(chan < 2); // TODO - return -1; + cemu_assert_debug(false); + + return NTAG_RESULT_INVALID; } void Initialize() diff --git a/src/Cafe/OS/libs/ntag/ntag.h b/src/Cafe/OS/libs/ntag/ntag.h index 697c065e..68f1801b 100644 --- a/src/Cafe/OS/libs/ntag/ntag.h +++ b/src/Cafe/OS/libs/ntag/ntag.h @@ -1,6 +1,13 @@ #pragma once #include "Cafe/OS/libs/nfc/nfc.h" +#define NTAG_RESULT_SUCCESS (0) +#define NTAG_RESULT_UNINITIALIZED (-0x3E7) +#define NTAG_RESULT_INVALID_STATE (-0x3E6) +#define NTAG_RESULT_NO_TAG (-0x3E5) +#define NTAG_RESULT_INVALID (-0x3E1) +#define NTAG_RESULT_UID_MISMATCH (-0x3DB) + namespace ntag { struct NTAGFormatSettings diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index cb2e988d..33e2cdc1 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -269,10 +269,10 @@ public: } else { - if (nfcError == NFC_ERROR_NO_ACCESS) + if (nfcError == NFC_TOUCH_TAG_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); - else if (nfcError == NFC_ERROR_INVALID_FILE_FORMAT) - wxMessageBox(_("Not a valid NFC NTAG215 file"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + else if (nfcError == NFC_TOUCH_TAG_ERROR_INVALID_FILE_FORMAT) + wxMessageBox(_("Not a valid NFC file"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } } @@ -751,10 +751,10 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) uint32 nfcError; if (nfc::TouchTagFromFile(_utf8ToPath(wxStrFilePath.utf8_string()), &nfcError) == false) { - if (nfcError == NFC_ERROR_NO_ACCESS) + if (nfcError == NFC_TOUCH_TAG_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); - else if (nfcError == NFC_ERROR_INVALID_FILE_FORMAT) - wxMessageBox(_("Not a valid NFC NTAG215 file")); + else if (nfcError == NFC_TOUCH_TAG_ERROR_INVALID_FILE_FORMAT) + wxMessageBox(_("Not a valid NFC file")); } else { @@ -774,10 +774,10 @@ void MainWindow::OnNFCMenu(wxCommandEvent& event) uint32 nfcError = 0; if (nfc::TouchTagFromFile(_utf8ToPath(path), &nfcError) == false) { - if (nfcError == NFC_ERROR_NO_ACCESS) + if (nfcError == NFC_TOUCH_TAG_ERROR_NO_ACCESS) wxMessageBox(_("Cannot open file")); - else if (nfcError == NFC_ERROR_INVALID_FILE_FORMAT) - wxMessageBox(_("Not a valid NFC NTAG215 file")); + else if (nfcError == NFC_TOUCH_TAG_ERROR_INVALID_FILE_FORMAT) + wxMessageBox(_("Not a valid NFC file")); } else { From eb1983daa6e46dfa09ad76eba86c5b636fe0b826 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 18 May 2024 17:27:49 +0200 Subject: [PATCH 187/314] nfc: Remove backup path --- src/Cafe/OS/libs/nfc/nfc.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp index 818c7339..c6809362 100644 --- a/src/Cafe/OS/libs/nfc/nfc.cpp +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -223,16 +223,8 @@ namespace nfc // Update tag NDEF data ctx->tag->SetNDEFData(ctx->writeMessage.ToBytes()); - // TODO remove this once writing is confirmed working - fs::path newPath = ctx->tagPath; - if (newPath.extension() != ".bak") - { - newPath += ".bak"; - } - cemuLog_log(LogType::NFC, "Saving tag as {}...", newPath.string()); - // open file for writing - FileStream* fs = FileStream::createFile2(newPath); + FileStream* fs = FileStream::openFile2(ctx->tagPath, true); if (!fs) { result = NFC_MAKE_RESULT(NFC_RESULT_BASE_WRITE, 0x22); From a115921b43d39c24fafd387d9c87190168422583 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 18 May 2024 19:56:56 +0200 Subject: [PATCH 188/314] Fix inconsistency with int types --- src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp | 22 +++++++------- src/Cafe/OS/libs/nfc/TLV.cpp | 12 ++++---- src/Cafe/OS/libs/nfc/TagV0.cpp | 42 +++++++++++++------------- src/Cafe/OS/libs/nfc/TagV0.h | 8 ++--- src/Cafe/OS/libs/nfc/ndef.cpp | 26 ++++++++-------- src/Cafe/OS/libs/nfc/ndef.h | 4 +-- src/Cafe/OS/libs/nfc/nfc.cpp | 4 +-- src/Cafe/OS/libs/nfc/stream.cpp | 12 ++++---- 8 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp index ff8ba2b1..1ceb16dc 100644 --- a/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp +++ b/src/Cafe/IOSU/ccr_nfc/iosu_ccr_nfc.cpp @@ -71,9 +71,9 @@ namespace iosu return CCR_NFC_ERROR; } - sint32 CCRNFCAESCTRCrypt(const uint8* key, const void* ivNonce, const void* inData, uint32_t inSize, void* outData, uint32_t outSize) + sint32 CCRNFCAESCTRCrypt(const uint8* key, const void* ivNonce, const void* inData, uint32 inSize, void* outData, uint32 outSize) { - uint8_t tmpIv[0x10]; + uint8 tmpIv[0x10]; memcpy(tmpIv, ivNonce, sizeof(tmpIv)); memcpy(outData, inData, inSize); @@ -81,7 +81,7 @@ namespace iosu return 0; } - sint32 __CCRNFCGenerateKey(const uint8* hmacKey, uint32 hmacKeySize, const uint8* name, uint32_t nameSize, const uint8* inData, uint32_t inSize, uint8* outData, uint32_t outSize) + sint32 __CCRNFCGenerateKey(const uint8* hmacKey, uint32 hmacKeySize, const uint8* name, uint32 nameSize, const uint8* inData, uint32 inSize, uint8* outData, uint32 outSize) { if (nameSize != 0xe || outSize != 0x40) { @@ -89,13 +89,13 @@ namespace iosu } // Create a buffer containing 2 counter bytes, the key name, and the key data - uint8_t buffer[0x50]; + uint8 buffer[0x50]; buffer[0] = 0; buffer[1] = 0; memcpy(buffer + 2, name, nameSize); memcpy(buffer + nameSize + 2, inData, inSize); - uint16_t counter = 0; + uint16 counter = 0; while (outSize > 0) { // Set counter bytes and increment counter @@ -118,9 +118,9 @@ namespace iosu sint32 __CCRNFCGenerateInternalKeys(const CCRNFCCryptData* in, const uint8* keyGenSalt) { - uint8_t lockedSecretBuffer[0x40] = { 0 }; - uint8_t unfixedInfosBuffer[0x40] = { 0 }; - uint8_t outBuffer[0x40] = { 0 }; + uint8 lockedSecretBuffer[0x40] = { 0 }; + uint8 unfixedInfosBuffer[0x40] = { 0 }; + uint8 outBuffer[0x40] = { 0 }; // Fill the locked secret buffer memcpy(lockedSecretBuffer, sLockedSecretMagicBytes, sizeof(sLockedSecretMagicBytes)); @@ -193,7 +193,7 @@ namespace iosu sint32 __CCRNFCCryptData(const CCRNFCCryptData* in, CCRNFCCryptData* out, bool decrypt) { // Decrypt key generation salt - uint8_t keyGenSalt[0x20]; + uint8 keyGenSalt[0x20]; sint32 res = CCRNFCAESCTRCrypt(sNfcKey, sNfcKeyIV, in->data + in->keyGenSaltOffset, 0x20, keyGenSalt, sizeof(keyGenSalt)); if (res != 0) { @@ -227,7 +227,7 @@ namespace iosu } // Verify HMACs - uint8_t hmacBuffer[0x20]; + uint8 hmacBuffer[0x20]; uint32 hmacLen = sizeof(hmacBuffer); if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen)) @@ -258,7 +258,7 @@ namespace iosu } else { - uint8_t hmacBuffer[0x20]; + uint8 hmacBuffer[0x20]; uint32 hmacLen = sizeof(hmacBuffer); if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen)) diff --git a/src/Cafe/OS/libs/nfc/TLV.cpp b/src/Cafe/OS/libs/nfc/TLV.cpp index 99536428..2650858d 100644 --- a/src/Cafe/OS/libs/nfc/TLV.cpp +++ b/src/Cafe/OS/libs/nfc/TLV.cpp @@ -25,7 +25,7 @@ std::vector<TLV> TLV::FromBytes(const std::span<std::byte>& data) while (stream.GetRemaining() > 0 && !hasTerminator) { // Read the tag - uint8_t byte; + uint8 byte; stream >> byte; Tag tag = static_cast<Tag>(byte); @@ -43,7 +43,7 @@ std::vector<TLV> TLV::FromBytes(const std::span<std::byte>& data) default: { // Read the length - uint16_t length; + uint16 length; stream >> byte; length = byte; @@ -85,7 +85,7 @@ std::vector<std::byte> TLV::ToBytes() const VectorStream stream(bytes, std::endian::big); // Write tag - stream << std::uint8_t(mTag); + stream << uint8(mTag); switch (mTag) { @@ -99,12 +99,12 @@ std::vector<std::byte> TLV::ToBytes() const // Write length (decide if as a 8-bit or 16-bit value) if (mValue.size() >= 0xff) { - stream << std::uint8_t(0xff); - stream << std::uint16_t(mValue.size()); + stream << uint8(0xff); + stream << uint16(mValue.size()); } else { - stream << std::uint8_t(mValue.size()); + stream << uint8(mValue.size()); } // Write value diff --git a/src/Cafe/OS/libs/nfc/TagV0.cpp b/src/Cafe/OS/libs/nfc/TagV0.cpp index 8b5a8143..41b5c7a0 100644 --- a/src/Cafe/OS/libs/nfc/TagV0.cpp +++ b/src/Cafe/OS/libs/nfc/TagV0.cpp @@ -9,17 +9,17 @@ namespace constexpr std::size_t kTagSize = 512u; constexpr std::size_t kMaxBlockCount = kTagSize / sizeof(TagV0::Block); -constexpr std::uint8_t kLockbyteBlock0 = 0xe; -constexpr std::uint8_t kLockbytesStart0 = 0x0; -constexpr std::uint8_t kLockbytesEnd0 = 0x2; -constexpr std::uint8_t kLockbyteBlock1 = 0xf; -constexpr std::uint8_t kLockbytesStart1 = 0x2; -constexpr std::uint8_t kLockbytesEnd1 = 0x8; +constexpr uint8 kLockbyteBlock0 = 0xe; +constexpr uint8 kLockbytesStart0 = 0x0; +constexpr uint8 kLockbytesEnd0 = 0x2; +constexpr uint8 kLockbyteBlock1 = 0xf; +constexpr uint8 kLockbytesStart1 = 0x2; +constexpr uint8 kLockbytesEnd1 = 0x8; -constexpr std::uint8_t kNDEFMagicNumber = 0xe1; +constexpr uint8 kNDEFMagicNumber = 0xe1; // These blocks are not part of the locked area -constexpr bool IsBlockLockedOrReserved(std::uint8_t blockIdx) +constexpr bool IsBlockLockedOrReserved(uint8 blockIdx) { // Block 0 is the UID if (blockIdx == 0x0) @@ -153,7 +153,7 @@ std::vector<std::byte> TagV0::ToBytes() const // The rest will be the data area auto dataIterator = dataArea.begin(); - for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) + for (uint8 currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) { // All blocks which aren't locked make up the dataArea if (!IsBlockLocked(currentBlock)) @@ -189,15 +189,15 @@ void TagV0::SetNDEFData(const std::span<const std::byte>& data) bool TagV0::ParseLockedArea(const std::span<const std::byte>& data) { - std::uint8_t currentBlock = 0; + uint8 currentBlock = 0; // Start by parsing the first set of lock bytes - for (std::uint8_t i = kLockbytesStart0; i < kLockbytesEnd0; i++) + for (uint8 i = kLockbytesStart0; i < kLockbytesEnd0; i++) { - std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock0 * sizeof(Block) + i]); + uint8 lockByte = uint8(data[kLockbyteBlock0 * sizeof(Block) + i]); // Iterate over the individual bits in the lock byte - for (std::uint8_t j = 0; j < 8; j++) + for (uint8 j = 0; j < 8; j++) { // Is block locked? if (lockByte & (1u << j)) @@ -221,11 +221,11 @@ bool TagV0::ParseLockedArea(const std::span<const std::byte>& data) } // Parse the second set of lock bytes - for (std::uint8_t i = kLockbytesStart1; i < kLockbytesEnd1; i++) { - std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock1 * sizeof(Block) + i]); + for (uint8 i = kLockbytesStart1; i < kLockbytesEnd1; i++) { + uint8 lockByte = uint8(data[kLockbyteBlock1 * sizeof(Block) + i]); // Iterate over the individual bits in the lock byte - for (std::uint8_t j = 0; j < 8; j++) + for (uint8 j = 0; j < 8; j++) { // Is block locked? if (lockByte & (1u << j)) @@ -251,14 +251,14 @@ bool TagV0::ParseLockedArea(const std::span<const std::byte>& data) return true; } -bool TagV0::IsBlockLocked(std::uint8_t blockIdx) const +bool TagV0::IsBlockLocked(uint8 blockIdx) const { return mLockedBlocks.contains(blockIdx) || IsBlockLockedOrReserved(blockIdx); } bool TagV0::ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea) { - for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) + for (uint8 currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++) { // All blocks which aren't locked make up the dataArea if (!IsBlockLocked(currentBlock)) @@ -274,7 +274,7 @@ bool TagV0::ParseDataArea(const std::span<const std::byte>& data, std::vector<st bool TagV0::ValidateCapabilityContainer() { // NDEF Magic Number - std::uint8_t nmn = mCapabilityContainer[0]; + uint8 nmn = mCapabilityContainer[0]; if (nmn != kNDEFMagicNumber) { cemuLog_log(LogType::Force, "Error: CC: Invalid NDEF Magic Number"); @@ -282,7 +282,7 @@ bool TagV0::ValidateCapabilityContainer() } // Version Number - std::uint8_t vno = mCapabilityContainer[1]; + uint8 vno = mCapabilityContainer[1]; if (vno >> 4 != 1) { cemuLog_log(LogType::Force, "Error: CC: Invalid Version Number"); @@ -290,7 +290,7 @@ bool TagV0::ValidateCapabilityContainer() } // Tag memory size - std::uint8_t tms = mCapabilityContainer[2]; + uint8 tms = mCapabilityContainer[2]; if (8u * (tms + 1) < kTagSize) { cemuLog_log(LogType::Force, "Error: CC: Incomplete tag memory size"); diff --git a/src/Cafe/OS/libs/nfc/TagV0.h b/src/Cafe/OS/libs/nfc/TagV0.h index 1d0e88d7..72c321b6 100644 --- a/src/Cafe/OS/libs/nfc/TagV0.h +++ b/src/Cafe/OS/libs/nfc/TagV0.h @@ -26,13 +26,13 @@ public: private: bool ParseLockedArea(const std::span<const std::byte>& data); - bool IsBlockLocked(std::uint8_t blockIdx) const; + bool IsBlockLocked(uint8 blockIdx) const; bool ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea); bool ValidateCapabilityContainer(); - std::map<std::uint8_t, Block> mLockedOrReservedBlocks; - std::map<std::uint8_t, Block> mLockedBlocks; - std::array<std::uint8_t, 0x4> mCapabilityContainer; + std::map<uint8, Block> mLockedOrReservedBlocks; + std::map<uint8, Block> mLockedBlocks; + std::array<uint8, 0x4> mCapabilityContainer; std::vector<TLV> mTLVs; std::size_t mNdefTlvIdx; std::vector<std::byte> mLockedArea; diff --git a/src/Cafe/OS/libs/nfc/ndef.cpp b/src/Cafe/OS/libs/nfc/ndef.cpp index 32097cfd..60be5811 100644 --- a/src/Cafe/OS/libs/nfc/ndef.cpp +++ b/src/Cafe/OS/libs/nfc/ndef.cpp @@ -19,20 +19,20 @@ namespace ndef Record rec; // Read record header - uint8_t recHdr; + uint8 recHdr; stream >> recHdr; rec.mFlags = recHdr & ~NDEF_TNF_MASK; rec.mTNF = static_cast<TypeNameFormat>(recHdr & NDEF_TNF_MASK); // Type length - uint8_t typeLen; + uint8 typeLen; stream >> typeLen; // Payload length; - uint32_t payloadLen; + uint32 payloadLen; if (recHdr & NDEF_SR) { - uint8_t len; + uint8 len; stream >> len; payloadLen = len; } @@ -48,7 +48,7 @@ namespace ndef } // ID length - uint8_t idLen = 0; + uint8 idLen = 0; if (recHdr & NDEF_IL) { stream >> idLen; @@ -81,35 +81,35 @@ namespace ndef return rec; } - std::vector<std::byte> Record::ToBytes(uint8_t flags) const + std::vector<std::byte> Record::ToBytes(uint8 flags) const { std::vector<std::byte> bytes; VectorStream stream(bytes, std::endian::big); // Combine flags (clear message begin and end flags) - std::uint8_t finalFlags = mFlags & ~(NDEF_MB | NDEF_ME); + uint8 finalFlags = mFlags & ~(NDEF_MB | NDEF_ME); finalFlags |= flags; // Write flags + tnf - stream << std::uint8_t(finalFlags | std::uint8_t(mTNF)); + stream << uint8(finalFlags | uint8(mTNF)); // Type length - stream << std::uint8_t(mType.size()); + stream << uint8(mType.size()); // Payload length if (IsShort()) { - stream << std::uint8_t(mPayload.size()); + stream << uint8(mPayload.size()); } else { - stream << std::uint32_t(mPayload.size()); + stream << uint32(mPayload.size()); } // ID length if (mFlags & NDEF_IL) { - stream << std::uint8_t(mID.size()); + stream << uint8(mID.size()); } // Type @@ -249,7 +249,7 @@ namespace ndef for (std::size_t i = 0; i < mRecords.size(); i++) { - std::uint8_t flags = 0; + uint8 flags = 0; // Add message begin flag to first record if (i == 0) diff --git a/src/Cafe/OS/libs/nfc/ndef.h b/src/Cafe/OS/libs/nfc/ndef.h index b5f38b17..398feb54 100644 --- a/src/Cafe/OS/libs/nfc/ndef.h +++ b/src/Cafe/OS/libs/nfc/ndef.h @@ -39,7 +39,7 @@ namespace ndef virtual ~Record(); static std::optional<Record> FromStream(Stream& stream); - std::vector<std::byte> ToBytes(uint8_t flags = 0) const; + std::vector<std::byte> ToBytes(uint8 flags = 0) const; TypeNameFormat GetTNF() const; const std::vector<std::byte>& GetID() const; @@ -55,7 +55,7 @@ namespace ndef bool IsShort() const; private: - uint8_t mFlags; + uint8 mFlags; TypeNameFormat mTNF; std::vector<std::byte> mID; std::vector<std::byte> mType; diff --git a/src/Cafe/OS/libs/nfc/nfc.cpp b/src/Cafe/OS/libs/nfc/nfc.cpp index c6809362..fcb1d8d0 100644 --- a/src/Cafe/OS/libs/nfc/nfc.cpp +++ b/src/Cafe/OS/libs/nfc/nfc.cpp @@ -149,9 +149,9 @@ namespace nfc StackAllocator<NFCUid> uid; bool readOnly = false; uint32 dataSize = 0; - StackAllocator<uint8_t, 0x200> data; + StackAllocator<uint8, 0x200> data; uint32 lockedDataSize = 0; - StackAllocator<uint8_t, 0x200> lockedData; + StackAllocator<uint8, 0x200> lockedData; if (ctx->tag) { diff --git a/src/Cafe/OS/libs/nfc/stream.cpp b/src/Cafe/OS/libs/nfc/stream.cpp index 73c2880f..dd6de7ad 100644 --- a/src/Cafe/OS/libs/nfc/stream.cpp +++ b/src/Cafe/OS/libs/nfc/stream.cpp @@ -28,7 +28,7 @@ std::endian Stream::GetEndianness() const Stream& Stream::operator>>(bool& val) { - std::uint8_t i; + uint8 i; *this >> i; val = !!i; @@ -37,7 +37,7 @@ Stream& Stream::operator>>(bool& val) Stream& Stream::operator>>(float& val) { - std::uint32_t i; + uint32 i; *this >> i; val = std::bit_cast<float>(i); @@ -46,7 +46,7 @@ Stream& Stream::operator>>(float& val) Stream& Stream::operator>>(double& val) { - std::uint64_t i; + uint64 i; *this >> i; val = std::bit_cast<double>(i); @@ -55,7 +55,7 @@ Stream& Stream::operator>>(double& val) Stream& Stream::operator<<(bool val) { - std::uint8_t i = val; + uint8 i = val; *this >> i; return *this; @@ -63,7 +63,7 @@ Stream& Stream::operator<<(bool val) Stream& Stream::operator<<(float val) { - std::uint32_t i = std::bit_cast<std::uint32_t>(val); + uint32 i = std::bit_cast<uint32>(val); *this >> i; return *this; @@ -71,7 +71,7 @@ Stream& Stream::operator<<(float val) Stream& Stream::operator<<(double val) { - std::uint64_t i = std::bit_cast<std::uint64_t>(val); + uint64 i = std::bit_cast<uint64>(val); *this >> i; return *this; From 964d2acb44c64015637d1a8713cc2e96bf53bb48 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 18 May 2024 20:47:09 +0200 Subject: [PATCH 189/314] Filestream_unix: Include cstdarg --- src/Common/unix/FileStream_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Common/unix/FileStream_unix.cpp b/src/Common/unix/FileStream_unix.cpp index 2dba17b7..4bc9b526 100644 --- a/src/Common/unix/FileStream_unix.cpp +++ b/src/Common/unix/FileStream_unix.cpp @@ -1,4 +1,5 @@ #include "Common/unix/FileStream_unix.h" +#include <cstdarg> fs::path findPathCI(const fs::path& path) { From c913a59c7a7140eb7b148611362eee519217dc27 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 22 May 2024 04:11:02 +0200 Subject: [PATCH 190/314] TitleList: Add homebrew title type (#1203) --- src/Cafe/TitleList/TitleId.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Cafe/TitleList/TitleId.h b/src/Cafe/TitleList/TitleId.h index b7f63b13..073472d9 100644 --- a/src/Cafe/TitleList/TitleId.h +++ b/src/Cafe/TitleList/TitleId.h @@ -13,6 +13,7 @@ public: /* 00 */ BASE_TITLE = 0x00, // eShop and disc titles /* 02 */ BASE_TITLE_DEMO = 0x02, /* 0E */ BASE_TITLE_UPDATE = 0x0E, // update for BASE_TITLE (and maybe BASE_TITLE_DEMO?) + /* 0F */ HOMEBREW = 0x0F, /* 0C */ AOC = 0x0C, // DLC /* 10 */ SYSTEM_TITLE = 0x10, // eShop etc /* 1B */ SYSTEM_DATA = 0x1B, @@ -43,6 +44,8 @@ public: return TITLE_TYPE::BASE_TITLE_DEMO; case 0x0E: return TITLE_TYPE::BASE_TITLE_UPDATE; + case 0x0F: + return TITLE_TYPE::HOMEBREW; case 0x0C: return TITLE_TYPE::AOC; case 0x10: From 523a1652df4e8e7a18466e1d2668573dc06909af Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 22 May 2024 04:23:33 +0200 Subject: [PATCH 191/314] OpenGL: Restore ProgramBinary cache for GL shaders (#1209) --- src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp index 3d46f206..cae53140 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/RendererShaderGL.cpp @@ -23,16 +23,13 @@ bool RendererShaderGL::loadBinary() cemu_assert_debug(m_baseHash != 0); uint64 h1, h2; GenerateShaderPrecompiledCacheFilename(m_type, m_baseHash, m_auxHash, h1, h2); - sint32 fileSize = 0; std::vector<uint8> cacheFileData; if (!s_programBinaryCache->GetFile({h1, h2 }, cacheFileData)) return false; - if (fileSize < sizeof(uint32)) - { + if (cacheFileData.size() <= sizeof(uint32)) return false; - } - uint32 shaderBinFormat = *(uint32*)(cacheFileData.data() + 0); + uint32 shaderBinFormat = *(uint32*)(cacheFileData.data()); m_program = glCreateProgram(); glProgramBinary(m_program, shaderBinFormat, cacheFileData.data()+4, cacheFileData.size()-4); From b048a1fd9effb59a212c8e1c8ad5069a953f3f3b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 22 May 2024 05:08:03 +0200 Subject: [PATCH 192/314] Use CURLOPT_USERAGENT instead of manually setting User-Agent --- src/Cemu/napi/napi_helper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Cemu/napi/napi_helper.cpp b/src/Cemu/napi/napi_helper.cpp index e498d07f..164de7e5 100644 --- a/src/Cemu/napi/napi_helper.cpp +++ b/src/Cemu/napi/napi_helper.cpp @@ -388,9 +388,8 @@ bool CurlSOAPHelper::submitRequest() headers = curl_slist_append(headers, "Accept-Charset: UTF-8"); headers = curl_slist_append(headers, fmt::format("SOAPAction: urn:{}.wsapi.broadon.com/{}", m_serviceType, m_requestMethod).c_str()); headers = curl_slist_append(headers, "Accept: */*"); - headers = curl_slist_append(headers, "User-Agent: EVL NUP 040800 Sep 18 2012 20:20:02"); - curl_easy_setopt(m_curl, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(m_curl, CURLOPT_USERAGENT, "EVL NUP 040800 Sep 18 2012 20:20:02"); // send request auto res = curl_easy_perform(m_curl); From 917ea2ef234f583032dab84a6f0f371709823ce1 Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Thu, 23 May 2024 17:48:04 +0000 Subject: [PATCH 193/314] Update translation files --- bin/resources/de/cemu.mo | Bin 65048 -> 65571 bytes bin/resources/es/cemu.mo | Bin 62413 -> 65733 bytes bin/resources/fr/cemu.mo | Bin 63716 -> 72178 bytes bin/resources/hu/cemu.mo | Bin 62167 -> 71267 bytes bin/resources/ko/cemu.mo | Bin 69116 -> 69784 bytes bin/resources/ru/cemu.mo | Bin 46500 -> 89284 bytes bin/resources/zh/cemu.mo | Bin 56868 -> 58070 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/de/cemu.mo b/bin/resources/de/cemu.mo index 918fcd3546c99e9c385fe726bbd91c9e95b19270..8dc4e8cc9ec032d5dcd38af5359b3246398a7e0a 100644 GIT binary patch delta 15405 zcmYk?2VhRu|Httg2_Z(vuoBH<#ERHNVusiwX6z9W#7Ib_YSd#ZHA>8y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k`Yyp%;y)`GmQ{kHx!oI#zgX!1XqZ1(@% z%Vx6~OI;`1P6gTT?FKS|+0}fqs0<;WKto^Ka5jELyy=x2-yz?Cve~pPg1Rc$`qAVQ zZ2n8?j%C-HAAiFj+n%h;sX@?_#@$Kx$j`?S)J(CB;>aH-O|u>LCZ9kGp?*1KCCTfW zU~mdiHk!Ip#OrJys=7kDMC^-y;TYQerRP6FFoNJ36=g|{h{utdlV4A2P2B>VLD>!* ziMobT?oayM#v92GFjdYD%04B(7$@0!RlPyJ0qwlWZzP{p_?5~CDsB@O#3pGs;sP6W zBZ{&uDpOireQ?#H%->|Qe-7p6Qpz^kvMPAk<{clOw5iR5(|R^9mR7v_rL_O5cg*Zn z!_O^qa?%R#%(w>M<;u+0c(YsP`6lz-GnY4ybk980%GWpZa##PL%)pUnish|PEv{mP zi1-TC<144#TXZ28{iScMp7~W;tXtZn#eFmTE~)31nYr|!Pv)ZZba$_au>(f*j_93s z_F`ySvx`1yBi2vLe6qfRTUzHQ`7&SM80+EIBW>c=Mwu_RX1QnH%V<*|v)REGKAw@y T2MmbJT>bS>-^?0UevSS=9Aq~l diff --git a/bin/resources/es/cemu.mo b/bin/resources/es/cemu.mo index 4f78fdcd0d63921934cbce6338ed108d179fbc24..856049de037de70de90a2868e6da991fe25d1235 100644 GIT binary patch delta 20815 zcmb8$2Y3`k!2j{Rgc^EFXp#*r1SB*84ZXL}4Io84l1n&9?!py1o}hxFfVu(}1W}|( z(*r4jfS@2MBBFw#*s&v`i2eWl-EIK=`@GNl?(+<vnc3Ny*_qkdJ<!+B#=kVXSmeXX z#TFYJzr-0vZ9I`=7(d4w#=XsyYZ$k5GK_NQ#<J+gGB^`U<6VvqI4*NsjViYVYvFFJ zfG4p$eu)W&5ix#oPQ-P#8>o!MD3FYmu|Af<wpa-}V{sgUHE;wr!~j;rhp{TIcifBh zNuNNS{}t7Ngf50rg7%FXMCgfOVo7X*y0ccO20Ne{9O$I8umtHmR0n-n1!tq`S&ZuN z<EZP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jThZPk9ri_v*tHKO+Iffi z*_98Ev{xLSZnr%Ws9h*nj1lq%Iq$X0dIy5JocWQnM{-<o`i;r62OUk0Ja)9e6>0qP za#!TF<3GmLh~DsITD>OnqcUT1fzKP{*@3<(K9Ao%d7@FdetusD`OJVj-y03DUG`*F zgP{c>k9*L-WUFr=mt)ZCr33cg*Ulrp{J_~8PPTWY+Kaa*me19R>GN1A(dKTBOS{pj zz4oP3H6mr+oaJ))BMaZkaz*OAQ^{rLzPsL@{9c>LOYfC;MJm0Y7gMs(D|#af&s>kO ztAA1>^4-ThV(bB*?zJnOyHR+{*oo&yB@k_X1oHy~+%7o3!|r-vvi;VDHHF(n@-Mb^ z{YS;-&vIS%^PiuM?E2yxmn%22_Dffh$m`$iiY?t&E0<AlY#qNg83Ft5AGXyl`~hik zL&vs;3RqPuDThVy+n(*!?EXKV{$KWP&7VfbG#tiu(5?++vR#NSvvtnwOuqPlKcGr0 z$*%EB4SVa=1bfxh)h@T)@s}F>Ir5iXwF)?se0+fe*+!gA{0i$UbbAW;B@G4aOM5y+ zyuY3(-l$OMI7*z&tKsrEIihRt{B6Y^@lSqiCcgr&{*zQJ_t;i`2Lg7n8#Vjn6+~BF z$4|5??W~)>2K0AqojcQ`!!E!n!`I-ChCRdqd2C039}4%BW9#?@2-w~m-T1#D6+Y~v mC*1$tdEqAi9|KsqH_vKk?|CeKxA>C1!GL8Vx~zd~#{U7g9r)4! diff --git a/bin/resources/fr/cemu.mo b/bin/resources/fr/cemu.mo index d31685fca1c4072f58d2fe0e0b467e562a64a205..8328991f01eb915b5ea722452ccefde985d6416c 100644 GIT binary patch delta 25093 zcmai+2Ygh;8n;gpYUsVgK}x8hSrF-j4xxickxjA*3!7}%-2@_X7ew@mog)fY6cm(V zLszAU?M6jW5fv3d!QQ~$%f;{cpEH{T_4~f_`^`Qx@64I<&O7hSoS+|loAO<}QtWvB zN^32i7Acn168_NCvN}|<te1L8YFYD!T2?LSgEe6Y)_|A7>hRx&YYaCS-VIf5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C}z&)M#trDKI-y3TpiMfOn+vSxH%_bVRqbFa|dL+ zu}8G!Gc$d$@!r^^oXy%b1Ih1Q$b`&>BFx@#oZV;N49}>fkkO`@Z~hjxt*Ph6EYI1i ziP8S<sfA_;b+sUsuI!o*B2Hh!D*bmGWX#fWkDXn1uXwH``8Opevo}QN#2qj*A@r>| znZ50pH<M?w*!O0_e|c|8lJAYYC#ybFPG!fZ|97ioya{`~OLTkcboX{|yk30OkIv6~ zIrVN1CUfj4Z<A-_nxdl~O_;hb>2U6fjk(bqy~noOjQ^QG`U=vA_ehF&kw&0?H*>jf z<zC;i`Pu6h`qv?6-|K90m*>4TWed<`2-~jMttu6%4&@Fvrer5Cb@lJx*+n~+RQKp{ ztu0^a(evgD^hksLYb*15Oj}!}x@lHx*rX|wT)CSM<!;#G*v(O=)-X2h`ope_w6)<u zCB4U1G7a;g;^XAX_#(MpV1O&5(8liqS8N#@xO$&w{Fcczyj%C>&i6RJ^sV0HRP%AO z-?;3!SYPsPUFu2M+L_^Vwl>RXwJn@ZJj1u2q^t5fCIxunQjceh+8Lzm*tAysOiHU- z(tN}o8T?|}7x|m#?AYpkW2txB{+xp;_fE`rOl(@2y`j-~r|cR3v_IZIiLZM`hm5d* zj7bN3sh)A@sD_)G8QQ?#+Pfz%XX_&KcINe9bN=r%XZ&65$($R+b#+f%^c2pjNv%=V zo?xbWH#6Foo|5q(D<&x8*6BV0Wm#liK=!=8Q{FvU+6|u8XW!+Lg69q~gA?cOsi(Ay zRoc*&&w<&wE^ppvH0u9T$@{#^^abT@v8~L?x-uSKT(4hT>n^wC=X;mK`1#Fc9&|>* hD?b-2o*d_m-}~Pq^yIsl#+ki0U)2iKzm-<-{{T+uaXSD2 From 149fe10a4e0006963956d5dc9d103dc731c1cb6a Mon Sep 17 00:00:00 2001 From: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Date: Fri, 24 May 2024 16:48:17 -0700 Subject: [PATCH 194/314] CI+MacOS: Use libusb dylib from vcpkg (#1219) --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b78b1fb..d5843c37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,7 @@ if (MACOS_BUNDLE) COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh" COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}" - COMMAND bash -c "install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") + COMMAND bash -c "install_name_tool -change /Users/runner/work/Cemu/Cemu/build/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() set_target_properties(CemuBin PROPERTIES From aadd2f4a1af788d208a38a2d23161a4de517083a Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 25 May 2024 01:48:53 +0200 Subject: [PATCH 195/314] Input: Assign profile name correctly on save (#1217) --- src/input/InputManager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/input/InputManager.cpp b/src/input/InputManager.cpp index d928e46c..64b238fc 100644 --- a/src/input/InputManager.cpp +++ b/src/input/InputManager.cpp @@ -472,15 +472,12 @@ bool InputManager::save(size_t player_index, std::string_view filename) emulated_controller->type_string() }.c_str()); + if(!is_default_file) + emulated_controller->m_profile_name = std::string{filename}; + if (emulated_controller->has_profile_name()) emulated_controller_node.append_child("profile").append_child(pugi::node_pcdata).set_value( emulated_controller->get_profile_name().c_str()); - else if (!is_default_file) - { - emulated_controller->m_profile_name = std::string{filename}; - emulated_controller_node.append_child("profile").append_child(pugi::node_pcdata).set_value( - emulated_controller->get_profile_name().c_str()); - } // custom settings emulated_controller->save(emulated_controller_node); From 1ee9d5c78c1c5216c92764977363fad38b0d4f0b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 27 May 2024 01:24:24 +0200 Subject: [PATCH 196/314] coreinit: Tweak JD2019 workaround to avoid XCX softlock --- src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 8 ++++---- src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 6 +++--- src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp | 9 +++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp index 9e5de19e..c144c384 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp @@ -310,7 +310,7 @@ namespace coreinit currentThread->mutexQueue.removeMutex(mutex); mutex->owner = nullptr; if (!mutex->threadQueue.isEmpty()) - mutex->threadQueue.wakeupSingleThreadWaitQueue(true); + mutex->threadQueue.wakeupSingleThreadWaitQueue(true, true); } // currentThread->cancelState = currentThread->cancelState & ~0x10000; } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index fbf498db..b53d04ed 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -758,14 +758,14 @@ namespace coreinit } // returns true if thread runs on same core and has higher priority - bool __OSCoreShouldSwitchToThread(OSThread_t* currentThread, OSThread_t* newThread) + bool __OSCoreShouldSwitchToThread(OSThread_t* currentThread, OSThread_t* newThread, bool sharedPriorityAndAffinityWorkaround) { uint32 coreIndex = OSGetCoreId(); if (!newThread->context.hasCoreAffinitySet(coreIndex)) return false; // special case: if current and new thread are running only on the same core then reschedule even if priority is equal // this resolves a deadlock in Just Dance 2019 where one thread would always reacquire the same mutex within it's timeslice, blocking another thread on the same core from acquiring it - if ((1<<coreIndex) == newThread->context.affinity && currentThread->context.affinity == newThread->context.affinity && currentThread->effectivePriority == newThread->effectivePriority) + if (sharedPriorityAndAffinityWorkaround && (1<<coreIndex) == newThread->context.affinity && currentThread->context.affinity == newThread->context.affinity && currentThread->effectivePriority == newThread->effectivePriority) return true; // otherwise reschedule if new thread has higher priority return newThread->effectivePriority < currentThread->effectivePriority; @@ -791,7 +791,7 @@ namespace coreinit // todo - only set this once? thread->wakeUpTime = PPCInterpreter_getMainCoreCycleCounter(); // reschedule if thread has higher priority - if (PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread, false)) PPCCore_switchToSchedulerWithLock(); } return previousSuspendCount; @@ -948,7 +948,7 @@ namespace coreinit OSThread_t* currentThread = OSGetCurrentThread(); if (currentThread && currentThread != thread) { - if (__OSCoreShouldSwitchToThread(currentThread, thread)) + if (__OSCoreShouldSwitchToThread(currentThread, thread, false)) PPCCore_switchToSchedulerWithLock(); } __OSUnlockScheduler(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index fdbcfea7..8b144bd3 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -126,8 +126,8 @@ namespace coreinit // counterparts for queueAndWait void cancelWait(OSThread_t* thread); - void wakeupEntireWaitQueue(bool reschedule); - void wakeupSingleThreadWaitQueue(bool reschedule); + void wakeupEntireWaitQueue(bool reschedule, bool sharedPriorityAndAffinityWorkaround = false); + void wakeupSingleThreadWaitQueue(bool reschedule, bool sharedPriorityAndAffinityWorkaround = false); private: OSThread_t* takeFirstFromQueue(size_t linkOffset) @@ -611,7 +611,7 @@ namespace coreinit // internal void __OSAddReadyThreadToRunQueue(OSThread_t* thread); - bool __OSCoreShouldSwitchToThread(OSThread_t* currentThread, OSThread_t* newThread); + bool __OSCoreShouldSwitchToThread(OSThread_t* currentThread, OSThread_t* newThread, bool sharedPriorityAndAffinityWorkaround); void __OSQueueThreadDeallocation(OSThread_t* thread); bool __OSIsThreadActive(OSThread_t* thread); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp b/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp index 68cb22b3..b33aa888 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_ThreadQueue.cpp @@ -128,7 +128,8 @@ namespace coreinit // counterpart for queueAndWait // if reschedule is true then scheduler will switch to woken up thread (if it is runnable on the same core) - void OSThreadQueueInternal::wakeupEntireWaitQueue(bool reschedule) + // sharedPriorityAndAffinityWorkaround is currently a hack/placeholder for some special cases. A proper fix likely involves handling all the nuances of thread effective priority + void OSThreadQueueInternal::wakeupEntireWaitQueue(bool reschedule, bool sharedPriorityAndAffinityWorkaround) { cemu_assert_debug(__OSHasSchedulerLock()); bool shouldReschedule = false; @@ -139,7 +140,7 @@ namespace coreinit thread->state = OSThread_t::THREAD_STATE::STATE_READY; thread->currentWaitQueue = nullptr; coreinit::__OSAddReadyThreadToRunQueue(thread); - if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread, sharedPriorityAndAffinityWorkaround)) shouldReschedule = true; } if (shouldReschedule) @@ -148,7 +149,7 @@ namespace coreinit // counterpart for queueAndWait // if reschedule is true then scheduler will switch to woken up thread (if it is runnable on the same core) - void OSThreadQueueInternal::wakeupSingleThreadWaitQueue(bool reschedule) + void OSThreadQueueInternal::wakeupSingleThreadWaitQueue(bool reschedule, bool sharedPriorityAndAffinityWorkaround) { cemu_assert_debug(__OSHasSchedulerLock()); OSThread_t* thread = takeFirstFromQueue(offsetof(OSThread_t, waitQueueLink)); @@ -159,7 +160,7 @@ namespace coreinit thread->state = OSThread_t::THREAD_STATE::STATE_READY; thread->currentWaitQueue = nullptr; coreinit::__OSAddReadyThreadToRunQueue(thread); - if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread)) + if (reschedule && thread->suspendCounter == 0 && PPCInterpreter_getCurrentInstance() && __OSCoreShouldSwitchToThread(coreinit::OSGetCurrentThread(), thread, sharedPriorityAndAffinityWorkaround)) shouldReschedule = true; } if (shouldReschedule) From da8fd5b7c7ba51816d477e00f22d9a2cc56cb60b Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 29 May 2024 00:07:37 +0200 Subject: [PATCH 197/314] nn_save: Refactor and modernize code --- .../Interpreter/PPCInterpreterMain.cpp | 2 +- src/Cafe/HW/Espresso/PPCState.h | 2 +- src/Cafe/OS/libs/nn_save/nn_save.cpp | 1195 +++++------------ src/Common/MemPtr.h | 2 +- src/Common/StackAllocator.h | 9 +- 5 files changed, 323 insertions(+), 887 deletions(-) diff --git a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp index a9ab49a5..ace1601f 100644 --- a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp +++ b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterMain.cpp @@ -90,7 +90,7 @@ uint8* PPCInterpreterGetStackPointer() return memory_getPointerFromVirtualOffset(PPCInterpreter_getCurrentInstance()->gpr[1]); } -uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset) +uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset) { PPCInterpreter_t* hCPU = PPCInterpreter_getCurrentInstance(); uint8* result = memory_getPointerFromVirtualOffset(hCPU->gpr[1] - offset); diff --git a/src/Cafe/HW/Espresso/PPCState.h b/src/Cafe/HW/Espresso/PPCState.h index 134f73a8..c315ed0e 100644 --- a/src/Cafe/HW/Espresso/PPCState.h +++ b/src/Cafe/HW/Espresso/PPCState.h @@ -213,7 +213,7 @@ void PPCTimer_start(); // core info and control extern uint32 ppcThreadQuantum; -uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset); +uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset); uint8* PPCInterpreterGetStackPointer(); void PPCInterpreterModifyStackPointer(sint32 offset); diff --git a/src/Cafe/OS/libs/nn_save/nn_save.cpp b/src/Cafe/OS/libs/nn_save/nn_save.cpp index 09d4413b..31f8ac8e 100644 --- a/src/Cafe/OS/libs/nn_save/nn_save.cpp +++ b/src/Cafe/OS/libs/nn_save/nn_save.cpp @@ -160,39 +160,60 @@ namespace save return FS_RESULT::FATAL_ERROR; } - typedef struct + struct AsyncResultData { - coreinit::OSEvent* event; - SAVEStatus returnStatus; + MEMPTR<coreinit::OSEvent> event; + betype<SAVEStatus> returnStatus; + }; - MEMPTR<OSThread_t> thread; // own stuff until cond + event rewritten - } AsyncCallbackParam_t; + void SaveAsyncFinishCallback(PPCInterpreter_t* hCPU); - void AsyncCallback(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 returnStatus, void* p) + struct AsyncToSyncWrapper : public FSAsyncParams { - cemu_assert_debug(p && ((AsyncCallbackParam_t*)p)->event); + AsyncToSyncWrapper() + { + coreinit::OSInitEvent(&_event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + ioMsgQueue = nullptr; + userContext = &_result; + userCallback = RPLLoader_MakePPCCallable(SaveAsyncFinishCallback); + _result.returnStatus = 0; + _result.event = &_event; + } - AsyncCallbackParam_t* param = (AsyncCallbackParam_t*)p; - param->returnStatus = returnStatus; - coreinit::OSSignalEvent(param->event); - } + ~AsyncToSyncWrapper() + { - void AsyncCallback(PPCInterpreter_t* hCPU) + } + + FSAsyncParams* GetAsyncParams() + { + return this; + } + + SAVEStatus GetResult() + { + return _result.returnStatus; + } + + void WaitForEvent() + { + coreinit::OSWaitEvent(&_event); + } + private: + coreinit::OSEvent _event; + AsyncResultData _result; + }; + + void SaveAsyncFinishCallback(PPCInterpreter_t* hCPU) { ppcDefineParamMEMPTR(client, coreinit::FSClient_t, 0); ppcDefineParamMEMPTR(block, coreinit::FSCmdBlock_t, 1); ppcDefineParamU32(returnStatus, 2); ppcDefineParamMEMPTR(userContext, void, 3); - MEMPTR<AsyncCallbackParam_t> param{ userContext }; - - // wait till thread is actually suspended - OSThread_t* thread = param->thread.GetPtr(); - while (thread->suspendCounter == 0 || thread->state == OSThread_t::THREAD_STATE::STATE_RUNNING) - coreinit::OSYieldThread(); - - param->returnStatus = returnStatus; - coreinit_resumeThread(param->thread.GetPtr(), 1000); + MEMPTR<AsyncResultData> resultPtr{ userContext }; + resultPtr->returnStatus = returnStatus; + coreinit::OSSignalEvent(resultPtr->event); osLib_returnFromFunction(hCPU, 0); } @@ -320,18 +341,16 @@ namespace save return SAVE_STATUS_OK; } - SAVEStatus SAVERemoveAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + SAVEStatus SAVEInitSaveDir(uint8 accountSlot) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - OSLockMutex(&g_nn_save->mutex); uint32 persistentId; if (GetPersistentIdEx(accountSlot, &persistentId)) { - char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSRemoveAsync(client, block, (uint8*)fullPath, errHandling, (FSAsyncParams*)asyncParams); + acp::ACPStatus status = nn::acp::ACPCreateSaveDir(persistentId, iosu::acp::ACPDeviceType::InternalDeviceType); + result = ConvertACPToSaveStatus(status); } else result = (FSStatus)FS_RESULT::NOT_FOUND; @@ -340,27 +359,6 @@ namespace save return result; } - SAVEStatus SAVEMakeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - - OSLockMutex(&g_nn_save->mutex); - - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, path, fullPath)) - result = coreinit::FSMakeDirAsync(client, block, fullPath, errHandling, (FSAsyncParams*)asyncParams); - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - - OSUnlockMutex(&g_nn_save->mutex); - - return result; - } - SAVEStatus SAVEOpenDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -383,6 +381,69 @@ namespace save return result; } + SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVEOpenDirOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + { + SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); + + OSLockMutex(&g_nn_save->mutex); + uint32 persistentId; + if (GetPersistentIdEx(accountSlot, &persistentId)) + { + char fullPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS) + result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams); + } + else + result = (FSStatus)FS_RESULT::NOT_FOUND; + OSUnlockMutex(&g_nn_save->mutex); + + return result; + } + + SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVEOpenDirOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + { + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); + return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); + } + + SAVEStatus SAVEOpenDirOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) + { + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); + return SAVEOpenDirOtherApplication(client, block, titleId, accountSlot, path, hDir, errHandling); + } + + SAVEStatus SAVEOpenDirOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + { + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); + return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); + } + + SAVEStatus SAVEOpenDirOtherNormalApplicationVariation(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) + { + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); + return SAVEOpenDirOtherApplication(client, block, titleId, accountSlot, path, hDir, errHandling); + } + SAVEStatus SAVEOpenFileAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -430,25 +491,12 @@ namespace save SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetPointer(); - - SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); } SAVEStatus SAVEOpenFileOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) @@ -475,27 +523,6 @@ namespace save return SAVEOpenFileOtherApplication(client, block, titleId, accountSlot, path, mode, outFileHandle, errHandling); } - SAVEStatus SAVEGetFreeSpaceSizeAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - - OSLockMutex(&g_nn_save->mutex); - - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, nullptr, fullPath)) - result = coreinit::FSGetFreeSpaceSizeAsync(client, block, fullPath, freeSize, errHandling, (FSAsyncParams*)asyncParams); - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - - OSUnlockMutex(&g_nn_save->mutex); - - return result; - } - SAVEStatus SAVEGetStatAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -517,6 +544,16 @@ namespace save return result; } + SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + SAVEStatus SAVEGetStatOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -538,12 +575,28 @@ namespace save return result; } + SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + SAVEStatus SAVEGetStatOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); } + SAVEStatus SAVEGetStatOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) + { + uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); + return SAVEGetStatOtherApplication(client, block, titleId, accountSlot, path, stat, errHandling); + } + SAVEStatus SAVEGetStatOtherDemoApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { uint64 titleId = SAVE_UNIQUE_DEMO_TO_TITLE_ID(uniqueId); @@ -562,644 +615,6 @@ namespace save return SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, asyncParams); } - SAVEStatus SAVEInitSaveDir(uint8 accountSlot) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - OSLockMutex(&g_nn_save->mutex); - - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - acp::ACPStatus status = nn::acp::ACPCreateSaveDir(persistentId, iosu::acp::ACPDeviceType::InternalDeviceType); - result = ConvertACPToSaveStatus(status); - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - - OSUnlockMutex(&g_nn_save->mutex); - return result; - } - - SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEGetFreeSpaceSize(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(returnedFreeSize, FSLargeSize, 3); - ppcDefineParamU32(errHandling, 4); - - const SAVEStatus result = SAVEGetFreeSpaceSize(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, returnedFreeSize.GetPtr(), errHandling); - cemuLog_log(LogType::Save, "SAVEGetFreeSpaceSize(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVEGetFreeSpaceSizeAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(returnedFreeSize, FSLargeSize, 3); - ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); - - const SAVEStatus result = SAVEGetFreeSpaceSizeAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, returnedFreeSize.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEGetFreeSpaceSizeAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVEInit(PPCInterpreter_t* hCPU) - { - const SAVEStatus result = SAVEInit(); - cemuLog_log(LogType::Save, "SAVEInit() -> {:x}", result); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVERemoveAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); - - const SAVEStatus result = SAVERemoveAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVERemove(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - - const SAVEStatus result = SAVERemove(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVERenameAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - - OSLockMutex(&g_nn_save->mutex); - - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - char fullOldPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, oldPath, fullOldPath)) - { - char fullNewPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, newPath, fullNewPath)) - result = coreinit::FSRenameAsync(client, block, fullOldPath, fullNewPath, errHandling, (FSAsyncParams*)asyncParams); - } - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - - OSUnlockMutex(&g_nn_save->mutex); - - return result; - } - - void export_SAVERenameAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(oldPath, const char, 3); - ppcDefineParamMEMPTR(newPath, const char, 4); - ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); - - const SAVEStatus result = SAVERenameAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, oldPath.GetPtr(), newPath.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVERenameAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, oldPath.GetPtr(), newPath.GetPtr(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVERename(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - - OSLockMutex(&g_nn_save->mutex); - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - char fullOldPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, oldPath, fullOldPath)) - { - char fullNewPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPath(persistentId, newPath, fullNewPath)) - result = coreinit::FSRename(client, block, fullOldPath, fullNewPath, errHandling); - } - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - OSUnlockMutex(&g_nn_save->mutex); - - return result; - } - - void export_SAVEOpenDirAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 4); - ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); - - const SAVEStatus result = SAVEOpenDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEOpenDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), hDir.GetMPTR(), - (hDir.GetPtr() == nullptr ? 0 : (uint32)*hDir.GetPtr()), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEOpenDir(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 4); - ppcDefineParamU32(errHandling, 5); - - const SAVEStatus result = SAVEOpenDir(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), hDir, errHandling); - cemuLog_log(LogType::Save, "SAVEOpenDir(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), hDir.GetMPTR(), - (hDir.GetPtr() == nullptr ? 0 : (uint32)*hDir.GetPtr()), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - - OSLockMutex(&g_nn_save->mutex); - uint32 persistentId; - if (GetPersistentIdEx(accountSlot, &persistentId)) - { - char fullPath[SAVE_MAX_PATH_SIZE]; - if (GetAbsoluteFullPathOtherApplication(persistentId, titleId, path, fullPath) == FS_RESULT::SUCCESS) - result = coreinit::FSOpenDirAsync(client, block, fullPath, hDir, errHandling, (FSAsyncParams*)asyncParams); - } - else - result = (FSStatus)FS_RESULT::NOT_FOUND; - OSUnlockMutex(&g_nn_save->mutex); - - return result; - } - - void export_SAVEOpenDirOtherApplicationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); - ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 7); - - const SAVEStatus result = SAVEOpenDirOtherApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEOpenDirOtherApplicationAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), titleId, accountSlot, path.GetPtr(), hDir.GetMPTR(), - (hDir.GetPtr() == nullptr ? 0 : (uint32)*hDir.GetPtr()), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEOpenDirOtherApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); - ppcDefineParamU32(errHandling, 6); - - const SAVEStatus result = SAVEOpenDirOtherApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), hDir, errHandling); - cemuLog_log(LogType::Save, "SAVEOpenDirOtherApplication(0x{:08x}, 0x{:08x}, {:x}, {:x}, {}, 0x{:08x} ({:x}), {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), titleId, accountSlot, path.GetPtr(), hDir.GetMPTR(), - (hDir.GetPtr() == nullptr ? 0 : (uint32)*hDir.GetPtr()), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherNormalApplicationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); - return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); - } - - void export_SAVEOpenDirOtherNormalApplicationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); - ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 7); - - const SAVEStatus result = SAVEOpenDirOtherNormalApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) - { - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); - return SAVEOpenDirOtherApplication(client, block, titleId, accountSlot, path, hDir, errHandling); - } - - void export_SAVEOpenDirOtherNormalApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 5); - ppcDefineParamU32(errHandling, 6); - - const SAVEStatus result = SAVEOpenDirOtherNormalApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), hDir, errHandling); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherNormalApplicationVariationAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) - { - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); - return SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, asyncParams); - } - - void export_SAVEOpenDirOtherNormalApplicationVariationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 6); - ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); - - const SAVEStatus result = SAVEOpenDirOtherNormalApplicationVariationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), hDir, errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenDirOtherNormalApplicationVariation(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling) - { - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID_VARIATION(uniqueId, variation); - return SAVEOpenDirOtherApplication(client, block, titleId, accountSlot, path, hDir, errHandling); - } - - void export_SAVEOpenDirOtherNormalApplicationVariation(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(hDir, betype<FSDirHandle2>, 6); - ppcDefineParamU32(errHandling, 7); - - const SAVEStatus result = SAVEOpenDirOtherNormalApplicationVariation(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), hDir, errHandling); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVEMakeDirAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); - - const SAVEStatus result = SAVEMakeDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEMakeDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEMakeDir(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - - const SAVEStatus result = SAVEMakeDir(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling); - cemuLog_log(LogType::Save, "SAVEMakeDir(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = param.GetPointer(); - - SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, outFileHandle, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEInitSaveDir(PPCInterpreter_t* hCPU) - { - ppcDefineParamU8(accountSlot, 0); - const SAVEStatus result = SAVEInitSaveDir(accountSlot); - cemuLog_log(LogType::Save, "SAVEInitSaveDir({:x}) -> {:x}", accountSlot, result); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVEGetStatAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(stat, FSStat_t, 4); - ppcDefineParamU32(errHandling, 5); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 6); - - const SAVEStatus result = SAVEGetStatAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEGetStatAsync(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), stat.GetMPTR(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEGetStat(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamMEMPTR(stat, FSStat_t, 4); - ppcDefineParamU32(errHandling, 5); - - const SAVEStatus result = SAVEGetStat(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), stat.GetPtr(), errHandling); - cemuLog_log(LogType::Save, "SAVEGetStat(0x{:08x}, 0x{:08x}, {:x}, {}, 0x{:08x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), stat.GetMPTR(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - - void export_SAVEGetStatOtherApplicationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(stat, FSStat_t, 6); - ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); - - const SAVEStatus result = SAVEGetStatOtherApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) - { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEGetStatOtherApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU64(titleId, 2); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(stat, FSStat_t, 6); - ppcDefineParamU32(errHandling, 7); - - const SAVEStatus result = SAVEGetStatOtherApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), titleId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); - } - - - void export_SAVEGetStatOtherNormalApplicationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(stat, FSStat_t, 5); - ppcDefineParamU32(errHandling, 6); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); - - const SAVEStatus result = SAVEGetStatOtherNormalApplicationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - - SAVEStatus SAVEGetStatOtherNormalApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) - { - uint64 titleId = SAVE_UNIQUE_TO_TITLE_ID(uniqueId); - return SAVEGetStatOtherApplication(client, block, titleId, accountSlot, path, stat, errHandling); - } - - void export_SAVEGetStatOtherNormalApplication(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(accountSlot, 3); - ppcDefineParamMEMPTR(path, const char, 4); - ppcDefineParamMEMPTR(stat, FSStat_t, 5); - ppcDefineParamU32(errHandling, 6); - - const SAVEStatus result = SAVEGetStatOtherNormalApplication(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); - } - - - - void export_SAVEGetStatOtherNormalApplicationVariationAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(stat, FSStat_t, 6); - ppcDefineParamU32(errHandling, 7); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 8); - - const SAVEStatus result = SAVEGetStatOtherNormalApplicationVariationAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling, asyncParams.GetPtr()); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEGetStatOtherNormalApplicationVariation(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint32 uniqueId, uint8 variation, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling) { //peterBreak(); @@ -1208,21 +623,140 @@ namespace save return SAVEGetStatOtherApplication(client, block, titleId, accountSlot, path, stat, errHandling); } - void export_SAVEGetStatOtherNormalApplicationVariation(PPCInterpreter_t* hCPU) + SAVEStatus SAVEGetFreeSpaceSizeAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU32(uniqueId, 2); - ppcDefineParamU8(variation, 3); - ppcDefineParamU8(accountSlot, 4); - ppcDefineParamMEMPTR(path, const char, 5); - ppcDefineParamMEMPTR(stat, FSStat_t, 6); - ppcDefineParamU32(errHandling, 7); + SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); - const SAVEStatus result = SAVEGetStatOtherNormalApplicationVariation(fsClient.GetPtr(), fsCmdBlock.GetPtr(), uniqueId, variation, accountSlot, path.GetPtr(), stat.GetPtr(), errHandling); - osLib_returnFromFunction(hCPU, result); + OSLockMutex(&g_nn_save->mutex); + + uint32 persistentId; + if (GetPersistentIdEx(accountSlot, &persistentId)) + { + char fullPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPath(persistentId, nullptr, fullPath)) + result = coreinit::FSGetFreeSpaceSizeAsync(client, block, fullPath, freeSize, errHandling, (FSAsyncParams*)asyncParams); + } + else + result = (FSStatus)FS_RESULT::NOT_FOUND; + + OSUnlockMutex(&g_nn_save->mutex); + + return result; } + SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVERemoveAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + { + SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); + + OSLockMutex(&g_nn_save->mutex); + + uint32 persistentId; + if (GetPersistentIdEx(accountSlot, &persistentId)) + { + char fullPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPath(persistentId, path, fullPath)) + result = coreinit::FSRemoveAsync(client, block, (uint8*)fullPath, errHandling, (FSAsyncParams*)asyncParams); + } + else + result = (FSStatus)FS_RESULT::NOT_FOUND; + + OSUnlockMutex(&g_nn_save->mutex); + return result; + } + + SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVERenameAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling, FSAsyncParams* asyncParams) + { + SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); + OSLockMutex(&g_nn_save->mutex); + + uint32 persistentId; + if (GetPersistentIdEx(accountSlot, &persistentId)) + { + char fullOldPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPath(persistentId, oldPath, fullOldPath)) + { + char fullNewPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPath(persistentId, newPath, fullNewPath)) + result = coreinit::FSRenameAsync(client, block, fullOldPath, fullNewPath, errHandling, asyncParams); + } + } + else + result = (FSStatus)FS_RESULT::NOT_FOUND; + + OSUnlockMutex(&g_nn_save->mutex); + return result; + } + + SAVEStatus SAVERename(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* oldPath, const char* newPath, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVERenameAsync(client, block, accountSlot, oldPath, newPath, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVEMakeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) + { + SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); + + OSLockMutex(&g_nn_save->mutex); + + uint32 persistentId; + if (GetPersistentIdEx(accountSlot, &persistentId)) + { + char fullPath[SAVE_MAX_PATH_SIZE]; + if (GetAbsoluteFullPath(persistentId, path, fullPath)) + result = coreinit::FSMakeDirAsync(client, block, fullPath, errHandling, (FSAsyncParams*)asyncParams); + } + else + result = (FSStatus)FS_RESULT::NOT_FOUND; + + OSUnlockMutex(&g_nn_save->mutex); + + return result; + } + + SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } + + SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandlePtr outFileHandle, FS_ERROR_MASK errHandling) + { + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, outFileHandle, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); + } SAVEStatus SAVEGetSharedDataTitlePath(uint64 titleId, const char* dataFileName, char* output, sint32 outputLength) { @@ -1234,17 +768,6 @@ namespace save return result; } - void export_SAVEGetSharedDataTitlePath(PPCInterpreter_t* hCPU) - { - ppcDefineParamU64(titleId, 0); - ppcDefineParamMEMPTR(dataFileName, const char, 2); - ppcDefineParamMEMPTR(output, char, 3); - ppcDefineParamS32(outputLength, 4); - const SAVEStatus result = SAVEGetSharedDataTitlePath(titleId, dataFileName.GetPtr(), output.GetPtr(), outputLength); - cemuLog_log(LogType::Save, "SAVEGetSharedDataTitlePath(0x{:x}, {}, {}, 0x{:x}) -> {:x}", titleId, dataFileName.GetPtr(), output.GetPtr(), outputLength, result); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEGetSharedSaveDataPath(uint64 titleId, const char* dataFileName, char* output, uint32 outputLength) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -1255,16 +778,6 @@ namespace save return result; } - void export_SAVEGetSharedSaveDataPath(PPCInterpreter_t* hCPU) - { - ppcDefineParamU64(titleId, 0); - ppcDefineParamMEMPTR(dataFileName, const char, 2); - ppcDefineParamMEMPTR(output, char, 3); - ppcDefineParamU32(outputLength, 4); - const SAVEStatus result = SAVEGetSharedSaveDataPath(titleId, dataFileName.GetPtr(), output.GetPtr(), outputLength); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEChangeDirAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) { SAVEStatus result = (FSStatus)(FS_RESULT::FATAL_ERROR); @@ -1284,52 +797,14 @@ namespace save return result; } - void export_SAVEChangeDirAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 5); - const SAVEStatus result = SAVEChangeDirAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEChangeDirAsync(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEChangeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling) { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - - return status; - } - - void export_SAVEChangeDir(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamMEMPTR(path, const char, 3); - ppcDefineParamU32(errHandling, 4); - const SAVEStatus result = SAVEChangeDir(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, path.GetPtr(), errHandling); - cemuLog_log(LogType::Save, "SAVEChangeDir(0x{:08x}, 0x{:08x}, {:x}, {}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, path.GetPtr(), errHandling, result); - osLib_returnFromFunction(hCPU, result); + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); } SAVEStatus SAVEFlushQuotaAsync(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling, const FSAsyncParams* asyncParams) @@ -1355,71 +830,45 @@ namespace save return result; } - void export_SAVEFlushQuotaAsync(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamU32(errHandling, 3); - ppcDefineParamMEMPTR(asyncParams, FSAsyncParams, 4); - const SAVEStatus result = SAVEFlushQuotaAsync(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, errHandling, asyncParams.GetPtr()); - cemuLog_log(LogType::Save, "SAVEFlushQuotaAsync(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); - osLib_returnFromFunction(hCPU, result); - } - SAVEStatus SAVEFlushQuota(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling) { - MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()}; - FSAsyncParams asyncParams; - asyncParams.ioMsgQueue = nullptr; - asyncParams.userCallback = RPLLoader_MakePPCCallable(AsyncCallback); - - StackAllocator<AsyncCallbackParam_t> param; - param->thread = currentThread; - param->returnStatus = (FSStatus)FS_RESULT::SUCCESS; - asyncParams.userContext = ¶m; - - SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams); - if (status == (FSStatus)FS_RESULT::SUCCESS) - { - coreinit_suspendThread(currentThread, 1000); - PPCCore_switchToScheduler(); - return param->returnStatus; - } - return status; - } - - void export_SAVEFlushQuota(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 0); - ppcDefineParamMEMPTR(fsCmdBlock, coreinit::FSCmdBlock_t, 1); - ppcDefineParamU8(accountSlot, 2); - ppcDefineParamU32(errHandling, 3); - const SAVEStatus result = SAVEFlushQuota(fsClient.GetPtr(), fsCmdBlock.GetPtr(), accountSlot, errHandling); - cemuLog_log(LogType::Save, "SAVEFlushQuota(0x{:08x}, 0x{:08x}, {:x}, {:x}) -> {:x}", fsClient.GetMPTR(), fsCmdBlock.GetMPTR(), accountSlot, errHandling, result); - osLib_returnFromFunction(hCPU, result); + StackAllocator<AsyncToSyncWrapper> asyncData; + SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, asyncData->GetAsyncParams()); + if (status != (FSStatus)FS_RESULT::SUCCESS) + return status; + asyncData->WaitForEvent(); + return asyncData->GetResult(); } void load() { + cafeExportRegister("nn_save", SAVEInit, LogType::Save); + cafeExportRegister("nn_save", SAVEInitSaveDir, LogType::Save); + cafeExportRegister("nn_save", SAVEGetSharedDataTitlePath, LogType::Save); + cafeExportRegister("nn_save", SAVEGetSharedSaveDataPath, LogType::Save); - osLib_addFunction("nn_save", "SAVEInit", export_SAVEInit); - osLib_addFunction("nn_save", "SAVEInitSaveDir", export_SAVEInitSaveDir); - osLib_addFunction("nn_save", "SAVEGetSharedDataTitlePath", export_SAVEGetSharedDataTitlePath); - osLib_addFunction("nn_save", "SAVEGetSharedSaveDataPath", export_SAVEGetSharedSaveDataPath); + cafeExportRegister("nn_save", SAVEGetFreeSpaceSize, LogType::Save); + cafeExportRegister("nn_save", SAVEGetFreeSpaceSizeAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEMakeDir, LogType::Save); + cafeExportRegister("nn_save", SAVEMakeDirAsync, LogType::Save); + cafeExportRegister("nn_save", SAVERemove, LogType::Save); + cafeExportRegister("nn_save", SAVERemoveAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEChangeDir, LogType::Save); + cafeExportRegister("nn_save", SAVEChangeDirAsync, LogType::Save); + cafeExportRegister("nn_save", SAVERename, LogType::Save); + cafeExportRegister("nn_save", SAVERenameAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEFlushQuota, LogType::Save); + cafeExportRegister("nn_save", SAVEFlushQuotaAsync, LogType::Save); - // sync functions - osLib_addFunction("nn_save", "SAVEGetFreeSpaceSize", export_SAVEGetFreeSpaceSize); - osLib_addFunction("nn_save", "SAVEMakeDir", export_SAVEMakeDir); - osLib_addFunction("nn_save", "SAVERemove", export_SAVERemove); - osLib_addFunction("nn_save", "SAVEChangeDir", export_SAVEChangeDir); - osLib_addFunction("nn_save", "SAVEFlushQuota", export_SAVEFlushQuota); - - osLib_addFunction("nn_save", "SAVEGetStat", export_SAVEGetStat); - osLib_addFunction("nn_save", "SAVEGetStatOtherApplication", export_SAVEGetStatOtherApplication); - osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplication", export_SAVEGetStatOtherNormalApplication); - osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationVariation", export_SAVEGetStatOtherNormalApplicationVariation); + cafeExportRegister("nn_save", SAVEGetStat, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherNormalApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherNormalApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherNormalApplicationVariation, LogType::Save); + cafeExportRegister("nn_save", SAVEGetStatOtherNormalApplicationVariationAsync, LogType::Save); cafeExportRegister("nn_save", SAVEOpenFile, LogType::Save); cafeExportRegister("nn_save", SAVEOpenFileAsync, LogType::Save); @@ -1430,30 +879,14 @@ namespace save cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplicationVariation, LogType::Save); cafeExportRegister("nn_save", SAVEOpenFileOtherNormalApplicationVariationAsync, LogType::Save); - osLib_addFunction("nn_save", "SAVEOpenDir", export_SAVEOpenDir); - osLib_addFunction("nn_save", "SAVEOpenDirOtherApplication", export_SAVEOpenDirOtherApplication); - osLib_addFunction("nn_save", "SAVEOpenDirOtherNormalApplication", export_SAVEOpenDirOtherNormalApplication); - osLib_addFunction("nn_save", "SAVEOpenDirOtherNormalApplicationVariation", export_SAVEOpenDirOtherNormalApplicationVariation); - - // async functions - osLib_addFunction("nn_save", "SAVEGetFreeSpaceSizeAsync", export_SAVEGetFreeSpaceSizeAsync); - osLib_addFunction("nn_save", "SAVEMakeDirAsync", export_SAVEMakeDirAsync); - osLib_addFunction("nn_save", "SAVERemoveAsync", export_SAVERemoveAsync); - osLib_addFunction("nn_save", "SAVERenameAsync", export_SAVERenameAsync); - cafeExportRegister("nn_save", SAVERename, LogType::Save); - - osLib_addFunction("nn_save", "SAVEChangeDirAsync", export_SAVEChangeDirAsync); - osLib_addFunction("nn_save", "SAVEFlushQuotaAsync", export_SAVEFlushQuotaAsync); - - osLib_addFunction("nn_save", "SAVEGetStatAsync", export_SAVEGetStatAsync); - osLib_addFunction("nn_save", "SAVEGetStatOtherApplicationAsync", export_SAVEGetStatOtherApplicationAsync); - osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationAsync", export_SAVEGetStatOtherNormalApplicationAsync); - osLib_addFunction("nn_save", "SAVEGetStatOtherNormalApplicationVariationAsync", export_SAVEGetStatOtherNormalApplicationVariationAsync); - - osLib_addFunction("nn_save", "SAVEOpenDirAsync", export_SAVEOpenDirAsync); - osLib_addFunction("nn_save", "SAVEOpenDirOtherApplicationAsync", export_SAVEOpenDirOtherApplicationAsync); - osLib_addFunction("nn_save", "SAVEOpenDirOtherNormalApplicationAsync", export_SAVEOpenDirOtherNormalApplicationAsync); - osLib_addFunction("nn_save", "SAVEOpenDirOtherNormalApplicationVariationAsync", export_SAVEOpenDirOtherNormalApplicationVariationAsync); + cafeExportRegister("nn_save", SAVEOpenDir, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherNormalApplication, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherNormalApplicationVariation, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherNormalApplicationAsync, LogType::Save); + cafeExportRegister("nn_save", SAVEOpenDirOtherNormalApplicationVariationAsync, LogType::Save); } void ResetToDefaultState() diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index b2362d0b..5fb73479 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -11,7 +11,7 @@ using PAddr = uint32; // physical address extern uint8* memory_base; extern uint8* PPCInterpreterGetStackPointer(); -extern uint8* PPCInterpreterGetAndModifyStackPointer(sint32 offset); +extern uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset); extern void PPCInterpreterModifyStackPointer(sint32 offset); class MEMPTRBase {}; diff --git a/src/Common/StackAllocator.h b/src/Common/StackAllocator.h index 1dc52d51..856224cf 100644 --- a/src/Common/StackAllocator.h +++ b/src/Common/StackAllocator.h @@ -10,14 +10,16 @@ public: explicit StackAllocator(const uint32 items) { + m_items = items; m_modified_size = count * sizeof(T) * items + kStaticMemOffset * 2; - - auto tmp = PPCInterpreterGetStackPointer(); - m_ptr = (T*)(PPCInterpreterGetAndModifyStackPointer(m_modified_size) + kStaticMemOffset); + m_modified_size = (m_modified_size/8+7) * 8; // pad to 8 bytes + m_ptr = new(PPCInterpreter_PushAndReturnStackPointer(m_modified_size) + kStaticMemOffset) T[count * items](); } ~StackAllocator() { + for (size_t i = 0; i < count * m_items; ++i) + m_ptr[i].~T(); PPCInterpreterModifyStackPointer(-m_modified_size); } @@ -64,4 +66,5 @@ private: T* m_ptr; sint32 m_modified_size; + uint32 m_items; }; \ No newline at end of file From f576269ed0e52f5487a1e8ad19a109b5d4214bf0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 29 May 2024 00:34:11 +0200 Subject: [PATCH 198/314] Refactor legacy method of emulating thread events --- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 18 --------- src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 5 --- src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp | 13 ++++--- src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 38 +++++++++---------- 4 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index b53d04ed..2f3808b7 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -1608,21 +1608,3 @@ namespace coreinit } } - -void coreinit_suspendThread(OSThread_t* OSThreadBE, sint32 count) -{ - // for legacy source - OSThreadBE->suspendCounter += count; -} - -void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count) -{ - __OSLockScheduler(); - coreinit::__OSResumeThreadInternal(OSThreadBE, count); - __OSUnlockScheduler(); -} - -OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU) -{ - return coreinit::__currentCoreThread[PPCInterpreter_getCoreIndex(hCPU)]; -} diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index 8b144bd3..df787bf0 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -621,11 +621,6 @@ namespace coreinit #pragma pack() // deprecated / clean up required -void coreinit_suspendThread(OSThread_t* OSThreadBE, sint32 count = 1); -void coreinit_resumeThread(OSThread_t* OSThreadBE, sint32 count = 1); - -OSThread_t* coreinitThread_getCurrentThreadDepr(PPCInterpreter_t* hCPU); - extern MPTR activeThread[256]; extern sint32 activeThreadCount; diff --git a/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp b/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp index a69f32a3..eb0178fe 100644 --- a/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp +++ b/src/Cafe/OS/libs/nn_idbe/nn_idbe.cpp @@ -40,7 +40,7 @@ namespace nn static_assert(offsetof(nnIdbeEncryptedIcon_t, iconData) == 0x22, ""); static_assert(sizeof(nnIdbeEncryptedIcon_t) == 0x12082); - void asyncDownloadIconFile(uint64 titleId, nnIdbeEncryptedIcon_t* iconOut, OSThread_t* thread) + void asyncDownloadIconFile(uint64 titleId, nnIdbeEncryptedIcon_t* iconOut, coreinit::OSEvent* event) { std::vector<uint8> idbeData = NAPI::IDBE_RequestRawEncrypted(ActiveSettings::GetNetworkService(), titleId); if (idbeData.size() != sizeof(nnIdbeEncryptedIcon_t)) @@ -48,11 +48,11 @@ namespace nn // icon does not exist or has the wrong size cemuLog_log(LogType::Force, "IDBE: Failed to retrieve icon for title {:016x}", titleId); memset(iconOut, 0, sizeof(nnIdbeEncryptedIcon_t)); - coreinit_resumeThread(thread); + coreinit::OSSignalEvent(event); return; } memcpy(iconOut, idbeData.data(), sizeof(nnIdbeEncryptedIcon_t)); - coreinit_resumeThread(thread); + coreinit::OSSignalEvent(event); } void export_DownloadIconFile(PPCInterpreter_t* hCPU) @@ -62,9 +62,10 @@ namespace nn ppcDefineParamU32(uknR7, 4); ppcDefineParamU32(uknR8, 5); - auto asyncTask = std::async(std::launch::async, asyncDownloadIconFile, titleId, encryptedIconData, coreinit::OSGetCurrentThread()); - coreinit::OSSuspendThread(coreinit::OSGetCurrentThread()); - PPCCore_switchToScheduler(); + StackAllocator<coreinit::OSEvent> event; + coreinit::OSInitEvent(&event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + auto asyncTask = std::async(std::launch::async, asyncDownloadIconFile, titleId, encryptedIconData, &event); + coreinit::OSWaitEvent(&event); osLib_returnFromFunction(hCPU, 1); } diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index ba3e3b96..ff5c4f45 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -429,8 +429,7 @@ namespace nsyshid // handler for synchronous HIDSetReport transfers sint32 _hidSetReportSync(std::shared_ptr<Device> device, uint8* reportData, sint32 length, - uint8* originalData, - sint32 originalLength, OSThread_t* osThread) + uint8* originalData, sint32 originalLength, coreinit::OSEvent* event) { _debugPrintHex("_hidSetReportSync Begin", reportData, length); sint32 returnCode = 0; @@ -440,7 +439,7 @@ namespace nsyshid } free(reportData); cemuLog_logDebug(LogType::Force, "_hidSetReportSync end. returnCode: {}", returnCode); - coreinit_resumeThread(osThread, 1000); + coreinit::OSSignalEvent(event); return returnCode; } @@ -484,11 +483,12 @@ namespace nsyshid sint32 returnCode = 0; if (callbackFuncMPTR == MPTR_NULL) { + // synchronous + StackAllocator<coreinit::OSEvent> event; + coreinit::OSInitEvent(&event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); std::future<sint32> res = std::async(std::launch::async, &_hidSetReportSync, device, reportData, - paddedLength + 1, data, dataLength, - coreinitThread_getCurrentThreadDepr(hCPU)); - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); - PPCCore_switchToScheduler(); + paddedLength + 1, data, dataLength, &event); + coreinit::OSWaitEvent(&event); returnCode = res.get(); } else @@ -557,10 +557,10 @@ namespace nsyshid sint32 _hidReadSync(std::shared_ptr<Device> device, uint8* data, sint32 maxLength, - OSThread_t* osThread) + coreinit::OSEvent* event) { sint32 returnCode = _hidReadInternalSync(device, data, maxLength); - coreinit_resumeThread(osThread, 1000); + coreinit::OSSignalEvent(event); return returnCode; } @@ -591,10 +591,10 @@ namespace nsyshid else { // synchronous transfer - std::future<sint32> res = std::async(std::launch::async, &_hidReadSync, device, data, maxLength, - coreinitThread_getCurrentThreadDepr(hCPU)); - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); - PPCCore_switchToScheduler(); + StackAllocator<coreinit::OSEvent> event; + coreinit::OSInitEvent(&event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + std::future<sint32> res = std::async(std::launch::async, &_hidReadSync, device, data, maxLength, &event); + coreinit::OSWaitEvent(&event); returnCode = res.get(); } @@ -654,10 +654,10 @@ namespace nsyshid sint32 _hidWriteSync(std::shared_ptr<Device> device, uint8* data, sint32 maxLength, - OSThread_t* osThread) + coreinit::OSEvent* event) { sint32 returnCode = _hidWriteInternalSync(device, data, maxLength); - coreinit_resumeThread(osThread, 1000); + coreinit::OSSignalEvent(event); return returnCode; } @@ -688,10 +688,10 @@ namespace nsyshid else { // synchronous transfer - std::future<sint32> res = std::async(std::launch::async, &_hidWriteSync, device, data, maxLength, - coreinitThread_getCurrentThreadDepr(hCPU)); - coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(hCPU), 1000); - PPCCore_switchToScheduler(); + StackAllocator<coreinit::OSEvent> event; + coreinit::OSInitEvent(&event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + std::future<sint32> res = std::async(std::launch::async, &_hidWriteSync, device, data, maxLength, &event); + coreinit::OSWaitEvent(&event); returnCode = res.get(); } From d33337d5394754a738989fe4736abc534cefe8cb Mon Sep 17 00:00:00 2001 From: Colin Kinloch <colin@kinlo.ch> Date: Tue, 28 May 2024 23:36:12 +0100 Subject: [PATCH 199/314] Fix GamePad window size (#1224) --- src/gui/PadViewFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/PadViewFrame.cpp b/src/gui/PadViewFrame.cpp index 744df323..f2da2ca7 100644 --- a/src/gui/PadViewFrame.cpp +++ b/src/gui/PadViewFrame.cpp @@ -72,7 +72,7 @@ void PadViewFrame::InitializeRenderCanvas() m_render_canvas = GLCanvas_Create(this, wxSize(854, 480), false); sizer->Add(m_render_canvas, 1, wxEXPAND, 0, nullptr); } - SetSizer(sizer); + SetSizerAndFit(sizer); Layout(); m_render_canvas->Bind(wxEVT_KEY_UP, &PadViewFrame::OnKeyUp, this); From 5f825a1fa8eacf87b18a5b5666080c7c0dd55926 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 2 Jun 2024 20:29:10 +0200 Subject: [PATCH 200/314] Latte: Always allow views with the same format as base texture Fixes crash/assert in VC N64 titles --- src/Cafe/HW/Latte/Core/LatteTexture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Cafe/HW/Latte/Core/LatteTexture.cpp b/src/Cafe/HW/Latte/Core/LatteTexture.cpp index 3754fb19..d8852891 100644 --- a/src/Cafe/HW/Latte/Core/LatteTexture.cpp +++ b/src/Cafe/HW/Latte/Core/LatteTexture.cpp @@ -235,6 +235,9 @@ void LatteTexture_InitSliceAndMipInfo(LatteTexture* texture) // if this function returns false, textures will not be synchronized even if their data overlaps bool LatteTexture_IsFormatViewCompatible(Latte::E_GX2SURFFMT formatA, Latte::E_GX2SURFFMT formatB) { + if(formatA == formatB) + return true; // if the format is identical then compatibility must be guaranteed (otherwise we can't create the necessary default view of a texture) + // todo - find a better way to handle this for (sint32 swap = 0; swap < 2; swap++) { From 16070458edddb8bd73baf3cbb1678f5a8b2dbc5e Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:39:06 +0200 Subject: [PATCH 201/314] Logging: Restructure menu + allow toggeling APIErrors logtype The logtype "APIErrors" previously was always enabled. This option is intended to help homebrew developers notice mistakes in how they use CafeOS API. But some commercial games trigger these a lot and cause log.txt bloat (e.g. seen in XCX). Thus this commit changes it so that it's off by default and instead can be toggled if desired. Additionally in this commit: - COS module logging options are no longer translatable (our debug logging is fundamentally English) - Restructured the log menu and moved the logging options that are mainly of interest to Cemu devs into a separate submenu --- src/Cafe/OS/libs/gx2/GX2_Command.cpp | 8 ----- src/Cafe/OS/libs/gx2/GX2_Command.h | 4 +-- src/Cafe/OS/libs/gx2/GX2_ContextState.cpp | 3 +- src/Cafe/OS/libs/gx2/GX2_Shader.cpp | 2 +- src/Cemu/Logging/CemuLogging.cpp | 1 + src/Cemu/Logging/CemuLogging.h | 2 +- src/gui/MainWindow.cpp | 44 +++++++++++++---------- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Cafe/OS/libs/gx2/GX2_Command.cpp b/src/Cafe/OS/libs/gx2/GX2_Command.cpp index 804e3da0..ec96a4ff 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Command.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Command.cpp @@ -154,14 +154,6 @@ namespace GX2 return gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL; } - bool GX2WriteGather_isDisplayListActive() - { - uint32 coreIndex = coreinit::OSGetCoreId(); - if (gx2WriteGatherPipe.displayListStart[coreIndex] != MPTR_NULL) - return true; - return false; - } - uint32 GX2WriteGather_getReadWriteDistance() { uint32 coreIndex = sGX2MainCoreIndex; diff --git a/src/Cafe/OS/libs/gx2/GX2_Command.h b/src/Cafe/OS/libs/gx2/GX2_Command.h index 635680e0..51c04928 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Command.h +++ b/src/Cafe/OS/libs/gx2/GX2_Command.h @@ -84,8 +84,6 @@ inline void gx2WriteGather_submit(Targs... args) namespace GX2 { - - bool GX2WriteGather_isDisplayListActive(); uint32 GX2WriteGather_getReadWriteDistance(); void GX2WriteGather_checkAndInsertWrapAroundMark(); @@ -96,6 +94,8 @@ namespace GX2 void GX2CallDisplayList(MPTR addr, uint32 size); void GX2DirectCallDisplayList(void* addr, uint32 size); + bool GX2GetDisplayListWriteStatus(); + void GX2Init_writeGather(); void GX2CommandInit(); void GX2CommandResetToDefaultState(); diff --git a/src/Cafe/OS/libs/gx2/GX2_ContextState.cpp b/src/Cafe/OS/libs/gx2/GX2_ContextState.cpp index a4cfc93d..cf150b47 100644 --- a/src/Cafe/OS/libs/gx2/GX2_ContextState.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_ContextState.cpp @@ -291,8 +291,7 @@ void gx2Export_GX2SetDefaultState(PPCInterpreter_t* hCPU) void _GX2ContextCreateRestoreStateDL(GX2ContextState_t* gx2ContextState) { // begin display list - if (GX2::GX2WriteGather_isDisplayListActive()) - assert_dbg(); + cemu_assert_debug(!GX2::GX2GetDisplayListWriteStatus()); // must not already be writing to a display list GX2::GX2BeginDisplayList((void*)gx2ContextState->loadDL_buffer, sizeof(gx2ContextState->loadDL_buffer)); _GX2Context_WriteCmdRestoreState(gx2ContextState, 0); uint32 displayListSize = GX2::GX2EndDisplayList((void*)gx2ContextState->loadDL_buffer); diff --git a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp index d004288b..dfbbfcff 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp @@ -426,7 +426,7 @@ namespace GX2 } if((aluRegisterOffset+sizeInU32s) > 0x400) { - cemuLog_logOnce(LogType::APIErrors, "GX2SetVertexUniformReg values are out of range (offset {} + size {} must be equal or smaller than 0x400)", aluRegisterOffset, sizeInU32s); + cemuLog_logOnce(LogType::APIErrors, "GX2SetVertexUniformReg values are out of range (offset {} + size {} must be equal or smaller than 1024)", aluRegisterOffset, sizeInU32s); } if( (sizeInU32s&3) != 0) { diff --git a/src/Cemu/Logging/CemuLogging.cpp b/src/Cemu/Logging/CemuLogging.cpp index e49ece94..5cde2a7f 100644 --- a/src/Cemu/Logging/CemuLogging.cpp +++ b/src/Cemu/Logging/CemuLogging.cpp @@ -36,6 +36,7 @@ struct _LogContext const std::map<LogType, std::string> g_logging_window_mapping { {LogType::UnsupportedAPI, "Unsupported API calls"}, + {LogType::APIErrors, "Invalid API usage"}, {LogType::CoreinitLogging, "Coreinit Logging"}, {LogType::CoreinitFile, "Coreinit File-Access"}, {LogType::CoreinitThreadSync, "Coreinit Thread-Synchronization"}, diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 5fd652b3..a671ce51 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -7,7 +7,7 @@ enum class LogType : sint32 // note: IDs must be in range 1-64 Force = 63, // always enabled Placeholder = 62, // always disabled - APIErrors = Force, // alias for Force. Logs bad parameters or other API usage mistakes or unintended errors in OS libs + APIErrors = 61, // Logs bad parameters or other API usage mistakes or unintended errors in OS libs. Intended for homebrew developers CoreinitFile = 0, GX2 = 1, diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 33e2cdc1..03c69a7f 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2191,27 +2191,35 @@ void MainWindow::RecreateMenu() m_menuBar->Append(nfcMenu, _("&NFC")); m_nfcMenuSeparator0 = nullptr; // debug->logging submenu - wxMenu* debugLoggingMenu = new wxMenu; + wxMenu* debugLoggingMenu = new wxMenu(); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::UnsupportedAPI), _("&Unsupported API calls"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::UnsupportedAPI)); + debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::APIErrors), _("&Invalid API usage"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::APIErrors)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitLogging), _("&Coreinit Logging (OSReport/OSConsole)"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitLogging)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitFile), _("&Coreinit File-Access API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitFile)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThreadSync), _("&Coreinit Thread-Synchronization API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThreadSync)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMem), _("&Coreinit Memory API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMem)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMP), _("&Coreinit MP API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMP)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("&Coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("&NN NFP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_FP), _("&NN FP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_FP)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::PRUDP), _("&PRUDP (for NN FP)"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::PRUDP)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_BOSS), _("&NN BOSS"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_BOSS)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("&GX2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("&Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::InputAPI), _("&Input API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::InputAPI)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Socket), _("&Socket API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Socket)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Save), _("&Save API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Save)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::H264), _("&H264 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::H264)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NFC), _("&NFC API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NFC)); - debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NTAG), _("&NTAG API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NTAG)); + debugLoggingMenu->AppendSeparator(); + + wxMenu* logCosModulesMenu = new wxMenu(); + logCosModulesMenu->AppendCheckItem(0, _("&Options below are for experts. Leave off if unsure"), wxEmptyString)->Enable(false); + logCosModulesMenu->AppendSeparator(); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitFile), _("coreinit File-Access API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitFile)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThreadSync), _("coreinit Thread-Synchronization API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThreadSync)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMem), _("coreinit Memory API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMem)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitMP), _("coreinit MP API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitMP)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::CoreinitThread), _("coreinit Thread API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::CoreinitThread)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Save), _("nn_save API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Save)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_NFP), _("nn_nfp API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_NFP)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_FP), _("nn_fp API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_FP)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::PRUDP), _("nn_fp PRUDP"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::PRUDP)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NN_BOSS), _("nn_boss API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NN_BOSS)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NFC), _("nfc API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NFC)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::NTAG), _("ntag API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::NTAG)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Socket), _("nsysnet API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Socket)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::H264), _("h264 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::H264)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::GX2), _("gx2 API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::GX2)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::SoundAPI), _("Audio API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::SoundAPI)); + logCosModulesMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::InputAPI), _("Input API"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::InputAPI)); + + debugLoggingMenu->AppendSubMenu(logCosModulesMenu, _("&CafeOS modules logging")); debugLoggingMenu->AppendSeparator(); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::Patches), _("&Graphic pack patches"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::Patches)); debugLoggingMenu->AppendCheckItem(MAINFRAME_MENU_ID_DEBUG_LOGGING0 + stdx::to_underlying(LogType::TextureCache), _("&Texture cache warnings"), wxEmptyString)->Check(cemuLog_isLoggingEnabled(LogType::TextureCache)); From 6772b1993ff678050d9a064dbd8c625eede272a1 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:34:42 +0200 Subject: [PATCH 202/314] vcpkg: Update dependencies (#1229) --- dependencies/vcpkg | 2 +- .../sdl2/alsa-dep-fix.patch | 13 -- .../vcpkg_overlay_ports/sdl2/deps.patch | 13 -- .../vcpkg_overlay_ports/sdl2/portfile.cmake | 137 ------------------ dependencies/vcpkg_overlay_ports/sdl2/usage | 8 - .../vcpkg_overlay_ports/sdl2/vcpkg.json | 68 --------- .../vcpkg_overlay_ports/tiff/FindCMath.patch | 13 -- .../vcpkg_overlay_ports/tiff/portfile.cmake | 86 ----------- dependencies/vcpkg_overlay_ports/tiff/usage | 9 -- .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ------------- .../vcpkg_overlay_ports/tiff/vcpkg.json | 67 --------- .../dbus/cmake.dep.patch | 15 -- .../dbus/getpeereid.patch | 26 ---- .../dbus/libsystemd.patch | 15 -- .../dbus/pkgconfig.patch | 21 --- .../dbus/portfile.cmake | 88 ----------- .../vcpkg_overlay_ports_linux/dbus/vcpkg.json | 30 ---- .../sdl2/alsa-dep-fix.patch | 13 -- .../vcpkg_overlay_ports_linux/sdl2/deps.patch | 13 -- .../sdl2/portfile.cmake | 137 ------------------ .../vcpkg_overlay_ports_linux/sdl2/usage | 8 - .../vcpkg_overlay_ports_linux/sdl2/vcpkg.json | 68 --------- .../tiff/FindCMath.patch | 13 -- .../tiff/portfile.cmake | 86 ----------- .../vcpkg_overlay_ports_linux/tiff/usage | 9 -- .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ------------- .../vcpkg_overlay_ports_linux/tiff/vcpkg.json | 67 --------- .../sdl2/alsa-dep-fix.patch | 13 -- .../vcpkg_overlay_ports_mac/sdl2/deps.patch | 13 -- .../sdl2/portfile.cmake | 137 ------------------ .../vcpkg_overlay_ports_mac/sdl2/usage | 8 - .../vcpkg_overlay_ports_mac/sdl2/vcpkg.json | 68 --------- .../tiff/FindCMath.patch | 13 -- .../tiff/portfile.cmake | 86 ----------- .../vcpkg_overlay_ports_mac/tiff/usage | 9 -- .../tiff/vcpkg-cmake-wrapper.cmake.in | 104 ------------- .../vcpkg_overlay_ports_mac/tiff/vcpkg.json | 67 --------- vcpkg.json | 18 ++- 38 files changed, 18 insertions(+), 1751 deletions(-) delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/deps.patch delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/usage delete mode 100644 dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch delete mode 100644 dependencies/vcpkg_overlay_ports/tiff/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports/tiff/usage delete mode 100644 dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in delete mode 100644 dependencies/vcpkg_overlay_ports/tiff/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/usage delete mode 100644 dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch delete mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/usage delete mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in delete mode 100644 dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch delete mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch delete mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/usage delete mode 100644 dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json delete mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch delete mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake delete mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/usage delete mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in delete mode 100644 dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json diff --git a/dependencies/vcpkg b/dependencies/vcpkg index cbf4a664..a4275b7e 160000 --- a/dependencies/vcpkg +++ b/dependencies/vcpkg @@ -1 +1 @@ -Subproject commit cbf4a6641528cee6f172328984576f51698de726 +Subproject commit a4275b7eee79fb24ec2e135481ef5fce8b41c339 diff --git a/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch deleted file mode 100644 index 5b2c77b9..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/alsa-dep-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in -index cc8bcf26d..ead829767 100644 ---- a/SDL2Config.cmake.in -+++ b/SDL2Config.cmake.in -@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") - - set(SDL_ALSA @SDL_ALSA@) - set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) --if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) -+if(SDL_ALSA) - sdlFindALSA() - endif() - unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports/sdl2/deps.patch deleted file mode 100644 index a8637d8c..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/deps.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake -index 65a98efbe..2f99f28f1 100644 ---- a/cmake/sdlchecks.cmake -+++ b/cmake/sdlchecks.cmake -@@ -352,7 +352,7 @@ endmacro() - # - HAVE_SDL_LOADSO opt - macro(CheckLibSampleRate) - if(SDL_LIBSAMPLERATE) -- find_package(SampleRate QUIET) -+ find_package(SampleRate CONFIG REQUIRED) - if(SampleRate_FOUND AND TARGET SampleRate::samplerate) - set(HAVE_LIBSAMPLERATE TRUE) - set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake deleted file mode 100644 index 22685e6a..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/portfile.cmake +++ /dev/null @@ -1,137 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libsdl-org/SDL - REF "release-${VERSION}" - SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c - HEAD_REF main - PATCHES - deps.patch - alsa-dep-fix.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - alsa SDL_ALSA - alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA - ibus SDL_IBUS - samplerate SDL_LIBSAMPLERATE - vulkan SDL_VULKAN - wayland SDL_WAYLAND - x11 SDL_X11 - INVERTED_FEATURES - alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA -) - -if ("x11" IN_LIST FEATURES) - message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") -endif() -if ("wayland" IN_LIST FEATURES) - message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") -endif() -if ("ibus" IN_LIST FEATURES) - message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} - OPTIONS ${FEATURE_OPTIONS} - -DSDL_STATIC=${SDL_STATIC} - -DSDL_SHARED=${SDL_SHARED} - -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} - -DSDL_LIBC=ON - -DSDL_TEST=OFF - -DSDL_INSTALL_CMAKEDIR="cmake" - -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON - -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON - -DSDL_LIBSAMPLERATE_SHARED=OFF - MAYBE_UNUSED_VARIABLES - SDL_FORCE_STATIC_VCRT - PKG_CONFIG_USE_CMAKE_PREFIX_PATH -) - -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH cmake) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/share/licenses" - "${CURRENT_PACKAGES_DIR}/share/aclocal" -) - -file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT BINS) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") - endif() - - file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") - foreach(SHARE_FILE ${SHARE_FILES}) - vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") - endforeach() -endif() - -vcpkg_copy_pdbs() - -set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") -set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) -string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") -string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") - endif() -endif() - -if(VCPKG_TARGET_IS_UWP) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "d") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() -endif() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports/sdl2/usage b/dependencies/vcpkg_overlay_ports/sdl2/usage deleted file mode 100644 index 1cddcd46..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/usage +++ /dev/null @@ -1,8 +0,0 @@ -sdl2 provides CMake targets: - - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(main - PRIVATE - $<TARGET_NAME_IF_EXISTS:SDL2::SDL2main> - $<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static> - ) diff --git a/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json deleted file mode 100644 index 1f460375..00000000 --- a/dependencies/vcpkg_overlay_ports/sdl2/vcpkg.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "sdl2", - "version": "2.30.0", - "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", - "homepage": "https://www.libsdl.org/download-2.0.php", - "license": "Zlib", - "dependencies": [ - { - "name": "dbus", - "default-features": false, - "platform": "linux" - }, - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - { - "name": "ibus", - "platform": "linux" - }, - { - "name": "wayland", - "platform": "linux" - }, - { - "name": "x11", - "platform": "linux" - } - ], - "features": { - "alsa": { - "description": "Support for alsa audio", - "dependencies": [ - { - "name": "alsa", - "platform": "linux" - } - ] - }, - "ibus": { - "description": "Build with ibus IME support", - "supports": "linux" - }, - "samplerate": { - "description": "Use libsamplerate for audio rate conversion", - "dependencies": [ - "libsamplerate" - ] - }, - "vulkan": { - "description": "Vulkan functionality for SDL" - }, - "wayland": { - "description": "Build with Wayland support", - "supports": "linux" - }, - "x11": { - "description": "Build with X11 support", - "supports": "!windows" - } - } -} diff --git a/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch deleted file mode 100644 index 70654cf8..00000000 --- a/dependencies/vcpkg_overlay_ports/tiff/FindCMath.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake -index ad92218..dd42aba 100644 ---- a/cmake/FindCMath.cmake -+++ b/cmake/FindCMath.cmake -@@ -31,7 +31,7 @@ include(CheckSymbolExists) - include(CheckLibraryExists) - - check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) --find_library(CMath_LIBRARY NAMES m) -+find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) - - if(NOT CMath_HAVE_LIBC_POW) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake deleted file mode 100644 index 426d8af7..00000000 --- a/dependencies/vcpkg_overlay_ports/tiff/portfile.cmake +++ /dev/null @@ -1,86 +0,0 @@ -vcpkg_from_gitlab( - GITLAB_URL https://gitlab.com - OUT_SOURCE_PATH SOURCE_PATH - REPO libtiff/libtiff - REF "v${VERSION}" - SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa - HEAD_REF master - PATCHES - FindCMath.patch -) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - cxx cxx - jpeg jpeg - jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG - libdeflate libdeflate - libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate - lzma lzma - lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma - tools tiff-tools - webp webp - webp CMAKE_REQUIRE_FIND_PACKAGE_WebP - zip zlib - zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB - zstd zstd - zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${FEATURE_OPTIONS} - -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON - -Dtiff-docs=OFF - -Dtiff-contrib=OFF - -Dtiff-tests=OFF - -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. - -Djpeg12=OFF - -Dlerc=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON - -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON - -DZSTD_HAVE_DECOMPRESS_STREAM=ON - -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF - OPTIONS_DEBUG - -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. - MAYBE_UNUSED_VARIABLES - CMAKE_DISABLE_FIND_PACKAGE_GLUT - CMAKE_DISABLE_FIND_PACKAGE_OpenGL - ZSTD_HAVE_DECOMPRESS_STREAM -) - -vcpkg_cmake_install() - -# CMake config wasn't packaged in the past and is not yet usable now, -# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 -# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") - -set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") -if(EXISTS "${_file}") - vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") -endif() -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" -) - -configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) - -if ("tools" IN_LIST FEATURES) - vcpkg_copy_tools(TOOL_NAMES - tiffcp - tiffdump - tiffinfo - tiffset - tiffsplit - AUTO_CLEAN - ) -endif() - -vcpkg_copy_pdbs() -file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports/tiff/usage b/dependencies/vcpkg_overlay_ports/tiff/usage deleted file mode 100644 index d47265b1..00000000 --- a/dependencies/vcpkg_overlay_ports/tiff/usage +++ /dev/null @@ -1,9 +0,0 @@ -tiff is compatible with built-in CMake targets: - - find_package(TIFF REQUIRED) - target_link_libraries(main PRIVATE TIFF::TIFF) - -tiff provides pkg-config modules: - - # Tag Image File Format (TIFF) library. - libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in deleted file mode 100644 index 1d04ec7a..00000000 --- a/dependencies/vcpkg_overlay_ports/tiff/vcpkg-cmake-wrapper.cmake.in +++ /dev/null @@ -1,104 +0,0 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0012 NEW) -cmake_policy(SET CMP0057 NEW) -set(z_vcpkg_tiff_find_options "") -if("REQUIRED" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "REQUIRED") -endif() -if("QUIET" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "QUIET") -endif() - -_find_package(${ARGS}) - -if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") - include(SelectLibraryConfigurations) - set(z_vcpkg_tiff_link_libraries "") - set(z_vcpkg_tiff_libraries "") - if("@webp@") - find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") - list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) - endif() - if("@lzma@") - find_package(LibLZMA ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") - list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) - endif() - if("@jpeg@") - find_package(JPEG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") - list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) - endif() - if("@zstd@") - find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") - if(TARGET zstd::libzstd_shared) - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) - if(WIN32) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) - endif() - get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) - get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(ZSTD) - if(NOT TARGET ZSTD::ZSTD) - add_library(ZSTD::ZSTD INTERFACE IMPORTED) - set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) - endif() - list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) - list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) - unset(z_vcpkg_tiff_zstd) - unset(z_vcpkg_tiff_zstd_configs) - unset(z_vcpkg_config) - unset(z_vcpkg_tiff_zstd_target) - endif() - if("@libdeflate@") - find_package(libdeflate ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_property "IMPORTED_LOCATION_") - if(TARGET libdeflate::libdeflate_shared) - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) - if(WIN32) - set(z_vcpkg_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) - endif() - get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) - get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(Z_VCPKG_DEFLATE) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") - list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) - unset(z_vcpkg_config) - unset(z_vcpkg_libdeflate_configs) - unset(z_vcpkg_libdeflate_target) - unset(z_vcpkg_property) - unset(Z_VCPKG_DEFLATE_FOUND) - endif() - if("@zlib@") - find_package(ZLIB ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") - list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) - endif() - if(UNIX) - list(APPEND z_vcpkg_tiff_link_libraries m) - list(APPEND z_vcpkg_tiff_libraries m) - endif() - - if(TARGET TIFF::TIFF) - set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) - endif() - list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) - unset(z_vcpkg_tiff_link_libraries) - unset(z_vcpkg_tiff_libraries) -endif() -unset(z_vcpkg_tiff_find_options) -cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json deleted file mode 100644 index 9b36e1a8..00000000 --- a/dependencies/vcpkg_overlay_ports/tiff/vcpkg.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "tiff", - "version": "4.6.0", - "port-version": 2, - "description": "A library that supports the manipulation of TIFF image files", - "homepage": "https://libtiff.gitlab.io/libtiff/", - "license": "libtiff", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "jpeg", - "zip" - ], - "features": { - "cxx": { - "description": "Build C++ libtiffxx library" - }, - "jpeg": { - "description": "Support JPEG compression in TIFF image files", - "dependencies": [ - "libjpeg-turbo" - ] - }, - "libdeflate": { - "description": "Use libdeflate for faster ZIP support", - "dependencies": [ - "libdeflate", - { - "name": "tiff", - "default-features": false, - "features": [ - "zip" - ] - } - ] - }, - "tools": { - "description": "Build tools" - }, - "webp": { - "description": "Support WEBP compression in TIFF image files", - "dependencies": [ - "libwebp" - ] - }, - "zip": { - "description": "Support ZIP/deflate compression in TIFF image files", - "dependencies": [ - "zlib" - ] - }, - "zstd": { - "description": "Support ZSTD compression in TIFF image files", - "dependencies": [ - "zstd" - ] - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch deleted file mode 100644 index ac827f0c..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/cmake.dep.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt -index 8cde1ffe0..d4d09f223 100644 ---- a/tools/CMakeLists.txt -+++ b/tools/CMakeLists.txt -@@ -91,7 +91,9 @@ endif() - add_executable(dbus-launch ${dbus_launch_SOURCES}) - target_link_libraries(dbus-launch ${DBUS_LIBRARIES}) - if(DBUS_BUILD_X11) -- target_link_libraries(dbus-launch ${X11_LIBRARIES} ) -+ find_package(Threads REQUIRED) -+ target_link_libraries(dbus-launch ${X11_LIBRARIES} ${X11_xcb_LIB} ${X11_Xau_LIB} ${X11_Xdmcp_LIB} Threads::Threads) -+ target_include_directories(dbus-launch PRIVATE ${X11_INCLUDE_DIR}) - endif() - install(TARGETS dbus-launch ${INSTALL_TARGETS_DEFAULT_ARGS}) - diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch deleted file mode 100644 index 5cd2309e..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/getpeereid.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake -index b7f3702..e2336ba 100644 ---- a/cmake/ConfigureChecks.cmake -+++ b/cmake/ConfigureChecks.cmake -@@ -51,6 +51,7 @@ check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM) # - check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON) - check_symbol_exists(fstatfs "sys/vfs.h" HAVE_FSTATFS) - check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c -+check_symbol_exists(getpeereid "sys/types.h;unistd.h" HAVE_GETPEEREID) # dbus-sysdeps.c, - check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c - check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_GETPWNAM_R) # dbus-sysdeps-util-unix.c - check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM) -diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake -index 77fc19c..2f25643 100644 ---- a/cmake/config.h.cmake -+++ b/cmake/config.h.cmake -@@ -140,6 +140,9 @@ - /* Define to 1 if you have getgrouplist */ - #cmakedefine HAVE_GETGROUPLIST 1 - -+/* Define to 1 if you have getpeereid */ -+#cmakedefine HAVE_GETPEEREID 1 -+ - /* Define to 1 if you have getpeerucred */ - #cmakedefine HAVE_GETPEERUCRED 1 - diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch deleted file mode 100644 index 74193dc4..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/libsystemd.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index d3ec71b..932066a 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -141,6 +141,10 @@ if(DBUS_LINUX) - if(ENABLE_SYSTEMD AND SYSTEMD_FOUND) - set(DBUS_BUS_ENABLE_SYSTEMD ON) - set(HAVE_SYSTEMD ${SYSTEMD_FOUND}) -+ pkg_check_modules(SYSTEMD libsystemd IMPORTED_TARGET) -+ set(SYSTEMD_LIBRARIES PkgConfig::SYSTEMD CACHE INTERNAL "") -+ else() -+ set(SYSTEMD_LIBRARIES "" CACHE INTERNAL "") - endif() - option(ENABLE_USER_SESSION "enable user-session semantics for session bus under systemd" OFF) - set(DBUS_ENABLE_USER_SESSION ${ENABLE_USER_SESSION}) diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch b/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch deleted file mode 100644 index 63581487..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/pkgconfig.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index caef738..b878f42 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -724,11 +724,11 @@ add_custom_target(help-options - # - if(DBUS_ENABLE_PKGCONFIG) - set(PLATFORM_LIBS pthread ${LIBRT}) -- if(PKG_CONFIG_FOUND) -- # convert lists of link libraries into -lstdc++ -lm etc.. -- foreach(LIB ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${PLATFORM_LIBS}) -- set(LIBDBUS_LIBS "${LIBDBUS_LIBS} -l${LIB}") -- endforeach() -+ if(1) -+ set(LIBDBUS_LIBS "${CMAKE_THREAD_LIBS_INIT}") -+ if(LIBRT) -+ string(APPEND LIBDBUS_LIBS " -lrt") -+ endif() - set(original_prefix "${CMAKE_INSTALL_PREFIX}") - if(DBUS_RELOCATABLE) - set(pkgconfig_prefix "\${pcfiledir}/../..") diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake deleted file mode 100644 index 56c7e182..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/portfile.cmake +++ /dev/null @@ -1,88 +0,0 @@ -vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) - -vcpkg_from_gitlab( - GITLAB_URL https://gitlab.freedesktop.org/ - OUT_SOURCE_PATH SOURCE_PATH - REPO dbus/dbus - REF "dbus-${VERSION}" - SHA512 8e476b408514e6540c36beb84e8025827c22cda8958b6eb74d22b99c64765eb3cd5a6502aea546e3e5f0534039857b37edee89c659acef40e7cab0939947d4af - HEAD_REF master - PATCHES - cmake.dep.patch - pkgconfig.patch - getpeereid.patch # missing check from configure.ac - libsystemd.patch -) - -vcpkg_check_features(OUT_FEATURE_OPTIONS options - FEATURES - systemd ENABLE_SYSTEMD - x11 DBUS_BUILD_X11 - x11 CMAKE_REQUIRE_FIND_PACKAGE_X11 -) - -unset(ENV{DBUSDIR}) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - -DDBUS_BUILD_TESTS=OFF - -DDBUS_ENABLE_DOXYGEN_DOCS=OFF - -DDBUS_ENABLE_XML_DOCS=OFF - -DDBUS_INSTALL_SYSTEM_LIBS=OFF - #-DDBUS_SERVICE=ON - -DDBUS_WITH_GLIB=OFF - -DTHREADS_PREFER_PTHREAD_FLAG=ON - -DXSLTPROC_EXECUTABLE=FALSE - "-DCMAKE_INSTALL_SYSCONFDIR=${CURRENT_PACKAGES_DIR}/etc/${PORT}" - "-DWITH_SYSTEMD_SYSTEMUNITDIR=lib/systemd/system" - "-DWITH_SYSTEMD_USERUNITDIR=lib/systemd/user" - ${options} - OPTIONS_RELEASE - -DDBUS_DISABLE_ASSERT=OFF - -DDBUS_ENABLE_STATS=OFF - -DDBUS_ENABLE_VERBOSE_MODE=OFF - MAYBE_UNUSED_VARIABLES - DBUS_BUILD_X11 - DBUS_WITH_GLIB - ENABLE_SYSTEMD - THREADS_PREFER_PTHREAD_FLAG - WITH_SYSTEMD_SYSTEMUNITDIR - WITH_SYSTEMD_USERUNITDIR -) -vcpkg_cmake_install() -vcpkg_copy_pdbs() -vcpkg_cmake_config_fixup(PACKAGE_NAME "DBus1" CONFIG_PATH "lib/cmake/DBus1") -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/debug/var/" - "${CURRENT_PACKAGES_DIR}/etc" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/services" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/session.d" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/system-services" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.d" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.conf" - "${CURRENT_PACKAGES_DIR}/share/dbus-1/system.conf" - "${CURRENT_PACKAGES_DIR}/share/doc" - "${CURRENT_PACKAGES_DIR}/var" -) - -vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<include ignore_missing=\"yes\">${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session.conf</include>" "") -vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<includedir>${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session.d</includedir>" "") -vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/dbus-1/session.conf" "<include ignore_missing=\"yes\">${CURRENT_PACKAGES_DIR}/etc/dbus/dbus-1/session-local.conf</include>" "") - -set(TOOLS daemon launch monitor run-session send test-tool update-activation-environment) -if(VCPKG_TARGET_IS_WINDOWS) - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") - file(RENAME "${CURRENT_PACKAGES_DIR}/bin/dbus-env.bat" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/dbus-env.bat") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/${PORT}/dbus-env.bat" "${CURRENT_PACKAGES_DIR}" "%~dp0/../..") -else() - list(APPEND TOOLS cleanup-sockets uuidgen) -endif() -list(TRANSFORM TOOLS PREPEND "dbus-" ) -vcpkg_copy_tools(TOOL_NAMES ${TOOLS} AUTO_CLEAN) - -file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json deleted file mode 100644 index 853dff05..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/dbus/vcpkg.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "dbus", - "version": "1.15.8", - "port-version": 2, - "description": "D-Bus specification and reference implementation, including libdbus and dbus-daemon", - "homepage": "https://gitlab.freedesktop.org/dbus/dbus", - "license": "AFL-2.1 OR GPL-2.0-or-later", - "supports": "!uwp & !staticcrt", - "dependencies": [ - "expat", - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - ], - "features": { - "x11": { - "description": "Build with X11 autolaunch support", - "dependencies": [ - "libx11" - ] - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch deleted file mode 100644 index 5b2c77b9..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/alsa-dep-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in -index cc8bcf26d..ead829767 100644 ---- a/SDL2Config.cmake.in -+++ b/SDL2Config.cmake.in -@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") - - set(SDL_ALSA @SDL_ALSA@) - set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) --if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) -+if(SDL_ALSA) - sdlFindALSA() - endif() - unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch deleted file mode 100644 index a8637d8c..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/deps.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake -index 65a98efbe..2f99f28f1 100644 ---- a/cmake/sdlchecks.cmake -+++ b/cmake/sdlchecks.cmake -@@ -352,7 +352,7 @@ endmacro() - # - HAVE_SDL_LOADSO opt - macro(CheckLibSampleRate) - if(SDL_LIBSAMPLERATE) -- find_package(SampleRate QUIET) -+ find_package(SampleRate CONFIG REQUIRED) - if(SampleRate_FOUND AND TARGET SampleRate::samplerate) - set(HAVE_LIBSAMPLERATE TRUE) - set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake deleted file mode 100644 index 22685e6a..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/portfile.cmake +++ /dev/null @@ -1,137 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libsdl-org/SDL - REF "release-${VERSION}" - SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c - HEAD_REF main - PATCHES - deps.patch - alsa-dep-fix.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - alsa SDL_ALSA - alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA - ibus SDL_IBUS - samplerate SDL_LIBSAMPLERATE - vulkan SDL_VULKAN - wayland SDL_WAYLAND - x11 SDL_X11 - INVERTED_FEATURES - alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA -) - -if ("x11" IN_LIST FEATURES) - message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") -endif() -if ("wayland" IN_LIST FEATURES) - message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") -endif() -if ("ibus" IN_LIST FEATURES) - message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} - OPTIONS ${FEATURE_OPTIONS} - -DSDL_STATIC=${SDL_STATIC} - -DSDL_SHARED=${SDL_SHARED} - -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} - -DSDL_LIBC=ON - -DSDL_TEST=OFF - -DSDL_INSTALL_CMAKEDIR="cmake" - -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON - -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON - -DSDL_LIBSAMPLERATE_SHARED=OFF - MAYBE_UNUSED_VARIABLES - SDL_FORCE_STATIC_VCRT - PKG_CONFIG_USE_CMAKE_PREFIX_PATH -) - -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH cmake) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/share/licenses" - "${CURRENT_PACKAGES_DIR}/share/aclocal" -) - -file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT BINS) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") - endif() - - file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") - foreach(SHARE_FILE ${SHARE_FILES}) - vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") - endforeach() -endif() - -vcpkg_copy_pdbs() - -set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") -set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) -string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") -string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") - endif() -endif() - -if(VCPKG_TARGET_IS_UWP) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "d") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() -endif() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/usage b/dependencies/vcpkg_overlay_ports_linux/sdl2/usage deleted file mode 100644 index 1cddcd46..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/usage +++ /dev/null @@ -1,8 +0,0 @@ -sdl2 provides CMake targets: - - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(main - PRIVATE - $<TARGET_NAME_IF_EXISTS:SDL2::SDL2main> - $<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static> - ) diff --git a/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json deleted file mode 100644 index 1f460375..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/sdl2/vcpkg.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "sdl2", - "version": "2.30.0", - "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", - "homepage": "https://www.libsdl.org/download-2.0.php", - "license": "Zlib", - "dependencies": [ - { - "name": "dbus", - "default-features": false, - "platform": "linux" - }, - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - { - "name": "ibus", - "platform": "linux" - }, - { - "name": "wayland", - "platform": "linux" - }, - { - "name": "x11", - "platform": "linux" - } - ], - "features": { - "alsa": { - "description": "Support for alsa audio", - "dependencies": [ - { - "name": "alsa", - "platform": "linux" - } - ] - }, - "ibus": { - "description": "Build with ibus IME support", - "supports": "linux" - }, - "samplerate": { - "description": "Use libsamplerate for audio rate conversion", - "dependencies": [ - "libsamplerate" - ] - }, - "vulkan": { - "description": "Vulkan functionality for SDL" - }, - "wayland": { - "description": "Build with Wayland support", - "supports": "linux" - }, - "x11": { - "description": "Build with X11 support", - "supports": "!windows" - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch deleted file mode 100644 index 70654cf8..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/tiff/FindCMath.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake -index ad92218..dd42aba 100644 ---- a/cmake/FindCMath.cmake -+++ b/cmake/FindCMath.cmake -@@ -31,7 +31,7 @@ include(CheckSymbolExists) - include(CheckLibraryExists) - - check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) --find_library(CMath_LIBRARY NAMES m) -+find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) - - if(NOT CMath_HAVE_LIBC_POW) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake deleted file mode 100644 index 426d8af7..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/tiff/portfile.cmake +++ /dev/null @@ -1,86 +0,0 @@ -vcpkg_from_gitlab( - GITLAB_URL https://gitlab.com - OUT_SOURCE_PATH SOURCE_PATH - REPO libtiff/libtiff - REF "v${VERSION}" - SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa - HEAD_REF master - PATCHES - FindCMath.patch -) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - cxx cxx - jpeg jpeg - jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG - libdeflate libdeflate - libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate - lzma lzma - lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma - tools tiff-tools - webp webp - webp CMAKE_REQUIRE_FIND_PACKAGE_WebP - zip zlib - zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB - zstd zstd - zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${FEATURE_OPTIONS} - -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON - -Dtiff-docs=OFF - -Dtiff-contrib=OFF - -Dtiff-tests=OFF - -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. - -Djpeg12=OFF - -Dlerc=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON - -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON - -DZSTD_HAVE_DECOMPRESS_STREAM=ON - -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF - OPTIONS_DEBUG - -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. - MAYBE_UNUSED_VARIABLES - CMAKE_DISABLE_FIND_PACKAGE_GLUT - CMAKE_DISABLE_FIND_PACKAGE_OpenGL - ZSTD_HAVE_DECOMPRESS_STREAM -) - -vcpkg_cmake_install() - -# CMake config wasn't packaged in the past and is not yet usable now, -# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 -# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") - -set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") -if(EXISTS "${_file}") - vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") -endif() -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" -) - -configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) - -if ("tools" IN_LIST FEATURES) - vcpkg_copy_tools(TOOL_NAMES - tiffcp - tiffdump - tiffinfo - tiffset - tiffsplit - AUTO_CLEAN - ) -endif() - -vcpkg_copy_pdbs() -file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/usage b/dependencies/vcpkg_overlay_ports_linux/tiff/usage deleted file mode 100644 index d47265b1..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/tiff/usage +++ /dev/null @@ -1,9 +0,0 @@ -tiff is compatible with built-in CMake targets: - - find_package(TIFF REQUIRED) - target_link_libraries(main PRIVATE TIFF::TIFF) - -tiff provides pkg-config modules: - - # Tag Image File Format (TIFF) library. - libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in deleted file mode 100644 index 1d04ec7a..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg-cmake-wrapper.cmake.in +++ /dev/null @@ -1,104 +0,0 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0012 NEW) -cmake_policy(SET CMP0057 NEW) -set(z_vcpkg_tiff_find_options "") -if("REQUIRED" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "REQUIRED") -endif() -if("QUIET" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "QUIET") -endif() - -_find_package(${ARGS}) - -if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") - include(SelectLibraryConfigurations) - set(z_vcpkg_tiff_link_libraries "") - set(z_vcpkg_tiff_libraries "") - if("@webp@") - find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") - list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) - endif() - if("@lzma@") - find_package(LibLZMA ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") - list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) - endif() - if("@jpeg@") - find_package(JPEG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") - list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) - endif() - if("@zstd@") - find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") - if(TARGET zstd::libzstd_shared) - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) - if(WIN32) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) - endif() - get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) - get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(ZSTD) - if(NOT TARGET ZSTD::ZSTD) - add_library(ZSTD::ZSTD INTERFACE IMPORTED) - set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) - endif() - list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) - list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) - unset(z_vcpkg_tiff_zstd) - unset(z_vcpkg_tiff_zstd_configs) - unset(z_vcpkg_config) - unset(z_vcpkg_tiff_zstd_target) - endif() - if("@libdeflate@") - find_package(libdeflate ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_property "IMPORTED_LOCATION_") - if(TARGET libdeflate::libdeflate_shared) - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) - if(WIN32) - set(z_vcpkg_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) - endif() - get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) - get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(Z_VCPKG_DEFLATE) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") - list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) - unset(z_vcpkg_config) - unset(z_vcpkg_libdeflate_configs) - unset(z_vcpkg_libdeflate_target) - unset(z_vcpkg_property) - unset(Z_VCPKG_DEFLATE_FOUND) - endif() - if("@zlib@") - find_package(ZLIB ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") - list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) - endif() - if(UNIX) - list(APPEND z_vcpkg_tiff_link_libraries m) - list(APPEND z_vcpkg_tiff_libraries m) - endif() - - if(TARGET TIFF::TIFF) - set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) - endif() - list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) - unset(z_vcpkg_tiff_link_libraries) - unset(z_vcpkg_tiff_libraries) -endif() -unset(z_vcpkg_tiff_find_options) -cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json deleted file mode 100644 index 9b36e1a8..00000000 --- a/dependencies/vcpkg_overlay_ports_linux/tiff/vcpkg.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "tiff", - "version": "4.6.0", - "port-version": 2, - "description": "A library that supports the manipulation of TIFF image files", - "homepage": "https://libtiff.gitlab.io/libtiff/", - "license": "libtiff", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "jpeg", - "zip" - ], - "features": { - "cxx": { - "description": "Build C++ libtiffxx library" - }, - "jpeg": { - "description": "Support JPEG compression in TIFF image files", - "dependencies": [ - "libjpeg-turbo" - ] - }, - "libdeflate": { - "description": "Use libdeflate for faster ZIP support", - "dependencies": [ - "libdeflate", - { - "name": "tiff", - "default-features": false, - "features": [ - "zip" - ] - } - ] - }, - "tools": { - "description": "Build tools" - }, - "webp": { - "description": "Support WEBP compression in TIFF image files", - "dependencies": [ - "libwebp" - ] - }, - "zip": { - "description": "Support ZIP/deflate compression in TIFF image files", - "dependencies": [ - "zlib" - ] - }, - "zstd": { - "description": "Support ZSTD compression in TIFF image files", - "dependencies": [ - "zstd" - ] - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch b/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch deleted file mode 100644 index 5b2c77b9..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/sdl2/alsa-dep-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/SDL2Config.cmake.in b/SDL2Config.cmake.in -index cc8bcf26d..ead829767 100644 ---- a/SDL2Config.cmake.in -+++ b/SDL2Config.cmake.in -@@ -35,7 +35,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake") - - set(SDL_ALSA @SDL_ALSA@) - set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@) --if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static) -+if(SDL_ALSA) - sdlFindALSA() - endif() - unset(SDL_ALSA) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch b/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch deleted file mode 100644 index a8637d8c..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/sdl2/deps.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake -index 65a98efbe..2f99f28f1 100644 ---- a/cmake/sdlchecks.cmake -+++ b/cmake/sdlchecks.cmake -@@ -352,7 +352,7 @@ endmacro() - # - HAVE_SDL_LOADSO opt - macro(CheckLibSampleRate) - if(SDL_LIBSAMPLERATE) -- find_package(SampleRate QUIET) -+ find_package(SampleRate CONFIG REQUIRED) - if(SampleRate_FOUND AND TARGET SampleRate::samplerate) - set(HAVE_LIBSAMPLERATE TRUE) - set(HAVE_LIBSAMPLERATE_H TRUE) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake b/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake deleted file mode 100644 index 22685e6a..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/sdl2/portfile.cmake +++ /dev/null @@ -1,137 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO libsdl-org/SDL - REF "release-${VERSION}" - SHA512 c7635a83a52f3970a372b804a8631f0a7e6b8d89aed1117bcc54a2040ad0928122175004cf2b42cf84a4fd0f86236f779229eaa63dfa6ca9c89517f999c5ff1c - HEAD_REF main - PATCHES - deps.patch - alsa-dep-fix.patch -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" SDL_STATIC) -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SDL_SHARED) -string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" FORCE_STATIC_VCRT) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - alsa SDL_ALSA - alsa CMAKE_REQUIRE_FIND_PACKAGE_ALSA - ibus SDL_IBUS - samplerate SDL_LIBSAMPLERATE - vulkan SDL_VULKAN - wayland SDL_WAYLAND - x11 SDL_X11 - INVERTED_FEATURES - alsa CMAKE_DISABLE_FIND_PACKAGE_ALSA -) - -if ("x11" IN_LIST FEATURES) - message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") -endif() -if ("wayland" IN_LIST FEATURES) - message(WARNING "You will need to install Wayland dependencies to use feature wayland:\nsudo apt install libwayland-dev libxkbcommon-dev libegl1-mesa-dev\n") -endif() -if ("ibus" IN_LIST FEATURES) - message(WARNING "You will need to install ibus dependencies to use feature ibus:\nsudo apt install libibus-1.0-dev\n") -endif() - -if(VCPKG_TARGET_IS_UWP) - set(configure_opts WINDOWS_USE_MSBUILD) -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - ${configure_opts} - OPTIONS ${FEATURE_OPTIONS} - -DSDL_STATIC=${SDL_STATIC} - -DSDL_SHARED=${SDL_SHARED} - -DSDL_FORCE_STATIC_VCRT=${FORCE_STATIC_VCRT} - -DSDL_LIBC=ON - -DSDL_TEST=OFF - -DSDL_INSTALL_CMAKEDIR="cmake" - -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON - -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON - -DSDL_LIBSAMPLERATE_SHARED=OFF - MAYBE_UNUSED_VARIABLES - SDL_FORCE_STATIC_VCRT - PKG_CONFIG_USE_CMAKE_PREFIX_PATH -) - -vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH cmake) - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" - "${CURRENT_PACKAGES_DIR}/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/debug/bin/sdl2-config" - "${CURRENT_PACKAGES_DIR}/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/debug/SDL2.framework" - "${CURRENT_PACKAGES_DIR}/share/licenses" - "${CURRENT_PACKAGES_DIR}/share/aclocal" -) - -file(GLOB BINS "${CURRENT_PACKAGES_DIR}/debug/bin/*" "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT BINS) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDL2main.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDL2main.lib") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDL2maind.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDL2maind.lib") - endif() - - file(GLOB SHARE_FILES "${CURRENT_PACKAGES_DIR}/share/sdl2/*.cmake") - foreach(SHARE_FILE ${SHARE_FILES}) - vcpkg_replace_string("${SHARE_FILE}" "lib/SDL2main" "lib/manual-link/SDL2main") - endforeach() -endif() - -vcpkg_copy_pdbs() - -set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") -set(DYLIB_CURRENT_VERSION_REGEX "set\\(DYLIB_CURRENT_VERSION (.+)\\)") -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_COMPATIBILITY_VERSION REGEX ${DYLIB_COMPATIBILITY_VERSION_REGEX}) -file(STRINGS "${SOURCE_PATH}/CMakeLists.txt" DYLIB_CURRENT_VERSION REGEX ${DYLIB_CURRENT_VERSION_REGEX}) -string(REGEX REPLACE ${DYLIB_COMPATIBILITY_VERSION_REGEX} "\\1" DYLIB_COMPATIBILITY_VERSION "${DYLIB_COMPATIBILITY_VERSION}") -string(REGEX REPLACE ${DYLIB_CURRENT_VERSION_REGEX} "\\1" DYLIB_CURRENT_VERSION "${DYLIB_CURRENT_VERSION}") - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2main" "-lSDL2maind") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2 " "-lSDL2d ") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-static " "-lSDL2-staticd ") -endif() - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-lSDL2-static " " ") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-lSDL2-staticd " " ") - endif() -endif() - -if(VCPKG_TARGET_IS_UWP) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "$<$<CONFIG:Debug>:d>.lib" "d") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/sdl2.pc" "-l-nodefaultlib:" "-nodefaultlib:") - endif() -endif() - -vcpkg_fixup_pkgconfig() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/usage b/dependencies/vcpkg_overlay_ports_mac/sdl2/usage deleted file mode 100644 index 1cddcd46..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/sdl2/usage +++ /dev/null @@ -1,8 +0,0 @@ -sdl2 provides CMake targets: - - find_package(SDL2 CONFIG REQUIRED) - target_link_libraries(main - PRIVATE - $<TARGET_NAME_IF_EXISTS:SDL2::SDL2main> - $<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static> - ) diff --git a/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json b/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json deleted file mode 100644 index 1f460375..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/sdl2/vcpkg.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "sdl2", - "version": "2.30.0", - "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", - "homepage": "https://www.libsdl.org/download-2.0.php", - "license": "Zlib", - "dependencies": [ - { - "name": "dbus", - "default-features": false, - "platform": "linux" - }, - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - { - "name": "ibus", - "platform": "linux" - }, - { - "name": "wayland", - "platform": "linux" - }, - { - "name": "x11", - "platform": "linux" - } - ], - "features": { - "alsa": { - "description": "Support for alsa audio", - "dependencies": [ - { - "name": "alsa", - "platform": "linux" - } - ] - }, - "ibus": { - "description": "Build with ibus IME support", - "supports": "linux" - }, - "samplerate": { - "description": "Use libsamplerate for audio rate conversion", - "dependencies": [ - "libsamplerate" - ] - }, - "vulkan": { - "description": "Vulkan functionality for SDL" - }, - "wayland": { - "description": "Build with Wayland support", - "supports": "linux" - }, - "x11": { - "description": "Build with X11 support", - "supports": "!windows" - } - } -} diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch b/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch deleted file mode 100644 index 70654cf8..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/tiff/FindCMath.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/FindCMath.cmake b/cmake/FindCMath.cmake -index ad92218..dd42aba 100644 ---- a/cmake/FindCMath.cmake -+++ b/cmake/FindCMath.cmake -@@ -31,7 +31,7 @@ include(CheckSymbolExists) - include(CheckLibraryExists) - - check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) --find_library(CMath_LIBRARY NAMES m) -+find_library(CMath_LIBRARY NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) - - if(NOT CMath_HAVE_LIBC_POW) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake b/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake deleted file mode 100644 index 426d8af7..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/tiff/portfile.cmake +++ /dev/null @@ -1,86 +0,0 @@ -vcpkg_from_gitlab( - GITLAB_URL https://gitlab.com - OUT_SOURCE_PATH SOURCE_PATH - REPO libtiff/libtiff - REF "v${VERSION}" - SHA512 ef2f1d424219d9e245069b7d23e78f5e817cf6ee516d46694915ab6c8909522166f84997513d20a702f4e52c3f18467813935b328fafa34bea5156dee00f66fa - HEAD_REF master - PATCHES - FindCMath.patch -) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - cxx cxx - jpeg jpeg - jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG - libdeflate libdeflate - libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate - lzma lzma - lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma - tools tiff-tools - webp webp - webp CMAKE_REQUIRE_FIND_PACKAGE_WebP - zip zlib - zip CMAKE_REQUIRE_FIND_PACKAGE_ZLIB - zstd zstd - zstd CMAKE_REQUIRE_FIND_PACKAGE_ZSTD -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${FEATURE_OPTIONS} - -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON - -Dtiff-docs=OFF - -Dtiff-contrib=OFF - -Dtiff-tests=OFF - -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. - -Djpeg12=OFF - -Dlerc=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON - -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON - -DZSTD_HAVE_DECOMPRESS_STREAM=ON - -DHAVE_JPEGTURBO_DUAL_MODE_8_12=OFF - OPTIONS_DEBUG - -DCMAKE_DEBUG_POSTFIX=d # tiff sets "d" for MSVC only. - MAYBE_UNUSED_VARIABLES - CMAKE_DISABLE_FIND_PACKAGE_GLUT - CMAKE_DISABLE_FIND_PACKAGE_OpenGL - ZSTD_HAVE_DECOMPRESS_STREAM -) - -vcpkg_cmake_install() - -# CMake config wasn't packaged in the past and is not yet usable now, -# cf. https://gitlab.com/libtiff/libtiff/-/merge_requests/496 -# vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/tiff") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake" "${CURRENT_PACKAGES_DIR}/debug/lib/cmake") - -set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libtiff-4.pc") -if(EXISTS "${_file}") - vcpkg_replace_string("${_file}" "-ltiff" "-ltiffd") -endif() -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" -) - -configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) - -if ("tools" IN_LIST FEATURES) - vcpkg_copy_tools(TOOL_NAMES - tiffcp - tiffdump - tiffinfo - tiffset - tiffsplit - AUTO_CLEAN - ) -endif() - -vcpkg_copy_pdbs() -file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/usage b/dependencies/vcpkg_overlay_ports_mac/tiff/usage deleted file mode 100644 index d47265b1..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/tiff/usage +++ /dev/null @@ -1,9 +0,0 @@ -tiff is compatible with built-in CMake targets: - - find_package(TIFF REQUIRED) - target_link_libraries(main PRIVATE TIFF::TIFF) - -tiff provides pkg-config modules: - - # Tag Image File Format (TIFF) library. - libtiff-4 diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in deleted file mode 100644 index 1d04ec7a..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg-cmake-wrapper.cmake.in +++ /dev/null @@ -1,104 +0,0 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0012 NEW) -cmake_policy(SET CMP0057 NEW) -set(z_vcpkg_tiff_find_options "") -if("REQUIRED" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "REQUIRED") -endif() -if("QUIET" IN_LIST ARGS) - list(APPEND z_vcpkg_tiff_find_options "QUIET") -endif() - -_find_package(${ARGS}) - -if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") - include(SelectLibraryConfigurations) - set(z_vcpkg_tiff_link_libraries "") - set(z_vcpkg_tiff_libraries "") - if("@webp@") - find_package(WebP CONFIG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:WebP::WebP>") - list(APPEND z_vcpkg_tiff_libraries ${WebP_LIBRARIES}) - endif() - if("@lzma@") - find_package(LibLZMA ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:LibLZMA::LibLZMA>") - list(APPEND z_vcpkg_tiff_libraries ${LIBLZMA_LIBRARIES}) - endif() - if("@jpeg@") - find_package(JPEG ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:JPEG::JPEG>") - list(APPEND z_vcpkg_tiff_libraries ${JPEG_LIBRARIES}) - endif() - if("@zstd@") - find_package(zstd CONFIG ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_LOCATION_") - if(TARGET zstd::libzstd_shared) - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_shared>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_shared) - if(WIN32) - set(z_vcpkg_tiff_zstd_target_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_tiff_zstd "\$<LINK_ONLY:zstd::libzstd_static>") - set(z_vcpkg_tiff_zstd_target zstd::libzstd_static) - endif() - get_target_property(z_vcpkg_tiff_zstd_configs "${z_vcpkg_tiff_zstd_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_tiff_zstd_configs) - get_target_property(ZSTD_LIBRARY_${z_vcpkg_config} "${z_vcpkg_tiff_zstd_target}" "${z_vcpkg_tiff_zstd_target_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(ZSTD) - if(NOT TARGET ZSTD::ZSTD) - add_library(ZSTD::ZSTD INTERFACE IMPORTED) - set_property(TARGET ZSTD::ZSTD APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_zstd}) - endif() - list(APPEND z_vcpkg_tiff_link_libraries ${z_vcpkg_tiff_zstd}) - list(APPEND z_vcpkg_tiff_libraries ${ZSTD_LIBRARIES}) - unset(z_vcpkg_tiff_zstd) - unset(z_vcpkg_tiff_zstd_configs) - unset(z_vcpkg_config) - unset(z_vcpkg_tiff_zstd_target) - endif() - if("@libdeflate@") - find_package(libdeflate ${z_vcpkg_tiff_find_options}) - set(z_vcpkg_property "IMPORTED_LOCATION_") - if(TARGET libdeflate::libdeflate_shared) - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_shared) - if(WIN32) - set(z_vcpkg_property "IMPORTED_IMPLIB_") - endif() - else() - set(z_vcpkg_libdeflate_target libdeflate::libdeflate_static) - endif() - get_target_property(z_vcpkg_libdeflate_configs "${z_vcpkg_libdeflate_target}" IMPORTED_CONFIGURATIONS) - foreach(z_vcpkg_config IN LISTS z_vcpkg_libdeflate_configs) - get_target_property(Z_VCPKG_DEFLATE_LIBRARY_${z_vcpkg_config} "${z_vcpkg_libdeflate_target}" "${z_vcpkg_property}${z_vcpkg_config}") - endforeach() - select_library_configurations(Z_VCPKG_DEFLATE) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:${z_vcpkg_libdeflate_target}>") - list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_DEFLATE_LIBRARIES}) - unset(z_vcpkg_config) - unset(z_vcpkg_libdeflate_configs) - unset(z_vcpkg_libdeflate_target) - unset(z_vcpkg_property) - unset(Z_VCPKG_DEFLATE_FOUND) - endif() - if("@zlib@") - find_package(ZLIB ${z_vcpkg_tiff_find_options}) - list(APPEND z_vcpkg_tiff_link_libraries "\$<LINK_ONLY:ZLIB::ZLIB>") - list(APPEND z_vcpkg_tiff_libraries ${ZLIB_LIBRARIES}) - endif() - if(UNIX) - list(APPEND z_vcpkg_tiff_link_libraries m) - list(APPEND z_vcpkg_tiff_libraries m) - endif() - - if(TARGET TIFF::TIFF) - set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_tiff_link_libraries}) - endif() - list(APPEND TIFF_LIBRARIES ${z_vcpkg_tiff_libraries}) - unset(z_vcpkg_tiff_link_libraries) - unset(z_vcpkg_tiff_libraries) -endif() -unset(z_vcpkg_tiff_find_options) -cmake_policy(POP) diff --git a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json b/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json deleted file mode 100644 index 9b36e1a8..00000000 --- a/dependencies/vcpkg_overlay_ports_mac/tiff/vcpkg.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "tiff", - "version": "4.6.0", - "port-version": 2, - "description": "A library that supports the manipulation of TIFF image files", - "homepage": "https://libtiff.gitlab.io/libtiff/", - "license": "libtiff", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - "jpeg", - "zip" - ], - "features": { - "cxx": { - "description": "Build C++ libtiffxx library" - }, - "jpeg": { - "description": "Support JPEG compression in TIFF image files", - "dependencies": [ - "libjpeg-turbo" - ] - }, - "libdeflate": { - "description": "Use libdeflate for faster ZIP support", - "dependencies": [ - "libdeflate", - { - "name": "tiff", - "default-features": false, - "features": [ - "zip" - ] - } - ] - }, - "tools": { - "description": "Build tools" - }, - "webp": { - "description": "Support WEBP compression in TIFF image files", - "dependencies": [ - "libwebp" - ] - }, - "zip": { - "description": "Support ZIP/deflate compression in TIFF image files", - "dependencies": [ - "zlib" - ] - }, - "zstd": { - "description": "Support ZSTD compression in TIFF image files", - "dependencies": [ - "zstd" - ] - } - } -} diff --git a/vcpkg.json b/vcpkg.json index b27a7095..0a46e32e 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "name": "cemu", "version-string": "1.0", - "builtin-baseline": "cbf4a6641528cee6f172328984576f51698de726", + "builtin-baseline": "a4275b7eee79fb24ec2e135481ef5fce8b41c339", "dependencies": [ "pugixml", "zlib", @@ -44,6 +44,22 @@ "default-features": false, "features": [ "openssl" ] }, + { + "name": "dbus", + "default-features": false, + "platform": "linux" + }, + { + "name": "tiff", + "default-features": false, + "features": ["jpeg", "zip"] + }, "libusb" + ], + "overrides": [ + { + "name": "sdl2", + "version": "2.30.3" + } ] } From 1672f969bbc4a683e4a852aa2e145c1e6f9f68e6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 9 Jun 2024 17:38:59 +0200 Subject: [PATCH 203/314] Latte: Add support for vertex format used by Rabbids Land --- .../LatteDecompilerEmitGLSLAttrDecoder.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLAttrDecoder.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLAttrDecoder.cpp index ea2b9491..76d76322 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLAttrDecoder.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSLAttrDecoder.cpp @@ -241,6 +241,16 @@ void LatteDecompiler_emitAttributeDecodeGLSL(LatteDecompilerShader* shaderContex src->add("attrDecoder.z = floatBitsToUint(max(float(int(attrDecoder.z))/32767.0,-1.0));" _CRLF); src->add("attrDecoder.w = floatBitsToUint(max(float(int(attrDecoder.w))/32767.0,-1.0));" _CRLF); } + else if( attrib->format == FMT_16_16_16_16 && attrib->nfa == 2 && attrib->isSigned == 1 ) + { + // seen in Rabbids Land + _readLittleEndianAttributeU16x4(shaderContext, src, attributeInputIndex); + src->add("if( (attrDecoder.x&0x8000) != 0 ) attrDecoder.x |= 0xFFFF0000;" _CRLF); + src->add("if( (attrDecoder.y&0x8000) != 0 ) attrDecoder.y |= 0xFFFF0000;" _CRLF); + src->add("if( (attrDecoder.z&0x8000) != 0 ) attrDecoder.z |= 0xFFFF0000;" _CRLF); + src->add("if( (attrDecoder.w&0x8000) != 0 ) attrDecoder.w |= 0xFFFF0000;" _CRLF); + src->add("attrDecoder.xyzw = floatBitsToUint(vec4(ivec4(attrDecoder)));" _CRLF); + } else if (attrib->format == FMT_16_16_16_16_FLOAT && attrib->nfa == 2) { // seen in Giana Sisters: Twisted Dreams @@ -496,3 +506,5 @@ void LatteDecompiler_emitAttributeDecodeGLSL(LatteDecompilerShader* shaderContex cemu_assert_debug(false); } } + + From d4c2c3d2098616b3596b743f33fcc37629282ec0 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:50:06 +0200 Subject: [PATCH 204/314] nsyskbd: Stub KBDGetKey Fixes MSX VC games freezing on boot --- src/Cafe/OS/libs/nsyskbd/nsyskbd.cpp | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Cafe/OS/libs/nsyskbd/nsyskbd.cpp b/src/Cafe/OS/libs/nsyskbd/nsyskbd.cpp index 72cb9bd0..f1571cc0 100644 --- a/src/Cafe/OS/libs/nsyskbd/nsyskbd.cpp +++ b/src/Cafe/OS/libs/nsyskbd/nsyskbd.cpp @@ -3,6 +3,11 @@ namespace nsyskbd { + bool IsValidChannel(uint32 channel) + { + return channel >= 0 && channel < 4; + } + uint32 KBDGetChannelStatus(uint32 channel, uint32be* status) { static bool loggedError = false; @@ -16,8 +21,38 @@ namespace nsyskbd return 0; } +#pragma pack(push, 1) + struct KeyState + { + uint8be channel; + uint8be ukn1; + uint8be _padding[2]; + uint32be ukn4; + uint32be ukn8; + uint16be uknC; + }; +#pragma pack(pop) + static_assert(sizeof(KeyState) == 0xE); // actual size might be padded to 0x10? + + uint32 KBDGetKey(uint32 channel, KeyState* keyState) + { + // used by MSX VC + if(!IsValidChannel(channel) || !keyState) + { + cemuLog_log(LogType::APIErrors, "KBDGetKey(): Invalid parameter"); + return 0; + } + keyState->channel = channel; + keyState->ukn1 = 0; + keyState->ukn4 = 0; + keyState->ukn8 = 0; + keyState->uknC = 0; + return 0; + } + void nsyskbd_load() { cafeExportRegister("nsyskbd", KBDGetChannelStatus, LogType::Placeholder); + cafeExportRegister("nsyskbd", KBDGetKey, LogType::Placeholder); } } From f3d20832c191f90fe4ad6f9b64a3ff21eb477b02 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 25 Jun 2024 19:28:21 +0200 Subject: [PATCH 205/314] Avoid an unhandled exception when mlc path is invalid --- src/gui/CemuApp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 505a09c6..86d81e43 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -266,10 +266,10 @@ std::vector<const wxLanguageInfo*> CemuApp::GetAvailableTranslationLanguages(wxT void CemuApp::CreateDefaultFiles(bool first_start) { + std::error_code ec; fs::path mlc = ActiveSettings::GetMlcPath(); - // check for mlc01 folder missing if custom path has been set - if (!fs::exists(mlc) && !first_start) + if (!fs::exists(mlc, ec) && !first_start) { const wxString message = formatWxString(_("Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?"), _pathToUtf8(mlc)); From 93b58ae6f7315bf17126d49314e0132eeb356ef9 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Thu, 27 Jun 2024 23:55:20 +0100 Subject: [PATCH 206/314] nsyshid: Add infrastructure and support for emulating Skylander Portal (#971) --- src/Cafe/CMakeLists.txt | 4 + .../OS/libs/nsyshid/AttachDefaultBackends.cpp | 9 + src/Cafe/OS/libs/nsyshid/Backend.h | 57 +- src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp | 29 + src/Cafe/OS/libs/nsyshid/BackendEmulated.h | 16 + src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 36 +- src/Cafe/OS/libs/nsyshid/BackendLibusb.h | 6 +- .../OS/libs/nsyshid/BackendWindowsHID.cpp | 34 +- src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h | 6 +- src/Cafe/OS/libs/nsyshid/Skylander.cpp | 939 ++++++++++++++++++ src/Cafe/OS/libs/nsyshid/Skylander.h | 98 ++ src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 41 +- src/config/CemuConfig.cpp | 8 + src/config/CemuConfig.h | 6 + src/gui/CMakeLists.txt | 2 + .../EmulatedUSBDeviceFrame.cpp | 354 +++++++ .../EmulatedUSBDeviceFrame.h | 42 + src/gui/MainWindow.cpp | 27 + src/gui/MainWindow.h | 2 + 19 files changed, 1658 insertions(+), 58 deletions(-) create mode 100644 src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/BackendEmulated.h create mode 100644 src/Cafe/OS/libs/nsyshid/Skylander.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/Skylander.h create mode 100644 src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp create mode 100644 src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index b5090dcf..1583bdd7 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -457,10 +457,14 @@ add_library(CemuCafe OS/libs/nsyshid/AttachDefaultBackends.cpp OS/libs/nsyshid/Whitelist.cpp OS/libs/nsyshid/Whitelist.h + OS/libs/nsyshid/BackendEmulated.cpp + OS/libs/nsyshid/BackendEmulated.h OS/libs/nsyshid/BackendLibusb.cpp OS/libs/nsyshid/BackendLibusb.h OS/libs/nsyshid/BackendWindowsHID.cpp OS/libs/nsyshid/BackendWindowsHID.h + OS/libs/nsyshid/Skylander.cpp + OS/libs/nsyshid/Skylander.h OS/libs/nsyskbd/nsyskbd.cpp OS/libs/nsyskbd/nsyskbd.h OS/libs/nsysnet/nsysnet.cpp diff --git a/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp index 6e6cb123..fc8e496c 100644 --- a/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp +++ b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp @@ -1,5 +1,6 @@ #include "nsyshid.h" #include "Backend.h" +#include "BackendEmulated.h" #if NSYSHID_ENABLE_BACKEND_LIBUSB @@ -37,5 +38,13 @@ namespace nsyshid::backend } } #endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID + // add emulated backend + { + auto backendEmulated = std::make_shared<backend::emulated::BackendEmulated>(); + if (backendEmulated->IsInitialisedOk()) + { + AttachBackend(backendEmulated); + } + } } } // namespace nsyshid::backend diff --git a/src/Cafe/OS/libs/nsyshid/Backend.h b/src/Cafe/OS/libs/nsyshid/Backend.h index 641104f5..03232736 100644 --- a/src/Cafe/OS/libs/nsyshid/Backend.h +++ b/src/Cafe/OS/libs/nsyshid/Backend.h @@ -23,6 +23,55 @@ namespace nsyshid /* +0x12 */ uint16be maxPacketSizeTX; } HID_t; + struct TransferCommand + { + uint8* data; + sint32 length; + + TransferCommand(uint8* data, sint32 length) + : data(data), length(length) + { + } + virtual ~TransferCommand() = default; + }; + + struct ReadMessage final : TransferCommand + { + sint32 bytesRead; + + ReadMessage(uint8* data, sint32 length, sint32 bytesRead) + : bytesRead(bytesRead), TransferCommand(data, length) + { + } + using TransferCommand::TransferCommand; + }; + + struct WriteMessage final : TransferCommand + { + sint32 bytesWritten; + + WriteMessage(uint8* data, sint32 length, sint32 bytesWritten) + : bytesWritten(bytesWritten), TransferCommand(data, length) + { + } + using TransferCommand::TransferCommand; + }; + + struct ReportMessage final : TransferCommand + { + uint8* reportData; + sint32 length; + uint8* originalData; + sint32 originalLength; + + ReportMessage(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) + : reportData(reportData), length(length), originalData(originalData), + originalLength(originalLength), TransferCommand(reportData, length) + { + } + using TransferCommand::TransferCommand; + }; + static_assert(offsetof(HID_t, vendorId) == 0x8, ""); static_assert(offsetof(HID_t, productId) == 0xA, ""); static_assert(offsetof(HID_t, ifIndex) == 0xC, ""); @@ -69,7 +118,7 @@ namespace nsyshid ErrorTimeout, }; - virtual ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) = 0; + virtual ReadResult Read(ReadMessage* message) = 0; enum class WriteResult { @@ -78,7 +127,7 @@ namespace nsyshid ErrorTimeout, }; - virtual WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) = 0; + virtual WriteResult Write(WriteMessage* message) = 0; virtual bool GetDescriptor(uint8 descType, uint8 descIndex, @@ -88,7 +137,7 @@ namespace nsyshid virtual bool SetProtocol(uint32 ifIndef, uint32 protocol) = 0; - virtual bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) = 0; + virtual bool SetReport(ReportMessage* message) = 0; }; class Backend { @@ -121,6 +170,8 @@ namespace nsyshid std::shared_ptr<Device> FindDevice(std::function<bool(const std::shared_ptr<Device>&)> isWantedDevice); + bool FindDeviceById(uint16 vendorId, uint16 productId); + bool IsDeviceWhitelisted(uint16 vendorId, uint16 productId); // called from OnAttach() - attach devices that your backend can see here diff --git a/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp new file mode 100644 index 00000000..11a299ed --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp @@ -0,0 +1,29 @@ +#include "BackendEmulated.h" +#include "Skylander.h" +#include "config/CemuConfig.h" + +namespace nsyshid::backend::emulated +{ + BackendEmulated::BackendEmulated() + { + cemuLog_logDebug(LogType::Force, "nsyshid::BackendEmulated: emulated backend initialised"); + } + + BackendEmulated::~BackendEmulated() = default; + + bool BackendEmulated::IsInitialisedOk() + { + return true; + } + + void BackendEmulated::AttachVisibleDevices() + { + if (GetConfig().emulated_usb_devices.emulate_skylander_portal && !FindDeviceById(0x1430, 0x0150)) + { + cemuLog_logDebug(LogType::Force, "Attaching Emulated Portal"); + // Add Skylander Portal + auto device = std::make_shared<SkylanderPortalDevice>(); + AttachDevice(device); + } + } +} // namespace nsyshid::backend::emulated \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/BackendEmulated.h b/src/Cafe/OS/libs/nsyshid/BackendEmulated.h new file mode 100644 index 00000000..cf38a8b7 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/BackendEmulated.h @@ -0,0 +1,16 @@ +#include "nsyshid.h" +#include "Backend.h" + +namespace nsyshid::backend::emulated +{ + class BackendEmulated : public nsyshid::Backend { + public: + BackendEmulated(); + ~BackendEmulated(); + + bool IsInitialisedOk() override; + + protected: + void AttachVisibleDevices() override; + }; +} // namespace nsyshid::backend::emulated diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp index 4f88b7ed..6701d780 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -241,11 +241,6 @@ namespace nsyshid::backend::libusb ret); return nullptr; } - if (desc.idVendor == 0x0e6f && desc.idProduct == 0x0241) - { - cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb::CheckAndCreateDevice(): lego dimensions portal detected"); - } auto device = std::make_shared<DeviceLibusb>(m_ctx, desc.idVendor, desc.idProduct, @@ -471,7 +466,7 @@ namespace nsyshid::backend::libusb return m_libusbHandle != nullptr && m_handleInUseCounter >= 0; } - Device::ReadResult DeviceLibusb::Read(uint8* data, sint32 length, sint32& bytesRead) + Device::ReadResult DeviceLibusb::Read(ReadMessage* message) { auto handleLock = AquireHandleLock(); if (!handleLock->IsValid()) @@ -488,8 +483,8 @@ namespace nsyshid::backend::libusb { ret = libusb_bulk_transfer(handleLock->GetHandle(), this->m_libusbEndpointIn, - data, - length, + message->data, + message->length, &actualLength, timeout); } @@ -500,8 +495,8 @@ namespace nsyshid::backend::libusb // success cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::read(): read {} of {} bytes", actualLength, - length); - bytesRead = actualLength; + message->length); + message->bytesRead = actualLength; return ReadResult::Success; } cemuLog_logDebug(LogType::Force, @@ -510,7 +505,7 @@ namespace nsyshid::backend::libusb return ReadResult::Error; } - Device::WriteResult DeviceLibusb::Write(uint8* data, sint32 length, sint32& bytesWritten) + Device::WriteResult DeviceLibusb::Write(WriteMessage* message) { auto handleLock = AquireHandleLock(); if (!handleLock->IsValid()) @@ -520,23 +515,23 @@ namespace nsyshid::backend::libusb return WriteResult::Error; } - bytesWritten = 0; + message->bytesWritten = 0; int actualLength = 0; int ret = libusb_bulk_transfer(handleLock->GetHandle(), this->m_libusbEndpointOut, - data, - length, + message->data, + message->length, &actualLength, 0); if (ret == 0) { // success - bytesWritten = actualLength; + message->bytesWritten = actualLength; cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::write(): wrote {} of {} bytes", - bytesWritten, - length); + message->bytesWritten, + message->length); return WriteResult::Success; } cemuLog_logDebug(LogType::Force, @@ -713,8 +708,7 @@ namespace nsyshid::backend::libusb return true; } - bool DeviceLibusb::SetReport(uint8* reportData, sint32 length, uint8* originalData, - sint32 originalLength) + bool DeviceLibusb::SetReport(ReportMessage* message) { auto handleLock = AquireHandleLock(); if (!handleLock->IsValid()) @@ -731,8 +725,8 @@ namespace nsyshid::backend::libusb bRequest, wValue, wIndex, - reportData, - length, + message->reportData, + message->length, timeout); #endif diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h index 216be6ce..a8122aff 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h @@ -63,9 +63,9 @@ namespace nsyshid::backend::libusb bool IsOpened() override; - ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) override; + ReadResult Read(ReadMessage* message) override; - WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) override; + WriteResult Write(WriteMessage* message) override; bool GetDescriptor(uint8 descType, uint8 descIndex, @@ -75,7 +75,7 @@ namespace nsyshid::backend::libusb bool SetProtocol(uint32 ifIndex, uint32 protocol) override; - bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) override; + bool SetReport(ReportMessage* message) override; uint8 m_libusbBusNumber; uint8 m_libusbDeviceAddress; diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp index 23da5798..3cfba26a 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -196,20 +196,20 @@ namespace nsyshid::backend::windows return m_hFile != INVALID_HANDLE_VALUE; } - Device::ReadResult DeviceWindowsHID::Read(uint8* data, sint32 length, sint32& bytesRead) + Device::ReadResult DeviceWindowsHID::Read(ReadMessage* message) { - bytesRead = 0; + message->bytesRead = 0; DWORD bt; OVERLAPPED ovlp = {0}; ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - uint8* tempBuffer = (uint8*)malloc(length + 1); + uint8* tempBuffer = (uint8*)malloc(message->length + 1); sint32 transferLength = 0; // minus report byte - _debugPrintHex("HID_READ_BEFORE", data, length); + _debugPrintHex("HID_READ_BEFORE", message->data, message->length); - cemuLog_logDebug(LogType::Force, "HidRead Begin (Length 0x{:08x})", length); - BOOL readResult = ReadFile(this->m_hFile, tempBuffer, length + 1, &bt, &ovlp); + cemuLog_logDebug(LogType::Force, "HidRead Begin (Length 0x{:08x})", message->length); + BOOL readResult = ReadFile(this->m_hFile, tempBuffer, message->length + 1, &bt, &ovlp); if (readResult != FALSE) { // sometimes we get the result immediately @@ -247,7 +247,7 @@ namespace nsyshid::backend::windows ReadResult result = ReadResult::Success; if (bt != 0) { - memcpy(data, tempBuffer + 1, transferLength); + memcpy(message->data, tempBuffer + 1, transferLength); sint32 hidReadLength = transferLength; char debugOutput[1024] = {0}; @@ -257,7 +257,7 @@ namespace nsyshid::backend::windows } cemuLog_logDebug(LogType::Force, "HIDRead data: {}", debugOutput); - bytesRead = transferLength; + message->bytesRead = transferLength; result = ReadResult::Success; } else @@ -270,19 +270,19 @@ namespace nsyshid::backend::windows return result; } - Device::WriteResult DeviceWindowsHID::Write(uint8* data, sint32 length, sint32& bytesWritten) + Device::WriteResult DeviceWindowsHID::Write(WriteMessage* message) { - bytesWritten = 0; + message->bytesWritten = 0; DWORD bt; OVERLAPPED ovlp = {0}; ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - uint8* tempBuffer = (uint8*)malloc(length + 1); - memcpy(tempBuffer + 1, data, length); + uint8* tempBuffer = (uint8*)malloc(message->length + 1); + memcpy(tempBuffer + 1, message->data, message->length); tempBuffer[0] = 0; // report byte? - cemuLog_logDebug(LogType::Force, "HidWrite Begin (Length 0x{:08x})", length); - BOOL writeResult = WriteFile(this->m_hFile, tempBuffer, length + 1, &bt, &ovlp); + cemuLog_logDebug(LogType::Force, "HidWrite Begin (Length 0x{:08x})", message->length); + BOOL writeResult = WriteFile(this->m_hFile, tempBuffer, message->length + 1, &bt, &ovlp); if (writeResult != FALSE) { // sometimes we get the result immediately @@ -314,7 +314,7 @@ namespace nsyshid::backend::windows if (bt != 0) { - bytesWritten = length; + message->bytesWritten = message->length; return WriteResult::Success; } return WriteResult::Error; @@ -407,12 +407,12 @@ namespace nsyshid::backend::windows return true; } - bool DeviceWindowsHID::SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) + bool DeviceWindowsHID::SetReport(ReportMessage* message) { sint32 retryCount = 0; while (true) { - BOOL r = HidD_SetOutputReport(this->m_hFile, reportData, length); + BOOL r = HidD_SetOutputReport(this->m_hFile, message->reportData, message->length); if (r != FALSE) break; Sleep(20); // retry diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h index 049b33e4..84fe7bda 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h @@ -41,15 +41,15 @@ namespace nsyshid::backend::windows bool IsOpened() override; - ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) override; + ReadResult Read(ReadMessage* message) override; - WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) override; + WriteResult Write(WriteMessage* message) override; bool GetDescriptor(uint8 descType, uint8 descIndex, uint8 lang, uint8* output, uint32 outputMaxLength) override; bool SetProtocol(uint32 ifIndef, uint32 protocol) override; - bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) override; + bool SetReport(ReportMessage* message) override; private: wchar_t* m_devicePath; diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp new file mode 100644 index 00000000..3123d14d --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -0,0 +1,939 @@ +#include "Skylander.h" + +#include "nsyshid.h" +#include "Backend.h" + +#include "Common/FileStream.h" + +namespace nsyshid +{ + SkylanderUSB g_skyportal; + + const std::map<const std::pair<const uint16, const uint16>, const std::string> + listSkylanders = { + {{0, 0x0000}, "Whirlwind"}, + {{0, 0x1801}, "Series 2 Whirlwind"}, + {{0, 0x1C02}, "Polar Whirlwind"}, + {{0, 0x2805}, "Horn Blast Whirlwind"}, + {{0, 0x3810}, "Eon's Elite Whirlwind"}, + {{1, 0x0000}, "Sonic Boom"}, + {{1, 0x1801}, "Series 2 Sonic Boom"}, + {{2, 0x0000}, "Warnado"}, + {{2, 0x2206}, "LightCore Warnado"}, + {{3, 0x0000}, "Lightning Rod"}, + {{3, 0x1801}, "Series 2 Lightning Rod"}, + {{4, 0x0000}, "Bash"}, + {{4, 0x1801}, "Series 2 Bash"}, + {{5, 0x0000}, "Terrafin"}, + {{5, 0x1801}, "Series 2 Terrafin"}, + {{5, 0x2805}, "Knockout Terrafin"}, + {{5, 0x3810}, "Eon's Elite Terrafin"}, + {{6, 0x0000}, "Dino Rang"}, + {{6, 0x4810}, "Eon's Elite Dino Rang"}, + {{7, 0x0000}, "Prism Break"}, + {{7, 0x1801}, "Series 2 Prism Break"}, + {{7, 0x2805}, "Hyper Beam Prism Break"}, + {{7, 0x1206}, "LightCore Prism Break"}, + {{8, 0x0000}, "Sunburn"}, + {{9, 0x0000}, "Eruptor"}, + {{9, 0x1801}, "Series 2 Eruptor"}, + {{9, 0x2C02}, "Volcanic Eruptor"}, + {{9, 0x2805}, "Lava Barf Eruptor"}, + {{9, 0x1206}, "LightCore Eruptor"}, + {{9, 0x3810}, "Eon's Elite Eruptor"}, + {{10, 0x0000}, "Ignitor"}, + {{10, 0x1801}, "Series 2 Ignitor"}, + {{10, 0x1C03}, "Legendary Ignitor"}, + {{11, 0x0000}, "Flameslinger"}, + {{11, 0x1801}, "Series 2 Flameslinger"}, + {{12, 0x0000}, "Zap"}, + {{12, 0x1801}, "Series 2 Zap"}, + {{13, 0x0000}, "Wham Shell"}, + {{13, 0x2206}, "LightCore Wham Shell"}, + {{14, 0x0000}, "Gill Grunt"}, + {{14, 0x1801}, "Series 2 Gill Grunt"}, + {{14, 0x2805}, "Anchors Away Gill Grunt"}, + {{14, 0x3805}, "Tidal Wave Gill Grunt"}, + {{14, 0x3810}, "Eon's Elite Gill Grunt"}, + {{15, 0x0000}, "Slam Bam"}, + {{15, 0x1801}, "Series 2 Slam Bam"}, + {{15, 0x1C03}, "Legendary Slam Bam"}, + {{15, 0x4810}, "Eon's Elite Slam Bam"}, + {{16, 0x0000}, "Spyro"}, + {{16, 0x1801}, "Series 2 Spyro"}, + {{16, 0x2C02}, "Dark Mega Ram Spyro"}, + {{16, 0x2805}, "Mega Ram Spyro"}, + {{16, 0x3810}, "Eon's Elite Spyro"}, + {{17, 0x0000}, "Voodood"}, + {{17, 0x4810}, "Eon's Elite Voodood"}, + {{18, 0x0000}, "Double Trouble"}, + {{18, 0x1801}, "Series 2 Double Trouble"}, + {{18, 0x1C02}, "Royal Double Trouble"}, + {{19, 0x0000}, "Trigger Happy"}, + {{19, 0x1801}, "Series 2 Trigger Happy"}, + {{19, 0x2C02}, "Springtime Trigger Happy"}, + {{19, 0x2805}, "Big Bang Trigger Happy"}, + {{19, 0x3810}, "Eon's Elite Trigger Happy"}, + {{20, 0x0000}, "Drobot"}, + {{20, 0x1801}, "Series 2 Drobot"}, + {{20, 0x1206}, "LightCore Drobot"}, + {{21, 0x0000}, "Drill Seargeant"}, + {{21, 0x1801}, "Series 2 Drill Seargeant"}, + {{22, 0x0000}, "Boomer"}, + {{22, 0x4810}, "Eon's Elite Boomer"}, + {{23, 0x0000}, "Wrecking Ball"}, + {{23, 0x1801}, "Series 2 Wrecking Ball"}, + {{24, 0x0000}, "Camo"}, + {{24, 0x2805}, "Thorn Horn Camo"}, + {{25, 0x0000}, "Zook"}, + {{25, 0x1801}, "Series 2 Zook"}, + {{25, 0x4810}, "Eon's Elite Zook"}, + {{26, 0x0000}, "Stealth Elf"}, + {{26, 0x1801}, "Series 2 Stealth Elf"}, + {{26, 0x2C02}, "Dark Stealth Elf"}, + {{26, 0x1C03}, "Legendary Stealth Elf"}, + {{26, 0x2805}, "Ninja Stealth Elf"}, + {{26, 0x3810}, "Eon's Elite Stealth Elf"}, + {{27, 0x0000}, "Stump Smash"}, + {{27, 0x1801}, "Series 2 Stump Smash"}, + {{28, 0x0000}, "Dark Spyro"}, + {{29, 0x0000}, "Hex"}, + {{29, 0x1801}, "Series 2 Hex"}, + {{29, 0x1206}, "LightCore Hex"}, + {{30, 0x0000}, "Chop Chop"}, + {{30, 0x1801}, "Series 2 Chop Chop"}, + {{30, 0x2805}, "Twin Blade Chop Chop"}, + {{30, 0x3810}, "Eon's Elite Chop Chop"}, + {{31, 0x0000}, "Ghost Roaster"}, + {{31, 0x4810}, "Eon's Elite Ghost Roaster"}, + {{32, 0x0000}, "Cynder"}, + {{32, 0x1801}, "Series 2 Cynder"}, + {{32, 0x2805}, "Phantom Cynder"}, + {{100, 0x0000}, "Jet Vac"}, + {{100, 0x1403}, "Legendary Jet Vac"}, + {{100, 0x2805}, "Turbo Jet Vac"}, + {{100, 0x3805}, "Full Blast Jet Vac"}, + {{100, 0x1206}, "LightCore Jet Vac"}, + {{101, 0x0000}, "Swarm"}, + {{102, 0x0000}, "Crusher"}, + {{102, 0x1602}, "Granite Crusher"}, + {{103, 0x0000}, "Flashwing"}, + {{103, 0x1402}, "Jade Flash Wing"}, + {{103, 0x2206}, "LightCore Flashwing"}, + {{104, 0x0000}, "Hot Head"}, + {{105, 0x0000}, "Hot Dog"}, + {{105, 0x1402}, "Molten Hot Dog"}, + {{105, 0x2805}, "Fire Bone Hot Dog"}, + {{106, 0x0000}, "Chill"}, + {{106, 0x1603}, "Legendary Chill"}, + {{106, 0x2805}, "Blizzard Chill"}, + {{106, 0x1206}, "LightCore Chill"}, + {{107, 0x0000}, "Thumpback"}, + {{108, 0x0000}, "Pop Fizz"}, + {{108, 0x1402}, "Punch Pop Fizz"}, + {{108, 0x3C02}, "Love Potion Pop Fizz"}, + {{108, 0x2805}, "Super Gulp Pop Fizz"}, + {{108, 0x3805}, "Fizzy Frenzy Pop Fizz"}, + {{108, 0x1206}, "LightCore Pop Fizz"}, + {{109, 0x0000}, "Ninjini"}, + {{109, 0x1602}, "Scarlet Ninjini"}, + {{110, 0x0000}, "Bouncer"}, + {{110, 0x1603}, "Legendary Bouncer"}, + {{111, 0x0000}, "Sprocket"}, + {{111, 0x2805}, "Heavy Duty Sprocket"}, + {{112, 0x0000}, "Tree Rex"}, + {{112, 0x1602}, "Gnarly Tree Rex"}, + {{113, 0x0000}, "Shroomboom"}, + {{113, 0x3805}, "Sure Shot Shroomboom"}, + {{113, 0x1206}, "LightCore Shroomboom"}, + {{114, 0x0000}, "Eye Brawl"}, + {{115, 0x0000}, "Fright Rider"}, + {{200, 0x0000}, "Anvil Rain"}, + {{201, 0x0000}, "Hidden Treasure"}, + {{201, 0x2000}, "Platinum Hidden Treasure"}, + {{202, 0x0000}, "Healing Elixir"}, + {{203, 0x0000}, "Ghost Pirate Swords"}, + {{204, 0x0000}, "Time Twist Hourglass"}, + {{205, 0x0000}, "Sky Iron Shield"}, + {{206, 0x0000}, "Winged Boots"}, + {{207, 0x0000}, "Sparx the Dragonfly"}, + {{208, 0x0000}, "Dragonfire Cannon"}, + {{208, 0x1602}, "Golden Dragonfire Cannon"}, + {{209, 0x0000}, "Scorpion Striker"}, + {{210, 0x3002}, "Biter's Bane"}, + {{210, 0x3008}, "Sorcerous Skull"}, + {{210, 0x300B}, "Axe of Illusion"}, + {{210, 0x300E}, "Arcane Hourglass"}, + {{210, 0x3012}, "Spell Slapper"}, + {{210, 0x3014}, "Rune Rocket"}, + {{211, 0x3001}, "Tidal Tiki"}, + {{211, 0x3002}, "Wet Walter"}, + {{211, 0x3006}, "Flood Flask"}, + {{211, 0x3406}, "Legendary Flood Flask"}, + {{211, 0x3007}, "Soaking Staff"}, + {{211, 0x300B}, "Aqua Axe"}, + {{211, 0x3016}, "Frost Helm"}, + {{212, 0x3003}, "Breezy Bird"}, + {{212, 0x3006}, "Drafty Decanter"}, + {{212, 0x300D}, "Tempest Timer"}, + {{212, 0x3010}, "Cloudy Cobra"}, + {{212, 0x3011}, "Storm Warning"}, + {{212, 0x3018}, "Cyclone Saber"}, + {{213, 0x3004}, "Spirit Sphere"}, + {{213, 0x3404}, "Legendary Spirit Sphere"}, + {{213, 0x3008}, "Spectral Skull"}, + {{213, 0x3408}, "Legendary Spectral Skull"}, + {{213, 0x300B}, "Haunted Hatchet"}, + {{213, 0x300C}, "Grim Gripper"}, + {{213, 0x3010}, "Spooky Snake"}, + {{213, 0x3017}, "Dream Piercer"}, + {{214, 0x3000}, "Tech Totem"}, + {{214, 0x3007}, "Automatic Angel"}, + {{214, 0x3009}, "Factory Flower"}, + {{214, 0x300C}, "Grabbing Gadget"}, + {{214, 0x3016}, "Makers Mana"}, + {{214, 0x301A}, "Topsy Techy"}, + {{215, 0x3005}, "Eternal Flame"}, + {{215, 0x3009}, "Fire Flower"}, + {{215, 0x3011}, "Scorching Stopper"}, + {{215, 0x3012}, "Searing Spinner"}, + {{215, 0x3017}, "Spark Spear"}, + {{215, 0x301B}, "Blazing Belch"}, + {{216, 0x3000}, "Banded Boulder"}, + {{216, 0x3003}, "Rock Hawk"}, + {{216, 0x300A}, "Slag Hammer"}, + {{216, 0x300E}, "Dust Of Time"}, + {{216, 0x3013}, "Spinning Sandstorm"}, + {{216, 0x301A}, "Rubble Trouble"}, + {{217, 0x3003}, "Oak Eagle"}, + {{217, 0x3005}, "Emerald Energy"}, + {{217, 0x300A}, "Weed Whacker"}, + {{217, 0x3010}, "Seed Serpent"}, + {{217, 0x3018}, "Jade Blade"}, + {{217, 0x301B}, "Shrub Shrieker"}, + {{218, 0x3000}, "Dark Dagger"}, + {{218, 0x3014}, "Shadow Spider"}, + {{218, 0x301A}, "Ghastly Grimace"}, + {{219, 0x3000}, "Shining Ship"}, + {{219, 0x300F}, "Heavenly Hawk"}, + {{219, 0x301B}, "Beam Scream"}, + {{220, 0x301E}, "Kaos Trap"}, + {{220, 0x351F}, "Ultimate Kaos Trap"}, + {{230, 0x0000}, "Hand of Fate"}, + {{230, 0x3403}, "Legendary Hand of Fate"}, + {{231, 0x0000}, "Piggy Bank"}, + {{232, 0x0000}, "Rocket Ram"}, + {{233, 0x0000}, "Tiki Speaky"}, + {{300, 0x0000}, "Dragon’s Peak"}, + {{301, 0x0000}, "Empire of Ice"}, + {{302, 0x0000}, "Pirate Seas"}, + {{303, 0x0000}, "Darklight Crypt"}, + {{304, 0x0000}, "Volcanic Vault"}, + {{305, 0x0000}, "Mirror of Mystery"}, + {{306, 0x0000}, "Nightmare Express"}, + {{307, 0x0000}, "Sunscraper Spire"}, + {{308, 0x0000}, "Midnight Museum"}, + {{404, 0x0000}, "Legendary Bash"}, + {{416, 0x0000}, "Legendary Spyro"}, + {{419, 0x0000}, "Legendary Trigger Happy"}, + {{430, 0x0000}, "Legendary Chop Chop"}, + {{450, 0x0000}, "Gusto"}, + {{451, 0x0000}, "Thunderbolt"}, + {{452, 0x0000}, "Fling Kong"}, + {{453, 0x0000}, "Blades"}, + {{453, 0x3403}, "Legendary Blades"}, + {{454, 0x0000}, "Wallop"}, + {{455, 0x0000}, "Head Rush"}, + {{455, 0x3402}, "Nitro Head Rush"}, + {{456, 0x0000}, "Fist Bump"}, + {{457, 0x0000}, "Rocky Roll"}, + {{458, 0x0000}, "Wildfire"}, + {{458, 0x3402}, "Dark Wildfire"}, + {{459, 0x0000}, "Ka Boom"}, + {{460, 0x0000}, "Trail Blazer"}, + {{461, 0x0000}, "Torch"}, + {{462, 0x3000}, "Snap Shot"}, + {{462, 0x3402}, "Dark Snap Shot"}, + {{463, 0x0000}, "Lob Star"}, + {{463, 0x3402}, "Winterfest Lob-Star"}, + {{464, 0x0000}, "Flip Wreck"}, + {{465, 0x0000}, "Echo"}, + {{466, 0x0000}, "Blastermind"}, + {{467, 0x0000}, "Enigma"}, + {{468, 0x0000}, "Deja Vu"}, + {{468, 0x3403}, "Legendary Deja Vu"}, + {{469, 0x0000}, "Cobra Candabra"}, + {{469, 0x3402}, "King Cobra Cadabra"}, + {{470, 0x0000}, "Jawbreaker"}, + {{470, 0x3403}, "Legendary Jawbreaker"}, + {{471, 0x0000}, "Gearshift"}, + {{472, 0x0000}, "Chopper"}, + {{473, 0x0000}, "Tread Head"}, + {{474, 0x0000}, "Bushwack"}, + {{474, 0x3403}, "Legendary Bushwack"}, + {{475, 0x0000}, "Tuff Luck"}, + {{476, 0x0000}, "Food Fight"}, + {{476, 0x3402}, "Dark Food Fight"}, + {{477, 0x0000}, "High Five"}, + {{478, 0x0000}, "Krypt King"}, + {{478, 0x3402}, "Nitro Krypt King"}, + {{479, 0x0000}, "Short Cut"}, + {{480, 0x0000}, "Bat Spin"}, + {{481, 0x0000}, "Funny Bone"}, + {{482, 0x0000}, "Knight Light"}, + {{483, 0x0000}, "Spotlight"}, + {{484, 0x0000}, "Knight Mare"}, + {{485, 0x0000}, "Blackout"}, + {{502, 0x0000}, "Bop"}, + {{505, 0x0000}, "Terrabite"}, + {{506, 0x0000}, "Breeze"}, + {{508, 0x0000}, "Pet Vac"}, + {{508, 0x3402}, "Power Punch Pet Vac"}, + {{507, 0x0000}, "Weeruptor"}, + {{507, 0x3402}, "Eggcellent Weeruptor"}, + {{509, 0x0000}, "Small Fry"}, + {{510, 0x0000}, "Drobit"}, + {{519, 0x0000}, "Trigger Snappy"}, + {{526, 0x0000}, "Whisper Elf"}, + {{540, 0x0000}, "Barkley"}, + {{540, 0x3402}, "Gnarly Barkley"}, + {{541, 0x0000}, "Thumpling"}, + {{514, 0x0000}, "Gill Runt"}, + {{542, 0x0000}, "Mini-Jini"}, + {{503, 0x0000}, "Spry"}, + {{504, 0x0000}, "Hijinx"}, + {{543, 0x0000}, "Eye Small"}, + {{601, 0x0000}, "King Pen"}, + {{602, 0x0000}, "Tri-Tip"}, + {{603, 0x0000}, "Chopscotch"}, + {{604, 0x0000}, "Boom Bloom"}, + {{605, 0x0000}, "Pit Boss"}, + {{606, 0x0000}, "Barbella"}, + {{607, 0x0000}, "Air Strike"}, + {{608, 0x0000}, "Ember"}, + {{609, 0x0000}, "Ambush"}, + {{610, 0x0000}, "Dr. Krankcase"}, + {{611, 0x0000}, "Hood Sickle"}, + {{612, 0x0000}, "Tae Kwon Crow"}, + {{613, 0x0000}, "Golden Queen"}, + {{614, 0x0000}, "Wolfgang"}, + {{615, 0x0000}, "Pain-Yatta"}, + {{616, 0x0000}, "Mysticat"}, + {{617, 0x0000}, "Starcast"}, + {{618, 0x0000}, "Buckshot"}, + {{619, 0x0000}, "Aurora"}, + {{620, 0x0000}, "Flare Wolf"}, + {{621, 0x0000}, "Chompy Mage"}, + {{622, 0x0000}, "Bad Juju"}, + {{623, 0x0000}, "Grave Clobber"}, + {{624, 0x0000}, "Blaster-Tron"}, + {{625, 0x0000}, "Ro-Bow"}, + {{626, 0x0000}, "Chain Reaction"}, + {{627, 0x0000}, "Kaos"}, + {{628, 0x0000}, "Wild Storm"}, + {{629, 0x0000}, "Tidepool"}, + {{630, 0x0000}, "Crash Bandicoot"}, + {{631, 0x0000}, "Dr. Neo Cortex"}, + {{1000, 0x0000}, "Boom Jet (Bottom)"}, + {{1001, 0x0000}, "Free Ranger (Bottom)"}, + {{1001, 0x2403}, "Legendary Free Ranger (Bottom)"}, + {{1002, 0x0000}, "Rubble Rouser (Bottom)"}, + {{1003, 0x0000}, "Doom Stone (Bottom)"}, + {{1004, 0x0000}, "Blast Zone (Bottom)"}, + {{1004, 0x2402}, "Dark Blast Zone (Bottom)"}, + {{1005, 0x0000}, "Fire Kraken (Bottom)"}, + {{1005, 0x2402}, "Jade Fire Kraken (Bottom)"}, + {{1006, 0x0000}, "Stink Bomb (Bottom)"}, + {{1007, 0x0000}, "Grilla Drilla (Bottom)"}, + {{1008, 0x0000}, "Hoot Loop (Bottom)"}, + {{1008, 0x2402}, "Enchanted Hoot Loop (Bottom)"}, + {{1009, 0x0000}, "Trap Shadow (Bottom)"}, + {{1010, 0x0000}, "Magna Charge (Bottom)"}, + {{1010, 0x2402}, "Nitro Magna Charge (Bottom)"}, + {{1011, 0x0000}, "Spy Rise (Bottom)"}, + {{1012, 0x0000}, "Night Shift (Bottom)"}, + {{1012, 0x2403}, "Legendary Night Shift (Bottom)"}, + {{1013, 0x0000}, "Rattle Shake (Bottom)"}, + {{1013, 0x2402}, "Quick Draw Rattle Shake (Bottom)"}, + {{1014, 0x0000}, "Freeze Blade (Bottom)"}, + {{1014, 0x2402}, "Nitro Freeze Blade (Bottom)"}, + {{1015, 0x0000}, "Wash Buckler (Bottom)"}, + {{1015, 0x2402}, "Dark Wash Buckler (Bottom)"}, + {{2000, 0x0000}, "Boom Jet (Top)"}, + {{2001, 0x0000}, "Free Ranger (Top)"}, + {{2001, 0x2403}, "Legendary Free Ranger (Top)"}, + {{2002, 0x0000}, "Rubble Rouser (Top)"}, + {{2003, 0x0000}, "Doom Stone (Top)"}, + {{2004, 0x0000}, "Blast Zone (Top)"}, + {{2004, 0x2402}, "Dark Blast Zone (Top)"}, + {{2005, 0x0000}, "Fire Kraken (Top)"}, + {{2005, 0x2402}, "Jade Fire Kraken (Top)"}, + {{2006, 0x0000}, "Stink Bomb (Top)"}, + {{2007, 0x0000}, "Grilla Drilla (Top)"}, + {{2008, 0x0000}, "Hoot Loop (Top)"}, + {{2008, 0x2402}, "Enchanted Hoot Loop (Top)"}, + {{2009, 0x0000}, "Trap Shadow (Top)"}, + {{2010, 0x0000}, "Magna Charge (Top)"}, + {{2010, 0x2402}, "Nitro Magna Charge (Top)"}, + {{2011, 0x0000}, "Spy Rise (Top)"}, + {{2012, 0x0000}, "Night Shift (Top)"}, + {{2012, 0x2403}, "Legendary Night Shift (Top)"}, + {{2013, 0x0000}, "Rattle Shake (Top)"}, + {{2013, 0x2402}, "Quick Draw Rattle Shake (Top)"}, + {{2014, 0x0000}, "Freeze Blade (Top)"}, + {{2014, 0x2402}, "Nitro Freeze Blade (Top)"}, + {{2015, 0x0000}, "Wash Buckler (Top)"}, + {{2015, 0x2402}, "Dark Wash Buckler (Top)"}, + {{3000, 0x0000}, "Scratch"}, + {{3001, 0x0000}, "Pop Thorn"}, + {{3002, 0x0000}, "Slobber Tooth"}, + {{3002, 0x2402}, "Dark Slobber Tooth"}, + {{3003, 0x0000}, "Scorp"}, + {{3004, 0x0000}, "Fryno"}, + {{3004, 0x3805}, "Hog Wild Fryno"}, + {{3005, 0x0000}, "Smolderdash"}, + {{3005, 0x2206}, "LightCore Smolderdash"}, + {{3006, 0x0000}, "Bumble Blast"}, + {{3006, 0x2402}, "Jolly Bumble Blast"}, + {{3006, 0x2206}, "LightCore Bumble Blast"}, + {{3007, 0x0000}, "Zoo Lou"}, + {{3007, 0x2403}, "Legendary Zoo Lou"}, + {{3008, 0x0000}, "Dune Bug"}, + {{3009, 0x0000}, "Star Strike"}, + {{3009, 0x2602}, "Enchanted Star Strike"}, + {{3009, 0x2206}, "LightCore Star Strike"}, + {{3010, 0x0000}, "Countdown"}, + {{3010, 0x2402}, "Kickoff Countdown"}, + {{3010, 0x2206}, "LightCore Countdown"}, + {{3011, 0x0000}, "Wind Up"}, + {{3011, 0x2404}, "Gear Head VVind Up"}, + {{3012, 0x0000}, "Roller Brawl"}, + {{3013, 0x0000}, "Grim Creeper"}, + {{3013, 0x2603}, "Legendary Grim Creeper"}, + {{3013, 0x2206}, "LightCore Grim Creeper"}, + {{3014, 0x0000}, "Rip Tide"}, + {{3015, 0x0000}, "Punk Shock"}, + {{3200, 0x0000}, "Battle Hammer"}, + {{3201, 0x0000}, "Sky Diamond"}, + {{3202, 0x0000}, "Platinum Sheep"}, + {{3203, 0x0000}, "Groove Machine"}, + {{3204, 0x0000}, "UFO Hat"}, + {{3300, 0x0000}, "Sheep Wreck Island"}, + {{3301, 0x0000}, "Tower of Time"}, + {{3302, 0x0000}, "Fiery Forge"}, + {{3303, 0x0000}, "Arkeyan Crossbow"}, + {{3220, 0x0000}, "Jet Stream"}, + {{3221, 0x0000}, "Tomb Buggy"}, + {{3222, 0x0000}, "Reef Ripper"}, + {{3223, 0x0000}, "Burn Cycle"}, + {{3224, 0x0000}, "Hot Streak"}, + {{3224, 0x4402}, "Dark Hot Streak"}, + {{3224, 0x4004}, "E3 Hot Streak"}, + {{3224, 0x441E}, "Golden Hot Streak"}, + {{3225, 0x0000}, "Shark Tank"}, + {{3226, 0x0000}, "Thump Truck"}, + {{3227, 0x0000}, "Crypt Crusher"}, + {{3228, 0x0000}, "Stealth Stinger"}, + {{3228, 0x4402}, "Nitro Stealth Stinger"}, + {{3231, 0x0000}, "Dive Bomber"}, + {{3231, 0x4402}, "Spring Ahead Dive Bomber"}, + {{3232, 0x0000}, "Sky Slicer"}, + {{3233, 0x0000}, "Clown Cruiser (Nintendo Only)"}, + {{3233, 0x4402}, "Dark Clown Cruiser (Nintendo Only)"}, + {{3234, 0x0000}, "Gold Rusher"}, + {{3234, 0x4402}, "Power Blue Gold Rusher"}, + {{3235, 0x0000}, "Shield Striker"}, + {{3236, 0x0000}, "Sun Runner"}, + {{3236, 0x4403}, "Legendary Sun Runner"}, + {{3237, 0x0000}, "Sea Shadow"}, + {{3237, 0x4402}, "Dark Sea Shadow"}, + {{3238, 0x0000}, "Splatter Splasher"}, + {{3238, 0x4402}, "Power Blue Splatter Splasher"}, + {{3239, 0x0000}, "Soda Skimmer"}, + {{3239, 0x4402}, "Nitro Soda Skimmer"}, + {{3240, 0x0000}, "Barrel Blaster (Nintendo Only)"}, + {{3240, 0x4402}, "Dark Barrel Blaster (Nintendo Only)"}, + {{3241, 0x0000}, "Buzz Wing"}, + {{3400, 0x0000}, "Fiesta"}, + {{3400, 0x4515}, "Frightful Fiesta"}, + {{3401, 0x0000}, "High Volt"}, + {{3402, 0x0000}, "Splat"}, + {{3402, 0x4502}, "Power Blue Splat"}, + {{3406, 0x0000}, "Stormblade"}, + {{3411, 0x0000}, "Smash Hit"}, + {{3411, 0x4502}, "Steel Plated Smash Hit"}, + {{3412, 0x0000}, "Spitfire"}, + {{3412, 0x4502}, "Dark Spitfire"}, + {{3413, 0x0000}, "Hurricane Jet Vac"}, + {{3413, 0x4503}, "Legendary Hurricane Jet Vac"}, + {{3414, 0x0000}, "Double Dare Trigger Happy"}, + {{3414, 0x4502}, "Power Blue Double Dare Trigger Happy"}, + {{3415, 0x0000}, "Super Shot Stealth Elf"}, + {{3415, 0x4502}, "Dark Super Shot Stealth Elf"}, + {{3416, 0x0000}, "Shark Shooter Terrafin"}, + {{3417, 0x0000}, "Bone Bash Roller Brawl"}, + {{3417, 0x4503}, "Legendary Bone Bash Roller Brawl"}, + {{3420, 0x0000}, "Big Bubble Pop Fizz"}, + {{3420, 0x450E}, "Birthday Bash Big Bubble Pop Fizz"}, + {{3421, 0x0000}, "Lava Lance Eruptor"}, + {{3422, 0x0000}, "Deep Dive Gill Grunt"}, + {{3423, 0x0000}, "Turbo Charge Donkey Kong (Nintendo Only)"}, + {{3423, 0x4502}, "Dark Turbo Charge Donkey Kong (Nintendo Only)"}, + {{3424, 0x0000}, "Hammer Slam Bowser (Nintendo Only)"}, + {{3424, 0x4502}, "Dark Hammer Slam Bowser (Nintendo Only)"}, + {{3425, 0x0000}, "Dive-Clops"}, + {{3425, 0x450E}, "Missile-Tow Dive-Clops"}, + {{3426, 0x0000}, "Astroblast"}, + {{3426, 0x4503}, "Legendary Astroblast"}, + {{3427, 0x0000}, "Nightfall"}, + {{3428, 0x0000}, "Thrillipede"}, + {{3428, 0x450D}, "Eggcited Thrillipede"}, + {{3500, 0x0000}, "Sky Trophy"}, + {{3501, 0x0000}, "Land Trophy"}, + {{3502, 0x0000}, "Sea Trophy"}, + {{3503, 0x0000}, "Kaos Trophy"}, + }; + + uint16 SkylanderUSB::SkylanderCRC16(uint16 initValue, const uint8* buffer, uint32 size) + { + const unsigned short CRC_CCITT_TABLE[256] = {0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, + 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, + 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, + 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, + 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, + 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, + 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, + 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, + 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, + 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, + 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}; + + uint16 crc = initValue; + + for (uint32 i = 0; i < size; i++) + { + const uint16 tmp = (crc >> 8) ^ buffer[i]; + crc = (crc << 8) ^ CRC_CCITT_TABLE[tmp]; + } + + return crc; + } + SkylanderPortalDevice::SkylanderPortalDevice() + : Device(0x1430, 0x0150, 1, 2, 0) + { + m_IsOpened = false; + } + + bool SkylanderPortalDevice::Open() + { + if (!IsOpened()) + { + m_IsOpened = true; + } + return true; + } + + void SkylanderPortalDevice::Close() + { + if (IsOpened()) + { + m_IsOpened = false; + } + } + + bool SkylanderPortalDevice::IsOpened() + { + return m_IsOpened; + } + + Device::ReadResult SkylanderPortalDevice::Read(ReadMessage* message) + { + memcpy(message->data, g_skyportal.GetStatus().data(), message->length); + message->bytesRead = message->length; + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + return Device::ReadResult::Success; + } + + Device::WriteResult SkylanderPortalDevice::Write(WriteMessage* message) + { + message->bytesWritten = message->length; + return Device::WriteResult::Success; + } + + bool SkylanderPortalDevice::GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) + { + uint8 configurationDescriptor[0x29]; + + uint8* currentWritePtr; + + // configuration descriptor + currentWritePtr = configurationDescriptor + 0; + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength + *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces + *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue + *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration + *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes + *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber + *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting + *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints + *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass + *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass + *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol + *(uint8*)(currentWritePtr + 8) = 0; // iInterface + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID + *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode + *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors + *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType + *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength + currentWritePtr = currentWritePtr + 9; + // endpoint descriptor 1 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + // endpoint descriptor 2 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x02; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + + cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); + + memcpy(output, configurationDescriptor, + std::min<uint32>(outputMaxLength, sizeof(configurationDescriptor))); + return true; + } + + bool SkylanderPortalDevice::SetProtocol(uint32 ifIndex, uint32 protocol) + { + return true; + } + + bool SkylanderPortalDevice::SetReport(ReportMessage* message) + { + g_skyportal.ControlTransfer(message->originalData, message->originalLength); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + return true; + } + + void SkylanderUSB::ControlTransfer(uint8* buf, sint32 originalLength) + { + std::array<uint8, 64> interruptResponse = {}; + switch (buf[0]) + { + case 'A': + { + interruptResponse = {buf[0], buf[1], 0xFF, 0x77}; + g_skyportal.Activate(); + break; + } + case 'C': + { + g_skyportal.SetLeds(0x01, buf[1], buf[2], buf[3]); + break; + } + case 'J': + { + g_skyportal.SetLeds(buf[1], buf[2], buf[3], buf[4]); + interruptResponse = {buf[0]}; + break; + } + case 'L': + { + uint8 side = buf[1]; + if (side == 0x02) + { + side = 0x04; + } + g_skyportal.SetLeds(side, buf[2], buf[3], buf[4]); + break; + } + case 'M': + { + interruptResponse = {buf[0], buf[1], 0x00, 0x19}; + break; + } + case 'Q': + { + const uint8 skyNum = buf[1] & 0xF; + const uint8 block = buf[2]; + g_skyportal.QueryBlock(skyNum, block, interruptResponse.data()); + break; + } + case 'R': + { + interruptResponse = {buf[0], 0x02, 0x1b}; + break; + } + case 'S': + case 'V': + { + // No response needed + break; + } + case 'W': + { + const uint8 skyNum = buf[1] & 0xF; + const uint8 block = buf[2]; + g_skyportal.WriteBlock(skyNum, block, &buf[3], interruptResponse.data()); + break; + } + default: + cemu_assert_error(); + break; + } + if (interruptResponse[0] != 0) + { + std::lock_guard lock(m_queryMutex); + m_queries.push(interruptResponse); + } + } + + void SkylanderUSB::Activate() + { + std::lock_guard lock(m_skyMutex); + if (m_activated) + { + // If the portal was already active no change is needed + return; + } + + // If not we need to advertise change to all the figures present on the portal + for (auto& s : m_skylanders) + { + if (s.status & 1) + { + s.queuedStatus.push(3); + s.queuedStatus.push(1); + } + } + + m_activated = true; + } + + void SkylanderUSB::Deactivate() + { + std::lock_guard lock(m_skyMutex); + + for (auto& s : m_skylanders) + { + // check if at the end of the updates there would be a figure on the portal + if (!s.queuedStatus.empty()) + { + s.status = s.queuedStatus.back(); + s.queuedStatus = std::queue<uint8>(); + } + + s.status &= 1; + } + + m_activated = false; + } + + void SkylanderUSB::SetLeds(uint8 side, uint8 r, uint8 g, uint8 b) + { + std::lock_guard lock(m_skyMutex); + if (side == 0x00) + { + m_colorRight.red = r; + m_colorRight.green = g; + m_colorRight.blue = b; + } + else if (side == 0x01) + { + m_colorRight.red = r; + m_colorRight.green = g; + m_colorRight.blue = b; + + m_colorLeft.red = r; + m_colorLeft.green = g; + m_colorLeft.blue = b; + } + else if (side == 0x02) + { + m_colorLeft.red = r; + m_colorLeft.green = g; + m_colorLeft.blue = b; + } + else if (side == 0x03) + { + m_colorTrap.red = r; + m_colorTrap.green = g; + m_colorTrap.blue = b; + } + } + + uint8 SkylanderUSB::LoadSkylander(uint8* buf, std::unique_ptr<FileStream> file) + { + std::lock_guard lock(m_skyMutex); + + uint32 skySerial = 0; + for (int i = 3; i > -1; i--) + { + skySerial <<= 8; + skySerial |= buf[i]; + } + uint8 foundSlot = 0xFF; + + // mimics spot retaining on the portal + for (auto i = 0; i < 16; i++) + { + if ((m_skylanders[i].status & 1) == 0) + { + if (m_skylanders[i].lastId == skySerial) + { + foundSlot = i; + break; + } + + if (i < foundSlot) + { + foundSlot = i; + } + } + } + + if (foundSlot != 0xFF) + { + auto& skylander = m_skylanders[foundSlot]; + memcpy(skylander.data.data(), buf, skylander.data.size()); + skylander.skyFile = std::move(file); + skylander.status = Skylander::ADDED; + skylander.queuedStatus.push(Skylander::ADDED); + skylander.queuedStatus.push(Skylander::READY); + skylander.lastId = skySerial; + } + return foundSlot; + } + + bool SkylanderUSB::RemoveSkylander(uint8 skyNum) + { + std::lock_guard lock(m_skyMutex); + auto& thesky = m_skylanders[skyNum]; + + if (thesky.status & 1) + { + thesky.status = 2; + thesky.queuedStatus.push(2); + thesky.queuedStatus.push(0); + thesky.Save(); + thesky.skyFile.reset(); + return true; + } + + return false; + } + + void SkylanderUSB::QueryBlock(uint8 skyNum, uint8 block, uint8* replyBuf) + { + std::lock_guard lock(m_skyMutex); + + const auto& skylander = m_skylanders[skyNum]; + + replyBuf[0] = 'Q'; + replyBuf[2] = block; + if (skylander.status & 1) + { + replyBuf[1] = (0x10 | skyNum); + memcpy(replyBuf + 3, skylander.data.data() + (16 * block), 16); + } + else + { + replyBuf[1] = skyNum; + } + } + + void SkylanderUSB::WriteBlock(uint8 skyNum, uint8 block, + const uint8* toWriteBuf, uint8* replyBuf) + { + std::lock_guard lock(m_skyMutex); + + auto& skylander = m_skylanders[skyNum]; + + replyBuf[0] = 'W'; + replyBuf[2] = block; + + if (skylander.status & 1) + { + replyBuf[1] = (0x10 | skyNum); + memcpy(skylander.data.data() + (block * 16), toWriteBuf, 16); + skylander.Save(); + } + else + { + replyBuf[1] = skyNum; + } + } + + std::array<uint8, 64> SkylanderUSB::GetStatus() + { + std::lock_guard lock(m_queryMutex); + std::array<uint8, 64> interruptResponse = {}; + + if (!m_queries.empty()) + { + interruptResponse = m_queries.front(); + m_queries.pop(); + // This needs to happen after ~22 milliseconds + } + else + { + uint32 status = 0; + uint8 active = 0x00; + if (m_activated) + { + active = 0x01; + } + + for (int i = 16 - 1; i >= 0; i--) + { + auto& s = m_skylanders[i]; + + if (!s.queuedStatus.empty()) + { + s.status = s.queuedStatus.front(); + s.queuedStatus.pop(); + } + status <<= 2; + status |= s.status; + } + interruptResponse = {0x53, 0x00, 0x00, 0x00, 0x00, m_interruptCounter++, + active, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00}; + memcpy(&interruptResponse[1], &status, sizeof(status)); + } + return interruptResponse; + } + + void SkylanderUSB::Skylander::Save() + { + if (!skyFile) + return; + + skyFile->writeData(data.data(), data.size()); + } +} // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h new file mode 100644 index 00000000..dfa370dc --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -0,0 +1,98 @@ +#include <mutex> + +#include "nsyshid.h" +#include "Backend.h" + +#include "Common/FileStream.h" + +namespace nsyshid +{ + class SkylanderPortalDevice final : public Device { + public: + SkylanderPortalDevice(); + ~SkylanderPortalDevice() = default; + + bool Open() override; + + void Close() override; + + bool IsOpened() override; + + ReadResult Read(ReadMessage* message) override; + + WriteResult Write(WriteMessage* message) override; + + bool GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) override; + + bool SetProtocol(uint32 ifIndex, uint32 protocol) override; + + bool SetReport(ReportMessage* message) override; + + private: + bool m_IsOpened; + }; + + extern const std::map<const std::pair<const uint16, const uint16>, const std::string> listSkylanders; + + class SkylanderUSB { + public: + struct Skylander final + { + std::unique_ptr<FileStream> skyFile; + uint8 status = 0; + std::queue<uint8> queuedStatus; + std::array<uint8, 0x40 * 0x10> data{}; + uint32 lastId = 0; + void Save(); + + enum : uint8 + { + REMOVED = 0, + READY = 1, + REMOVING = 2, + ADDED = 3 + }; + }; + + struct SkylanderLEDColor final + { + uint8 red = 0; + uint8 green = 0; + uint8 blue = 0; + }; + + void ControlTransfer(uint8* buf, sint32 originalLength); + + void Activate(); + void Deactivate(); + void SetLeds(uint8 side, uint8 r, uint8 g, uint8 b); + + std::array<uint8, 64> GetStatus(); + void QueryBlock(uint8 skyNum, uint8 block, uint8* replyBuf); + void WriteBlock(uint8 skyNum, uint8 block, const uint8* toWriteBuf, + uint8* replyBuf); + + uint8 LoadSkylander(uint8* buf, std::unique_ptr<FileStream> file); + bool RemoveSkylander(uint8 skyNum); + uint16 SkylanderCRC16(uint16 initValue, const uint8* buffer, uint32 size); + + protected: + std::mutex m_skyMutex; + std::mutex m_queryMutex; + std::array<Skylander, 16> m_skylanders; + + private: + std::queue<std::array<uint8, 64>> m_queries; + bool m_activated = true; + uint8 m_interruptCounter = 0; + SkylanderLEDColor m_colorRight = {}; + SkylanderLEDColor m_colorLeft = {}; + SkylanderLEDColor m_colorTrap = {}; + + }; + extern SkylanderUSB g_skyportal; +} // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index ff5c4f45..c674b844 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -256,6 +256,19 @@ namespace nsyshid device->m_productId); } + bool FindDeviceById(uint16 vendorId, uint16 productId) + { + std::lock_guard<std::recursive_mutex> lock(hidMutex); + for (const auto& device : deviceList) + { + if (device->m_vendorId == vendorId && device->m_productId == productId) + { + return true; + } + } + return false; + } + void export_HIDAddClient(PPCInterpreter_t* hCPU) { ppcDefineParamTypePtr(hidClient, HIDClient_t, 0); @@ -406,7 +419,8 @@ namespace nsyshid sint32 originalLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) { cemuLog_logDebug(LogType::Force, "_hidSetReportAsync begin"); - if (device->SetReport(reportData, length, originalData, originalLength)) + ReportMessage message(reportData, length, originalData, originalLength); + if (device->SetReport(&message)) { DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, @@ -433,7 +447,8 @@ namespace nsyshid { _debugPrintHex("_hidSetReportSync Begin", reportData, length); sint32 returnCode = 0; - if (device->SetReport(reportData, length, originalData, originalLength)) + ReportMessage message(reportData, length, originalData, originalLength); + if (device->SetReport(&message)) { returnCode = originalLength; } @@ -511,17 +526,16 @@ namespace nsyshid return -1; } memset(data, 0, maxLength); - - sint32 bytesRead = 0; - Device::ReadResult readResult = device->Read(data, maxLength, bytesRead); + ReadMessage message(data, maxLength, 0); + Device::ReadResult readResult = device->Read(&message); switch (readResult) { case Device::ReadResult::Success: { cemuLog_logDebug(LogType::Force, "nsyshid.hidReadInternalSync(): read {} of {} bytes", - bytesRead, + message.bytesRead, maxLength); - return bytesRead; + return message.bytesRead; } break; case Device::ReadResult::Error: @@ -609,15 +623,15 @@ namespace nsyshid cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): cannot write to a non-opened device"); return -1; } - sint32 bytesWritten = 0; - Device::WriteResult writeResult = device->Write(data, maxLength, bytesWritten); + WriteMessage message(data, maxLength, 0); + Device::WriteResult writeResult = device->Write(&message); switch (writeResult) { case Device::WriteResult::Success: { - cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): wrote {} of {} bytes", bytesWritten, + cemuLog_logDebug(LogType::Force, "nsyshid.hidWriteInternalSync(): wrote {} of {} bytes", message.bytesWritten, maxLength); - return bytesWritten; + return message.bytesWritten; } break; case Device::WriteResult::Error: @@ -758,6 +772,11 @@ namespace nsyshid return nullptr; } + bool Backend::FindDeviceById(uint16 vendorId, uint16 productId) + { + return nsyshid::FindDeviceById(vendorId, productId); + } + bool Backend::IsDeviceWhitelisted(uint16 vendorId, uint16 productId) { return Whitelist::GetInstance().IsDeviceWhitelisted(vendorId, productId); diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 4f1736e2..8e7cf398 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -358,6 +358,10 @@ void CemuConfig::Load(XMLConfigParser& parser) auto dsuc = input.get("DSUC"); dsu_client.host = dsuc.get_attribute("host", dsu_client.host); dsu_client.port = dsuc.get_attribute("port", dsu_client.port); + + // emulatedusbdevices + auto usbdevices = parser.get("EmulatedUsbDevices"); + emulated_usb_devices.emulate_skylander_portal = usbdevices.get("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal); } void CemuConfig::Save(XMLConfigParser& parser) @@ -551,6 +555,10 @@ void CemuConfig::Save(XMLConfigParser& parser) auto dsuc = input.set("DSUC"); dsuc.set_attribute("host", dsu_client.host); dsuc.set_attribute("port", dsu_client.port); + + // emulated usb devices + auto usbdevices = config.set("EmulatedUsbDevices"); + usbdevices.set("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal.GetValue()); } GameEntry* CemuConfig::GetGameEntryByTitleId(uint64 titleId) diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index cab7a1af..d0776d2e 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -514,6 +514,12 @@ struct CemuConfig NetworkService GetAccountNetworkService(uint32 persistentId); void SetAccountSelectedService(uint32 persistentId, NetworkService serviceIndex); + + // emulated usb devices + struct + { + ConfigValue<bool> emulate_skylander_portal{false}; + }emulated_usb_devices{}; private: GameEntry* GetGameEntryByTitleId(uint64 titleId); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 19ce95dc..02f96a9c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -101,6 +101,8 @@ add_library(CemuGui PairingDialog.h TitleManager.cpp TitleManager.h + EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp + EmulatedUSBDevices/EmulatedUSBDeviceFrame.h windows/PPCThreadsViewer windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp windows/PPCThreadsViewer/DebugPPCThreadsWindow.h diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp new file mode 100644 index 00000000..58c1823c --- /dev/null +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -0,0 +1,354 @@ +#include "gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h" + +#include <algorithm> +#include <random> + +#include "config/CemuConfig.h" +#include "gui/helpers/wxHelpers.h" +#include "gui/wxHelper.h" +#include "util/helpers/helpers.h" + +#include "Cafe/OS/libs/nsyshid/nsyshid.h" +#include "Cafe/OS/libs/nsyshid/Skylander.h" + +#include "Common/FileStream.h" + +#include <wx/arrstr.h> +#include <wx/button.h> +#include <wx/checkbox.h> +#include <wx/combobox.h> +#include <wx/filedlg.h> +#include <wx/msgdlg.h> +#include <wx/notebook.h> +#include <wx/panel.h> +#include <wx/sizer.h> +#include <wx/statbox.h> +#include <wx/stattext.h> +#include <wx/stream.h> +#include <wx/textctrl.h> +#include <wx/textentry.h> +#include <wx/valnum.h> +#include <wx/wfstream.h> + +#include "resource/embedded/resources.h" +#include "EmulatedUSBDeviceFrame.h" + +EmulatedUSBDeviceFrame::EmulatedUSBDeviceFrame(wxWindow* parent) + : wxFrame(parent, wxID_ANY, _("Emulated USB Devices"), wxDefaultPosition, + wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) +{ + SetIcon(wxICON(X_BOX)); + + auto& config = GetConfig(); + + auto* sizer = new wxBoxSizer(wxVERTICAL); + auto* notebook = new wxNotebook(this, wxID_ANY); + + notebook->AddPage(AddSkylanderPage(notebook), _("Skylanders Portal")); + + sizer->Add(notebook, 1, wxEXPAND | wxALL, 2); + + SetSizerAndFit(sizer); + Layout(); + Centre(wxBOTH); +} + +EmulatedUSBDeviceFrame::~EmulatedUSBDeviceFrame() {} + +wxPanel* EmulatedUSBDeviceFrame::AddSkylanderPage(wxNotebook* notebook) +{ + auto* panel = new wxPanel(notebook); + auto* panelSizer = new wxBoxSizer(wxVERTICAL); + auto* box = new wxStaticBox(panel, wxID_ANY, _("Skylanders Manager")); + auto* boxSizer = new wxStaticBoxSizer(box, wxVERTICAL); + + auto* row = new wxBoxSizer(wxHORIZONTAL); + + m_emulatePortal = + new wxCheckBox(box, wxID_ANY, _("Emulate Skylander Portal")); + m_emulatePortal->SetValue( + GetConfig().emulated_usb_devices.emulate_skylander_portal); + m_emulatePortal->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { + GetConfig().emulated_usb_devices.emulate_skylander_portal = + m_emulatePortal->IsChecked(); + g_config.Save(); + }); + row->Add(m_emulatePortal, 1, wxEXPAND | wxALL, 2); + boxSizer->Add(row, 1, wxEXPAND | wxALL, 2); + for (int i = 0; i < 16; i++) + { + boxSizer->Add(AddSkylanderRow(i, box), 1, wxEXPAND | wxALL, 2); + } + panelSizer->Add(boxSizer, 1, wxEXPAND | wxALL, 2); + panel->SetSizerAndFit(panelSizer); + + return panel; +} + +wxBoxSizer* EmulatedUSBDeviceFrame::AddSkylanderRow(uint8 row_number, + wxStaticBox* box) +{ + auto* row = new wxBoxSizer(wxHORIZONTAL); + + row->Add(new wxStaticText(box, wxID_ANY, + fmt::format("{} {}", _("Skylander").ToStdString(), + (row_number + 1))), + 1, wxEXPAND | wxALL, 2); + m_skylanderSlots[row_number] = + new wxTextCtrl(box, wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, + wxTE_READONLY); + m_skylanderSlots[row_number]->SetMinSize(wxSize(150, -1)); + m_skylanderSlots[row_number]->Disable(); + row->Add(m_skylanderSlots[row_number], 1, wxEXPAND | wxALL, 2); + auto* loadButton = new wxButton(box, wxID_ANY, _("Load")); + loadButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { + LoadSkylander(row_number); + }); + auto* createButton = new wxButton(box, wxID_ANY, _("Create")); + createButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { + CreateSkylander(row_number); + }); + auto* clearButton = new wxButton(box, wxID_ANY, _("Clear")); + clearButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { + ClearSkylander(row_number); + }); + row->Add(loadButton, 1, wxEXPAND | wxALL, 2); + row->Add(createButton, 1, wxEXPAND | wxALL, 2); + row->Add(clearButton, 1, wxEXPAND | wxALL, 2); + + return row; +} + +void EmulatedUSBDeviceFrame::LoadSkylander(uint8 slot) +{ + wxFileDialog openFileDialog(this, _("Open Skylander dump"), "", "", + "Skylander files (*.sky;*.bin;*.dump;*.dmp)|*.sky;*.bin;*.dump;*.dmp", + wxFD_OPEN | wxFD_FILE_MUST_EXIST); + if (openFileDialog.ShowModal() != wxID_OK || openFileDialog.GetPath().empty()) + return; + + LoadSkylanderPath(slot, openFileDialog.GetPath()); +} + +void EmulatedUSBDeviceFrame::LoadSkylanderPath(uint8 slot, wxString path) +{ + std::unique_ptr<FileStream> skyFile(FileStream::openFile2(_utf8ToPath(path.utf8_string()), true)); + if (!skyFile) + { + wxMessageDialog open_error(this, "Error Opening File: " + path.c_str()); + open_error.ShowModal(); + return; + } + + std::array<uint8, 0x40 * 0x10> fileData; + if (skyFile->readData(fileData.data(), fileData.size()) != fileData.size()) + { + wxMessageDialog open_error(this, "Failed to read file! File was too small"); + open_error.ShowModal(); + return; + } + ClearSkylander(slot); + + uint16 skyId = uint16(fileData[0x11]) << 8 | uint16(fileData[0x10]); + uint16 skyVar = uint16(fileData[0x1D]) << 8 | uint16(fileData[0x1C]); + + uint8 portalSlot = nsyshid::g_skyportal.LoadSkylander(fileData.data(), + std::move(skyFile)); + m_skySlots[slot] = std::tuple(portalSlot, skyId, skyVar); + UpdateSkylanderEdits(); +} + +void EmulatedUSBDeviceFrame::CreateSkylander(uint8 slot) +{ + CreateSkylanderDialog create_dlg(this, slot); + create_dlg.ShowModal(); + if (create_dlg.GetReturnCode() == 1) + { + LoadSkylanderPath(slot, create_dlg.GetFilePath()); + } +} + +void EmulatedUSBDeviceFrame::ClearSkylander(uint8 slot) +{ + if (auto slotInfos = m_skySlots[slot]) + { + auto [curSlot, id, var] = slotInfos.value(); + nsyshid::g_skyportal.RemoveSkylander(curSlot); + m_skySlots[slot] = {}; + UpdateSkylanderEdits(); + } +} + +CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) + : wxDialog(parent, wxID_ANY, _("Skylander Figure Creator"), wxDefaultPosition, wxSize(500, 150)) +{ + auto* sizer = new wxBoxSizer(wxVERTICAL); + + auto* comboRow = new wxBoxSizer(wxHORIZONTAL); + + auto* comboBox = new wxComboBox(this, wxID_ANY); + comboBox->Append("---Select---", reinterpret_cast<void*>(0xFFFFFFFF)); + wxArrayString filterlist; + for (auto it = nsyshid::listSkylanders.begin(); it != nsyshid::listSkylanders.end(); it++) + { + const uint32 variant = uint32(uint32(it->first.first) << 16) | uint32(it->first.second); + comboBox->Append(it->second, reinterpret_cast<void*>(variant)); + filterlist.Add(it->second); + } + comboBox->SetSelection(0); + bool enabled = comboBox->AutoComplete(filterlist); + comboRow->Add(comboBox, 1, wxEXPAND | wxALL, 2); + + auto* idVarRow = new wxBoxSizer(wxHORIZONTAL); + + wxIntegerValidator<uint32> validator; + + auto* labelId = new wxStaticText(this, wxID_ANY, "ID:"); + auto* labelVar = new wxStaticText(this, wxID_ANY, "Variant:"); + auto* editId = new wxTextCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0, validator); + auto* editVar = new wxTextCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0, validator); + + idVarRow->Add(labelId, 1, wxALL, 5); + idVarRow->Add(editId, 1, wxALL, 5); + idVarRow->Add(labelVar, 1, wxALL, 5); + idVarRow->Add(editVar, 1, wxALL, 5); + + auto* buttonRow = new wxBoxSizer(wxHORIZONTAL); + + auto* createButton = new wxButton(this, wxID_ANY, _("Create")); + createButton->Bind(wxEVT_BUTTON, [editId, editVar, this](wxCommandEvent&) { + long longSkyId; + if (!editId->GetValue().ToLong(&longSkyId) || longSkyId > 0xFFFF) + { + wxMessageDialog id_error(this, "Error Converting ID!", "ID Entered is Invalid"); + id_error.ShowModal(); + return; + } + long longSkyVar; + if (!editVar->GetValue().ToLong(&longSkyVar) || longSkyVar > 0xFFFF) + { + wxMessageDialog id_error(this, "Error Converting Variant!", "Variant Entered is Invalid"); + id_error.ShowModal(); + return; + } + uint16 skyId = longSkyId & 0xFFFF; + uint16 skyVar = longSkyVar & 0xFFFF; + const auto foundSky = nsyshid::listSkylanders.find(std::make_pair(skyId, skyVar)); + wxString predefName; + if (foundSky != nsyshid::listSkylanders.end()) + { + predefName = foundSky->second + ".sky"; + } + else + { + predefName = wxString::Format(_("Unknown(%i %i).sky"), skyId, skyVar); + } + wxFileDialog + saveFileDialog(this, _("Create Skylander file"), "", predefName, + "SKY files (*.sky)|*.sky", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + + if (saveFileDialog.ShowModal() == wxID_CANCEL) + return; + + m_filePath = saveFileDialog.GetPath(); + + wxFileOutputStream output_stream(saveFileDialog.GetPath()); + if (!output_stream.IsOk()) + { + wxMessageDialog saveError(this, "Error Creating Skylander File"); + return; + } + + std::array<uint8, 0x40 * 0x10> data{}; + + uint32 first_block = 0x690F0F0F; + uint32 other_blocks = 0x69080F7F; + memcpy(&data[0x36], &first_block, sizeof(first_block)); + for (size_t index = 1; index < 0x10; index++) + { + memcpy(&data[(index * 0x40) + 0x36], &other_blocks, sizeof(other_blocks)); + } + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution<int> dist(0, 255); + data[0] = dist(mt); + data[1] = dist(mt); + data[2] = dist(mt); + data[3] = dist(mt); + data[4] = data[0] ^ data[1] ^ data[2] ^ data[3]; + data[5] = 0x81; + data[6] = 0x01; + data[7] = 0x0F; + + memcpy(&data[0x10], &skyId, sizeof(skyId)); + memcpy(&data[0x1C], &skyVar, sizeof(skyVar)); + + uint16 crc = nsyshid::g_skyportal.SkylanderCRC16(0xFFFF, data.data(), 0x1E); + + memcpy(&data[0x1E], &crc, sizeof(crc)); + + output_stream.SeekO(0); + output_stream.WriteAll(data.data(), data.size()); + output_stream.Close(); + + this->EndModal(1); + }); + auto* cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); + cancelButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { + this->EndModal(0); + }); + + comboBox->Bind(wxEVT_COMBOBOX, [comboBox, editId, editVar, this](wxCommandEvent&) { + const uint64 sky_info = reinterpret_cast<uint64>(comboBox->GetClientData(comboBox->GetSelection())); + if (sky_info != 0xFFFFFFFF) + { + const uint16 skyId = sky_info >> 16; + const uint16 skyVar = sky_info & 0xFFFF; + + editId->SetValue(wxString::Format(wxT("%i"), skyId)); + editVar->SetValue(wxString::Format(wxT("%i"), skyVar)); + } + }); + + buttonRow->Add(createButton, 1, wxALL, 5); + buttonRow->Add(cancelButton, 1, wxALL, 5); + + sizer->Add(comboRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(idVarRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(buttonRow, 1, wxEXPAND | wxALL, 2); + + this->SetSizer(sizer); + this->Centre(wxBOTH); +} + +wxString CreateSkylanderDialog::GetFilePath() const +{ + return m_filePath; +} + +void EmulatedUSBDeviceFrame::UpdateSkylanderEdits() +{ + for (auto i = 0; i < 16; i++) + { + std::string displayString; + if (auto sd = m_skySlots[i]) + { + auto [portalSlot, skyId, skyVar] = sd.value(); + auto foundSky = nsyshid::listSkylanders.find(std::make_pair(skyId, skyVar)); + if (foundSky != nsyshid::listSkylanders.end()) + { + displayString = foundSky->second; + } + else + { + displayString = fmt::format("Unknown (Id:{} Var:{})", skyId, skyVar); + } + } + else + { + displayString = "None"; + } + + m_skylanderSlots[i]->ChangeValue(displayString); + } +} \ No newline at end of file diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h new file mode 100644 index 00000000..6acb7da8 --- /dev/null +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h @@ -0,0 +1,42 @@ +#pragma once + +#include <array> + +#include <wx/dialog.h> +#include <wx/frame.h> + +class wxBoxSizer; +class wxCheckBox; +class wxFlexGridSizer; +class wxNotebook; +class wxPanel; +class wxStaticBox; +class wxString; +class wxTextCtrl; + +class EmulatedUSBDeviceFrame : public wxFrame { + public: + EmulatedUSBDeviceFrame(wxWindow* parent); + ~EmulatedUSBDeviceFrame(); + + private: + wxCheckBox* m_emulatePortal; + std::array<wxTextCtrl*, 16> m_skylanderSlots; + std::array<std::optional<std::tuple<uint8, uint16, uint16>>, 16> m_skySlots; + + wxPanel* AddSkylanderPage(wxNotebook* notebook); + wxBoxSizer* AddSkylanderRow(uint8 row_number, wxStaticBox* box); + void LoadSkylander(uint8 slot); + void LoadSkylanderPath(uint8 slot, wxString path); + void CreateSkylander(uint8 slot); + void ClearSkylander(uint8 slot); + void UpdateSkylanderEdits(); +}; +class CreateSkylanderDialog : public wxDialog { + public: + explicit CreateSkylanderDialog(wxWindow* parent, uint8 slot); + wxString GetFilePath() const; + + protected: + wxString m_filePath; +}; \ No newline at end of file diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 03c69a7f..7a4f3174 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -30,6 +30,7 @@ #include "Cafe/Filesystem/FST/FST.h" #include "gui/TitleManager.h" +#include "gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h" #include "Cafe/CafeSystem.h" @@ -110,6 +111,7 @@ enum MAINFRAME_MENU_ID_TOOLS_MEMORY_SEARCHER = 20600, MAINFRAME_MENU_ID_TOOLS_TITLE_MANAGER, MAINFRAME_MENU_ID_TOOLS_DOWNLOAD_MANAGER, + MAINFRAME_MENU_ID_TOOLS_EMULATED_USB_DEVICES, // cpu // cpu->timer speed MAINFRAME_MENU_ID_TIMER_SPEED_1X = 20700, @@ -188,6 +190,7 @@ EVT_MENU(MAINFRAME_MENU_ID_OPTIONS_INPUT, MainWindow::OnOptionsInput) EVT_MENU(MAINFRAME_MENU_ID_TOOLS_MEMORY_SEARCHER, MainWindow::OnToolsInput) EVT_MENU(MAINFRAME_MENU_ID_TOOLS_TITLE_MANAGER, MainWindow::OnToolsInput) EVT_MENU(MAINFRAME_MENU_ID_TOOLS_DOWNLOAD_MANAGER, MainWindow::OnToolsInput) +EVT_MENU(MAINFRAME_MENU_ID_TOOLS_EMULATED_USB_DEVICES, MainWindow::OnToolsInput) // cpu menu EVT_MENU(MAINFRAME_MENU_ID_TIMER_SPEED_8X, MainWindow::OnDebugSetting) EVT_MENU(MAINFRAME_MENU_ID_TIMER_SPEED_4X, MainWindow::OnDebugSetting) @@ -1515,6 +1518,29 @@ void MainWindow::OnToolsInput(wxCommandEvent& event) }); m_title_manager->Show(); } + break; + } + case MAINFRAME_MENU_ID_TOOLS_EMULATED_USB_DEVICES: + { + if (m_usb_devices) + { + m_usb_devices->Show(true); + m_usb_devices->Raise(); + m_usb_devices->SetFocus(); + } + else + { + m_usb_devices = new EmulatedUSBDeviceFrame(this); + m_usb_devices->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) + { + if (event.CanVeto()) { + m_usb_devices->Show(false); + event.Veto(); + } + }); + m_usb_devices->Show(true); + } + break; } break; } @@ -2166,6 +2192,7 @@ void MainWindow::RecreateMenu() m_memorySearcherMenuItem->Enable(false); toolsMenu->Append(MAINFRAME_MENU_ID_TOOLS_TITLE_MANAGER, _("&Title Manager")); toolsMenu->Append(MAINFRAME_MENU_ID_TOOLS_DOWNLOAD_MANAGER, _("&Download Manager")); + toolsMenu->Append(MAINFRAME_MENU_ID_TOOLS_EMULATED_USB_DEVICES, _("&Emulated USB Devices")); m_menuBar->Append(toolsMenu, _("&Tools")); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 7191df12..dd4d0d0d 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -22,6 +22,7 @@ struct GameEntry; class DiscordPresence; class TitleManager; class GraphicPacksWindow2; +class EmulatedUSBDeviceFrame; class wxLaunchGameEvent; wxDECLARE_EVENT(wxEVT_LAUNCH_GAME, wxLaunchGameEvent); @@ -164,6 +165,7 @@ private: MemorySearcherTool* m_toolWindow = nullptr; TitleManager* m_title_manager = nullptr; + EmulatedUSBDeviceFrame* m_usb_devices = nullptr; PadViewFrame* m_padView = nullptr; GraphicPacksWindow2* m_graphic_pack_window = nullptr; From aefbb918beb8718af8f190a73018ff63bf801d95 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Fri, 28 Jun 2024 14:44:49 +0100 Subject: [PATCH 207/314] nsyshid: Skylander emulation fixes and code cleanup (#1244) --- src/Cafe/OS/libs/nsyshid/Skylander.cpp | 79 +++++++++++++++++-- src/Cafe/OS/libs/nsyshid/Skylander.h | 17 ++-- .../EmulatedUSBDeviceFrame.cpp | 78 ++++-------------- .../EmulatedUSBDeviceFrame.h | 6 +- 4 files changed, 101 insertions(+), 79 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp index 3123d14d..241e1969 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.cpp +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -1,5 +1,7 @@ #include "Skylander.h" +#include <random> + #include "nsyshid.h" #include "Backend.h" @@ -9,8 +11,8 @@ namespace nsyshid { SkylanderUSB g_skyportal; - const std::map<const std::pair<const uint16, const uint16>, const std::string> - listSkylanders = { + const std::map<const std::pair<const uint16, const uint16>, const char*> + s_listSkylanders = { {{0, 0x0000}, "Whirlwind"}, {{0, 0x1801}, "Series 2 Whirlwind"}, {{0, 0x1C02}, "Polar Whirlwind"}, @@ -845,6 +847,49 @@ namespace nsyshid return false; } + bool SkylanderUSB::CreateSkylander(fs::path pathName, uint16 skyId, uint16 skyVar) + { + FileStream* skyFile(FileStream::createFile2(pathName)); + if (!skyFile) + { + return false; + } + + std::array<uint8, BLOCK_COUNT * BLOCK_SIZE> data{}; + + uint32 first_block = 0x690F0F0F; + uint32 other_blocks = 0x69080F7F; + memcpy(&data[0x36], &first_block, sizeof(first_block)); + for (size_t index = 1; index < 0x10; index++) + { + memcpy(&data[(index * 0x40) + 0x36], &other_blocks, sizeof(other_blocks)); + } + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution<int> dist(0, 255); + data[0] = dist(mt); + data[1] = dist(mt); + data[2] = dist(mt); + data[3] = dist(mt); + data[4] = data[0] ^ data[1] ^ data[2] ^ data[3]; + data[5] = 0x81; + data[6] = 0x01; + data[7] = 0x0F; + + memcpy(&data[0x10], &skyId, sizeof(skyId)); + memcpy(&data[0x1C], &skyVar, sizeof(skyVar)); + + uint16 crc = nsyshid::g_skyportal.SkylanderCRC16(0xFFFF, data.data(), 0x1E); + + memcpy(&data[0x1E], &crc, sizeof(crc)); + + skyFile->writeData(data.data(), data.size()); + + delete skyFile; + + return true; + } + void SkylanderUSB::QueryBlock(uint8 skyNum, uint8 block, uint8* replyBuf) { std::lock_guard lock(m_skyMutex); @@ -865,7 +910,7 @@ namespace nsyshid } void SkylanderUSB::WriteBlock(uint8 skyNum, uint8 block, - const uint8* toWriteBuf, uint8* replyBuf) + const uint8* toWriteBuf, uint8* replyBuf) { std::lock_guard lock(m_skyMutex); @@ -919,21 +964,39 @@ namespace nsyshid status |= s.status; } interruptResponse = {0x53, 0x00, 0x00, 0x00, 0x00, m_interruptCounter++, - active, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00}; + active, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00}; memcpy(&interruptResponse[1], &status, sizeof(status)); } return interruptResponse; } + std::string SkylanderUSB::FindSkylander(uint16 skyId, uint16 skyVar) + { + for (const auto& it : GetListSkylanders()) + { + if(it.first.first == skyId && it.first.second == skyVar) + { + return it.second; + } + } + return fmt::format("Unknown ({} {})", skyId, skyVar); + } + + std::map<const std::pair<const uint16, const uint16>, const char*> SkylanderUSB::GetListSkylanders() + { + return s_listSkylanders; + } + void SkylanderUSB::Skylander::Save() { if (!skyFile) return; + skyFile->SetPosition(0); skyFile->writeData(data.data(), data.size()); } } // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h index dfa370dc..a1ca7f8f 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.h +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -1,3 +1,5 @@ +#pragma once + #include <mutex> #include "nsyshid.h" @@ -36,7 +38,10 @@ namespace nsyshid bool m_IsOpened; }; - extern const std::map<const std::pair<const uint16, const uint16>, const std::string> listSkylanders; + constexpr uint16 BLOCK_COUNT = 0x40; + constexpr uint16 BLOCK_SIZE = 0x10; + constexpr uint16 FIGURE_SIZE = BLOCK_COUNT * BLOCK_SIZE; + constexpr uint8 MAX_SKYLANDERS = 16; class SkylanderUSB { public: @@ -45,7 +50,7 @@ namespace nsyshid std::unique_ptr<FileStream> skyFile; uint8 status = 0; std::queue<uint8> queuedStatus; - std::array<uint8, 0x40 * 0x10> data{}; + std::array<uint8, BLOCK_COUNT * BLOCK_SIZE> data{}; uint32 lastId = 0; void Save(); @@ -74,16 +79,19 @@ namespace nsyshid std::array<uint8, 64> GetStatus(); void QueryBlock(uint8 skyNum, uint8 block, uint8* replyBuf); void WriteBlock(uint8 skyNum, uint8 block, const uint8* toWriteBuf, - uint8* replyBuf); + uint8* replyBuf); uint8 LoadSkylander(uint8* buf, std::unique_ptr<FileStream> file); bool RemoveSkylander(uint8 skyNum); + bool CreateSkylander(fs::path pathName, uint16 skyId, uint16 skyVar); uint16 SkylanderCRC16(uint16 initValue, const uint8* buffer, uint32 size); + static std::map<const std::pair<const uint16, const uint16>, const char*> GetListSkylanders(); + std::string FindSkylander(uint16 skyId, uint16 skyVar); protected: std::mutex m_skyMutex; std::mutex m_queryMutex; - std::array<Skylander, 16> m_skylanders; + std::array<Skylander, MAX_SKYLANDERS> m_skylanders; private: std::queue<std::array<uint8, 64>> m_queries; @@ -92,7 +100,6 @@ namespace nsyshid SkylanderLEDColor m_colorRight = {}; SkylanderLEDColor m_colorLeft = {}; SkylanderLEDColor m_colorTrap = {}; - }; extern SkylanderUSB g_skyportal; } // namespace nsyshid \ No newline at end of file diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp index 58c1823c..f43c3690 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -1,7 +1,6 @@ #include "gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h" #include <algorithm> -#include <random> #include "config/CemuConfig.h" #include "gui/helpers/wxHelpers.h" @@ -9,7 +8,6 @@ #include "util/helpers/helpers.h" #include "Cafe/OS/libs/nsyshid/nsyshid.h" -#include "Cafe/OS/libs/nsyshid/Skylander.h" #include "Common/FileStream.h" @@ -75,7 +73,7 @@ wxPanel* EmulatedUSBDeviceFrame::AddSkylanderPage(wxNotebook* notebook) }); row->Add(m_emulatePortal, 1, wxEXPAND | wxALL, 2); boxSizer->Add(row, 1, wxEXPAND | wxALL, 2); - for (int i = 0; i < 16; i++) + for (int i = 0; i < nsyshid::MAX_SKYLANDERS; i++) { boxSizer->Add(AddSkylanderRow(i, box), 1, wxEXPAND | wxALL, 2); } @@ -153,7 +151,7 @@ void EmulatedUSBDeviceFrame::LoadSkylanderPath(uint8 slot, wxString path) uint16 skyVar = uint16(fileData[0x1D]) << 8 | uint16(fileData[0x1C]); uint8 portalSlot = nsyshid::g_skyportal.LoadSkylander(fileData.data(), - std::move(skyFile)); + std::move(skyFile)); m_skySlots[slot] = std::tuple(portalSlot, skyId, skyVar); UpdateSkylanderEdits(); } @@ -189,11 +187,11 @@ CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) auto* comboBox = new wxComboBox(this, wxID_ANY); comboBox->Append("---Select---", reinterpret_cast<void*>(0xFFFFFFFF)); wxArrayString filterlist; - for (auto it = nsyshid::listSkylanders.begin(); it != nsyshid::listSkylanders.end(); it++) + for (const auto& it : nsyshid::g_skyportal.GetListSkylanders()) { - const uint32 variant = uint32(uint32(it->first.first) << 16) | uint32(it->first.second); - comboBox->Append(it->second, reinterpret_cast<void*>(variant)); - filterlist.Add(it->second); + const uint32 variant = uint32(uint32(it.first.first) << 16) | uint32(it.first.second); + comboBox->Append(it.second, reinterpret_cast<void*>(variant)); + filterlist.Add(it.second); } comboBox->SetSelection(0); bool enabled = comboBox->AutoComplete(filterlist); @@ -233,16 +231,7 @@ CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) } uint16 skyId = longSkyId & 0xFFFF; uint16 skyVar = longSkyVar & 0xFFFF; - const auto foundSky = nsyshid::listSkylanders.find(std::make_pair(skyId, skyVar)); - wxString predefName; - if (foundSky != nsyshid::listSkylanders.end()) - { - predefName = foundSky->second + ".sky"; - } - else - { - predefName = wxString::Format(_("Unknown(%i %i).sky"), skyId, skyVar); - } + wxString predefName = nsyshid::g_skyportal.FindSkylander(skyId, skyVar) + ".sky"; wxFileDialog saveFileDialog(this, _("Create Skylander file"), "", predefName, "SKY files (*.sky)|*.sky", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); @@ -251,46 +240,15 @@ CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) return; m_filePath = saveFileDialog.GetPath(); - - wxFileOutputStream output_stream(saveFileDialog.GetPath()); - if (!output_stream.IsOk()) + + if(!nsyshid::g_skyportal.CreateSkylander(_utf8ToPath(m_filePath.utf8_string()), skyId, skyVar)) { - wxMessageDialog saveError(this, "Error Creating Skylander File"); + wxMessageDialog errorMessage(this, "Failed to create file"); + errorMessage.ShowModal(); + this->EndModal(0); return; } - std::array<uint8, 0x40 * 0x10> data{}; - - uint32 first_block = 0x690F0F0F; - uint32 other_blocks = 0x69080F7F; - memcpy(&data[0x36], &first_block, sizeof(first_block)); - for (size_t index = 1; index < 0x10; index++) - { - memcpy(&data[(index * 0x40) + 0x36], &other_blocks, sizeof(other_blocks)); - } - std::random_device rd; - std::mt19937 mt(rd()); - std::uniform_int_distribution<int> dist(0, 255); - data[0] = dist(mt); - data[1] = dist(mt); - data[2] = dist(mt); - data[3] = dist(mt); - data[4] = data[0] ^ data[1] ^ data[2] ^ data[3]; - data[5] = 0x81; - data[6] = 0x01; - data[7] = 0x0F; - - memcpy(&data[0x10], &skyId, sizeof(skyId)); - memcpy(&data[0x1C], &skyVar, sizeof(skyVar)); - - uint16 crc = nsyshid::g_skyportal.SkylanderCRC16(0xFFFF, data.data(), 0x1E); - - memcpy(&data[0x1E], &crc, sizeof(crc)); - - output_stream.SeekO(0); - output_stream.WriteAll(data.data(), data.size()); - output_stream.Close(); - this->EndModal(1); }); auto* cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); @@ -328,21 +286,13 @@ wxString CreateSkylanderDialog::GetFilePath() const void EmulatedUSBDeviceFrame::UpdateSkylanderEdits() { - for (auto i = 0; i < 16; i++) + for (auto i = 0; i < nsyshid::MAX_SKYLANDERS; i++) { std::string displayString; if (auto sd = m_skySlots[i]) { auto [portalSlot, skyId, skyVar] = sd.value(); - auto foundSky = nsyshid::listSkylanders.find(std::make_pair(skyId, skyVar)); - if (foundSky != nsyshid::listSkylanders.end()) - { - displayString = foundSky->second; - } - else - { - displayString = fmt::format("Unknown (Id:{} Var:{})", skyId, skyVar); - } + displayString = nsyshid::g_skyportal.FindSkylander(skyId, skyVar); } else { diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h index 6acb7da8..8988cb8a 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h @@ -5,6 +5,8 @@ #include <wx/dialog.h> #include <wx/frame.h> +#include "Cafe/OS/libs/nsyshid/Skylander.h" + class wxBoxSizer; class wxCheckBox; class wxFlexGridSizer; @@ -21,8 +23,8 @@ class EmulatedUSBDeviceFrame : public wxFrame { private: wxCheckBox* m_emulatePortal; - std::array<wxTextCtrl*, 16> m_skylanderSlots; - std::array<std::optional<std::tuple<uint8, uint16, uint16>>, 16> m_skySlots; + std::array<wxTextCtrl*, nsyshid::MAX_SKYLANDERS> m_skylanderSlots; + std::array<std::optional<std::tuple<uint8, uint16, uint16>>, nsyshid::MAX_SKYLANDERS> m_skySlots; wxPanel* AddSkylanderPage(wxNotebook* notebook); wxBoxSizer* AddSkylanderRow(uint8 row_number, wxStaticBox* box); From 64b0b85ed5fe15d17cfa6b5fce0044000b013a07 Mon Sep 17 00:00:00 2001 From: Colin Kinloch <colin@kinlo.ch> Date: Sat, 29 Jun 2024 21:31:47 +0100 Subject: [PATCH 208/314] Create GamePad window at correct size (#1247) Don't change the size on canvas initialization --- src/gui/PadViewFrame.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/PadViewFrame.cpp b/src/gui/PadViewFrame.cpp index f2da2ca7..e7cc5c18 100644 --- a/src/gui/PadViewFrame.cpp +++ b/src/gui/PadViewFrame.cpp @@ -20,18 +20,24 @@ extern WindowInfo g_window_info; +#define PAD_MIN_WIDTH 320 +#define PAD_MIN_HEIGHT 180 + PadViewFrame::PadViewFrame(wxFrame* parent) - : wxFrame(nullptr, wxID_ANY, _("GamePad View"), wxDefaultPosition, wxSize(854, 480), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxCLOSE_BOX | wxWANTS_CHARS) + : wxFrame(nullptr, wxID_ANY, _("GamePad View"), wxDefaultPosition, wxDefaultSize, wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN | wxRESIZE_BORDER | wxCLOSE_BOX | wxWANTS_CHARS) { gui_initHandleContextFromWxWidgetsWindow(g_window_info.window_pad, this); - + SetIcon(wxICON(M_WND_ICON128)); wxWindow::EnableTouchEvents(wxTOUCH_PAN_GESTURES); - SetMinClientSize({ 320, 180 }); + SetMinClientSize({ PAD_MIN_WIDTH, PAD_MIN_HEIGHT }); SetPosition({ g_window_info.restored_pad_x, g_window_info.restored_pad_y }); - SetSize({ g_window_info.restored_pad_width, g_window_info.restored_pad_height }); + if (g_window_info.restored_pad_width >= PAD_MIN_WIDTH && g_window_info.restored_pad_height >= PAD_MIN_HEIGHT) + SetClientSize({ g_window_info.restored_pad_width, g_window_info.restored_pad_height }); + else + SetClientSize(wxSize(854, 480)); if (g_window_info.pad_maximized) Maximize(); @@ -72,7 +78,7 @@ void PadViewFrame::InitializeRenderCanvas() m_render_canvas = GLCanvas_Create(this, wxSize(854, 480), false); sizer->Add(m_render_canvas, 1, wxEXPAND, 0, nullptr); } - SetSizerAndFit(sizer); + SetSizer(sizer); Layout(); m_render_canvas->Bind(wxEVT_KEY_UP, &PadViewFrame::OnKeyUp, this); From 5209677f2fd661949778c071287f5005b57bc8fe Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Tue, 2 Jul 2024 02:32:37 +0100 Subject: [PATCH 209/314] nsyshid: Add SetProtocol and SetReport support for libusb backend (#1243) --- src/Cafe/OS/libs/nsyshid/Backend.h | 2 +- src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 161 +++++++++++++----- src/Cafe/OS/libs/nsyshid/BackendLibusb.h | 15 +- .../OS/libs/nsyshid/BackendWindowsHID.cpp | 2 +- src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h | 2 +- src/Cafe/OS/libs/nsyshid/Skylander.cpp | 2 +- src/Cafe/OS/libs/nsyshid/Skylander.h | 2 +- src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 4 +- 8 files changed, 137 insertions(+), 53 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/Backend.h b/src/Cafe/OS/libs/nsyshid/Backend.h index 03232736..12362773 100644 --- a/src/Cafe/OS/libs/nsyshid/Backend.h +++ b/src/Cafe/OS/libs/nsyshid/Backend.h @@ -135,7 +135,7 @@ namespace nsyshid uint8* output, uint32 outputMaxLength) = 0; - virtual bool SetProtocol(uint32 ifIndef, uint32 protocol) = 0; + virtual bool SetProtocol(uint8 ifIndex, uint8 protocol) = 0; virtual bool SetReport(ReportMessage* message) = 0; }; diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp index 6701d780..7548c998 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -230,6 +230,17 @@ namespace nsyshid::backend::libusb return nullptr; } + std::pair<int, ConfigDescriptor> MakeConfigDescriptor(libusb_device* device, uint8 config_num) + { + libusb_config_descriptor* descriptor = nullptr; + const int ret = libusb_get_config_descriptor(device, config_num, &descriptor); + if (ret == LIBUSB_SUCCESS) + return {ret, ConfigDescriptor{descriptor, libusb_free_config_descriptor}}; + + return {ret, ConfigDescriptor{nullptr, [](auto) { + }}}; + } + std::shared_ptr<Device> BackendLibusb::CheckAndCreateDevice(libusb_device* dev) { struct libusb_device_descriptor desc; @@ -241,6 +252,25 @@ namespace nsyshid::backend::libusb ret); return nullptr; } + std::vector<ConfigDescriptor> config_descriptors{}; + for (uint8 i = 0; i < desc.bNumConfigurations; ++i) + { + auto [ret, config_descriptor] = MakeConfigDescriptor(dev, i); + if (ret != LIBUSB_SUCCESS || !config_descriptor) + { + cemuLog_log(LogType::Force, "Failed to make config descriptor {} for {:04x}:{:04x}: {}", + i, desc.idVendor, desc.idProduct, libusb_error_name(ret)); + } + else + { + config_descriptors.emplace_back(std::move(config_descriptor)); + } + } + if (desc.idVendor == 0x0e6f && desc.idProduct == 0x0241) + { + cemuLog_logDebug(LogType::Force, + "nsyshid::BackendLibusb::CheckAndCreateDevice(): lego dimensions portal detected"); + } auto device = std::make_shared<DeviceLibusb>(m_ctx, desc.idVendor, desc.idProduct, @@ -248,7 +278,8 @@ namespace nsyshid::backend::libusb 2, 0, libusb_get_bus_number(dev), - libusb_get_device_address(dev)); + libusb_get_device_address(dev), + std::move(config_descriptors)); // figure out device endpoints if (!FindDefaultDeviceEndpoints(dev, device->m_libusbHasEndpointIn, @@ -330,7 +361,8 @@ namespace nsyshid::backend::libusb uint8 interfaceSubClass, uint8 protocol, uint8 libusbBusNumber, - uint8 libusbDeviceAddress) + uint8 libusbDeviceAddress, + std::vector<ConfigDescriptor> configs) : Device(vendorId, productId, interfaceIndex, @@ -346,6 +378,7 @@ namespace nsyshid::backend::libusb m_libusbHasEndpointOut(false), m_libusbEndpointOut(0) { + m_config_descriptors = std::move(configs); } DeviceLibusb::~DeviceLibusb() @@ -413,20 +446,8 @@ namespace nsyshid::backend::libusb } this->m_handleInUseCounter = 0; } - if (libusb_kernel_driver_active(this->m_libusbHandle, 0) == 1) { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): kernel driver active"); - if (libusb_detach_kernel_driver(this->m_libusbHandle, 0) == 0) - { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): kernel driver detached"); - } - else - { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): failed to detach kernel driver"); - } - } - { - int ret = libusb_claim_interface(this->m_libusbHandle, 0); + int ret = ClaimAllInterfaces(0); if (ret != 0) { cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): cannot claim interface"); @@ -680,7 +701,65 @@ namespace nsyshid::backend::libusb return false; } - bool DeviceLibusb::SetProtocol(uint32 ifIndex, uint32 protocol) + template<typename Configs, typename Function> + static int DoForEachInterface(const Configs& configs, uint8 config_num, Function action) + { + int ret = LIBUSB_ERROR_NOT_FOUND; + if (configs.size() <= config_num || !configs[config_num]) + return ret; + for (uint8 i = 0; i < configs[config_num]->bNumInterfaces; ++i) + { + ret = action(i); + if (ret < LIBUSB_SUCCESS) + break; + } + return ret; + } + + int DeviceLibusb::ClaimAllInterfaces(uint8 config_num) + { + const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](uint8 i) { + if (libusb_kernel_driver_active(this->m_libusbHandle, i)) + { + const int ret2 = libusb_detach_kernel_driver(this->m_libusbHandle, i); + if (ret2 < LIBUSB_SUCCESS && ret2 != LIBUSB_ERROR_NOT_FOUND && + ret2 != LIBUSB_ERROR_NOT_SUPPORTED) + { + cemuLog_log(LogType::Force, "Failed to detach kernel driver {}", libusb_error_name(ret2)); + return ret2; + } + } + return libusb_claim_interface(this->m_libusbHandle, i); + }); + if (ret < LIBUSB_SUCCESS) + { + cemuLog_log(LogType::Force, "Failed to release all interfaces for config {}", config_num); + } + return ret; + } + + int DeviceLibusb::ReleaseAllInterfaces(uint8 config_num) + { + const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](uint8 i) { + return libusb_release_interface(AquireHandleLock()->GetHandle(), i); + }); + if (ret < LIBUSB_SUCCESS && ret != LIBUSB_ERROR_NO_DEVICE && ret != LIBUSB_ERROR_NOT_FOUND) + { + cemuLog_log(LogType::Force, "Failed to release all interfaces for config {}", config_num); + } + return ret; + } + + int DeviceLibusb::ReleaseAllInterfacesForCurrentConfig() + { + int config_num; + const int get_config_ret = libusb_get_configuration(AquireHandleLock()->GetHandle(), &config_num); + if (get_config_ret < LIBUSB_SUCCESS) + return get_config_ret; + return ReleaseAllInterfaces(config_num); + } + + bool DeviceLibusb::SetProtocol(uint8 ifIndex, uint8 protocol) { auto handleLock = AquireHandleLock(); if (!handleLock->IsValid()) @@ -688,24 +767,18 @@ namespace nsyshid::backend::libusb cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetProtocol(): device is not opened"); return false; } + if (m_interfaceIndex != ifIndex) + m_interfaceIndex = ifIndex; - // ToDo: implement this -#if 0 - // is this correct? Discarding "ifIndex" seems like a bad idea - int ret = libusb_set_configuration(handleLock->getHandle(), protocol); - if (ret == 0) { - cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::setProtocol(): success"); + ReleaseAllInterfacesForCurrentConfig(); + int ret = libusb_set_configuration(AquireHandleLock()->GetHandle(), protocol); + if (ret == LIBUSB_SUCCESS) + ret = ClaimAllInterfaces(protocol); + + if (ret == LIBUSB_SUCCESS) return true; - } - cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::setProtocol(): failed with error code: {}", - ret); - return false; -#endif - // pretend that everything is fine - return true; + return false; } bool DeviceLibusb::SetReport(ReportMessage* message) @@ -717,20 +790,20 @@ namespace nsyshid::backend::libusb return false; } - // ToDo: implement this -#if 0 - // not sure if libusb_control_transfer() is the right candidate for this - int ret = libusb_control_transfer(handleLock->getHandle(), - bmRequestType, - bRequest, - wValue, - wIndex, - message->reportData, - message->length, - timeout); -#endif + int ret = libusb_control_transfer(handleLock->GetHandle(), + LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT, + LIBUSB_REQUEST_SET_CONFIGURATION, + 512, + 0, + message->originalData, + message->originalLength, + 0); - // pretend that everything is fine + if (ret != message->originalLength) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): Control Transfer Failed: {}", libusb_error_name(ret)); + return false; + } return true; } diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h index a8122aff..a7b23769 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h @@ -44,6 +44,11 @@ namespace nsyshid::backend::libusb bool& endpointOutFound, uint8& endpointOut, uint16& endpointOutMaxPacketSize); }; + template<typename T> + using UniquePtr = std::unique_ptr<T, void (*)(T*)>; + + using ConfigDescriptor = UniquePtr<libusb_config_descriptor>; + class DeviceLibusb : public nsyshid::Device { public: DeviceLibusb(libusb_context* ctx, @@ -53,7 +58,8 @@ namespace nsyshid::backend::libusb uint8 interfaceSubClass, uint8 protocol, uint8 libusbBusNumber, - uint8 libusbDeviceAddress); + uint8 libusbDeviceAddress, + std::vector<ConfigDescriptor> configs); ~DeviceLibusb() override; @@ -73,7 +79,11 @@ namespace nsyshid::backend::libusb uint8* output, uint32 outputMaxLength) override; - bool SetProtocol(uint32 ifIndex, uint32 protocol) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; + + int ClaimAllInterfaces(uint8 config_num); + int ReleaseAllInterfaces(uint8 config_num); + int ReleaseAllInterfacesForCurrentConfig(); bool SetReport(ReportMessage* message) override; @@ -92,6 +102,7 @@ namespace nsyshid::backend::libusb std::atomic<sint32> m_handleInUseCounter; std::condition_variable m_handleInUseCounterDecremented; libusb_device_handle* m_libusbHandle; + std::vector<ConfigDescriptor> m_config_descriptors; class HandleLock { public: diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp index 3cfba26a..44e01399 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -400,7 +400,7 @@ namespace nsyshid::backend::windows return false; } - bool DeviceWindowsHID::SetProtocol(uint32 ifIndef, uint32 protocol) + bool DeviceWindowsHID::SetProtocol(uint8 ifIndex, uint8 protocol) { // ToDo: implement this // pretend that everything is fine diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h index 84fe7bda..9a8a78e9 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h @@ -47,7 +47,7 @@ namespace nsyshid::backend::windows bool GetDescriptor(uint8 descType, uint8 descIndex, uint8 lang, uint8* output, uint32 outputMaxLength) override; - bool SetProtocol(uint32 ifIndef, uint32 protocol) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; bool SetReport(ReportMessage* message) override; diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp index 241e1969..7f17f8a3 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.cpp +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -627,7 +627,7 @@ namespace nsyshid return true; } - bool SkylanderPortalDevice::SetProtocol(uint32 ifIndex, uint32 protocol) + bool SkylanderPortalDevice::SetProtocol(uint8 ifIndex, uint8 protocol) { return true; } diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h index a1ca7f8f..ae8b5d92 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.h +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -30,7 +30,7 @@ namespace nsyshid uint8* output, uint32 outputMaxLength) override; - bool SetProtocol(uint32 ifIndex, uint32 protocol) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; bool SetReport(ReportMessage* message) override; diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index c674b844..99a736d9 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -379,8 +379,8 @@ namespace nsyshid void export_HIDSetProtocol(PPCInterpreter_t* hCPU) { ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(ifIndex, 1); // r4 - ppcDefineParamU32(protocol, 2); // r5 + ppcDefineParamU8(ifIndex, 1); // r4 + ppcDefineParamU8(protocol, 2); // r5 ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(...)"); From 9d366937cd1c5908e073ecd726a0b12763838ef7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 7 Jul 2024 08:55:26 +0200 Subject: [PATCH 210/314] Workaround for compiler issue with Visual Studio 17.10 --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5843c37..7d64d91b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,12 @@ add_executable(CemuBin mainLLE.cpp ) +if(MSVC AND MSVC_VERSION EQUAL 1940) + # workaround for an msvc issue on VS 17.10 where generated ILK files are too large + # see https://developercommunity.visualstudio.com/t/After-updating-to-VS-1710-the-size-of-/10665511 + set_target_properties(CemuBin PROPERTIES LINK_FLAGS "/INCREMENTAL:NO") +endif() + if(WIN32) target_sources(CemuBin PRIVATE resource/cemu.rc From 7522c8470ee27d50a68ba662ae721b69018f3a8f Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:24:46 +0200 Subject: [PATCH 211/314] resource: move fontawesome to .rodata (#1259) --- src/resource/embedded/fontawesome.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/embedded/fontawesome.S b/src/resource/embedded/fontawesome.S index 04da3b24..29b4f93a 100644 --- a/src/resource/embedded/fontawesome.S +++ b/src/resource/embedded/fontawesome.S @@ -1,4 +1,4 @@ -.section .text +.rodata .global g_fontawesome_data, g_fontawesome_size g_fontawesome_data: From 64232ffdbddd39cf14eed0ef457273af67277f3c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 23 Jul 2024 03:13:36 +0200 Subject: [PATCH 212/314] Windows default to non-portable + Reworked MLC handling and related UI (#1252) --- src/config/ActiveSettings.cpp | 52 ++-- src/config/ActiveSettings.h | 23 +- src/config/CMakeLists.txt | 4 - src/config/CemuConfig.cpp | 18 -- src/config/CemuConfig.h | 2 +- src/config/PermanentConfig.cpp | 65 ----- src/config/PermanentConfig.h | 18 -- src/config/PermanentStorage.cpp | 76 ------ src/config/PermanentStorage.h | 27 -- src/gui/CemuApp.cpp | 407 +++++++++++++++++++------------ src/gui/CemuApp.h | 13 +- src/gui/GeneralSettings2.cpp | 154 ++++++------ src/gui/GeneralSettings2.h | 3 +- src/gui/GettingStartedDialog.cpp | 224 +++++++---------- src/gui/GettingStartedDialog.h | 34 +-- src/gui/MainWindow.cpp | 30 +-- src/gui/MainWindow.h | 2 - src/main.cpp | 14 +- 18 files changed, 515 insertions(+), 651 deletions(-) delete mode 100644 src/config/PermanentConfig.cpp delete mode 100644 src/config/PermanentConfig.h delete mode 100644 src/config/PermanentStorage.cpp delete mode 100644 src/config/PermanentStorage.h diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index 07e6f16d..560f2986 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -7,41 +7,47 @@ #include "config/LaunchSettings.h" #include "util/helpers/helpers.h" -std::set<fs::path> -ActiveSettings::LoadOnce( - const fs::path& executablePath, - const fs::path& userDataPath, - const fs::path& configPath, - const fs::path& cachePath, - const fs::path& dataPath) +void ActiveSettings::SetPaths(bool isPortableMode, + const fs::path& executablePath, + const fs::path& userDataPath, + const fs::path& configPath, + const fs::path& cachePath, + const fs::path& dataPath, + std::set<fs::path>& failedWriteAccess) { + cemu_assert_debug(!s_setPathsCalled); // can only change paths before loading + s_isPortableMode = isPortableMode; s_executable_path = executablePath; s_user_data_path = userDataPath; s_config_path = configPath; s_cache_path = cachePath; s_data_path = dataPath; - std::set<fs::path> failed_write_access; + failedWriteAccess.clear(); for (auto&& path : {userDataPath, configPath, cachePath}) { - if (!fs::exists(path)) - { - std::error_code ec; + std::error_code ec; + if (!fs::exists(path, ec)) fs::create_directories(path, ec); - } if (!TestWriteAccess(path)) { cemuLog_log(LogType::Force, "Failed to write to {}", _pathToUtf8(path)); - failed_write_access.insert(path); + failedWriteAccess.insert(path); } } - s_executable_filename = s_executable_path.filename(); + s_setPathsCalled = true; +} - g_config.SetFilename(GetConfigPath("settings.xml").generic_wstring()); - g_config.Load(); +[[nodiscard]] bool ActiveSettings::IsPortableMode() +{ + return s_isPortableMode; +} + +void ActiveSettings::Init() +{ + cemu_assert_debug(s_setPathsCalled); std::string additionalErrorInfo; s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK; - return failed_write_access; } bool ActiveSettings::LoadSharedLibrariesEnabled() @@ -229,6 +235,7 @@ bool ActiveSettings::ForceSamplerRoundToPrecision() fs::path ActiveSettings::GetMlcPath() { + cemu_assert_debug(s_setPathsCalled); if(const auto launch_mlc = LaunchSettings::GetMLCPath(); launch_mlc.has_value()) return launch_mlc.value(); @@ -238,6 +245,17 @@ fs::path ActiveSettings::GetMlcPath() return GetDefaultMLCPath(); } +bool ActiveSettings::IsCustomMlcPath() +{ + cemu_assert_debug(s_setPathsCalled); + return !GetConfig().mlc_path.GetValue().empty(); +} + +bool ActiveSettings::IsCommandLineMlcPath() +{ + return LaunchSettings::GetMLCPath().has_value(); +} + fs::path ActiveSettings::GetDefaultMLCPath() { return GetUserDataPath("mlc01"); diff --git a/src/config/ActiveSettings.h b/src/config/ActiveSettings.h index 54052741..e672fbee 100644 --- a/src/config/ActiveSettings.h +++ b/src/config/ActiveSettings.h @@ -34,12 +34,16 @@ private: public: // Set directories and return all directories that failed write access test - static std::set<fs::path> - LoadOnce(const fs::path& executablePath, - const fs::path& userDataPath, - const fs::path& configPath, - const fs::path& cachePath, - const fs::path& dataPath); + static void + SetPaths(bool isPortableMode, + const fs::path& executablePath, + const fs::path& userDataPath, + const fs::path& configPath, + const fs::path& cachePath, + const fs::path& dataPath, + std::set<fs::path>& failedWriteAccess); + + static void Init(); [[nodiscard]] static fs::path GetExecutablePath() { return s_executable_path; } [[nodiscard]] static fs::path GetExecutableFilename() { return s_executable_filename; } @@ -56,11 +60,14 @@ public: template <typename ...TArgs> [[nodiscard]] static fs::path GetMlcPath(TArgs&&... args){ return GetPath(GetMlcPath(), std::forward<TArgs>(args)...); }; + static bool IsCustomMlcPath(); + static bool IsCommandLineMlcPath(); // get mlc path to default cemu root dir/mlc01 [[nodiscard]] static fs::path GetDefaultMLCPath(); private: + inline static bool s_isPortableMode{false}; inline static fs::path s_executable_path; inline static fs::path s_user_data_path; inline static fs::path s_config_path; @@ -70,6 +77,9 @@ private: inline static fs::path s_mlc_path; public: + // can be called before Init + [[nodiscard]] static bool IsPortableMode(); + // general [[nodiscard]] static bool LoadSharedLibrariesEnabled(); [[nodiscard]] static bool DisplayDRCEnabled(); @@ -111,6 +121,7 @@ public: [[nodiscard]] static bool ForceSamplerRoundToPrecision(); private: + inline static bool s_setPathsCalled = false; // dump options inline static bool s_dump_shaders = false; inline static bool s_dump_textures = false; diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index f02b95d4..d53e8574 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -8,10 +8,6 @@ add_library(CemuConfig LaunchSettings.h NetworkSettings.cpp NetworkSettings.h - PermanentConfig.cpp - PermanentConfig.h - PermanentStorage.cpp - PermanentStorage.h XMLConfig.h ) diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 8e7cf398..03b12731 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -5,7 +5,6 @@ #include <wx/language.h> -#include "PermanentConfig.h" #include "ActiveSettings.h" XMLCemuConfig_t g_config(L"settings.xml"); @@ -15,23 +14,6 @@ void CemuConfig::SetMLCPath(fs::path path, bool save) mlc_path.SetValue(_pathToUtf8(path)); if(save) g_config.Save(); - - // if custom mlc path has been selected, store it in permanent config - if (path != ActiveSettings::GetDefaultMLCPath()) - { - try - { - auto pconfig = PermanentConfig::Load(); - pconfig.custom_mlc_path = _pathToUtf8(path); - pconfig.Store(); - } - catch (const PSDisabledException&) {} - catch (const std::exception& ex) - { - cemuLog_log(LogType::Force, "can't store custom mlc path in permanent storage: {}", ex.what()); - } - } - Account::RefreshAccounts(); } diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index d0776d2e..3f3da953 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -417,7 +417,7 @@ struct CemuConfig ConfigValue<bool> save_screenshot{true}; ConfigValue<bool> did_show_vulkan_warning{false}; - ConfigValue<bool> did_show_graphic_pack_download{false}; + ConfigValue<bool> did_show_graphic_pack_download{false}; // no longer used but we keep the config value around in case people downgrade Cemu. Despite the name this was used for the Getting Started dialog ConfigValue<bool> did_show_macos_disclaimer{false}; ConfigValue<bool> show_icon_column{ true }; diff --git a/src/config/PermanentConfig.cpp b/src/config/PermanentConfig.cpp deleted file mode 100644 index 20a44d28..00000000 --- a/src/config/PermanentConfig.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "PermanentConfig.h" - -#include "pugixml.hpp" - -#include "PermanentStorage.h" - -struct xml_string_writer : pugi::xml_writer -{ - std::string result; - - void write(const void* data, size_t size) override - { - result.append(static_cast<const char*>(data), size); - } -}; - -std::string PermanentConfig::ToXMLString() const noexcept -{ - pugi::xml_document doc; - doc.append_child(pugi::node_declaration).append_attribute("encoding") = "UTF-8"; - auto root = doc.append_child("config"); - root.append_child("MlcPath").text().set(this->custom_mlc_path.c_str()); - - xml_string_writer writer; - doc.save(writer); - return writer.result; -} - -PermanentConfig PermanentConfig::FromXMLString(std::string_view str) noexcept -{ - PermanentConfig result{}; - - pugi::xml_document doc; - if(doc.load_buffer(str.data(), str.size())) - { - result.custom_mlc_path = doc.select_node("/config/MlcPath").node().text().as_string(); - } - - return result; -} - -PermanentConfig PermanentConfig::Load() -{ - PermanentStorage storage; - - const auto str = storage.ReadFile(kFileName); - if (!str.empty()) - return FromXMLString(str); - - return {}; -} - -bool PermanentConfig::Store() noexcept -{ - try - { - PermanentStorage storage; - storage.WriteStringToFile(kFileName, ToXMLString()); - } - catch (...) - { - return false; - } - return true; -} diff --git a/src/config/PermanentConfig.h b/src/config/PermanentConfig.h deleted file mode 100644 index 8c134747..00000000 --- a/src/config/PermanentConfig.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "PermanentStorage.h" - -struct PermanentConfig -{ - static constexpr const char* kFileName = "perm_setting.xml"; - - std::string custom_mlc_path; - - [[nodiscard]] std::string ToXMLString() const noexcept; - static PermanentConfig FromXMLString(std::string_view str) noexcept; - - // gets from permanent storage - static PermanentConfig Load(); - // saves to permanent storage - bool Store() noexcept; -}; diff --git a/src/config/PermanentStorage.cpp b/src/config/PermanentStorage.cpp deleted file mode 100644 index e095ff4b..00000000 --- a/src/config/PermanentStorage.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "PermanentStorage.h" -#include "config/CemuConfig.h" -#include "util/helpers/SystemException.h" - -PermanentStorage::PermanentStorage() -{ - if (!GetConfig().permanent_storage) - throw PSDisabledException(); - - const char* appdata = std::getenv("LOCALAPPDATA"); - if (!appdata) - throw std::runtime_error("can't get LOCALAPPDATA"); - m_storage_path = appdata; - m_storage_path /= "Cemu"; - - fs::create_directories(m_storage_path); -} - -PermanentStorage::~PermanentStorage() -{ - if (m_remove_storage) - { - std::error_code ec; - fs::remove_all(m_storage_path, ec); - if (ec) - { - SystemException ex(ec); - cemuLog_log(LogType::Force, "can't remove permanent storage: {}", ex.what()); - } - } -} - -void PermanentStorage::ClearAllFiles() const -{ - fs::remove_all(m_storage_path); - fs::create_directories(m_storage_path); -} - -void PermanentStorage::RemoveStorage() -{ - m_remove_storage = true; -} - -void PermanentStorage::WriteStringToFile(std::string_view filename, std::string_view content) -{ - const auto name = m_storage_path.append(filename.data(), filename.data() + filename.size()); - std::ofstream file(name.string()); - file.write(content.data(), (uint32_t)content.size()); -} - -std::string PermanentStorage::ReadFile(std::string_view filename) noexcept -{ - try - { - const auto name = m_storage_path.append(filename.data(), filename.data() + filename.size()); - std::ifstream file(name, std::ios::in | std::ios::ate); - if (!file.is_open()) - return {}; - - const auto end = file.tellg(); - file.seekg(0, std::ios::beg); - const auto file_size = end - file.tellg(); - if (file_size == 0) - return {}; - - std::string result; - result.resize(file_size); - file.read(result.data(), file_size); - return result; - } - catch (...) - { - return {}; - } - -} diff --git a/src/config/PermanentStorage.h b/src/config/PermanentStorage.h deleted file mode 100644 index 3cda3d6d..00000000 --- a/src/config/PermanentStorage.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -// disabled by config -class PSDisabledException : public std::runtime_error -{ -public: - PSDisabledException() - : std::runtime_error("permanent storage is disabled by user") {} -}; - -class PermanentStorage -{ -public: - PermanentStorage(); - ~PermanentStorage(); - - void ClearAllFiles() const; - // flags storage to be removed on destruction - void RemoveStorage(); - - void WriteStringToFile(std::string_view filename, std::string_view content); - std::string ReadFile(std::string_view filename) noexcept; - -private: - fs::path m_storage_path; - bool m_remove_storage = false; -}; \ No newline at end of file diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 86d81e43..baa83888 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -3,11 +3,11 @@ #include "gui/wxgui.h" #include "config/CemuConfig.h" #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" +#include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "gui/guiWrapper.h" #include "config/ActiveSettings.h" +#include "config/LaunchSettings.h" #include "gui/GettingStartedDialog.h" -#include "config/PermanentConfig.h" -#include "config/PermanentStorage.h" #include "input/InputManager.h" #include "gui/helpers/wxHelpers.h" #include "Cemu/ncrypto/ncrypto.h" @@ -30,7 +30,10 @@ wxIMPLEMENT_APP_NO_MAIN(CemuApp); extern WindowInfo g_window_info; extern std::shared_mutex g_mutex; -int mainEmulatorHLE(); +// forward declarations from main.cpp +void UnitTests(); +void CemuCommonInit(); + void HandlePostUpdate(); // Translation strings to extract for gettext: void unused_translation_dummy() @@ -54,34 +57,86 @@ void unused_translation_dummy() void(_("unknown")); } -bool CemuApp::OnInit() +#if BOOST_OS_WINDOWS +#include <shlobj_core.h> +fs::path GetAppDataRoamingPath() { + PWSTR path = nullptr; + HRESULT result = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &path); + if (result != S_OK || !path) + { + if (path) + CoTaskMemFree(path); + return {}; + } + std::string appDataPath = boost::nowide::narrow(path); + CoTaskMemFree(path); + return _utf8ToPath(appDataPath); +} +#endif + +#if BOOST_OS_WINDOWS +void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for Windows +{ + std::error_code ec; + bool isPortable = false; fs::path user_data_path, config_path, cache_path, data_path; auto standardPaths = wxStandardPaths::Get(); fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); + fs::path portablePath = exePath.parent_path() / "portable"; + data_path = exePath.parent_path(); // the data path is always the same as the exe path + if (fs::exists(portablePath, ec)) + { + isPortable = true; + user_data_path = config_path = cache_path = portablePath; + } + else + { + fs::path roamingPath = GetAppDataRoamingPath() / "Cemu"; + user_data_path = config_path = cache_path = roamingPath; + } + // on Windows Cemu used to be portable by default prior to 2.0-89 + // to remain backwards compatible with old installations we check for settings.xml in the Cemu directory + // if it exists, we use the exe path as the portable directory + if(!isPortable) // lower priority than portable directory + { + if (fs::exists(exePath.parent_path() / "settings.xml", ec)) + { + isPortable = true; + user_data_path = config_path = cache_path = exePath.parent_path(); + } + } + ActiveSettings::SetPaths(isPortable, exePath, user_data_path, config_path, cache_path, data_path, failedWriteAccess); +} +#endif + #if BOOST_OS_LINUX +void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for Linux +{ + std::error_code ec; + bool isPortable = false; + fs::path user_data_path, config_path, cache_path, data_path; + auto standardPaths = wxStandardPaths::Get(); + fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); + fs::path portablePath = exePath.parent_path() / "portable"; // GetExecutablePath returns the AppImage's temporary mount location wxString appImagePath; if (wxGetEnv(("APPIMAGE"), &appImagePath)) - exePath = wxHelper::MakeFSPath(appImagePath); -#endif - // Try a portable path first, if it exists. - user_data_path = config_path = cache_path = data_path = exePath.parent_path() / "portable"; -#if BOOST_OS_MACOS - // If run from an app bundle, use its parent directory. - fs::path appPath = exePath.parent_path().parent_path().parent_path(); - if (appPath.extension() == ".app") - user_data_path = config_path = cache_path = data_path = appPath.parent_path() / "portable"; -#endif - - if (!fs::exists(user_data_path)) { -#if BOOST_OS_WINDOWS - user_data_path = config_path = cache_path = data_path = exePath.parent_path(); -#else + exePath = wxHelper::MakeFSPath(appImagePath); + portablePath = exePath.parent_path() / "portable"; + } + if (fs::exists(portablePath, ec)) + { + isPortable = true; + user_data_path = config_path = cache_path = portablePath; + // in portable mode assume the data directories (resources, gameProfiles/default/) are next to the executable + data_path = exePath.parent_path(); + } + else + { SetAppName("Cemu"); - wxString appName=GetAppName(); -#if BOOST_OS_LINUX + wxString appName = GetAppName(); standardPaths.SetFileLayout(wxStandardPaths::FileLayout::FileLayout_XDG); auto getEnvDir = [&](const wxString& varName, const wxString& defaultValue) { @@ -90,33 +145,151 @@ bool CemuApp::OnInit() return defaultValue; return dir; }; - wxString homeDir=wxFileName::GetHomeDir(); + wxString homeDir = wxFileName::GetHomeDir(); user_data_path = (getEnvDir(wxS("XDG_DATA_HOME"), homeDir + wxS("/.local/share")) + "/" + appName).ToStdString(); config_path = (getEnvDir(wxS("XDG_CONFIG_HOME"), homeDir + wxS("/.config")) + "/" + appName).ToStdString(); -#else - user_data_path = config_path = standardPaths.GetUserDataDir().ToStdString(); -#endif data_path = standardPaths.GetDataDir().ToStdString(); cache_path = standardPaths.GetUserDir(wxStandardPaths::Dir::Dir_Cache).ToStdString(); cache_path /= appName.ToStdString(); -#endif } + ActiveSettings::SetPaths(isPortable, exePath, user_data_path, config_path, cache_path, data_path, failedWriteAccess); +} +#endif - auto failed_write_access = ActiveSettings::LoadOnce(exePath, user_data_path, config_path, cache_path, data_path); - for (auto&& path : failed_write_access) - wxMessageBox(formatWxString(_("Cemu can't write to {}!"), wxString::FromUTF8(_pathToUtf8(path))), - _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr); +#if BOOST_OS_MACOS +void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for MacOS +{ + std::error_code ec; + bool isPortable = false; + fs::path user_data_path, config_path, cache_path, data_path; + auto standardPaths = wxStandardPaths::Get(); + fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); + // If run from an app bundle, use its parent directory + fs::path appPath = exePath.parent_path().parent_path().parent_path(); + fs::path portablePath = appPath.extension() == ".app" ? appPath.parent_path() / "portable" : exePath.parent_path() / "portable"; + if (fs::exists(portablePath, ec)) + { + isPortable = true; + user_data_path = config_path = cache_path = portablePath; + data_path = exePath.parent_path(); + } + else + { + SetAppName("Cemu"); + wxString appName = GetAppName(); + user_data_path = config_path = standardPaths.GetUserDataDir().ToStdString(); + data_path = standardPaths.GetDataDir().ToStdString(); + cache_path = standardPaths.GetUserDir(wxStandardPaths::Dir::Dir_Cache).ToStdString(); + cache_path /= appName.ToStdString(); + } + ActiveSettings::SetPaths(isPortable, exePath, user_data_path, config_path, cache_path, data_path, failedWriteAccess); +} +#endif + +// create default MLC files or quit if it fails +void CemuApp::InitializeNewMLCOrFail(fs::path mlc) +{ + if( CemuApp::CreateDefaultMLCFiles(mlc) ) + return; // all good + cemu_assert_debug(!ActiveSettings::IsCustomMlcPath()); // should not be possible? + + if(ActiveSettings::IsCommandLineMlcPath() || ActiveSettings::IsCustomMlcPath()) + { + // tell user that the custom path is not writable + wxMessageBox(formatWxString(_("Cemu failed to write to the custom mlc directory.\nThe path is:\n{}"), wxHelper::FromPath(mlc)), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + exit(0); + } + wxMessageBox(formatWxString(_("Cemu failed to write to the mlc directory.\nThe path is:\n{}"), wxHelper::FromPath(mlc)), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + exit(0); +} + +void CemuApp::InitializeExistingMLCOrFail(fs::path mlc) +{ + if(CreateDefaultMLCFiles(mlc)) + return; // all good + // failed to write mlc files + if(ActiveSettings::IsCommandLineMlcPath() || ActiveSettings::IsCustomMlcPath()) + { + // tell user that the custom path is not writable + // if it's a command line path then just quit. Otherwise ask if user wants to reset the path + if(ActiveSettings::IsCommandLineMlcPath()) + { + wxMessageBox(formatWxString(_("Cemu failed to write to the custom mlc directory.\nThe path is:\n{}"), wxHelper::FromPath(mlc)), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + exit(0); + } + // ask user if they want to reset the path + const wxString message = formatWxString(_("Cemu failed to write to the custom mlc directory.\n\nThe path is:\n{}\n\nCemu cannot start without a valid mlc path. Do you want to reset the path? You can later change it again in the General Settings."), + _pathToUtf8(mlc)); + wxMessageDialog dialog(nullptr, message, _("Error"), wxCENTRE | wxYES_NO | wxICON_WARNING); + dialog.SetYesNoLabels(_("Reset path"), _("Exit")); + const auto dialogResult = dialog.ShowModal(); + if (dialogResult == wxID_NO) + exit(0); + else // reset path + { + GetConfig().mlc_path = ""; + g_config.Save(); + } + } +} + +bool CemuApp::OnInit() +{ + std::set<fs::path> failedWriteAccess; + DeterminePaths(failedWriteAccess); + // make sure default cemu directories exist + CreateDefaultCemuFiles(); + + g_config.SetFilename(ActiveSettings::GetConfigPath("settings.xml").generic_wstring()); + + std::error_code ec; + bool isFirstStart = !fs::exists(ActiveSettings::GetConfigPath("settings.xml"), ec); NetworkConfig::LoadOnce(); - g_config.Load(); + if(!isFirstStart) + { + g_config.Load(); + LocalizeUI(static_cast<wxLanguage>(GetConfig().language == wxLANGUAGE_DEFAULT ? wxLocale::GetSystemLanguage() : GetConfig().language.GetValue())); + } + else + { + LocalizeUI(static_cast<wxLanguage>(wxLocale::GetSystemLanguage())); + } + for (auto&& path : failedWriteAccess) + { + wxMessageBox(formatWxString(_("Cemu can't write to {}!"), wxString::FromUTF8(_pathToUtf8(path))), + _("Warning"), wxOK | wxCENTRE | wxICON_EXCLAMATION, nullptr); + } + + if (isFirstStart) + { + // show the getting started dialog + GettingStartedDialog dia(nullptr); + dia.ShowModal(); + // make sure config is created. Gfx pack UI and input UI may create it earlier already, but we still want to update it + g_config.Save(); + // create mlc, on failure the user can quit here. So do this after the Getting Started dialog + InitializeNewMLCOrFail(ActiveSettings::GetMlcPath()); + } + else + { + // check if mlc is valid and recreate default files + InitializeExistingMLCOrFail(ActiveSettings::GetMlcPath()); + } + + ActiveSettings::Init(); // this is a bit of a misnomer, right now this call only loads certs for online play. In the future we should move the logic to a more appropriate place HandlePostUpdate(); - mainEmulatorHLE(); + + LatteOverlay_init(); + // run a couple of tests if in non-release mode +#ifdef CEMU_DEBUG_ASSERT + UnitTests(); +#endif + CemuCommonInit(); wxInitAllImageHandlers(); - LocalizeUI(); - // fill colour db wxTheColourDatabase->AddColour("ERROR", wxColour(0xCC, 0, 0)); wxTheColourDatabase->AddColour("SUCCESS", wxColour(0, 0xbb, 0)); @@ -135,15 +308,8 @@ bool CemuApp::OnInit() Bind(wxEVT_ACTIVATE_APP, &CemuApp::ActivateApp, this); auto& config = GetConfig(); - const bool first_start = !config.did_show_graphic_pack_download; - - CreateDefaultFiles(first_start); - m_mainFrame = new MainWindow(); - if (first_start) - m_mainFrame->ShowGettingStartedDialog(); - std::unique_lock lock(g_mutex); g_window_info.app_active = true; @@ -230,22 +396,22 @@ std::vector<const wxLanguageInfo *> CemuApp::GetLanguages() const { return availableLanguages; } -void CemuApp::LocalizeUI() +void CemuApp::LocalizeUI(wxLanguage languageToUse) { std::unique_ptr<wxTranslations> translationsMgr(new wxTranslations()); m_availableTranslations = GetAvailableTranslationLanguages(translationsMgr.get()); - const sint32 configuredLanguage = GetConfig().language; bool isTranslationAvailable = std::any_of(m_availableTranslations.begin(), m_availableTranslations.end(), - [configuredLanguage](const wxLanguageInfo* info) { return info->Language == configuredLanguage; }); - if (configuredLanguage == wxLANGUAGE_DEFAULT || isTranslationAvailable) + [languageToUse](const wxLanguageInfo* info) { return info->Language == languageToUse; }); + if (languageToUse == wxLANGUAGE_DEFAULT || isTranslationAvailable) { - translationsMgr->SetLanguage(static_cast<wxLanguage>(configuredLanguage)); + translationsMgr->SetLanguage(static_cast<wxLanguage>(languageToUse)); translationsMgr->AddCatalog("cemu"); - if (translationsMgr->IsLoaded("cemu") && wxLocale::IsAvailable(configuredLanguage)) - m_locale.Init(configuredLanguage); - + if (translationsMgr->IsLoaded("cemu") && wxLocale::IsAvailable(languageToUse)) + { + m_locale.Init(languageToUse); + } // This must be run after wxLocale::Init, as the latter sets up its own wxTranslations instance which we want to override wxTranslations::Set(translationsMgr.release()); } @@ -264,55 +430,47 @@ std::vector<const wxLanguageInfo*> CemuApp::GetAvailableTranslationLanguages(wxT return languages; } -void CemuApp::CreateDefaultFiles(bool first_start) +bool CemuApp::CheckMLCPath(const fs::path& mlc) { std::error_code ec; - fs::path mlc = ActiveSettings::GetMlcPath(); - // check for mlc01 folder missing if custom path has been set - if (!fs::exists(mlc, ec) && !first_start) - { - const wxString message = formatWxString(_("Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?"), - _pathToUtf8(mlc)); - - wxMessageDialog dialog(nullptr, message, _("Error"), wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING); - dialog.SetYesNoCancelLabels(_("Yes"), _("No"), _("Select a custom path")); - const auto dialogResult = dialog.ShowModal(); - if (dialogResult == wxID_NO) - exit(0); - else if(dialogResult == wxID_CANCEL) - { - if (!SelectMLCPath()) - return; - mlc = ActiveSettings::GetMlcPath(); - } - else - { - GetConfig().mlc_path = ""; - g_config.Save(); - } - } + if (!fs::exists(mlc, ec)) + return false; + if (!fs::exists(mlc / "usr", ec) || !fs::exists(mlc / "sys", ec)) + return false; + return true; +} +bool CemuApp::CreateDefaultMLCFiles(const fs::path& mlc) +{ + auto CreateDirectoriesIfNotExist = [](const fs::path& path) + { + std::error_code ec; + if (!fs::exists(path, ec)) + return fs::create_directories(path, ec); + return true; + }; + // list of directories to create + const fs::path directories[] = { + mlc, + mlc / "sys", + mlc / "usr", + mlc / "usr/title/00050000", // base + mlc / "usr/title/0005000c", // dlc + mlc / "usr/title/0005000e", // update + mlc / "usr/save/00050010/1004a000/user/common/db", // Mii Maker save folders {0x500101004A000, 0x500101004A100, 0x500101004A200} + mlc / "usr/save/00050010/1004a100/user/common/db", + mlc / "usr/save/00050010/1004a200/user/common/db", + mlc / "sys/title/0005001b/1005c000/content" // lang files + }; + for(auto& path : directories) + { + if(!CreateDirectoriesIfNotExist(path)) + return false; + } // create sys/usr folder in mlc01 try { - const auto sysFolder = fs::path(mlc).append("sys"); - fs::create_directories(sysFolder); - - const auto usrFolder = fs::path(mlc).append("usr"); - fs::create_directories(usrFolder); - fs::create_directories(fs::path(usrFolder).append("title/00050000")); // base - fs::create_directories(fs::path(usrFolder).append("title/0005000c")); // dlc - fs::create_directories(fs::path(usrFolder).append("title/0005000e")); // update - - // Mii Maker save folders {0x500101004A000, 0x500101004A100, 0x500101004A200}, - fs::create_directories(fs::path(mlc).append("usr/save/00050010/1004a000/user/common/db")); - fs::create_directories(fs::path(mlc).append("usr/save/00050010/1004a100/user/common/db")); - fs::create_directories(fs::path(mlc).append("usr/save/00050010/1004a200/user/common/db")); - - // lang files const auto langDir = fs::path(mlc).append("sys/title/0005001b/1005c000/content"); - fs::create_directories(langDir); - auto langFile = fs::path(langDir).append("language.txt"); if (!fs::exists(langFile)) { @@ -346,18 +504,13 @@ void CemuApp::CreateDefaultFiles(bool first_start) } catch (const std::exception& ex) { - wxString errorMsg = formatWxString(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}"), ex.what(), _pathToUtf8(mlc)); - -#if BOOST_OS_WINDOWS - const DWORD lastError = GetLastError(); - if (lastError != ERROR_SUCCESS) - errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); -#endif - - wxMessageBox(errorMsg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); - exit(0); + return false; } + return true; +} +void CemuApp::CreateDefaultCemuFiles() +{ // cemu directories try { @@ -384,58 +537,6 @@ void CemuApp::CreateDefaultFiles(bool first_start) } } - -bool CemuApp::TrySelectMLCPath(fs::path path) -{ - if (path.empty()) - path = ActiveSettings::GetDefaultMLCPath(); - - if (!TestWriteAccess(path)) - return false; - - GetConfig().SetMLCPath(path); - CemuApp::CreateDefaultFiles(); - - // update TitleList and SaveList scanner with new MLC path - CafeTitleList::SetMLCPath(path); - CafeTitleList::Refresh(); - CafeSaveList::SetMLCPath(path); - CafeSaveList::Refresh(); - return true; -} - -bool CemuApp::SelectMLCPath(wxWindow* parent) -{ - auto& config = GetConfig(); - - fs::path default_path; - if (fs::exists(_utf8ToPath(config.mlc_path.GetValue()))) - default_path = _utf8ToPath(config.mlc_path.GetValue()); - - // try until users selects a valid path or aborts - while(true) - { - wxDirDialog path_dialog(parent, _("Select a mlc directory"), wxHelper::FromPath(default_path), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); - if (path_dialog.ShowModal() != wxID_OK || path_dialog.GetPath().empty()) - return false; - - const auto path = path_dialog.GetPath().ToStdWstring(); - - if (!TrySelectMLCPath(path)) - { - const auto result = wxMessageBox(_("Cemu can't write to the selected mlc path!\nDo you want to select another path?"), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR); - if (result == wxYES) - continue; - - break; - } - - return true; - } - - return false; -} - void CemuApp::ActivateApp(wxActivateEvent& event) { g_window_info.app_active = event.GetActive(); diff --git a/src/gui/CemuApp.h b/src/gui/CemuApp.h index cfdab0a2..b73d627d 100644 --- a/src/gui/CemuApp.h +++ b/src/gui/CemuApp.h @@ -15,13 +15,18 @@ public: std::vector<const wxLanguageInfo*> GetLanguages() const; - static void CreateDefaultFiles(bool first_start = false); - static bool TrySelectMLCPath(fs::path path); - static bool SelectMLCPath(wxWindow* parent = nullptr); + static bool CheckMLCPath(const fs::path& mlc); + static bool CreateDefaultMLCFiles(const fs::path& mlc); + static void CreateDefaultCemuFiles(); + static void InitializeNewMLCOrFail(fs::path mlc); + static void InitializeExistingMLCOrFail(fs::path mlc); private: + void LocalizeUI(wxLanguage languageToUse); + + void DeterminePaths(std::set<fs::path>& failedWriteAccess); + void ActivateApp(wxActivateEvent& event); - void LocalizeUI(); static std::vector<const wxLanguageInfo*> GetAvailableTranslationLanguages(wxTranslations* translationsMgr); MainWindow* m_mainFrame = nullptr; diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index c0b54949..08395cd3 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -32,7 +32,6 @@ #include <boost/tokenizer.hpp> #include "util/helpers/SystemException.h" #include "gui/dialogs/CreateAccount/wxCreateAccountDialog.h" -#include "config/PermanentStorage.h" #if BOOST_OS_WINDOWS #include <VersionHelpers.h> @@ -176,19 +175,15 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) m_save_screenshot->SetToolTip(_("Pressing the screenshot key (F12) will save a screenshot directly to the screenshots folder")); second_row->Add(m_save_screenshot, 0, botflag, 5); - m_permanent_storage = new wxCheckBox(box, wxID_ANY, _("Use permanent storage")); - m_permanent_storage->SetToolTip(_("Cemu will remember your custom mlc path in %LOCALAPPDATA%/Cemu for new installations.")); - second_row->Add(m_permanent_storage, 0, botflag, 5); - second_row->AddSpacer(10); m_disable_screensaver = new wxCheckBox(box, wxID_ANY, _("Disable screen saver")); m_disable_screensaver->SetToolTip(_("Prevents the system from activating the screen saver or going to sleep while running a game.")); second_row->Add(m_disable_screensaver, 0, botflag, 5); - // Enable/disable feral interactive gamemode + // Enable/disable feral interactive gamemode #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) - m_feral_gamemode = new wxCheckBox(box, wxID_ANY, _("Enable Feral GameMode")); - m_feral_gamemode->SetToolTip(_("Use FeralInteractive GameMode if installed.")); - second_row->Add(m_feral_gamemode, 0, botflag, 5); + m_feral_gamemode = new wxCheckBox(box, wxID_ANY, _("Enable Feral GameMode")); + m_feral_gamemode->SetToolTip(_("Use FeralInteractive GameMode if installed.")); + second_row->Add(m_feral_gamemode, 0, botflag, 5); #endif // temporary workaround because feature crashes on macOS @@ -203,23 +198,33 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) } { - auto* box = new wxStaticBox(panel, wxID_ANY, _("MLC Path")); - auto* box_sizer = new wxStaticBoxSizer(box, wxHORIZONTAL); + auto* outerMlcBox = new wxStaticBox(panel, wxID_ANY, _("Custom MLC path")); - m_mlc_path = new wxTextCtrl(box, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); + auto* box_sizer_mlc = new wxStaticBoxSizer(outerMlcBox, wxVERTICAL); + box_sizer_mlc->Add(new wxStaticText(box_sizer_mlc->GetStaticBox(), wxID_ANY, _("You can configure a custom path for the emulated internal Wii U storage (MLC).\nThis is where Cemu stores saves, accounts and other Wii U system files."), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5); + + auto* mlcPathLineSizer = new wxBoxSizer(wxHORIZONTAL); + + m_mlc_path = new wxTextCtrl(outerMlcBox, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); m_mlc_path->SetMinSize(wxSize(150, -1)); - m_mlc_path->Bind(wxEVT_CHAR, &GeneralSettings2::OnMLCPathChar, this); m_mlc_path->SetToolTip(_("The mlc directory contains your save games and installed game update/dlc data")); - box_sizer->Add(m_mlc_path, 1, wxALL | wxEXPAND, 5); + mlcPathLineSizer->Add(m_mlc_path, 1, wxALL | wxEXPAND, 5); - auto* change_path = new wxButton(box, wxID_ANY, "..."); - change_path->Bind(wxEVT_BUTTON, &GeneralSettings2::OnMLCPathSelect, this); - change_path->SetToolTip(_("Select a custom mlc path\nThe mlc path is used to store Wii U related files like save games, game updates and dlc data")); - box_sizer->Add(change_path, 0, wxALL, 5); + auto* changePath = new wxButton(outerMlcBox, wxID_ANY, "Change"); + changePath->Bind(wxEVT_BUTTON, &GeneralSettings2::OnMLCPathSelect, this); + mlcPathLineSizer->Add(changePath, 0, wxALL, 5); if (LaunchSettings::GetMLCPath().has_value()) - change_path->Disable(); - general_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5); + changePath->Disable(); + + auto* clearPath = new wxButton(outerMlcBox, wxID_ANY, "Clear custom path"); + clearPath->Bind(wxEVT_BUTTON, &GeneralSettings2::OnMLCPathClear, this); + mlcPathLineSizer->Add(clearPath, 0, wxALL, 5); + if (LaunchSettings::GetMLCPath().has_value() || !ActiveSettings::IsCustomMlcPath()) + clearPath->Disable(); + + box_sizer_mlc->Add(mlcPathLineSizer, 0, wxEXPAND, 5); + general_panel_sizer->Add(box_sizer_mlc, 0, wxEXPAND | wxALL, 5); } { @@ -897,39 +902,12 @@ void GeneralSettings2::StoreConfig() #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) config.feral_gamemode = m_feral_gamemode->IsChecked(); #endif - const bool use_ps = m_permanent_storage->IsChecked(); - if(use_ps) - { - config.permanent_storage = use_ps; - try - { - - PermanentStorage storage; - storage.RemoveStorage(); - } - catch (...) {} - } - else - { - try - { - // delete permanent storage - PermanentStorage storage; - storage.RemoveStorage(); - } - catch (...) {} - config.permanent_storage = use_ps; - } - config.disable_screensaver = m_disable_screensaver->IsChecked(); // Toggle while a game is running if (CafeSystem::IsTitleRunning()) { ScreenSaver::SetInhibit(config.disable_screensaver); } - - if (!LaunchSettings::GetMLCPath().has_value()) - config.SetMLCPath(wxHelper::MakeFSPath(m_mlc_path->GetValue()), false); // -1 is default wx widget value -> set to dummy 0 so mainwindow and padwindow will update it config.window_position = m_save_window_position_size->IsChecked() ? Vector2i{ 0,0 } : Vector2i{-1,-1}; @@ -1560,7 +1538,6 @@ void GeneralSettings2::ApplyConfig() m_auto_update->SetValue(config.check_update); m_save_screenshot->SetValue(config.save_screenshot); - m_permanent_storage->SetValue(config.permanent_storage); m_disable_screensaver->SetValue(config.disable_screensaver); #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) m_feral_gamemode->SetValue(config.feral_gamemode); @@ -1570,6 +1547,7 @@ void GeneralSettings2::ApplyConfig() m_disable_screensaver->SetValue(false); #endif + m_game_paths->Clear(); for (auto& path : config.game_paths) { m_game_paths->Append(to_wxString(path)); @@ -1985,34 +1963,70 @@ void GeneralSettings2::OnAccountServiceChanged(wxCommandEvent& event) void GeneralSettings2::OnMLCPathSelect(wxCommandEvent& event) { - if (!CemuApp::SelectMLCPath(this)) + if(CafeSystem::IsTitleRunning()) + { + wxMessageBox(_("Can't change MLC path while a game is running!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); return; - - m_mlc_path->SetValue(wxHelper::FromPath(ActiveSettings::GetMlcPath())); - m_reload_gamelist = true; - m_mlc_modified = true; + } + // show directory dialog + wxDirDialog path_dialog(this, _("Select MLC directory"), wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); + if (path_dialog.ShowModal() != wxID_OK || path_dialog.GetPath().empty()) + return; + // check if the choosen MLC path is an already initialized MLC location + fs::path newMlc = wxHelper::MakeFSPath(path_dialog.GetPath()); + if(CemuApp::CheckMLCPath(newMlc)) + { + // ask user if they are sure they want to use this folder and let them know that accounts and saves wont transfer + wxString message = _("Note that changing the MLC location will not transfer any accounts or save files. Are you sure you want to change the path?"); + wxMessageDialog dialog(this, message, _("Warning"), wxYES_NO | wxCENTRE | wxICON_WARNING); + if(dialog.ShowModal() == wxID_NO) + return; + if( !CemuApp::CreateDefaultMLCFiles(newMlc) ) // creating also acts as a check for read+write access + { + wxMessageBox(_("Failed to create default MLC files in the selected directory. The MLC path has not been changed"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + return; + } + } + else + { + // ask user if they want to create a new mlc structure at the choosen location + wxString message = _("The selected directory does not contain the expected MLC structure. Do you want to create a new MLC structure in this directory?\nNote that changing the MLC location will not transfer any accounts or save files."); + wxMessageDialog dialog(this, message, _("Warning"), wxYES_NO | wxCENTRE | wxICON_WARNING); + if( !CemuApp::CreateDefaultMLCFiles(newMlc) ) + { + wxMessageBox(_("Failed to create default MLC files in the selected directory. The MLC path has not been changed"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + return; + } + } + // update MLC path and store any other modified settings + GetConfig().SetMLCPath(newMlc); + StoreConfig(); + wxMessageBox(_("Cemu needs to be restarted for the changes to take effect."), _("Information"), wxOK | wxCENTRE | wxICON_INFORMATION, this); + // close settings and then cemu + wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW); + wxPostEvent(this, closeEvent); + wxPostEvent(GetParent(), closeEvent); } -void GeneralSettings2::OnMLCPathChar(wxKeyEvent& event) +void GeneralSettings2::OnMLCPathClear(wxCommandEvent& event) { - if (LaunchSettings::GetMLCPath().has_value()) - return; - - if(event.GetKeyCode() == WXK_DELETE || event.GetKeyCode() == WXK_BACK) + if(CafeSystem::IsTitleRunning()) { - fs::path newPath = ""; - if(!CemuApp::TrySelectMLCPath(newPath)) - { - const auto res = wxMessageBox(_("The default MLC path is inaccessible.\nDo you want to select a different path?"), _("Error"), wxYES_NO | wxCENTRE | wxICON_ERROR); - if (res == wxYES && CemuApp::SelectMLCPath(this)) - newPath = ActiveSettings::GetMlcPath(); - else - return; - } - m_mlc_path->SetValue(wxHelper::FromPath(newPath)); - m_reload_gamelist = true; - m_mlc_modified = true; + wxMessageBox(_("Can't change MLC path while a game is running!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this); + return; } + wxString message = _("Note that changing the MLC location will not transfer any accounts or save files. Are you sure you want to change the path?"); + wxMessageDialog dialog(this, message, _("Warning"), wxYES_NO | wxCENTRE | wxICON_WARNING); + if(dialog.ShowModal() == wxID_NO) + return; + GetConfig().SetMLCPath(""); + StoreConfig(); + g_config.Save(); + wxMessageBox(_("Cemu needs to be restarted for the changes to take effect."), _("Information"), wxOK | wxCENTRE | wxICON_INFORMATION, this); + // close settings and then cemu + wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW); + wxPostEvent(this, closeEvent); + wxPostEvent(GetParent(), closeEvent); } void GeneralSettings2::OnShowOnlineValidator(wxCommandEvent& event) diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index b34c9222..a3429fa1 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -42,7 +42,6 @@ private: wxCheckBox* m_save_padwindow_position_size; wxCheckBox* m_discord_presence, *m_fullscreen_menubar; wxCheckBox* m_auto_update, *m_save_screenshot; - wxCheckBox* m_permanent_storage; wxCheckBox* m_disable_screensaver; #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) wxCheckBox* m_feral_gamemode; @@ -96,7 +95,7 @@ private: void OnRemovePathClicked(wxCommandEvent& event); void OnActiveAccountChanged(wxCommandEvent& event); void OnMLCPathSelect(wxCommandEvent& event); - void OnMLCPathChar(wxKeyEvent& event); + void OnMLCPathClear(wxCommandEvent& event); void OnShowOnlineValidator(wxCommandEvent& event); void OnAccountServiceChanged(wxCommandEvent& event); static wxString GetOnlineAccountErrorMessage(OnlineAccountError error); diff --git a/src/gui/GettingStartedDialog.cpp b/src/gui/GettingStartedDialog.cpp index bfd206b1..22426cf2 100644 --- a/src/gui/GettingStartedDialog.cpp +++ b/src/gui/GettingStartedDialog.cpp @@ -4,6 +4,7 @@ #include <wx/filepicker.h> #include <wx/statbox.h> #include <wx/msgdlg.h> +#include <wx/radiobox.h> #include "config/ActiveSettings.h" #include "gui/CemuApp.h" @@ -11,7 +12,6 @@ #include "gui/GraphicPacksWindow2.h" #include "gui/input/InputSettings2.h" #include "config/CemuConfig.h" -#include "config/PermanentConfig.h" #include "Cafe/TitleList/TitleList.h" @@ -21,75 +21,100 @@ #include "wxHelper.h" +wxDEFINE_EVENT(EVT_REFRESH_FIRST_PAGE, wxCommandEvent); // used to refresh the first page after the language change + wxPanel* GettingStartedDialog::CreatePage1() { - auto* result = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + auto* mainPanel = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); auto* page1_sizer = new wxBoxSizer(wxVERTICAL); { auto* sizer = new wxBoxSizer(wxHORIZONTAL); - - sizer->Add(new wxStaticBitmap(result, wxID_ANY, wxICON(M_WND_ICON128)), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - - auto* m_staticText11 = new wxStaticText(result, wxID_ANY, _("It looks like you're starting Cemu for the first time.\nThis quick setup assistant will help you get the best experience"), wxDefaultPosition, wxDefaultSize, 0); - m_staticText11->Wrap(-1); - sizer->Add(m_staticText11, 0, wxALL, 5); - + sizer->Add(new wxStaticBitmap(mainPanel, wxID_ANY, wxICON(M_WND_ICON128)), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + m_page1.staticText11 = new wxStaticText(mainPanel, wxID_ANY, _("It looks like you're starting Cemu for the first time.\nThis quick setup assistant will help you get the best experience"), wxDefaultPosition, wxDefaultSize, 0); + m_page1.staticText11->Wrap(-1); + sizer->Add(m_page1.staticText11, 0, wxALL, 5); page1_sizer->Add(sizer, 0, wxALL | wxEXPAND, 5); } + if(ActiveSettings::IsPortableMode()) { - m_mlc_box_sizer = new wxStaticBoxSizer(wxVERTICAL, result, _("mlc01 path")); - m_mlc_box_sizer->Add(new wxStaticText(m_mlc_box_sizer->GetStaticBox(), wxID_ANY, _("The mlc path is the root folder of the emulated Wii U internal flash storage. It contains all your saves, installed updates and DLCs.\nIt is strongly recommend that you create a dedicated folder for it (example: C:\\wiiu\\mlc\\) \nIf left empty, the mlc folder will be created inside the Cemu folder.")), 0, wxALL, 5); + m_page1.portableModeInfoText = new wxStaticText(mainPanel, wxID_ANY, _("Cemu is running in portable mode")); + m_page1.portableModeInfoText->Show(true); + page1_sizer->Add(m_page1.portableModeInfoText, 0, wxALL, 5); - m_prev_mlc_warning = new wxStaticText(m_mlc_box_sizer->GetStaticBox(), wxID_ANY, _("A custom mlc path from a previous Cemu installation has been found and filled in.")); - m_prev_mlc_warning->SetForegroundColour(*wxRED); - m_prev_mlc_warning->Show(false); - m_mlc_box_sizer->Add(m_prev_mlc_warning, 0, wxALL, 5); - - auto* mlc_path_sizer = new wxBoxSizer(wxHORIZONTAL); - mlc_path_sizer->Add(new wxStaticText(m_mlc_box_sizer->GetStaticBox(), wxID_ANY, _("Custom mlc01 path")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - - // workaround since we can't specify our own browse label? >> _("Browse") - m_mlc_folder = new wxDirPickerCtrl(m_mlc_box_sizer->GetStaticBox(), wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE); - auto tTest1 = m_mlc_folder->GetTextCtrl(); - if(m_mlc_folder->HasTextCtrl()) - { - m_mlc_folder->GetTextCtrl()->SetEditable(false); - m_mlc_folder->GetTextCtrl()->Bind(wxEVT_CHAR, &GettingStartedDialog::OnMLCPathChar, this); - } - mlc_path_sizer->Add(m_mlc_folder, 1, wxALL, 5); - - mlc_path_sizer->Add(new wxStaticText(m_mlc_box_sizer->GetStaticBox(), wxID_ANY, _("(optional)")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - - m_mlc_box_sizer->Add(mlc_path_sizer, 0, wxEXPAND, 5); - - page1_sizer->Add(m_mlc_box_sizer, 0, wxALL | wxEXPAND, 5); } + // language selection +#if 0 { - auto* sizer = new wxStaticBoxSizer(wxVERTICAL, result, _("Game paths")); + m_page1.languageBoxSizer = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("Language")); + m_page1.languageText = new wxStaticText(m_page1.languageBoxSizer->GetStaticBox(), wxID_ANY, _("Select the language you want to use in Cemu")); + m_page1.languageBoxSizer->Add(m_page1.languageText, 0, wxALL, 5); - sizer->Add(new wxStaticText(sizer->GetStaticBox(), wxID_ANY, _("The game path is scanned by Cemu to locate your games. We recommend creating a dedicated directory in which\nyou place all your Wii U games. (example: C:\\wiiu\\games\\)\n\nYou can also set additional paths in the general settings of Cemu.")), 0, wxALL, 5); + wxString language_choices[] = { _("Default") }; + wxChoice* m_language = new wxChoice(m_page1.languageBoxSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, std::size(language_choices), language_choices); + m_language->SetSelection(0); + + for (const auto& language : wxGetApp().GetLanguages()) + { + m_language->Append(language->DescriptionNative); + } + + m_language->SetSelection(0); + m_page1.languageBoxSizer->Add(m_language, 0, wxALL | wxEXPAND, 5); + + page1_sizer->Add(m_page1.languageBoxSizer, 0, wxALL | wxEXPAND, 5); + + m_language->Bind(wxEVT_CHOICE, [this, m_language](const auto&) + { + const auto language = m_language->GetStringSelection(); + auto selection = m_language->GetSelection(); + if (selection == 0) + GetConfig().language = wxLANGUAGE_DEFAULT; + else + { + auto* app = (CemuApp*)wxTheApp; + const auto language = m_language->GetStringSelection(); + for (const auto& lang : app->GetLanguages()) + { + if (lang->DescriptionNative == language) + { + app->LocalizeUI(static_cast<wxLanguage>(lang->Language)); + wxCommandEvent event(EVT_REFRESH_FIRST_PAGE); + wxPostEvent(this, event); + break; + } + } + } + }); + } +#endif + + { + m_page1.gamePathBoxSizer = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("Game paths")); + m_page1.gamePathText = new wxStaticText(m_page1.gamePathBoxSizer->GetStaticBox(), wxID_ANY, _("The game path is scanned by Cemu to automatically locate your games, game updates and DLCs. We recommend creating a dedicated directory in which\nyou place all your Wii U game files. Additional paths can be set later in Cemu's general settings. All common Wii U game formats are supported by Cemu.")); + m_page1.gamePathBoxSizer->Add(m_page1.gamePathText, 0, wxALL, 5); auto* game_path_sizer = new wxBoxSizer(wxHORIZONTAL); - game_path_sizer->Add(new wxStaticText(sizer->GetStaticBox(), wxID_ANY, _("Game path")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + m_page1.gamePathText2 = new wxStaticText(m_page1.gamePathBoxSizer->GetStaticBox(), wxID_ANY, _("Game path")); + game_path_sizer->Add(m_page1.gamePathText2, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_game_path = new wxDirPickerCtrl(sizer->GetStaticBox(), wxID_ANY, wxEmptyString, _("Select a folder")); - game_path_sizer->Add(m_game_path, 1, wxALL, 5); + m_page1.gamePathPicker = new wxDirPickerCtrl(m_page1.gamePathBoxSizer->GetStaticBox(), wxID_ANY, wxEmptyString, _("Select a folder")); + game_path_sizer->Add(m_page1.gamePathPicker, 1, wxALL, 5); - sizer->Add(game_path_sizer, 0, wxEXPAND, 5); + m_page1.gamePathBoxSizer->Add(game_path_sizer, 0, wxEXPAND, 5); - page1_sizer->Add(sizer, 0, wxALL | wxEXPAND, 5); + page1_sizer->Add(m_page1.gamePathBoxSizer, 0, wxALL | wxEXPAND, 5); } { - auto* sizer = new wxStaticBoxSizer(wxVERTICAL, result, _("Graphic packs")); + auto* sizer = new wxStaticBoxSizer(wxVERTICAL, mainPanel, _("Graphic packs && mods")); - sizer->Add(new wxStaticText(sizer->GetStaticBox(), wxID_ANY, _("Graphic packs improve games by offering the possibility to change resolution, tweak FPS or add other visual or gameplay modifications.\nDownload the community graphic packs to get started.\n")), 0, wxALL, 5); + sizer->Add(new wxStaticText(sizer->GetStaticBox(), wxID_ANY, _("Graphic packs improve games by offering the ability to change resolution, increase FPS, tweak visuals or add gameplay modifications.\nGet started by opening the graphic packs configuration window.\n")), 0, wxALL, 5); - auto* download_gp = new wxButton(sizer->GetStaticBox(), wxID_ANY, _("Download community graphic packs")); - download_gp->Bind(wxEVT_BUTTON, &GettingStartedDialog::OnDownloadGPs, this); + auto* download_gp = new wxButton(sizer->GetStaticBox(), wxID_ANY, _("Download and configure graphic packs")); + download_gp->Bind(wxEVT_BUTTON, &GettingStartedDialog::OnConfigureGPs, this); sizer->Add(download_gp, 0, wxALIGN_CENTER | wxALL, 5); page1_sizer->Add(sizer, 0, wxALL | wxEXPAND, 5); @@ -102,16 +127,15 @@ wxPanel* GettingStartedDialog::CreatePage1() sizer->SetFlexibleDirection(wxBOTH); sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL); - auto* next = new wxButton(result, wxID_ANY, _("Next"), wxDefaultPosition, wxDefaultSize, 0); + auto* next = new wxButton(mainPanel, wxID_ANY, _("Next"), wxDefaultPosition, wxDefaultSize, 0); next->Bind(wxEVT_BUTTON, [this](const auto&){m_notebook->SetSelection(1); }); sizer->Add(next, 0, wxALIGN_BOTTOM | wxALIGN_RIGHT | wxALL, 5); page1_sizer->Add(sizer, 1, wxEXPAND, 5); } - - result->SetSizer(page1_sizer); - return result; + mainPanel->SetSizer(page1_sizer); + return mainPanel; } wxPanel* GettingStartedDialog::CreatePage2() @@ -138,17 +162,17 @@ wxPanel* GettingStartedDialog::CreatePage2() option_sizer->SetFlexibleDirection(wxBOTH); option_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - m_fullscreen = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Start games with fullscreen")); - option_sizer->Add(m_fullscreen, 0, wxALL, 5); + m_page2.fullscreenCheckbox = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Start games with fullscreen")); + option_sizer->Add(m_page2.fullscreenCheckbox, 0, wxALL, 5); - m_separate = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Open separate pad screen")); - option_sizer->Add(m_separate, 0, wxALL, 5); + m_page2.separateCheckbox = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Open separate pad screen")); + option_sizer->Add(m_page2.separateCheckbox, 0, wxALL, 5); - m_update = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Automatically check for updates")); - option_sizer->Add(m_update, 0, wxALL, 5); + m_page2.updateCheckbox = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Automatically check for updates")); + option_sizer->Add(m_page2.updateCheckbox, 0, wxALL, 5); #if BOOST_OS_LINUX if (!std::getenv("APPIMAGE")) { - m_update->Disable(); + m_page2.updateCheckbox->Disable(); } #endif sizer->Add(option_sizer, 1, wxEXPAND, 5); @@ -162,10 +186,6 @@ wxPanel* GettingStartedDialog::CreatePage2() sizer->SetFlexibleDirection(wxBOTH); sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL); - m_dont_show = new wxCheckBox(result, wxID_ANY, _("Don't show this again")); - m_dont_show->SetValue(true); - sizer->Add(m_dont_show, 0, wxALIGN_BOTTOM | wxALL, 5); - auto* previous = new wxButton(result, wxID_ANY, _("Previous")); previous->Bind(wxEVT_BUTTON, [this](const auto&) {m_notebook->SetSelection(0); }); sizer->Add(previous, 0, wxALIGN_BOTTOM | wxALIGN_RIGHT | wxALL, 5); @@ -184,23 +204,9 @@ wxPanel* GettingStartedDialog::CreatePage2() void GettingStartedDialog::ApplySettings() { auto& config = GetConfig(); - m_fullscreen->SetValue(config.fullscreen.GetValue()); - m_update->SetValue(config.check_update.GetValue()); - m_separate->SetValue(config.pad_open.GetValue()); - m_dont_show->SetValue(true); // we want it always enabled by default - m_mlc_folder->SetPath(config.mlc_path.GetValue()); - - try - { - const auto pconfig = PermanentConfig::Load(); - if(!pconfig.custom_mlc_path.empty()) - { - m_mlc_folder->SetPath(wxString::FromUTF8(pconfig.custom_mlc_path)); - m_prev_mlc_warning->Show(true); - } - } - catch (const PSDisabledException&) {} - catch (...) {} + m_page2.fullscreenCheckbox->SetValue(config.fullscreen.GetValue()); + m_page2.updateCheckbox->SetValue(config.check_update.GetValue()); + m_page2.separateCheckbox->SetValue(config.pad_open.GetValue()); } void GettingStartedDialog::UpdateWindowSize() @@ -219,46 +225,25 @@ void GettingStartedDialog::OnClose(wxCloseEvent& event) event.Skip(); auto& config = GetConfig(); - config.fullscreen = m_fullscreen->GetValue(); - config.check_update = m_update->GetValue(); - config.pad_open = m_separate->GetValue(); - config.did_show_graphic_pack_download = m_dont_show->GetValue(); + config.fullscreen = m_page2.fullscreenCheckbox->GetValue(); + config.check_update = m_page2.updateCheckbox->GetValue(); + config.pad_open = m_page2.separateCheckbox->GetValue(); - const fs::path gamePath = wxHelper::MakeFSPath(m_game_path->GetPath()); - if (!gamePath.empty() && fs::exists(gamePath)) + const fs::path gamePath = wxHelper::MakeFSPath(m_page1.gamePathPicker->GetPath()); + std::error_code ec; + if (!gamePath.empty() && fs::exists(gamePath, ec)) { const auto it = std::find(config.game_paths.cbegin(), config.game_paths.cend(), gamePath); if (it == config.game_paths.cend()) { config.game_paths.emplace_back(_pathToUtf8(gamePath)); - m_game_path_changed = true; } } - - const fs::path mlcPath = wxHelper::MakeFSPath(m_mlc_folder->GetPath()); - if(config.mlc_path.GetValue() != mlcPath && (mlcPath.empty() || fs::exists(mlcPath))) - { - config.SetMLCPath(mlcPath, false); - m_mlc_changed = true; - } - - g_config.Save(); - - if(m_mlc_changed) - CemuApp::CreateDefaultFiles(); - - CafeTitleList::ClearScanPaths(); - for (auto& it : GetConfig().game_paths) - CafeTitleList::AddScanPath(_utf8ToPath(it)); - CafeTitleList::Refresh(); } - GettingStartedDialog::GettingStartedDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _("Getting started"), wxDefaultPosition, { 740,530 }, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { - //this->SetSizeHints(wxDefaultSize, { 740,530 }); - auto* sizer = new wxBoxSizer(wxVERTICAL); m_notebook = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0); @@ -274,24 +259,18 @@ GettingStartedDialog::GettingStartedDialog(wxWindow* parent) this->SetSizer(sizer); this->Centre(wxBOTH); this->Bind(wxEVT_CLOSE_WINDOW, &GettingStartedDialog::OnClose, this); - + ApplySettings(); UpdateWindowSize(); } -void GettingStartedDialog::OnDownloadGPs(wxCommandEvent& event) +void GettingStartedDialog::OnConfigureGPs(wxCommandEvent& event) { DownloadGraphicPacksWindow dialog(this); dialog.ShowModal(); - GraphicPacksWindow2::RefreshGraphicPacks(); - - wxMessageDialog ask_dialog(this, _("Do you want to view the downloaded graphic packs?"), _("Graphic packs"), wxCENTRE | wxYES_NO); - if (ask_dialog.ShowModal() == wxID_YES) - { - GraphicPacksWindow2 window(this, 0); - window.ShowModal(); - } + GraphicPacksWindow2 window(this, 0); + window.ShowModal(); } void GettingStartedDialog::OnInputSettings(wxCommandEvent& event) @@ -299,20 +278,3 @@ void GettingStartedDialog::OnInputSettings(wxCommandEvent& event) InputSettings2 dialog(this); dialog.ShowModal(); } - -void GettingStartedDialog::OnMLCPathChar(wxKeyEvent& event) -{ - //if (LaunchSettings::GetMLCPath().has_value()) - // return; - - if (event.GetKeyCode() == WXK_DELETE || event.GetKeyCode() == WXK_BACK) - { - m_mlc_folder->GetTextCtrl()->SetValue(wxEmptyString); - if(m_prev_mlc_warning->IsShown()) - { - m_prev_mlc_warning->Show(false); - UpdateWindowSize(); - } - } -} - diff --git a/src/gui/GettingStartedDialog.h b/src/gui/GettingStartedDialog.h index ec122eab..9dfd69b4 100644 --- a/src/gui/GettingStartedDialog.h +++ b/src/gui/GettingStartedDialog.h @@ -13,9 +13,6 @@ class GettingStartedDialog : public wxDialog public: GettingStartedDialog(wxWindow* parent = nullptr); - [[nodiscard]] bool HasGamePathChanged() const { return m_game_path_changed; } - [[nodiscard]] bool HasMLCChanged() const { return m_mlc_changed; } - private: wxPanel* CreatePage1(); wxPanel* CreatePage2(); @@ -23,22 +20,29 @@ private: void UpdateWindowSize(); void OnClose(wxCloseEvent& event); - void OnDownloadGPs(wxCommandEvent& event); + void OnConfigureGPs(wxCommandEvent& event); void OnInputSettings(wxCommandEvent& event); - void OnMLCPathChar(wxKeyEvent& event); wxSimplebook* m_notebook; - wxCheckBox* m_fullscreen; - wxCheckBox* m_separate; - wxCheckBox* m_update; - wxCheckBox* m_dont_show; - wxStaticBoxSizer* m_mlc_box_sizer; - wxStaticText* m_prev_mlc_warning; - wxDirPickerCtrl* m_mlc_folder; - wxDirPickerCtrl* m_game_path; + struct + { + // header + wxStaticText* staticText11{}; + wxStaticText* portableModeInfoText{}; - bool m_game_path_changed = false; - bool m_mlc_changed = false; + // game path box + wxStaticBoxSizer* gamePathBoxSizer{}; + wxStaticText* gamePathText{}; + wxStaticText* gamePathText2{}; + wxDirPickerCtrl* gamePathPicker{}; + }m_page1; + + struct + { + wxCheckBox* fullscreenCheckbox; + wxCheckBox* separateCheckbox; + wxCheckBox* updateCheckbox; + }m_page2; }; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7a4f3174..c83ab16b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -149,8 +149,6 @@ enum // help MAINFRAME_MENU_ID_HELP_ABOUT = 21700, MAINFRAME_MENU_ID_HELP_UPDATE, - MAINFRAME_MENU_ID_HELP_GETTING_STARTED, - // custom MAINFRAME_ID_TIMER1 = 21800, }; @@ -225,7 +223,6 @@ EVT_MENU(MAINFRAME_MENU_ID_DEBUG_VIEW_TEXTURE_RELATIONS, MainWindow::OnDebugView // help menu EVT_MENU(MAINFRAME_MENU_ID_HELP_ABOUT, MainWindow::OnHelpAbout) EVT_MENU(MAINFRAME_MENU_ID_HELP_UPDATE, MainWindow::OnHelpUpdate) -EVT_MENU(MAINFRAME_MENU_ID_HELP_GETTING_STARTED, MainWindow::OnHelpGettingStarted) // misc EVT_COMMAND(wxID_ANY, wxEVT_REQUEST_GAMELIST_REFRESH, MainWindow::OnRequestGameListRefresh) @@ -418,25 +415,6 @@ wxString MainWindow::GetInitialWindowTitle() return BUILD_VERSION_WITH_NAME_STRING; } -void MainWindow::ShowGettingStartedDialog() -{ - GettingStartedDialog dia(this); - dia.ShowModal(); - if (dia.HasGamePathChanged() || dia.HasMLCChanged()) - m_game_list->ReloadGameEntries(); - - TogglePadView(); - - auto& config = GetConfig(); - m_padViewMenuItem->Check(config.pad_open.GetValue()); - m_fullscreenMenuItem->Check(config.fullscreen.GetValue()); -} - -namespace coreinit -{ - void OSSchedulerEnd(); -}; - void MainWindow::OnClose(wxCloseEvent& event) { wxTheClipboard->Flush(); @@ -2075,11 +2053,6 @@ void MainWindow::OnHelpUpdate(wxCommandEvent& event) test.ShowModal(); } -void MainWindow::OnHelpGettingStarted(wxCommandEvent& event) -{ - ShowGettingStartedDialog(); -} - void MainWindow::RecreateMenu() { if (m_menuBar) @@ -2303,8 +2276,7 @@ void MainWindow::RecreateMenu() if (!std::getenv("APPIMAGE")) { m_check_update_menu->Enable(false); } -#endif - helpMenu->Append(MAINFRAME_MENU_ID_HELP_GETTING_STARTED, _("&Getting started")); +#endif helpMenu->AppendSeparator(); helpMenu->Append(MAINFRAME_MENU_ID_HELP_ABOUT, _("&About Cemu")); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index dd4d0d0d..beb86f98 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -103,7 +103,6 @@ public: void OnAccountSelect(wxCommandEvent& event); void OnConsoleLanguage(wxCommandEvent& event); void OnHelpAbout(wxCommandEvent& event); - void OnHelpGettingStarted(wxCommandEvent& event); void OnHelpUpdate(wxCommandEvent& event); void OnDebugSetting(wxCommandEvent& event); void OnDebugLoggingToggleFlagGeneric(wxCommandEvent& event); @@ -150,7 +149,6 @@ private: void RecreateMenu(); void UpdateChildWindowTitleRunningState(); static wxString GetInitialWindowTitle(); - void ShowGettingStartedDialog(); bool InstallUpdate(const fs::path& metaFilePath); diff --git a/src/main.cpp b/src/main.cpp index 1ccc2805..ea1df684 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include "Cafe/OS/RPL/rpl.h" #include "Cafe/OS/libs/gx2/GX2.h" #include "Cafe/OS/libs/coreinit/coreinit_Thread.h" -#include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "Cafe/GameProfile/GameProfile.h" #include "Cafe/GraphicPack/GraphicPack2.h" #include "config/CemuConfig.h" @@ -160,7 +159,7 @@ void ExpressionParser_test(); void FSTVolumeTest(); void CRCTest(); -void unitTests() +void UnitTests() { ExpressionParser_test(); gx2CopySurfaceTest(); @@ -169,17 +168,6 @@ void unitTests() CRCTest(); } -int mainEmulatorHLE() -{ - LatteOverlay_init(); - // run a couple of tests if in non-release mode -#ifdef CEMU_DEBUG_ASSERT - unitTests(); -#endif - CemuCommonInit(); - return 0; -} - bool isConsoleConnected = false; void requireConsole() { From a1c1a608d77e6c1f7989127d472c655d3159df62 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Tue, 23 Jul 2024 02:18:48 +0100 Subject: [PATCH 213/314] nsyshid: Emulate Infinity Base (#1246) --- src/Cafe/CMakeLists.txt | 2 + src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp | 8 + src/Cafe/OS/libs/nsyshid/Infinity.cpp | 1102 +++++++++++++++++ src/Cafe/OS/libs/nsyshid/Infinity.h | 105 ++ src/Cafe/OS/libs/nsyshid/Skylander.cpp | 2 +- src/Cafe/OS/libs/nsyshid/Skylander.h | 8 +- src/config/CemuConfig.cpp | 2 + src/config/CemuConfig.h | 1 + .../EmulatedUSBDeviceFrame.cpp | 252 +++- .../EmulatedUSBDeviceFrame.h | 18 + 10 files changed, 1478 insertions(+), 22 deletions(-) create mode 100644 src/Cafe/OS/libs/nsyshid/Infinity.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/Infinity.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 1583bdd7..0fb7a44b 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -463,6 +463,8 @@ add_library(CemuCafe OS/libs/nsyshid/BackendLibusb.h OS/libs/nsyshid/BackendWindowsHID.cpp OS/libs/nsyshid/BackendWindowsHID.h + OS/libs/nsyshid/Infinity.cpp + OS/libs/nsyshid/Infinity.h OS/libs/nsyshid/Skylander.cpp OS/libs/nsyshid/Skylander.h OS/libs/nsyskbd/nsyskbd.cpp diff --git a/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp index 11a299ed..95eaf06a 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp @@ -1,4 +1,5 @@ #include "BackendEmulated.h" +#include "Infinity.h" #include "Skylander.h" #include "config/CemuConfig.h" @@ -25,5 +26,12 @@ namespace nsyshid::backend::emulated auto device = std::make_shared<SkylanderPortalDevice>(); AttachDevice(device); } + if (GetConfig().emulated_usb_devices.emulate_infinity_base && !FindDeviceById(0x0E6F, 0x0129)) + { + cemuLog_logDebug(LogType::Force, "Attaching Emulated Base"); + // Add Infinity Base + auto device = std::make_shared<InfinityBaseDevice>(); + AttachDevice(device); + } } } // namespace nsyshid::backend::emulated \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Infinity.cpp b/src/Cafe/OS/libs/nsyshid/Infinity.cpp new file mode 100644 index 00000000..ab44ef4a --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Infinity.cpp @@ -0,0 +1,1102 @@ +#include "Infinity.h" + +#include <random> + +#include "nsyshid.h" +#include "Backend.h" + +#include "util/crypto/aes128.h" + +#include <openssl/crypto.h> +#include "openssl/sha.h" + +namespace nsyshid +{ + static constexpr std::array<uint8, 32> SHA1_CONSTANT = { + 0xAF, 0x62, 0xD2, 0xEC, 0x04, 0x91, 0x96, 0x8C, 0xC5, 0x2A, 0x1A, 0x71, 0x65, 0xF8, 0x65, 0xFE, + 0x28, 0x63, 0x29, 0x20, 0x44, 0x69, 0x73, 0x6e, 0x65, 0x79, 0x20, 0x32, 0x30, 0x31, 0x33}; + + InfinityUSB g_infinitybase; + + const std::map<const uint32, const std::pair<const uint8, const char*>> s_listFigures = { + {0x0F4241, {1, "Mr. Incredible"}}, + {0x0F4242, {1, "Sulley"}}, + {0x0F4243, {1, "Jack Sparrow"}}, + {0x0F4244, {1, "Lone Ranger"}}, + {0x0F4245, {1, "Tonto"}}, + {0x0F4246, {1, "Lightning McQueen"}}, + {0x0F4247, {1, "Holley Shiftwell"}}, + {0x0F4248, {1, "Buzz Lightyear"}}, + {0x0F4249, {1, "Jessie"}}, + {0x0F424A, {1, "Mike"}}, + {0x0F424B, {1, "Mrs. Incredible"}}, + {0x0F424C, {1, "Hector Barbossa"}}, + {0x0F424D, {1, "Davy Jones"}}, + {0x0F424E, {1, "Randy"}}, + {0x0F424F, {1, "Syndrome"}}, + {0x0F4250, {1, "Woody"}}, + {0x0F4251, {1, "Mater"}}, + {0x0F4252, {1, "Dash"}}, + {0x0F4253, {1, "Violet"}}, + {0x0F4254, {1, "Francesco Bernoulli"}}, + {0x0F4255, {1, "Sorcerer's Apprentice Mickey"}}, + {0x0F4256, {1, "Jack Skellington"}}, + {0x0F4257, {1, "Rapunzel"}}, + {0x0F4258, {1, "Anna"}}, + {0x0F4259, {1, "Elsa"}}, + {0x0F425A, {1, "Phineas"}}, + {0x0F425B, {1, "Agent P"}}, + {0x0F425C, {1, "Wreck-It Ralph"}}, + {0x0F425D, {1, "Vanellope"}}, + {0x0F425E, {1, "Mr. Incredible (Crystal)"}}, + {0x0F425F, {1, "Jack Sparrow (Crystal)"}}, + {0x0F4260, {1, "Sulley (Crystal)"}}, + {0x0F4261, {1, "Lightning McQueen (Crystal)"}}, + {0x0F4262, {1, "Lone Ranger (Crystal)"}}, + {0x0F4263, {1, "Buzz Lightyear (Crystal)"}}, + {0x0F4264, {1, "Agent P (Crystal)"}}, + {0x0F4265, {1, "Sorcerer's Apprentice Mickey (Crystal)"}}, + {0x0F4266, {1, "Buzz Lightyear (Glowing)"}}, + {0x0F42A4, {2, "Captain America"}}, + {0x0F42A5, {2, "Hulk"}}, + {0x0F42A6, {2, "Iron Man"}}, + {0x0F42A7, {2, "Thor"}}, + {0x0F42A8, {2, "Groot"}}, + {0x0F42A9, {2, "Rocket Raccoon"}}, + {0x0F42AA, {2, "Star-Lord"}}, + {0x0F42AB, {2, "Spider-Man"}}, + {0x0F42AC, {2, "Nick Fury"}}, + {0x0F42AD, {2, "Black Widow"}}, + {0x0F42AE, {2, "Hawkeye"}}, + {0x0F42AF, {2, "Drax"}}, + {0x0F42B0, {2, "Gamora"}}, + {0x0F42B1, {2, "Iron Fist"}}, + {0x0F42B2, {2, "Nova"}}, + {0x0F42B3, {2, "Venom"}}, + {0x0F42B4, {2, "Donald Duck"}}, + {0x0F42B5, {2, "Aladdin"}}, + {0x0F42B6, {2, "Stitch"}}, + {0x0F42B7, {2, "Merida"}}, + {0x0F42B8, {2, "Tinker Bell"}}, + {0x0F42B9, {2, "Maleficent"}}, + {0x0F42BA, {2, "Hiro"}}, + {0x0F42BB, {2, "Baymax"}}, + {0x0F42BC, {2, "Loki"}}, + {0x0F42BD, {2, "Ronan"}}, + {0x0F42BE, {2, "Green Goblin"}}, + {0x0F42BF, {2, "Falcon"}}, + {0x0F42C0, {2, "Yondu"}}, + {0x0F42C1, {2, "Jasmine"}}, + {0x0F42C6, {2, "Black Suit Spider-Man"}}, + {0x0F42D6, {3, "Sam Flynn"}}, + {0x0F42D7, {3, "Quorra"}}, + {0x0F4308, {3, "Anakin Skywalker"}}, + {0x0F4309, {3, "Obi-Wan Kenobi"}}, + {0x0F430A, {3, "Yoda"}}, + {0x0F430B, {3, "Ahsoka Tano"}}, + {0x0F430C, {3, "Darth Maul"}}, + {0x0F430E, {3, "Luke Skywalker"}}, + {0x0F430F, {3, "Han Solo"}}, + {0x0F4310, {3, "Princess Leia"}}, + {0x0F4311, {3, "Chewbacca"}}, + {0x0F4312, {3, "Darth Vader"}}, + {0x0F4313, {3, "Boba Fett"}}, + {0x0F4314, {3, "Ezra Bridger"}}, + {0x0F4315, {3, "Kanan Jarrus"}}, + {0x0F4316, {3, "Sabine Wren"}}, + {0x0F4317, {3, "Zeb Orrelios"}}, + {0x0F4318, {3, "Joy"}}, + {0x0F4319, {3, "Anger"}}, + {0x0F431A, {3, "Fear"}}, + {0x0F431B, {3, "Sadness"}}, + {0x0F431C, {3, "Disgust"}}, + {0x0F431D, {3, "Mickey Mouse"}}, + {0x0F431E, {3, "Minnie Mouse"}}, + {0x0F431F, {3, "Mulan"}}, + {0x0F4320, {3, "Olaf"}}, + {0x0F4321, {3, "Vision"}}, + {0x0F4322, {3, "Ultron"}}, + {0x0F4323, {3, "Ant-Man"}}, + {0x0F4325, {3, "Captain America - The First Avenger"}}, + {0x0F4326, {3, "Finn"}}, + {0x0F4327, {3, "Kylo Ren"}}, + {0x0F4328, {3, "Poe Dameron"}}, + {0x0F4329, {3, "Rey"}}, + {0x0F432B, {3, "Spot"}}, + {0x0F432C, {3, "Nick Wilde"}}, + {0x0F432D, {3, "Judy Hopps"}}, + {0x0F432E, {3, "Hulkbuster"}}, + {0x0F432F, {3, "Anakin Skywalker (Light FX)"}}, + {0x0F4330, {3, "Obi-Wan Kenobi (Light FX)"}}, + {0x0F4331, {3, "Yoda (Light FX)"}}, + {0x0F4332, {3, "Luke Skywalker (Light FX)"}}, + {0x0F4333, {3, "Darth Vader (Light FX)"}}, + {0x0F4334, {3, "Kanan Jarrus (Light FX)"}}, + {0x0F4335, {3, "Kylo Ren (Light FX)"}}, + {0x0F4336, {3, "Black Panther"}}, + {0x0F436C, {3, "Nemo"}}, + {0x0F436D, {3, "Dory"}}, + {0x0F436E, {3, "Baloo"}}, + {0x0F436F, {3, "Alice"}}, + {0x0F4370, {3, "Mad Hatter"}}, + {0x0F4371, {3, "Time"}}, + {0x0F4372, {3, "Peter Pan"}}, + {0x1E8481, {1, "Starter Play Set"}}, + {0x1E8482, {1, "Lone Ranger Play Set"}}, + {0x1E8483, {1, "Cars Play Set"}}, + {0x1E8484, {1, "Toy Story in Space Play Set"}}, + {0x1E84E4, {2, "Marvel's The Avengers Play Set"}}, + {0x1E84E5, {2, "Marvel's Spider-Man Play Set"}}, + {0x1E84E6, {2, "Marvel's Guardians of the Galaxy Play Set"}}, + {0x1E84E7, {2, "Assault on Asgard"}}, + {0x1E84E8, {2, "Escape from the Kyln"}}, + {0x1E84E9, {2, "Stitch's Tropical Rescue"}}, + {0x1E84EA, {2, "Brave Forest Siege"}}, + {0x1E8548, {3, "Inside Out Play Set"}}, + {0x1E8549, {3, "Star Wars: Twilight of the Republic Play Set"}}, + {0x1E854A, {3, "Star Wars: Rise Against the Empire Play Set"}}, + {0x1E854B, {3, "Star Wars: The Force Awakens Play Set"}}, + {0x1E854C, {3, "Marvel Battlegrounds Play Set"}}, + {0x1E854D, {3, "Toy Box Speedway"}}, + {0x1E854E, {3, "Toy Box Takeover"}}, + {0x1E85AC, {3, "Finding Dory Play Set"}}, + {0x2DC6C3, {1, "Bolt's Super Strength"}}, + {0x2DC6C4, {1, "Ralph's Power of Destruction"}}, + {0x2DC6C5, {1, "Chernabog's Power"}}, + {0x2DC6C6, {1, "C.H.R.O.M.E. Damage Increaser"}}, + {0x2DC6C7, {1, "Dr. Doofenshmirtz's Damage-Inator!"}}, + {0x2DC6C8, {1, "Electro-Charge"}}, + {0x2DC6C9, {1, "Fix-It Felix's Repair Power"}}, + {0x2DC6CA, {1, "Rapunzel's Healing"}}, + {0x2DC6CB, {1, "C.H.R.O.M.E. Armor Shield"}}, + {0x2DC6CC, {1, "Star Command Shield"}}, + {0x2DC6CD, {1, "Violet's Force Field"}}, + {0x2DC6CE, {1, "Pieces of Eight"}}, + {0x2DC6CF, {1, "Scrooge McDuck's Lucky Dime"}}, + {0x2DC6D0, {1, "User Control"}}, + {0x2DC6D1, {1, "Sorcerer Mickey's Hat"}}, + {0x2DC6FE, {1, "Emperor Zurg's Wrath"}}, + {0x2DC6FF, {1, "Merlin's Summon"}}, + {0x2DC765, {2, "Enchanted Rose"}}, + {0x2DC766, {2, "Mulan's Training Uniform"}}, + {0x2DC767, {2, "Flubber"}}, + {0x2DC768, {2, "S.H.I.E.L.D. Helicarrier Strike"}}, + {0x2DC769, {2, "Zeus' Thunderbolts"}}, + {0x2DC76A, {2, "King Louie's Monkeys"}}, + {0x2DC76B, {2, "Infinity Gauntlet"}}, + {0x2DC76D, {2, "Sorcerer Supreme"}}, + {0x2DC76E, {2, "Maleficent's Spell Cast"}}, + {0x2DC76F, {2, "Chernabog's Spirit Cyclone"}}, + {0x2DC770, {2, "Marvel Team-Up: Capt. Marvel"}}, + {0x2DC771, {2, "Marvel Team-Up: Iron Patriot"}}, + {0x2DC772, {2, "Marvel Team-Up: Ant-Man"}}, + {0x2DC773, {2, "Marvel Team-Up: White Tiger"}}, + {0x2DC774, {2, "Marvel Team-Up: Yondu"}}, + {0x2DC775, {2, "Marvel Team-Up: Winter Soldier"}}, + {0x2DC776, {2, "Stark Arc Reactor"}}, + {0x2DC777, {2, "Gamma Rays"}}, + {0x2DC778, {2, "Alien Symbiote"}}, + {0x2DC779, {2, "All for One"}}, + {0x2DC77A, {2, "Sandy Claws Surprise"}}, + {0x2DC77B, {2, "Glory Days"}}, + {0x2DC77C, {2, "Cursed Pirate Gold"}}, + {0x2DC77D, {2, "Sentinel of Liberty"}}, + {0x2DC77E, {2, "The Immortal Iron Fist"}}, + {0x2DC77F, {2, "Space Armor"}}, + {0x2DC780, {2, "Rags to Riches"}}, + {0x2DC781, {2, "Ultimate Falcon"}}, + {0x2DC788, {3, "Tomorrowland Time Bomb"}}, + {0x2DC78E, {3, "Galactic Team-Up: Mace Windu"}}, + {0x2DC791, {3, "Luke's Rebel Alliance Flight Suit Costume"}}, + {0x2DC798, {3, "Finn's Stormtrooper Costume"}}, + {0x2DC799, {3, "Poe's Resistance Jacket"}}, + {0x2DC79A, {3, "Resistance Tactical Strike"}}, + {0x2DC79E, {3, "Officer Nick Wilde"}}, + {0x2DC79F, {3, "Meter Maid Judy"}}, + {0x2DC7A2, {3, "Darkhawk's Blast"}}, + {0x2DC7A3, {3, "Cosmic Cube Blast"}}, + {0x2DC7A4, {3, "Princess Leia's Boushh Disguise"}}, + {0x2DC7A6, {3, "Nova Corps Strike"}}, + {0x2DC7A7, {3, "King Mickey"}}, + {0x3D0912, {1, "Mickey's Car"}}, + {0x3D0913, {1, "Cinderella's Coach"}}, + {0x3D0914, {1, "Electric Mayhem Bus"}}, + {0x3D0915, {1, "Cruella De Vil's Car"}}, + {0x3D0916, {1, "Pizza Planet Delivery Truck"}}, + {0x3D0917, {1, "Mike's New Car"}}, + {0x3D0919, {1, "Parking Lot Tram"}}, + {0x3D091A, {1, "Captain Hook's Ship"}}, + {0x3D091B, {1, "Dumbo"}}, + {0x3D091C, {1, "Calico Helicopter"}}, + {0x3D091D, {1, "Maximus"}}, + {0x3D091E, {1, "Angus"}}, + {0x3D091F, {1, "Abu the Elephant"}}, + {0x3D0920, {1, "Headless Horseman's Horse"}}, + {0x3D0921, {1, "Phillipe"}}, + {0x3D0922, {1, "Khan"}}, + {0x3D0923, {1, "Tantor"}}, + {0x3D0924, {1, "Dragon Firework Cannon"}}, + {0x3D0925, {1, "Stitch's Blaster"}}, + {0x3D0926, {1, "Toy Story Mania Blaster"}}, + {0x3D0927, {1, "Flamingo Croquet Mallet"}}, + {0x3D0928, {1, "Carl Fredricksen's Cane"}}, + {0x3D0929, {1, "Hangin' Ten Stitch With Surfboard"}}, + {0x3D092A, {1, "Condorman Glider"}}, + {0x3D092B, {1, "WALL-E's Fire Extinguisher"}}, + {0x3D092C, {1, "On the Grid"}}, + {0x3D092D, {1, "WALL-E's Collection"}}, + {0x3D092E, {1, "King Candy's Dessert Toppings"}}, + {0x3D0930, {1, "Victor's Experiments"}}, + {0x3D0931, {1, "Jack's Scary Decorations"}}, + {0x3D0933, {1, "Frozen Flourish"}}, + {0x3D0934, {1, "Rapunzel's Kingdom"}}, + {0x3D0935, {1, "TRON Interface"}}, + {0x3D0936, {1, "Buy N Large Atmosphere"}}, + {0x3D0937, {1, "Sugar Rush Sky"}}, + {0x3D0939, {1, "New Holland Skyline"}}, + {0x3D093A, {1, "Halloween Town Sky"}}, + {0x3D093C, {1, "Chill in the Air"}}, + {0x3D093D, {1, "Rapunzel's Birthday Sky"}}, + {0x3D0940, {1, "Astro Blasters Space Cruiser"}}, + {0x3D0941, {1, "Marlin's Reef"}}, + {0x3D0942, {1, "Nemo's Seascape"}}, + {0x3D0943, {1, "Alice's Wonderland"}}, + {0x3D0944, {1, "Tulgey Wood"}}, + {0x3D0945, {1, "Tri-State Area Terrain"}}, + {0x3D0946, {1, "Danville Sky"}}, + {0x3D0965, {2, "Stark Tech"}}, + {0x3D0966, {2, "Spider-Streets"}}, + {0x3D0967, {2, "World War Hulk"}}, + {0x3D0968, {2, "Gravity Falls Forest"}}, + {0x3D0969, {2, "Neverland"}}, + {0x3D096A, {2, "Simba's Pridelands"}}, + {0x3D096C, {2, "Calhoun's Command"}}, + {0x3D096D, {2, "Star-Lord's Galaxy"}}, + {0x3D096E, {2, "Dinosaur World"}}, + {0x3D096F, {2, "Groot's Roots"}}, + {0x3D0970, {2, "Mulan's Countryside"}}, + {0x3D0971, {2, "The Sands of Agrabah"}}, + {0x3D0974, {2, "A Small World"}}, + {0x3D0975, {2, "View from the Suit"}}, + {0x3D0976, {2, "Spider-Sky"}}, + {0x3D0977, {2, "World War Hulk Sky"}}, + {0x3D0978, {2, "Gravity Falls Sky"}}, + {0x3D0979, {2, "Second Star to the Right"}}, + {0x3D097A, {2, "The King's Domain"}}, + {0x3D097C, {2, "CyBug Swarm"}}, + {0x3D097D, {2, "The Rip"}}, + {0x3D097E, {2, "Forgotten Skies"}}, + {0x3D097F, {2, "Groot's View"}}, + {0x3D0980, {2, "The Middle Kingdom"}}, + {0x3D0984, {2, "Skies of the World"}}, + {0x3D0985, {2, "S.H.I.E.L.D. Containment Truck"}}, + {0x3D0986, {2, "Main Street Electrical Parade Float"}}, + {0x3D0987, {2, "Mr. Toad's Motorcar"}}, + {0x3D0988, {2, "Le Maximum"}}, + {0x3D0989, {2, "Alice in Wonderland's Caterpillar"}}, + {0x3D098A, {2, "Eglantine's Motorcycle"}}, + {0x3D098B, {2, "Medusa's Swamp Mobile"}}, + {0x3D098C, {2, "Hydra Motorcycle"}}, + {0x3D098D, {2, "Darkwing Duck's Ratcatcher"}}, + {0x3D098F, {2, "The USS Swinetrek"}}, + {0x3D0991, {2, "Spider-Copter"}}, + {0x3D0992, {2, "Aerial Area Rug"}}, + {0x3D0993, {2, "Jack-O-Lantern's Glider"}}, + {0x3D0994, {2, "Spider-Buggy"}}, + {0x3D0995, {2, "Jack Skellington's Reindeer"}}, + {0x3D0996, {2, "Fantasyland Carousel Horse"}}, + {0x3D0997, {2, "Odin's Horse"}}, + {0x3D0998, {2, "Gus the Mule"}}, + {0x3D099A, {2, "Darkwing Duck's Grappling Gun"}}, + {0x3D099C, {2, "Ghost Rider's Chain Whip"}}, + {0x3D099D, {2, "Lew Zealand's Boomerang Fish"}}, + {0x3D099E, {2, "Sergeant Calhoun's Blaster"}}, + {0x3D09A0, {2, "Falcon's Wings"}}, + {0x3D09A1, {2, "Mabel's Kittens for Fists"}}, + {0x3D09A2, {2, "Jim Hawkins' Solar Board"}}, + {0x3D09A3, {2, "Black Panther's Vibranium Knives"}}, + {0x3D09A4, {2, "Cloak of Levitation"}}, + {0x3D09A5, {2, "Aladdin's Magic Carpet"}}, + {0x3D09A6, {2, "Honey Lemon's Ice Capsules"}}, + {0x3D09A7, {2, "Jasmine's Palace View"}}, + {0x3D09C1, {2, "Lola"}}, + {0x3D09C2, {2, "Spider-Cycle"}}, + {0x3D09C3, {2, "The Avenjet"}}, + {0x3D09C4, {2, "Spider-Glider"}}, + {0x3D09C5, {2, "Light Cycle"}}, + {0x3D09C6, {2, "Light Jet"}}, + {0x3D09C9, {3, "Retro Ray Gun"}}, + {0x3D09CA, {3, "Tomorrowland Futurescape"}}, + {0x3D09CB, {3, "Tomorrowland Stratosphere"}}, + {0x3D09CC, {3, "Skies Over Felucia"}}, + {0x3D09CD, {3, "Forests of Felucia"}}, + {0x3D09CF, {3, "General Grievous' Wheel Bike"}}, + {0x3D09D2, {3, "Slave I Flyer"}}, + {0x3D09D3, {3, "Y-Wing Fighter"}}, + {0x3D09D4, {3, "Arlo"}}, + {0x3D09D5, {3, "Nash"}}, + {0x3D09D6, {3, "Butch"}}, + {0x3D09D7, {3, "Ramsey"}}, + {0x3D09DC, {3, "Stars Over Sahara Square"}}, + {0x3D09DD, {3, "Sahara Square Sands"}}, + {0x3D09E0, {3, "Ghost Rider's Motorcycle"}}, + {0x3D09E5, {3, "Quad Jumper"}}}; + + InfinityBaseDevice::InfinityBaseDevice() + : Device(0x0E6F, 0x0129, 1, 2, 0) + { + m_IsOpened = false; + } + + bool InfinityBaseDevice::Open() + { + if (!IsOpened()) + { + m_IsOpened = true; + } + return true; + } + + void InfinityBaseDevice::Close() + { + if (IsOpened()) + { + m_IsOpened = false; + } + } + + bool InfinityBaseDevice::IsOpened() + { + return m_IsOpened; + } + + Device::ReadResult InfinityBaseDevice::Read(ReadMessage* message) + { + memcpy(message->data, g_infinitybase.GetStatus().data(), message->length); + message->bytesRead = message->length; + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + return Device::ReadResult::Success; + } + + Device::WriteResult InfinityBaseDevice::Write(WriteMessage* message) + { + g_infinitybase.SendCommand(message->data, message->length); + message->bytesWritten = message->length; + return Device::WriteResult::Success; + } + + bool InfinityBaseDevice::GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) + { + uint8 configurationDescriptor[0x29]; + + uint8* currentWritePtr; + + // configuration descriptor + currentWritePtr = configurationDescriptor + 0; + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength + *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces + *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue + *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration + *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes + *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber + *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting + *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints + *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass + *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass + *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol + *(uint8*)(currentWritePtr + 8) = 0; // iInterface + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID + *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode + *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors + *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType + *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength + currentWritePtr = currentWritePtr + 9; + // endpoint descriptor 1 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + // endpoint descriptor 2 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 1) = 0x02; // bEndpointAddress + *(uint8*)(currentWritePtr + 2) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 3) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 5) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + + cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); + + memcpy(output, configurationDescriptor, + std::min<uint32>(outputMaxLength, sizeof(configurationDescriptor))); + return true; + } + + bool InfinityBaseDevice::SetProtocol(uint8 ifIndex, uint8 protocol) + { + return true; + } + + bool InfinityBaseDevice::SetReport(ReportMessage* message) + { + return true; + } + + std::array<uint8, 32> InfinityUSB::GetStatus() + { + std::array<uint8, 32> response = {}; + + bool responded = false; + + do + { + if (!m_figureAddedRemovedResponses.empty()) + { + memcpy(response.data(), m_figureAddedRemovedResponses.front().data(), + 0x20); + m_figureAddedRemovedResponses.pop(); + responded = true; + } + else if (!m_queries.empty()) + { + memcpy(response.data(), m_queries.front().data(), 0x20); + m_queries.pop(); + responded = true; + } + else + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + /* code */ + } + while (!responded); + + return response; + } + + void InfinityUSB::SendCommand(uint8* buf, sint32 originalLength) + { + const uint8 command = buf[2]; + const uint8 sequence = buf[3]; + + std::array<uint8, 32> q_result{}; + + switch (command) + { + case 0x80: + { + q_result = {0xaa, 0x15, 0x00, 0x00, 0x0f, 0x01, 0x00, 0x03, + 0x02, 0x09, 0x09, 0x43, 0x20, 0x32, 0x62, 0x36, + 0x36, 0x4b, 0x34, 0x99, 0x67, 0x31, 0x93, 0x8c}; + break; + } + case 0x81: + { + // Initiate Challenge + g_infinitybase.DescrambleAndSeed(buf, sequence, q_result); + break; + } + case 0x83: + { + // Challenge Response + g_infinitybase.GetNextAndScramble(sequence, q_result); + break; + } + case 0x90: + case 0x92: + case 0x93: + case 0x95: + case 0x96: + { + // Color commands + g_infinitybase.GetBlankResponse(sequence, q_result); + break; + } + case 0xA1: + { + // Get Present Figures + g_infinitybase.GetPresentFigures(sequence, q_result); + break; + } + case 0xA2: + { + // Read Block from Figure + g_infinitybase.QueryBlock(buf[4], buf[5], q_result, sequence); + break; + } + case 0xA3: + { + // Write block to figure + g_infinitybase.WriteBlock(buf[4], buf[5], &buf[7], q_result, sequence); + break; + } + case 0xB4: + { + // Get figure ID + g_infinitybase.GetFigureIdentifier(buf[4], sequence, q_result); + break; + } + case 0xB5: + { + // Get status? + g_infinitybase.GetBlankResponse(sequence, q_result); + break; + } + default: + cemu_assert_error(); + break; + } + + m_queries.push(q_result); + } + + uint8 InfinityUSB::GenerateChecksum(const std::array<uint8, 32>& data, + int numOfBytes) const + { + int checksum = 0; + for (int i = 0; i < numOfBytes; i++) + { + checksum += data[i]; + } + return (checksum & 0xFF); + } + + void InfinityUSB::GetBlankResponse(uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + replyBuf[0] = 0xaa; + replyBuf[1] = 0x01; + replyBuf[2] = sequence; + replyBuf[3] = GenerateChecksum(replyBuf, 3); + } + + void InfinityUSB::DescrambleAndSeed(uint8* buf, uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + uint64 value = uint64(buf[4]) << 56 | uint64(buf[5]) << 48 | + uint64(buf[6]) << 40 | uint64(buf[7]) << 32 | + uint64(buf[8]) << 24 | uint64(buf[9]) << 16 | + uint64(buf[10]) << 8 | uint64(buf[11]); + uint32 seed = Descramble(value); + GenerateSeed(seed); + GetBlankResponse(sequence, replyBuf); + } + + void InfinityUSB::GetNextAndScramble(uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + const uint32 nextRandom = GetNext(); + const uint64 scrambledNextRandom = Scramble(nextRandom, 0); + replyBuf = {0xAA, 0x09, sequence}; + replyBuf[3] = uint8((scrambledNextRandom >> 56) & 0xFF); + replyBuf[4] = uint8((scrambledNextRandom >> 48) & 0xFF); + replyBuf[5] = uint8((scrambledNextRandom >> 40) & 0xFF); + replyBuf[6] = uint8((scrambledNextRandom >> 32) & 0xFF); + replyBuf[7] = uint8((scrambledNextRandom >> 24) & 0xFF); + replyBuf[8] = uint8((scrambledNextRandom >> 16) & 0xFF); + replyBuf[9] = uint8((scrambledNextRandom >> 8) & 0xFF); + replyBuf[10] = uint8(scrambledNextRandom & 0xFF); + replyBuf[11] = GenerateChecksum(replyBuf, 11); + } + + uint32 InfinityUSB::Descramble(uint64 numToDescramble) + { + uint64 mask = 0x8E55AA1B3999E8AA; + uint32 ret = 0; + + for (int i = 0; i < 64; i++) + { + if (mask & 0x8000000000000000) + { + ret = (ret << 1) | (numToDescramble & 0x01); + } + + numToDescramble >>= 1; + mask <<= 1; + } + + return ret; + } + + uint64 InfinityUSB::Scramble(uint32 numToScramble, uint32 garbage) + { + uint64 mask = 0x8E55AA1B3999E8AA; + uint64 ret = 0; + + for (int i = 0; i < 64; i++) + { + ret <<= 1; + + if ((mask & 1) != 0) + { + ret |= (numToScramble & 1); + numToScramble >>= 1; + } + else + { + ret |= (garbage & 1); + garbage >>= 1; + } + + mask >>= 1; + } + + return ret; + } + + void InfinityUSB::GenerateSeed(uint32 seed) + { + m_randomA = 0xF1EA5EED; + m_randomB = seed; + m_randomC = seed; + m_randomD = seed; + + for (int i = 0; i < 23; i++) + { + GetNext(); + } + } + + uint32 InfinityUSB::GetNext() + { + uint32 a = m_randomA; + uint32 b = m_randomB; + uint32 c = m_randomC; + uint32 ret = std::rotl(m_randomB, 27); + + const uint32 temp = (a + ((ret ^ 0xFFFFFFFF) + 1)); + b ^= std::rotl(c, 17); + a = m_randomD; + c += a; + ret = b + temp; + a += temp; + + m_randomC = a; + m_randomA = b; + m_randomB = c; + m_randomD = ret; + + return ret; + } + + void InfinityUSB::GetPresentFigures(uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + int x = 3; + for (uint8 i = 0; i < m_figures.size(); i++) + { + uint8 slot = i == 0 ? 0x10 : (i < 4) ? 0x20 + : 0x30; + if (m_figures[i].present) + { + replyBuf[x] = slot + m_figures[i].orderAdded; + replyBuf[x + 1] = 0x09; + x += 2; + } + } + replyBuf[0] = 0xaa; + replyBuf[1] = x - 2; + replyBuf[2] = sequence; + replyBuf[x] = GenerateChecksum(replyBuf, x); + } + + InfinityUSB::InfinityFigure& + InfinityUSB::GetFigureByOrder(uint8 orderAdded) + { + for (uint8 i = 0; i < m_figures.size(); i++) + { + if (m_figures[i].orderAdded == orderAdded) + { + return m_figures[i]; + } + } + return m_figures[0]; + } + + void InfinityUSB::QueryBlock(uint8 fig_num, uint8 block, + std::array<uint8, 32>& replyBuf, + uint8 sequence) + { + std::lock_guard lock(m_infinityMutex); + + InfinityFigure& figure = GetFigureByOrder(fig_num); + + replyBuf[0] = 0xaa; + replyBuf[1] = 0x12; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + const uint8 file_block = (block == 0) ? 1 : (block * 4); + if (figure.present && file_block < 20) + { + memcpy(&replyBuf[4], figure.data.data() + (16 * file_block), 16); + } + replyBuf[20] = GenerateChecksum(replyBuf, 20); + } + + void InfinityUSB::WriteBlock(uint8 fig_num, uint8 block, + const uint8* to_write_buf, + std::array<uint8, 32>& replyBuf, + uint8 sequence) + { + std::lock_guard lock(m_infinityMutex); + + InfinityFigure& figure = GetFigureByOrder(fig_num); + + replyBuf[0] = 0xaa; + replyBuf[1] = 0x02; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + const uint8 file_block = (block == 0) ? 1 : (block * 4); + if (figure.present && file_block < 20) + { + memcpy(figure.data.data() + (file_block * 16), to_write_buf, 16); + figure.Save(); + } + replyBuf[4] = GenerateChecksum(replyBuf, 4); + } + + void InfinityUSB::GetFigureIdentifier(uint8 fig_num, uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + std::lock_guard lock(m_infinityMutex); + + InfinityFigure& figure = GetFigureByOrder(fig_num); + + replyBuf[0] = 0xaa; + replyBuf[1] = 0x09; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + + if (figure.present) + { + memcpy(&replyBuf[4], figure.data.data(), 7); + } + replyBuf[11] = GenerateChecksum(replyBuf, 11); + } + + std::pair<uint8, std::string> InfinityUSB::FindFigure(uint32 figNum) + { + for (const auto& it : GetFigureList()) + { + if (it.first == figNum) + { + return it.second; + } + } + return {0, fmt::format("Unknown Figure ({})", figNum)}; + } + + std::map<const uint32, const std::pair<const uint8, const char*>> InfinityUSB::GetFigureList() + { + return s_listFigures; + } + + void InfinityUSB::InfinityFigure::Save() + { + if (!infFile) + return; + + infFile->SetPosition(0); + infFile->writeData(data.data(), data.size()); + } + + bool InfinityUSB::RemoveFigure(uint8 position) + { + std::lock_guard lock(m_infinityMutex); + InfinityFigure& figure = m_figures[position]; + + figure.Save(); + figure.infFile.reset(); + + if (figure.present) + { + figure.present = false; + + position = DeriveFigurePosition(position); + if (position == 0) + { + return false; + } + + std::array<uint8, 32> figureChangeResponse = {0xab, 0x04, position, 0x09, figure.orderAdded, + 0x01}; + figureChangeResponse[6] = GenerateChecksum(figureChangeResponse, 6); + m_figureAddedRemovedResponses.push(figureChangeResponse); + + return true; + } + return false; + } + + uint32 + InfinityUSB::LoadFigure(const std::array<uint8, INF_FIGURE_SIZE>& buf, + std::unique_ptr<FileStream> inFile, uint8 position) + { + std::lock_guard lock(m_infinityMutex); + uint8 orderAdded; + + std::vector<uint8> sha1Calc = {SHA1_CONSTANT.begin(), SHA1_CONSTANT.end() - 1}; + for (int i = 0; i < 7; i++) + { + sha1Calc.push_back(buf[i]); + } + + std::array<uint8, 16> key = GenerateInfinityFigureKey(sha1Calc); + + std::array<uint8, 16> infinity_decrypted_block = {}; + std::array<uint8, 16> encryptedBlock = {}; + memcpy(encryptedBlock.data(), &buf[16], 16); + + AES128_ECB_decrypt(encryptedBlock.data(), key.data(), infinity_decrypted_block.data()); + + uint32 number = uint32(infinity_decrypted_block[1]) << 16 | uint32(infinity_decrypted_block[2]) << 8 | + uint32(infinity_decrypted_block[3]); + + InfinityFigure& figure = m_figures[position]; + + figure.infFile = std::move(inFile); + memcpy(figure.data.data(), buf.data(), figure.data.size()); + figure.present = true; + if (figure.orderAdded == 255) + { + figure.orderAdded = m_figureOrder; + m_figureOrder++; + } + orderAdded = figure.orderAdded; + + position = DeriveFigurePosition(position); + if (position == 0) + { + return 0; + } + + std::array<uint8, 32> figureChangeResponse = {0xab, 0x04, position, 0x09, orderAdded, 0x00}; + figureChangeResponse[6] = GenerateChecksum(figureChangeResponse, 6); + m_figureAddedRemovedResponses.push(figureChangeResponse); + + return number; + } + + static uint32 InfinityCRC32(const std::array<uint8, 16>& buffer) + { + static constexpr std::array<uint32, 256> CRC32_TABLE{ + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, + 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, + 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, + 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, + 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, + 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, + 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, + 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, + 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, + 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, + 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, + 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, + 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, + 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, + 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, + 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, + 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, + 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, + 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, + 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; + + // Infinity m_figures calculate their CRC32 based on 12 bytes in the block of 16 + uint32 ret = 0; + for (uint32 i = 0; i < 12; ++i) + { + uint8 index = uint8(ret & 0xFF) ^ buffer[i]; + ret = ((ret >> 8) ^ CRC32_TABLE[index]); + } + + return ret; + } + + bool InfinityUSB::CreateFigure(fs::path pathName, uint32 figureNum, uint8 series) + { + FileStream* infFile(FileStream::createFile2(pathName)); + if (!infFile) + { + return false; + } + std::array<uint8, INF_FIGURE_SIZE> fileData{}; + uint32 firstBlock = 0x17878E; + uint32 otherBlocks = 0x778788; + for (sint8 i = 2; i >= 0; i--) + { + fileData[0x38 - i] = uint8((firstBlock >> i * 8) & 0xFF); + } + for (uint32 index = 1; index < 0x05; index++) + { + for (sint8 i = 2; i >= 0; i--) + { + fileData[((index * 0x40) + 0x38) - i] = uint8((otherBlocks >> i * 8) & 0xFF); + } + } + // Create the vector to calculate the SHA1 hash with + std::vector<uint8> sha1Calc = {SHA1_CONSTANT.begin(), SHA1_CONSTANT.end() - 1}; + + // Generate random UID, used for AES encrypt/decrypt + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution<int> dist(0, 255); + std::array<uint8, 16> uid_data = {0, 0, 0, 0, 0, 0, 0, 0x89, 0x44, 0x00, 0xC2}; + uid_data[0] = dist(mt); + uid_data[1] = dist(mt); + uid_data[2] = dist(mt); + uid_data[3] = dist(mt); + uid_data[4] = dist(mt); + uid_data[5] = dist(mt); + uid_data[6] = dist(mt); + for (sint8 i = 0; i < 7; i++) + { + sha1Calc.push_back(uid_data[i]); + } + std::array<uint8, 16> figureData = GenerateBlankFigureData(figureNum, series); + if (figureData[1] == 0x00) + return false; + + std::array<uint8, 16> key = GenerateInfinityFigureKey(sha1Calc); + + std::array<uint8, 16> encryptedBlock = {}; + std::array<uint8, 16> blankBlock = {}; + std::array<uint8, 16> encryptedBlank = {}; + + AES128_ECB_encrypt(figureData.data(), key.data(), encryptedBlock.data()); + AES128_ECB_encrypt(blankBlock.data(), key.data(), encryptedBlank.data()); + + memcpy(&fileData[0], uid_data.data(), uid_data.size()); + memcpy(&fileData[16], encryptedBlock.data(), encryptedBlock.size()); + memcpy(&fileData[16 * 0x04], encryptedBlank.data(), encryptedBlank.size()); + memcpy(&fileData[16 * 0x08], encryptedBlank.data(), encryptedBlank.size()); + memcpy(&fileData[16 * 0x0C], encryptedBlank.data(), encryptedBlank.size()); + memcpy(&fileData[16 * 0x0D], encryptedBlank.data(), encryptedBlank.size()); + + infFile->writeData(fileData.data(), fileData.size()); + + delete infFile; + + return true; + } + + std::array<uint8, 16> InfinityUSB::GenerateInfinityFigureKey(const std::vector<uint8>& sha1Data) + { + std::array<uint8, 20> digest = {}; + SHA_CTX ctx; + SHA1_Init(&ctx); + SHA1_Update(&ctx, sha1Data.data(), sha1Data.size()); + SHA1_Final(digest.data(), &ctx); + OPENSSL_cleanse(&ctx, sizeof(ctx)); + // Infinity AES keys are the first 16 bytes of the SHA1 Digest, every set of 4 bytes need to be + // reversed due to endianness + std::array<uint8, 16> key = {}; + for (int i = 0; i < 4; i++) + { + for (int x = 3; x >= 0; x--) + { + key[(3 - x) + (i * 4)] = digest[x + (i * 4)]; + } + } + return key; + } + + std::array<uint8, 16> InfinityUSB::GenerateBlankFigureData(uint32 figureNum, uint8 series) + { + std::array<uint8, 16> figureData = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0xD1, 0x1F}; + + // Figure Number, input by end user + figureData[1] = uint8((figureNum >> 16) & 0xFF); + figureData[2] = uint8((figureNum >> 8) & 0xFF); + figureData[3] = uint8(figureNum & 0xFF); + + // Manufacture date, formatted as YY/MM/DD. Set to release date of figure's series + if (series == 1) + { + figureData[4] = 0x0D; + figureData[5] = 0x08; + figureData[6] = 0x12; + } + else if (series == 2) + { + figureData[4] = 0x0E; + figureData[5] = 0x09; + figureData[6] = 0x12; + } + else if (series == 3) + { + figureData[4] = 0x0F; + figureData[5] = 0x08; + figureData[6] = 0x1C; + } + + uint32 checksum = InfinityCRC32(figureData); + for (sint8 i = 3; i >= 0; i--) + { + figureData[15 - i] = uint8((checksum >> i * 8) & 0xFF); + } + return figureData; + } + + uint8 InfinityUSB::DeriveFigurePosition(uint8 position) + { + // In the added/removed response, position needs to be 1 for the hexagon, 2 for Player 1 and + // Player 1's abilities, and 3 for Player 2 and Player 2's abilities. In the UI, positions 0, 1 + // and 2 represent the hexagon slot, 3, 4 and 5 represent Player 1's slot and 6, 7 and 8 represent + // Player 2's slot. + + switch (position) + { + case 0: + case 1: + case 2: + return 1; + case 3: + case 4: + case 5: + return 2; + case 6: + case 7: + case 8: + return 3; + + default: + return 0; + } + } +} // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Infinity.h b/src/Cafe/OS/libs/nsyshid/Infinity.h new file mode 100644 index 00000000..aa98fd15 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Infinity.h @@ -0,0 +1,105 @@ +#pragma once + +#include <mutex> + +#include "nsyshid.h" +#include "Backend.h" + +#include "Common/FileStream.h" + +namespace nsyshid +{ + class InfinityBaseDevice final : public Device { + public: + InfinityBaseDevice(); + ~InfinityBaseDevice() = default; + + bool Open() override; + + void Close() override; + + bool IsOpened() override; + + ReadResult Read(ReadMessage* message) override; + + WriteResult Write(WriteMessage* message) override; + + bool GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) override; + + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; + + bool SetReport(ReportMessage* message) override; + + private: + bool m_IsOpened; + }; + + constexpr uint16 INF_BLOCK_COUNT = 0x14; + constexpr uint16 INF_BLOCK_SIZE = 0x10; + constexpr uint16 INF_FIGURE_SIZE = INF_BLOCK_COUNT * INF_BLOCK_SIZE; + constexpr uint8 MAX_FIGURES = 9; + class InfinityUSB { + public: + struct InfinityFigure final + { + std::unique_ptr<FileStream> infFile; + std::array<uint8, INF_FIGURE_SIZE> data{}; + bool present = false; + uint8 orderAdded = 255; + void Save(); + }; + + void SendCommand(uint8* buf, sint32 originalLength); + std::array<uint8, 32> GetStatus(); + + void GetBlankResponse(uint8 sequence, std::array<uint8, 32>& replyBuf); + void DescrambleAndSeed(uint8* buf, uint8 sequence, + std::array<uint8, 32>& replyBuf); + void GetNextAndScramble(uint8 sequence, std::array<uint8, 32>& replyBuf); + void GetPresentFigures(uint8 sequence, std::array<uint8, 32>& replyBuf); + void QueryBlock(uint8 figNum, uint8 block, std::array<uint8, 32>& replyBuf, + uint8 sequence); + void WriteBlock(uint8 figNum, uint8 block, const uint8* toWriteBuf, + std::array<uint8, 32>& replyBuf, uint8 sequence); + void GetFigureIdentifier(uint8 figNum, uint8 sequence, + std::array<uint8, 32>& replyBuf); + + bool RemoveFigure(uint8 position); + uint32 LoadFigure(const std::array<uint8, INF_FIGURE_SIZE>& buf, + std::unique_ptr<FileStream>, uint8 position); + bool CreateFigure(fs::path pathName, uint32 figureNum, uint8 series); + static std::map<const uint32, const std::pair<const uint8, const char*>> GetFigureList(); + std::pair<uint8, std::string> FindFigure(uint32 figNum); + + protected: + std::shared_mutex m_infinityMutex; + std::array<InfinityFigure, 9> m_figures; + + private: + uint8 GenerateChecksum(const std::array<uint8, 32>& data, + int numOfBytes) const; + uint32 Descramble(uint64 numToDescramble); + uint64 Scramble(uint32 numToScramble, uint32 garbage); + void GenerateSeed(uint32 seed); + uint32 GetNext(); + InfinityFigure& GetFigureByOrder(uint8 orderAdded); + uint8 DeriveFigurePosition(uint8 position); + std::array<uint8, 16> GenerateInfinityFigureKey(const std::vector<uint8>& sha1Data); + std::array<uint8, 16> GenerateBlankFigureData(uint32 figureNum, uint8 series); + + uint32 m_randomA; + uint32 m_randomB; + uint32 m_randomC; + uint32 m_randomD; + + uint8 m_figureOrder = 0; + std::queue<std::array<uint8, 32>> m_figureAddedRemovedResponses; + std::queue<std::array<uint8, 32>> m_queries; + }; + extern InfinityUSB g_infinitybase; + +} // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp index 7f17f8a3..a9888787 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.cpp +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -855,7 +855,7 @@ namespace nsyshid return false; } - std::array<uint8, BLOCK_COUNT * BLOCK_SIZE> data{}; + std::array<uint8, SKY_FIGURE_SIZE> data{}; uint32 first_block = 0x690F0F0F; uint32 other_blocks = 0x69080F7F; diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h index ae8b5d92..95eaff0c 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.h +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -38,9 +38,9 @@ namespace nsyshid bool m_IsOpened; }; - constexpr uint16 BLOCK_COUNT = 0x40; - constexpr uint16 BLOCK_SIZE = 0x10; - constexpr uint16 FIGURE_SIZE = BLOCK_COUNT * BLOCK_SIZE; + constexpr uint16 SKY_BLOCK_COUNT = 0x40; + constexpr uint16 SKY_BLOCK_SIZE = 0x10; + constexpr uint16 SKY_FIGURE_SIZE = SKY_BLOCK_COUNT * SKY_BLOCK_SIZE; constexpr uint8 MAX_SKYLANDERS = 16; class SkylanderUSB { @@ -50,7 +50,7 @@ namespace nsyshid std::unique_ptr<FileStream> skyFile; uint8 status = 0; std::queue<uint8> queuedStatus; - std::array<uint8, BLOCK_COUNT * BLOCK_SIZE> data{}; + std::array<uint8, SKY_BLOCK_SIZE> data{}; uint32 lastId = 0; void Save(); diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 03b12731..338392dd 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -344,6 +344,7 @@ void CemuConfig::Load(XMLConfigParser& parser) // emulatedusbdevices auto usbdevices = parser.get("EmulatedUsbDevices"); emulated_usb_devices.emulate_skylander_portal = usbdevices.get("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal); + emulated_usb_devices.emulate_infinity_base = usbdevices.get("EmulateInfinityBase", emulated_usb_devices.emulate_infinity_base); } void CemuConfig::Save(XMLConfigParser& parser) @@ -541,6 +542,7 @@ void CemuConfig::Save(XMLConfigParser& parser) // emulated usb devices auto usbdevices = config.set("EmulatedUsbDevices"); usbdevices.set("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal.GetValue()); + usbdevices.set("EmulateInfinityBase", emulated_usb_devices.emulate_infinity_base.GetValue()); } GameEntry* CemuConfig::GetGameEntryByTitleId(uint64 titleId) diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 3f3da953..2a1d29cb 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -519,6 +519,7 @@ struct CemuConfig struct { ConfigValue<bool> emulate_skylander_portal{false}; + ConfigValue<bool> emulate_infinity_base{true}; }emulated_usb_devices{}; private: diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp index f43c3690..f4784f35 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -43,6 +43,7 @@ EmulatedUSBDeviceFrame::EmulatedUSBDeviceFrame(wxWindow* parent) auto* notebook = new wxNotebook(this, wxID_ANY); notebook->AddPage(AddSkylanderPage(notebook), _("Skylanders Portal")); + notebook->AddPage(AddInfinityPage(notebook), _("Infinity Base")); sizer->Add(notebook, 1, wxEXPAND | wxALL, 2); @@ -83,32 +84,98 @@ wxPanel* EmulatedUSBDeviceFrame::AddSkylanderPage(wxNotebook* notebook) return panel; } -wxBoxSizer* EmulatedUSBDeviceFrame::AddSkylanderRow(uint8 row_number, +wxPanel* EmulatedUSBDeviceFrame::AddInfinityPage(wxNotebook* notebook) +{ + auto* panel = new wxPanel(notebook); + auto* panelSizer = new wxBoxSizer(wxBOTH); + auto* box = new wxStaticBox(panel, wxID_ANY, _("Infinity Manager")); + auto* boxSizer = new wxStaticBoxSizer(box, wxBOTH); + + auto* row = new wxBoxSizer(wxHORIZONTAL); + + m_emulateBase = + new wxCheckBox(box, wxID_ANY, _("Emulate Infinity Base")); + m_emulateBase->SetValue( + GetConfig().emulated_usb_devices.emulate_infinity_base); + m_emulateBase->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { + GetConfig().emulated_usb_devices.emulate_infinity_base = + m_emulateBase->IsChecked(); + g_config.Save(); + }); + row->Add(m_emulateBase, 1, wxEXPAND | wxALL, 2); + boxSizer->Add(row, 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Play Set/Power Disc", 0, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Power Disc Two", 1, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Power Disc Three", 2, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player One", 3, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player One Ability One", 4, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player One Ability Two", 5, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player Two", 6, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player Two Ability One", 7, box), 1, wxEXPAND | wxALL, 2); + boxSizer->Add(AddInfinityRow("Player Two Ability Two", 8, box), 1, wxEXPAND | wxALL, 2); + + panelSizer->Add(boxSizer, 1, wxEXPAND | wxALL, 2); + panel->SetSizerAndFit(panelSizer); + + return panel; +} + +wxBoxSizer* EmulatedUSBDeviceFrame::AddSkylanderRow(uint8 rowNumber, wxStaticBox* box) { auto* row = new wxBoxSizer(wxHORIZONTAL); row->Add(new wxStaticText(box, wxID_ANY, fmt::format("{} {}", _("Skylander").ToStdString(), - (row_number + 1))), + (rowNumber + 1))), 1, wxEXPAND | wxALL, 2); - m_skylanderSlots[row_number] = + m_skylanderSlots[rowNumber] = new wxTextCtrl(box, wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY); - m_skylanderSlots[row_number]->SetMinSize(wxSize(150, -1)); - m_skylanderSlots[row_number]->Disable(); - row->Add(m_skylanderSlots[row_number], 1, wxEXPAND | wxALL, 2); + m_skylanderSlots[rowNumber]->SetMinSize(wxSize(150, -1)); + m_skylanderSlots[rowNumber]->Disable(); + row->Add(m_skylanderSlots[rowNumber], 1, wxEXPAND | wxALL, 2); auto* loadButton = new wxButton(box, wxID_ANY, _("Load")); - loadButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { - LoadSkylander(row_number); + loadButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + LoadSkylander(rowNumber); }); auto* createButton = new wxButton(box, wxID_ANY, _("Create")); - createButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { - CreateSkylander(row_number); + createButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + CreateSkylander(rowNumber); }); auto* clearButton = new wxButton(box, wxID_ANY, _("Clear")); - clearButton->Bind(wxEVT_BUTTON, [row_number, this](wxCommandEvent&) { - ClearSkylander(row_number); + clearButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + ClearSkylander(rowNumber); + }); + row->Add(loadButton, 1, wxEXPAND | wxALL, 2); + row->Add(createButton, 1, wxEXPAND | wxALL, 2); + row->Add(clearButton, 1, wxEXPAND | wxALL, 2); + + return row; +} + +wxBoxSizer* EmulatedUSBDeviceFrame::AddInfinityRow(wxString name, uint8 rowNumber, wxStaticBox* box) +{ + auto* row = new wxBoxSizer(wxHORIZONTAL); + + row->Add(new wxStaticText(box, wxID_ANY, name), 1, wxEXPAND | wxALL, 2); + m_infinitySlots[rowNumber] = + new wxTextCtrl(box, wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, + wxTE_READONLY); + m_infinitySlots[rowNumber]->SetMinSize(wxSize(150, -1)); + m_infinitySlots[rowNumber]->Disable(); + row->Add(m_infinitySlots[rowNumber], 1, wxALL | wxEXPAND, 5); + auto* loadButton = new wxButton(box, wxID_ANY, _("Load")); + loadButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + LoadFigure(rowNumber); + }); + auto* createButton = new wxButton(box, wxID_ANY, _("Create")); + createButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + CreateFigure(rowNumber); + }); + auto* clearButton = new wxButton(box, wxID_ANY, _("Clear")); + clearButton->Bind(wxEVT_BUTTON, [rowNumber, this](wxCommandEvent&) { + ClearFigure(rowNumber); }); row->Add(loadButton, 1, wxEXPAND | wxALL, 2); row->Add(createButton, 1, wxEXPAND | wxALL, 2); @@ -138,7 +205,7 @@ void EmulatedUSBDeviceFrame::LoadSkylanderPath(uint8 slot, wxString path) return; } - std::array<uint8, 0x40 * 0x10> fileData; + std::array<uint8, nsyshid::SKY_FIGURE_SIZE> fileData; if (skyFile->readData(fileData.data(), fileData.size()) != fileData.size()) { wxMessageDialog open_error(this, "Failed to read file! File was too small"); @@ -218,15 +285,15 @@ CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) long longSkyId; if (!editId->GetValue().ToLong(&longSkyId) || longSkyId > 0xFFFF) { - wxMessageDialog id_error(this, "Error Converting ID!", "ID Entered is Invalid"); - id_error.ShowModal(); + wxMessageDialog idError(this, "Error Converting ID!", "ID Entered is Invalid"); + idError.ShowModal(); return; } long longSkyVar; if (!editVar->GetValue().ToLong(&longSkyVar) || longSkyVar > 0xFFFF) { - wxMessageDialog id_error(this, "Error Converting Variant!", "Variant Entered is Invalid"); - id_error.ShowModal(); + wxMessageDialog idError(this, "Error Converting Variant!", "Variant Entered is Invalid"); + idError.ShowModal(); return; } uint16 skyId = longSkyId & 0xFFFF; @@ -284,6 +351,157 @@ wxString CreateSkylanderDialog::GetFilePath() const return m_filePath; } +CreateInfinityFigureDialog::CreateInfinityFigureDialog(wxWindow* parent, uint8 slot) + : wxDialog(parent, wxID_ANY, _("Infinity Figure Creator"), wxDefaultPosition, wxSize(500, 150)) +{ + auto* sizer = new wxBoxSizer(wxVERTICAL); + + auto* comboRow = new wxBoxSizer(wxHORIZONTAL); + + auto* comboBox = new wxComboBox(this, wxID_ANY); + comboBox->Append("---Select---", reinterpret_cast<void*>(0xFFFFFF)); + wxArrayString filterlist; + for (const auto& it : nsyshid::g_infinitybase.GetFigureList()) + { + const uint32 figure = it.first; + if ((slot == 0 && + ((figure > 0x1E8480 && figure < 0x2DC6BF) || (figure > 0x3D0900 && figure < 0x4C4B3F))) || + ((slot == 1 || slot == 2) && (figure > 0x3D0900 && figure < 0x4C4B3F)) || + ((slot == 3 || slot == 6) && figure < 0x1E847F) || + ((slot == 4 || slot == 5 || slot == 7 || slot == 8) && + (figure > 0x2DC6C0 && figure < 0x3D08FF))) + { + comboBox->Append(it.second.second, reinterpret_cast<void*>(figure)); + filterlist.Add(it.second.second); + } + } + comboBox->SetSelection(0); + bool enabled = comboBox->AutoComplete(filterlist); + comboRow->Add(comboBox, 1, wxEXPAND | wxALL, 2); + + auto* figNumRow = new wxBoxSizer(wxHORIZONTAL); + + wxIntegerValidator<uint32> validator; + + auto* labelFigNum = new wxStaticText(this, wxID_ANY, "Figure Number:"); + auto* editFigNum = new wxTextCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0, validator); + + figNumRow->Add(labelFigNum, 1, wxALL, 5); + figNumRow->Add(editFigNum, 1, wxALL, 5); + + auto* buttonRow = new wxBoxSizer(wxHORIZONTAL); + + auto* createButton = new wxButton(this, wxID_ANY, _("Create")); + createButton->Bind(wxEVT_BUTTON, [editFigNum, this](wxCommandEvent&) { + long longFigNum; + if (!editFigNum->GetValue().ToLong(&longFigNum)) + { + wxMessageDialog idError(this, "Error Converting Figure Number!", "Number Entered is Invalid"); + idError.ShowModal(); + this->EndModal(0);; + } + uint32 figNum = longFigNum & 0xFFFFFFFF; + auto figure = nsyshid::g_infinitybase.FindFigure(figNum); + wxString predefName = figure.second + ".bin"; + wxFileDialog + saveFileDialog(this, _("Create Infinity Figure file"), "", predefName, + "BIN files (*.bin)|*.bin", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + + if (saveFileDialog.ShowModal() == wxID_CANCEL) + this->EndModal(0);; + + m_filePath = saveFileDialog.GetPath(); + + nsyshid::g_infinitybase.CreateFigure(_utf8ToPath(m_filePath.utf8_string()), figNum, figure.first); + + this->EndModal(1); + }); + auto* cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); + cancelButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { + this->EndModal(0); + }); + + comboBox->Bind(wxEVT_COMBOBOX, [comboBox, editFigNum, this](wxCommandEvent&) { + const uint64 fig_info = reinterpret_cast<uint64>(comboBox->GetClientData(comboBox->GetSelection())); + if (fig_info != 0xFFFFFF) + { + const uint32 figNum = fig_info & 0xFFFFFFFF; + + editFigNum->SetValue(wxString::Format(wxT("%i"), figNum)); + } + }); + + buttonRow->Add(createButton, 1, wxALL, 5); + buttonRow->Add(cancelButton, 1, wxALL, 5); + + sizer->Add(comboRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(figNumRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(buttonRow, 1, wxEXPAND | wxALL, 2); + + this->SetSizer(sizer); + this->Centre(wxBOTH); +} + +wxString CreateInfinityFigureDialog::GetFilePath() const +{ + return m_filePath; +} + +void EmulatedUSBDeviceFrame::LoadFigure(uint8 slot) +{ + wxFileDialog openFileDialog(this, _("Open Infinity Figure dump"), "", "", + "BIN files (*.bin)|*.bin", + wxFD_OPEN | wxFD_FILE_MUST_EXIST); + if (openFileDialog.ShowModal() != wxID_OK || openFileDialog.GetPath().empty()) + { + wxMessageDialog errorMessage(this, "File Okay Error"); + errorMessage.ShowModal(); + return; + } + + LoadFigurePath(slot, openFileDialog.GetPath()); +} + +void EmulatedUSBDeviceFrame::LoadFigurePath(uint8 slot, wxString path) +{ + std::unique_ptr<FileStream> infFile(FileStream::openFile2(_utf8ToPath(path.utf8_string()), true)); + if (!infFile) + { + wxMessageDialog errorMessage(this, "File Open Error"); + errorMessage.ShowModal(); + return; + } + + std::array<uint8, nsyshid::INF_FIGURE_SIZE> fileData; + if (infFile->readData(fileData.data(), fileData.size()) != fileData.size()) + { + wxMessageDialog open_error(this, "Failed to read file! File was too small"); + open_error.ShowModal(); + return; + } + ClearFigure(slot); + + uint32 number = nsyshid::g_infinitybase.LoadFigure(fileData, std::move(infFile), slot); + m_infinitySlots[slot]->ChangeValue(nsyshid::g_infinitybase.FindFigure(number).second); +} + +void EmulatedUSBDeviceFrame::CreateFigure(uint8 slot) +{ + cemuLog_log(LogType::Force, "Create Figure: {}", slot); + CreateInfinityFigureDialog create_dlg(this, slot); + create_dlg.ShowModal(); + if (create_dlg.GetReturnCode() == 1) + { + LoadFigurePath(slot, create_dlg.GetFilePath()); + } +} + +void EmulatedUSBDeviceFrame::ClearFigure(uint8 slot) +{ + m_infinitySlots[slot]->ChangeValue("None"); + nsyshid::g_infinitybase.RemoveFigure(slot); +} + void EmulatedUSBDeviceFrame::UpdateSkylanderEdits() { for (auto i = 0; i < nsyshid::MAX_SKYLANDERS; i++) diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h index 8988cb8a..ae29a036 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h @@ -5,6 +5,7 @@ #include <wx/dialog.h> #include <wx/frame.h> +#include "Cafe/OS/libs/nsyshid/Infinity.h" #include "Cafe/OS/libs/nsyshid/Skylander.h" class wxBoxSizer; @@ -23,15 +24,23 @@ class EmulatedUSBDeviceFrame : public wxFrame { private: wxCheckBox* m_emulatePortal; + wxCheckBox* m_emulateBase; std::array<wxTextCtrl*, nsyshid::MAX_SKYLANDERS> m_skylanderSlots; + std::array<wxTextCtrl*, nsyshid::MAX_FIGURES> m_infinitySlots; std::array<std::optional<std::tuple<uint8, uint16, uint16>>, nsyshid::MAX_SKYLANDERS> m_skySlots; wxPanel* AddSkylanderPage(wxNotebook* notebook); + wxPanel* AddInfinityPage(wxNotebook* notebook); wxBoxSizer* AddSkylanderRow(uint8 row_number, wxStaticBox* box); + wxBoxSizer* AddInfinityRow(wxString name, uint8 row_number, wxStaticBox* box); void LoadSkylander(uint8 slot); void LoadSkylanderPath(uint8 slot, wxString path); void CreateSkylander(uint8 slot); void ClearSkylander(uint8 slot); + void LoadFigure(uint8 slot); + void LoadFigurePath(uint8 slot, wxString path); + void CreateFigure(uint8 slot); + void ClearFigure(uint8 slot); void UpdateSkylanderEdits(); }; class CreateSkylanderDialog : public wxDialog { @@ -39,6 +48,15 @@ class CreateSkylanderDialog : public wxDialog { explicit CreateSkylanderDialog(wxWindow* parent, uint8 slot); wxString GetFilePath() const; + protected: + wxString m_filePath; +}; + +class CreateInfinityFigureDialog : public wxDialog { + public: + explicit CreateInfinityFigureDialog(wxWindow* parent, uint8 slot); + wxString GetFilePath() const; + protected: wxString m_filePath; }; \ No newline at end of file From e65abf48983f92a8de5259362f9842dbf3c28fb4 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Tue, 23 Jul 2024 21:18:55 +0100 Subject: [PATCH 214/314] Suppress unnecessary GTK messages (#1267) --- src/gui/CemuApp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index baa83888..f91c1e3a 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -235,6 +235,9 @@ void CemuApp::InitializeExistingMLCOrFail(fs::path mlc) bool CemuApp::OnInit() { +#if __WXGTK__ + GTKSuppressDiagnostics(G_LOG_LEVEL_MASK & ~G_LOG_FLAG_FATAL); +#endif std::set<fs::path> failedWriteAccess; DeterminePaths(failedWriteAccess); // make sure default cemu directories exist From 4b9c7c0d307495c679127381d6f00bab9f0c2933 Mon Sep 17 00:00:00 2001 From: Exverge <exverge@exverge.xyz> Date: Wed, 24 Jul 2024 02:32:40 -0400 Subject: [PATCH 215/314] Update Fedora build instructions (#1269) --- BUILD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index 3ff2254f..1e92527e 100644 --- a/BUILD.md +++ b/BUILD.md @@ -57,7 +57,7 @@ At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clan `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` #### For Fedora and derivatives: -`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel` +`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel zlib-static` ### Build Cemu From f1685eab665e1b262b47d6ea0c47d691fcc0f4a6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Jul 2024 05:48:42 +0200 Subject: [PATCH 216/314] h264: Use asynchronous decoding when possible (#1257) --- src/Cafe/CMakeLists.txt | 2 + .../OS/libs/coreinit/coreinit_SysHeap.cpp | 12 +- src/Cafe/OS/libs/coreinit/coreinit_SysHeap.h | 3 + src/Cafe/OS/libs/h264_avc/H264Dec.cpp | 755 +++--------------- .../OS/libs/h264_avc/H264DecBackendAVC.cpp | 502 ++++++++++++ src/Cafe/OS/libs/h264_avc/H264DecInternal.h | 139 ++++ .../OS/libs/h264_avc/parser/H264Parser.cpp | 17 +- src/Cafe/OS/libs/h264_avc/parser/H264Parser.h | 2 + 8 files changed, 787 insertions(+), 645 deletions(-) create mode 100644 src/Cafe/OS/libs/h264_avc/H264DecBackendAVC.cpp create mode 100644 src/Cafe/OS/libs/h264_avc/H264DecInternal.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 0fb7a44b..91d257b2 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -374,7 +374,9 @@ add_library(CemuCafe OS/libs/gx2/GX2_Texture.h OS/libs/gx2/GX2_TilingAperture.cpp OS/libs/h264_avc/H264Dec.cpp + OS/libs/h264_avc/H264DecBackendAVC.cpp OS/libs/h264_avc/h264dec.h + OS/libs/h264_avc/H264DecInternal.h OS/libs/h264_avc/parser OS/libs/h264_avc/parser/H264Parser.cpp OS/libs/h264_avc/parser/H264Parser.h diff --git a/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.cpp b/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.cpp index e37949d7..2f819c50 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.cpp @@ -14,13 +14,10 @@ namespace coreinit return coreinit::MEMAllocFromExpHeapEx(_sysHeapHandle, size, alignment); } - void export_OSAllocFromSystem(PPCInterpreter_t* hCPU) + void OSFreeToSystem(void* ptr) { - ppcDefineParamU32(size, 0); - ppcDefineParamS32(alignment, 1); - MEMPTR<void> mem = OSAllocFromSystem(size, alignment); - cemuLog_logDebug(LogType::Force, "OSAllocFromSystem(0x{:x}, {}) -> 0x{:08x}", size, alignment, mem.GetMPTR()); - osLib_returnFromFunction(hCPU, mem.GetMPTR()); + _sysHeapFreeCounter++; + coreinit::MEMFreeToExpHeap(_sysHeapHandle, ptr); } void InitSysHeap() @@ -34,7 +31,8 @@ namespace coreinit void InitializeSysHeap() { - osLib_addFunction("coreinit", "OSAllocFromSystem", export_OSAllocFromSystem); + cafeExportRegister("h264", OSAllocFromSystem, LogType::CoreinitMem); + cafeExportRegister("h264", OSFreeToSystem, LogType::CoreinitMem); } } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.h b/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.h index 428224af..ad115754 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_SysHeap.h @@ -4,5 +4,8 @@ namespace coreinit { void InitSysHeap(); + void* OSAllocFromSystem(uint32 size, uint32 alignment); + void OSFreeToSystem(void* ptr); + void InitializeSysHeap(); } \ No newline at end of file diff --git a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp index 024965fd..82db039b 100644 --- a/src/Cafe/OS/libs/h264_avc/H264Dec.cpp +++ b/src/Cafe/OS/libs/h264_avc/H264Dec.cpp @@ -1,17 +1,12 @@ #include "Cafe/OS/common/OSCommon.h" #include "Cafe/HW/Espresso/PPCCallback.h" #include "Cafe/OS/libs/h264_avc/parser/H264Parser.h" +#include "Cafe/OS/libs/h264_avc/H264DecInternal.h" #include "util/highresolutiontimer/HighResolutionTimer.h" #include "Cafe/CafeSystem.h" #include "h264dec.h" -extern "C" -{ -#include "../dependencies/ih264d/common/ih264_typedefs.h" -#include "../dependencies/ih264d/decoder/ih264d.h" -}; - enum class H264DEC_STATUS : uint32 { SUCCESS = 0x0, @@ -33,10 +28,35 @@ namespace H264 return false; } + struct H264Context + { + struct + { + MEMPTR<void> ptr{ nullptr }; + uint32be length{ 0 }; + float64be timestamp; + }BitStream; + struct + { + MEMPTR<void> outputFunc{ nullptr }; + uint8be outputPerFrame{ 0 }; // whats the default? + MEMPTR<void> userMemoryParam{ nullptr }; + }Param; + // misc + uint32be sessionHandle; + + // decoder state + struct + { + uint32 numFramesInFlight{0}; + }decoderState; + }; + uint32 H264DECMemoryRequirement(uint32 codecProfile, uint32 codecLevel, uint32 width, uint32 height, uint32be* sizeRequirementOut) { if (H264_IsBotW()) { + static_assert(sizeof(H264Context) < 256); *sizeRequirementOut = 256; return 0; } @@ -169,590 +189,47 @@ namespace H264 return H264DEC_STATUS::BAD_STREAM; } - struct H264Context - { - struct - { - MEMPTR<void> ptr{ nullptr }; - uint32be length{ 0 }; - float64be timestamp; - }BitStream; - struct - { - MEMPTR<void> outputFunc{ nullptr }; - uint8be outputPerFrame{ 0 }; // whats the default? - MEMPTR<void> userMemoryParam{ nullptr }; - }Param; - // misc - uint32be sessionHandle; - }; - - class H264AVCDecoder - { - static void* ivd_aligned_malloc(void* ctxt, WORD32 alignment, WORD32 size) - { -#ifdef _WIN32 - return _aligned_malloc(size, alignment); -#else - // alignment is atleast sizeof(void*) - alignment = std::max<WORD32>(alignment, sizeof(void*)); - - //smallest multiple of 2 at least as large as alignment - alignment--; - alignment |= alignment << 1; - alignment |= alignment >> 1; - alignment |= alignment >> 2; - alignment |= alignment >> 4; - alignment |= alignment >> 8; - alignment |= alignment >> 16; - alignment ^= (alignment >> 1); - - void* temp; - posix_memalign(&temp, (size_t)alignment, (size_t)size); - return temp; -#endif - } - - static void ivd_aligned_free(void* ctxt, void* buf) - { -#ifdef _WIN32 - _aligned_free(buf); -#else - free(buf); -#endif - return; - } - - public: - struct DecodeResult - { - bool frameReady{ false }; - double timestamp; - void* imageOutput; - ivd_video_decode_op_t decodeOutput; - }; - - void Init(bool isBufferedMode) - { - ih264d_create_ip_t s_create_ip{ 0 }; - ih264d_create_op_t s_create_op{ 0 }; - - s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ih264d_create_ip_t); - s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE; - s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = 1; // shared display buffer mode -> We give the decoder a list of buffers that it will use (?) - - s_create_op.s_ivd_create_op_t.u4_size = sizeof(ih264d_create_op_t); - s_create_ip.s_ivd_create_ip_t.e_output_format = IV_YUV_420SP_UV; - s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ivd_aligned_malloc; - s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ivd_aligned_free; - s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL; - - WORD32 status = ih264d_api_function(m_codecCtx, &s_create_ip, &s_create_op); - cemu_assert(!status); - - m_codecCtx = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle; - m_codecCtx->pv_fxns = (void*)&ih264d_api_function; - m_codecCtx->u4_size = sizeof(iv_obj_t); - - SetDecoderCoreCount(1); - - m_isBufferedMode = isBufferedMode; - - UpdateParameters(false); - - m_bufferedResults.clear(); - m_numDecodedFrames = 0; - m_hasBufferSizeInfo = false; - m_timestampIndex = 0; - } - - void Destroy() - { - if (!m_codecCtx) - return; - ih264d_delete_ip_t s_delete_ip{ 0 }; - ih264d_delete_op_t s_delete_op{ 0 }; - s_delete_ip.s_ivd_delete_ip_t.u4_size = sizeof(ih264d_delete_ip_t); - s_delete_ip.s_ivd_delete_ip_t.e_cmd = IVD_CMD_DELETE; - s_delete_op.s_ivd_delete_op_t.u4_size = sizeof(ih264d_delete_op_t); - WORD32 status = ih264d_api_function(m_codecCtx, &s_delete_ip, &s_delete_op); - cemu_assert_debug(!status); - m_codecCtx = nullptr; - } - - void SetDecoderCoreCount(uint32 coreCount) - { - ih264d_ctl_set_num_cores_ip_t s_set_cores_ip; - ih264d_ctl_set_num_cores_op_t s_set_cores_op; - s_set_cores_ip.e_cmd = IVD_CMD_VIDEO_CTL; - s_set_cores_ip.e_sub_cmd = (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_SET_NUM_CORES; - s_set_cores_ip.u4_num_cores = coreCount; // valid numbers are 1-4 - s_set_cores_ip.u4_size = sizeof(ih264d_ctl_set_num_cores_ip_t); - s_set_cores_op.u4_size = sizeof(ih264d_ctl_set_num_cores_op_t); - IV_API_CALL_STATUS_T status = ih264d_api_function(m_codecCtx, (void *)&s_set_cores_ip, (void *)&s_set_cores_op); - cemu_assert(status == IV_SUCCESS); - } - - static bool GetImageInfo(uint8* stream, uint32 length, uint32& imageWidth, uint32& imageHeight) - { - // create temporary decoder - ih264d_create_ip_t s_create_ip{ 0 }; - ih264d_create_op_t s_create_op{ 0 }; - s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ih264d_create_ip_t); - s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE; - s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = 0; - s_create_op.s_ivd_create_op_t.u4_size = sizeof(ih264d_create_op_t); - s_create_ip.s_ivd_create_ip_t.e_output_format = IV_YUV_420SP_UV; - s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ivd_aligned_malloc; - s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ivd_aligned_free; - s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL; - iv_obj_t* ctx = nullptr; - WORD32 status = ih264d_api_function(ctx, &s_create_ip, &s_create_op); - cemu_assert_debug(!status); - if (status != IV_SUCCESS) - return false; - ctx = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle; - ctx->pv_fxns = (void*)&ih264d_api_function; - ctx->u4_size = sizeof(iv_obj_t); - // set header-only mode - ih264d_ctl_set_config_ip_t s_h264d_ctl_ip{ 0 }; - ih264d_ctl_set_config_op_t s_h264d_ctl_op{ 0 }; - ivd_ctl_set_config_ip_t* ps_ctl_ip = &s_h264d_ctl_ip.s_ivd_ctl_set_config_ip_t; - ivd_ctl_set_config_op_t* ps_ctl_op = &s_h264d_ctl_op.s_ivd_ctl_set_config_op_t; - ps_ctl_ip->u4_disp_wd = 0; - ps_ctl_ip->e_frm_skip_mode = IVD_SKIP_NONE; - ps_ctl_ip->e_frm_out_mode = IVD_DISPLAY_FRAME_OUT; - ps_ctl_ip->e_vid_dec_mode = IVD_DECODE_HEADER; - ps_ctl_ip->e_cmd = IVD_CMD_VIDEO_CTL; - ps_ctl_ip->e_sub_cmd = IVD_CMD_CTL_SETPARAMS; - ps_ctl_ip->u4_size = sizeof(ih264d_ctl_set_config_ip_t); - ps_ctl_op->u4_size = sizeof(ih264d_ctl_set_config_op_t); - status = ih264d_api_function(ctx, &s_h264d_ctl_ip, &s_h264d_ctl_op); - cemu_assert(!status); - // decode stream - ivd_video_decode_ip_t s_dec_ip{ 0 }; - ivd_video_decode_op_t s_dec_op{ 0 }; - s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); - s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); - s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; - s_dec_ip.pv_stream_buffer = stream; - s_dec_ip.u4_num_Bytes = length; - s_dec_ip.s_out_buffer.u4_num_bufs = 0; - - s_dec_op.u4_raw_wd = 0; - s_dec_op.u4_raw_ht = 0; - - status = ih264d_api_function(ctx, &s_dec_ip, &s_dec_op); - //cemu_assert(status == 0); -> This errors when not both the headers are present, but it will still set the parameters we need - bool isValid = false; - if (true)//status == 0) - { - imageWidth = s_dec_op.u4_raw_wd; - imageHeight = s_dec_op.u4_raw_ht; - cemu_assert_debug(imageWidth != 0 && imageHeight != 0); - isValid = true; - } - // destroy decoder - ih264d_delete_ip_t s_delete_ip{ 0 }; - ih264d_delete_op_t s_delete_op{ 0 }; - s_delete_ip.s_ivd_delete_ip_t.u4_size = sizeof(ih264d_delete_ip_t); - s_delete_ip.s_ivd_delete_ip_t.e_cmd = IVD_CMD_DELETE; - s_delete_op.s_ivd_delete_op_t.u4_size = sizeof(ih264d_delete_op_t); - status = ih264d_api_function(ctx, &s_delete_ip, &s_delete_op); - cemu_assert_debug(!status); - return isValid; - } - - void Decode(void* data, uint32 length, double timestamp, void* imageOutput, DecodeResult& decodeResult) - { - if (!m_hasBufferSizeInfo) - { - uint32 numByteConsumed = 0; - if (!DetermineBufferSizes(data, length, numByteConsumed)) - { - cemuLog_log(LogType::Force, "H264: Unable to determine picture size. Ignoring decode input"); - decodeResult.frameReady = false; - return; - } - length -= numByteConsumed; - data = (uint8*)data + numByteConsumed; - m_hasBufferSizeInfo = true; - } - - ivd_video_decode_ip_t s_dec_ip{ 0 }; - ivd_video_decode_op_t s_dec_op{ 0 }; - s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); - s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); - - s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; - - // remember timestamp and associated output buffer - m_timestamps[m_timestampIndex] = timestamp; - m_imageBuffers[m_timestampIndex] = imageOutput; - s_dec_ip.u4_ts = m_timestampIndex; - m_timestampIndex = (m_timestampIndex + 1) % 64; - - s_dec_ip.pv_stream_buffer = (uint8*)data; - s_dec_ip.u4_num_Bytes = length; - - s_dec_ip.s_out_buffer.u4_min_out_buf_size[0] = 0; - s_dec_ip.s_out_buffer.u4_min_out_buf_size[1] = 0; - s_dec_ip.s_out_buffer.u4_num_bufs = 0; - - BenchmarkTimer bt; - bt.Start(); - WORD32 status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); - if (status != 0 && (s_dec_op.u4_error_code&0xFF) == IVD_RES_CHANGED) - { - // resolution change - ResetDecoder(); - m_hasBufferSizeInfo = false; - Decode(data, length, timestamp, imageOutput, decodeResult); - return; - } - else if (status != 0) - { - cemuLog_log(LogType::Force, "H264: Failed to decode frame (error 0x{:08x})", status); - decodeResult.frameReady = false; - return; - } - - bt.Stop(); - double decodeTime = bt.GetElapsedMilliseconds(); - - cemu_assert(s_dec_op.u4_frame_decoded_flag); - cemu_assert_debug(s_dec_op.u4_num_bytes_consumed == length); - - cemu_assert_debug(m_isBufferedMode || s_dec_op.u4_output_present); // if buffered mode is disabled, then every input should output a frame (except for partial slices?) - - if (s_dec_op.u4_output_present) - { - cemu_assert(s_dec_op.e_output_format == IV_YUV_420SP_UV); - if (H264_IsBotW()) - { - if (s_dec_op.s_disp_frm_buf.u4_y_wd == 1920 && s_dec_op.s_disp_frm_buf.u4_y_ht == 1088) - s_dec_op.s_disp_frm_buf.u4_y_ht = 1080; - } - DecodeResult tmpResult; - tmpResult.frameReady = s_dec_op.u4_output_present != 0; - tmpResult.timestamp = m_timestamps[s_dec_op.u4_ts]; - tmpResult.imageOutput = m_imageBuffers[s_dec_op.u4_ts]; - tmpResult.decodeOutput = s_dec_op; - AddBufferedResult(tmpResult); - // transfer image to PPC output buffer and also correct stride - bt.Start(); - CopyImageToResultBuffer((uint8*)s_dec_op.s_disp_frm_buf.pv_y_buf, (uint8*)s_dec_op.s_disp_frm_buf.pv_u_buf, (uint8*)m_imageBuffers[s_dec_op.u4_ts], s_dec_op); - bt.Stop(); - double copyTime = bt.GetElapsedMilliseconds(); - // release buffer - sint32 bufferId = -1; - for (size_t i = 0; i < m_displayBuf.size(); i++) - { - if (s_dec_op.s_disp_frm_buf.pv_y_buf >= m_displayBuf[i].data() && s_dec_op.s_disp_frm_buf.pv_y_buf < (m_displayBuf[i].data() + m_displayBuf[i].size())) - { - bufferId = (sint32)i; - break; - } - } - cemu_assert_debug(bufferId == s_dec_op.u4_disp_buf_id); - cemu_assert(bufferId >= 0); - ivd_rel_display_frame_ip_t s_video_rel_disp_ip{ 0 }; - ivd_rel_display_frame_op_t s_video_rel_disp_op{ 0 }; - s_video_rel_disp_ip.e_cmd = IVD_CMD_REL_DISPLAY_FRAME; - s_video_rel_disp_ip.u4_size = sizeof(ivd_rel_display_frame_ip_t); - s_video_rel_disp_op.u4_size = sizeof(ivd_rel_display_frame_op_t); - s_video_rel_disp_ip.u4_disp_buf_id = bufferId; - status = ih264d_api_function(m_codecCtx, &s_video_rel_disp_ip, &s_video_rel_disp_op); - cemu_assert(!status); - - cemuLog_log(LogType::H264, "H264Bench | DecodeTime {}ms CopyTime {}ms", decodeTime, copyTime); - } - else - { - cemuLog_log(LogType::H264, "H264Bench | DecodeTime{}ms", decodeTime); - } - - if (s_dec_op.u4_frame_decoded_flag) - m_numDecodedFrames++; - - if (m_isBufferedMode) - { - // in buffered mode, always buffer 5 frames regardless of actual reordering and decoder latency - if (m_numDecodedFrames > 5) - GetCurrentBufferedResult(decodeResult); - } - else if(m_numDecodedFrames > 0) - GetCurrentBufferedResult(decodeResult); - - // get VUI - //ih264d_ctl_get_vui_params_ip_t s_ctl_get_vui_params_ip; - //ih264d_ctl_get_vui_params_op_t s_ctl_get_vui_params_op; - - //s_ctl_get_vui_params_ip.e_cmd = IVD_CMD_VIDEO_CTL; - //s_ctl_get_vui_params_ip.e_sub_cmd = (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_GET_VUI_PARAMS; - //s_ctl_get_vui_params_ip.u4_size = sizeof(ih264d_ctl_get_vui_params_ip_t); - //s_ctl_get_vui_params_op.u4_size = sizeof(ih264d_ctl_get_vui_params_op_t); - - //status = ih264d_api_function(mCodecCtx, &s_ctl_get_vui_params_ip, &s_ctl_get_vui_params_op); - //cemu_assert(status == 0); - } - - std::vector<DecodeResult> Flush() - { - std::vector<DecodeResult> results; - // set flush mode - ivd_ctl_flush_ip_t s_video_flush_ip{ 0 }; - ivd_ctl_flush_op_t s_video_flush_op{ 0 }; - s_video_flush_ip.e_cmd = IVD_CMD_VIDEO_CTL; - s_video_flush_ip.e_sub_cmd = IVD_CMD_CTL_FLUSH; - s_video_flush_ip.u4_size = sizeof(ivd_ctl_flush_ip_t); - s_video_flush_op.u4_size = sizeof(ivd_ctl_flush_op_t); - WORD32 status = ih264d_api_function(m_codecCtx, &s_video_flush_ip, &s_video_flush_op); - if (status != 0) - cemuLog_log(LogType::Force, "H264Dec: Unexpected error during flush ({})", status); - // get all frames from the codec - while (true) - { - ivd_video_decode_ip_t s_dec_ip{ 0 }; - ivd_video_decode_op_t s_dec_op{ 0 }; - s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); - s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); - s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; - s_dec_ip.pv_stream_buffer = NULL; - s_dec_ip.u4_num_Bytes = 0; - s_dec_ip.s_out_buffer.u4_min_out_buf_size[0] = 0; - s_dec_ip.s_out_buffer.u4_min_out_buf_size[1] = 0; - s_dec_ip.s_out_buffer.u4_num_bufs = 0; - status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); - if (status != 0) - break; - cemu_assert_debug(s_dec_op.u4_output_present != 0); // should never be zero? - if(s_dec_op.u4_output_present == 0) - continue; - if (H264_IsBotW()) - { - if (s_dec_op.s_disp_frm_buf.u4_y_wd == 1920 && s_dec_op.s_disp_frm_buf.u4_y_ht == 1088) - s_dec_op.s_disp_frm_buf.u4_y_ht = 1080; - } - DecodeResult tmpResult; - tmpResult.frameReady = s_dec_op.u4_output_present != 0; - tmpResult.timestamp = m_timestamps[s_dec_op.u4_ts]; - tmpResult.imageOutput = m_imageBuffers[s_dec_op.u4_ts]; - tmpResult.decodeOutput = s_dec_op; - AddBufferedResult(tmpResult); - CopyImageToResultBuffer((uint8*)s_dec_op.s_disp_frm_buf.pv_y_buf, (uint8*)s_dec_op.s_disp_frm_buf.pv_u_buf, (uint8*)m_imageBuffers[s_dec_op.u4_ts], s_dec_op); - } - results = std::move(m_bufferedResults); - return results; - } - - void CopyImageToResultBuffer(uint8* yIn, uint8* uvIn, uint8* bufOut, ivd_video_decode_op_t& decodeInfo) - { - uint32 imageWidth = decodeInfo.s_disp_frm_buf.u4_y_wd; - uint32 imageHeight = decodeInfo.s_disp_frm_buf.u4_y_ht; - - size_t inputStride = decodeInfo.s_disp_frm_buf.u4_y_strd; - size_t outputStride = (imageWidth + 0xFF) & ~0xFF; - - // copy Y - uint8* yOut = bufOut; - for (uint32 row = 0; row < imageHeight; row++) - { - memcpy(yOut, yIn, imageWidth); - yIn += inputStride; - yOut += outputStride; - } - - // copy UV - uint8* uvOut = bufOut + outputStride * imageHeight; - for (uint32 row = 0; row < imageHeight/2; row++) - { - memcpy(uvOut, uvIn, imageWidth); - uvIn += inputStride; - uvOut += outputStride; - } - } - - private: - - bool DetermineBufferSizes(void* data, uint32 length, uint32& numByteConsumed) - { - numByteConsumed = 0; - UpdateParameters(true); - - ivd_video_decode_ip_t s_dec_ip{ 0 }; - ivd_video_decode_op_t s_dec_op{ 0 }; - s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); - s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); - - s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; - s_dec_ip.pv_stream_buffer = (uint8*)data; - s_dec_ip.u4_num_Bytes = length; - s_dec_ip.s_out_buffer.u4_num_bufs = 0; - WORD32 status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); - if (status != 0) - { - cemuLog_log(LogType::Force, "H264: Unable to determine buffer sizes for stream"); - return false; - } - numByteConsumed = s_dec_op.u4_num_bytes_consumed; - cemu_assert(status == 0); - if (s_dec_op.u4_pic_wd == 0 || s_dec_op.u4_pic_ht == 0) - return false; - UpdateParameters(false); - ReinitBuffers(); - return true; - } - - void ReinitBuffers() - { - ivd_ctl_getbufinfo_ip_t s_ctl_ip{ 0 }; - ivd_ctl_getbufinfo_op_t s_ctl_op{ 0 }; - WORD32 outlen = 0; - - s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL; - s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_GETBUFINFO; - s_ctl_ip.u4_size = sizeof(ivd_ctl_getbufinfo_ip_t); - s_ctl_op.u4_size = sizeof(ivd_ctl_getbufinfo_op_t); - - WORD32 status = ih264d_api_function(m_codecCtx, &s_ctl_ip, &s_ctl_op); - cemu_assert(!status); - - // allocate - for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) - { - m_displayBuf.emplace_back().resize(s_ctl_op.u4_min_out_buf_size[0] + s_ctl_op.u4_min_out_buf_size[1]); - } - // set - ivd_set_display_frame_ip_t s_set_display_frame_ip{ 0 }; // make sure to zero-initialize this. The codec seems to check the first 3 pointers/sizes per frame, regardless of the value of u4_num_bufs - ivd_set_display_frame_op_t s_set_display_frame_op{ 0 }; - - s_set_display_frame_ip.e_cmd = IVD_CMD_SET_DISPLAY_FRAME; - s_set_display_frame_ip.u4_size = sizeof(ivd_set_display_frame_ip_t); - s_set_display_frame_op.u4_size = sizeof(ivd_set_display_frame_op_t); - - cemu_assert_debug(s_ctl_op.u4_min_num_out_bufs == 2); - cemu_assert_debug(s_ctl_op.u4_min_out_buf_size[0] != 0 && s_ctl_op.u4_min_out_buf_size[1] != 0); - - s_set_display_frame_ip.num_disp_bufs = s_ctl_op.u4_num_disp_bufs; - - for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) - { - s_set_display_frame_ip.s_disp_buffer[i].u4_num_bufs = 2; - s_set_display_frame_ip.s_disp_buffer[i].u4_min_out_buf_size[0] = s_ctl_op.u4_min_out_buf_size[0]; - s_set_display_frame_ip.s_disp_buffer[i].u4_min_out_buf_size[1] = s_ctl_op.u4_min_out_buf_size[1]; - s_set_display_frame_ip.s_disp_buffer[i].pu1_bufs[0] = m_displayBuf[i].data() + 0; - s_set_display_frame_ip.s_disp_buffer[i].pu1_bufs[1] = m_displayBuf[i].data() + s_ctl_op.u4_min_out_buf_size[0]; - } - - status = ih264d_api_function(m_codecCtx, &s_set_display_frame_ip, &s_set_display_frame_op); - cemu_assert(!status); - - - // mark all as released (available) - for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) - { - ivd_rel_display_frame_ip_t s_video_rel_disp_ip{ 0 }; - ivd_rel_display_frame_op_t s_video_rel_disp_op{ 0 }; - - s_video_rel_disp_ip.e_cmd = IVD_CMD_REL_DISPLAY_FRAME; - s_video_rel_disp_ip.u4_size = sizeof(ivd_rel_display_frame_ip_t); - s_video_rel_disp_op.u4_size = sizeof(ivd_rel_display_frame_op_t); - s_video_rel_disp_ip.u4_disp_buf_id = i; - - status = ih264d_api_function(m_codecCtx, &s_video_rel_disp_ip, &s_video_rel_disp_op); - cemu_assert(!status); - } - } - - void ResetDecoder() - { - ivd_ctl_reset_ip_t s_ctl_ip; - ivd_ctl_reset_op_t s_ctl_op; - - s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL; - s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_RESET; - s_ctl_ip.u4_size = sizeof(ivd_ctl_reset_ip_t); - s_ctl_op.u4_size = sizeof(ivd_ctl_reset_op_t); - - WORD32 status = ih264d_api_function(m_codecCtx, (void*)&s_ctl_ip, (void*)&s_ctl_op); - cemu_assert_debug(status == 0); - } - - void UpdateParameters(bool headerDecodeOnly) - { - ih264d_ctl_set_config_ip_t s_h264d_ctl_ip{ 0 }; - ih264d_ctl_set_config_op_t s_h264d_ctl_op{ 0 }; - ivd_ctl_set_config_ip_t* ps_ctl_ip = &s_h264d_ctl_ip.s_ivd_ctl_set_config_ip_t; - ivd_ctl_set_config_op_t* ps_ctl_op = &s_h264d_ctl_op.s_ivd_ctl_set_config_op_t; - - ps_ctl_ip->u4_disp_wd = 0; - ps_ctl_ip->e_frm_skip_mode = IVD_SKIP_NONE; - ps_ctl_ip->e_frm_out_mode = m_isBufferedMode ? IVD_DISPLAY_FRAME_OUT : IVD_DECODE_FRAME_OUT; - ps_ctl_ip->e_vid_dec_mode = headerDecodeOnly ? IVD_DECODE_HEADER : IVD_DECODE_FRAME; - ps_ctl_ip->e_cmd = IVD_CMD_VIDEO_CTL; - ps_ctl_ip->e_sub_cmd = IVD_CMD_CTL_SETPARAMS; - ps_ctl_ip->u4_size = sizeof(ih264d_ctl_set_config_ip_t); - ps_ctl_op->u4_size = sizeof(ih264d_ctl_set_config_op_t); - - WORD32 status = ih264d_api_function(m_codecCtx, &s_h264d_ctl_ip, &s_h264d_ctl_op); - cemu_assert(status == 0); - } - - /* In non-flush mode we have a delay of (at least?) 5 frames */ - void AddBufferedResult(DecodeResult& decodeResult) - { - if (decodeResult.frameReady) - m_bufferedResults.emplace_back(decodeResult); - } - - void GetCurrentBufferedResult(DecodeResult& decodeResult) - { - cemu_assert(!m_bufferedResults.empty()); - if (m_bufferedResults.empty()) - { - decodeResult.frameReady = false; - return; - } - decodeResult = m_bufferedResults.front(); - m_bufferedResults.erase(m_bufferedResults.begin()); - } - private: - iv_obj_t* m_codecCtx{nullptr}; - bool m_hasBufferSizeInfo{ false }; - bool m_isBufferedMode{ false }; - double m_timestamps[64]; - void* m_imageBuffers[64]; - uint32 m_timestampIndex{0}; - std::vector<DecodeResult> m_bufferedResults; - uint32 m_numDecodedFrames{0}; - std::vector<std::vector<uint8>> m_displayBuf; - }; - H264DEC_STATUS H264DECGetImageSize(uint8* stream, uint32 length, uint32 offset, uint32be* outputWidth, uint32be* outputHeight) { - cemu_assert(offset <= length); - - uint32 imageWidth, imageHeight; - - if (H264AVCDecoder::GetImageInfo(stream, length, imageWidth, imageHeight)) + if(!stream || length < 4 || !outputWidth || !outputHeight) + return H264DEC_STATUS::INVALID_PARAM; + if( (offset+4) > length ) + return H264DEC_STATUS::INVALID_PARAM; + uint8* cur = stream + offset; + uint8* end = stream + length; + cur += 2; // we access cur[-2] and cur[-1] so we need to start at offset 2 + while(cur < end-2) { - if (H264_IsBotW()) + // check for start code + if(*cur != 1) { - if (imageWidth == 1920 && imageHeight == 1088) - imageHeight = 1080; + cur++; + continue; } - *outputWidth = imageWidth; - *outputHeight = imageHeight; + // check if this is a valid NAL header + if(cur[-2] != 0 || cur[-1] != 0 || cur[0] != 1) + { + cur++; + continue; + } + uint8 nalHeader = cur[1]; + if((nalHeader & 0x1F) != 7) + { + cur++; + continue; + } + h264State_seq_parameter_set_t psp; + bool r = h264Parser_ParseSPS(cur+2, end-cur-2, psp); + if(!r) + { + cemu_assert_suspicious(); // should not happen + return H264DEC_STATUS::BAD_STREAM; + } + *outputWidth = (psp.pic_width_in_mbs_minus1 + 1) * 16; + *outputHeight = (psp.pic_height_in_map_units_minus1 + 1) * 16; // affected by frame_mbs_only_flag? + return H264DEC_STATUS::SUCCESS; } - else - { - *outputWidth = 0; - *outputHeight = 0; - return H264DEC_STATUS::BAD_STREAM; - } - - return H264DEC_STATUS::SUCCESS; + return H264DEC_STATUS::BAD_STREAM; } uint32 H264DECInitParam(uint32 workMemorySize, void* workMemory) @@ -762,26 +239,28 @@ namespace H264 return 0; } - std::unordered_map<uint32, H264AVCDecoder*> sDecoderSessions; + std::unordered_map<uint32, H264DecoderBackend*> sDecoderSessions; std::mutex sDecoderSessionsMutex; std::atomic_uint32_t sCurrentSessionHandle{ 1 }; - static H264AVCDecoder* _CreateDecoderSession(uint32& handleOut) + H264DecoderBackend* CreateAVCDecoder(); + + static H264DecoderBackend* _CreateDecoderSession(uint32& handleOut) { std::unique_lock _lock(sDecoderSessionsMutex); handleOut = sCurrentSessionHandle.fetch_add(1); - H264AVCDecoder* session = new H264AVCDecoder(); + H264DecoderBackend* session = CreateAVCDecoder(); sDecoderSessions.try_emplace(handleOut, session); return session; } - static H264AVCDecoder* _AcquireDecoderSession(uint32 handle) + static H264DecoderBackend* _AcquireDecoderSession(uint32 handle) { std::unique_lock _lock(sDecoderSessionsMutex); auto it = sDecoderSessions.find(handle); if (it == sDecoderSessions.end()) return nullptr; - H264AVCDecoder* session = it->second; + H264DecoderBackend* session = it->second; if (sDecoderSessions.size() >= 5) { cemuLog_log(LogType::Force, "H264: Warning - more than 5 active sessions"); @@ -790,7 +269,7 @@ namespace H264 return session; } - static void _ReleaseDecoderSession(H264AVCDecoder* session) + static void _ReleaseDecoderSession(H264DecoderBackend* session) { std::unique_lock _lock(sDecoderSessionsMutex); @@ -802,7 +281,7 @@ namespace H264 auto it = sDecoderSessions.find(handle); if (it == sDecoderSessions.end()) return; - H264AVCDecoder* session = it->second; + H264DecoderBackend* session = it->second; session->Destroy(); delete session; sDecoderSessions.erase(it); @@ -830,45 +309,44 @@ namespace H264 uint32 H264DECBegin(void* workMemory) { H264Context* ctx = (H264Context*)workMemory; - H264AVCDecoder* session = _AcquireDecoderSession(ctx->sessionHandle); + H264DecoderBackend* session = _AcquireDecoderSession(ctx->sessionHandle); if (!session) { cemuLog_log(LogType::Force, "H264DECBegin(): Invalid session"); return 0; } session->Init(ctx->Param.outputPerFrame == 0); + ctx->decoderState.numFramesInFlight = 0; _ReleaseDecoderSession(session); return 0; } - void H264DoFrameOutputCallback(H264Context* ctx, H264AVCDecoder::DecodeResult& decodeResult); - - void _async_H264DECEnd(coreinit::OSEvent* executeDoneEvent, H264AVCDecoder* session, H264Context* ctx, std::vector<H264AVCDecoder::DecodeResult>* decodeResultsOut) - { - *decodeResultsOut = session->Flush(); - coreinit::OSSignalEvent(executeDoneEvent); - } + void H264DoFrameOutputCallback(H264Context* ctx, H264DecoderBackend::DecodeResult& decodeResult); H264DEC_STATUS H264DECEnd(void* workMemory) { H264Context* ctx = (H264Context*)workMemory; - H264AVCDecoder* session = _AcquireDecoderSession(ctx->sessionHandle); + H264DecoderBackend* session = _AcquireDecoderSession(ctx->sessionHandle); if (!session) { cemuLog_log(LogType::Force, "H264DECEnd(): Invalid session"); return H264DEC_STATUS::SUCCESS; } - StackAllocator<coreinit::OSEvent> executeDoneEvent; - coreinit::OSInitEvent(&executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); - std::vector<H264AVCDecoder::DecodeResult> results; - auto asyncTask = std::async(std::launch::async, _async_H264DECEnd, executeDoneEvent.GetPointer(), session, ctx, &results); - coreinit::OSWaitEvent(&executeDoneEvent); - _ReleaseDecoderSession(session); - if (!results.empty()) + coreinit::OSEvent* flushEvt = &session->GetFlushEvent(); + coreinit::OSResetEvent(flushEvt); + session->QueueFlush(); + coreinit::OSWaitEvent(flushEvt); + while(true) { - for (auto& itr : results) - H264DoFrameOutputCallback(ctx, itr); + H264DecoderBackend::DecodeResult decodeResult; + if( !session->GetFrameOutputIfReady(decodeResult) ) + break; + // todo - output all frames in a single callback? + H264DoFrameOutputCallback(ctx, decodeResult); + ctx->decoderState.numFramesInFlight--; } + cemu_assert_debug(ctx->decoderState.numFramesInFlight == 0); // no frames should be in flight anymore. Exact behavior is not well understood but we may have to output dummy frames if necessary + _ReleaseDecoderSession(session); return H264DEC_STATUS::SUCCESS; } @@ -930,7 +408,6 @@ namespace H264 return 0; } - struct H264DECFrameOutput { /* +0x00 */ uint32be result; @@ -967,7 +444,7 @@ namespace H264 static_assert(sizeof(H264OutputCBStruct) == 12); - void H264DoFrameOutputCallback(H264Context* ctx, H264AVCDecoder::DecodeResult& decodeResult) + void H264DoFrameOutputCallback(H264Context* ctx, H264DecoderBackend::DecodeResult& decodeResult) { sint32 outputFrameCount = 1; @@ -984,14 +461,14 @@ namespace H264 frameOutput->imagePtr = (uint8*)decodeResult.imageOutput; frameOutput->result = 100; frameOutput->timestamp = decodeResult.timestamp; - frameOutput->frameWidth = decodeResult.decodeOutput.u4_pic_wd; - frameOutput->frameHeight = decodeResult.decodeOutput.u4_pic_ht; - frameOutput->bytesPerRow = (decodeResult.decodeOutput.u4_pic_wd + 0xFF) & ~0xFF; - frameOutput->cropEnable = decodeResult.decodeOutput.u1_frame_cropping_flag; - frameOutput->cropTop = decodeResult.decodeOutput.u1_frame_cropping_rect_top_ofst; - frameOutput->cropBottom = decodeResult.decodeOutput.u1_frame_cropping_rect_bottom_ofst; - frameOutput->cropLeft = decodeResult.decodeOutput.u1_frame_cropping_rect_left_ofst; - frameOutput->cropRight = decodeResult.decodeOutput.u1_frame_cropping_rect_right_ofst; + frameOutput->frameWidth = decodeResult.frameWidth; + frameOutput->frameHeight = decodeResult.frameHeight; + frameOutput->bytesPerRow = decodeResult.bytesPerRow; + frameOutput->cropEnable = decodeResult.cropEnable; + frameOutput->cropTop = decodeResult.cropTop; + frameOutput->cropBottom = decodeResult.cropBottom; + frameOutput->cropLeft = decodeResult.cropLeft; + frameOutput->cropRight = decodeResult.cropRight; StackAllocator<H264OutputCBStruct> stack_fptrOutputData; stack_fptrOutputData->frameCount = outputFrameCount; @@ -1006,29 +483,41 @@ namespace H264 } } - void _async_H264DECExecute(coreinit::OSEvent* executeDoneEvent, H264AVCDecoder* session, H264Context* ctx, void* imageOutput, H264AVCDecoder::DecodeResult* decodeResult) - { - session->Decode(ctx->BitStream.ptr.GetPtr(), ctx->BitStream.length, ctx->BitStream.timestamp, imageOutput, *decodeResult); - coreinit::OSSignalEvent(executeDoneEvent); - } - uint32 H264DECExecute(void* workMemory, void* imageOutput) { + BenchmarkTimer bt; + bt.Start(); H264Context* ctx = (H264Context*)workMemory; - H264AVCDecoder* session = _AcquireDecoderSession(ctx->sessionHandle); + H264DecoderBackend* session = _AcquireDecoderSession(ctx->sessionHandle); if (!session) { cemuLog_log(LogType::Force, "H264DECExecute(): Invalid session"); return 0; } - StackAllocator<coreinit::OSEvent> executeDoneEvent; - coreinit::OSInitEvent(&executeDoneEvent, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_MANUAL); - H264AVCDecoder::DecodeResult decodeResult; - auto asyncTask = std::async(std::launch::async, _async_H264DECExecute, &executeDoneEvent, session, ctx, imageOutput , &decodeResult); - coreinit::OSWaitEvent(&executeDoneEvent); + // feed data to backend + session->QueueForDecode((uint8*)ctx->BitStream.ptr.GetPtr(), ctx->BitStream.length, ctx->BitStream.timestamp, imageOutput); + ctx->decoderState.numFramesInFlight++; + // H264DECExecute is synchronous and will return a frame after either every call (non-buffered) or after 6 calls (buffered) + // normally frame decoding happens only during H264DECExecute, but in order to hide the latency of our CPU decoder we will decode asynchronously in buffered mode + uint32 numFramesToBuffer = (ctx->Param.outputPerFrame == 0) ? 5 : 0; + if(ctx->decoderState.numFramesInFlight > numFramesToBuffer) + { + ctx->decoderState.numFramesInFlight--; + while(true) + { + coreinit::OSEvent& evt = session->GetFrameOutputEvent(); + coreinit::OSWaitEvent(&evt); + H264DecoderBackend::DecodeResult decodeResult; + if( !session->GetFrameOutputIfReady(decodeResult) ) + continue; + H264DoFrameOutputCallback(ctx, decodeResult); + break; + } + } _ReleaseDecoderSession(session); - if(decodeResult.frameReady) - H264DoFrameOutputCallback(ctx, decodeResult); + bt.Stop(); + double callTime = bt.GetElapsedMilliseconds(); + cemuLog_log(LogType::H264, "H264Bench | H264DECExecute took {}ms", callTime); return 0x80 | 100; } diff --git a/src/Cafe/OS/libs/h264_avc/H264DecBackendAVC.cpp b/src/Cafe/OS/libs/h264_avc/H264DecBackendAVC.cpp new file mode 100644 index 00000000..228f65a5 --- /dev/null +++ b/src/Cafe/OS/libs/h264_avc/H264DecBackendAVC.cpp @@ -0,0 +1,502 @@ +#include "H264DecInternal.h" +#include "util/highresolutiontimer/HighResolutionTimer.h" + +extern "C" +{ +#include "../dependencies/ih264d/common/ih264_typedefs.h" +#include "../dependencies/ih264d/decoder/ih264d.h" +}; + +namespace H264 +{ + bool H264_IsBotW(); + + class H264AVCDecoder : public H264DecoderBackend + { + static void* ivd_aligned_malloc(void* ctxt, WORD32 alignment, WORD32 size) + { +#ifdef _WIN32 + return _aligned_malloc(size, alignment); +#else + // alignment is atleast sizeof(void*) + alignment = std::max<WORD32>(alignment, sizeof(void*)); + + //smallest multiple of 2 at least as large as alignment + alignment--; + alignment |= alignment << 1; + alignment |= alignment >> 1; + alignment |= alignment >> 2; + alignment |= alignment >> 4; + alignment |= alignment >> 8; + alignment |= alignment >> 16; + alignment ^= (alignment >> 1); + + void* temp; + posix_memalign(&temp, (size_t)alignment, (size_t)size); + return temp; +#endif + } + + static void ivd_aligned_free(void* ctxt, void* buf) + { +#ifdef _WIN32 + _aligned_free(buf); +#else + free(buf); +#endif + } + + public: + H264AVCDecoder() + { + m_decoderThread = std::thread(&H264AVCDecoder::DecoderThread, this); + } + + ~H264AVCDecoder() + { + m_threadShouldExit = true; + m_decodeSem.increment(); + if (m_decoderThread.joinable()) + m_decoderThread.join(); + } + + void Init(bool isBufferedMode) + { + ih264d_create_ip_t s_create_ip{ 0 }; + ih264d_create_op_t s_create_op{ 0 }; + + s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ih264d_create_ip_t); + s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE; + s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = 1; // shared display buffer mode -> We give the decoder a list of buffers that it will use (?) + + s_create_op.s_ivd_create_op_t.u4_size = sizeof(ih264d_create_op_t); + s_create_ip.s_ivd_create_ip_t.e_output_format = IV_YUV_420SP_UV; + s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ivd_aligned_malloc; + s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ivd_aligned_free; + s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL; + + WORD32 status = ih264d_api_function(m_codecCtx, &s_create_ip, &s_create_op); + cemu_assert(!status); + + m_codecCtx = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle; + m_codecCtx->pv_fxns = (void*)&ih264d_api_function; + m_codecCtx->u4_size = sizeof(iv_obj_t); + + SetDecoderCoreCount(1); + + m_isBufferedMode = isBufferedMode; + + UpdateParameters(false); + + m_numDecodedFrames = 0; + m_hasBufferSizeInfo = false; + } + + void Destroy() + { + if (!m_codecCtx) + return; + ih264d_delete_ip_t s_delete_ip{ 0 }; + ih264d_delete_op_t s_delete_op{ 0 }; + s_delete_ip.s_ivd_delete_ip_t.u4_size = sizeof(ih264d_delete_ip_t); + s_delete_ip.s_ivd_delete_ip_t.e_cmd = IVD_CMD_DELETE; + s_delete_op.s_ivd_delete_op_t.u4_size = sizeof(ih264d_delete_op_t); + WORD32 status = ih264d_api_function(m_codecCtx, &s_delete_ip, &s_delete_op); + cemu_assert_debug(!status); + m_codecCtx = nullptr; + } + + void PushDecodedFrame(ivd_video_decode_op_t& s_dec_op) + { + // copy image data outside of lock since its an expensive operation + CopyImageToResultBuffer((uint8*)s_dec_op.s_disp_frm_buf.pv_y_buf, (uint8*)s_dec_op.s_disp_frm_buf.pv_u_buf, (uint8*)m_decodedSliceArray[s_dec_op.u4_ts].result.imageOutput, s_dec_op); + + std::unique_lock _l(m_decodeQueueMtx); + cemu_assert(s_dec_op.u4_ts < m_decodedSliceArray.size()); + auto& result = m_decodedSliceArray[s_dec_op.u4_ts]; + cemu_assert_debug(result.isUsed); + cemu_assert_debug(s_dec_op.u4_output_present != 0); + + result.result.isDecoded = true; + result.result.hasFrame = s_dec_op.u4_output_present != 0; + result.result.frameWidth = s_dec_op.u4_pic_wd; + result.result.frameHeight = s_dec_op.u4_pic_ht; + result.result.bytesPerRow = (s_dec_op.u4_pic_wd + 0xFF) & ~0xFF; + result.result.cropEnable = s_dec_op.u1_frame_cropping_flag; + result.result.cropTop = s_dec_op.u1_frame_cropping_rect_top_ofst; + result.result.cropBottom = s_dec_op.u1_frame_cropping_rect_bottom_ofst; + result.result.cropLeft = s_dec_op.u1_frame_cropping_rect_left_ofst; + result.result.cropRight = s_dec_op.u1_frame_cropping_rect_right_ofst; + + m_displayQueue.push_back(s_dec_op.u4_ts); + + _l.unlock(); + coreinit::OSSignalEvent(m_displayQueueEvt); + } + + // called from async worker thread + void Decode(DecodedSlice& decodedSlice) + { + if (!m_hasBufferSizeInfo) + { + uint32 numByteConsumed = 0; + if (!DetermineBufferSizes(decodedSlice.dataToDecode.m_data, decodedSlice.dataToDecode.m_length, numByteConsumed)) + { + cemuLog_log(LogType::Force, "H264AVC: Unable to determine picture size. Ignoring decode input"); + std::unique_lock _l(m_decodeQueueMtx); + decodedSlice.result.isDecoded = true; + decodedSlice.result.hasFrame = false; + coreinit::OSSignalEvent(m_displayQueueEvt); + return; + } + decodedSlice.dataToDecode.m_length -= numByteConsumed; + decodedSlice.dataToDecode.m_data = (uint8*)decodedSlice.dataToDecode.m_data + numByteConsumed; + m_hasBufferSizeInfo = true; + } + + ivd_video_decode_ip_t s_dec_ip{ 0 }; + ivd_video_decode_op_t s_dec_op{ 0 }; + s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); + s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); + + s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; + + s_dec_ip.u4_ts = std::distance(m_decodedSliceArray.data(), &decodedSlice); + cemu_assert_debug(s_dec_ip.u4_ts < m_decodedSliceArray.size()); + + s_dec_ip.pv_stream_buffer = (uint8*)decodedSlice.dataToDecode.m_data; + s_dec_ip.u4_num_Bytes = decodedSlice.dataToDecode.m_length; + + s_dec_ip.s_out_buffer.u4_min_out_buf_size[0] = 0; + s_dec_ip.s_out_buffer.u4_min_out_buf_size[1] = 0; + s_dec_ip.s_out_buffer.u4_num_bufs = 0; + + BenchmarkTimer bt; + bt.Start(); + WORD32 status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); + if (status != 0 && (s_dec_op.u4_error_code&0xFF) == IVD_RES_CHANGED) + { + // resolution change + ResetDecoder(); + m_hasBufferSizeInfo = false; + Decode(decodedSlice); + return; + } + else if (status != 0) + { + cemuLog_log(LogType::Force, "H264: Failed to decode frame (error 0x{:08x})", status); + decodedSlice.result.hasFrame = false; + cemu_assert_unimplemented(); + return; + } + + bt.Stop(); + double decodeTime = bt.GetElapsedMilliseconds(); + + cemu_assert(s_dec_op.u4_frame_decoded_flag); + cemu_assert_debug(s_dec_op.u4_num_bytes_consumed == decodedSlice.dataToDecode.m_length); + + cemu_assert_debug(m_isBufferedMode || s_dec_op.u4_output_present); // if buffered mode is disabled, then every input should output a frame (except for partial slices?) + + if (s_dec_op.u4_output_present) + { + cemu_assert(s_dec_op.e_output_format == IV_YUV_420SP_UV); + if (H264_IsBotW()) + { + if (s_dec_op.s_disp_frm_buf.u4_y_wd == 1920 && s_dec_op.s_disp_frm_buf.u4_y_ht == 1088) + s_dec_op.s_disp_frm_buf.u4_y_ht = 1080; + } + bt.Start(); + PushDecodedFrame(s_dec_op); + bt.Stop(); + double copyTime = bt.GetElapsedMilliseconds(); + // release buffer + sint32 bufferId = -1; + for (size_t i = 0; i < m_displayBuf.size(); i++) + { + if (s_dec_op.s_disp_frm_buf.pv_y_buf >= m_displayBuf[i].data() && s_dec_op.s_disp_frm_buf.pv_y_buf < (m_displayBuf[i].data() + m_displayBuf[i].size())) + { + bufferId = (sint32)i; + break; + } + } + cemu_assert_debug(bufferId == s_dec_op.u4_disp_buf_id); + cemu_assert(bufferId >= 0); + ivd_rel_display_frame_ip_t s_video_rel_disp_ip{ 0 }; + ivd_rel_display_frame_op_t s_video_rel_disp_op{ 0 }; + s_video_rel_disp_ip.e_cmd = IVD_CMD_REL_DISPLAY_FRAME; + s_video_rel_disp_ip.u4_size = sizeof(ivd_rel_display_frame_ip_t); + s_video_rel_disp_op.u4_size = sizeof(ivd_rel_display_frame_op_t); + s_video_rel_disp_ip.u4_disp_buf_id = bufferId; + status = ih264d_api_function(m_codecCtx, &s_video_rel_disp_ip, &s_video_rel_disp_op); + cemu_assert(!status); + + cemuLog_log(LogType::H264, "H264Bench | DecodeTime {}ms CopyTime {}ms", decodeTime, copyTime); + } + else + { + cemuLog_log(LogType::H264, "H264Bench | DecodeTime {}ms (no frame output)", decodeTime); + } + + if (s_dec_op.u4_frame_decoded_flag) + m_numDecodedFrames++; + // get VUI + //ih264d_ctl_get_vui_params_ip_t s_ctl_get_vui_params_ip; + //ih264d_ctl_get_vui_params_op_t s_ctl_get_vui_params_op; + + //s_ctl_get_vui_params_ip.e_cmd = IVD_CMD_VIDEO_CTL; + //s_ctl_get_vui_params_ip.e_sub_cmd = (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_GET_VUI_PARAMS; + //s_ctl_get_vui_params_ip.u4_size = sizeof(ih264d_ctl_get_vui_params_ip_t); + //s_ctl_get_vui_params_op.u4_size = sizeof(ih264d_ctl_get_vui_params_op_t); + + //status = ih264d_api_function(mCodecCtx, &s_ctl_get_vui_params_ip, &s_ctl_get_vui_params_op); + //cemu_assert(status == 0); + } + + void Flush() + { + // set flush mode + ivd_ctl_flush_ip_t s_video_flush_ip{ 0 }; + ivd_ctl_flush_op_t s_video_flush_op{ 0 }; + s_video_flush_ip.e_cmd = IVD_CMD_VIDEO_CTL; + s_video_flush_ip.e_sub_cmd = IVD_CMD_CTL_FLUSH; + s_video_flush_ip.u4_size = sizeof(ivd_ctl_flush_ip_t); + s_video_flush_op.u4_size = sizeof(ivd_ctl_flush_op_t); + WORD32 status = ih264d_api_function(m_codecCtx, &s_video_flush_ip, &s_video_flush_op); + if (status != 0) + cemuLog_log(LogType::Force, "H264Dec: Unexpected error during flush ({})", status); + // get all frames from the decoder + while (true) + { + ivd_video_decode_ip_t s_dec_ip{ 0 }; + ivd_video_decode_op_t s_dec_op{ 0 }; + s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); + s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); + s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; + s_dec_ip.pv_stream_buffer = NULL; + s_dec_ip.u4_num_Bytes = 0; + s_dec_ip.s_out_buffer.u4_min_out_buf_size[0] = 0; + s_dec_ip.s_out_buffer.u4_min_out_buf_size[1] = 0; + s_dec_ip.s_out_buffer.u4_num_bufs = 0; + status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); + if (status != 0) + break; + cemu_assert_debug(s_dec_op.u4_output_present != 0); // should never be false? + if(s_dec_op.u4_output_present == 0) + continue; + if (H264_IsBotW()) + { + if (s_dec_op.s_disp_frm_buf.u4_y_wd == 1920 && s_dec_op.s_disp_frm_buf.u4_y_ht == 1088) + s_dec_op.s_disp_frm_buf.u4_y_ht = 1080; + } + PushDecodedFrame(s_dec_op); + } + } + + void CopyImageToResultBuffer(uint8* yIn, uint8* uvIn, uint8* bufOut, ivd_video_decode_op_t& decodeInfo) + { + uint32 imageWidth = decodeInfo.s_disp_frm_buf.u4_y_wd; + uint32 imageHeight = decodeInfo.s_disp_frm_buf.u4_y_ht; + + size_t inputStride = decodeInfo.s_disp_frm_buf.u4_y_strd; + size_t outputStride = (imageWidth + 0xFF) & ~0xFF; + + // copy Y + uint8* yOut = bufOut; + for (uint32 row = 0; row < imageHeight; row++) + { + memcpy(yOut, yIn, imageWidth); + yIn += inputStride; + yOut += outputStride; + } + + // copy UV + uint8* uvOut = bufOut + outputStride * imageHeight; + for (uint32 row = 0; row < imageHeight/2; row++) + { + memcpy(uvOut, uvIn, imageWidth); + uvIn += inputStride; + uvOut += outputStride; + } + } + private: + void SetDecoderCoreCount(uint32 coreCount) + { + ih264d_ctl_set_num_cores_ip_t s_set_cores_ip; + ih264d_ctl_set_num_cores_op_t s_set_cores_op; + s_set_cores_ip.e_cmd = IVD_CMD_VIDEO_CTL; + s_set_cores_ip.e_sub_cmd = (IVD_CONTROL_API_COMMAND_TYPE_T)IH264D_CMD_CTL_SET_NUM_CORES; + s_set_cores_ip.u4_num_cores = coreCount; // valid numbers are 1-4 + s_set_cores_ip.u4_size = sizeof(ih264d_ctl_set_num_cores_ip_t); + s_set_cores_op.u4_size = sizeof(ih264d_ctl_set_num_cores_op_t); + IV_API_CALL_STATUS_T status = ih264d_api_function(m_codecCtx, (void *)&s_set_cores_ip, (void *)&s_set_cores_op); + cemu_assert(status == IV_SUCCESS); + } + + bool DetermineBufferSizes(void* data, uint32 length, uint32& numByteConsumed) + { + numByteConsumed = 0; + UpdateParameters(true); + + ivd_video_decode_ip_t s_dec_ip{ 0 }; + ivd_video_decode_op_t s_dec_op{ 0 }; + s_dec_ip.u4_size = sizeof(ivd_video_decode_ip_t); + s_dec_op.u4_size = sizeof(ivd_video_decode_op_t); + + s_dec_ip.e_cmd = IVD_CMD_VIDEO_DECODE; + s_dec_ip.pv_stream_buffer = (uint8*)data; + s_dec_ip.u4_num_Bytes = length; + s_dec_ip.s_out_buffer.u4_num_bufs = 0; + WORD32 status = ih264d_api_function(m_codecCtx, &s_dec_ip, &s_dec_op); + if (status != 0) + { + cemuLog_log(LogType::Force, "H264: Unable to determine buffer sizes for stream"); + return false; + } + numByteConsumed = s_dec_op.u4_num_bytes_consumed; + cemu_assert(status == 0); + if (s_dec_op.u4_pic_wd == 0 || s_dec_op.u4_pic_ht == 0) + return false; + UpdateParameters(false); + ReinitBuffers(); + return true; + } + + void ReinitBuffers() + { + ivd_ctl_getbufinfo_ip_t s_ctl_ip{ 0 }; + ivd_ctl_getbufinfo_op_t s_ctl_op{ 0 }; + WORD32 outlen = 0; + + s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL; + s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_GETBUFINFO; + s_ctl_ip.u4_size = sizeof(ivd_ctl_getbufinfo_ip_t); + s_ctl_op.u4_size = sizeof(ivd_ctl_getbufinfo_op_t); + + WORD32 status = ih264d_api_function(m_codecCtx, &s_ctl_ip, &s_ctl_op); + cemu_assert(!status); + + // allocate + for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) + { + m_displayBuf.emplace_back().resize(s_ctl_op.u4_min_out_buf_size[0] + s_ctl_op.u4_min_out_buf_size[1]); + } + // set + ivd_set_display_frame_ip_t s_set_display_frame_ip{ 0 }; // make sure to zero-initialize this. The codec seems to check the first 3 pointers/sizes per frame, regardless of the value of u4_num_bufs + ivd_set_display_frame_op_t s_set_display_frame_op{ 0 }; + + s_set_display_frame_ip.e_cmd = IVD_CMD_SET_DISPLAY_FRAME; + s_set_display_frame_ip.u4_size = sizeof(ivd_set_display_frame_ip_t); + s_set_display_frame_op.u4_size = sizeof(ivd_set_display_frame_op_t); + + cemu_assert_debug(s_ctl_op.u4_min_num_out_bufs == 2); + cemu_assert_debug(s_ctl_op.u4_min_out_buf_size[0] != 0 && s_ctl_op.u4_min_out_buf_size[1] != 0); + + s_set_display_frame_ip.num_disp_bufs = s_ctl_op.u4_num_disp_bufs; + + for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) + { + s_set_display_frame_ip.s_disp_buffer[i].u4_num_bufs = 2; + s_set_display_frame_ip.s_disp_buffer[i].u4_min_out_buf_size[0] = s_ctl_op.u4_min_out_buf_size[0]; + s_set_display_frame_ip.s_disp_buffer[i].u4_min_out_buf_size[1] = s_ctl_op.u4_min_out_buf_size[1]; + s_set_display_frame_ip.s_disp_buffer[i].pu1_bufs[0] = m_displayBuf[i].data() + 0; + s_set_display_frame_ip.s_disp_buffer[i].pu1_bufs[1] = m_displayBuf[i].data() + s_ctl_op.u4_min_out_buf_size[0]; + } + + status = ih264d_api_function(m_codecCtx, &s_set_display_frame_ip, &s_set_display_frame_op); + cemu_assert(!status); + + + // mark all as released (available) + for (uint32 i = 0; i < s_ctl_op.u4_num_disp_bufs; i++) + { + ivd_rel_display_frame_ip_t s_video_rel_disp_ip{ 0 }; + ivd_rel_display_frame_op_t s_video_rel_disp_op{ 0 }; + + s_video_rel_disp_ip.e_cmd = IVD_CMD_REL_DISPLAY_FRAME; + s_video_rel_disp_ip.u4_size = sizeof(ivd_rel_display_frame_ip_t); + s_video_rel_disp_op.u4_size = sizeof(ivd_rel_display_frame_op_t); + s_video_rel_disp_ip.u4_disp_buf_id = i; + + status = ih264d_api_function(m_codecCtx, &s_video_rel_disp_ip, &s_video_rel_disp_op); + cemu_assert(!status); + } + } + + void ResetDecoder() + { + ivd_ctl_reset_ip_t s_ctl_ip; + ivd_ctl_reset_op_t s_ctl_op; + + s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL; + s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_RESET; + s_ctl_ip.u4_size = sizeof(ivd_ctl_reset_ip_t); + s_ctl_op.u4_size = sizeof(ivd_ctl_reset_op_t); + + WORD32 status = ih264d_api_function(m_codecCtx, (void*)&s_ctl_ip, (void*)&s_ctl_op); + cemu_assert_debug(status == 0); + } + + void UpdateParameters(bool headerDecodeOnly) + { + ih264d_ctl_set_config_ip_t s_h264d_ctl_ip{ 0 }; + ih264d_ctl_set_config_op_t s_h264d_ctl_op{ 0 }; + ivd_ctl_set_config_ip_t* ps_ctl_ip = &s_h264d_ctl_ip.s_ivd_ctl_set_config_ip_t; + ivd_ctl_set_config_op_t* ps_ctl_op = &s_h264d_ctl_op.s_ivd_ctl_set_config_op_t; + + ps_ctl_ip->u4_disp_wd = 0; + ps_ctl_ip->e_frm_skip_mode = IVD_SKIP_NONE; + ps_ctl_ip->e_frm_out_mode = m_isBufferedMode ? IVD_DISPLAY_FRAME_OUT : IVD_DECODE_FRAME_OUT; + ps_ctl_ip->e_vid_dec_mode = headerDecodeOnly ? IVD_DECODE_HEADER : IVD_DECODE_FRAME; + ps_ctl_ip->e_cmd = IVD_CMD_VIDEO_CTL; + ps_ctl_ip->e_sub_cmd = IVD_CMD_CTL_SETPARAMS; + ps_ctl_ip->u4_size = sizeof(ih264d_ctl_set_config_ip_t); + ps_ctl_op->u4_size = sizeof(ih264d_ctl_set_config_op_t); + + WORD32 status = ih264d_api_function(m_codecCtx, &s_h264d_ctl_ip, &s_h264d_ctl_op); + cemu_assert(status == 0); + } + + private: + void DecoderThread() + { + while(!m_threadShouldExit) + { + m_decodeSem.decrementWithWait(); + std::unique_lock _l(m_decodeQueueMtx); + if (m_decodeQueue.empty()) + continue; + uint32 decodeIndex = m_decodeQueue.front(); + m_decodeQueue.erase(m_decodeQueue.begin()); + _l.unlock(); + if(decodeIndex == CMD_FLUSH) + { + Flush(); + _l.lock(); + cemu_assert_debug(m_decodeQueue.empty()); // after flushing the queue should be empty since the sender is waiting for the flush to complete + _l.unlock(); + coreinit::OSSignalEvent(m_flushEvt); + } + else + { + auto& decodedSlice = m_decodedSliceArray[decodeIndex]; + Decode(decodedSlice); + } + } + } + + iv_obj_t* m_codecCtx{nullptr}; + bool m_hasBufferSizeInfo{ false }; + bool m_isBufferedMode{ false }; + uint32 m_numDecodedFrames{0}; + std::vector<std::vector<uint8>> m_displayBuf; + + std::thread m_decoderThread; + std::atomic_bool m_threadShouldExit{false}; + }; + + H264DecoderBackend* CreateAVCDecoder() + { + return new H264AVCDecoder(); + } +}; diff --git a/src/Cafe/OS/libs/h264_avc/H264DecInternal.h b/src/Cafe/OS/libs/h264_avc/H264DecInternal.h new file mode 100644 index 00000000..498cccfa --- /dev/null +++ b/src/Cafe/OS/libs/h264_avc/H264DecInternal.h @@ -0,0 +1,139 @@ +#pragma once + +#include "util/helpers/Semaphore.h" +#include "Cafe/OS/libs/coreinit/coreinit_Thread.h" +#include "Cafe/OS/libs/coreinit/coreinit_SysHeap.h" + +#include "Cafe/OS/libs/h264_avc/parser/H264Parser.h" + +namespace H264 +{ + class H264DecoderBackend + { + protected: + struct DataToDecode + { + uint8* m_data; + uint32 m_length; + std::vector<uint8> m_buffer; + }; + + static constexpr uint32 CMD_FLUSH = 0xFFFFFFFF; + + public: + struct DecodeResult + { + bool isDecoded{false}; + bool hasFrame{false}; // set to true if a full frame was successfully decoded + double timestamp{}; + void* imageOutput{nullptr}; + sint32 frameWidth{0}; + sint32 frameHeight{0}; + uint32 bytesPerRow{0}; + bool cropEnable{false}; + sint32 cropTop{0}; + sint32 cropBottom{0}; + sint32 cropLeft{0}; + sint32 cropRight{0}; + }; + + struct DecodedSlice + { + bool isUsed{false}; + DecodeResult result; + DataToDecode dataToDecode; + }; + + H264DecoderBackend() + { + m_displayQueueEvt = (coreinit::OSEvent*)coreinit::OSAllocFromSystem(sizeof(coreinit::OSEvent), 4); + coreinit::OSInitEvent(m_displayQueueEvt, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + m_flushEvt = (coreinit::OSEvent*)coreinit::OSAllocFromSystem(sizeof(coreinit::OSEvent), 4); + coreinit::OSInitEvent(m_flushEvt, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); + }; + + virtual ~H264DecoderBackend() + { + coreinit::OSFreeToSystem(m_displayQueueEvt); + coreinit::OSFreeToSystem(m_flushEvt); + }; + + virtual void Init(bool isBufferedMode) = 0; + virtual void Destroy() = 0; + + void QueueForDecode(uint8* data, uint32 length, double timestamp, void* imagePtr) + { + std::unique_lock _l(m_decodeQueueMtx); + + DecodedSlice& ds = GetFreeDecodedSliceEntry(); + + ds.dataToDecode.m_buffer.assign(data, data + length); + ds.dataToDecode.m_data = ds.dataToDecode.m_buffer.data(); + ds.dataToDecode.m_length = length; + + ds.result.isDecoded = false; + ds.result.imageOutput = imagePtr; + ds.result.timestamp = timestamp; + + m_decodeQueue.push_back(std::distance(m_decodedSliceArray.data(), &ds)); + m_decodeSem.increment(); + } + + void QueueFlush() + { + std::unique_lock _l(m_decodeQueueMtx); + m_decodeQueue.push_back(CMD_FLUSH); + m_decodeSem.increment(); + } + + bool GetFrameOutputIfReady(DecodeResult& result) + { + std::unique_lock _l(m_decodeQueueMtx); + if(m_displayQueue.empty()) + return false; + uint32 sliceIndex = m_displayQueue.front(); + DecodedSlice& ds = m_decodedSliceArray[sliceIndex]; + cemu_assert_debug(ds.result.isDecoded); + std::swap(result, ds.result); + ds.isUsed = false; + m_displayQueue.erase(m_displayQueue.begin()); + return true; + } + + coreinit::OSEvent& GetFrameOutputEvent() + { + return *m_displayQueueEvt; + } + + coreinit::OSEvent& GetFlushEvent() + { + return *m_flushEvt; + } + + protected: + DecodedSlice& GetFreeDecodedSliceEntry() + { + for (auto& slice : m_decodedSliceArray) + { + if (!slice.isUsed) + { + slice.isUsed = true; + return slice; + } + } + cemu_assert_suspicious(); + return m_decodedSliceArray[0]; + } + + std::mutex m_decodeQueueMtx; + std::vector<uint32> m_decodeQueue; // indices into m_decodedSliceArray, in order of decode input + CounterSemaphore m_decodeSem; + std::vector<uint32> m_displayQueue; // indices into m_decodedSliceArray, in order of frame display output + coreinit::OSEvent* m_displayQueueEvt; // signalled when a new frame is ready for display + coreinit::OSEvent* m_flushEvt; // signalled after flush operation finished and all queued slices are decoded + + // frame output queue + std::mutex m_frameOutputMtx; + std::array<DecodedSlice, 32> m_decodedSliceArray; + }; +} \ No newline at end of file diff --git a/src/Cafe/OS/libs/h264_avc/parser/H264Parser.cpp b/src/Cafe/OS/libs/h264_avc/parser/H264Parser.cpp index d77e551f..36f70f81 100644 --- a/src/Cafe/OS/libs/h264_avc/parser/H264Parser.cpp +++ b/src/Cafe/OS/libs/h264_avc/parser/H264Parser.cpp @@ -319,6 +319,17 @@ bool parseNAL_pic_parameter_set_rbsp(h264ParserState_t* h264ParserState, h264Par return true; } +bool h264Parser_ParseSPS(uint8* data, uint32 length, h264State_seq_parameter_set_t& sps) +{ + h264ParserState_t parserState; + RBSPInputBitstream nalStream(data, length); + bool r = parseNAL_seq_parameter_set_rbsp(&parserState, nullptr, nalStream); + if(!r || !parserState.hasSPS) + return false; + sps = parserState.sps; + return true; +} + void parseNAL_ref_pic_list_modification(const h264State_seq_parameter_set_t& sps, const h264State_pic_parameter_set_t& pps, RBSPInputBitstream& nalStream, nal_slice_header_t* sliceHeader) { if (!sliceHeader->slice_type.isSliceTypeI() && !sliceHeader->slice_type.isSliceTypeSI()) @@ -688,9 +699,8 @@ void _calculateFrameOrder(h264ParserState_t* h264ParserState, const h264State_se else if (sps.pic_order_cnt_type == 2) { // display order matches decode order - uint32 prevFrameNum = h264ParserState->picture_order.prevFrameNum; - ; + uint32 FrameNumOffset; if (sliceHeader->IdrPicFlag) { @@ -706,9 +716,6 @@ void _calculateFrameOrder(h264ParserState_t* h264ParserState, const h264State_se FrameNumOffset = prevFrameNumOffset + sps.getMaxFrameNum(); else FrameNumOffset = prevFrameNumOffset; - - - } uint32 tempPicOrderCnt; diff --git a/src/Cafe/OS/libs/h264_avc/parser/H264Parser.h b/src/Cafe/OS/libs/h264_avc/parser/H264Parser.h index ee32ca8b..6f2b3cf6 100644 --- a/src/Cafe/OS/libs/h264_avc/parser/H264Parser.h +++ b/src/Cafe/OS/libs/h264_avc/parser/H264Parser.h @@ -513,6 +513,8 @@ typedef struct void h264Parse(h264ParserState_t* h264ParserState, h264ParserOutput_t* output, uint8* data, uint32 length, bool parseSlices = true); sint32 h264GetUnitLength(h264ParserState_t* h264ParserState, uint8* data, uint32 length); +bool h264Parser_ParseSPS(uint8* data, uint32 length, h264State_seq_parameter_set_t& sps); + void h264Parser_getScalingMatrix4x4(h264State_seq_parameter_set_t* sps, h264State_pic_parameter_set_t* pps, nal_slice_header_t* sliceHeader, sint32 index, uint8* matrix4x4); void h264Parser_getScalingMatrix8x8(h264State_seq_parameter_set_t* sps, h264State_pic_parameter_set_t* pps, nal_slice_header_t* sliceHeader, sint32 index, uint8* matrix8x8); From 026d547dccd568a67bd42214728b173811694a1e Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:45:34 +0200 Subject: [PATCH 217/314] Use HTTP 1.1 in Nintendo API requests --- src/Cemu/napi/napi_helper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Cemu/napi/napi_helper.cpp b/src/Cemu/napi/napi_helper.cpp index 164de7e5..182c5371 100644 --- a/src/Cemu/napi/napi_helper.cpp +++ b/src/Cemu/napi/napi_helper.cpp @@ -107,6 +107,7 @@ CurlRequestHelper::CurlRequestHelper() curl_easy_setopt(m_curl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curl, CURLOPT_MAXREDIRS, 2); + curl_easy_setopt(m_curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); if(GetConfig().proxy_server.GetValue() != "") { @@ -263,6 +264,7 @@ CurlSOAPHelper::CurlSOAPHelper(NetworkService service) m_curl = curl_easy_init(); curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, __curlWriteCallback); curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this); + curl_easy_setopt(m_curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); // SSL if (!IsNetworkServiceSSLDisabled(service)) From 252429933f8ae8dde9443ee5cc2c17b83b7b9dc7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Jul 2024 03:31:42 +0200 Subject: [PATCH 218/314] debugger: Slightly optimize symbol list updates --- src/gui/debugger/SymbolCtrl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/debugger/SymbolCtrl.cpp b/src/gui/debugger/SymbolCtrl.cpp index cb1f3b1a..aa862987 100644 --- a/src/gui/debugger/SymbolCtrl.cpp +++ b/src/gui/debugger/SymbolCtrl.cpp @@ -46,25 +46,25 @@ SymbolListCtrl::SymbolListCtrl(wxWindow* parent, const wxWindowID& id, const wxP void SymbolListCtrl::OnGameLoaded() { m_data.clear(); - long itemId = 0; const auto symbol_map = rplSymbolStorage_lockSymbolMap(); for (auto const& [address, symbol_info] : symbol_map) { if (symbol_info == nullptr || symbol_info->symbolName == nullptr) continue; + wxString libNameWX = wxString::FromAscii((const char*)symbol_info->libName); + wxString symbolNameWX = wxString::FromAscii((const char*)symbol_info->symbolName); + wxString searchNameWX = libNameWX + symbolNameWX; + searchNameWX.MakeLower(); + auto new_entry = m_data.try_emplace( symbol_info->address, - (char*)(symbol_info->symbolName), - (char*)(symbol_info->libName), - "", + symbolNameWX, + libNameWX, + searchNameWX, false ); - new_entry.first->second.searchName += new_entry.first->second.name; - new_entry.first->second.searchName += new_entry.first->second.libName; - new_entry.first->second.searchName.MakeLower(); - if (m_list_filter.IsEmpty()) new_entry.first->second.visible = true; else if (new_entry.first->second.searchName.Contains(m_list_filter)) From 47f1dcf99691fbf0f8125f98f7df5ebf9eed221a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Jul 2024 05:08:38 +0200 Subject: [PATCH 219/314] debugger: Add symbol support to PPC stack traces Also moved the declaration to precompiled.h instead of redefining it wherever it is used --- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 2 -- src/Cafe/OS/libs/coreinit/coreinit.cpp | 14 +++++++++++--- src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp | 2 -- src/Common/ExceptionHandler/ExceptionHandler.cpp | 4 +--- src/Common/precompiled.h | 3 +++ .../PPCThreadsViewer/DebugPPCThreadsWindow.cpp | 4 +--- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 62a5d592..e7369af6 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -501,8 +501,6 @@ void debugger_createPPCStateSnapshot(PPCInterpreter_t* hCPU) debuggerState.debugSession.ppcSnapshot.cr[i] = hCPU->cr[i]; } -void DebugLogStackTrace(OSThread_t* thread, MPTR sp); - void debugger_enterTW(PPCInterpreter_t* hCPU) { // handle logging points diff --git a/src/Cafe/OS/libs/coreinit/coreinit.cpp b/src/Cafe/OS/libs/coreinit/coreinit.cpp index 49d232f8..00327a97 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit.cpp @@ -1,6 +1,6 @@ #include "Cafe/OS/common/OSCommon.h" #include "Common/SysAllocator.h" -#include "Cafe/OS/RPL/rpl.h" +#include "Cafe/OS/RPL/rpl_symbol_storage.h" #include "Cafe/OS/libs/coreinit/coreinit_Misc.h" @@ -69,7 +69,7 @@ sint32 ScoreStackTrace(OSThread_t* thread, MPTR sp) return score; } -void DebugLogStackTrace(OSThread_t* thread, MPTR sp) +void DebugLogStackTrace(OSThread_t* thread, MPTR sp, bool printSymbols) { // sp might not point to a valid stackframe // scan stack and evaluate which sp is most likely the beginning of the stackframe @@ -107,7 +107,15 @@ void DebugLogStackTrace(OSThread_t* thread, MPTR sp) uint32 returnAddress = 0; returnAddress = memory_readU32(nextStackPtr + 4); - cemuLog_log(LogType::Force, fmt::format("SP {0:08x} ReturnAddr {1:08x}", nextStackPtr, returnAddress)); + + RPLStoredSymbol* symbol = nullptr; + if(printSymbols) + symbol = rplSymbolStorage_getByClosestAddress(returnAddress); + + if(symbol) + cemuLog_log(LogType::Force, fmt::format("SP {:08x} ReturnAddr {:08x} ({}.{}+0x{:x})", nextStackPtr, returnAddress, (const char*)symbol->libName, (const char*)symbol->symbolName, returnAddress - symbol->address)); + else + cemuLog_log(LogType::Force, fmt::format("SP {:08x} ReturnAddr {:08x}", nextStackPtr, returnAddress)); currentStackPtr = nextStackPtr; } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp b/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp index 7ddadcf1..552a610f 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.cpp @@ -2,8 +2,6 @@ #include "Cafe/HW/Espresso/PPCCallback.h" #include "Cafe/OS/libs/coreinit/coreinit_MEM_ExpHeap.h" -void DebugLogStackTrace(OSThread_t* thread, MPTR sp); - #define EXP_HEAP_GET_FROM_FREE_BLOCKCHAIN(__blockchain__) (MEMExpHeapHead2*)((uintptr_t)__blockchain__ - offsetof(MEMExpHeapHead2, expHeapHead) - offsetof(MEMExpHeapHead40_t, chainFreeBlocks)) namespace coreinit diff --git a/src/Common/ExceptionHandler/ExceptionHandler.cpp b/src/Common/ExceptionHandler/ExceptionHandler.cpp index b6755fd8..7530a2eb 100644 --- a/src/Common/ExceptionHandler/ExceptionHandler.cpp +++ b/src/Common/ExceptionHandler/ExceptionHandler.cpp @@ -6,8 +6,6 @@ #include "Cafe/HW/Espresso/Debugger/GDBStub.h" #include "ExceptionHandler.h" -void DebugLogStackTrace(OSThread_t* thread, MPTR sp); - bool crashLogCreated = false; bool CrashLog_Create() @@ -97,7 +95,7 @@ void ExceptionHandler_LogGeneralInfo() MPTR currentStackVAddr = hCPU->gpr[1]; CrashLog_WriteLine(""); CrashLog_WriteHeader("PPC stack trace"); - DebugLogStackTrace(currentThread, currentStackVAddr); + DebugLogStackTrace(currentThread, currentStackVAddr, true); // stack dump CrashLog_WriteLine(""); diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 790a001a..61707519 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -552,6 +552,9 @@ inline uint32 GetTitleIdLow(uint64 titleId) #include "Cafe/HW/Espresso/PPCState.h" #include "Cafe/HW/Espresso/PPCCallback.h" +// PPC stack trace printer +void DebugLogStackTrace(struct OSThread_t* thread, MPTR sp, bool printSymbols = false); + // generic formatter for enums (to underlying) template <typename Enum> requires std::is_enum_v<Enum> diff --git a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp index dfbaf76e..f4e5b7af 100644 --- a/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp +++ b/src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp @@ -277,12 +277,10 @@ void DebugPPCThreadsWindow::RefreshThreadList() m_thread_list->SetScrollPos(0, scrollPos, true); } -void DebugLogStackTrace(OSThread_t* thread, MPTR sp); - void DebugPPCThreadsWindow::DumpStackTrace(OSThread_t* thread) { cemuLog_log(LogType::Force, "Dumping stack trace for thread {0:08x} LR: {1:08x}", memory_getVirtualOffsetFromPointer(thread), _swapEndianU32(thread->context.lr)); - DebugLogStackTrace(thread, _swapEndianU32(thread->context.gpr[1])); + DebugLogStackTrace(thread, _swapEndianU32(thread->context.gpr[1]), true); } void DebugPPCThreadsWindow::PresentProfileResults(OSThread_t* thread, const std::unordered_map<VAddr, uint32>& samples) From 5328e9eb10b2abeaf303310b06b37269d79dde12 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 26 Jul 2024 05:13:45 +0200 Subject: [PATCH 220/314] CPU: Fix overflow bit calculation in SUBFO instruction Since rD can overlap with rA or rB the result needs to be stored in a temporary --- src/Cafe/HW/Espresso/Interpreter/PPCInterpreterALU.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterALU.hpp b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterALU.hpp index ed97288d..fe9316f0 100644 --- a/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterALU.hpp +++ b/src/Cafe/HW/Espresso/Interpreter/PPCInterpreterALU.hpp @@ -212,11 +212,12 @@ static void PPCInterpreter_SUBF(PPCInterpreter_t* hCPU, uint32 opcode) static void PPCInterpreter_SUBFO(PPCInterpreter_t* hCPU, uint32 opcode) { - // untested (Don't Starve Giant Edition uses this) + // Seen in Don't Starve Giant Edition and Teslagrad // also used by DS Virtual Console (Super Mario 64 DS) PPC_OPC_TEMPL3_XO(); - hCPU->gpr[rD] = ~hCPU->gpr[rA] + hCPU->gpr[rB] + 1; - PPCInterpreter_setXerOV(hCPU, checkAdditionOverflow(~hCPU->gpr[rA], hCPU->gpr[rB], hCPU->gpr[rD])); + uint32 result = ~hCPU->gpr[rA] + hCPU->gpr[rB] + 1; + PPCInterpreter_setXerOV(hCPU, checkAdditionOverflow(~hCPU->gpr[rA], hCPU->gpr[rB], result)); + hCPU->gpr[rD] = result; if (opHasRC()) ppc_update_cr0(hCPU, hCPU->gpr[rD]); PPCInterpreter_nextInstruction(hCPU); From c73fa3761c9572db4d09cdb976a0f1510cda548a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:45:36 +0200 Subject: [PATCH 221/314] Fix compatibility with GCC --- src/resource/embedded/fontawesome.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/resource/embedded/fontawesome.S b/src/resource/embedded/fontawesome.S index 29b4f93a..db23e7ae 100644 --- a/src/resource/embedded/fontawesome.S +++ b/src/resource/embedded/fontawesome.S @@ -1,4 +1,4 @@ -.rodata +.section .rodata,"",%progbits .global g_fontawesome_data, g_fontawesome_size g_fontawesome_data: @@ -6,3 +6,4 @@ g_fontawesome_data: g_fontawesome_size: .int g_fontawesome_size - g_fontawesome_data +.section .note.GNU-stack,"",%progbits \ No newline at end of file From 593da5ed79cab9ca175391d0ba6666a1f8a52500 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 27 Jul 2024 18:33:01 +0200 Subject: [PATCH 222/314] CI: Workaround for MoltenVK crash 1.2.10 and later crash during descriptor set creation. So for now let's stick with the older version --- .github/workflows/build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2342c27..28efa833 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -239,7 +239,17 @@ jobs: - name: "Install system dependencies" run: | brew update - brew install llvm@15 ninja nasm molten-vk automake libtool + brew install llvm@15 ninja nasm automake libtool + brew install cmake python3 ninja + + - name: "Build and install molten-vk" + run: | + git clone https://github.com/KhronosGroup/MoltenVK.git + cd MoltenVK + git checkout bf097edc74ec3b6dfafdcd5a38d3ce14b11952d6 + ./fetchDependencies --macos + make macos + make install - name: "Setup cmake" uses: jwlawson/actions-setup-cmake@v2 From 517e68fe57ac1ac112f37c321d3d40a30ea5a8d6 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Sun, 28 Jul 2024 17:50:20 +0100 Subject: [PATCH 223/314] nsyshid: Tidyups and Fixes (#1275) --- src/Cafe/OS/libs/nsyshid/Skylander.cpp | 2 +- src/Cafe/OS/libs/nsyshid/Skylander.h | 2 +- src/config/CemuConfig.h | 2 +- src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp index a9888787..1b4515ef 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.cpp +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -978,7 +978,7 @@ namespace nsyshid { for (const auto& it : GetListSkylanders()) { - if(it.first.first == skyId && it.first.second == skyVar) + if (it.first.first == skyId && it.first.second == skyVar) { return it.second; } diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h index 95eaff0c..986ef185 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.h +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -50,7 +50,7 @@ namespace nsyshid std::unique_ptr<FileStream> skyFile; uint8 status = 0; std::queue<uint8> queuedStatus; - std::array<uint8, SKY_BLOCK_SIZE> data{}; + std::array<uint8, SKY_FIGURE_SIZE> data{}; uint32 lastId = 0; void Save(); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 2a1d29cb..ac861c9a 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -519,7 +519,7 @@ struct CemuConfig struct { ConfigValue<bool> emulate_skylander_portal{false}; - ConfigValue<bool> emulate_infinity_base{true}; + ConfigValue<bool> emulate_infinity_base{false}; }emulated_usb_devices{}; private: diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp index f4784f35..3a0f534a 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -398,7 +398,7 @@ CreateInfinityFigureDialog::CreateInfinityFigureDialog(wxWindow* parent, uint8 s { wxMessageDialog idError(this, "Error Converting Figure Number!", "Number Entered is Invalid"); idError.ShowModal(); - this->EndModal(0);; + this->EndModal(0); } uint32 figNum = longFigNum & 0xFFFFFFFF; auto figure = nsyshid::g_infinitybase.FindFigure(figNum); @@ -408,7 +408,7 @@ CreateInfinityFigureDialog::CreateInfinityFigureDialog(wxWindow* parent, uint8 s "BIN files (*.bin)|*.bin", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (saveFileDialog.ShowModal() == wxID_CANCEL) - this->EndModal(0);; + this->EndModal(0); m_filePath = saveFileDialog.GetPath(); From 1575866eca8f84bbe94f2e3a5c2bc8938a5856bb Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:45:57 +0200 Subject: [PATCH 224/314] Vulkan: Add R32_X8_FLOAT format --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 9209e3cd..b9922fc3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2439,6 +2439,11 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD // used by Color Splash and Resident Evil formatInfoOut->vkImageFormat = VK_FORMAT_R8G8B8A8_UINT; // todo - should we use ABGR format? formatInfoOut->decoder = TextureDecoder_X24_G8_UINT::getInstance(); // todo - verify + case Latte::E_GX2SURFFMT::R32_X8_FLOAT: + // seen in Disney Infinity 3.0 + formatInfoOut->vkImageFormat = VK_FORMAT_R32_SFLOAT; + formatInfoOut->decoder = TextureDecoder_NullData64::getInstance(); + break; default: cemuLog_log(LogType::Force, "Unsupported color texture format {:04x}", (uint32)format); cemu_assert_debug(false); From d81eb952a4c8273670c9a29fc3c7e69961282d41 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:58:23 +0200 Subject: [PATCH 225/314] nsyshid: Silence some logging in release builds --- src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp index 44e01399..267111b2 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp @@ -67,13 +67,6 @@ namespace nsyshid::backend::windows device->m_productId); } } - else - { - cemuLog_log(LogType::Force, - "nsyshid::BackendWindowsHID: device not on whitelist: {:04x}:{:04x}", - device->m_vendorId, - device->m_productId); - } } CloseHandle(hHIDDevice); } @@ -125,14 +118,12 @@ namespace nsyshid::backend::windows } if (maxPacketInputLength <= 0 || maxPacketInputLength >= 0xF000) { - cemuLog_log(LogType::Force, "HID: Input packet length not available or out of range (length = {})", - maxPacketInputLength); + cemuLog_logDebug(LogType::Force, "HID: Input packet length not available or out of range (length = {})", maxPacketInputLength); maxPacketInputLength = 0x20; } if (maxPacketOutputLength <= 0 || maxPacketOutputLength >= 0xF000) { - cemuLog_log(LogType::Force, "HID: Output packet length not available or out of range (length = {})", - maxPacketOutputLength); + cemuLog_logDebug(LogType::Force, "HID: Output packet length not available or out of range (length = {})", maxPacketOutputLength); maxPacketOutputLength = 0x20; } From 21296447812794f8cde76db93cf3697a96da7ac9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 6 Aug 2024 23:02:28 +0200 Subject: [PATCH 226/314] Remove shaderCache directory The location of the shaderCache path is different for non-portable cases so let's not confuse the user by shipping with a precreated directory that isn't actually used --- bin/shaderCache/info.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 bin/shaderCache/info.txt diff --git a/bin/shaderCache/info.txt b/bin/shaderCache/info.txt deleted file mode 100644 index 962cf88b..00000000 --- a/bin/shaderCache/info.txt +++ /dev/null @@ -1 +0,0 @@ -If you plan to transfer the shader cache to a different PC or Cemu installation you only need to copy the 'transferable' directory. \ No newline at end of file From b52b676413a5566adc4a5c1f2472fa6cc961a94c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 7 Aug 2024 02:50:24 +0200 Subject: [PATCH 227/314] vcpkg: Automatically unshallow submodule --- CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b5f3881..48e18637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,24 @@ if (EXPERIMENTAL_VERSION) endif() if (ENABLE_VCPKG) + # check if vcpkg is shallow and unshallow it if necessary + execute_process( + COMMAND git rev-parse --is-shallow-repository + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dependencies/vcpkg + OUTPUT_VARIABLE is_vcpkg_shallow + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(is_vcpkg_shallow STREQUAL "true") + message(STATUS "vcpkg is shallow. Unshallowing it now...") + execute_process( + COMMAND git fetch --unshallow + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/dependencies/vcpkg" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ) + endif() + if(UNIX AND NOT APPLE) set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports_linux") elseif(APPLE) From bf2208145b21505f5ebe3b1245e4c32bfc6f0d45 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:18:40 +0200 Subject: [PATCH 228/314] Enable async shader compile by default --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 4 +++- src/config/CemuConfig.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index b9922fc3..09515993 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -7,6 +7,7 @@ #include "Cafe/HW/Latte/Core/LatteBufferCache.h" #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" +#include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h" @@ -29,6 +30,7 @@ #include <glslang/Public/ShaderLang.h> #include <wx/msgdlg.h> +#include <wx/intl.h> // for localization #ifndef VK_API_VERSION_MAJOR #define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22) & 0x7FU) @@ -285,7 +287,7 @@ void VulkanRenderer::GetDeviceFeatures() cemuLog_log(LogType::Force, "VK_EXT_pipeline_creation_cache_control not supported. Cannot use asynchronous shader and pipeline compilation"); // if async shader compilation is enabled show warning message if (GetConfig().async_compile) - wxMessageBox(_("The currently installed graphics driver does not support the Vulkan extension necessary for asynchronous shader compilation. Asynchronous compilation cannot be used.\n \nRequired extension: VK_EXT_pipeline_creation_cache_control\n\nInstalling the latest graphics driver may solve this error."), _("Information"), wxOK | wxCENTRE); + LatteOverlay_pushNotification(_("Async shader compile is enabled but not supported by the graphics driver\nCemu will use synchronous compilation which can cause additional stutter").utf8_string(), 10000); } if (!m_featureControl.deviceExtensions.custom_border_color_without_format) { diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index ac861c9a..5db8f58c 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -441,7 +441,7 @@ struct CemuConfig ConfigValue<int> vsync{ 0 }; // 0 = off, 1+ = on depending on render backend ConfigValue<bool> gx2drawdone_sync {true}; ConfigValue<bool> render_upside_down{ false }; - ConfigValue<bool> async_compile{ false }; + ConfigValue<bool> async_compile{ true }; ConfigValue<bool> vk_accurate_barriers{ true }; From 54e695a6e81efd4fb9a632c62abdb4585f8f776e Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:58:24 +0200 Subject: [PATCH 229/314] git: unshallow vcpkg, shallow vulkan-headers and imgui (#1282) --- .gitmodules | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index f352d478..dc69c441 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,10 +9,12 @@ [submodule "dependencies/vcpkg"] path = dependencies/vcpkg url = https://github.com/microsoft/vcpkg - shallow = true + shallow = false [submodule "dependencies/Vulkan-Headers"] path = dependencies/Vulkan-Headers url = https://github.com/KhronosGroup/Vulkan-Headers + shallow = true [submodule "dependencies/imgui"] path = dependencies/imgui url = https://github.com/ocornut/imgui + shallow = true From 598298cb3d28fd608878f13ef1e76add75173692 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:07:08 +0200 Subject: [PATCH 230/314] Vulkan: Fix stencil front mask --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp index ce582b9a..ba094a84 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp @@ -826,7 +826,7 @@ void PipelineCompiler::InitDepthStencilState() depthStencilState.front.reference = stencilRefFront; depthStencilState.front.compareMask = stencilCompareMaskFront; - depthStencilState.front.writeMask = stencilWriteMaskBack; + depthStencilState.front.writeMask = stencilWriteMaskFront; depthStencilState.front.compareOp = vkDepthCompareTable[(size_t)frontStencilFunc]; depthStencilState.front.depthFailOp = stencilOpTable[(size_t)frontStencilZFail]; depthStencilState.front.failOp = stencilOpTable[(size_t)frontStencilFail]; From 7fd532436d5af65af5a27a532d7ea5cb6ac5895c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:07:36 +0200 Subject: [PATCH 231/314] CI: Manual unshallow of vcpkg is no longer needed --- .github/workflows/build.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28efa833..015ef367 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,11 +24,6 @@ jobs: submodules: "recursive" fetch-depth: 0 - - name: "Fetch full history for vcpkg submodule" - run: | - cd dependencies/vcpkg - git fetch --unshallow - - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} run: | @@ -133,11 +128,6 @@ jobs: with: submodules: "recursive" - - name: "Fetch full history for vcpkg submodule" - run: | - cd dependencies/vcpkg - git fetch --unshallow - - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} run: | @@ -212,11 +202,6 @@ jobs: with: submodules: "recursive" - - name: "Fetch full history for vcpkg submodule" - run: | - cd dependencies/vcpkg - git fetch --unshallow - - name: Setup release mode parameters (for deploy) if: ${{ inputs.deploymode == 'release' }} run: | From 9812a47cb182331f7c7c7a6a16eff014098a6206 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:35:50 +0200 Subject: [PATCH 232/314] clang-format: Put class braces on a new line (#1283) --- .clang-format | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-format b/.clang-format index b22a1048..0cef9ae4 100644 --- a/.clang-format +++ b/.clang-format @@ -15,6 +15,7 @@ BinPackArguments: true BinPackParameters: true BraceWrapping: AfterCaseLabel: true + AfterClass: true AfterControlStatement: Always AfterEnum: true AfterExternBlock: true From e02cc42d675ffe203c3f047f60669583934841ad Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 13 Aug 2024 01:00:49 +0200 Subject: [PATCH 233/314] COS: Implement PPC va_list, va_arg and update related functions --- src/Cafe/OS/common/OSCommon.h | 83 +++++++++++++++ src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp | 112 ++++++++++---------- src/Cafe/OS/libs/coreinit/coreinit_Misc.h | 14 +++ src/Common/MemPtr.h | 19 ++-- src/Common/betype.h | 25 +++++ 5 files changed, 182 insertions(+), 71 deletions(-) diff --git a/src/Cafe/OS/common/OSCommon.h b/src/Cafe/OS/common/OSCommon.h index 4fb65a47..34f207bb 100644 --- a/src/Cafe/OS/common/OSCommon.h +++ b/src/Cafe/OS/common/OSCommon.h @@ -23,3 +23,86 @@ void osLib_returnFromFunction64(PPCInterpreter_t* hCPU, uint64 returnValue64); // utility functions #include "Cafe/OS/common/OSUtil.h" + +// va_list +struct ppc_va_list +{ + uint8be gprIndex; + uint8be fprIndex; + uint8be _padding2[2]; + MEMPTR<uint8be> overflow_arg_area; + MEMPTR<uint8be> reg_save_area; +}; +static_assert(sizeof(ppc_va_list) == 0xC); + +struct ppc_va_list_reg_storage +{ + uint32be gpr_save_area[8]; // 32 bytes, r3 to r10 + float64be fpr_save_area[8]; // 64 bytes, f1 to f8 + ppc_va_list vargs; + uint32be padding; +}; +static_assert(sizeof(ppc_va_list_reg_storage) == 0x70); + +// Equivalent of va_start for PPC HLE functions. Must be called before any StackAllocator<> definitions +#define ppc_define_va_list(__gprIndex, __fprIndex) \ + MPTR vaOriginalR1 = PPCInterpreter_getCurrentInstance()->gpr[1]; \ + StackAllocator<ppc_va_list_reg_storage> va_list_storage; \ + for(int i=3; i<=10; i++) va_list_storage->gpr_save_area[i-3] = PPCInterpreter_getCurrentInstance()->gpr[i]; \ + for(int i=1; i<=8; i++) va_list_storage->fpr_save_area[i-1] = PPCInterpreter_getCurrentInstance()->fpr[i].fp0; \ + va_list_storage->vargs.gprIndex = __gprIndex; \ + va_list_storage->vargs.fprIndex = __fprIndex; \ + va_list_storage->vargs.reg_save_area = (uint8be*)&va_list_storage; \ + va_list_storage->vargs.overflow_arg_area = {vaOriginalR1 + 8}; \ + ppc_va_list& vargs = va_list_storage->vargs; + +enum class ppc_va_type +{ + INT32 = 1, + INT64 = 2, + FLOAT_OR_DOUBLE = 3, +}; + +static void* _ppc_va_arg(ppc_va_list* vargs, ppc_va_type argType) +{ + void* r; + switch ( argType ) + { + default: + cemu_assert_suspicious(); + case ppc_va_type::INT32: + if ( vargs[0].gprIndex < 8u ) + { + r = &vargs->reg_save_area[4 * vargs->gprIndex]; + vargs->gprIndex++; + return r; + } + r = vargs->overflow_arg_area; + vargs->overflow_arg_area += 4; + return r; + case ppc_va_type::INT64: + if ( (vargs->gprIndex & 1) != 0 ) + vargs->gprIndex++; + if ( vargs->gprIndex < 8 ) + { + r = &vargs->reg_save_area[4 * vargs->gprIndex]; + vargs->gprIndex += 2; + return r; + } + vargs->overflow_arg_area = {(vargs->overflow_arg_area.GetMPTR()+7) & 0xFFFFFFF8}; + r = vargs->overflow_arg_area; + vargs->overflow_arg_area += 8; + return r; + case ppc_va_type::FLOAT_OR_DOUBLE: + if ( vargs->fprIndex < 8 ) + { + r = &vargs->reg_save_area[0x20 + 8 * vargs->fprIndex]; + vargs->fprIndex++; + return r; + } + vargs->overflow_arg_area = {(vargs->overflow_arg_area.GetMPTR()+7) & 0xFFFFFFF8}; + r = vargs->overflow_arg_area; + vargs->overflow_arg_area += 8; + return r; + } +} \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp index e2b50661..71a7d6e2 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.cpp @@ -7,14 +7,9 @@ namespace coreinit { - - /* coreinit logging and string format */ - - sint32 ppcSprintf(const char* formatStr, char* strOut, sint32 maxLength, PPCInterpreter_t* hCPU, sint32 initialParamIndex) + sint32 ppc_vprintf(const char* formatStr, char* strOut, sint32 maxLength, ppc_va_list* vargs) { char tempStr[4096]; - sint32 integerParamIndex = initialParamIndex; - sint32 floatParamIndex = 0; sint32 writeIndex = 0; while (*formatStr) { @@ -101,8 +96,7 @@ namespace coreinit tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - sint32 tempLen = sprintf(tempStr, tempFormat, PPCInterpreter_getCallParamU32(hCPU, integerParamIndex)); - integerParamIndex++; + sint32 tempLen = sprintf(tempStr, tempFormat, (uint32)*(uint32be*)_ppc_va_arg(vargs, ppc_va_type::INT32)); for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -120,13 +114,12 @@ namespace coreinit tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - MPTR strOffset = PPCInterpreter_getCallParamU32(hCPU, integerParamIndex); + MPTR strOffset = *(uint32be*)_ppc_va_arg(vargs, ppc_va_type::INT32); sint32 tempLen = 0; if (strOffset == MPTR_NULL) tempLen = sprintf(tempStr, "NULL"); else tempLen = sprintf(tempStr, tempFormat, memory_getPointerFromVirtualOffset(strOffset)); - integerParamIndex++; for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -136,25 +129,6 @@ namespace coreinit } strOut[std::min(maxLength - 1, writeIndex)] = '\0'; } - else if (*formatStr == 'f') - { - // float - formatStr++; - strncpy(tempFormat, formatStart, std::min((std::ptrdiff_t)sizeof(tempFormat) - 1, formatStr - formatStart)); - if ((formatStr - formatStart) < sizeof(tempFormat)) - tempFormat[(formatStr - formatStart)] = '\0'; - else - tempFormat[sizeof(tempFormat) - 1] = '\0'; - sint32 tempLen = sprintf(tempStr, tempFormat, (float)hCPU->fpr[1 + floatParamIndex].fp0); - floatParamIndex++; - for (sint32 i = 0; i < tempLen; i++) - { - if (writeIndex >= maxLength) - break; - strOut[writeIndex] = tempStr[i]; - writeIndex++; - } - } else if (*formatStr == 'c') { // character @@ -164,8 +138,24 @@ namespace coreinit tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - sint32 tempLen = sprintf(tempStr, tempFormat, PPCInterpreter_getCallParamU32(hCPU, integerParamIndex)); - integerParamIndex++; + sint32 tempLen = sprintf(tempStr, tempFormat, (uint32)*(uint32be*)_ppc_va_arg(vargs, ppc_va_type::INT32)); + for (sint32 i = 0; i < tempLen; i++) + { + if (writeIndex >= maxLength) + break; + strOut[writeIndex] = tempStr[i]; + writeIndex++; + } + } + else if (*formatStr == 'f' || *formatStr == 'g' || *formatStr == 'G') + { + formatStr++; + strncpy(tempFormat, formatStart, std::min((std::ptrdiff_t)sizeof(tempFormat) - 1, formatStr - formatStart)); + if ((formatStr - formatStart) < sizeof(tempFormat)) + tempFormat[(formatStr - formatStart)] = '\0'; + else + tempFormat[sizeof(tempFormat) - 1] = '\0'; + sint32 tempLen = sprintf(tempStr, tempFormat, (double)*(betype<double>*)_ppc_va_arg(vargs, ppc_va_type::FLOAT_OR_DOUBLE)); for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -183,8 +173,7 @@ namespace coreinit tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - sint32 tempLen = sprintf(tempStr, tempFormat, (double)hCPU->fpr[1 + floatParamIndex].fp0); - floatParamIndex++; + sint32 tempLen = sprintf(tempStr, tempFormat, (double)*(betype<double>*)_ppc_va_arg(vargs, ppc_va_type::FLOAT_OR_DOUBLE)); for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -196,16 +185,13 @@ namespace coreinit else if ((formatStr[0] == 'l' && formatStr[1] == 'l' && (formatStr[2] == 'x' || formatStr[2] == 'X'))) { formatStr += 3; - // double (64bit) + // 64bit int strncpy(tempFormat, formatStart, std::min((std::ptrdiff_t)sizeof(tempFormat) - 1, formatStr - formatStart)); if ((formatStr - formatStart) < sizeof(tempFormat)) tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - if (integerParamIndex & 1) - integerParamIndex++; - sint32 tempLen = sprintf(tempStr, tempFormat, PPCInterpreter_getCallParamU64(hCPU, integerParamIndex)); - integerParamIndex += 2; + sint32 tempLen = sprintf(tempStr, tempFormat, (uint64)*(uint64be*)_ppc_va_arg(vargs, ppc_va_type::INT64)); for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -223,10 +209,7 @@ namespace coreinit tempFormat[(formatStr - formatStart)] = '\0'; else tempFormat[sizeof(tempFormat) - 1] = '\0'; - if (integerParamIndex & 1) - integerParamIndex++; - sint32 tempLen = sprintf(tempStr, tempFormat, PPCInterpreter_getCallParamU64(hCPU, integerParamIndex)); - integerParamIndex += 2; + sint32 tempLen = sprintf(tempStr, tempFormat, (sint64)*(sint64be*)_ppc_va_arg(vargs, ppc_va_type::INT64)); for (sint32 i = 0; i < tempLen; i++) { if (writeIndex >= maxLength) @@ -255,9 +238,12 @@ namespace coreinit return std::min(writeIndex, maxLength - 1); } + /* coreinit logging and string format */ + sint32 __os_snprintf(char* outputStr, sint32 maxLength, const char* formatStr) { - sint32 r = ppcSprintf(formatStr, outputStr, maxLength, PPCInterpreter_getCurrentInstance(), 3); + ppc_define_va_list(3, 0); + sint32 r = ppc_vprintf(formatStr, outputStr, maxLength, &vargs); return r; } @@ -322,32 +308,40 @@ namespace coreinit } } - void OSReport(const char* format) + void COSVReport(COSReportModule module, COSReportLevel level, const char* format, ppc_va_list* vargs) { - char buffer[1024 * 2]; - sint32 len = ppcSprintf(format, buffer, sizeof(buffer), PPCInterpreter_getCurrentInstance(), 1); - WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len); + char tmpBuffer[1024]; + sint32 len = ppc_vprintf(format, tmpBuffer, sizeof(tmpBuffer), vargs); + WriteCafeConsole(CafeLogType::OSCONSOLE, tmpBuffer, len); } - void OSVReport(const char* format, MPTR vaArgs) + void OSReport(const char* format) { - cemu_assert_unimplemented(); + ppc_define_va_list(1, 0); + COSVReport(COSReportModule::coreinit, COSReportLevel::Info, format, &vargs); + } + + void OSVReport(const char* format, ppc_va_list* vargs) + { + COSVReport(COSReportModule::coreinit, COSReportLevel::Info, format, vargs); } void COSWarn(int moduleId, const char* format) { - char buffer[1024 * 2]; - int prefixLen = sprintf(buffer, "[COSWarn-%d] ", moduleId); - sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, PPCInterpreter_getCurrentInstance(), 2); - WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len + prefixLen); + ppc_define_va_list(2, 0); + char tmpBuffer[1024]; + int prefixLen = sprintf(tmpBuffer, "[COSWarn-%d] ", moduleId); + sint32 len = ppc_vprintf(format, tmpBuffer + prefixLen, sizeof(tmpBuffer) - prefixLen, &vargs); + WriteCafeConsole(CafeLogType::OSCONSOLE, tmpBuffer, len + prefixLen); } void OSLogPrintf(int ukn1, int ukn2, int ukn3, const char* format) { - char buffer[1024 * 2]; - int prefixLen = sprintf(buffer, "[OSLogPrintf-%d-%d-%d] ", ukn1, ukn2, ukn3); - sint32 len = ppcSprintf(format, buffer + prefixLen, sizeof(buffer) - prefixLen, PPCInterpreter_getCurrentInstance(), 4); - WriteCafeConsole(CafeLogType::OSCONSOLE, buffer, len + prefixLen); + ppc_define_va_list(4, 0); + char tmpBuffer[1024]; + int prefixLen = sprintf(tmpBuffer, "[OSLogPrintf-%d-%d-%d] ", ukn1, ukn2, ukn3); + sint32 len = ppc_vprintf(format, tmpBuffer + prefixLen, sizeof(tmpBuffer) - prefixLen, &vargs); + WriteCafeConsole(CafeLogType::OSCONSOLE, tmpBuffer, len + prefixLen); } void OSConsoleWrite(const char* strPtr, sint32 length) @@ -562,9 +556,11 @@ namespace coreinit s_transitionToForeground = false; cafeExportRegister("coreinit", __os_snprintf, LogType::Placeholder); + + cafeExportRegister("coreinit", COSVReport, LogType::Placeholder); + cafeExportRegister("coreinit", COSWarn, LogType::Placeholder); cafeExportRegister("coreinit", OSReport, LogType::Placeholder); cafeExportRegister("coreinit", OSVReport, LogType::Placeholder); - cafeExportRegister("coreinit", COSWarn, LogType::Placeholder); cafeExportRegister("coreinit", OSLogPrintf, LogType::Placeholder); cafeExportRegister("coreinit", OSConsoleWrite, LogType::Placeholder); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Misc.h b/src/Cafe/OS/libs/coreinit/coreinit_Misc.h index 7abba92f..36f6b06a 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Misc.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Misc.h @@ -26,5 +26,19 @@ namespace coreinit uint32 OSDriver_Register(uint32 moduleHandle, sint32 priority, OSDriverInterface* driverCallbacks, sint32 driverId, uint32be* outUkn1, uint32be* outUkn2, uint32be* outUkn3); uint32 OSDriver_Deregister(uint32 moduleHandle, sint32 driverId); + enum class COSReportModule + { + coreinit = 0, + }; + + enum class COSReportLevel + { + Error = 0, + Warn = 1, + Info = 2 + }; + + sint32 ppc_vprintf(const char* formatStr, char* strOut, sint32 maxLength, ppc_va_list* vargs); + void miscInit(); }; \ No newline at end of file diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index 5fb73479..142da7e4 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -92,19 +92,6 @@ public: template <typename X> explicit operator MEMPTR<X>() const { return MEMPTR<X>(this->m_value); } - //bool operator==(const MEMPTR<T>& v) const { return m_value == v.m_value; } - //bool operator==(const T* rhs) const { return (T*)(m_value == 0 ? nullptr : memory_base + (uint32)m_value) == rhs; } -> ambigious (implicit cast to T* allows for T* == T*) - //bool operator==(std::nullptr_t rhs) const { return m_value == 0; } - - //bool operator!=(const MEMPTR<T>& v) const { return !(*this == v); } - //bool operator!=(const void* rhs) const { return !(*this == rhs); } - //bool operator!=(int rhs) const { return !(*this == rhs); } - - //bool operator==(const void* rhs) const { return (void*)(m_value == 0 ? nullptr : memory_base + (uint32)m_value) == rhs; } - - //explicit bool operator==(int rhs) const { return *this == (const void*)(size_t)rhs; } - - MEMPTR operator+(const MEMPTR& ptr) { return MEMPTR(this->GetMPTR() + ptr.GetMPTR()); } MEMPTR operator-(const MEMPTR& ptr) { return MEMPTR(this->GetMPTR() - ptr.GetMPTR()); } @@ -120,6 +107,12 @@ public: return MEMPTR(this->GetMPTR() - v * 4); } + MEMPTR& operator+=(sint32 v) + { + m_value += v * sizeof(T); + return *this; + } + template <class Q = T> typename std::enable_if<!std::is_same<Q, void>::value, Q>::type& operator*() const { return *GetPtr(); } diff --git a/src/Common/betype.h b/src/Common/betype.h index e684fb93..60a64b7a 100644 --- a/src/Common/betype.h +++ b/src/Common/betype.h @@ -121,6 +121,12 @@ public: return *this; } + betype<T>& operator+=(const T& v) requires std::integral<T> + { + m_value = SwapEndian(T(value() + v)); + return *this; + } + betype<T>& operator-=(const betype<T>& v) { m_value = SwapEndian(T(value() - v.value())); @@ -188,17 +194,36 @@ public: return from_bevalue(T(~m_value)); } + // pre-increment betype<T>& operator++() requires std::integral<T> { m_value = SwapEndian(T(value() + 1)); return *this; } + // post-increment + betype<T> operator++(int) requires std::integral<T> + { + betype<T> tmp(*this); + m_value = SwapEndian(T(value() + 1)); + return tmp; + } + + // pre-decrement betype<T>& operator--() requires std::integral<T> { m_value = SwapEndian(T(value() - 1)); return *this; } + + // post-decrement + betype<T> operator--(int) requires std::integral<T> + { + betype<T> tmp(*this); + m_value = SwapEndian(T(value() - 1)); + return tmp; + } + private: //T m_value{}; // before 1.26.2 T m_value; From f52970c822b7f671f6f9a80e828bf53152feb783 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 13 Aug 2024 04:47:43 +0200 Subject: [PATCH 234/314] Vulkan: Allow RGBA16F texture format with SRGB bit --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 09515993..81b0b0f1 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2212,6 +2212,7 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD formatInfoOut->decoder = TextureDecoder_R32_G32_B32_A32_UINT::getInstance(); break; case Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT: + case Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT | Latte::E_GX2SURFFMT::FMT_BIT_SRGB: // Seen in Sonic Transformed level Starry Speedway. SRGB should just be ignored for native float formats? formatInfoOut->vkImageFormat = VK_FORMAT_R16G16B16A16_SFLOAT; formatInfoOut->decoder = TextureDecoder_R16_G16_B16_A16_FLOAT::getInstance(); break; From e551f8f5245f9e94f677094d56e29b11870cd3f4 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Tue, 13 Aug 2024 05:57:51 +0200 Subject: [PATCH 235/314] Fix clang compile error --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 81b0b0f1..fb54a803 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2200,6 +2200,8 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD else { formatInfoOut->vkImageAspect = VK_IMAGE_ASPECT_COLOR_BIT; + if(format == (Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT | Latte::E_GX2SURFFMT::FMT_BIT_SRGB)) // Seen in Sonic Transformed level Starry Speedway. SRGB should just be ignored for native float formats? + format = Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT; switch (format) { // RGBA formats @@ -2212,7 +2214,6 @@ void VulkanRenderer::GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isD formatInfoOut->decoder = TextureDecoder_R32_G32_B32_A32_UINT::getInstance(); break; case Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT: - case Latte::E_GX2SURFFMT::R16_G16_B16_A16_FLOAT | Latte::E_GX2SURFFMT::FMT_BIT_SRGB: // Seen in Sonic Transformed level Starry Speedway. SRGB should just be ignored for native float formats? formatInfoOut->vkImageFormat = VK_FORMAT_R16G16B16A16_SFLOAT; formatInfoOut->decoder = TextureDecoder_R16_G16_B16_A16_FLOAT::getInstance(); break; From a6d8c0fb9f139817b90d82775e36a4f3d1a4ce76 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:48:13 +0200 Subject: [PATCH 236/314] CI: Fix macOS build (#1291) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 015ef367..9fb775e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -225,7 +225,7 @@ jobs: run: | brew update brew install llvm@15 ninja nasm automake libtool - brew install cmake python3 ninja + brew install cmake ninja - name: "Build and install molten-vk" run: | From c49296acdc4acf3998249d8f67e8cbc984b9e276 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:53:04 +0300 Subject: [PATCH 237/314] Add support for iterating directories in graphics pack content folders. (#1288) --- src/Cafe/Filesystem/FST/fstUtil.h | 65 +++++++++++++++++++++-- src/Cafe/Filesystem/fsc.h | 2 +- src/Cafe/Filesystem/fscDeviceRedirect.cpp | 13 +++-- src/Cafe/GraphicPack/GraphicPack2.cpp | 2 +- 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/Cafe/Filesystem/FST/fstUtil.h b/src/Cafe/Filesystem/FST/fstUtil.h index 01283684..a432cc95 100644 --- a/src/Cafe/Filesystem/FST/fstUtil.h +++ b/src/Cafe/Filesystem/FST/fstUtil.h @@ -3,6 +3,8 @@ #include <boost/container/small_vector.hpp> +#include "../fsc.h" + // path parser and utility class for Wii U paths // optimized to be allocation-free for common path lengths class FSCPath @@ -119,9 +121,7 @@ public: template<typename F> class FSAFileTree { -public: - -private: + private: enum NODETYPE : uint8 { @@ -133,6 +133,7 @@ private: { std::string name; std::vector<node_t*> subnodes; + size_t fileSize; F* custom; NODETYPE type; }; @@ -179,13 +180,54 @@ private: return newNode; } + class DirectoryIterator : public FSCVirtualFile + { + public: + DirectoryIterator(node_t* node) + : m_node(node), m_subnodeIndex(0) + { + } + + sint32 fscGetType() override + { + return FSC_TYPE_DIRECTORY; + } + + bool fscDirNext(FSCDirEntry* dirEntry) override + { + if (m_subnodeIndex >= m_node->subnodes.size()) + return false; + + const node_t* subnode = m_node->subnodes[m_subnodeIndex]; + + strncpy(dirEntry->path, subnode->name.c_str(), sizeof(dirEntry->path) - 1); + dirEntry->path[sizeof(dirEntry->path) - 1] = '\0'; + dirEntry->isDirectory = subnode->type == FSAFileTree::NODETYPE_DIRECTORY; + dirEntry->isFile = subnode->type == FSAFileTree::NODETYPE_FILE; + dirEntry->fileSize = subnode->type == FSAFileTree::NODETYPE_FILE ? subnode->fileSize : 0; + + ++m_subnodeIndex; + return true; + } + + bool fscRewindDir() override + { + m_subnodeIndex = 0; + return true; + } + + private: + node_t* m_node; + size_t m_subnodeIndex; + }; + public: FSAFileTree() { rootNode.type = NODETYPE_DIRECTORY; } - bool addFile(std::string_view path, F* custom) + bool addFile(std::string_view path, size_t fileSize, F* custom) { FSCPath p(path); if (p.GetNodeCount() == 0) @@ -196,6 +238,7 @@ public: return false; // node already exists // add file node node_t* fileNode = newNode(directoryNode, NODETYPE_FILE, p.GetNodeName(p.GetNodeCount() - 1)); + fileNode->fileSize = fileSize; fileNode->custom = custom; return true; } @@ -214,6 +257,20 @@ public: return true; } + bool getDirectory(std::string_view path, FSCVirtualFile*& dirIterator) + { + FSCPath p(path); + if (p.GetNodeCount() == 0) + return false; + node_t* node = getByNodePath(p, p.GetNodeCount(), false); + if (node == nullptr) + return false; + if (node->type != NODETYPE_DIRECTORY) + return false; + dirIterator = new DirectoryIterator(node); + return true; + } + bool removeFile(std::string_view path) { FSCPath p(path); diff --git a/src/Cafe/Filesystem/fsc.h b/src/Cafe/Filesystem/fsc.h index a3df2af2..8b8ed5ef 100644 --- a/src/Cafe/Filesystem/fsc.h +++ b/src/Cafe/Filesystem/fsc.h @@ -212,4 +212,4 @@ bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTarg // redirect device void fscDeviceRedirect_map(); -void fscDeviceRedirect_add(std::string_view virtualSourcePath, const fs::path& targetFilePath, sint32 priority); +void fscDeviceRedirect_add(std::string_view virtualSourcePath, size_t fileSize, const fs::path& targetFilePath, sint32 priority); diff --git a/src/Cafe/Filesystem/fscDeviceRedirect.cpp b/src/Cafe/Filesystem/fscDeviceRedirect.cpp index d25bff86..9c62d37a 100644 --- a/src/Cafe/Filesystem/fscDeviceRedirect.cpp +++ b/src/Cafe/Filesystem/fscDeviceRedirect.cpp @@ -11,7 +11,7 @@ struct RedirectEntry FSAFileTree<RedirectEntry> redirectTree; -void fscDeviceRedirect_add(std::string_view virtualSourcePath, const fs::path& targetFilePath, sint32 priority) +void fscDeviceRedirect_add(std::string_view virtualSourcePath, size_t fileSize, const fs::path& targetFilePath, sint32 priority) { // check if source already has a redirection RedirectEntry* existingEntry; @@ -24,7 +24,7 @@ void fscDeviceRedirect_add(std::string_view virtualSourcePath, const fs::path& t delete existingEntry; } RedirectEntry* entry = new RedirectEntry(targetFilePath, priority); - redirectTree.addFile(virtualSourcePath, entry); + redirectTree.addFile(virtualSourcePath, fileSize, entry); } class fscDeviceTypeRedirect : public fscDeviceC @@ -32,8 +32,15 @@ class fscDeviceTypeRedirect : public fscDeviceC FSCVirtualFile* fscDeviceOpenByPath(std::string_view path, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override { RedirectEntry* redirectionEntry; - if (redirectTree.getFile(path, redirectionEntry)) + + if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE) && redirectTree.getFile(path, redirectionEntry)) return FSCVirtualFile_Host::OpenFile(redirectionEntry->dstPath, accessFlags, *fscStatus); + + FSCVirtualFile* dirIterator; + + if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR) && redirectTree.getDirectory(path, dirIterator)) + return dirIterator; + return nullptr; } diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 27d423b9..c54c31cb 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -830,7 +830,7 @@ void GraphicPack2::_iterateReplacedFiles(const fs::path& currentPath, bool isAOC { virtualMountPath = fs::path("vol/content/") / virtualMountPath; } - fscDeviceRedirect_add(virtualMountPath.generic_string(), it.path().generic_string(), m_fs_priority); + fscDeviceRedirect_add(virtualMountPath.generic_string(), it.file_size(), it.path().generic_string(), m_fs_priority); } } } From b0bab273e21f8f648de011688d96baf78e064526 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 15 Aug 2024 02:16:03 +0200 Subject: [PATCH 238/314] padscore: Simulate queue behaviour for KPADRead --- src/Cafe/OS/libs/padscore/padscore.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Cafe/OS/libs/padscore/padscore.cpp b/src/Cafe/OS/libs/padscore/padscore.cpp index 47f3bc4f..8ae4730d 100644 --- a/src/Cafe/OS/libs/padscore/padscore.cpp +++ b/src/Cafe/OS/libs/padscore/padscore.cpp @@ -12,6 +12,7 @@ enum class KPAD_ERROR : sint32 { NONE = 0, + NO_SAMPLE_DATA = -1, NO_CONTROLLER = -2, NOT_INITIALIZED = -5, }; @@ -106,6 +107,9 @@ void padscoreExport_WPADProbe(PPCInterpreter_t* hCPU) } else { + if(type) + *type = 253; + osLib_returnFromFunction(hCPU, WPAD_ERR_NO_CONTROLLER); } } @@ -420,9 +424,12 @@ void padscoreExport_KPADSetConnectCallback(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, old_callback.GetMPTR()); } +uint64 g_kpadLastRead[InputManager::kMaxWPADControllers] = {0}; bool g_kpadIsInited = true; + sint32 _KPADRead(uint32 channel, KPADStatus_t* samplingBufs, uint32 length, betype<KPAD_ERROR>* errResult) { + if (channel >= InputManager::kMaxWPADControllers) { debugBreakpoint(); @@ -446,6 +453,19 @@ sint32 _KPADRead(uint32 channel, KPADStatus_t* samplingBufs, uint32 length, bety return 0; } + // On console new input samples are only received every few ms and calling KPADRead(Ex) clears the internal queue regardless of length value + // thus calling KPADRead(Ex) again too soon on the same channel will result in no data being returned + // Games that depend on this: Affordable Space Adventures + uint64 currentTime = coreinit::OSGetTime(); + uint64 timeDif = currentTime - g_kpadLastRead[channel]; + if(length == 0 || timeDif < coreinit::EspressoTime::ConvertNsToTimerTicks(1000000)) + { + if (errResult) + *errResult = KPAD_ERROR::NO_SAMPLE_DATA; + return 0; + } + g_kpadLastRead[channel] = currentTime; + memset(samplingBufs, 0x00, sizeof(KPADStatus_t)); samplingBufs->wpadErr = WPAD_ERR_NONE; samplingBufs->data_format = controller->get_data_format(); From 2843da4479630e82d93ca0bb0c7e0c1748c86c48 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 15 Aug 2024 05:00:09 +0200 Subject: [PATCH 239/314] padscore: Invoke sampling callbacks every 5ms This fixes high input latency in games like Pokemon Rumble U which update input via the sampling callbacks --- src/Cafe/OS/libs/padscore/padscore.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cafe/OS/libs/padscore/padscore.cpp b/src/Cafe/OS/libs/padscore/padscore.cpp index 8ae4730d..a83711fe 100644 --- a/src/Cafe/OS/libs/padscore/padscore.cpp +++ b/src/Cafe/OS/libs/padscore/padscore.cpp @@ -746,7 +746,8 @@ namespace padscore // call sampling callback for (auto i = 0; i < InputManager::kMaxWPADControllers; ++i) { - if (g_padscore.controller_data[i].sampling_callback) { + if (g_padscore.controller_data[i].sampling_callback) + { if (const auto controller = instance.get_wpad_controller(i)) { cemuLog_log(LogType::InputAPI, "Calling WPADsamplingCallback({})", i); @@ -761,7 +762,7 @@ namespace padscore { OSCreateAlarm(&g_padscore.alarm); const uint64 start_tick = coreinit::coreinit_getOSTime(); - const uint64 period_tick = coreinit::EspressoTime::GetTimerClock(); // once a second + const uint64 period_tick = coreinit::EspressoTime::GetTimerClock() / 200; // every 5ms MPTR handler = PPCInterpreter_makeCallableExportDepr(TickFunction); OSSetPeriodicAlarm(&g_padscore.alarm, start_tick, period_tick, handler); } From 294a6de779ddf9c6294dafa603ad23a404052ec3 Mon Sep 17 00:00:00 2001 From: 20943204920434 <160030054+20943204920434@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:22:41 +0200 Subject: [PATCH 240/314] Update appimage.sh to support runtime libstdc++.so.6 loading (#1292) Add checkrt plugin in order to detect the right libstdc++.so.6 version to load. --- dist/linux/appimage.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/linux/appimage.sh b/dist/linux/appimage.sh index 7bfc4701..e9081521 100755 --- a/dist/linux/appimage.sh +++ b/dist/linux/appimage.sh @@ -10,6 +10,8 @@ curl -sSfL https://github.com"$(curl https://github.com/probonopd/go-appimage/re chmod a+x mkappimage.AppImage curl -sSfLO "https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh" chmod a+x linuxdeploy-plugin-gtk.sh +curl -sSfLO "https://github.com/darealshinji/linuxdeploy-plugin-checkrt/releases/download/continuous/linuxdeploy-plugin-checkrt.sh" +chmod a+x linuxdeploy-plugin-checkrt.sh if [[ ! -e /usr/lib/x86_64-linux-gnu ]]; then sed -i 's#lib\/x86_64-linux-gnu#lib64#g' linuxdeploy-plugin-gtk.sh @@ -39,7 +41,8 @@ export NO_STRIP=1 -d "${GITHUB_WORKSPACE}"/AppDir/info.cemu.Cemu.desktop \ -i "${GITHUB_WORKSPACE}"/AppDir/info.cemu.Cemu.png \ -e "${GITHUB_WORKSPACE}"/AppDir/usr/bin/Cemu \ - --plugin gtk + --plugin gtk \ + --plugin checkrt if ! GITVERSION="$(git rev-parse --short HEAD 2>/dev/null)"; then GITVERSION=experimental From 958137a301208141b1e62f6b2f5b3ce2f04335d6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 15 Aug 2024 18:26:58 +0200 Subject: [PATCH 241/314] vpad: Keep second channel empty if no extra GamePad is configured --- src/Cafe/OS/libs/padscore/padscore.cpp | 1 - src/Cafe/OS/libs/vpad/vpad.cpp | 24 +++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Cafe/OS/libs/padscore/padscore.cpp b/src/Cafe/OS/libs/padscore/padscore.cpp index a83711fe..0a577b97 100644 --- a/src/Cafe/OS/libs/padscore/padscore.cpp +++ b/src/Cafe/OS/libs/padscore/padscore.cpp @@ -494,7 +494,6 @@ void padscoreExport_KPADReadEx(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, samplesRead); } -bool debugUseDRC1 = true; void padscoreExport_KPADRead(PPCInterpreter_t* hCPU) { ppcDefineParamU32(channel, 0); diff --git a/src/Cafe/OS/libs/vpad/vpad.cpp b/src/Cafe/OS/libs/vpad/vpad.cpp index 94bb0ca2..ded4304d 100644 --- a/src/Cafe/OS/libs/vpad/vpad.cpp +++ b/src/Cafe/OS/libs/vpad/vpad.cpp @@ -50,7 +50,6 @@ extern bool isLaunchTypeELF; -bool debugUseDRC = true; VPADDir g_vpadGyroDirOverwrite[VPAD_MAX_CONTROLLERS] = { {{1.0f,0.0f,0.0f}, {0.0f,1.0f,0.0f}, {0.0f, 0.0f, 0.1f}}, @@ -240,19 +239,20 @@ namespace vpad status->tpProcessed2.validity = VPAD_TP_VALIDITY_INVALID_XY; const auto controller = InputManager::instance().get_vpad_controller(channel); - if (!controller || debugUseDRC == false) + if (!controller) { - // no controller + // most games expect the Wii U GamePad to be connected, so even if the user has not set it up we should still return empty samples for channel 0 + if(channel != 0) + { + if (error) + *error = VPAD_READ_ERR_NO_CONTROLLER; + if (length > 0) + status->vpadErr = -1; + return 0; + } if (error) - *error = VPAD_READ_ERR_NONE; // VPAD_READ_ERR_NO_DATA; // VPAD_READ_ERR_NO_CONTROLLER; - + *error = VPAD_READ_ERR_NONE; return 1; - //osLib_returnFromFunction(hCPU, 1); return; - } - - if (channel != 0) - { - debugBreakpoint(); } const bool vpadDelayEnabled = ActiveSettings::VPADDelayEnabled(); @@ -274,9 +274,7 @@ namespace vpad // not ready yet if (error) *error = VPAD_READ_ERR_NONE; - return 0; - //osLib_returnFromFunction(hCPU, 0); return; } else if (dif <= ESPRESSO_TIMER_CLOCK) { From 9e53c1ce2760ac6a33d52f8813d79402b5183203 Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Thu, 22 Aug 2024 05:17:01 +0000 Subject: [PATCH 242/314] Update translation files --- bin/resources/es/cemu.mo | Bin 65733 -> 68744 bytes bin/resources/ko/cemu.mo | Bin 69784 -> 70573 bytes bin/resources/ru/cemu.mo | Bin 89284 -> 90752 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/es/cemu.mo b/bin/resources/es/cemu.mo index 856049de037de70de90a2868e6da991fe25d1235..a43d4a1dc46c8db327cd91f2ae906dccb734169b 100644 GIT binary patch delta 20556 zcma*u2Y6J~qW1AUAq7Gw^g2jyk=~?8?=3VD1SZLl3?!L2GXVnPhz&(ibSMIXD2gaj zM?i`qf(>a01VuqX5Jg2rKtx6F|J{4RiRYg0x!-=C<!`OE*Is??J>lH@?#$Rn7R83Y zC=)y1;woCmvZ`XJqGgqgwXA(jm1|jryI59nEP}<b0v5&ESOl9I+Z($Z2cpW|fmJXa zOX7W40_S3)WreNh%#Bx34QxZ&x8BDxxDN~CmslFV#W?&OE1}iZvg$%*EQMXLET$MU zur}#?%>Cz49oUHRv~TSqLQkv@FaeLCM)o<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`p& zjlA_$-C`x#&D<@Z#grFY-7TO0NHzDK(EKqTcT%zZ_<HX2@M1PL{(CRS^wdsdO)1dq znZv<-8LoT&Yq{Lql4hCQn96@_vHVR5?x2uf!H*%LqE(_0X*06AG;iAf1mK_3sW;F* zV#6CExapMH8(bJm<30WzFIUgo+1xE16?`k`W%AOEg;}sKJnv+4x1Mhoci;?t*adok z!V<eUxo#fynkEACci%TAH2AT_Hx}M<gqZz6sQ;I*EhZ*r2H6@OZJYu!+_Wquz1x^N z8=bsXE!;YJb6dD|^UJn$i@BkijjFBObqP1tB^91?b60x`m(u~Sy#36<T*9>{7z0+@ zjbQD}%OB__^j*M9dU@gEMmLw=UcCYIkY=gHGikhW3s)5!Fgr-`n9Be)q~P*3VYm@u zf4^_bhZe4En3r72jm}GL<yHwL>i)#z<--bB#)s$a>+jy~BW8zqvcI1z__-4tC2v>V zhXoV-9I>Avyrov$96B%U|0Ae8Jl_Nh*3bbD;W5jP0PfZj*IUSZN(|C$nhzQFz=4K0 zd*-1PKi&p*-pwNiN6P4SY9SpAzA>56zppYMPx1MIR&H2me&0LY%aM7$-fq!`H*Xqz z-yC8$vy*vrR?Uswek0s_{8>k$@;mo-dlk#yHOTE<^saRbJh%=N=6{couT{bK>%8D- zf^Rdk8~BD)u-#1k-!nb0hFhVU**-V#%f`9!7U5N_&v=(ftK&xXVZK<y_Op(6>MiYV ztO>o%c(pTwCZfD=8SNfEP?z5F*=W9&<+bYRR*V0~eA|)f(|5OBsVuMH7SW^ZX`lbc z2sgy_H@#Fo@3RJOg}nDhxygBnqur$Hx2*FfO&y}SS4*7R>-&&Dd0U12Qe)iQkpBnf C7n9Kd From 573c98b2f80826c2bf0a9994c4e7d1f0950b4dc7 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 23 Aug 2024 19:26:33 +0200 Subject: [PATCH 243/314] GfxPack: Workaround for invisible detail panel Fixes #1307 There is probably a better way to calculate the maximum width. But this suffices for now as a workaround --- src/gui/GraphicPacksWindow2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/GraphicPacksWindow2.cpp b/src/gui/GraphicPacksWindow2.cpp index 29f4b865..c49cbeae 100644 --- a/src/gui/GraphicPacksWindow2.cpp +++ b/src/gui/GraphicPacksWindow2.cpp @@ -458,10 +458,10 @@ void GraphicPacksWindow2::OnTreeSelectionChanged(wxTreeEvent& event) m_shown_graphic_pack = gp; - m_graphic_pack_name->Wrap(m_graphic_pack_name->GetParent()->GetClientSize().GetWidth() - 10); + m_graphic_pack_name->Wrap(m_graphic_pack_name->GetParent()->GetClientSize().GetWidth() - 20); m_graphic_pack_name->GetGrandParent()->Layout(); - m_graphic_pack_description->Wrap(m_graphic_pack_description->GetParent()->GetClientSize().GetWidth() - 10); + m_graphic_pack_description->Wrap(m_graphic_pack_description->GetParent()->GetClientSize().GetWidth() - 20); m_graphic_pack_description->GetGrandParent()->Layout(); m_right_panel->FitInside(); From dc9d99b03b38f3cf427714ad1ebb4d6d29f645fa Mon Sep 17 00:00:00 2001 From: bl <147349656+squelchiee@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:03:03 -0300 Subject: [PATCH 244/314] nn_fp: Implement GetMyComment and UpdateCommentAsync (#1173) --- src/Cafe/IOSU/legacy/iosu_fpd.cpp | 55 ++++++++++++++++++++++++++----- src/Cafe/IOSU/legacy/iosu_fpd.h | 2 ++ src/Cafe/OS/libs/nn_fp/nn_fp.cpp | 33 +++++++++++++++++++ src/Cemu/nex/nexFriends.cpp | 25 +++++++++++++- src/Cemu/nex/nexFriends.h | 7 +++- 5 files changed, 111 insertions(+), 11 deletions(-) diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index aca1a332..28d248ae 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -511,6 +511,8 @@ namespace iosu return CallHandler_GetBlackList(fpdClient, vecIn, numVecIn, vecOut, numVecOut); case FPD_REQUEST_ID::GetFriendListEx: return CallHandler_GetFriendListEx(fpdClient, vecIn, numVecIn, vecOut, numVecOut); + case FPD_REQUEST_ID::UpdateCommentAsync: + return CallHandler_UpdateCommentAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); case FPD_REQUEST_ID::UpdatePreferenceAsync: return CallHandler_UpdatePreferenceAsync(fpdClient, vecIn, numVecIn, vecOut, numVecOut); case FPD_REQUEST_ID::AddFriendRequestByPlayRecordAsync: @@ -719,18 +721,23 @@ namespace iosu nnResult CallHandler_GetMyComment(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) { - static constexpr uint32 MY_COMMENT_LENGTH = 0x12; // are comments utf16? Buffer length is 0x24 if(numVecIn != 0 || numVecOut != 1) return FPResult_InvalidIPCParam; - if(vecOut->size != MY_COMMENT_LENGTH*sizeof(uint16be)) - { - cemuLog_log(LogType::Force, "GetMyComment: Unexpected output size"); - return FPResult_InvalidIPCParam; - } std::basic_string<uint16be> myComment; - myComment.resize(MY_COMMENT_LENGTH); - memcpy(vecOut->basePhys.GetPtr(), myComment.data(), MY_COMMENT_LENGTH*sizeof(uint16be)); - return 0; + if(g_fpd.nexFriendSession) + { + if(vecOut->size != MY_COMMENT_LENGTH * sizeof(uint16be)) + { + cemuLog_log(LogType::Force, "GetMyComment: Unexpected output size"); + return FPResult_InvalidIPCParam; + } + nexComment myNexComment; + g_fpd.nexFriendSession->getMyComment(myNexComment); + myComment = StringHelpers::FromUtf8(myNexComment.commentString); + } + myComment.insert(0, 1, '\0'); + memcpy(vecOut->basePhys.GetPtr(), myComment.c_str(), MY_COMMENT_LENGTH * sizeof(uint16be)); + return FPResult_Ok; } nnResult CallHandler_GetMyPreference(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) @@ -1143,6 +1150,36 @@ namespace iosu return FPResult_Ok; } + nnResult CallHandler_UpdateCommentAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) + { + std::unique_lock _l(g_fpd.mtxFriendSession); + if (numVecIn != 1 || numVecOut != 0) + return FPResult_InvalidIPCParam; + if (!g_fpd.nexFriendSession) + return FPResult_RequestFailed; + uint32 messageLength = vecIn[0].size / sizeof(uint16be); + DeclareInputPtr(newComment, uint16be, messageLength, 0); + if (messageLength == 0 || newComment[messageLength-1] != 0) + { + cemuLog_log(LogType::Force, "UpdateCommentAsync: Message must contain at least a null-termination character"); + return FPResult_InvalidIPCParam; + } + IPCCommandBody* cmd = ServiceCallDelayCurrentResponse(); + + auto utf8_comment = StringHelpers::ToUtf8(newComment, messageLength); + nexComment temporaryComment; + temporaryComment.ukn0 = 0; + temporaryComment.commentString = utf8_comment; + temporaryComment.ukn1 = 0; + + g_fpd.nexFriendSession->updateCommentAsync(temporaryComment, [cmd](NexFriends::RpcErrorCode result) { + if (result != NexFriends::ERR_NONE) + return ServiceCallAsyncRespond(cmd, FPResult_RequestFailed); + ServiceCallAsyncRespond(cmd, FPResult_Ok); + }); + return FPResult_Ok; + } + nnResult CallHandler_UpdatePreferenceAsync(FPDClient* fpdClient, IPCIoctlVector* vecIn, uint32 numVecIn, IPCIoctlVector* vecOut, uint32 numVecOut) { std::unique_lock _l(g_fpd.mtxFriendSession); diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.h b/src/Cafe/IOSU/legacy/iosu_fpd.h index 0a6f0885..b1c30765 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.h +++ b/src/Cafe/IOSU/legacy/iosu_fpd.h @@ -212,6 +212,7 @@ namespace iosu static const int RELATIONSHIP_FRIEND = 3; static const int GAMEMODE_MAX_MESSAGE_LENGTH = 0x80; // limit includes null-terminator character, so only 0x7F actual characters can be used + static const int MY_COMMENT_LENGTH = 0x12; enum class FPD_REQUEST_ID { @@ -245,6 +246,7 @@ namespace iosu CheckSettingStatusAsync = 0x7596, GetFriendListEx = 0x75F9, GetFriendRequestListEx = 0x76C1, + UpdateCommentAsync = 0x7726, UpdatePreferenceAsync = 0x7727, RemoveFriendAsync = 0x7789, DeleteFriendFlagsAsync = 0x778A, diff --git a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp index fc757ea9..86ca4708 100644 --- a/src/Cafe/OS/libs/nn_fp/nn_fp.cpp +++ b/src/Cafe/OS/libs/nn_fp/nn_fp.cpp @@ -464,6 +464,14 @@ namespace nn return ipcCtx->Submit(std::move(ipcCtx)); } + nnResult GetMyPlayingGame(iosu::fpd::GameKey* myPlayingGame) + { + FP_API_BASE(); + auto ipcCtx = std::make_unique<FPIpcContext>(iosu::fpd::FPD_REQUEST_ID::GetMyPlayingGame); + ipcCtx->AddOutput(myPlayingGame, sizeof(iosu::fpd::GameKey)); + return ipcCtx->Submit(std::move(ipcCtx)); + } + nnResult GetMyPreference(iosu::fpd::FPDPreference* myPreference) { FP_API_BASE(); @@ -472,6 +480,14 @@ namespace nn return ipcCtx->Submit(std::move(ipcCtx)); } + nnResult GetMyComment(uint16be* myComment) + { + FP_API_BASE(); + auto ipcCtx = std::make_unique<FPIpcContext>(iosu::fpd::FPD_REQUEST_ID::GetMyComment); + ipcCtx->AddOutput(myComment, iosu::fpd::MY_COMMENT_LENGTH * sizeof(uint16be)); + return ipcCtx->Submit(std::move(ipcCtx)); + } + nnResult GetMyMii(FFLData_t* fflData) { FP_API_BASE(); @@ -607,6 +623,20 @@ namespace nn return resultBuf != 0 ? 1 : 0; } + nnResult UpdateCommentAsync(uint16be* newComment, void* funcPtr, void* customParam) + { + FP_API_BASE(); + auto ipcCtx = std::make_unique<FPIpcContext>(iosu::fpd::FPD_REQUEST_ID::UpdateCommentAsync); + uint32 commentLen = CafeStringHelpers::Length(newComment, iosu::fpd::MY_COMMENT_LENGTH-1); + if (commentLen >= iosu::fpd::MY_COMMENT_LENGTH-1) + { + cemuLog_log(LogType::Force, "UpdateCommentAsync: message too long"); + return FPResult_InvalidIPCParam; + } + ipcCtx->AddInput(newComment, sizeof(uint16be) * commentLen + 2); + return ipcCtx->SubmitAsync(std::move(ipcCtx), funcPtr, customParam); + } + nnResult UpdatePreferenceAsync(iosu::fpd::FPDPreference* newPreference, void* funcPtr, void* customParam) { FP_API_BASE(); @@ -763,7 +793,9 @@ namespace nn cafeExportRegisterFunc(GetMyAccountId, "nn_fp", "GetMyAccountId__Q2_2nn2fpFPc", LogType::NN_FP); cafeExportRegisterFunc(GetMyScreenName, "nn_fp", "GetMyScreenName__Q2_2nn2fpFPw", LogType::NN_FP); cafeExportRegisterFunc(GetMyMii, "nn_fp", "GetMyMii__Q2_2nn2fpFP12FFLStoreData", LogType::NN_FP); + cafeExportRegisterFunc(GetMyPlayingGame, "nn_fp", "GetMyPlayingGame__Q2_2nn2fpFPQ3_2nn2fp7GameKey", LogType::NN_FP); cafeExportRegisterFunc(GetMyPreference, "nn_fp", "GetMyPreference__Q2_2nn2fpFPQ3_2nn2fp10Preference", LogType::NN_FP); + cafeExportRegisterFunc(GetMyComment, "nn_fp", "GetMyComment__Q2_2nn2fpFPQ3_2nn2fp7Comment", LogType::NN_FP); cafeExportRegisterFunc(GetFriendAccountId, "nn_fp", "GetFriendAccountId__Q2_2nn2fpFPA17_cPCUiUi", LogType::NN_FP); cafeExportRegisterFunc(GetFriendScreenName, "nn_fp", "GetFriendScreenName__Q2_2nn2fpFPA11_wPCUiUibPUc", LogType::NN_FP); @@ -774,6 +806,7 @@ namespace nn cafeExportRegisterFunc(CheckSettingStatusAsync, "nn_fp", "CheckSettingStatusAsync__Q2_2nn2fpFPUcPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); cafeExportRegisterFunc(IsPreferenceValid, "nn_fp", "IsPreferenceValid__Q2_2nn2fpFv", LogType::NN_FP); + cafeExportRegisterFunc(UpdateCommentAsync, "nn_fp", "UpdateCommentAsync__Q2_2nn2fpFPCwPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); cafeExportRegisterFunc(UpdatePreferenceAsync, "nn_fp", "UpdatePreferenceAsync__Q2_2nn2fpFPCQ3_2nn2fp10PreferencePFQ2_2nn6ResultPv_vPv", LogType::NN_FP); cafeExportRegisterFunc(GetRequestBlockSettingAsync, "nn_fp", "GetRequestBlockSettingAsync__Q2_2nn2fpFPUcPCUiUiPFQ2_2nn6ResultPv_vPv", LogType::NN_FP); diff --git a/src/Cemu/nex/nexFriends.cpp b/src/Cemu/nex/nexFriends.cpp index 927418ca..36ba4a53 100644 --- a/src/Cemu/nex/nexFriends.cpp +++ b/src/Cemu/nex/nexFriends.cpp @@ -277,7 +277,8 @@ void NexFriends::handleResponse_getAllInformation(nexServiceResponse_t* response } NexFriends* session = (NexFriends*)nexFriends; session->myPreference = nexPrincipalPreference(&response->data); - nexComment comment(&response->data); + auto comment = nexComment(&response->data); + session->myComment = comment; if (response->data.hasReadOutOfBounds()) return; // acquire lock on lists @@ -391,6 +392,28 @@ void NexFriends::getMyPreference(nexPrincipalPreference& preference) preference = myPreference; } +bool NexFriends::updateCommentAsync(nexComment newComment, std::function<void(RpcErrorCode)> cb) +{ + uint8 tempNexBufferArray[1024]; + nexPacketBuffer packetBuffer(tempNexBufferArray, sizeof(tempNexBufferArray), true); + newComment.writeData(&packetBuffer); + nexCon->callMethod( + NEX_PROTOCOL_FRIENDS_WIIU, 15, &packetBuffer, [this, cb, newComment](nexServiceResponse_t* response) -> void { + if (!response->isSuccessful) + return cb(NexFriends::ERR_RPC_FAILED); + this->myComment = newComment; + return cb(NexFriends::ERR_NONE); + }, + true); + // TEST + return true; +} + +void NexFriends::getMyComment(nexComment& comment) +{ + comment = myComment; +} + bool NexFriends::addProvisionalFriendByPidGuessed(uint32 principalId) { uint8 tempNexBufferArray[512]; diff --git a/src/Cemu/nex/nexFriends.h b/src/Cemu/nex/nexFriends.h index 1077b0d5..05cc433f 100644 --- a/src/Cemu/nex/nexFriends.h +++ b/src/Cemu/nex/nexFriends.h @@ -297,7 +297,9 @@ public: void writeData(nexPacketBuffer* pb) const override { - cemu_assert_unimplemented(); + pb->writeU8(ukn0); + pb->writeString(commentString.c_str()); + pb->writeU64(ukn1); } void readData(nexPacketBuffer* pb) override @@ -554,6 +556,7 @@ public: bool getFriendRequestByMessageId(nexFriendRequest& friendRequestData, bool* isIncoming, uint64 messageId); bool isOnline(); void getMyPreference(nexPrincipalPreference& preference); + void getMyComment(nexComment& comment); // asynchronous API (data has to be requested) bool addProvisionalFriend(char* name, std::function<void(RpcErrorCode)> cb); @@ -565,6 +568,7 @@ public: void acceptFriendRequest(uint64 messageId, std::function<void(RpcErrorCode)> cb); void deleteFriendRequest(uint64 messageId, std::function<void(RpcErrorCode)> cb); // rejecting incoming friend request (differs from blocking friend requests) bool updatePreferencesAsync(const nexPrincipalPreference newPreferences, std::function<void(RpcErrorCode)> cb); + bool updateCommentAsync(const nexComment newComment, std::function<void(RpcErrorCode)> cb); void updateMyPresence(nexPresenceV2& myPresence); void setNotificationHandler(void(*notificationHandler)(NOTIFICATION_TYPE notificationType, uint32 pid)); @@ -619,6 +623,7 @@ private: // local friend state nexPresenceV2 myPresence; nexPrincipalPreference myPreference; + nexComment myComment; std::recursive_mutex mtx_lists; std::vector<nexFriend> list_friends; From d7f39aab054a715e7b0481407298cbd654212fb9 Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Mon, 26 Aug 2024 09:16:11 +0000 Subject: [PATCH 245/314] Update translation files --- bin/resources/hu/cemu.mo | Bin 71267 -> 72404 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/hu/cemu.mo b/bin/resources/hu/cemu.mo index dd3d2fbc74157e457fac7fefe3356bdbfbbe9e11..51b00d083cc320a55615d50774d60c74f71108d5 100644 GIT binary patch delta 22802 zcmcKB2Xs``;_vY@Nob*Wkap-L5PC--bPx~;sMv6lOp+m!nUI-KA~Mo07DQlFuu()n z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E6w|wK+Mj-KarlNSl-`n#{q{$G>w?fX7^HasCby<hg83 zbPneZ$GX#Q%$^k|a~|Z&pYKxr<tm*Qgtw+;{xt*U+~M1?zsoFCo_=8XP1xdhtC4J1 z)(l@pQWuR_XYI9fV2<VJ0Z3nT25N_!Hd&NHSIQ=b!*PAgrp9rOTjCS=+gh+V!WR(R zRFkwRtCAx#ZqvMKj;CYGrkWEqoN%R9h`;1<kTFIx8r5z8%&~2XBRRSeeY1J7ldhdA zCS6k%J!7Vrr7=ebJ3Q4?=jCI?!yL0VUcT+!Ua!Y(e^J>#S5^4E%J^p-UQdrDt!p_p hFPU81F>J}U+K!YO_G$gkY*+zbwrf-WI*$2{{|9Kk&?*1` From 1234e2c11808a97c76381f147e564d74f6ffbbd1 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:43:38 +0200 Subject: [PATCH 246/314] Preparations for 2.1 (#1306) --- .github/getversion.cpp | 9 -- .github/workflows/build.yml | 66 ++++--------- .github/workflows/build_check.yml | 3 - .../workflows/deploy_experimental_release.yml | 93 ++++++++++++++++--- .../workflows/determine_release_version.yml | 74 +++++++++++++++ CMakeLists.txt | 27 +++--- src/Cafe/HW/Latte/Core/LatteShader.cpp | 2 +- src/Cafe/HW/Latte/Renderer/RendererShader.cpp | 6 +- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 4 +- .../OS/libs/coreinit/coreinit_Spinlock.cpp | 2 +- src/Common/version.h | 29 ++---- src/config/CemuConfig.cpp | 2 + src/config/CemuConfig.h | 3 +- src/config/LaunchSettings.cpp | 6 +- src/gui/CemuUpdateWindow.cpp | 4 +- src/gui/DownloadGraphicPacksWindow.cpp | 2 +- src/gui/GeneralSettings2.cpp | 56 ++++++++--- src/gui/GeneralSettings2.h | 2 +- src/resource/cemu.rc | 6 +- 19 files changed, 261 insertions(+), 135 deletions(-) delete mode 100644 .github/getversion.cpp create mode 100644 .github/workflows/determine_release_version.yml diff --git a/.github/getversion.cpp b/.github/getversion.cpp deleted file mode 100644 index 469a796e..00000000 --- a/.github/getversion.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdio.h> -#include "./../src/Common/version.h" - -// output current Cemu version for CI workflow. Do not modify -int main() -{ - printf("%d.%d", EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR); - return 0; -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9fb775e2..dd28ceb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,10 @@ name: Build Cemu on: workflow_call: inputs: - deploymode: + next_version_major: required: false type: string - experimentalversion: + next_version_minor: required: false type: string @@ -24,25 +24,17 @@ jobs: submodules: "recursive" fetch-depth: 0 - - name: Setup release mode parameters (for deploy) - if: ${{ inputs.deploymode == 'release' }} + - name: Setup release mode parameters run: | echo "BUILD_MODE=release" >> $GITHUB_ENV echo "BUILD_FLAGS=" >> $GITHUB_ENV echo "Build mode is release" - - name: Setup debug mode parameters (for continous build) - if: ${{ inputs.deploymode != 'release' }} + - name: Setup build flags for version + if: ${{ inputs.next_version_major != '' }} run: | - echo "BUILD_MODE=debug" >> $GITHUB_ENV - echo "BUILD_FLAGS=" >> $GITHUB_ENV - echo "Build mode is debug" - - - name: Setup version for experimental - if: ${{ inputs.experimentalversion != '' }} - run: | - echo "[INFO] Experimental version ${{ inputs.experimentalversion }}" - echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEXPERIMENTAL_VERSION=${{ inputs.experimentalversion }}" >> $GITHUB_ENV + echo "[INFO] Version ${{ inputs.next_version_major }}.${{ inputs.next_version_minor }}" + echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEMULATOR_VERSION_MAJOR=${{ inputs.next_version_major }} -DEMULATOR_VERSION_MINOR=${{ inputs.next_version_minor }}" >> $GITHUB_ENV - name: "Install system dependencies" run: | @@ -81,12 +73,10 @@ jobs: cmake --build build - name: Prepare artifact - if: ${{ inputs.deploymode == 'release' }} run: mv bin/Cemu_release bin/Cemu - name: Upload artifact uses: actions/upload-artifact@v4 - if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-linux-x64 path: ./bin/Cemu @@ -128,24 +118,17 @@ jobs: with: submodules: "recursive" - - name: Setup release mode parameters (for deploy) - if: ${{ inputs.deploymode == 'release' }} + - name: Setup release mode parameters run: | echo "BUILD_MODE=release" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append echo "BUILD_FLAGS=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append echo "Build mode is release" - - - name: Setup debug mode parameters (for continous build) - if: ${{ inputs.deploymode != 'release' }} + + - name: Setup build flags for version + if: ${{ inputs.next_version_major != '' }} run: | - echo "BUILD_MODE=debug" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append - echo "BUILD_FLAGS=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append - echo "Build mode is debug" - - name: Setup version for experimental - if: ${{ inputs.experimentalversion != '' }} - run: | - echo "[INFO] Experimental version ${{ inputs.experimentalversion }}" - echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEXPERIMENTAL_VERSION=${{ inputs.experimentalversion }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + echo "[INFO] Version ${{ inputs.next_version_major }}.${{ inputs.next_version_minor }}" + echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEMULATOR_VERSION_MAJOR=${{ inputs.next_version_major }} -DEMULATOR_VERSION_MINOR=${{ inputs.next_version_minor }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append - name: "Setup cmake" uses: jwlawson/actions-setup-cmake@v2 @@ -184,12 +167,10 @@ jobs: cmake --build . --config ${{ env.BUILD_MODE }} - name: Prepare artifact - if: ${{ inputs.deploymode == 'release' }} run: Rename-Item bin/Cemu_release.exe Cemu.exe - name: Upload artifact uses: actions/upload-artifact@v4 - if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-windows-x64 path: ./bin/Cemu.exe @@ -202,24 +183,17 @@ jobs: with: submodules: "recursive" - - name: Setup release mode parameters (for deploy) - if: ${{ inputs.deploymode == 'release' }} + - name: Setup release mode parameters run: | echo "BUILD_MODE=release" >> $GITHUB_ENV echo "BUILD_FLAGS=" >> $GITHUB_ENV echo "Build mode is release" - - name: Setup debug mode parameters (for continous build) - if: ${{ inputs.deploymode != 'release' }} + + - name: Setup build flags for version + if: ${{ inputs.next_version_major != '' }} run: | - echo "BUILD_MODE=debug" >> $GITHUB_ENV - echo "BUILD_FLAGS=" >> $GITHUB_ENV - echo "Build mode is debug" - - - name: Setup version for experimental - if: ${{ inputs.experimentalversion != '' }} - run: | - echo "[INFO] Experimental version ${{ inputs.experimentalversion }}" - echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEXPERIMENTAL_VERSION=${{ inputs.experimentalversion }}" >> $GITHUB_ENV + echo "[INFO] Version ${{ inputs.next_version_major }}.${{ inputs.next_version_minor }}" + echo "BUILD_FLAGS=${{ env.BUILD_FLAGS }} -DEMULATOR_VERSION_MAJOR=${{ inputs.next_version_major }} -DEMULATOR_VERSION_MINOR=${{ inputs.next_version_minor }}" >> $GITHUB_ENV - name: "Install system dependencies" run: | @@ -275,7 +249,6 @@ jobs: cmake --build build - name: Prepare artifact - if: ${{ inputs.deploymode == 'release' }} run: | mkdir bin/Cemu_app mv bin/Cemu_release.app bin/Cemu_app/Cemu.app @@ -289,7 +262,6 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 - if: ${{ inputs.deploymode == 'release' }} with: name: cemu-bin-macos-x64 path: ./bin/Cemu.dmg diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 49ef79e9..5d24b0c6 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -16,6 +16,3 @@ on: jobs: build: uses: ./.github/workflows/build.yml - with: - deploymode: release - experimentalversion: 999999 diff --git a/.github/workflows/deploy_experimental_release.yml b/.github/workflows/deploy_experimental_release.yml index a8c5ec53..97e0c69e 100644 --- a/.github/workflows/deploy_experimental_release.yml +++ b/.github/workflows/deploy_experimental_release.yml @@ -1,20 +1,83 @@ name: Deploy experimental release on: workflow_dispatch: + inputs: + changelog0: + description: 'Enter the changelog lines for this release. Each line is a feature / bullet point. Do not use dash.' + required: true + type: string + changelog1: + description: 'Feature 2' + required: false + type: string + changelog2: + description: 'Feature 3' + required: false + type: string + changelog3: + description: 'Feature 4' + required: false + type: string + changelog4: + description: 'Feature 5' + required: false + type: string + changelog5: + description: 'Feature 6' + required: false + type: string + changelog6: + description: 'Feature 7' + required: false + type: string + changelog7: + description: 'Feature 8' + required: false + type: string + changelog8: + description: 'Feature 9' + required: false + type: string + changelog9: + description: 'Feature 10' + required: false + type: string jobs: + calculate-version: + name: Calculate Version + uses: ./.github/workflows/determine_release_version.yml call-release-build: uses: ./.github/workflows/build.yml + needs: calculate-version with: - deploymode: release - experimentalversion: ${{ github.run_number }} + next_version_major: ${{ needs.calculate-version.outputs.next_version_major }} + next_version_minor: ${{ needs.calculate-version.outputs.next_version_minor }} deploy: name: Deploy experimental release runs-on: ubuntu-22.04 - needs: call-release-build + needs: [call-release-build, calculate-version] steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate changelog + id: generate_changelog + run: | + CHANGELOG="" + if [ -n "${{ github.event.inputs.changelog0 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog0 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog1 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog1 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog2 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog2 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog3 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog3 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog4 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog4 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog5 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog5 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog6 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog6 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog7 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog7 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog8 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog8 }}\n"; fi + if [ -n "${{ github.event.inputs.changelog9 }}" ]; then CHANGELOG="$CHANGELOG- ${{ github.event.inputs.changelog9 }}\n"; fi + echo -e "$CHANGELOG" + echo "RELEASE_BODY=$CHANGELOG" >> $GITHUB_ENV - uses: actions/download-artifact@v4 with: name: cemu-bin-linux-x64 @@ -40,15 +103,13 @@ jobs: mkdir upload sudo apt install zip - - name: Get version + - name: Set version dependent vars run: | - echo "Experimental version: ${{ github.run_number }}" - ls - gcc -o getversion .github/getversion.cpp - ./getversion - echo "Cemu CI version: $(./getversion)" - echo "CEMU_FOLDER_NAME=Cemu_$(./getversion)-${{ github.run_number }}" >> $GITHUB_ENV - echo "CEMU_VERSION=$(./getversion)-${{ github.run_number }}" >> $GITHUB_ENV + echo "Version: ${{ needs.calculate-version.outputs.next_version }}" + echo "CEMU_FOLDER_NAME=Cemu_${{ needs.calculate-version.outputs.next_version }}" + echo "CEMU_VERSION=${{ needs.calculate-version.outputs.next_version }}" + echo "CEMU_FOLDER_NAME=Cemu_${{ needs.calculate-version.outputs.next_version }}" >> $GITHUB_ENV + echo "CEMU_VERSION=${{ needs.calculate-version.outputs.next_version }}" >> $GITHUB_ENV - name: Create release from windows-bin run: | @@ -83,4 +144,8 @@ jobs: wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz tar xvzf ghr.tar.gz; rm ghr.tar.gz echo "[INFO] Release tag: v${{ env.CEMU_VERSION }}" - ghr_v0.15.0_linux_amd64/ghr -prerelease -t ${{ secrets.GITHUB_TOKEN }} -n "Cemu ${{ env.CEMU_VERSION }} (Experimental)" -b "Cemu experimental release" "v${{ env.CEMU_VERSION }}" ./upload + CHANGELOG_UNESCAPED=$(printf "%s\n" "${{ env.RELEASE_BODY }}" | sed 's/\\n/\n/g') + RELEASE_BODY=$(printf "%s\n%s" \ + "**Changelog:**" \ + "$CHANGELOG_UNESCAPED") + ghr_v0.15.0_linux_amd64/ghr -draft -t ${{ secrets.GITHUB_TOKEN }} -n "Cemu ${{ env.CEMU_VERSION }}" -b "$RELEASE_BODY" "v${{ env.CEMU_VERSION }}" ./upload diff --git a/.github/workflows/determine_release_version.yml b/.github/workflows/determine_release_version.yml new file mode 100644 index 00000000..be606941 --- /dev/null +++ b/.github/workflows/determine_release_version.yml @@ -0,0 +1,74 @@ +name: Calculate Next Version from release history + +on: + workflow_dispatch: + workflow_call: + outputs: + next_version: + description: "The next semantic version" + value: ${{ jobs.calculate-version.outputs.next_version }} + next_version_major: + description: "The next semantic version (major)" + value: ${{ jobs.calculate-version.outputs.next_version_major }} + next_version_minor: + description: "The next semantic version (minor)" + value: ${{ jobs.calculate-version.outputs.next_version_minor }} + +jobs: + calculate-version: + runs-on: ubuntu-latest + outputs: + next_version: ${{ steps.calculate_next_version.outputs.next_version }} + next_version_major: ${{ steps.calculate_next_version.outputs.next_version_major }} + next_version_minor: ${{ steps.calculate_next_version.outputs.next_version_minor }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get all releases + id: get_all_releases + run: | + # Fetch all releases and check for API errors + RESPONSE=$(curl -s -o response.json -w "%{http_code}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=100") + if [ "$RESPONSE" -ne 200 ]; then + echo "Failed to fetch releases. HTTP status: $RESPONSE" + cat response.json + exit 1 + fi + + # Extract and sort tags + ALL_TAGS=$(jq -r '.[].tag_name' response.json | grep -E '^v[0-9]+\.[0-9]+(-[0-9]+)?$' | sed 's/-.*//' | sort -V | tail -n 1) + + # Exit if no tags were found + if [ -z "$ALL_TAGS" ]; then + echo "No valid tags found." + exit 1 + fi + + echo "::set-output name=tag::$ALL_TAGS" + # echo "tag=$ALL_TAGS" >> $GITHUB_STATE + + - name: Calculate next semver minor + id: calculate_next_version + run: | + LATEST_VERSION=${{ steps.get_all_releases.outputs.tag }} + + # strip 'v' prefix and split into major.minor + LATEST_VERSION=${LATEST_VERSION//v/} + IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_VERSION" + + MAJOR=${VERSION_PARTS[0]} + MINOR=${VERSION_PARTS[1]} + + # increment the minor version + MINOR=$((MINOR + 1)) + + NEXT_VERSION="${MAJOR}.${MINOR}" + + echo "Major: $MAJOR" + echo "Minor: $MINOR" + + echo "Next version: $NEXT_VERSION" + echo "::set-output name=next_version::$NEXT_VERSION" + echo "::set-output name=next_version_major::$MAJOR" + echo "::set-output name=next_version_minor::$MINOR" \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 48e18637..80ac6cf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,18 +2,19 @@ cmake_minimum_required(VERSION 3.21.1) option(ENABLE_VCPKG "Enable the vcpkg package manager" ON) option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF) -set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version -if (EXPERIMENTAL_VERSION) - add_definitions(-DEMULATOR_VERSION_MINOR=${EXPERIMENTAL_VERSION}) - execute_process( - COMMAND git log --format=%h -1 - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - OUTPUT_VARIABLE GIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - add_definitions(-DEMULATOR_HASH=${GIT_HASH}) -endif() +# used by CI script to set version: +set(EMULATOR_VERSION_MAJOR "0" CACHE STRING "") +set(EMULATOR_VERSION_MINOR "0" CACHE STRING "") +set(EMULATOR_VERSION_PATCH "0" CACHE STRING "") + +execute_process( + COMMAND git log --format=%h -1 + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +add_definitions(-DEMULATOR_HASH=${GIT_HASH}) if (ENABLE_VCPKG) # check if vcpkg is shallow and unshallow it if necessary @@ -62,6 +63,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_definitions($<$<CONFIG:Debug>:CEMU_DEBUG_ASSERT>) # if build type is debug, set CEMU_DEBUG_ASSERT +add_definitions(-DEMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR}) +add_definitions(-DEMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR}) +add_definitions(-DEMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) # enable link time optimization for release builds diff --git a/src/Cafe/HW/Latte/Core/LatteShader.cpp b/src/Cafe/HW/Latte/Core/LatteShader.cpp index b59702cd..77f16468 100644 --- a/src/Cafe/HW/Latte/Core/LatteShader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShader.cpp @@ -524,7 +524,7 @@ void LatteSHRC_UpdateGSBaseHash(uint8* geometryShaderPtr, uint32 geometryShaderS // update hash from geometry shader data uint64 gsHash1 = 0; uint64 gsHash2 = 0; - _calculateShaderProgramHash((uint32*)geometryShaderPtr, geometryShaderSize, &hashCacheVS, &gsHash1, &gsHash2); + _calculateShaderProgramHash((uint32*)geometryShaderPtr, geometryShaderSize, &hashCacheGS, &gsHash1, &gsHash2); // get geometry shader uint64 gsHash = gsHash1 + gsHash2; gsHash += (uint64)_activeVertexShader->ringParameterCount; diff --git a/src/Cafe/HW/Latte/Renderer/RendererShader.cpp b/src/Cafe/HW/Latte/Renderer/RendererShader.cpp index f66dc9f4..23c8d0ea 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererShader.cpp +++ b/src/Cafe/HW/Latte/Renderer/RendererShader.cpp @@ -12,9 +12,9 @@ uint32 RendererShader::GeneratePrecompiledCacheId() v += (uint32)(*s); s++; } - v += (EMULATOR_VERSION_LEAD * 1000000u); - v += (EMULATOR_VERSION_MAJOR * 10000u); - v += (EMULATOR_VERSION_MINOR * 100u); + v += (EMULATOR_VERSION_MAJOR * 1000000u); + v += (EMULATOR_VERSION_MINOR * 10000u); + v += (EMULATOR_VERSION_PATCH * 100u); // settings that can influence shaders v += (uint32)g_current_game_profile->GetAccurateShaderMul() * 133; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index fb54a803..f464c7a3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -125,7 +125,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices() VkApplicationInfo app_info{}; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app_info.pApplicationName = EMULATOR_NAME; - app_info.applicationVersion = VK_MAKE_VERSION(EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR); + app_info.applicationVersion = VK_MAKE_VERSION(EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH); app_info.pEngineName = EMULATOR_NAME; app_info.engineVersion = app_info.applicationVersion; app_info.apiVersion = apiVersion; @@ -339,7 +339,7 @@ VulkanRenderer::VulkanRenderer() VkApplicationInfo app_info{}; app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; app_info.pApplicationName = EMULATOR_NAME; - app_info.applicationVersion = VK_MAKE_VERSION(EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR); + app_info.applicationVersion = VK_MAKE_VERSION(EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH); app_info.pEngineName = EMULATOR_NAME; app_info.engineVersion = app_info.applicationVersion; app_info.apiVersion = apiVersion; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp index 4c55c2b0..5201d441 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp @@ -140,7 +140,7 @@ namespace coreinit // we are in single-core mode and the lock will never be released unless we let other threads resume work // to avoid an infinite loop we have no choice but to yield the thread even it is in an uninterruptible state if( !OSIsInterruptEnabled() ) - cemuLog_log(LogType::APIErrors, "OSUninterruptibleSpinLock_Acquire(): Lock is occupied which requires a wait but current thread is already in an uninterruptible state (Avoid cascaded OSDisableInterrupts and/or OSUninterruptibleSpinLock)"); + cemuLog_logOnce(LogType::APIErrors, "OSUninterruptibleSpinLock_Acquire(): Lock is occupied which requires a wait but current thread is already in an uninterruptible state (Avoid cascaded OSDisableInterrupts and/or OSUninterruptibleSpinLock)"); while (!spinlock->ownerThread.atomic_compare_exchange(nullptr, currentThread)) { OSYieldThread(); diff --git a/src/Common/version.h b/src/Common/version.h index 8c08f238..36925a52 100644 --- a/src/Common/version.h +++ b/src/Common/version.h @@ -1,36 +1,19 @@ #ifndef EMULATOR_NAME #define EMULATOR_NAME "Cemu" -#define EMULATOR_VERSION_LEAD 2 -#define EMULATOR_VERSION_MAJOR 0 -// the minor version is used for experimental builds to indicate the build index. Set by command line option from CI build script -// if zero, the version text will be constructed as LEAD.MAJOR, otherwise as LEAD.MAJOR-MINOR - -#if defined(EMULATOR_VERSION_MINOR) && EMULATOR_VERSION_MINOR == 0 #define EMULATOR_VERSION_SUFFIX "" -#else -#define EMULATOR_VERSION_SUFFIX " (experimental)" -#endif - -#ifndef EMULATOR_VERSION_MINOR -#define EMULATOR_VERSION_MINOR 0 -#endif #define _XSTRINGFY(s) _STRINGFY(s) #define _STRINGFY(s) #s -#if EMULATOR_VERSION_MINOR != 0 -#if defined(EMULATOR_HASH) && EMULATOR_VERSION_MINOR == 999999 -#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) -#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) +#if EMULATOR_VERSION_MAJOR != 0 +#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_MAJOR) "." _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) +#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_MAJOR) "." _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) #else -#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) -#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) -#endif -#else -#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) EMULATOR_VERSION_SUFFIX) -#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) EMULATOR_VERSION_SUFFIX) +// no version provided. Only show commit hash +#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) +#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) #endif #endif diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 338392dd..e7920e84 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -38,6 +38,7 @@ void CemuConfig::Load(XMLConfigParser& parser) fullscreen_menubar = parser.get("fullscreen_menubar", false); feral_gamemode = parser.get("feral_gamemode", false); check_update = parser.get("check_update", check_update); + receive_untested_updates = parser.get("receive_untested_updates", check_update); save_screenshot = parser.get("save_screenshot", save_screenshot); did_show_vulkan_warning = parser.get("vk_warning", did_show_vulkan_warning); did_show_graphic_pack_download = parser.get("gp_download", did_show_graphic_pack_download); @@ -360,6 +361,7 @@ void CemuConfig::Save(XMLConfigParser& parser) config.set<bool>("fullscreen_menubar", fullscreen_menubar); config.set<bool>("feral_gamemode", feral_gamemode); config.set<bool>("check_update", check_update); + config.set<bool>("receive_untested_updates", receive_untested_updates); config.set<bool>("save_screenshot", save_screenshot); config.set<bool>("vk_warning", did_show_vulkan_warning); config.set<bool>("gp_download", did_show_graphic_pack_download); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 5db8f58c..e2fbb74c 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -413,7 +413,8 @@ struct CemuConfig Vector2i pad_size{ -1,-1 }; ConfigValue<bool> pad_maximized; - ConfigValue<bool> check_update{false}; + ConfigValue<bool> check_update{true}; + ConfigValue<bool> receive_untested_updates{false}; ConfigValue<bool> save_screenshot{true}; ConfigValue<bool> did_show_vulkan_warning{false}; diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index 1731f500..bf38b9cf 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -112,10 +112,10 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args) { requireConsole(); std::string versionStr; -#if EMULATOR_VERSION_MINOR == 0 - versionStr = fmt::format("{}.{}{}", EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_SUFFIX); +#if EMULATOR_VERSION_PATCH == 0 + versionStr = fmt::format("{}.{}{}", EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_SUFFIX); #else - versionStr = fmt::format("{}.{}-{}{}", EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_SUFFIX); + versionStr = fmt::format("{}.{}-{}{}", EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH, EMULATOR_VERSION_SUFFIX); #endif std::cout << versionStr << std::endl; return false; // exit in main diff --git a/src/gui/CemuUpdateWindow.cpp b/src/gui/CemuUpdateWindow.cpp index 445c7c17..6a4e6885 100644 --- a/src/gui/CemuUpdateWindow.cpp +++ b/src/gui/CemuUpdateWindow.cpp @@ -116,9 +116,11 @@ bool CemuUpdateWindow::QueryUpdateInfo(std::string& downloadUrlOut, std::string& #elif BOOST_OS_MACOS urlStr.append("&platform=macos_bundle_x86"); #elif - #error Name for current platform is missing #endif + const auto& config = GetConfig(); + if(config.receive_untested_updates) + urlStr.append("&allowNewUpdates=1"); curl_easy_setopt(curl, CURLOPT_URL, urlStr.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); diff --git a/src/gui/DownloadGraphicPacksWindow.cpp b/src/gui/DownloadGraphicPacksWindow.cpp index 03f102d2..9ea9e1dd 100644 --- a/src/gui/DownloadGraphicPacksWindow.cpp +++ b/src/gui/DownloadGraphicPacksWindow.cpp @@ -115,7 +115,7 @@ void DownloadGraphicPacksWindow::UpdateThread() curlDownloadFileState_t tempDownloadState; std::string queryUrl("https://cemu.info/api2/query_graphicpack_url.php?"); char temp[64]; - sprintf(temp, "version=%d.%d.%d", EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR); + sprintf(temp, "version=%d.%d.%d", EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH); queryUrl.append(temp); queryUrl.append("&"); sprintf(temp, "t=%u", (uint32)std::chrono::seconds(std::time(NULL)).count()); // add a dynamic part to the url to bypass overly aggressive caching (like some proxies do) diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 08395cd3..bd394479 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -141,49 +141,66 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) second_row->SetFlexibleDirection(wxBOTH); second_row->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); + sint32 checkboxCount = 0; + auto CountRowElement = [&]() + { + checkboxCount++; + if(checkboxCount != 2) + return; + second_row->AddSpacer(10); + checkboxCount = 0; + }; + + auto InsertEmptyRow = [&]() + { + while(checkboxCount != 0) + CountRowElement(); + second_row->AddSpacer(10); + second_row->AddSpacer(10); + second_row->AddSpacer(10); + }; + const int topflag = wxALIGN_CENTER_VERTICAL | wxALL; m_save_window_position_size = new wxCheckBox(box, wxID_ANY, _("Remember main window position")); m_save_window_position_size->SetToolTip(_("Restores the last known window position and size when starting Cemu")); second_row->Add(m_save_window_position_size, 0, topflag, 5); - second_row->AddSpacer(10); + CountRowElement(); + //second_row->AddSpacer(10); m_save_padwindow_position_size = new wxCheckBox(box, wxID_ANY, _("Remember pad window position")); m_save_padwindow_position_size->SetToolTip(_("Restores the last known pad window position and size when opening it")); second_row->Add(m_save_padwindow_position_size, 0, topflag, 5); + CountRowElement(); const int botflag = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM; m_discord_presence = new wxCheckBox(box, wxID_ANY, _("Discord Presence")); m_discord_presence->SetToolTip(_("Enables the Discord Rich Presence feature\nYou will also need to enable it in the Discord settings itself!")); second_row->Add(m_discord_presence, 0, botflag, 5); + CountRowElement(); #ifndef ENABLE_DISCORD_RPC m_discord_presence->Disable(); #endif - second_row->AddSpacer(10); + //second_row->AddSpacer(10); m_fullscreen_menubar = new wxCheckBox(box, wxID_ANY, _("Fullscreen menu bar")); m_fullscreen_menubar->SetToolTip(_("Displays the menu bar when Cemu is running in fullscreen mode and the mouse cursor is moved to the top")); second_row->Add(m_fullscreen_menubar, 0, botflag, 5); + CountRowElement(); - m_auto_update = new wxCheckBox(box, wxID_ANY, _("Automatically check for updates")); - m_auto_update->SetToolTip(_("Automatically checks for new cemu versions on startup")); - second_row->Add(m_auto_update, 0, botflag, 5); -#if BOOST_OS_LINUX - if (!std::getenv("APPIMAGE")) { - m_auto_update->Disable(); - } -#endif - second_row->AddSpacer(10); m_save_screenshot = new wxCheckBox(box, wxID_ANY, _("Save screenshot")); m_save_screenshot->SetToolTip(_("Pressing the screenshot key (F12) will save a screenshot directly to the screenshots folder")); second_row->Add(m_save_screenshot, 0, botflag, 5); + CountRowElement(); m_disable_screensaver = new wxCheckBox(box, wxID_ANY, _("Disable screen saver")); m_disable_screensaver->SetToolTip(_("Prevents the system from activating the screen saver or going to sleep while running a game.")); second_row->Add(m_disable_screensaver, 0, botflag, 5); + CountRowElement(); // Enable/disable feral interactive gamemode #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) m_feral_gamemode = new wxCheckBox(box, wxID_ANY, _("Enable Feral GameMode")); m_feral_gamemode->SetToolTip(_("Use FeralInteractive GameMode if installed.")); second_row->Add(m_feral_gamemode, 0, botflag, 5); + CountRowElement(); #endif // temporary workaround because feature crashes on macOS @@ -191,6 +208,22 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) m_disable_screensaver->Enable(false); #endif + // InsertEmptyRow(); + + m_auto_update = new wxCheckBox(box, wxID_ANY, _("Automatically check for updates")); + m_auto_update->SetToolTip(_("Automatically checks for new cemu versions on startup")); + second_row->Add(m_auto_update, 0, botflag, 5); + CountRowElement(); + + m_receive_untested_releases = new wxCheckBox(box, wxID_ANY, _("Receive untested updates")); + m_receive_untested_releases->SetToolTip(_("When checking for updates, include brand new and untested releases. These may contain bugs!")); + second_row->Add(m_receive_untested_releases, 0, botflag, 5); +#if BOOST_OS_LINUX + if (!std::getenv("APPIMAGE")) { + m_auto_update->Disable(); + } +#endif + box_sizer->Add(second_row, 0, wxEXPAND, 5); } @@ -1536,6 +1569,7 @@ void GeneralSettings2::ApplyConfig() m_fullscreen_menubar->SetValue(config.fullscreen_menubar); m_auto_update->SetValue(config.check_update); + m_receive_untested_releases->SetValue(config.receive_untested_updates); m_save_screenshot->SetValue(config.save_screenshot); m_disable_screensaver->SetValue(config.disable_screensaver); diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index a3429fa1..b1ab01e8 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -41,7 +41,7 @@ private: wxCheckBox* m_save_window_position_size; wxCheckBox* m_save_padwindow_position_size; wxCheckBox* m_discord_presence, *m_fullscreen_menubar; - wxCheckBox* m_auto_update, *m_save_screenshot; + wxCheckBox* m_auto_update, *m_receive_untested_releases, *m_save_screenshot; wxCheckBox* m_disable_screensaver; #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) wxCheckBox* m_feral_gamemode; diff --git a/src/resource/cemu.rc b/src/resource/cemu.rc index 860ca8fb..6f78bfc3 100644 --- a/src/resource/cemu.rc +++ b/src/resource/cemu.rc @@ -73,8 +73,8 @@ END #define str(s) #s VS_VERSION_INFO VERSIONINFO -FILEVERSION EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, 0 -PRODUCTVERSION EMULATOR_VERSION_LEAD, EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, 0 +FILEVERSION EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH, 0 +PRODUCTVERSION EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH, 0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -94,7 +94,7 @@ BEGIN VALUE "LegalCopyright", "Team Cemu" VALUE "OriginalFilename", "Cemu.exe" VALUE "ProductName", "Cemu" - VALUE "ProductVersion", xstr(EMULATOR_VERSION_LEAD) "." xstr(EMULATOR_VERSION_MAJOR) "." xstr(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX "\0" + VALUE "ProductVersion", xstr(EMULATOR_VERSION_MAJOR) "." xstr(EMULATOR_VERSION_MINOR) "." xstr(EMULATOR_VERSION_PATCH) EMULATOR_VERSION_SUFFIX "\0" END END BLOCK "VarFileInfo" From 03484d214678cd5e442f196bbfc38b79c53509f9 Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Wed, 28 Aug 2024 09:05:50 +0000 Subject: [PATCH 247/314] Update translation files --- bin/resources/fr/cemu.mo | Bin 72178 -> 73978 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/fr/cemu.mo b/bin/resources/fr/cemu.mo index 8328991f01eb915b5ea722452ccefde985d6416c..f3f3b49871a8078edf991f90f995d71f14e80f94 100644 GIT binary patch delta 25041 zcmb`O2Y6J~_P5W3&_b0S>Y?}06a?v2q)HXRG9;5^AejkM=sGGYiUs9djRg@D1?)O1 zb`dOy9V;s86;ZKwvEldr&fXKid;j0}{GaDLk2~*PYxlL+Zo|Dlq_cm2Dm(Q-z3i(T zzW$XQr#bv2*KsCgJI)<_q;;InM><X|cmURfzrq?Ydz9l;hjlHRTDG&ygUWY2Yz9Zd zI`B+b8<rV4<)nzH;?<CLowcwr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ZG)AaggFDM!dH`VoK)VP$-mnc7<<^H=&E6aP}{{ZC_DFXli From 9a53b19403d4fea5861bcdf115a673d801759245 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Wed, 28 Aug 2024 02:06:49 -0700 Subject: [PATCH 248/314] CI+build: Improve macOS builds (#1310) --- .github/workflows/build.yml | 20 +++++------- BUILD.md | 50 ++++++++++++++++++------------ CMakeLists.txt | 1 + dependencies/ih264d/CMakeLists.txt | 12 +++++-- src/asm/CMakeLists.txt | 12 +++++-- 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd28ceb5..72bbcf52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -176,7 +176,7 @@ jobs: path: ./bin/Cemu.exe build-macos: - runs-on: macos-12 + runs-on: macos-14 steps: - name: "Checkout repo" uses: actions/checkout@v4 @@ -198,17 +198,14 @@ jobs: - name: "Install system dependencies" run: | brew update - brew install llvm@15 ninja nasm automake libtool - brew install cmake ninja + brew install ninja nasm automake libtool - - name: "Build and install molten-vk" + - name: "Install molten-vk" run: | - git clone https://github.com/KhronosGroup/MoltenVK.git - cd MoltenVK - git checkout bf097edc74ec3b6dfafdcd5a38d3ce14b11952d6 - ./fetchDependencies --macos - make macos - make install + curl -L -O https://github.com/KhronosGroup/MoltenVK/releases/download/v1.2.9/MoltenVK-macos.tar + tar xf MoltenVK-macos.tar + sudo mkdir -p /usr/local/lib + sudo cp MoltenVK/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib /usr/local/lib - name: "Setup cmake" uses: jwlawson/actions-setup-cmake@v2 @@ -239,9 +236,8 @@ jobs: cd build cmake .. ${{ env.BUILD_FLAGS }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} \ + -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DMACOS_BUNDLE=ON \ - -DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \ - -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++ \ -G Ninja - name: "Build Cemu" diff --git a/BUILD.md b/BUILD.md index 1e92527e..44d69c6c 100644 --- a/BUILD.md +++ b/BUILD.md @@ -16,11 +16,11 @@ - [Compiling Errors](#compiling-errors) - [Building Errors](#building-errors) - [macOS](#macos) - - [On Apple Silicon Macs, Rosetta 2 and the x86_64 version of Homebrew must be used](#on-apple-silicon-macs-rosetta-2-and-the-x86_64-version-of-homebrew-must-be-used) - [Installing brew](#installing-brew) - - [Installing Dependencies](#installing-dependencies) - - [Build Cemu using CMake and Clang](#build-cemu-using-cmake-and-clang) - - [Updating Cemu and source code](#updating-cemu-and-source-code) + - [Installing Tool Dependencies](#installing-tool-dependencies) + - [Installing Library Dependencies](#installing-library-dependencies) + - [Build Cemu using CMake](#build-cemu-using-cmake) +- [Updating Cemu and source code](#updating-cemu-and-source-code) ## Windows @@ -141,31 +141,41 @@ If you are getting a different error than any of the errors listed above, you ma ## macOS -To compile Cemu, a recent enough compiler and STL with C++20 support is required! LLVM 13 and -below, built in LLVM, and Xcode LLVM don't support the C++20 feature set required. The OpenGL graphics -API isn't support on macOS, Vulkan must be used. Additionally Vulkan must be used through the -Molten-VK compatibility layer - -### On Apple Silicon Macs, Rosetta 2 and the x86_64 version of Homebrew must be used - -You can skip this section if you have an Intel Mac. Every time you compile, you need to perform steps 2. - -1. `softwareupdate --install-rosetta` # Install Rosetta 2 if you don't have it. This only has to be done once -2. `arch -x86_64 zsh` # run an x64 shell +To compile Cemu, a recent enough compiler and STL with C++20 support is required! LLVM 13 and below +don't support the C++20 feature set required, so either install LLVM from Homebrew or make sure that +you have a recent enough version of Xcode. Xcode 15 is known to work. The OpenGL graphics API isn't +supported on macOS, so Vulkan must be used through the Molten-VK compatibility layer. ### Installing brew 1. `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` -2. `eval "$(/usr/local/Homebrew/bin/brew shellenv)"` # set x86_64 brew env +2. Set up the Homebrew shell environment: + 1. **On an Intel Mac:** `eval "$(/usr/local/Homebrew/bin/brew shellenv)"` + 2. **On an Apple Silicon Mac:** eval `"$(/opt/homebrew/bin/brew shellenv)"` -### Installing Dependencies +### Installing Tool Dependencies -`brew install boost git cmake llvm ninja nasm molten-vk automake libtool` +The native versions of these can be used regardless of what type of Mac you have. + +`brew install git cmake ninja nasm automake libtool` + +### Installing Library Dependencies + +**On Apple Silicon Macs, Rosetta 2 and the x86_64 version of Homebrew must be used to install these dependencies:** +1. `softwareupdate --install-rosetta` # Install Rosetta 2 if you don't have it. This only has to be done once +2. `arch -x86_64 zsh` # run an x64 shell +3. `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` +4. `eval "$(/usr/local/Homebrew/bin/brew shellenv)"` + +Then install the dependencies: + +`brew install boost molten-vk` + +### Build Cemu using CMake -### Build Cemu using CMake and Clang 1. `git clone --recursive https://github.com/cemu-project/Cemu` 2. `cd Cemu` -3. `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G Ninja` +3. `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_OSX_ARCHITECTURES=x86_64 -G Ninja` 4. `cmake --build build` 5. You should now have a Cemu executable file in the /bin folder, which you can run using `./bin/Cemu_release`. diff --git a/CMakeLists.txt b/CMakeLists.txt index 80ac6cf0..54e2012a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ endif() if (APPLE) enable_language(OBJC OBJCXX) + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0") endif() if (UNIX AND NOT APPLE) diff --git a/dependencies/ih264d/CMakeLists.txt b/dependencies/ih264d/CMakeLists.txt index d97d6dda..686a9d08 100644 --- a/dependencies/ih264d/CMakeLists.txt +++ b/dependencies/ih264d/CMakeLists.txt @@ -117,7 +117,13 @@ add_library (ih264d "decoder/ivd.h" ) -if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") +if (CMAKE_OSX_ARCHITECTURES) +set(IH264D_ARCHITECTURE ${CMAKE_OSX_ARCHITECTURES}) +else() +set(IH264D_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +if (IH264D_ARCHITECTURE STREQUAL "x86_64" OR IH264D_ARCHITECTURE STREQUAL "amd64" OR IH264D_ARCHITECTURE STREQUAL "AMD64") set(LIBAVCDEC_X86_INCLUDES "common/x86" "decoder/x86") include_directories("common/" "decoder/" ${LIBAVCDEC_X86_INCLUDES}) target_sources(ih264d PRIVATE @@ -140,7 +146,7 @@ target_sources(ih264d PRIVATE "decoder/x86/ih264d_function_selector_sse42.c" "decoder/x86/ih264d_function_selector_ssse3.c" ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") +elseif(IH264D_ARCHITECTURE STREQUAL "aarch64" OR IH264D_ARCHITECTURE STREQUAL "arm64") enable_language( C CXX ASM ) set(LIBAVCDEC_ARM_INCLUDES "common/armv8" "decoder/arm") include_directories("common/" "decoder/" ${LIBAVCDEC_ARM_INCLUDES}) @@ -178,7 +184,7 @@ target_sources(ih264d PRIVATE ) target_compile_options(ih264d PRIVATE -DARMV8) else() -message(FATAL_ERROR "ih264d unknown architecture: ${CMAKE_SYSTEM_PROCESSOR}") +message(FATAL_ERROR "ih264d unknown architecture: ${IH264D_ARCHITECTURE}") endif() if(MSVC) diff --git a/src/asm/CMakeLists.txt b/src/asm/CMakeLists.txt index 5d9f84c2..19a7ddd8 100644 --- a/src/asm/CMakeLists.txt +++ b/src/asm/CMakeLists.txt @@ -1,6 +1,12 @@ project(CemuAsm C) -if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") +if (CMAKE_OSX_ARCHITECTURES) + set(CEMU_ASM_ARCHITECTURE ${CMAKE_OSX_ARCHITECTURES}) +else() + set(CEMU_ASM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +endif() + +if (CEMU_ASM_ARCHITECTURE MATCHES "(x86)|(X86)|(amd64)|(AMD64)") if (WIN32) @@ -40,8 +46,8 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") endif() -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(AARCH64)") +elseif(CEMU_ASM_ARCHITECTURE MATCHES "(aarch64)|(AARCH64)|(arm64)|(ARM64)") add_library(CemuAsm stub.cpp) else() - message(STATUS "CemuAsm - Unsupported arch: ${CMAKE_SYSTEM_PROCESSOR}") + message(STATUS "CemuAsm - Unsupported arch: ${CEMU_ASM_ARCHITECTURE}") endif() From b06990607d31fc204d82be2b062df4c7edd6e299 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Mon, 2 Sep 2024 15:20:16 +0100 Subject: [PATCH 249/314] nsysnet: Avoid crash on NULL timeout in select (#1324) --- src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index dd7c9189..5a0ddc59 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -1210,6 +1210,14 @@ void nsysnetExport_select(PPCInterpreter_t* hCPU) timeval tv = { 0 }; + if (timeOut == NULL) + { + // return immediately + cemuLog_log(LogType::Socket, "select returned immediately because of null timeout"); + osLib_returnFromFunction(hCPU, 0); + return; + } + uint64 msTimeout = (_swapEndianU32(timeOut->tv_usec) / 1000) + (_swapEndianU32(timeOut->tv_sec) * 1000); uint32 startTime = GetTickCount(); while (true) From 0d8fd7c0dc2ea6ff750f4ef5b193ebc6388d31d0 Mon Sep 17 00:00:00 2001 From: MoonlightWave-12 <123384363+MoonlightWave-12@users.noreply.github.com> Date: Mon, 2 Sep 2024 21:22:38 +0200 Subject: [PATCH 250/314] appimage: Do not copy `libstdc++.so.6` to `usr/lib/` (#1319) --- dist/linux/appimage.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/linux/appimage.sh b/dist/linux/appimage.sh index e9081521..b66326d7 100755 --- a/dist/linux/appimage.sh +++ b/dist/linux/appimage.sh @@ -50,7 +50,6 @@ fi echo "Cemu Version Cemu-${GITVERSION}" rm AppDir/usr/lib/libwayland-client.so.0 -cp /lib/x86_64-linux-gnu/libstdc++.so.6 AppDir/usr/lib/ echo -e "export LC_ALL=C\nexport FONTCONFIG_PATH=/etc/fonts" >> AppDir/apprun-hooks/linuxdeploy-plugin-gtk.sh VERSION="${GITVERSION}" ./mkappimage.AppImage --appimage-extract-and-run "${GITHUB_WORKSPACE}"/AppDir From ba54d1540cf6103728abe606223b299d284a6df8 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:21:20 +0200 Subject: [PATCH 251/314] Fix "Receive untested updates" option not being synced to config --- src/gui/GeneralSettings2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index bd394479..eaada7cb 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -932,6 +932,7 @@ void GeneralSettings2::StoreConfig() config.fullscreen_menubar = m_fullscreen_menubar->IsChecked(); config.check_update = m_auto_update->IsChecked(); config.save_screenshot = m_save_screenshot->IsChecked(); + config.receive_untested_updates = m_receive_untested_releases->IsChecked(); #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) config.feral_gamemode = m_feral_gamemode->IsChecked(); #endif From 1a4d9660e756f52a01589add71df619361543a2f Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Sun, 8 Sep 2024 15:40:13 +0000 Subject: [PATCH 252/314] Update translation files --- bin/resources/ko/cemu.mo | Bin 70573 -> 71668 bytes bin/resources/zh/cemu.mo | Bin 58070 -> 60704 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/resources/ko/cemu.mo b/bin/resources/ko/cemu.mo index b812df970a34b41a6d2407c9ec4771adadd6a5db..5ea5e1da1a39c3ac7d15b9b270c5a01a89a4ed07 100644 GIT binary patch delta 22630 zcmcKB2Y3|K;`i}c5?bhlUWXP!3%&OaQl$ur3QMvffsn)$5J49tD80Cppn#xs0RtO~ z1q=3y4M7nFE3g|yv0?pxe={eDdhc7F=Y8k7htFwq=G57Nd+**Ik>5WW>HoN5<Qj{s zV}xbZ!uP6M*5F9XTH02*mX+7fvdZ9oER9cNDSRDE;wj^&#<1~6R6VP|Wz~ezSPo;c zEOv6!erq5RH9QU@F#)S$GFHTSSOQmL1>A^5@ljMm2TlI-Sf2Fz7=vG#blCxJy}DS8 z{5Xul_E_BVTUIY38p$Bk14dy{Ofc!GSd8=>REOqcG_FN8v>PkqK~zUyL*4%#s@)Gw z`g1H!`XXv(zQb}n-}-}y9$a>yTfs)nNGz)1_Nb8#K{b36>cNvxQ#uVB;cQd~x1c(b zkLtitERHXsmhw2N-81M{#mhvh;cuvP<w0%->Y%2y8ER>|p*q^z<c~&mAOS03mT?i5 zAiW8-jdq}B>@;fR-=I4B>mcS|BPl!B?OAnH&l;m{=#ItldMt)FVhNmtdT=sougt<K zxXP68H10>;_qa(vi+bLxsQXR~X8tvz0y0YCpQx!Xd7V4uRZtByLOq~4s(xRri(^qE z$u{{5Q8RHrYDOPL)q5GE@H}cjmr+aktDi`1BAy`xtczOfdZ-y_g<67s$O*N^qDFor zs=;JbgITEhbFdDsMBVo&_QYrKPPB$v7AM@g3-ug-E)i{t9jFH!#4-37YGh@Hxeus^ z_mXaceQ-ajBj2OyMG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s%ya4~5hsSEkE&mTqJYk`75=oMm+ z9hRSnr%0nMe~LQ4#cEyBChSbv4blPfMJP`qeoS1Ow8q+3CC*6FHJkJb=kNcyhFHUk zH0oeA3n{BXT5lb@m|sypg7^yQ6YJNEcoL}&b+_;^>1*Q7_zi9P;(hYx@FMwQFOu0x zM%QjqKGGvn9viTZOet3P3x8;Q?;!t_dg+5wmehah|Dr+n2!F+-#X%`IT6FW@YB@BW z|LwM|g8cW}l}PVz-RVr2zjV)6gHxvWzUyDzXINND!NIvx_75)N&o-oBI)9_#ON0G? zjU1ldzkOU(q`%vo>Y?G4%2uclTcLc7%9T=57knR7A!X*mA3}=PPim8rvgmR|@dk<Y zWA825e0T5slrf99`Rgue8kCZ{bZ1EMW)177bpK$Qzr?bc!I_G;>-$FE*!wHD-~V8h z|ML|`Gx%q3=ogfdb<?Z<-!~Ou;w|-q{42KZ4)HJ8-Zv~H_THu~bN4p(C+$rPPD$Or z-#`CArm$>x_e}Ke?cRT9=Zx>yue`fwc1nrkCH%hQTZ1$HuzBCz&5OTZnVM4b#9;ri r6McgH@uzmD3(@NQ!Dq(?`H!93lRcCM->;nRPrh3^$lvJR<@EmtGq=as From a05bdb172d198904a76b4b166b43fb31a94a0dd3 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sun, 15 Sep 2024 20:23:11 +0200 Subject: [PATCH 253/314] Vulkan: Add explicit synchronization on frame boundaries (#1290) --- .../Latte/Renderer/Vulkan/SwapchainInfoVk.cpp | 34 ++++++++- .../Latte/Renderer/Vulkan/SwapchainInfoVk.h | 8 ++ src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h | 3 + .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 73 ++++++++++++++++++- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 4 +- 5 files changed, 119 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp index 75ff02ba..56a3ab12 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp @@ -146,8 +146,17 @@ void SwapchainInfoVk::Create() UnrecoverableError("Failed to create semaphore for swapchain acquire"); } + VkFenceCreateInfo fenceInfo = {}; + fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; + fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; + result = vkCreateFence(m_logicalDevice, &fenceInfo, nullptr, &m_imageAvailableFence); + if (result != VK_SUCCESS) + UnrecoverableError("Failed to create fence for swapchain"); + m_acquireIndex = 0; hasDefinedSwapchainImage = false; + + m_queueDepth = 0; } void SwapchainInfoVk::Cleanup() @@ -177,6 +186,12 @@ void SwapchainInfoVk::Cleanup() m_swapchainFramebuffers.clear(); + if (m_imageAvailableFence) + { + WaitAvailableFence(); + vkDestroyFence(m_logicalDevice, m_imageAvailableFence, nullptr); + m_imageAvailableFence = nullptr; + } if (m_swapchain) { vkDestroySwapchainKHR(m_logicalDevice, m_swapchain, nullptr); @@ -189,6 +204,18 @@ bool SwapchainInfoVk::IsValid() const return m_swapchain && !m_acquireSemaphores.empty(); } +void SwapchainInfoVk::WaitAvailableFence() +{ + if(m_awaitableFence != VK_NULL_HANDLE) + vkWaitForFences(m_logicalDevice, 1, &m_awaitableFence, VK_TRUE, UINT64_MAX); + m_awaitableFence = VK_NULL_HANDLE; +} + +void SwapchainInfoVk::ResetAvailableFence() const +{ + vkResetFences(m_logicalDevice, 1, &m_imageAvailableFence); +} + VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore() { VkSemaphore ret = m_currentSemaphore; @@ -198,8 +225,10 @@ VkSemaphore SwapchainInfoVk::ConsumeAcquireSemaphore() bool SwapchainInfoVk::AcquireImage() { + ResetAvailableFence(); + VkSemaphore acquireSemaphore = m_acquireSemaphores[m_acquireIndex]; - VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, 1'000'000'000, acquireSemaphore, nullptr, &swapchainImageIndex); + VkResult result = vkAcquireNextImageKHR(m_logicalDevice, m_swapchain, 1'000'000'000, acquireSemaphore, m_imageAvailableFence, &swapchainImageIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) m_shouldRecreate = true; if (result == VK_TIMEOUT) @@ -216,6 +245,7 @@ bool SwapchainInfoVk::AcquireImage() return false; } m_currentSemaphore = acquireSemaphore; + m_awaitableFence = m_imageAvailableFence; m_acquireIndex = (m_acquireIndex + 1) % m_swapchainImages.size(); return true; @@ -319,6 +349,7 @@ VkExtent2D SwapchainInfoVk::ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& cap VkPresentModeKHR SwapchainInfoVk::ChoosePresentMode(const std::vector<VkPresentModeKHR>& modes) { + m_maxQueued = 0; const auto vsyncState = (VSync)GetConfig().vsync.GetValue(); if (vsyncState == VSync::MAILBOX) { @@ -345,6 +376,7 @@ VkPresentModeKHR SwapchainInfoVk::ChoosePresentMode(const std::vector<VkPresentM return VK_PRESENT_MODE_FIFO_KHR; } + m_maxQueued = 1; return VK_PRESENT_MODE_FIFO_KHR; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h index ceffab41..7023f291 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h @@ -26,6 +26,9 @@ struct SwapchainInfoVk bool IsValid() const; + void WaitAvailableFence(); + void ResetAvailableFence() const; + bool AcquireImage(); // retrieve semaphore of last acquire for submitting a wait operation // only one wait operation must be submitted per acquire (which submits a single signal operation) @@ -68,6 +71,9 @@ struct SwapchainInfoVk VkSwapchainKHR m_swapchain{}; Vector2i m_desiredExtent{}; uint32 swapchainImageIndex = (uint32)-1; + uint64 m_presentId = 1; + uint64 m_queueDepth = 0; // number of frames with pending presentation requests + uint64 m_maxQueued = 0; // the maximum number of frames with presentation requests. // swapchain image ringbuffer (indexed by swapchainImageIndex) @@ -81,6 +87,8 @@ struct SwapchainInfoVk private: uint32 m_acquireIndex = 0; std::vector<VkSemaphore> m_acquireSemaphores; // indexed by m_acquireIndex + VkFence m_imageAvailableFence{}; + VkFence m_awaitableFence = VK_NULL_HANDLE; VkSemaphore m_currentSemaphore = VK_NULL_HANDLE; std::array<uint32, 2> m_swapchainQueueFamilyIndices; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h index 0489bb4e..6bde2a0b 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h @@ -188,6 +188,9 @@ VKFUNC_DEVICE(vkCmdPipelineBarrier2KHR); VKFUNC_DEVICE(vkCmdBeginRenderingKHR); VKFUNC_DEVICE(vkCmdEndRenderingKHR); +// khr_present_wait +VKFUNC_DEVICE(vkWaitForPresentKHR); + // transform feedback extension VKFUNC_DEVICE(vkCmdBindTransformFeedbackBuffersEXT); VKFUNC_DEVICE(vkCmdBeginTransformFeedbackEXT); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index f464c7a3..12d1d975 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -47,7 +47,9 @@ const std::vector<const char*> kOptionalDeviceExtensions = VK_EXT_FILTER_CUBIC_EXTENSION_NAME, // not supported by any device yet VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, - VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME + VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, + VK_KHR_PRESENT_WAIT_EXTENSION_NAME, + VK_KHR_PRESENT_ID_EXTENSION_NAME }; const std::vector<const char*> kRequiredDeviceExtensions = @@ -252,12 +254,24 @@ void VulkanRenderer::GetDeviceFeatures() pcc.pNext = prevStruct; prevStruct = &pcc; + VkPhysicalDevicePresentIdFeaturesKHR pidf{}; + pidf.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR; + pidf.pNext = prevStruct; + prevStruct = &pidf; + + VkPhysicalDevicePresentWaitFeaturesKHR pwf{}; + pwf.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR; + pwf.pNext = prevStruct; + prevStruct = &pwf; + VkPhysicalDeviceFeatures2 physicalDeviceFeatures2{}; physicalDeviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; physicalDeviceFeatures2.pNext = prevStruct; vkGetPhysicalDeviceFeatures2(m_physicalDevice, &physicalDeviceFeatures2); + cemuLog_log(LogType::Force, "Vulkan: present_wait extension: {}", (pwf.presentWait && pidf.presentId) ? "supported" : "unsupported"); + /* Get Vulkan device properties and limits */ VkPhysicalDeviceFloatControlsPropertiesKHR pfcp{}; prevStruct = nullptr; @@ -490,6 +504,24 @@ VulkanRenderer::VulkanRenderer() customBorderColorFeature.customBorderColors = VK_TRUE; customBorderColorFeature.customBorderColorWithoutFormat = VK_TRUE; } + // enable VK_KHR_present_id + VkPhysicalDevicePresentIdFeaturesKHR presentIdFeature{}; + if(m_featureControl.deviceExtensions.present_wait) + { + presentIdFeature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR; + presentIdFeature.pNext = deviceExtensionFeatures; + deviceExtensionFeatures = &presentIdFeature; + presentIdFeature.presentId = VK_TRUE; + } + // enable VK_KHR_present_wait + VkPhysicalDevicePresentWaitFeaturesKHR presentWaitFeature{}; + if(m_featureControl.deviceExtensions.present_wait) + { + presentWaitFeature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR; + presentWaitFeature.pNext = deviceExtensionFeatures; + deviceExtensionFeatures = &presentWaitFeature; + presentWaitFeature.presentWait = VK_TRUE; + } std::vector<const char*> used_extensions; VkDeviceCreateInfo createInfo = CreateDeviceCreateInfo(queueCreateInfos, deviceFeatures, deviceExtensionFeatures, used_extensions); @@ -1047,6 +1079,10 @@ VkDeviceCreateInfo VulkanRenderer::CreateDeviceCreateInfo(const std::vector<VkDe used_extensions.emplace_back(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); if (m_featureControl.deviceExtensions.shader_float_controls) used_extensions.emplace_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME); + if (m_featureControl.deviceExtensions.present_wait) + used_extensions.emplace_back(VK_KHR_PRESENT_ID_EXTENSION_NAME); + if (m_featureControl.deviceExtensions.present_wait) + used_extensions.emplace_back(VK_KHR_PRESENT_WAIT_EXTENSION_NAME); VkDeviceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; @@ -1144,6 +1180,7 @@ bool VulkanRenderer::CheckDeviceExtensionSupport(const VkPhysicalDevice device, info.deviceExtensions.shader_float_controls = isExtensionAvailable(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME); info.deviceExtensions.dynamic_rendering = false; // isExtensionAvailable(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); // dynamic rendering doesn't provide any benefits for us right now. Driver implementations are very unoptimized as of Feb 2022 + info.deviceExtensions.present_wait = isExtensionAvailable(VK_KHR_PRESENT_WAIT_EXTENSION_NAME) && isExtensionAvailable(VK_KHR_PRESENT_ID_EXTENSION_NAME); // check for framedebuggers info.debugMarkersSupported = false; @@ -2695,11 +2732,21 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) ClearColorImageRaw(chainInfo.m_swapchainImages[chainInfo.swapchainImageIndex], 0, 0, clearColor, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } + const size_t currentFrameCmdBufferID = GetCurrentCommandBufferId(); + VkSemaphore presentSemaphore = chainInfo.m_presentSemaphores[chainInfo.swapchainImageIndex]; SubmitCommandBuffer(presentSemaphore); // submit all command and signal semaphore cemu_assert_debug(m_numSubmittedCmdBuffers > 0); + // wait for the previous frame to finish rendering + WaitCommandBufferFinished(m_commandBufferIDOfPrevFrame); + m_commandBufferIDOfPrevFrame = currentFrameCmdBufferID; + + chainInfo.WaitAvailableFence(); + + VkPresentIdKHR presentId = {}; + VkPresentInfoKHR presentInfo = {}; presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; presentInfo.swapchainCount = 1; @@ -2709,6 +2756,24 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) presentInfo.waitSemaphoreCount = 1; presentInfo.pWaitSemaphores = &presentSemaphore; + // if present_wait is available and enabled, add frame markers to present requests + // and limit the number of queued present operations + if (m_featureControl.deviceExtensions.present_wait && chainInfo.m_maxQueued > 0) + { + presentId.sType = VK_STRUCTURE_TYPE_PRESENT_ID_KHR; + presentId.swapchainCount = 1; + presentId.pPresentIds = &chainInfo.m_presentId; + + presentInfo.pNext = &presentId; + + if(chainInfo.m_queueDepth >= chainInfo.m_maxQueued) + { + uint64 waitFrameId = chainInfo.m_presentId - chainInfo.m_queueDepth; + vkWaitForPresentKHR(m_logicalDevice, chainInfo.m_swapchain, waitFrameId, 40'000'000); + chainInfo.m_queueDepth--; + } + } + VkResult result = vkQueuePresentKHR(m_presentQueue, &presentInfo); if (result < 0 && result != VK_ERROR_OUT_OF_DATE_KHR) { @@ -2717,6 +2782,12 @@ void VulkanRenderer::SwapBuffer(bool mainWindow) if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) chainInfo.m_shouldRecreate = true; + if(result >= 0) + { + chainInfo.m_queueDepth++; + chainInfo.m_presentId++; + } + chainInfo.hasDefinedSwapchainImage = false; chainInfo.swapchainImageIndex = -1; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 6df53da4..ce97b5e9 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -450,6 +450,7 @@ private: bool synchronization2 = false; // VK_KHR_synchronization2 bool dynamic_rendering = false; // VK_KHR_dynamic_rendering bool shader_float_controls = false; // VK_KHR_shader_float_controls + bool present_wait = false; // VK_KHR_present_wait }deviceExtensions; struct @@ -457,7 +458,7 @@ private: bool shaderRoundingModeRTEFloat32{ false }; }shaderFloatControls; // from VK_KHR_shader_float_controls - struct + struct { bool debug_utils = false; // VK_EXT_DEBUG_UTILS }instanceExtensions; @@ -635,6 +636,7 @@ private: size_t m_commandBufferIndex = 0; // current buffer being filled size_t m_commandBufferSyncIndex = 0; // latest buffer that finished execution (updated on submit) + size_t m_commandBufferIDOfPrevFrame = 0; std::array<VkFence, kCommandBufferPoolSize> m_cmd_buffer_fences; std::array<VkCommandBuffer, kCommandBufferPoolSize> m_commandBuffers; std::array<VkSemaphore, kCommandBufferPoolSize> m_commandBufferSemaphores; From adffd53dbdc86f54803e79dcf06004e688e3b19d Mon Sep 17 00:00:00 2001 From: Andrea Toska <toskaandrea@gmail.com> Date: Mon, 16 Sep 2024 12:40:38 +0200 Subject: [PATCH 254/314] boss: Fix BOSS not honoring the proxy_server setting (#1344) --- src/Cafe/IOSU/legacy/iosu_boss.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Cafe/IOSU/legacy/iosu_boss.cpp b/src/Cafe/IOSU/legacy/iosu_boss.cpp index 760e5b66..7ab25f68 100644 --- a/src/Cafe/IOSU/legacy/iosu_boss.cpp +++ b/src/Cafe/IOSU/legacy/iosu_boss.cpp @@ -137,6 +137,10 @@ namespace iosu this->task_settings.taskType = settings->taskType; curl = std::shared_ptr<CURL>(curl_easy_init(), curl_easy_cleanup); + if(GetConfig().proxy_server.GetValue() != "") + { + curl_easy_setopt(curl.get(), CURLOPT_PROXY, GetConfig().proxy_server.GetValue().c_str()); + } } }; From 8508c625407e80a5a7fcb9cf02c5355d018ff64b Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Tue, 17 Sep 2024 01:00:26 +0100 Subject: [PATCH 255/314] Various smaller code improvements (#1343) --- CMakeLists.txt | 2 +- src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp | 4 +- src/Cafe/OS/libs/nsyshid/Infinity.cpp | 6 +- src/Cafe/OS/libs/ntag/ntag.cpp | 2 +- src/Cafe/OS/libs/snd_core/ax_out.cpp | 8 +- src/Common/MemPtr.h | 160 ++++++++++++------- src/Common/precompiled.h | 48 +++--- src/gui/CemuApp.cpp | 3 + src/util/CMakeLists.txt | 1 - src/util/ThreadPool/ThreadPool.cpp | 0 src/util/containers/robin_hood.h | 2 +- src/util/crypto/crc32.cpp | 55 ++----- src/util/crypto/crc32.h | 4 +- 13 files changed, 153 insertions(+), 142 deletions(-) delete mode 100644 src/util/ThreadPool/ThreadPool.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 54e2012a..5b5cff6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,7 @@ if (ENABLE_CUBEB) option(BUILD_TOOLS "" OFF) option(BUNDLE_SPEEX "" OFF) set(USE_WINMM OFF CACHE BOOL "") - add_subdirectory("dependencies/cubeb" EXCLUDE_FROM_ALL) + add_subdirectory("dependencies/cubeb" EXCLUDE_FROM_ALL SYSTEM) set_property(TARGET cubeb PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") add_library(cubeb::cubeb ALIAS cubeb) endif() diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp index 309394e6..c87cbd39 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp @@ -112,7 +112,7 @@ namespace nn nnResult _Async_OfflineDB_DownloadPostDataListParam_DownloadPostDataList(coreinit::OSEvent* event, DownloadedTopicData* downloadedTopicData, DownloadedPostData* downloadedPostData, uint32be* postCountOut, uint32 maxCount, DownloadPostDataListParam* param) { - scope_exit _se([&](){coreinit::OSSignalEvent(event);}); + stdx::scope_exit _se([&](){coreinit::OSSignalEvent(event);}); uint64 titleId = CafeSystem::GetForegroundTitleId(); @@ -184,7 +184,7 @@ namespace nn nnResult _Async_OfflineDB_DownloadPostDataListParam_DownloadExternalImageData(coreinit::OSEvent* event, DownloadedDataBase* _this, void* imageDataOut, uint32be* imageSizeOut, uint32 maxSize) { - scope_exit _se([&](){coreinit::OSSignalEvent(event);}); + stdx::scope_exit _se([&](){coreinit::OSSignalEvent(event);}); if (!_this->TestFlags(_this, DownloadedDataBase::FLAGS::HAS_EXTERNAL_IMAGE)) return OLV_RESULT_MISSING_DATA; diff --git a/src/Cafe/OS/libs/nsyshid/Infinity.cpp b/src/Cafe/OS/libs/nsyshid/Infinity.cpp index ab44ef4a..ac793109 100644 --- a/src/Cafe/OS/libs/nsyshid/Infinity.cpp +++ b/src/Cafe/OS/libs/nsyshid/Infinity.cpp @@ -1017,11 +1017,7 @@ namespace nsyshid std::array<uint8, 16> InfinityUSB::GenerateInfinityFigureKey(const std::vector<uint8>& sha1Data) { std::array<uint8, 20> digest = {}; - SHA_CTX ctx; - SHA1_Init(&ctx); - SHA1_Update(&ctx, sha1Data.data(), sha1Data.size()); - SHA1_Final(digest.data(), &ctx); - OPENSSL_cleanse(&ctx, sizeof(ctx)); + SHA1(sha1Data.data(), sha1Data.size(), digest.data()); // Infinity AES keys are the first 16 bytes of the SHA1 Digest, every set of 4 bytes need to be // reversed due to endianness std::array<uint8, 16> key = {}; diff --git a/src/Cafe/OS/libs/ntag/ntag.cpp b/src/Cafe/OS/libs/ntag/ntag.cpp index 24617791..7c95a1a1 100644 --- a/src/Cafe/OS/libs/ntag/ntag.cpp +++ b/src/Cafe/OS/libs/ntag/ntag.cpp @@ -509,7 +509,7 @@ namespace ntag noftHeader->writeCount = _swapEndianU16(_swapEndianU16(noftHeader->writeCount) + 1); } - memcpy(decryptedBuffer + 0x20, noftHeader, sizeof(noftHeader)); + memcpy(decryptedBuffer + 0x20, noftHeader, sizeof(NTAGNoftHeader)); memcpy(decryptedBuffer + _swapEndianU16(rwHeader->offset), data, dataSize); // Encrypt diff --git a/src/Cafe/OS/libs/snd_core/ax_out.cpp b/src/Cafe/OS/libs/snd_core/ax_out.cpp index 68b05165..40b9c643 100644 --- a/src/Cafe/OS/libs/snd_core/ax_out.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_out.cpp @@ -522,10 +522,10 @@ namespace snd_core // called periodically to check for AX updates void AXOut_update() { - constexpr auto kTimeout = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(((IAudioAPI::kBlockCount * 3) / 4) * (AX_FRAMES_PER_GROUP * 3))); - constexpr auto kWaitDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(3)); - constexpr auto kWaitDurationFast = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::microseconds(2900)); - constexpr auto kWaitDurationMinimum = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::microseconds(1700)); + constexpr static auto kTimeout = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(((IAudioAPI::kBlockCount * 3) / 4) * (AX_FRAMES_PER_GROUP * 3))); + constexpr static auto kWaitDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(3)); + constexpr static auto kWaitDurationFast = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::microseconds(2900)); + constexpr static auto kWaitDurationMinimum = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::microseconds(1700)); // if we haven't buffered any blocks, we will wait less time than usual bool additional_blocks_required = false; diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index 142da7e4..7825e4d5 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -4,7 +4,7 @@ using MPTR = uint32; // generic address in PowerPC memory space -#define MPTR_NULL (0) +#define MPTR_NULL (0) using VAddr = uint32; // virtual address using PAddr = uint32; // physical address @@ -14,137 +14,175 @@ extern uint8* PPCInterpreterGetStackPointer(); extern uint8* PPCInterpreter_PushAndReturnStackPointer(sint32 offset); extern void PPCInterpreterModifyStackPointer(sint32 offset); -class MEMPTRBase {}; +class MEMPTRBase +{ +}; -template <typename T> +template<typename T> class MEMPTR : MEMPTRBase { -public: - constexpr MEMPTR() - : m_value(0) { } + public: + constexpr MEMPTR() noexcept + : m_value(0) {} - explicit constexpr MEMPTR(uint32 offset) - : m_value(offset) { } + explicit constexpr MEMPTR(uint32 offset) noexcept + : m_value(offset) {} - explicit constexpr MEMPTR(const uint32be& offset) - : m_value(offset) { } + explicit constexpr MEMPTR(const uint32be& offset) noexcept + : m_value(offset) {} - constexpr MEMPTR(std::nullptr_t) - : m_value(0) { } + constexpr MEMPTR(std::nullptr_t) noexcept + : m_value(0) {} - MEMPTR(T* ptr) + MEMPTR(T* ptr) noexcept { if (ptr == nullptr) m_value = 0; else - { - cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000); - m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base); - } + { + cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000); + m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base); + } } - constexpr MEMPTR(const MEMPTR& memptr) - : m_value(memptr.m_value) { } + constexpr MEMPTR(const MEMPTR&) noexcept = default; - constexpr MEMPTR& operator=(const MEMPTR& memptr) - { - m_value = memptr.m_value; - return *this; - } + constexpr MEMPTR& operator=(const MEMPTR&) noexcept = default; - constexpr MEMPTR& operator=(const uint32& offset) + constexpr MEMPTR& operator=(const uint32& offset) noexcept { m_value = offset; return *this; } - constexpr MEMPTR& operator=(const std::nullptr_t rhs) + constexpr MEMPTR& operator=(std::nullptr_t) noexcept { m_value = 0; return *this; } - MEMPTR& operator=(T* ptr) + MEMPTR& operator=(T* ptr) noexcept { - if (ptr == nullptr) + if (ptr == nullptr) m_value = 0; else - { - cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000); - m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base); - } + { + cemu_assert_debug((uint8*)ptr >= memory_base && (uint8*)ptr <= memory_base + 0x100000000); + m_value = (uint32)((uintptr_t)ptr - (uintptr_t)memory_base); + } return *this; } - bool atomic_compare_exchange(T* comparePtr, T* newPtr) + bool atomic_compare_exchange(T* comparePtr, T* newPtr) noexcept { MEMPTR<T> mp_compare = comparePtr; MEMPTR<T> mp_new = newPtr; - std::atomic<uint32be>* thisValueAtomic = (std::atomic<uint32be>*)&m_value; + auto* thisValueAtomic = reinterpret_cast<std::atomic<uint32be>*>(&m_value); return thisValueAtomic->compare_exchange_strong(mp_compare.m_value, mp_new.m_value); } - explicit constexpr operator bool() const noexcept { return m_value != 0; } - - constexpr operator T*() const noexcept { return GetPtr(); } // allow implicit cast to wrapped pointer type + explicit constexpr operator bool() const noexcept + { + return m_value != 0; + } + // allow implicit cast to wrapped pointer type + constexpr operator T*() const noexcept + { + return GetPtr(); + } - template <typename X> - explicit operator MEMPTR<X>() const { return MEMPTR<X>(this->m_value); } + template<typename X> + explicit operator MEMPTR<X>() const noexcept + { + return MEMPTR<X>(this->m_value); + } - MEMPTR operator+(const MEMPTR& ptr) { return MEMPTR(this->GetMPTR() + ptr.GetMPTR()); } - MEMPTR operator-(const MEMPTR& ptr) { return MEMPTR(this->GetMPTR() - ptr.GetMPTR()); } + MEMPTR operator+(const MEMPTR& ptr) noexcept + { + return MEMPTR(this->GetMPTR() + ptr.GetMPTR()); + } + MEMPTR operator-(const MEMPTR& ptr) noexcept + { + return MEMPTR(this->GetMPTR() - ptr.GetMPTR()); + } - MEMPTR operator+(sint32 v) + MEMPTR operator+(sint32 v) noexcept { // pointer arithmetic return MEMPTR(this->GetMPTR() + v * 4); } - MEMPTR operator-(sint32 v) + MEMPTR operator-(sint32 v) noexcept { // pointer arithmetic return MEMPTR(this->GetMPTR() - v * 4); } - MEMPTR& operator+=(sint32 v) + MEMPTR& operator+=(sint32 v) noexcept { m_value += v * sizeof(T); return *this; } - template <class Q = T> - typename std::enable_if<!std::is_same<Q, void>::value, Q>::type& - operator*() const { return *GetPtr(); } + template<typename Q = T> + std::enable_if_t<!std::is_same_v<Q, void>, Q>& operator*() const noexcept + { + return *GetPtr(); + } - T* operator->() const { return GetPtr(); } + constexpr T* operator->() const noexcept + { + return GetPtr(); + } - template <class Q = T> - typename std::enable_if<!std::is_same<Q, void>::value, Q>::type& - operator[](int index) { return GetPtr()[index]; } + template<typename Q = T> + std::enable_if_t<!std::is_same_v<Q, void>, Q>& operator[](int index) noexcept + { + return GetPtr()[index]; + } - T* GetPtr() const { return (T*)(m_value == 0 ? nullptr : memory_base + (uint32)m_value); } + T* GetPtr() const noexcept + { + return (T*)(m_value == 0 ? nullptr : memory_base + (uint32)m_value); + } - template <typename C> - C* GetPtr() const { return (C*)(GetPtr()); } + template<typename C> + C* GetPtr() const noexcept + { + return static_cast<C*>(GetPtr()); + } - constexpr uint32 GetMPTR() const { return m_value.value(); } - constexpr const uint32be& GetBEValue() const { return m_value; } + [[nodiscard]] constexpr uint32 GetMPTR() const noexcept + { + return m_value.value(); + } + [[nodiscard]] constexpr const uint32be& GetBEValue() const noexcept + { + return m_value; + } - constexpr bool IsNull() const { return m_value == 0; } + [[nodiscard]] constexpr bool IsNull() const noexcept + { + return m_value == 0; + } -private: + private: uint32be m_value; }; static_assert(sizeof(MEMPTR<void*>) == sizeof(uint32be)); +static_assert(std::is_trivially_copyable_v<MEMPTR<void*>>); #include "StackAllocator.h" #include "SysAllocator.h" -template <typename T> +template<typename T> struct fmt::formatter<MEMPTR<T>> : formatter<string_view> { - template <typename FormatContext> - auto format(const MEMPTR<T>& v, FormatContext& ctx) const -> format_context::iterator { return fmt::format_to(ctx.out(), "{:#x}", v.GetMPTR()); } + template<typename FormatContext> + auto format(const MEMPTR<T>& v, FormatContext& ctx) const -> format_context::iterator + { + return fmt::format_to(ctx.out(), "{:#x}", v.GetMPTR()); + } }; diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 61707519..d4df4343 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -394,16 +394,10 @@ void vectorRemoveByIndex(std::vector<T>& vec, const size_t index) vec.erase(vec.begin() + index); } -template<typename T1, typename T2> -int match_any_of(T1 value, T2 compareTo) +template<typename T1, typename... Types> +bool match_any_of(T1&& value, Types&&... others) { - return value == compareTo; -} - -template<typename T1, typename T2, typename... Types> -bool match_any_of(T1 value, T2 compareTo, Types&&... others) -{ - return value == compareTo || match_any_of(value, others...); + return ((value == others) || ...); } // we cache the frequency in a static variable @@ -501,13 +495,6 @@ bool future_is_ready(std::future<T>& f) #endif } -// replace with std::scope_exit once available -struct scope_exit -{ - std::function<void()> f_; - explicit scope_exit(std::function<void()> f) noexcept : f_(std::move(f)) {} - ~scope_exit() { if (f_) f_(); } -}; // helper function to cast raw pointers to std::atomic // this is technically not legal but works on most platforms as long as alignment restrictions are met and the implementation of atomic doesnt come with additional members @@ -515,6 +502,8 @@ struct scope_exit template<typename T> std::atomic<T>* _rawPtrToAtomic(T* ptr) { + static_assert(sizeof(T) == sizeof(std::atomic<T>)); + cemu_assert_debug((reinterpret_cast<std::uintptr_t>(ptr) % alignof(std::atomic<T>)) == 0); return reinterpret_cast<std::atomic<T>*>(ptr); } @@ -578,13 +567,34 @@ struct fmt::formatter<betype<T>> : fmt::formatter<T> } }; -// useful C++23 stuff that isn't yet widely supported - -// std::to_underlying +// useful future C++ stuff namespace stdx { + // std::to_underlying template <typename EnumT, typename = std::enable_if_t < std::is_enum<EnumT>{} >> constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept { return static_cast<std::underlying_type_t<EnumT>>(e); }; + + // std::scope_exit + template <typename Fn> + class scope_exit + { + Fn m_func; + bool m_released = false; + public: + explicit scope_exit(Fn&& f) noexcept + : m_func(std::forward<Fn>(f)) + {} + ~scope_exit() + { + if (!m_released) m_func(); + } + scope_exit(scope_exit&& other) noexcept + : m_func(std::move(other.m_func)), m_released(std::exchange(other.m_released, true)) + {} + scope_exit(const scope_exit&) = delete; + scope_exit& operator=(scope_exit) = delete; + void release() { m_released = true;} + }; } \ No newline at end of file diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index f91c1e3a..50ff3b89 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -15,6 +15,9 @@ #if BOOST_OS_LINUX && HAS_WAYLAND #include "gui/helpers/wxWayland.h" #endif +#if __WXGTK__ +#include <glib.h> +#endif #include <wx/image.h> #include <wx/filename.h> diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 5af88176..5ac5ebfd 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -50,7 +50,6 @@ add_library(CemuUtil MemMapper/MemMapper.h SystemInfo/SystemInfo.cpp SystemInfo/SystemInfo.h - ThreadPool/ThreadPool.cpp ThreadPool/ThreadPool.h tinyxml2/tinyxml2.cpp tinyxml2/tinyxml2.h diff --git a/src/util/ThreadPool/ThreadPool.cpp b/src/util/ThreadPool/ThreadPool.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/util/containers/robin_hood.h b/src/util/containers/robin_hood.h index 577521b1..4f76519f 100644 --- a/src/util/containers/robin_hood.h +++ b/src/util/containers/robin_hood.h @@ -194,7 +194,7 @@ namespace robin_hood { // workaround missing "is_trivially_copyable" in g++ < 5.0 // See https://stackoverflow.com/a/31798726/48181 -#if defined(__GNUC__) && __GNUC__ < 5 +#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) # define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) __has_trivial_copy(__VA_ARGS__) #else # define ROBIN_HOOD_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable<__VA_ARGS__>::value diff --git a/src/util/crypto/crc32.cpp b/src/util/crypto/crc32.cpp index 52eb8a88..a5b37a5e 100644 --- a/src/util/crypto/crc32.cpp +++ b/src/util/crypto/crc32.cpp @@ -1,29 +1,6 @@ #include "crc32.h" -#if defined(_MSC_VER) || defined(__MINGW32__) -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __BYTE_ORDER __LITTLE_ENDIAN - -#include <xmmintrin.h> -#ifdef __MINGW32__ -#define PREFETCH(location) __builtin_prefetch(location) -#else -#define PREFETCH(location) _mm_prefetch(location, _MM_HINT_T0) -#endif -#else -// defines __BYTE_ORDER as __LITTLE_ENDIAN or __BIG_ENDIAN -#include <sys/param.h> - -#ifdef __GNUC__ -#define PREFETCH(location) __builtin_prefetch(location) -#else - // no prefetching -#define PREFETCH(location) ; -#endif -#endif - -unsigned int Crc32Lookup[8][256] = +constexpr uint32 Crc32Lookup[8][256] = { { 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3, @@ -301,20 +278,7 @@ unsigned int Crc32Lookup[8][256] = } }; -/// swap endianess -static inline uint32_t swap(uint32_t x) -{ -#if defined(__GNUC__) || defined(__clang__) - return __builtin_bswap32(x); -#else - return (x >> 24) | - ((x >> 8) & 0x0000FF00) | - ((x << 8) & 0x00FF0000) | - (x << 24); -#endif -} - -unsigned int crc32_calc_slice_by_8(unsigned int previousCrc32, const void* data, int length) +uint32 crc32_calc_slice_by_8(uint32 previousCrc32, const void* data, size_t length) { uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF const uint32_t* current = (const uint32_t*)data; @@ -323,7 +287,7 @@ unsigned int crc32_calc_slice_by_8(unsigned int previousCrc32, const void* data, while (length >= 8) { if constexpr (std::endian::native == std::endian::big){ - uint32_t one = *current++ ^ swap(crc); + uint32_t one = *current++ ^ _swapEndianU32(crc); uint32_t two = *current++; crc = Crc32Lookup[0][two & 0xFF] ^ Crc32Lookup[1][(two >> 8) & 0xFF] ^ @@ -348,13 +312,14 @@ unsigned int crc32_calc_slice_by_8(unsigned int previousCrc32, const void* data, Crc32Lookup[7][one & 0xFF]; } else { - cemu_assert(false); + static_assert(std::endian::native == std::endian::big || std::endian::native == std::endian::little, + "Platform byte-order is unsupported"); } length -= 8; } - const uint8_t* currentChar = (const uint8_t*)current; + const uint8* currentChar = (const uint8*)current; // remaining 1 to 7 bytes (standard algorithm) while (length-- != 0) crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++]; @@ -362,20 +327,20 @@ unsigned int crc32_calc_slice_by_8(unsigned int previousCrc32, const void* data, return ~crc; // same as crc ^ 0xFFFFFFFF } -unsigned int crc32_calc(unsigned int c, const void* data, int length) +uint32 crc32_calc(uint32 c, const void* data, size_t length) { if (length >= 16) { return crc32_calc_slice_by_8(c, data, length); } - unsigned char* p = (unsigned char*)data; + const uint8* p = (const uint8*)data; if (length == 0) return c; c ^= 0xFFFFFFFF; while (length) { - unsigned char temp = *p; - temp ^= (unsigned char)c; + uint8 temp = *p; + temp ^= (uint8)c; c = (c >> 8) ^ Crc32Lookup[0][temp]; // next length--; diff --git a/src/util/crypto/crc32.h b/src/util/crypto/crc32.h index b8002261..2ab37376 100644 --- a/src/util/crypto/crc32.h +++ b/src/util/crypto/crc32.h @@ -1,8 +1,8 @@ #pragma once -unsigned int crc32_calc(unsigned int c, const void* data, int length); +uint32 crc32_calc(uint32 c, const void* data, size_t length); -inline unsigned int crc32_calc(const void* data, int length) +inline uint32 crc32_calc(const void* data, size_t length) { return crc32_calc(0, data, length); } \ No newline at end of file From 6dc73f5d797082c25a68ad162377077547948d26 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier <contact@amb.tf> Date: Thu, 3 Oct 2024 06:48:25 +0000 Subject: [PATCH 256/314] Add support for fmt 11 (#1366) --- src/Cemu/Logging/CemuLogging.h | 4 ++++ src/config/CemuConfig.h | 10 +++++----- src/gui/helpers/wxHelpers.h | 2 +- src/input/emulated/EmulatedController.h | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index a671ce51..5b2e5fa4 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -91,7 +91,11 @@ bool cemuLog_log(LogType type, std::basic_string<T> formatStr, TArgs&&... args) else { const auto format_view = fmt::basic_string_view<T>(formatStr); +#if FMT_VERSION >= 110000 + const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffered_context<T>>(args...)); +#else const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(args...)); +#endif cemuLog_log(type, std::basic_string_view(text.data(), text.size())); } return true; diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index e2fbb74c..2f22cd76 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -194,7 +194,7 @@ ENABLE_ENUM_ITERATORS(CrashDump, CrashDump::Disabled, CrashDump::Enabled); template <> struct fmt::formatter<PrecompiledShaderOption> : formatter<string_view> { template <typename FormatContext> - auto format(const PrecompiledShaderOption c, FormatContext &ctx) { + auto format(const PrecompiledShaderOption c, FormatContext &ctx) const { string_view name; switch (c) { @@ -209,7 +209,7 @@ struct fmt::formatter<PrecompiledShaderOption> : formatter<string_view> { template <> struct fmt::formatter<AccurateShaderMulOption> : formatter<string_view> { template <typename FormatContext> - auto format(const AccurateShaderMulOption c, FormatContext &ctx) { + auto format(const AccurateShaderMulOption c, FormatContext &ctx) const { string_view name; switch (c) { @@ -223,7 +223,7 @@ struct fmt::formatter<AccurateShaderMulOption> : formatter<string_view> { template <> struct fmt::formatter<CPUMode> : formatter<string_view> { template <typename FormatContext> - auto format(const CPUMode c, FormatContext &ctx) { + auto format(const CPUMode c, FormatContext &ctx) const { string_view name; switch (c) { @@ -240,7 +240,7 @@ struct fmt::formatter<CPUMode> : formatter<string_view> { template <> struct fmt::formatter<CPUModeLegacy> : formatter<string_view> { template <typename FormatContext> - auto format(const CPUModeLegacy c, FormatContext &ctx) { + auto format(const CPUModeLegacy c, FormatContext &ctx) const { string_view name; switch (c) { @@ -257,7 +257,7 @@ struct fmt::formatter<CPUModeLegacy> : formatter<string_view> { template <> struct fmt::formatter<CafeConsoleRegion> : formatter<string_view> { template <typename FormatContext> - auto format(const CafeConsoleRegion v, FormatContext &ctx) { + auto format(const CafeConsoleRegion v, FormatContext &ctx) const { string_view name; switch (v) { diff --git a/src/gui/helpers/wxHelpers.h b/src/gui/helpers/wxHelpers.h index fa135cf4..9e00bf48 100644 --- a/src/gui/helpers/wxHelpers.h +++ b/src/gui/helpers/wxHelpers.h @@ -8,7 +8,7 @@ template <> struct fmt::formatter<wxString> : formatter<string_view> { template <typename FormatContext> - auto format(const wxString& str, FormatContext& ctx) + auto format(const wxString& str, FormatContext& ctx) const { return formatter<string_view>::format(str.c_str().AsChar(), ctx); } diff --git a/src/input/emulated/EmulatedController.h b/src/input/emulated/EmulatedController.h index 907be07e..c5adf81e 100644 --- a/src/input/emulated/EmulatedController.h +++ b/src/input/emulated/EmulatedController.h @@ -127,7 +127,7 @@ using EmulatedControllerPtr = std::shared_ptr<EmulatedController>; template <> struct fmt::formatter<EmulatedController::Type> : formatter<string_view> { template <typename FormatContext> - auto format(EmulatedController::Type v, FormatContext& ctx) { + auto format(EmulatedController::Type v, FormatContext& ctx) const { switch (v) { case EmulatedController::Type::VPAD: return formatter<string_view>::format("Wii U Gamepad", ctx); From 3acd0c4f2ca328abe80f2d35fb20136e738c84ae Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:03:36 +0200 Subject: [PATCH 257/314] Vulkan: Protect against uniform var ringbuffer overflow (#1378) --- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 8 +- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 4 +- .../Renderer/Vulkan/VulkanRendererCore.cpp | 99 +++++++++++++------ 3 files changed, 75 insertions(+), 36 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 12d1d975..9ad2c5ca 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -1892,6 +1892,7 @@ void VulkanRenderer::ProcessFinishedCommandBuffers() if (fenceStatus == VK_SUCCESS) { ProcessDestructionQueue(); + m_uniformVarBufferReadIndex = m_cmdBufferUniformRingbufIndices[m_commandBufferSyncIndex]; m_commandBufferSyncIndex = (m_commandBufferSyncIndex + 1) % m_commandBuffers.size(); memoryManager->cleanupBuffers(m_countCommandBufferFinished); m_countCommandBufferFinished++; @@ -1985,6 +1986,7 @@ void VulkanRenderer::SubmitCommandBuffer(VkSemaphore signalSemaphore, VkSemaphor cemuLog_logDebug(LogType::Force, "Vulkan: Waiting for available command buffer..."); WaitForNextFinishedCommandBuffer(); } + m_cmdBufferUniformRingbufIndices[nextCmdBufferIndex] = m_cmdBufferUniformRingbufIndices[m_commandBufferIndex]; m_commandBufferIndex = nextCmdBufferIndex; @@ -3562,13 +3564,13 @@ void VulkanRenderer::buffer_bindUniformBuffer(LatteConst::ShaderType shaderType, switch (shaderType) { case LatteConst::ShaderType::Vertex: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX].unformBufferOffset[bufferIndex] = offset; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX].uniformBufferOffset[bufferIndex] = offset; break; case LatteConst::ShaderType::Geometry: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY].unformBufferOffset[bufferIndex] = offset; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY].uniformBufferOffset[bufferIndex] = offset; break; case LatteConst::ShaderType::Pixel: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT].unformBufferOffset[bufferIndex] = offset; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT].uniformBufferOffset[bufferIndex] = offset; break; default: cemu_assert_debug(false); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index ce97b5e9..52c1c6ed 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -591,6 +591,7 @@ private: bool m_uniformVarBufferMemoryIsCoherent{false}; uint8* m_uniformVarBufferPtr = nullptr; uint32 m_uniformVarBufferWriteIndex = 0; + uint32 m_uniformVarBufferReadIndex = 0; // transform feedback ringbuffer VkBuffer m_xfbRingBuffer = VK_NULL_HANDLE; @@ -637,6 +638,7 @@ private: size_t m_commandBufferIndex = 0; // current buffer being filled size_t m_commandBufferSyncIndex = 0; // latest buffer that finished execution (updated on submit) size_t m_commandBufferIDOfPrevFrame = 0; + std::array<size_t, kCommandBufferPoolSize> m_cmdBufferUniformRingbufIndices {}; // index in the uniform ringbuffer std::array<VkFence, kCommandBufferPoolSize> m_cmd_buffer_fences; std::array<VkCommandBuffer, kCommandBufferPoolSize> m_commandBuffers; std::array<VkSemaphore, kCommandBufferPoolSize> m_commandBufferSemaphores; @@ -659,7 +661,7 @@ private: uint32 uniformVarBufferOffset[VulkanRendererConst::SHADER_STAGE_INDEX_COUNT]; struct { - uint32 unformBufferOffset[LATTE_NUM_MAX_UNIFORM_BUFFERS]; + uint32 uniformBufferOffset[LATTE_NUM_MAX_UNIFORM_BUFFERS]; }shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_COUNT]; }dynamicOffsetInfo{}; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 6500f7d3..3a684072 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -375,24 +375,20 @@ float s_vkUniformData[512 * 4]; void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, LatteDecompilerShader* shader) { - auto GET_UNIFORM_DATA_PTR = [&](size_t index) { return s_vkUniformData + (index / 4); }; + auto GET_UNIFORM_DATA_PTR = [](size_t index) { return s_vkUniformData + (index / 4); }; sint32 shaderAluConst; - sint32 shaderUniformRegisterOffset; switch (shader->shaderType) { case LatteConst::ShaderType::Vertex: shaderAluConst = 0x400; - shaderUniformRegisterOffset = mmSQ_VTX_UNIFORM_BLOCK_START; break; case LatteConst::ShaderType::Pixel: shaderAluConst = 0; - shaderUniformRegisterOffset = mmSQ_PS_UNIFORM_BLOCK_START; break; case LatteConst::ShaderType::Geometry: shaderAluConst = 0; // geometry shader has no ALU const - shaderUniformRegisterOffset = mmSQ_GS_UNIFORM_BLOCK_START; break; default: UNREACHABLE; @@ -445,7 +441,7 @@ void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, Latt } if (shader->uniform.loc_verticesPerInstance >= 0) { - *(int*)(s_vkUniformData + ((size_t)shader->uniform.loc_verticesPerInstance / 4)) = m_streamoutState.verticesPerInstance; + *(int*)GET_UNIFORM_DATA_PTR(shader->uniform.loc_verticesPerInstance) = m_streamoutState.verticesPerInstance; for (sint32 b = 0; b < LATTE_NUM_STREAMOUT_BUFFER; b++) { if (shader->uniform.loc_streamoutBufferBase[b] >= 0) @@ -455,26 +451,63 @@ void VulkanRenderer::uniformData_updateUniformVars(uint32 shaderStageIndex, Latt } } // upload - if ((m_uniformVarBufferWriteIndex + shader->uniform.uniformRangeSize + 1024) > UNIFORMVAR_RINGBUFFER_SIZE) + const uint32 bufferAlignmentM1 = std::max(m_featureControl.limits.minUniformBufferOffsetAlignment, m_featureControl.limits.nonCoherentAtomSize) - 1; + const uint32 uniformSize = (shader->uniform.uniformRangeSize + bufferAlignmentM1) & ~bufferAlignmentM1; + + auto waitWhileCondition = [&](std::function<bool()> condition) { + while (condition()) + { + if (m_commandBufferSyncIndex == m_commandBufferIndex) + { + if (m_cmdBufferUniformRingbufIndices[m_commandBufferIndex] != m_uniformVarBufferReadIndex) + { + draw_endRenderPass(); + SubmitCommandBuffer(); + } + else + { + // submitting work would not change readIndex, so there's no way for conditions based on it to change + cemuLog_log(LogType::Force, "draw call overflowed and corrupted uniform ringbuffer. expect visual corruption"); + cemu_assert_suspicious(); + break; + } + } + WaitForNextFinishedCommandBuffer(); + } + }; + + // wrap around if it doesnt fit consecutively + if (m_uniformVarBufferWriteIndex + uniformSize > UNIFORMVAR_RINGBUFFER_SIZE) { + waitWhileCondition([&]() { + return m_uniformVarBufferReadIndex > m_uniformVarBufferWriteIndex || m_uniformVarBufferReadIndex == 0; + }); m_uniformVarBufferWriteIndex = 0; } - uint32 bufferAlignmentM1 = std::max(m_featureControl.limits.minUniformBufferOffsetAlignment, m_featureControl.limits.nonCoherentAtomSize) - 1; + + auto ringBufRemaining = [&]() { + ssize_t ringBufferUsedBytes = (ssize_t)m_uniformVarBufferWriteIndex - m_uniformVarBufferReadIndex; + if (ringBufferUsedBytes < 0) + ringBufferUsedBytes += UNIFORMVAR_RINGBUFFER_SIZE; + return UNIFORMVAR_RINGBUFFER_SIZE - 1 - ringBufferUsedBytes; + }; + waitWhileCondition([&]() { + return ringBufRemaining() < uniformSize; + }); + const uint32 uniformOffset = m_uniformVarBufferWriteIndex; memcpy(m_uniformVarBufferPtr + uniformOffset, s_vkUniformData, shader->uniform.uniformRangeSize); - m_uniformVarBufferWriteIndex += shader->uniform.uniformRangeSize; - m_uniformVarBufferWriteIndex = (m_uniformVarBufferWriteIndex + bufferAlignmentM1) & ~bufferAlignmentM1; + m_uniformVarBufferWriteIndex += uniformSize; // update dynamic offset dynamicOffsetInfo.uniformVarBufferOffset[shaderStageIndex] = uniformOffset; // flush if not coherent if (!m_uniformVarBufferMemoryIsCoherent) { - uint32 nonCoherentAtomSizeM1 = m_featureControl.limits.nonCoherentAtomSize - 1; VkMappedMemoryRange flushedRange{}; flushedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; flushedRange.memory = m_uniformVarBufferMemory; flushedRange.offset = uniformOffset; - flushedRange.size = (shader->uniform.uniformRangeSize + nonCoherentAtomSizeM1) & ~nonCoherentAtomSizeM1; + flushedRange.size = uniformSize; vkFlushMappedMemoryRanges(m_logicalDevice, 1, &flushedRange); } } @@ -494,7 +527,7 @@ void VulkanRenderer::draw_prepareDynamicOffsetsForDescriptorSet(uint32 shaderSta { for (auto& itr : pipeline_info->dynamicOffsetInfo.list_uniformBuffers[shaderStageIndex]) { - dynamicOffsets[numDynOffsets] = dynamicOffsetInfo.shaderUB[shaderStageIndex].unformBufferOffset[itr]; + dynamicOffsets[numDynOffsets] = dynamicOffsetInfo.shaderUB[shaderStageIndex].uniformBufferOffset[itr]; numDynOffsets++; } } @@ -1357,6 +1390,24 @@ void VulkanRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 return; } + // prepare streamout + m_streamoutState.verticesPerInstance = count; + LatteStreamout_PrepareDrawcall(count, instanceCount); + + // update uniform vars + LatteDecompilerShader* vertexShader = LatteSHRC_GetActiveVertexShader(); + LatteDecompilerShader* pixelShader = LatteSHRC_GetActivePixelShader(); + LatteDecompilerShader* geometryShader = LatteSHRC_GetActiveGeometryShader(); + + if (vertexShader) + uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX, vertexShader); + if (pixelShader) + uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT, pixelShader); + if (geometryShader) + uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY, geometryShader); + // store where the read pointer should go after command buffer execution + m_cmdBufferUniformRingbufIndices[m_commandBufferIndex] = m_uniformVarBufferWriteIndex; + // process index data const LattePrimitiveMode primitiveMode = static_cast<LattePrimitiveMode>(LatteGPUState.contextRegister[mmVGT_PRIMITIVE_TYPE]); @@ -1410,22 +1461,6 @@ void VulkanRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 LatteBufferCache_Sync(indexMin + baseVertex, indexMax + baseVertex, baseInstance, instanceCount); } - // prepare streamout - m_streamoutState.verticesPerInstance = count; - LatteStreamout_PrepareDrawcall(count, instanceCount); - - // update uniform vars - LatteDecompilerShader* vertexShader = LatteSHRC_GetActiveVertexShader(); - LatteDecompilerShader* pixelShader = LatteSHRC_GetActivePixelShader(); - LatteDecompilerShader* geometryShader = LatteSHRC_GetActiveGeometryShader(); - - if (vertexShader) - uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX, vertexShader); - if (pixelShader) - uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT, pixelShader); - if (geometryShader) - uniformData_updateUniformVars(VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY, geometryShader); - PipelineInfo* pipeline_info; if (!isFirst) @@ -1613,13 +1648,13 @@ void VulkanRenderer::draw_updateUniformBuffersDirectAccess(LatteDecompilerShader switch (shaderType) { case LatteConst::ShaderType::Vertex: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX].unformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_VERTEX].uniformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; break; case LatteConst::ShaderType::Geometry: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY].unformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_GEOMETRY].uniformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; break; case LatteConst::ShaderType::Pixel: - dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT].unformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; + dynamicOffsetInfo.shaderUB[VulkanRendererConst::SHADER_STAGE_INDEX_FRAGMENT].uniformBufferOffset[bufferIndex] = physicalAddr - m_importedMemBaseAddress; break; default: UNREACHABLE; From d6575455eedf8fc4dbe4bd1b8101361f4257d0c4 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 17 Oct 2024 22:24:01 +0200 Subject: [PATCH 258/314] Linux: Fix crash on invalid command-line arguments use std::cout instead of wxMessageBox which does not work when wxWidgets has not been initialised yet --- src/config/LaunchSettings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index bf38b9cf..32a069c6 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -199,7 +199,11 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args) std::string errorMsg; errorMsg.append("Error while trying to parse command line parameter:\n"); errorMsg.append(ex.what()); +#if BOOST_OS_WINDOWS wxMessageBox(errorMsg, "Parameter error", wxICON_ERROR); +#else + std::cout << errorMsg << std::endl; +#endif return false; } From f9a4b2dbb1ae8de07223a3d988b1605b941f35a8 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:56:56 +0200 Subject: [PATCH 259/314] input: Add option to make `show screen` button a toggle (#1383) --- src/Cafe/CafeSystem.cpp | 2 +- src/Cafe/HW/Latte/Core/Latte.h | 2 +- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 47 ++++++++------------ src/gui/input/panels/VPADInputPanel.cpp | 24 +++++++++- src/gui/input/panels/VPADInputPanel.h | 3 ++ src/input/emulated/VPADController.cpp | 11 +++++ src/input/emulated/VPADController.h | 6 +++ 7 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 958a5a57..51de3550 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -396,7 +396,7 @@ void cemu_initForGame() // replace any known function signatures with our HLE implementations and patch bugs in the games GamePatch_scan(); } - LatteGPUState.alwaysDisplayDRC = ActiveSettings::DisplayDRCEnabled(); + LatteGPUState.isDRCPrimary = ActiveSettings::DisplayDRCEnabled(); InfoLog_PrintActiveSettings(); Latte_Start(); // check for debugger entrypoint bp diff --git a/src/Cafe/HW/Latte/Core/Latte.h b/src/Cafe/HW/Latte/Core/Latte.h index e8cb2be4..e5e9dd5c 100644 --- a/src/Cafe/HW/Latte/Core/Latte.h +++ b/src/Cafe/HW/Latte/Core/Latte.h @@ -52,7 +52,7 @@ struct LatteGPUState_t uint32 gx2InitCalled; // incremented every time GX2Init() is called // OpenGL control uint32 glVendor; // GLVENDOR_* - bool alwaysDisplayDRC = false; + bool isDRCPrimary = false; // temporary (replace with proper solution later) bool tvBufferUsesSRGB; bool drcBufferUsesSRGB; diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 60124c02..ca6a2a4d 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -989,8 +989,6 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa g_renderer->ImguiEnd(); } -bool ctrlTabHotkeyPressed = false; - void LatteRenderTarget_itHLECopyColorBufferToScanBuffer(MPTR colorBufferPtr, uint32 colorBufferWidth, uint32 colorBufferHeight, uint32 colorBufferSliceIndex, uint32 colorBufferFormat, uint32 colorBufferPitch, Latte::E_HWTILEMODE colorBufferTilemode, uint32 colorBufferSwizzle, uint32 renderTarget) { cemu_assert_debug(colorBufferSliceIndex == 0); // todo - support for non-zero slice @@ -1000,38 +998,31 @@ void LatteRenderTarget_itHLECopyColorBufferToScanBuffer(MPTR colorBufferPtr, uin return; } + auto getVPADScreenActive = [](size_t n) -> std::pair<bool, bool> { + auto controller = InputManager::instance().get_vpad_controller(n); + if (!controller) + return {false,false}; + auto pressed = controller->is_screen_active(); + auto toggle = controller->is_screen_active_toggle(); + return {pressed && !toggle, pressed && toggle}; + }; + const bool tabPressed = gui_isKeyDown(PlatformKeyCodes::TAB); const bool ctrlPressed = gui_isKeyDown(PlatformKeyCodes::LCONTROL); + const auto [vpad0Active, vpad0Toggle] = getVPADScreenActive(0); + const auto [vpad1Active, vpad1Toggle] = getVPADScreenActive(1); - bool showDRC = swkbd_hasKeyboardInputHook() == false && tabPressed; - bool& alwaysDisplayDRC = LatteGPUState.alwaysDisplayDRC; + const bool altScreenRequested = (!ctrlPressed && tabPressed) || vpad0Active || vpad1Active; + const bool togglePressed = (ctrlPressed && tabPressed) || vpad0Toggle || vpad1Toggle; + static bool togglePressedLast = false; - if (ctrlPressed && tabPressed) - { - if (ctrlTabHotkeyPressed == false) - { - alwaysDisplayDRC = !alwaysDisplayDRC; - ctrlTabHotkeyPressed = true; - } - } - else - ctrlTabHotkeyPressed = false; + bool& isDRCPrimary = LatteGPUState.isDRCPrimary; - if (alwaysDisplayDRC) - showDRC = !tabPressed; + if(togglePressed && !togglePressedLast) + isDRCPrimary = !isDRCPrimary; + togglePressedLast = togglePressed; - if (!showDRC) - { - auto controller = InputManager::instance().get_vpad_controller(0); - if (controller && controller->is_screen_active()) - showDRC = true; - if (!showDRC) - { - controller = InputManager::instance().get_vpad_controller(1); - if (controller && controller->is_screen_active()) - showDRC = true; - } - } + bool showDRC = swkbd_hasKeyboardInputHook() == false && (isDRCPrimary ^ altScreenRequested); if ((renderTarget & RENDER_TARGET_DRC) && g_renderer->IsPadWindowActive()) LatteRenderTarget_copyToBackbuffer(texView, true); diff --git a/src/gui/input/panels/VPADInputPanel.cpp b/src/gui/input/panels/VPADInputPanel.cpp index fbcdfde4..9e6d75d6 100644 --- a/src/gui/input/panels/VPADInputPanel.cpp +++ b/src/gui/input/panels/VPADInputPanel.cpp @@ -5,6 +5,7 @@ #include <wx/statline.h> #include <wx/textctrl.h> #include <wx/slider.h> +#include <wx/checkbox.h> #include "gui/helpers/wxControlObject.h" @@ -131,11 +132,23 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent) } // Blow Mic - row = 9; + row = 8; add_button_row(main_sizer, row, column, VPADController::kButtonId_Mic, _("blow mic")); row++; add_button_row(main_sizer, row, column, VPADController::kButtonId_Screen, _("show screen")); + row++; + + auto toggleScreenText = new wxStaticText(this, wxID_ANY, _("toggle screen")); + main_sizer->Add(toggleScreenText, + wxGBPosition(row, column), + wxDefaultSpan, + wxALL | wxALIGN_CENTER_VERTICAL, 5); + m_togglePadViewCheckBox = new wxCheckBox(this, wxID_ANY, {}, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + wxString toggleScreenTT = _("Makes the \"show screen\" button toggle between the TV and gamepad screens"); + m_togglePadViewCheckBox->SetToolTip(toggleScreenTT); + toggleScreenText->SetToolTip(toggleScreenTT); + main_sizer->Add(m_togglePadViewCheckBox, wxGBPosition(row,column+1), wxDefaultSpan, wxALL | wxEXPAND, 5); ////////////////////////////////////////////////////////////////// @@ -168,6 +181,8 @@ void VPADInputPanel::on_timer(const EmulatedControllerPtr& emulated_controller, { InputPanel::on_timer(emulated_controller, controller_base); + static_cast<VPADController*>(emulated_controller.get())->set_screen_toggle(m_togglePadViewCheckBox->GetValue()); + if(emulated_controller) { const auto axis = emulated_controller->get_axis(); @@ -182,3 +197,10 @@ void VPADInputPanel::OnVolumeChange(wxCommandEvent& event) { } +void VPADInputPanel::load_controller(const EmulatedControllerPtr& controller) +{ + InputPanel::load_controller(controller); + + const bool isToggle = static_cast<VPADController*>(controller.get())->is_screen_active_toggle(); + m_togglePadViewCheckBox->SetValue(isToggle); +} diff --git a/src/gui/input/panels/VPADInputPanel.h b/src/gui/input/panels/VPADInputPanel.h index 3513bbf7..477385f4 100644 --- a/src/gui/input/panels/VPADInputPanel.h +++ b/src/gui/input/panels/VPADInputPanel.h @@ -4,6 +4,7 @@ #include "gui/input/panels/InputPanel.h" class wxInputDraw; +class wxCheckBox; class VPADInputPanel : public InputPanel { @@ -11,11 +12,13 @@ public: VPADInputPanel(wxWindow* parent); void on_timer(const EmulatedControllerPtr& emulated_controller, const ControllerPtr& controller) override; + virtual void load_controller(const EmulatedControllerPtr& controller) override; private: void OnVolumeChange(wxCommandEvent& event); wxInputDraw* m_left_draw, * m_right_draw; + wxCheckBox* m_togglePadViewCheckBox; void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const VPADController::ButtonId &button_id); void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const VPADController::ButtonId &button_id, const wxString &label); diff --git a/src/input/emulated/VPADController.cpp b/src/input/emulated/VPADController.cpp index aeb56395..f1ab1bc4 100644 --- a/src/input/emulated/VPADController.cpp +++ b/src/input/emulated/VPADController.cpp @@ -686,3 +686,14 @@ bool VPADController::set_default_mapping(const std::shared_ptr<ControllerBase>& return mapping_updated; } + +void VPADController::load(const pugi::xml_node& node) +{ + if (const auto value = node.child("toggle_display")) + m_screen_active_toggle = ConvertString<bool>(value.child_value()); +} + +void VPADController::save(pugi::xml_node& node) +{ + node.append_child("toggle_display").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (int)m_screen_active_toggle).c_str()); +} diff --git a/src/input/emulated/VPADController.h b/src/input/emulated/VPADController.h index 6aef16ae..937062da 100644 --- a/src/input/emulated/VPADController.h +++ b/src/input/emulated/VPADController.h @@ -66,6 +66,8 @@ public: bool is_mic_active() { return m_mic_active; } bool is_screen_active() { return m_screen_active; } + bool is_screen_active_toggle() { return m_screen_active_toggle; } + void set_screen_toggle(bool toggle) {m_screen_active_toggle = toggle;} static std::string_view get_button_name(ButtonId id); @@ -86,9 +88,13 @@ public: bool set_default_mapping(const std::shared_ptr<ControllerBase>& controller) override; + void load(const pugi::xml_node& node) override; + void save(pugi::xml_node& node) override; + private: bool m_mic_active = false; bool m_screen_active = false; + bool m_screen_active_toggle = false; uint32be m_last_holdvalue = 0; std::chrono::high_resolution_clock::time_point m_last_hold_change{}, m_last_pulse{}; From 63e1289bb518562ae62033389610a1e772e63c8b Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Fri, 25 Oct 2024 17:48:21 +0100 Subject: [PATCH 260/314] Windows: Save icons to Cemu user data directory (#1390) --- src/gui/components/wxGameList.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/components/wxGameList.cpp b/src/gui/components/wxGameList.cpp index eedfde5d..6cbb5859 100644 --- a/src/gui/components/wxGameList.cpp +++ b/src/gui/components/wxGameList.cpp @@ -1392,7 +1392,6 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) const auto outputPath = shortcutDialog.GetPath(); std::optional<fs::path> icon_path = std::nullopt; - [&]() { int iconIdx; int smallIconIdx; @@ -1402,15 +1401,13 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) return; } const auto icon = m_image_list->GetIcon(iconIdx); - PWSTR localAppData; - const auto hres = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &localAppData); - wxBitmap bitmap{}; - auto folder = fs::path(localAppData) / "Cemu" / "icons"; - if (!SUCCEEDED(hres) || (!fs::exists(folder) && !fs::create_directories(folder))) + const auto folder = ActiveSettings::GetUserDataPath("icons"); + if (!fs::exists(folder) && !fs::create_directories(folder)) { cemuLog_log(LogType::Force, "Failed to create icon directory"); return; } + wxBitmap bitmap{}; if (!bitmap.CopyFromIcon(icon)) { cemuLog_log(LogType::Force, "Failed to copy icon"); @@ -1426,7 +1423,7 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo) icon_path = std::nullopt; cemuLog_log(LogType::Force, "Icon failed to save"); } - }(); + } IShellLinkW* shellLink; HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast<LPVOID*>(&shellLink)); From 459fd5d9bb4897381c4d7d326302ca707c7b818c Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:37:30 +0100 Subject: [PATCH 261/314] input: Fix crash when closing add controller dialog before search completes (#1386) --- src/gui/input/InputAPIAddWindow.cpp | 43 ++++++++++++++++++++++------- src/gui/input/InputAPIAddWindow.h | 9 ++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/gui/input/InputAPIAddWindow.cpp b/src/gui/input/InputAPIAddWindow.cpp index a6d1f1a9..688ee14e 100644 --- a/src/gui/input/InputAPIAddWindow.cpp +++ b/src/gui/input/InputAPIAddWindow.cpp @@ -114,6 +114,11 @@ InputAPIAddWindow::InputAPIAddWindow(wxWindow* parent, const wxPoint& position, this->Bind(wxControllersRefreshed, &InputAPIAddWindow::on_controllers_refreshed, this); } +InputAPIAddWindow::~InputAPIAddWindow() +{ + discard_thread_result(); +} + void InputAPIAddWindow::on_add_button(wxCommandEvent& event) { const auto selection = m_input_api->GetSelection(); @@ -159,6 +164,8 @@ std::unique_ptr<ControllerProviderSettings> InputAPIAddWindow::get_settings() co void InputAPIAddWindow::on_api_selected(wxCommandEvent& event) { + discard_thread_result(); + if (m_input_api->GetSelection() == wxNOT_FOUND) return; @@ -239,19 +246,25 @@ void InputAPIAddWindow::on_controller_dropdown(wxCommandEvent& event) m_controller_list->Append(_("Searching for controllers..."), (wxClientData*)nullptr); m_controller_list->SetSelection(wxNOT_FOUND); - std::thread([this, provider, selected_uuid]() + m_search_thread_data = std::make_unique<AsyncThreadData>(); + std::thread([this, provider, selected_uuid](std::shared_ptr<AsyncThreadData> data) { auto available_controllers = provider->get_controllers(); - wxCommandEvent event(wxControllersRefreshed); - event.SetEventObject(m_controller_list); - event.SetClientObject(new wxCustomData(std::move(available_controllers))); - event.SetInt(provider->api()); - event.SetString(selected_uuid); - wxPostEvent(this, event); - - m_search_running = false; - }).detach(); + { + std::lock_guard lock{data->mutex}; + if(!data->discardResult) + { + wxCommandEvent event(wxControllersRefreshed); + event.SetEventObject(m_controller_list); + event.SetClientObject(new wxCustomData(std::move(available_controllers))); + event.SetInt(provider->api()); + event.SetString(selected_uuid); + wxPostEvent(this, event); + m_search_running = false; + } + } + }, m_search_thread_data).detach(); } void InputAPIAddWindow::on_controller_selected(wxCommandEvent& event) @@ -301,3 +314,13 @@ void InputAPIAddWindow::on_controllers_refreshed(wxCommandEvent& event) } } } + +void InputAPIAddWindow::discard_thread_result() +{ + m_search_running = false; + if(m_search_thread_data) + { + std::lock_guard lock{m_search_thread_data->mutex}; + m_search_thread_data->discardResult = true; + } +} diff --git a/src/gui/input/InputAPIAddWindow.h b/src/gui/input/InputAPIAddWindow.h index ebee0592..085dd623 100644 --- a/src/gui/input/InputAPIAddWindow.h +++ b/src/gui/input/InputAPIAddWindow.h @@ -19,6 +19,7 @@ class InputAPIAddWindow : public wxDialog { public: InputAPIAddWindow(wxWindow* parent, const wxPoint& position, const std::vector<ControllerPtr>& controllers); + ~InputAPIAddWindow(); bool is_valid() const { return m_type.has_value() && m_controller != nullptr; } InputAPI::Type get_type() const { return m_type.value(); } @@ -38,6 +39,8 @@ private: void on_controller_selected(wxCommandEvent& event); void on_controllers_refreshed(wxCommandEvent& event); + void discard_thread_result(); + wxChoice* m_input_api; wxComboBox* m_controller_list; wxButton* m_ok_button; @@ -50,4 +53,10 @@ private: std::vector<ControllerPtr> m_controllers; std::atomic_bool m_search_running = false; + struct AsyncThreadData + { + std::atomic_bool discardResult = false; + std::mutex mutex; + }; + std::shared_ptr<AsyncThreadData> m_search_thread_data; }; From 47001ad23349fae130d6faae9409117899eb11cc Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Wed, 30 Oct 2024 22:10:32 +0000 Subject: [PATCH 262/314] Make `MEMPTR<T>` a little more `T*`-like (#1385) --- src/Common/MemPtr.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index 7825e4d5..2dc92040 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -98,35 +98,36 @@ class MEMPTR : MEMPTRBase return MEMPTR<X>(this->m_value); } - MEMPTR operator+(const MEMPTR& ptr) noexcept + sint32 operator-(const MEMPTR& ptr) noexcept + requires(!std::is_void_v<T>) { - return MEMPTR(this->GetMPTR() + ptr.GetMPTR()); - } - MEMPTR operator-(const MEMPTR& ptr) noexcept - { - return MEMPTR(this->GetMPTR() - ptr.GetMPTR()); + return static_cast<sint32>(this->GetMPTR() - ptr.GetMPTR()); } MEMPTR operator+(sint32 v) noexcept + requires(!std::is_void_v<T>) { // pointer arithmetic - return MEMPTR(this->GetMPTR() + v * 4); + return MEMPTR(this->GetMPTR() + v * sizeof(T)); } MEMPTR operator-(sint32 v) noexcept + requires(!std::is_void_v<T>) { // pointer arithmetic - return MEMPTR(this->GetMPTR() - v * 4); + return MEMPTR(this->GetMPTR() - v * sizeof(T)); } MEMPTR& operator+=(sint32 v) noexcept + requires(!std::is_void_v<T>) { m_value += v * sizeof(T); return *this; } template<typename Q = T> - std::enable_if_t<!std::is_same_v<Q, void>, Q>& operator*() const noexcept + requires(!std::is_void_v<Q>) + Q& operator*() const noexcept { return *GetPtr(); } @@ -137,7 +138,8 @@ class MEMPTR : MEMPTRBase } template<typename Q = T> - std::enable_if_t<!std::is_same_v<Q, void>, Q>& operator[](int index) noexcept + requires(!std::is_void_v<Q>) + Q& operator[](int index) noexcept { return GetPtr()[index]; } From 1c49a8a1ba8fea6e656c1d535f35e316bc29da76 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:47:19 +0100 Subject: [PATCH 263/314] nn_nfp: Implement GetNfpReadOnlyInfo and fix deactivate event Fixes Amiibos not being detected in MK8 --- src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp | 102 +++++++++++++++++------------ 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp index 10d9e7cb..38e0c4fe 100644 --- a/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp +++ b/src/Cafe/OS/libs/nn_nfp/nn_nfp.cpp @@ -334,45 +334,63 @@ void nnNfpExport_MountRom(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0)); } -typedef struct +namespace nn::nfp { - /* +0x00 */ uint8 characterId[3]; - /* +0x03 */ uint8 amiiboSeries; - /* +0x04 */ uint16be number; - /* +0x06 */ uint8 nfpType; - /* +0x07 */ uint8 unused[0x2F]; -}nfpRomInfo_t; - -static_assert(offsetof(nfpRomInfo_t, amiiboSeries) == 0x3, "nfpRomInfo.seriesId has invalid offset"); -static_assert(offsetof(nfpRomInfo_t, number) == 0x4, "nfpRomInfo.number has invalid offset"); -static_assert(offsetof(nfpRomInfo_t, nfpType) == 0x6, "nfpRomInfo.nfpType has invalid offset"); -static_assert(sizeof(nfpRomInfo_t) == 0x36, "nfpRomInfo_t has invalid size"); - -void nnNfpExport_GetNfpRomInfo(PPCInterpreter_t* hCPU) -{ - cemuLog_log(LogType::NN_NFP, "GetNfpRomInfo(0x{:08x})", hCPU->gpr[3]); - ppcDefineParamStructPtr(romInfo, nfpRomInfo_t, 0); - - nnNfpLock(); - if (nfp_data.hasActiveAmiibo == false) + struct RomInfo { - nnNfpUnlock(); - osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0)); // todo: Return correct error code - return; + /* +0x00 */ uint8 characterId[3]; + /* +0x03 */ uint8 amiiboSeries; + /* +0x04 */ uint16be number; + /* +0x06 */ uint8 nfpType; + /* +0x07 */ uint8 unused[0x2F]; + }; + + static_assert(offsetof(RomInfo, amiiboSeries) == 0x3); + static_assert(offsetof(RomInfo, number) == 0x4); + static_assert(offsetof(RomInfo, nfpType) == 0x6); + static_assert(sizeof(RomInfo) == 0x36); + + using ReadOnlyInfo = RomInfo; // same layout + + void GetRomInfo(RomInfo* romInfo) + { + cemu_assert_debug(nfp_data.hasActiveAmiibo); + memset(romInfo, 0x00, sizeof(RomInfo)); + romInfo->characterId[0] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.gameAndCharacterId[0]; + romInfo->characterId[1] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.gameAndCharacterId[1]; + romInfo->characterId[2] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.characterVariation; // guessed + romInfo->amiiboSeries = nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboSeries; // guessed + romInfo->number = *(uint16be*)nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboModelNumber; // guessed + romInfo->nfpType = nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboFigureType; // guessed + memset(romInfo->unused, 0x00, sizeof(romInfo->unused)); } - memset(romInfo, 0x00, sizeof(nfpRomInfo_t)); - romInfo->characterId[0] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.gameAndCharacterId[0]; - romInfo->characterId[1] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.gameAndCharacterId[1]; - romInfo->characterId[2] = nfp_data.amiiboNFCData.amiiboIdentificationBlock.characterVariation; // guessed + nnResult GetNfpRomInfo(RomInfo* romInfo) + { + nnNfpLock(); + if (nfp_data.hasActiveAmiibo == false) + { + nnNfpUnlock(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0); // todo: Return correct error code + } + GetRomInfo(romInfo); + nnNfpUnlock(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0); + } - romInfo->amiiboSeries = nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboSeries; // guessed - romInfo->number = *(uint16be*)nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboModelNumber; // guessed - romInfo->nfpType = nfp_data.amiiboNFCData.amiiboIdentificationBlock.amiiboFigureType; // guessed - - nnNfpUnlock(); - osLib_returnFromFunction(hCPU, BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0)); -} + nnResult GetNfpReadOnlyInfo(ReadOnlyInfo* readOnlyInfo) + { + nnNfpLock(); + if (nfp_data.hasActiveAmiibo == false) + { + nnNfpUnlock(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_NFP, 0); // todo: Return correct error code + } + GetRomInfo(readOnlyInfo); + nnNfpUnlock(); + return BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_NFP, 0); + } +}; typedef struct { @@ -880,13 +898,13 @@ void nnNfp_update() if (amiiboElapsedTouchTime >= 1500) { nnNfp_unloadAmiibo(); + if (nfp_data.deactivateEvent) + { + coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset(nfp_data.deactivateEvent); + coreinit::OSSignalEvent(osEvent); + } } nnNfpUnlock(); - if (nfp_data.deactivateEvent) - { - coreinit::OSEvent* osEvent = (coreinit::OSEvent*)memory_getPointerFromVirtualOffset(nfp_data.deactivateEvent); - coreinit::OSSignalEvent(osEvent); - } } void nnNfpExport_GetNfpState(PPCInterpreter_t* hCPU) @@ -1001,8 +1019,6 @@ namespace nn::nfp osLib_addFunction("nn_nfp", "Mount__Q2_2nn3nfpFv", nnNfpExport_Mount); osLib_addFunction("nn_nfp", "MountRom__Q2_2nn3nfpFv", nnNfpExport_MountRom); osLib_addFunction("nn_nfp", "Unmount__Q2_2nn3nfpFv", nnNfpExport_Unmount); - - osLib_addFunction("nn_nfp", "GetNfpRomInfo__Q2_2nn3nfpFPQ3_2nn3nfp7RomInfo", nnNfpExport_GetNfpRomInfo); osLib_addFunction("nn_nfp", "GetNfpCommonInfo__Q2_2nn3nfpFPQ3_2nn3nfp10CommonInfo", nnNfpExport_GetNfpCommonInfo); osLib_addFunction("nn_nfp", "GetNfpRegisterInfo__Q2_2nn3nfpFPQ3_2nn3nfp12RegisterInfo", nnNfpExport_GetNfpRegisterInfo); @@ -1028,7 +1044,9 @@ namespace nn::nfp { nnNfp_load(); // legacy interface, update these to use cafeExportRegister / cafeExportRegisterFunc - cafeExportRegisterFunc(nn::nfp::GetErrorCode, "nn_nfp", "GetErrorCode__Q2_2nn3nfpFRCQ2_2nn6Result", LogType::Placeholder); + cafeExportRegisterFunc(nn::nfp::GetErrorCode, "nn_nfp", "GetErrorCode__Q2_2nn3nfpFRCQ2_2nn6Result", LogType::NN_NFP); + cafeExportRegisterFunc(nn::nfp::GetNfpRomInfo, "nn_nfp", "GetNfpRomInfo__Q2_2nn3nfpFPQ3_2nn3nfp7RomInfo", LogType::NN_NFP); + cafeExportRegisterFunc(nn::nfp::GetNfpReadOnlyInfo, "nn_nfp", "GetNfpReadOnlyInfo__Q2_2nn3nfpFPQ3_2nn3nfp12ReadOnlyInfo", LogType::NN_NFP); } } From 9941e00b545a9c99a8e62c8c33ebe790d38de26e Mon Sep 17 00:00:00 2001 From: SamoZ256 <96914946+SamoZ256@users.noreply.github.com> Date: Tue, 5 Nov 2024 22:22:00 +0100 Subject: [PATCH 264/314] macOS: Fix libusb path for bundle (#1403) --- src/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d64d91b..84d4fcad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,12 +101,18 @@ if (MACOS_BUNDLE) COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/bin/${folder}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/SharedSupport/${folder}") endforeach(folder) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/debug/lib/libusb-1.0.0.dylib") + else() + set(LIBUSB_PATH "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib") + endif() + add_custom_command (TARGET CemuBin POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib" - COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_BINARY_DIR}/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${LIBUSB_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh" COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}" - COMMAND bash -c "install_name_tool -change /Users/runner/work/Cemu/Cemu/build/vcpkg_installed/x64-osx/lib/libusb-1.0.0.dylib @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") + COMMAND bash -c "install_name_tool -change ${LIBUSB_PATH} ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() set_target_properties(CemuBin PROPERTIES From 813f9148b1afe75053102877e3db5733f701660e Mon Sep 17 00:00:00 2001 From: SamoZ256 <96914946+SamoZ256@users.noreply.github.com> Date: Thu, 7 Nov 2024 07:09:35 +0100 Subject: [PATCH 265/314] macOS: Fix absolute path to libusb dylib (#1405) --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84d4fcad..3792ab85 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,7 +112,7 @@ if (MACOS_BUNDLE) COMMAND ${CMAKE_COMMAND} ARGS -E copy "${LIBUSB_PATH}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib" COMMAND ${CMAKE_COMMAND} ARGS -E copy "${CMAKE_SOURCE_DIR}/src/resource/update.sh" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/update.sh" COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}" - COMMAND bash -c "install_name_tool -change ${LIBUSB_PATH} ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") + COMMAND bash -c "install_name_tool -change ${LIBUSB_PATH} @executable_path/../Frameworks/libusb-1.0.0.dylib ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}") endif() set_target_properties(CemuBin PROPERTIES From 4ac1ab162a2a2734a4b1839e57ff367233e16853 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Sat, 9 Nov 2024 05:21:06 +0000 Subject: [PATCH 266/314] procui: swap `tickDelay` and `priority` args in callbacks (#1408) --- src/Cafe/OS/libs/proc_ui/proc_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp index dd9a460f..ff38abbb 100644 --- a/src/Cafe/OS/libs/proc_ui/proc_ui.cpp +++ b/src/Cafe/OS/libs/proc_ui/proc_ui.cpp @@ -427,7 +427,7 @@ namespace proc_ui } if(callbackType != ProcUICallbackId::AcquireForeground) priority = -priority; - AddCallbackInternal(funcPtr, userParam, priority, 0, s_CallbackTables[stdx::to_underlying(callbackType)][coreIndex]); + AddCallbackInternal(funcPtr, userParam, 0, priority, s_CallbackTables[stdx::to_underlying(callbackType)][coreIndex]); } void ProcUIRegisterCallback(ProcUICallbackId callbackType, void* funcPtr, void* userParam, sint32 priority) @@ -437,7 +437,7 @@ namespace proc_ui void ProcUIRegisterBackgroundCallback(void* funcPtr, void* userParam, uint64 tickDelay) { - AddCallbackInternal(funcPtr, userParam, 0, tickDelay, s_backgroundCallbackList); + AddCallbackInternal(funcPtr, userParam, tickDelay, 0, s_backgroundCallbackList); } void FreeCallbackChain(ProcUICallbackList& callbackList) From 2e829479d9f63dcfbd8ef67d456793a70f684b18 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Sat, 9 Nov 2024 05:22:13 +0000 Subject: [PATCH 267/314] nsyshid/libusb: correct error message formatting and print error string on open fail (#1407) --- src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp index 7548c998..ab355136 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -15,7 +15,7 @@ namespace nsyshid::backend::libusb if (m_initReturnCode < 0) { m_ctx = nullptr; - cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: failed to initialize libusb with return code %i", + cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: failed to initialize libusb, return code: {}", m_initReturnCode); return; } @@ -35,7 +35,7 @@ namespace nsyshid::backend::libusb if (ret != LIBUSB_SUCCESS) { cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb: failed to register hotplug callback with return code %i", + "nsyshid::BackendLibusb: failed to register hotplug callback with return code {}", ret); } else @@ -415,7 +415,7 @@ namespace nsyshid::backend::libusb if (ret < 0) { cemuLog_log(LogType::Force, - "nsyshid::DeviceLibusb::open(): failed to get device descriptor; return code: %i", + "nsyshid::DeviceLibusb::open(): failed to get device descriptor, return code: {}", ret); libusb_free_device_list(devices, 1); return false; @@ -439,8 +439,8 @@ namespace nsyshid::backend::libusb { this->m_libusbHandle = nullptr; cemuLog_log(LogType::Force, - "nsyshid::DeviceLibusb::open(): failed to open device; return code: %i", - ret); + "nsyshid::DeviceLibusb::open(): failed to open device: {}", + libusb_strerror(ret)); libusb_free_device_list(devices, 1); return false; } From ca2e0a7c31dcaeac110dc4aa703a992b55c8155f Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Mon, 11 Nov 2024 07:58:01 +0000 Subject: [PATCH 268/314] nsyshid: Add support for emulated Dimensions Toypad (#1371) --- src/Cafe/CMakeLists.txt | 2 + src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp | 9 + src/Cafe/OS/libs/nsyshid/Dimensions.cpp | 1162 +++++++++++++++++ src/Cafe/OS/libs/nsyshid/Dimensions.h | 108 ++ src/config/CemuConfig.cpp | 2 + src/config/CemuConfig.h | 1 + .../EmulatedUSBDeviceFrame.cpp | 410 +++++- .../EmulatedUSBDeviceFrame.h | 48 +- 8 files changed, 1690 insertions(+), 52 deletions(-) create mode 100644 src/Cafe/OS/libs/nsyshid/Dimensions.cpp create mode 100644 src/Cafe/OS/libs/nsyshid/Dimensions.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 91d257b2..0901fece 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -465,6 +465,8 @@ add_library(CemuCafe OS/libs/nsyshid/BackendLibusb.h OS/libs/nsyshid/BackendWindowsHID.cpp OS/libs/nsyshid/BackendWindowsHID.h + OS/libs/nsyshid/Dimensions.cpp + OS/libs/nsyshid/Dimensions.h OS/libs/nsyshid/Infinity.cpp OS/libs/nsyshid/Infinity.h OS/libs/nsyshid/Skylander.cpp diff --git a/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp index 95eaf06a..533d349e 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendEmulated.cpp @@ -1,4 +1,6 @@ #include "BackendEmulated.h" + +#include "Dimensions.h" #include "Infinity.h" #include "Skylander.h" #include "config/CemuConfig.h" @@ -33,5 +35,12 @@ namespace nsyshid::backend::emulated auto device = std::make_shared<InfinityBaseDevice>(); AttachDevice(device); } + if (GetConfig().emulated_usb_devices.emulate_dimensions_toypad && !FindDeviceById(0x0E6F, 0x0241)) + { + cemuLog_logDebug(LogType::Force, "Attaching Emulated Toypad"); + // Add Dimensions Toypad + auto device = std::make_shared<DimensionsToypadDevice>(); + AttachDevice(device); + } } } // namespace nsyshid::backend::emulated \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Dimensions.cpp b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp new file mode 100644 index 00000000..f328dde7 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp @@ -0,0 +1,1162 @@ +#include "Dimensions.h" + +#include "nsyshid.h" +#include "Backend.h" + +#include "Common/FileStream.h" + +#include <array> +#include <random> + +namespace nsyshid +{ + static constexpr std::array<uint8, 16> COMMAND_KEY = {0x55, 0xFE, 0xF6, 0xB0, 0x62, 0xBF, 0x0B, 0x41, + 0xC9, 0xB3, 0x7C, 0xB4, 0x97, 0x3E, 0x29, 0x7B}; + + static constexpr std::array<uint8, 17> CHAR_CONSTANT = {0xB7, 0xD5, 0xD7, 0xE6, 0xE7, 0xBA, 0x3C, 0xA8, + 0xD8, 0x75, 0x47, 0x68, 0xCF, 0x23, 0xE9, 0xFE, 0xAA}; + + static constexpr std::array<uint8, 25> PWD_CONSTANT = {0x28, 0x63, 0x29, 0x20, 0x43, 0x6F, 0x70, 0x79, + 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x4C, 0x45, + 0x47, 0x4F, 0x20, 0x32, 0x30, 0x31, 0x34, 0xAA, 0xAA}; + + DimensionsUSB g_dimensionstoypad; + + const std::map<const uint32, const char*> s_listMinis = { + {0, "Blank Tag"}, + {1, "Batman"}, + {2, "Gandalf"}, + {3, "Wyldstyle"}, + {4, "Aquaman"}, + {5, "Bad Cop"}, + {6, "Bane"}, + {7, "Bart Simpson"}, + {8, "Benny"}, + {9, "Chell"}, + {10, "Cole"}, + {11, "Cragger"}, + {12, "Cyborg"}, + {13, "Cyberman"}, + {14, "Doc Brown"}, + {15, "The Doctor"}, + {16, "Emmet"}, + {17, "Eris"}, + {18, "Gimli"}, + {19, "Gollum"}, + {20, "Harley Quinn"}, + {21, "Homer Simpson"}, + {22, "Jay"}, + {23, "Joker"}, + {24, "Kai"}, + {25, "ACU Trooper"}, + {26, "Gamer Kid"}, + {27, "Krusty the Clown"}, + {28, "Laval"}, + {29, "Legolas"}, + {30, "Lloyd"}, + {31, "Marty McFly"}, + {32, "Nya"}, + {33, "Owen Grady"}, + {34, "Peter Venkman"}, + {35, "Slimer"}, + {36, "Scooby-Doo"}, + {37, "Sensei Wu"}, + {38, "Shaggy"}, + {39, "Stay Puft"}, + {40, "Superman"}, + {41, "Unikitty"}, + {42, "Wicked Witch of the West"}, + {43, "Wonder Woman"}, + {44, "Zane"}, + {45, "Green Arrow"}, + {46, "Supergirl"}, + {47, "Abby Yates"}, + {48, "Finn the Human"}, + {49, "Ethan Hunt"}, + {50, "Lumpy Space Princess"}, + {51, "Jake the Dog"}, + {52, "Harry Potter"}, + {53, "Lord Voldemort"}, + {54, "Michael Knight"}, + {55, "B.A. Baracus"}, + {56, "Newt Scamander"}, + {57, "Sonic the Hedgehog"}, + {58, "Future Update (unreleased)"}, + {59, "Gizmo"}, + {60, "Stripe"}, + {61, "E.T."}, + {62, "Tina Goldstein"}, + {63, "Marceline the Vampire Queen"}, + {64, "Batgirl"}, + {65, "Robin"}, + {66, "Sloth"}, + {67, "Hermione Granger"}, + {68, "Chase McCain"}, + {69, "Excalibur Batman"}, + {70, "Raven"}, + {71, "Beast Boy"}, + {72, "Betelgeuse"}, + {73, "Lord Vortech (unreleased)"}, + {74, "Blossom"}, + {75, "Bubbles"}, + {76, "Buttercup"}, + {77, "Starfire"}, + {78, "World 15 (unreleased)"}, + {79, "World 16 (unreleased)"}, + {80, "World 17 (unreleased)"}, + {81, "World 18 (unreleased)"}, + {82, "World 19 (unreleased)"}, + {83, "World 20 (unreleased)"}, + {768, "Unknown 768"}, + {769, "Supergirl Red Lantern"}, + {770, "Unknown 770"}}; + + const std::map<const uint32, const char*> s_listTokens = { + {1000, "Police Car"}, + {1001, "Aerial Squad Car"}, + {1002, "Missile Striker"}, + {1003, "Gravity Sprinter"}, + {1004, "Street Shredder"}, + {1005, "Sky Clobberer"}, + {1006, "Batmobile"}, + {1007, "Batblaster"}, + {1008, "Sonic Batray"}, + {1009, "Benny's Spaceship"}, + {1010, "Lasercraft"}, + {1011, "The Annihilator"}, + {1012, "DeLorean Time Machine"}, + {1013, "Electric Time Machine"}, + {1014, "Ultra Time Machine"}, + {1015, "Hoverboard"}, + {1016, "Cyclone Board"}, + {1017, "Ultimate Hoverjet"}, + {1018, "Eagle Interceptor"}, + {1019, "Eagle Sky Blazer"}, + {1020, "Eagle Swoop Diver"}, + {1021, "Swamp Skimmer"}, + {1022, "Cragger's Fireship"}, + {1023, "Croc Command Sub"}, + {1024, "Cyber-Guard"}, + {1025, "Cyber-Wrecker"}, + {1026, "Laser Robot Walker"}, + {1027, "K-9"}, + {1028, "K-9 Ruff Rover"}, + {1029, "K-9 Laser Cutter"}, + {1030, "TARDIS"}, + {1031, "Laser-Pulse TARDIS"}, + {1032, "Energy-Burst TARDIS"}, + {1033, "Emmet's Excavator"}, + {1034, "Destroy Dozer"}, + {1035, "Destruct-o-Mech"}, + {1036, "Winged Monkey"}, + {1037, "Battle Monkey"}, + {1038, "Commander Monkey"}, + {1039, "Axe Chariot"}, + {1040, "Axe Hurler"}, + {1041, "Soaring Chariot"}, + {1042, "Shelob the Great"}, + {1043, "8-Legged Stalker"}, + {1044, "Poison Slinger"}, + {1045, "Homer's Car"}, + {1047, "The SubmaHomer"}, + {1046, "The Homercraft"}, + {1048, "Taunt-o-Vision"}, + {1050, "The MechaHomer"}, + {1049, "Blast Cam"}, + {1051, "Velociraptor"}, + {1053, "Venom Raptor"}, + {1052, "Spike Attack Raptor"}, + {1054, "Gyrosphere"}, + {1055, "Sonic Beam Gyrosphere"}, + {1056, " Gyrosphere"}, + {1057, "Clown Bike"}, + {1058, "Cannon Bike"}, + {1059, "Anti-Gravity Rocket Bike"}, + {1060, "Mighty Lion Rider"}, + {1061, "Lion Blazer"}, + {1062, "Fire Lion"}, + {1063, "Arrow Launcher"}, + {1064, "Seeking Shooter"}, + {1065, "Triple Ballista"}, + {1066, "Mystery Machine"}, + {1067, "Mystery Tow & Go"}, + {1068, "Mystery Monster"}, + {1069, "Boulder Bomber"}, + {1070, "Boulder Blaster"}, + {1071, "Cyclone Jet"}, + {1072, "Storm Fighter"}, + {1073, "Lightning Jet"}, + {1074, "Electro-Shooter"}, + {1075, "Blade Bike"}, + {1076, "Flight Fire Bike"}, + {1077, "Blades of Fire"}, + {1078, "Samurai Mech"}, + {1079, "Samurai Shooter"}, + {1080, "Soaring Samurai Mech"}, + {1081, "Companion Cube"}, + {1082, "Laser Deflector"}, + {1083, "Gold Heart Emitter"}, + {1084, "Sentry Turret"}, + {1085, "Turret Striker"}, + {1086, "Flight Turret Carrier"}, + {1087, "Scooby Snack"}, + {1088, "Scooby Fire Snack"}, + {1089, "Scooby Ghost Snack"}, + {1090, "Cloud Cuckoo Car"}, + {1091, "X-Stream Soaker"}, + {1092, "Rainbow Cannon"}, + {1093, "Invisible Jet"}, + {1094, "Laser Shooter"}, + {1095, "Torpedo Bomber"}, + {1096, "NinjaCopter"}, + {1097, "Glaciator"}, + {1098, "Freeze Fighter"}, + {1099, "Travelling Time Train"}, + {1100, "Flight Time Train"}, + {1101, "Missile Blast Time Train"}, + {1102, "Aqua Watercraft"}, + {1103, "Seven Seas Speeder"}, + {1104, "Trident of Fire"}, + {1105, "Drill Driver"}, + {1106, "Bane Dig 'n' Drill"}, + {1107, "Bane Drill 'n' Blast"}, + {1108, "Quinn Mobile"}, + {1109, "Quinn Ultra Racer"}, + {1110, "Missile Launcher"}, + {1111, "The Joker's Chopper"}, + {1112, "Mischievous Missile Blaster"}, + {1113, "Lock 'n' Laser Jet"}, + {1114, "Hover Pod"}, + {1115, "Krypton Striker"}, + {1116, "Super Stealth Pod"}, + {1117, "Dalek"}, + {1118, "Fire 'n' Ride Dalek"}, + {1119, "Silver Shooter Dalek"}, + {1120, "Ecto-1"}, + {1121, "Ecto-1 Blaster"}, + {1122, "Ecto-1 Water Diver"}, + {1123, "Ghost Trap"}, + {1124, "Ghost Stun 'n' Trap"}, + {1125, "Proton Zapper"}, + {1126, "Unknown"}, + {1127, "Unknown"}, + {1128, "Unknown"}, + {1129, "Unknown"}, + {1130, "Unknown"}, + {1131, "Unknown"}, + {1132, "Lloyd's Golden Dragon"}, + {1133, "Sword Projector Dragon"}, + {1134, "Unknown"}, + {1135, "Unknown"}, + {1136, "Unknown"}, + {1137, "Unknown"}, + {1138, "Unknown"}, + {1139, "Unknown"}, + {1140, "Unknown"}, + {1141, "Unknown"}, + {1142, "Unknown"}, + {1143, "Unknown"}, + {1144, "Mega Flight Dragon"}, + {1145, "Unknown"}, + {1146, "Unknown"}, + {1147, "Unknown"}, + {1148, "Unknown"}, + {1149, "Unknown"}, + {1150, "Unknown"}, + {1151, "Unknown"}, + {1152, "Unknown"}, + {1153, "Unknown"}, + {1154, "Unknown"}, + {1155, "Flying White Dragon"}, + {1156, "Golden Fire Dragon"}, + {1157, "Ultra Destruction Dragon"}, + {1158, "Arcade Machine"}, + {1159, "8-Bit Shooter"}, + {1160, "The Pixelator"}, + {1161, "G-6155 Spy Hunter"}, + {1162, "Interdiver"}, + {1163, "Aerial Spyhunter"}, + {1164, "Slime Shooter"}, + {1165, "Slime Exploder"}, + {1166, "Slime Streamer"}, + {1167, "Terror Dog"}, + {1168, "Terror Dog Destroyer"}, + {1169, "Soaring Terror Dog"}, + {1170, "Ancient Psychic Tandem War Elephant"}, + {1171, "Cosmic Squid"}, + {1172, "Psychic Submarine"}, + {1173, "BMO"}, + {1174, "DOGMO"}, + {1175, "SNAKEMO"}, + {1176, "Jakemobile"}, + {1177, "Snail Dude Jake"}, + {1178, "Hover Jake"}, + {1179, "Lumpy Car"}, + {1181, "Lumpy Land Whale"}, + {1180, "Lumpy Truck"}, + {1182, "Lunatic Amp"}, + {1183, "Shadow Scorpion"}, + {1184, "Heavy Metal Monster"}, + {1185, "B.A.'s Van"}, + {1186, "Fool Smasher"}, + {1187, "Pain Plane"}, + {1188, "Phone Home"}, + {1189, "Mobile Uplink"}, + {1190, "Super-Charged Satellite"}, + {1191, "Niffler"}, + {1192, "Sinister Scorpion"}, + {1193, "Vicious Vulture"}, + {1194, "Swooping Evil"}, + {1195, "Brutal Bloom"}, + {1196, "Crawling Creeper"}, + {1197, "Ecto-1 (2016)"}, + {1198, "Ectozer"}, + {1199, "PerfEcto"}, + {1200, "Flash 'n' Finish"}, + {1201, "Rampage Record Player"}, + {1202, "Stripe's Throne"}, + {1203, "R.C. Racer"}, + {1204, "Gadget-O-Matic"}, + {1205, "Scarlet Scorpion"}, + {1206, "Hogwarts Express"}, + {1208, "Steam Warrior"}, + {1207, "Soaring Steam Plane"}, + {1209, "Enchanted Car"}, + {1210, "Shark Sub"}, + {1211, "Monstrous Mouth"}, + {1212, "IMF Scrambler"}, + {1213, "Shock Cycle"}, + {1214, "IMF Covert Jet"}, + {1215, "IMF Sports Car"}, + {1216, "IMF Tank"}, + {1217, "IMF Splorer"}, + {1218, "Sonic Speedster"}, + {1219, "Blue Typhoon"}, + {1220, "Moto Bug"}, + {1221, "The Tornado"}, + {1222, "Crabmeat"}, + {1223, "Eggcatcher"}, + {1224, "K.I.T.T."}, + {1225, "Goliath Armored Semi"}, + {1226, "K.I.T.T. Jet"}, + {1227, "Police Helicopter"}, + {1228, "Police Hovercraft"}, + {1229, "Police Plane"}, + {1230, "Bionic Steed"}, + {1231, "Bat-Raptor"}, + {1232, "Ultrabat"}, + {1233, "Batwing"}, + {1234, "The Black Thunder"}, + {1235, "Bat-Tank"}, + {1236, "Skeleton Organ"}, + {1237, "Skeleton Jukebox"}, + {1238, "Skele-Turkey"}, + {1239, "One-Eyed Willy's Pirate Ship"}, + {1240, "Fanged Fortune"}, + {1241, "Inferno Cannon"}, + {1242, "Buckbeak"}, + {1243, "Giant Owl"}, + {1244, "Fierce Falcon"}, + {1245, "Saturn's Sandworm"}, + {1247, "Haunted Vacuum"}, + {1246, "Spooky Spider"}, + {1248, "PPG Smartphone"}, + {1249, "PPG Hotline"}, + {1250, "Powerpuff Mag-Net"}, + {1253, "Mega Blast Bot"}, + {1251, "Ka-Pow Cannon"}, + {1252, "Slammin' Guitar"}, + {1254, "Octi"}, + {1255, "Super Skunk"}, + {1256, "Sonic Squid"}, + {1257, "T-Car"}, + {1258, "T-Forklift"}, + {1259, "T-Plane"}, + {1260, "Spellbook of Azarath"}, + {1261, "Raven Wings"}, + {1262, "Giant Hand"}, + {1263, "Titan Robot"}, + {1264, "T-Rocket"}, + {1265, "Robot Retriever"}}; + + DimensionsToypadDevice::DimensionsToypadDevice() + : Device(0x0E6F, 0x0241, 1, 2, 0) + { + m_IsOpened = false; + } + + bool DimensionsToypadDevice::Open() + { + if (!IsOpened()) + { + m_IsOpened = true; + } + return true; + } + + void DimensionsToypadDevice::Close() + { + if (IsOpened()) + { + m_IsOpened = false; + } + } + + bool DimensionsToypadDevice::IsOpened() + { + return m_IsOpened; + } + + Device::ReadResult DimensionsToypadDevice::Read(ReadMessage* message) + { + memcpy(message->data, g_dimensionstoypad.GetStatus().data(), message->length); + message->bytesRead = message->length; + return Device::ReadResult::Success; + } + + Device::WriteResult DimensionsToypadDevice::Write(WriteMessage* message) + { + if (message->length != 32) + return Device::WriteResult::Error; + + g_dimensionstoypad.SendCommand(std::span<const uint8, 32>{message->data, 32}); + message->bytesWritten = message->length; + return Device::WriteResult::Success; + } + + bool DimensionsToypadDevice::GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) + { + uint8 configurationDescriptor[0x29]; + + uint8* currentWritePtr; + + // configuration descriptor + currentWritePtr = configurationDescriptor + 0; + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength + *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces + *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue + *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration + *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes + *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber + *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting + *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints + *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass + *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass + *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol + *(uint8*)(currentWritePtr + 8) = 0; // iInterface + currentWritePtr = currentWritePtr + 9; + // configuration descriptor + *(uint8*)(currentWritePtr + 0) = 9; // bLength + *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType + *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID + *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode + *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors + *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType + *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength + currentWritePtr = currentWritePtr + 9; + // endpoint descriptor 1 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress + *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + // endpoint descriptor 2 + *(uint8*)(currentWritePtr + 0) = 7; // bLength + *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType + *(uint8*)(currentWritePtr + 1) = 0x02; // bEndpointAddress + *(uint8*)(currentWritePtr + 2) = 0x03; // bmAttributes + *(uint16be*)(currentWritePtr + 3) = 0x40; // wMaxPacketSize + *(uint8*)(currentWritePtr + 5) = 0x01; // bInterval + currentWritePtr = currentWritePtr + 7; + + cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); + + memcpy(output, configurationDescriptor, + std::min<uint32>(outputMaxLength, sizeof(configurationDescriptor))); + return true; + } + + bool DimensionsToypadDevice::SetProtocol(uint8 ifIndex, uint8 protocol) + { + cemuLog_log(LogType::Force, "Toypad Protocol"); + return true; + } + + bool DimensionsToypadDevice::SetReport(ReportMessage* message) + { + cemuLog_log(LogType::Force, "Toypad Report"); + return true; + } + + std::array<uint8, 32> DimensionsUSB::GetStatus() + { + std::array<uint8, 32> response = {}; + + bool responded = false; + do + { + if (!m_queries.empty()) + { + response = m_queries.front(); + m_queries.pop(); + responded = true; + } + else if (!m_figureAddedRemovedResponses.empty() && m_isAwake) + { + std::lock_guard lock(m_dimensionsMutex); + response = m_figureAddedRemovedResponses.front(); + m_figureAddedRemovedResponses.pop(); + responded = true; + } + else + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + } + while (responded == false); + return response; + } + + void DimensionsUSB::SendCommand(std::span<const uint8, 32> buf) + { + const uint8 command = buf[2]; + const uint8 sequence = buf[3]; + + std::array<uint8, 32> q_result{}; + + switch (command) + { + case 0xB0: // Wake + { + // Consistent device response to the wake command + q_result = {0x55, 0x0e, 0x01, 0x28, 0x63, 0x29, + 0x20, 0x4c, 0x45, 0x47, 0x4f, 0x20, + 0x32, 0x30, 0x31, 0x34, 0x46}; + break; + } + case 0xB1: // Seed + { + // Initialise a random number generator using the seed provided + g_dimensionstoypad.GenerateRandomNumber(std::span<const uint8, 8>{buf.begin() + 4, 8}, sequence, q_result); + break; + } + case 0xB3: // Challenge + { + // Get the next number in the sequence based on the RNG from 0xB1 command + g_dimensionstoypad.GetChallengeResponse(std::span<const uint8, 8>{buf.begin() + 4, 8}, sequence, q_result); + break; + } + case 0xC0: // Color + case 0xC1: // Get Pad Color + case 0xC2: // Fade + case 0xC3: // Flash + case 0xC4: // Fade Random + case 0xC6: // Fade All + case 0xC7: // Flash All + case 0xC8: // Color All + { + // Send a blank response to acknowledge color has been sent to toypad + q_result = {0x55, 0x01, sequence}; + q_result[3] = GenerateChecksum(q_result, 3); + break; + } + case 0xD2: // Read + { + // Read 4 pages from the figure at index (buf[4]), starting with page buf[5] + g_dimensionstoypad.QueryBlock(buf[4], buf[5], q_result, sequence); + break; + } + case 0xD3: // Write + { + // Write 4 bytes to page buf[5] to the figure at index buf[4] + g_dimensionstoypad.WriteBlock(buf[4], buf[5], std::span<const uint8, 4>{buf.begin() + 6, 4}, q_result, sequence); + break; + } + case 0xD4: // Model + { + // Get the model id of the figure at index buf[4] + g_dimensionstoypad.GetModel(std::span<const uint8, 8>{buf.begin() + 4, 8}, sequence, q_result); + break; + } + case 0xD0: // Tag List + case 0xE1: // PWD + case 0xE5: // Active + case 0xFF: // LEDS Query + { + // Further investigation required + cemuLog_log(LogType::Force, "Unimplemented LD Function: {:x}", command); + break; + } + default: + { + cemuLog_log(LogType::Force, "Unknown LD Function: {:x}", command); + break; + } + } + + m_queries.push(q_result); + } + + uint32 DimensionsUSB::LoadFigure(const std::array<uint8, 0x2D * 0x04>& buf, std::unique_ptr<FileStream> file, uint8 pad, uint8 index) + { + std::lock_guard lock(m_dimensionsMutex); + + const uint32 id = GetFigureId(buf); + + DimensionsMini& figure = GetFigureByIndex(index); + figure.dimFile = std::move(file); + figure.id = id; + figure.pad = pad; + figure.index = index + 1; + figure.data = buf; + // When a figure is added to the toypad, respond to the game with the pad they were added to, their index, + // the direction (0x00 in byte 6 for added) and their UID + std::array<uint8, 32> figureChangeResponse = {0x56, 0x0b, figure.pad, 0x00, figure.index, 0x00, buf[0], buf[1], buf[2], buf[4], buf[5], buf[6], buf[7]}; + figureChangeResponse[13] = GenerateChecksum(figureChangeResponse, 13); + m_figureAddedRemovedResponses.push(figureChangeResponse); + + return id; + } + + bool DimensionsUSB::RemoveFigure(uint8 pad, uint8 index, bool fullRemove) + { + std::lock_guard lock(m_dimensionsMutex); + + DimensionsMini& figure = GetFigureByIndex(index); + if (figure.index == 255) + return false; + + // When a figure is removed from the toypad, respond to the game with the pad they were removed from, their index, + // the direction (0x01 in byte 6 for removed) and their UID + if (fullRemove) + { + std::array<uint8, 32> figureChangeResponse = {0x56, 0x0b, figure.pad, 0x00, figure.index, 0x01, + figure.data[0], figure.data[1], figure.data[2], + figure.data[4], figure.data[5], figure.data[6], figure.data[7]}; + figureChangeResponse[13] = GenerateChecksum(figureChangeResponse, 13); + m_figureAddedRemovedResponses.push(figureChangeResponse); + figure.Save(); + figure.dimFile.reset(); + } + + figure.index = 255; + figure.pad = 255; + figure.id = 0; + + return true; + } + + bool DimensionsUSB::TempRemove(uint8 index) + { + std::lock_guard lock(m_dimensionsMutex); + + DimensionsMini& figure = GetFigureByIndex(index); + if (figure.index == 255) + return false; + + // Send a response to the game that the figure has been "Picked up" from existing slot, + // until either the movement is cancelled, or user chooses a space to move to + std::array<uint8, 32> figureChangeResponse = {0x56, 0x0b, figure.pad, 0x00, figure.index, 0x01, + figure.data[0], figure.data[1], figure.data[2], + figure.data[4], figure.data[5], figure.data[6], figure.data[7]}; + + figureChangeResponse[13] = GenerateChecksum(figureChangeResponse, 13); + m_figureAddedRemovedResponses.push(figureChangeResponse); + } + + bool DimensionsUSB::CancelRemove(uint8 index) + { + std::lock_guard lock(m_dimensionsMutex); + + DimensionsMini& figure = GetFigureByIndex(index); + if (figure.index == 255) + return false; + + // Cancel the previous movement of the figure + std::array<uint8, 32> figureChangeResponse = {0x56, 0x0b, figure.pad, 0x00, figure.index, 0x00, + figure.data[0], figure.data[1], figure.data[2], + figure.data[4], figure.data[5], figure.data[6], figure.data[7]}; + + figureChangeResponse[13] = GenerateChecksum(figureChangeResponse, 13); + m_figureAddedRemovedResponses.push(figureChangeResponse); + + return true; + } + + bool DimensionsUSB::CreateFigure(fs::path pathName, uint32 id) + { + FileStream* dimFile(FileStream::createFile2(pathName)); + if (!dimFile) + return false; + + std::array<uint8, 0x2D * 0x04> fileData{}; + RandomUID(fileData); + fileData[3] = id & 0xFF; + + std::array<uint8, 7> uid = {fileData[0], fileData[1], fileData[2], fileData[4], fileData[5], fileData[6], fileData[7]}; + + // Only characters are created with their ID encrypted and stored in pages 36 and 37, + // as well as a password stored in page 43. Blank tags have their information populated + // by the game when it calls the write_block command. + if (id != 0) + { + const std::array<uint8, 16> figureKey = GenerateFigureKey(fileData); + + std::array<uint8, 8> valueToEncrypt = {uint8(id & 0xFF), uint8((id >> 8) & 0xFF), uint8((id >> 16) & 0xFF), uint8((id >> 24) & 0xFF), + uint8(id & 0xFF), uint8((id >> 8) & 0xFF), uint8((id >> 16) & 0xFF), uint8((id >> 24) & 0xFF)}; + + std::array<uint8, 8> encrypted = Encrypt(valueToEncrypt, figureKey); + + std::memcpy(&fileData[36 * 4], &encrypted[0], 4); + std::memcpy(&fileData[37 * 4], &encrypted[4], 4); + + std::memcpy(&fileData[43 * 4], PWDGenerate(fileData).data(), 4); + } + else + { + // Page 38 is used as verification for blank tags + fileData[(38 * 4) + 1] = 1; + } + + if (fileData.size() != dimFile->writeData(fileData.data(), fileData.size())) + { + delete dimFile; + return false; + } + delete dimFile; + return true; + } + + bool DimensionsUSB::MoveFigure(uint8 pad, uint8 index, uint8 oldPad, uint8 oldIndex) + { + if (oldIndex == index) + { + // Don't bother removing and loading again, just send response to the game + CancelRemove(index); + return true; + } + + // When moving figures between spaces on the toypad, remove any figure from the space they are moving to, + // then remove them from their current space, then load them to the space they are moving to + RemoveFigure(pad, index, true); + + DimensionsMini& figure = GetFigureByIndex(oldIndex); + const std::array<uint8, 0x2D * 0x04> data = figure.data; + std::unique_ptr<FileStream> inFile = std::move(figure.dimFile); + + RemoveFigure(oldPad, oldIndex, false); + + LoadFigure(data, std::move(inFile), pad, index); + + return true; + } + + void DimensionsUSB::GenerateRandomNumber(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + // Decrypt payload into an 8 byte array + std::array<uint8, 8> value = Decrypt(buf, std::nullopt); + // Seed is the first 4 bytes (little endian) of the decrypted payload + uint32 seed = (uint32&)value[0]; + // Confirmation is the second 4 bytes (big endian) of the decrypted payload + uint32 conf = (uint32be&)value[4]; + // Initialize rng using the seed from decrypted payload + InitializeRNG(seed); + // Encrypt 8 bytes, first 4 bytes is the decrypted confirmation from payload, 2nd 4 bytes are blank + std::array<uint8, 8> valueToEncrypt = {value[4], value[5], value[6], value[7], 0, 0, 0, 0}; + std::array<uint8, 8> encrypted = Encrypt(valueToEncrypt, std::nullopt); + replyBuf[0] = 0x55; + replyBuf[1] = 0x09; + replyBuf[2] = sequence; + // Copy encrypted value to response data + memcpy(&replyBuf[3], encrypted.data(), encrypted.size()); + replyBuf[11] = GenerateChecksum(replyBuf, 11); + } + + void DimensionsUSB::GetChallengeResponse(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + // Decrypt payload into an 8 byte array + std::array<uint8, 8> value = Decrypt(buf, std::nullopt); + // Confirmation is the first 4 bytes of the decrypted payload + uint32 conf = (uint32be&)value[0]; + // Generate next random number based on RNG + uint32 nextRandom = GetNext(); + // Encrypt an 8 byte array, first 4 bytes are the next random number (little endian) + // followed by the confirmation from the decrypted payload + std::array<uint8, 8> valueToEncrypt = {uint8(nextRandom & 0xFF), uint8((nextRandom >> 8) & 0xFF), + uint8((nextRandom >> 16) & 0xFF), uint8((nextRandom >> 24) & 0xFF), + value[0], value[1], value[2], value[3]}; + std::array<uint8, 8> encrypted = Encrypt(valueToEncrypt, std::nullopt); + replyBuf[0] = 0x55; + replyBuf[1] = 0x09; + replyBuf[2] = sequence; + // Copy encrypted value to response data + memcpy(&replyBuf[3], encrypted.data(), encrypted.size()); + replyBuf[11] = GenerateChecksum(replyBuf, 11); + + if (!m_isAwake) + m_isAwake = true; + } + + void DimensionsUSB::InitializeRNG(uint32 seed) + { + m_randomA = 0xF1EA5EED; + m_randomB = seed; + m_randomC = seed; + m_randomD = seed; + + for (int i = 0; i < 42; i++) + { + GetNext(); + } + } + + uint32 DimensionsUSB::GetNext() + { + uint32 e = m_randomA - std::rotl(m_randomB, 21); + m_randomA = m_randomB ^ std::rotl(m_randomC, 19); + m_randomB = m_randomC + std::rotl(m_randomD, 6); + m_randomC = m_randomD + e; + m_randomD = e + m_randomA; + return m_randomD; + } + + std::array<uint8, 8> DimensionsUSB::Decrypt(std::span<const uint8, 8> buf, std::optional<std::array<uint8, 16>> key) + { + // Value to decrypt is separated in to two little endian 32 bit unsigned integers + uint32 dataOne = (uint32&)buf[0]; + uint32 dataTwo = (uint32&)buf[4]; + + // Use the key as 4 32 bit little endian unsigned integers + uint32 keyOne; + uint32 keyTwo; + uint32 keyThree; + uint32 keyFour; + + if (key) + { + keyOne = (uint32&)key.value()[0]; + keyTwo = (uint32&)key.value()[4]; + keyThree = (uint32&)key.value()[8]; + keyFour = (uint32&)key.value()[12]; + } + else + { + keyOne = (uint32&)COMMAND_KEY[0]; + keyTwo = (uint32&)COMMAND_KEY[4]; + keyThree = (uint32&)COMMAND_KEY[8]; + keyFour = (uint32&)COMMAND_KEY[12]; + } + + uint32 sum = 0xC6EF3720; + uint32 delta = 0x9E3779B9; + + for (int i = 0; i < 32; i++) + { + dataTwo -= (((dataOne << 4) + keyThree) ^ (dataOne + sum) ^ ((dataOne >> 5) + keyFour)); + dataOne -= (((dataTwo << 4) + keyOne) ^ (dataTwo + sum) ^ ((dataTwo >> 5) + keyTwo)); + sum -= delta; + } + + cemu_assert(sum == 0); + + std::array<uint8, 8> decrypted = {uint8(dataOne & 0xFF), uint8((dataOne >> 8) & 0xFF), + uint8((dataOne >> 16) & 0xFF), uint8((dataOne >> 24) & 0xFF), + uint8(dataTwo & 0xFF), uint8((dataTwo >> 8) & 0xFF), + uint8((dataTwo >> 16) & 0xFF), uint8((dataTwo >> 24) & 0xFF)}; + return decrypted; + } + std::array<uint8, 8> DimensionsUSB::Encrypt(std::span<const uint8, 8> buf, std::optional<std::array<uint8, 16>> key) + { + // Value to encrypt is separated in to two little endian 32 bit unsigned integers + uint32 dataOne = (uint32&)buf[0]; + uint32 dataTwo = (uint32&)buf[4]; + + // Use the key as 4 32 bit little endian unsigned integers + uint32 keyOne; + uint32 keyTwo; + uint32 keyThree; + uint32 keyFour; + + if (key) + { + keyOne = (uint32&)key.value()[0]; + keyTwo = (uint32&)key.value()[4]; + keyThree = (uint32&)key.value()[8]; + keyFour = (uint32&)key.value()[12]; + } + else + { + keyOne = (uint32&)COMMAND_KEY[0]; + keyTwo = (uint32&)COMMAND_KEY[4]; + keyThree = (uint32&)COMMAND_KEY[8]; + keyFour = (uint32&)COMMAND_KEY[12]; + } + + uint32 sum = 0; + uint32 delta = 0x9E3779B9; + + for (int i = 0; i < 32; i++) + { + sum += delta; + dataOne += (((dataTwo << 4) + keyOne) ^ (dataTwo + sum) ^ ((dataTwo >> 5) + keyTwo)); + dataTwo += (((dataOne << 4) + keyThree) ^ (dataOne + sum) ^ ((dataOne >> 5) + keyFour)); + } + + cemu_assert(sum == 0xC6EF3720); + + std::array<uint8, 8> encrypted = {uint8(dataOne & 0xFF), uint8((dataOne >> 8) & 0xFF), + uint8((dataOne >> 16) & 0xFF), uint8((dataOne >> 24) & 0xFF), + uint8(dataTwo & 0xFF), uint8((dataTwo >> 8) & 0xFF), + uint8((dataTwo >> 16) & 0xFF), uint8((dataTwo >> 24) & 0xFF)}; + return encrypted; + } + + std::array<uint8, 16> DimensionsUSB::GenerateFigureKey(const std::array<uint8, 0x2D * 0x04>& buf) + { + std::array<uint8, 7> uid = {buf[0], buf[1], buf[2], buf[4], buf[5], buf[6], buf[7]}; + + uint32 scrambleA = Scramble(uid, 3); + uint32 scrambleB = Scramble(uid, 4); + uint32 scrambleC = Scramble(uid, 5); + uint32 scrambleD = Scramble(uid, 6); + + return {uint8((scrambleA >> 24) & 0xFF), uint8((scrambleA >> 16) & 0xFF), + uint8((scrambleA >> 8) & 0xFF), uint8(scrambleA & 0xFF), + uint8((scrambleB >> 24) & 0xFF), uint8((scrambleB >> 16) & 0xFF), + uint8((scrambleB >> 8) & 0xFF), uint8(scrambleB & 0xFF), + uint8((scrambleC >> 24) & 0xFF), uint8((scrambleC >> 16) & 0xFF), + uint8((scrambleC >> 8) & 0xFF), uint8(scrambleC & 0xFF), + uint8((scrambleD >> 24) & 0xFF), uint8((scrambleD >> 16) & 0xFF), + uint8((scrambleD >> 8) & 0xFF), uint8(scrambleD & 0xFF)}; + } + + uint32 DimensionsUSB::Scramble(const std::array<uint8, 7>& uid, uint8 count) + { + std::vector<uint8> toScramble; + toScramble.reserve(uid.size() + CHAR_CONSTANT.size()); + for (uint8 x : uid) + { + toScramble.push_back(x); + } + for (uint8 c : CHAR_CONSTANT) + { + toScramble.push_back(c); + } + toScramble[(count * 4) - 1] = 0xaa; + + std::array<uint8, 4> randomized = DimensionsRandomize(toScramble, count); + + return (uint32be&)randomized[0]; + } + + std::array<uint8, 4> DimensionsUSB::PWDGenerate(const std::array<uint8, 0x2D * 0x04>& buf) + { + std::array<uint8, 7> uid = {buf[0], buf[1], buf[2], buf[4], buf[5], buf[6], buf[7]}; + + std::vector<uint8> pwdCalc = {PWD_CONSTANT.begin(), PWD_CONSTANT.end() - 1}; + for (uint8 i = 0; i < uid.size(); i++) + { + pwdCalc.insert(pwdCalc.begin() + i, uid[i]); + } + + return DimensionsRandomize(pwdCalc, 8); + } + + std::array<uint8, 4> DimensionsUSB::DimensionsRandomize(const std::vector<uint8> key, uint8 count) + { + uint32 scrambled = 0; + for (uint8 i = 0; i < count; i++) + { + const uint32 v4 = std::rotr(scrambled, 25); + const uint32 v5 = std::rotr(scrambled, 10); + const uint32 b = (uint32&)key[i * 4]; + scrambled = b + v4 + v5 - scrambled; + } + return {uint8(scrambled & 0xFF), uint8(scrambled >> 8 & 0xFF), uint8(scrambled >> 16 & 0xFF), uint8(scrambled >> 24 & 0xFF)}; + } + + uint32 DimensionsUSB::GetFigureId(const std::array<uint8, 0x2D * 0x04>& buf) + { + const std::array<uint8, 16> figureKey = GenerateFigureKey(buf); + + const std::span<const uint8, 8> modelNumber = std::span<const uint8, 8>{buf.begin() + (36 * 4), 8}; + + const std::array<uint8, 8> decrypted = Decrypt(modelNumber, figureKey); + + const uint32 figNum = (uint32&)decrypted[0]; + // Characters have their model number encrypted in page 36 + if (figNum < 1000) + { + return figNum; + } + // Vehicles/Gadgets have their model number written as little endian in page 36 + return (uint32&)modelNumber[0]; + } + + DimensionsUSB::DimensionsMini& + DimensionsUSB::GetFigureByIndex(uint8 index) + { + return m_figures[index]; + } + + void DimensionsUSB::QueryBlock(uint8 index, uint8 page, + std::array<uint8, 32>& replyBuf, + uint8 sequence) + { + std::lock_guard lock(m_dimensionsMutex); + + replyBuf[0] = 0x55; + replyBuf[1] = 0x12; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + + // Index from game begins at 1 rather than 0, so minus 1 here + if (const uint8 figureIndex = index - 1; figureIndex < 7) + { + const DimensionsMini& figure = GetFigureByIndex(figureIndex); + + // Query 4 pages of 4 bytes from the figure, copy this to the response + if (figure.index != 255 && (4 * page) < ((0x2D * 4) - 16)) + { + std::memcpy(&replyBuf[4], figure.data.data() + (4 * page), 16); + } + } + replyBuf[20] = GenerateChecksum(replyBuf, 20); + } + + void DimensionsUSB::WriteBlock(uint8 index, uint8 page, std::span<const uint8, 4> toWriteBuf, + std::array<uint8, 32>& replyBuf, uint8 sequence) + { + std::lock_guard lock(m_dimensionsMutex); + + replyBuf[0] = 0x55; + replyBuf[1] = 0x02; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + + // Index from game begins at 1 rather than 0, so minus 1 here + if (const uint8 figureIndex = index - 1; figureIndex < 7) + { + DimensionsMini& figure = GetFigureByIndex(figureIndex); + + // Copy 4 bytes to the page on the figure requested by the game + if (figure.index != 255 && page < 0x2D) + { + // Id is written to page 36 + if (page == 36) + { + figure.id = (uint32&)toWriteBuf[0]; + } + std::memcpy(figure.data.data() + (page * 4), toWriteBuf.data(), 4); + figure.Save(); + } + } + replyBuf[4] = GenerateChecksum(replyBuf, 4); + } + + void DimensionsUSB::GetModel(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf) + { + // Decrypt payload to 8 byte array, byte 1 is the index, 4-7 are the confirmation + std::array<uint8, 8> value = Decrypt(buf, std::nullopt); + uint8 index = value[0]; + uint32 conf = (uint32be&)value[4]; + // Response is the figure's id (little endian) followed by the confirmation from payload + // Index from game begins at 1 rather than 0, so minus 1 here + std::array<uint8, 8> valueToEncrypt = {}; + if (const uint8 figureIndex = index - 1; figureIndex < 7) + { + const DimensionsMini& figure = GetFigureByIndex(figureIndex); + valueToEncrypt = {uint8(figure.id & 0xFF), uint8((figure.id >> 8) & 0xFF), + uint8((figure.id >> 16) & 0xFF), uint8((figure.id >> 24) & 0xFF), + value[4], value[5], value[6], value[7]}; + } + std::array<uint8, 8> encrypted = Encrypt(valueToEncrypt, std::nullopt); + replyBuf[0] = 0x55; + replyBuf[1] = 0x0a; + replyBuf[2] = sequence; + replyBuf[3] = 0x00; + memcpy(&replyBuf[4], encrypted.data(), encrypted.size()); + replyBuf[12] = GenerateChecksum(replyBuf, 12); + } + + void DimensionsUSB::RandomUID(std::array<uint8, 0x2D * 0x04>& uid_buffer) + { + uid_buffer[0] = 0x04; + uid_buffer[7] = 0x80; + + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_int_distribution<int> dist(0, 255); + + uid_buffer[1] = dist(mt); + uid_buffer[2] = dist(mt); + uid_buffer[4] = dist(mt); + uid_buffer[5] = dist(mt); + uid_buffer[6] = dist(mt); + } + + uint8 DimensionsUSB::GenerateChecksum(const std::array<uint8, 32>& data, + int num_of_bytes) const + { + int checksum = 0; + for (int i = 0; i < num_of_bytes; i++) + { + checksum += data[i]; + } + return (checksum & 0xFF); + } + + void DimensionsUSB::DimensionsMini::Save() + { + if (!dimFile) + return; + + dimFile->SetPosition(0); + dimFile->writeData(data.data(), data.size()); + } + + std::map<const uint32, const char*> DimensionsUSB::GetListMinifigs() + { + return s_listMinis; + } + + std::map<const uint32, const char*> DimensionsUSB::GetListTokens() + { + return s_listTokens; + } + + std::string DimensionsUSB::FindFigure(uint32 figNum) + { + for (const auto& it : GetListMinifigs()) + { + if (it.first == figNum) + { + return it.second; + } + } + for (const auto& it : GetListTokens()) + { + if (it.first == figNum) + { + return it.second; + } + } + return fmt::format("Unknown ({})", figNum); + } +} // namespace nsyshid \ No newline at end of file diff --git a/src/Cafe/OS/libs/nsyshid/Dimensions.h b/src/Cafe/OS/libs/nsyshid/Dimensions.h new file mode 100644 index 00000000..d5a2a529 --- /dev/null +++ b/src/Cafe/OS/libs/nsyshid/Dimensions.h @@ -0,0 +1,108 @@ +#include <mutex> + +#include "nsyshid.h" +#include "Backend.h" + +#include "Common/FileStream.h" + +namespace nsyshid +{ + class DimensionsToypadDevice final : public Device + { + public: + DimensionsToypadDevice(); + ~DimensionsToypadDevice() = default; + + bool Open() override; + + void Close() override; + + bool IsOpened() override; + + ReadResult Read(ReadMessage* message) override; + + WriteResult Write(WriteMessage* message) override; + + bool GetDescriptor(uint8 descType, + uint8 descIndex, + uint8 lang, + uint8* output, + uint32 outputMaxLength) override; + + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; + + bool SetReport(ReportMessage* message) override; + + private: + bool m_IsOpened; + }; + + class DimensionsUSB + { + public: + struct DimensionsMini final + { + std::unique_ptr<FileStream> dimFile; + std::array<uint8, 0x2D * 0x04> data{}; + uint8 index = 255; + uint8 pad = 255; + uint32 id = 0; + void Save(); + }; + + void SendCommand(std::span<const uint8, 32> buf); + std::array<uint8, 32> GetStatus(); + + void GenerateRandomNumber(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf); + void InitializeRNG(uint32 seed); + void GetChallengeResponse(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf); + void QueryBlock(uint8 index, uint8 page, std::array<uint8, 32>& replyBuf, + uint8 sequence); + void WriteBlock(uint8 index, uint8 page, std::span<const uint8, 4> toWriteBuf, std::array<uint8, 32>& replyBuf, + uint8 sequence); + void GetModel(std::span<const uint8, 8> buf, uint8 sequence, + std::array<uint8, 32>& replyBuf); + + bool RemoveFigure(uint8 pad, uint8 index, bool fullRemove); + bool TempRemove(uint8 index); + bool CancelRemove(uint8 index); + uint32 LoadFigure(const std::array<uint8, 0x2D * 0x04>& buf, std::unique_ptr<FileStream> file, uint8 pad, uint8 index); + bool CreateFigure(fs::path pathName, uint32 id); + bool MoveFigure(uint8 pad, uint8 index, uint8 oldPad, uint8 oldIndex); + static std::map<const uint32, const char*> GetListMinifigs(); + static std::map<const uint32, const char*> GetListTokens(); + std::string FindFigure(uint32 figNum); + + protected: + std::mutex m_dimensionsMutex; + std::array<DimensionsMini, 7> m_figures{}; + + private: + void RandomUID(std::array<uint8, 0x2D * 0x04>& uidBuffer); + uint8 GenerateChecksum(const std::array<uint8, 32>& data, + int numOfBytes) const; + std::array<uint8, 8> Decrypt(std::span<const uint8, 8> buf, std::optional<std::array<uint8, 16>> key); + std::array<uint8, 8> Encrypt(std::span<const uint8, 8> buf, std::optional<std::array<uint8, 16>> key); + std::array<uint8, 16> GenerateFigureKey(const std::array<uint8, 0x2D * 0x04>& uid); + std::array<uint8, 4> PWDGenerate(const std::array<uint8, 0x2D * 0x04>& uid); + std::array<uint8, 4> DimensionsRandomize(const std::vector<uint8> key, uint8 count); + uint32 GetFigureId(const std::array<uint8, 0x2D * 0x04>& buf); + uint32 Scramble(const std::array<uint8, 7>& uid, uint8 count); + uint32 GetNext(); + DimensionsMini& GetFigureByIndex(uint8 index); + + uint32 m_randomA; + uint32 m_randomB; + uint32 m_randomC; + uint32 m_randomD; + + bool m_isAwake = false; + + std::queue<std::array<uint8, 32>> m_figureAddedRemovedResponses; + std::queue<std::array<uint8, 32>> m_queries; + }; + extern DimensionsUSB g_dimensionstoypad; + +} // namespace nsyshid \ No newline at end of file diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index e7920e84..f5ee7ab4 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -346,6 +346,7 @@ void CemuConfig::Load(XMLConfigParser& parser) auto usbdevices = parser.get("EmulatedUsbDevices"); emulated_usb_devices.emulate_skylander_portal = usbdevices.get("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal); emulated_usb_devices.emulate_infinity_base = usbdevices.get("EmulateInfinityBase", emulated_usb_devices.emulate_infinity_base); + emulated_usb_devices.emulate_dimensions_toypad = usbdevices.get("EmulateDimensionsToypad", emulated_usb_devices.emulate_dimensions_toypad); } void CemuConfig::Save(XMLConfigParser& parser) @@ -545,6 +546,7 @@ void CemuConfig::Save(XMLConfigParser& parser) auto usbdevices = config.set("EmulatedUsbDevices"); usbdevices.set("EmulateSkylanderPortal", emulated_usb_devices.emulate_skylander_portal.GetValue()); usbdevices.set("EmulateInfinityBase", emulated_usb_devices.emulate_infinity_base.GetValue()); + usbdevices.set("EmulateDimensionsToypad", emulated_usb_devices.emulate_dimensions_toypad.GetValue()); } GameEntry* CemuConfig::GetGameEntryByTitleId(uint64 titleId) diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 2f22cd76..be131266 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -521,6 +521,7 @@ struct CemuConfig { ConfigValue<bool> emulate_skylander_portal{false}; ConfigValue<bool> emulate_infinity_base{false}; + ConfigValue<bool> emulate_dimensions_toypad{false}; }emulated_usb_devices{}; private: diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp index 3a0f534a..c77ae081 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp @@ -1,4 +1,4 @@ -#include "gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h" +#include "EmulatedUSBDeviceFrame.h" #include <algorithm> @@ -8,14 +8,17 @@ #include "util/helpers/helpers.h" #include "Cafe/OS/libs/nsyshid/nsyshid.h" +#include "Cafe/OS/libs/nsyshid/Dimensions.h" #include "Common/FileStream.h" #include <wx/arrstr.h> #include <wx/button.h> +#include <wx/combobox.h> #include <wx/checkbox.h> #include <wx/combobox.h> #include <wx/filedlg.h> +#include <wx/log.h> #include <wx/msgdlg.h> #include <wx/notebook.h> #include <wx/panel.h> @@ -29,7 +32,6 @@ #include <wx/wfstream.h> #include "resource/embedded/resources.h" -#include "EmulatedUSBDeviceFrame.h" EmulatedUSBDeviceFrame::EmulatedUSBDeviceFrame(wxWindow* parent) : wxFrame(parent, wxID_ANY, _("Emulated USB Devices"), wxDefaultPosition, @@ -44,6 +46,7 @@ EmulatedUSBDeviceFrame::EmulatedUSBDeviceFrame(wxWindow* parent) notebook->AddPage(AddSkylanderPage(notebook), _("Skylanders Portal")); notebook->AddPage(AddInfinityPage(notebook), _("Infinity Base")); + notebook->AddPage(AddDimensionsPage(notebook), _("Dimensions Toypad")); sizer->Add(notebook, 1, wxEXPAND | wxALL, 2); @@ -120,8 +123,52 @@ wxPanel* EmulatedUSBDeviceFrame::AddInfinityPage(wxNotebook* notebook) return panel; } -wxBoxSizer* EmulatedUSBDeviceFrame::AddSkylanderRow(uint8 rowNumber, - wxStaticBox* box) +wxPanel* EmulatedUSBDeviceFrame::AddDimensionsPage(wxNotebook* notebook) +{ + auto* panel = new wxPanel(notebook); + auto* panel_sizer = new wxBoxSizer(wxVERTICAL); + auto* box = new wxStaticBox(panel, wxID_ANY, _("Dimensions Manager")); + auto* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); + + auto* row = new wxBoxSizer(wxHORIZONTAL); + + m_emulateToypad = + new wxCheckBox(box, wxID_ANY, _("Emulate Dimensions Toypad")); + m_emulateToypad->SetValue( + GetConfig().emulated_usb_devices.emulate_dimensions_toypad); + m_emulateToypad->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { + GetConfig().emulated_usb_devices.emulate_dimensions_toypad = + m_emulateToypad->IsChecked(); + g_config.Save(); + }); + row->Add(m_emulateToypad, 1, wxEXPAND | wxALL, 2); + box_sizer->Add(row, 1, wxEXPAND | wxALL, 2); + auto* top_row = new wxBoxSizer(wxHORIZONTAL); + auto* bottom_row = new wxBoxSizer(wxHORIZONTAL); + + auto* dummy = new wxStaticText(box, wxID_ANY, ""); + + top_row->Add(AddDimensionPanel(2, 0, box), 1, wxEXPAND | wxALL, 2); + top_row->Add(dummy, 1, wxEXPAND | wxLEFT | wxRIGHT, 2); + top_row->Add(AddDimensionPanel(1, 1, box), 1, wxEXPAND | wxALL, 2); + top_row->Add(dummy, 1, wxEXPAND | wxLEFT | wxRIGHT, 2); + top_row->Add(AddDimensionPanel(3, 2, box), 1, wxEXPAND | wxALL, 2); + + bottom_row->Add(AddDimensionPanel(2, 3, box), 1, wxEXPAND | wxALL, 2); + bottom_row->Add(AddDimensionPanel(2, 4, box), 1, wxEXPAND | wxALL, 2); + bottom_row->Add(dummy, 1, wxEXPAND | wxLEFT | wxRIGHT, 0); + bottom_row->Add(AddDimensionPanel(3, 5, box), 1, wxEXPAND | wxALL, 2); + bottom_row->Add(AddDimensionPanel(3, 6, box), 1, wxEXPAND | wxALL, 2); + + box_sizer->Add(top_row, 1, wxEXPAND | wxALL, 2); + box_sizer->Add(bottom_row, 1, wxEXPAND | wxALL, 2); + panel_sizer->Add(box_sizer, 1, wxEXPAND | wxALL, 2); + panel->SetSizerAndFit(panel_sizer); + + return panel; +} + +wxBoxSizer* EmulatedUSBDeviceFrame::AddSkylanderRow(uint8 rowNumber, wxStaticBox* box) { auto* row = new wxBoxSizer(wxHORIZONTAL); @@ -184,6 +231,44 @@ wxBoxSizer* EmulatedUSBDeviceFrame::AddInfinityRow(wxString name, uint8 rowNumbe return row; } +wxBoxSizer* EmulatedUSBDeviceFrame::AddDimensionPanel(uint8 pad, uint8 index, wxStaticBox* box) +{ + auto* panel = new wxBoxSizer(wxVERTICAL); + + auto* combo_row = new wxBoxSizer(wxHORIZONTAL); + m_dimensionSlots[index] = new wxTextCtrl(box, wxID_ANY, _("None"), wxDefaultPosition, wxDefaultSize, + wxTE_READONLY); + combo_row->Add(m_dimensionSlots[index], 1, wxEXPAND | wxALL, 2); + auto* move_button = new wxButton(box, wxID_ANY, _("Move")); + move_button->Bind(wxEVT_BUTTON, [pad, index, this](wxCommandEvent&) { + MoveMinifig(pad, index); + }); + + combo_row->Add(move_button, 1, wxEXPAND | wxALL, 2); + + auto* button_row = new wxBoxSizer(wxHORIZONTAL); + auto* load_button = new wxButton(box, wxID_ANY, _("Load")); + load_button->Bind(wxEVT_BUTTON, [pad, index, this](wxCommandEvent&) { + LoadMinifig(pad, index); + }); + auto* clear_button = new wxButton(box, wxID_ANY, _("Clear")); + clear_button->Bind(wxEVT_BUTTON, [pad, index, this](wxCommandEvent&) { + ClearMinifig(pad, index); + }); + auto* create_button = new wxButton(box, wxID_ANY, _("Create")); + create_button->Bind(wxEVT_BUTTON, [pad, index, this](wxCommandEvent&) { + CreateMinifig(pad, index); + }); + button_row->Add(clear_button, 1, wxEXPAND | wxALL, 2); + button_row->Add(create_button, 1, wxEXPAND | wxALL, 2); + button_row->Add(load_button, 1, wxEXPAND | wxALL, 2); + + panel->Add(combo_row, 1, wxEXPAND | wxALL, 2); + panel->Add(button_row, 1, wxEXPAND | wxALL, 2); + + return panel; +} + void EmulatedUSBDeviceFrame::LoadSkylander(uint8 slot) { wxFileDialog openFileDialog(this, _("Open Skylander dump"), "", "", @@ -307,8 +392,8 @@ CreateSkylanderDialog::CreateSkylanderDialog(wxWindow* parent, uint8 slot) return; m_filePath = saveFileDialog.GetPath(); - - if(!nsyshid::g_skyportal.CreateSkylander(_utf8ToPath(m_filePath.utf8_string()), skyId, skyVar)) + + if (!nsyshid::g_skyportal.CreateSkylander(_utf8ToPath(m_filePath.utf8_string()), skyId, skyVar)) { wxMessageDialog errorMessage(this, "Failed to create file"); errorMessage.ShowModal(); @@ -351,6 +436,80 @@ wxString CreateSkylanderDialog::GetFilePath() const return m_filePath; } +void EmulatedUSBDeviceFrame::UpdateSkylanderEdits() +{ + for (auto i = 0; i < nsyshid::MAX_SKYLANDERS; i++) + { + std::string displayString; + if (auto sd = m_skySlots[i]) + { + auto [portalSlot, skyId, skyVar] = sd.value(); + displayString = nsyshid::g_skyportal.FindSkylander(skyId, skyVar); + } + else + { + displayString = "None"; + } + + m_skylanderSlots[i]->ChangeValue(displayString); + } +} + +void EmulatedUSBDeviceFrame::LoadFigure(uint8 slot) +{ + wxFileDialog openFileDialog(this, _("Open Infinity Figure dump"), "", "", + "BIN files (*.bin)|*.bin", + wxFD_OPEN | wxFD_FILE_MUST_EXIST); + if (openFileDialog.ShowModal() != wxID_OK || openFileDialog.GetPath().empty()) + { + wxMessageDialog errorMessage(this, "File Okay Error"); + errorMessage.ShowModal(); + return; + } + + LoadFigurePath(slot, openFileDialog.GetPath()); +} + +void EmulatedUSBDeviceFrame::LoadFigurePath(uint8 slot, wxString path) +{ + std::unique_ptr<FileStream> infFile(FileStream::openFile2(_utf8ToPath(path.utf8_string()), true)); + if (!infFile) + { + wxMessageDialog errorMessage(this, "File Open Error"); + errorMessage.ShowModal(); + return; + } + + std::array<uint8, nsyshid::INF_FIGURE_SIZE> fileData; + if (infFile->readData(fileData.data(), fileData.size()) != fileData.size()) + { + wxMessageDialog open_error(this, "Failed to read file! File was too small"); + open_error.ShowModal(); + return; + } + ClearFigure(slot); + + uint32 number = nsyshid::g_infinitybase.LoadFigure(fileData, std::move(infFile), slot); + m_infinitySlots[slot]->ChangeValue(nsyshid::g_infinitybase.FindFigure(number).second); +} + +void EmulatedUSBDeviceFrame::CreateFigure(uint8 slot) +{ + cemuLog_log(LogType::Force, "Create Figure: {}", slot); + CreateInfinityFigureDialog create_dlg(this, slot); + create_dlg.ShowModal(); + if (create_dlg.GetReturnCode() == 1) + { + LoadFigurePath(slot, create_dlg.GetFilePath()); + } +} + +void EmulatedUSBDeviceFrame::ClearFigure(uint8 slot) +{ + m_infinitySlots[slot]->ChangeValue("None"); + nsyshid::g_infinitybase.RemoveFigure(slot); +} + CreateInfinityFigureDialog::CreateInfinityFigureDialog(wxWindow* parent, uint8 slot) : wxDialog(parent, wxID_ANY, _("Infinity Figure Creator"), wxDefaultPosition, wxSize(500, 150)) { @@ -447,76 +606,231 @@ wxString CreateInfinityFigureDialog::GetFilePath() const return m_filePath; } -void EmulatedUSBDeviceFrame::LoadFigure(uint8 slot) +void EmulatedUSBDeviceFrame::LoadMinifig(uint8 pad, uint8 index) { - wxFileDialog openFileDialog(this, _("Open Infinity Figure dump"), "", "", - "BIN files (*.bin)|*.bin", + wxFileDialog openFileDialog(this, _("Load Dimensions Figure"), "", "", + "Dimensions files (*.bin)|*.bin", wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (openFileDialog.ShowModal() != wxID_OK || openFileDialog.GetPath().empty()) + return; + + LoadMinifigPath(openFileDialog.GetPath(), pad, index); +} + +void EmulatedUSBDeviceFrame::LoadMinifigPath(wxString path_name, uint8 pad, uint8 index) +{ + std::unique_ptr<FileStream> dim_file(FileStream::openFile2(_utf8ToPath(path_name.utf8_string()), true)); + if (!dim_file) { - wxMessageDialog errorMessage(this, "File Okay Error"); + wxMessageDialog errorMessage(this, "Failed to open minifig file"); errorMessage.ShowModal(); return; } - LoadFigurePath(slot, openFileDialog.GetPath()); -} + std::array<uint8, 0x2D * 0x04> file_data; -void EmulatedUSBDeviceFrame::LoadFigurePath(uint8 slot, wxString path) -{ - std::unique_ptr<FileStream> infFile(FileStream::openFile2(_utf8ToPath(path.utf8_string()), true)); - if (!infFile) + if (dim_file->readData(file_data.data(), file_data.size()) != file_data.size()) { - wxMessageDialog errorMessage(this, "File Open Error"); + wxMessageDialog errorMessage(this, "Failed to read minifig file data"); errorMessage.ShowModal(); return; } - std::array<uint8, nsyshid::INF_FIGURE_SIZE> fileData; - if (infFile->readData(fileData.data(), fileData.size()) != fileData.size()) - { - wxMessageDialog open_error(this, "Failed to read file! File was too small"); - open_error.ShowModal(); - return; - } - ClearFigure(slot); + ClearMinifig(pad, index); - uint32 number = nsyshid::g_infinitybase.LoadFigure(fileData, std::move(infFile), slot); - m_infinitySlots[slot]->ChangeValue(nsyshid::g_infinitybase.FindFigure(number).second); + uint32 id = nsyshid::g_dimensionstoypad.LoadFigure(file_data, std::move(dim_file), pad, index); + m_dimensionSlots[index]->ChangeValue(nsyshid::g_dimensionstoypad.FindFigure(id)); + m_dimSlots[index] = id; } -void EmulatedUSBDeviceFrame::CreateFigure(uint8 slot) +void EmulatedUSBDeviceFrame::ClearMinifig(uint8 pad, uint8 index) { - cemuLog_log(LogType::Force, "Create Figure: {}", slot); - CreateInfinityFigureDialog create_dlg(this, slot); + nsyshid::g_dimensionstoypad.RemoveFigure(pad, index, true); + m_dimensionSlots[index]->ChangeValue("None"); + m_dimSlots[index] = std::nullopt; +} + +void EmulatedUSBDeviceFrame::CreateMinifig(uint8 pad, uint8 index) +{ + CreateDimensionFigureDialog create_dlg(this); create_dlg.ShowModal(); if (create_dlg.GetReturnCode() == 1) { - LoadFigurePath(slot, create_dlg.GetFilePath()); + LoadMinifigPath(create_dlg.GetFilePath(), pad, index); } } -void EmulatedUSBDeviceFrame::ClearFigure(uint8 slot) +void EmulatedUSBDeviceFrame::MoveMinifig(uint8 pad, uint8 index) { - m_infinitySlots[slot]->ChangeValue("None"); - nsyshid::g_infinitybase.RemoveFigure(slot); -} + if (!m_dimSlots[index]) + return; -void EmulatedUSBDeviceFrame::UpdateSkylanderEdits() -{ - for (auto i = 0; i < nsyshid::MAX_SKYLANDERS; i++) + MoveDimensionFigureDialog move_dlg(this, index); + nsyshid::g_dimensionstoypad.TempRemove(index); + move_dlg.ShowModal(); + if (move_dlg.GetReturnCode() == 1) { - std::string displayString; - if (auto sd = m_skySlots[i]) + nsyshid::g_dimensionstoypad.MoveFigure(move_dlg.GetNewPad(), move_dlg.GetNewIndex(), pad, index); + if (index != move_dlg.GetNewIndex()) { - auto [portalSlot, skyId, skyVar] = sd.value(); - displayString = nsyshid::g_skyportal.FindSkylander(skyId, skyVar); + m_dimSlots[move_dlg.GetNewIndex()] = m_dimSlots[index]; + m_dimensionSlots[move_dlg.GetNewIndex()]->ChangeValue(m_dimensionSlots[index]->GetValue()); + m_dimSlots[index] = std::nullopt; + m_dimensionSlots[index]->ChangeValue("None"); } - else - { - displayString = "None"; - } - - m_skylanderSlots[i]->ChangeValue(displayString); } + else + { + nsyshid::g_dimensionstoypad.CancelRemove(index); + } +} + +CreateDimensionFigureDialog::CreateDimensionFigureDialog(wxWindow* parent) + : wxDialog(parent, wxID_ANY, _("Dimensions Figure Creator"), wxDefaultPosition, wxSize(500, 200)) +{ + auto* sizer = new wxBoxSizer(wxVERTICAL); + + auto* comboRow = new wxBoxSizer(wxHORIZONTAL); + + auto* comboBox = new wxComboBox(this, wxID_ANY); + comboBox->Append("---Select---", reinterpret_cast<void*>(0xFFFFFFFF)); + wxArrayString filterlist; + for (const auto& it : nsyshid::g_dimensionstoypad.GetListMinifigs()) + { + const uint32 figure = it.first; + comboBox->Append(it.second, reinterpret_cast<void*>(figure)); + filterlist.Add(it.second); + } + comboBox->SetSelection(0); + bool enabled = comboBox->AutoComplete(filterlist); + comboRow->Add(comboBox, 1, wxEXPAND | wxALL, 2); + + auto* figNumRow = new wxBoxSizer(wxHORIZONTAL); + + wxIntegerValidator<uint32> validator; + + auto* labelFigNum = new wxStaticText(this, wxID_ANY, "Figure Number:"); + auto* editFigNum = new wxTextCtrl(this, wxID_ANY, _("0"), wxDefaultPosition, wxDefaultSize, 0, validator); + + figNumRow->Add(labelFigNum, 1, wxALL, 5); + figNumRow->Add(editFigNum, 1, wxALL, 5); + + auto* buttonRow = new wxBoxSizer(wxHORIZONTAL); + + auto* createButton = new wxButton(this, wxID_ANY, _("Create")); + createButton->Bind(wxEVT_BUTTON, [editFigNum, this](wxCommandEvent&) { + long longFigNum; + if (!editFigNum->GetValue().ToLong(&longFigNum) || longFigNum > 0xFFFF) + { + wxMessageDialog idError(this, "Error Converting Figure Number!", "Number Entered is Invalid"); + idError.ShowModal(); + this->EndModal(0); + } + uint16 figNum = longFigNum & 0xFFFF; + auto figure = nsyshid::g_dimensionstoypad.FindFigure(figNum); + wxString predefName = figure + ".bin"; + wxFileDialog + saveFileDialog(this, _("Create Dimensions Figure file"), "", predefName, + "BIN files (*.bin)|*.bin", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + + if (saveFileDialog.ShowModal() == wxID_CANCEL) + this->EndModal(0); + + m_filePath = saveFileDialog.GetPath(); + + nsyshid::g_dimensionstoypad.CreateFigure(_utf8ToPath(m_filePath.utf8_string()), figNum); + + this->EndModal(1); + }); + auto* cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); + cancelButton->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { + this->EndModal(0); + }); + + comboBox->Bind(wxEVT_COMBOBOX, [comboBox, editFigNum, this](wxCommandEvent&) { + const uint64 fig_info = reinterpret_cast<uint64>(comboBox->GetClientData(comboBox->GetSelection())); + if (fig_info != 0xFFFF) + { + const uint16 figNum = fig_info & 0xFFFF; + + editFigNum->SetValue(wxString::Format(wxT("%i"), figNum)); + } + }); + + buttonRow->Add(createButton, 1, wxALL, 5); + buttonRow->Add(cancelButton, 1, wxALL, 5); + + sizer->Add(comboRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(figNumRow, 1, wxEXPAND | wxALL, 2); + sizer->Add(buttonRow, 1, wxEXPAND | wxALL, 2); + + this->SetSizer(sizer); + this->Centre(wxBOTH); +} + +wxString CreateDimensionFigureDialog::GetFilePath() const +{ + return m_filePath; +} + +MoveDimensionFigureDialog::MoveDimensionFigureDialog(EmulatedUSBDeviceFrame* parent, uint8 currentIndex) + : wxDialog(parent, wxID_ANY, _("Dimensions Figure Mover"), wxDefaultPosition, wxSize(700, 300)) +{ + auto* sizer = new wxGridSizer(2, 5, 10, 10); + + std::array<std::optional<uint32>, 7> ids = parent->GetCurrentMinifigs(); + + sizer->Add(AddMinifigSlot(2, 0, currentIndex, ids[0]), 1, wxALL, 5); + sizer->Add(new wxStaticText(this, wxID_ANY, ""), 1, wxALL, 5); + sizer->Add(AddMinifigSlot(1, 1, currentIndex, ids[1]), 1, wxALL, 5); + sizer->Add(new wxStaticText(this, wxID_ANY, ""), 1, wxALL, 5); + sizer->Add(AddMinifigSlot(3, 2, currentIndex, ids[2]), 1, wxALL, 5); + + sizer->Add(AddMinifigSlot(2, 3, currentIndex, ids[3]), 1, wxALL, 5); + sizer->Add(AddMinifigSlot(2, 4, currentIndex, ids[4]), 1, wxALL, 5); + sizer->Add(new wxStaticText(this, wxID_ANY, ""), 1, wxALL, 5); + sizer->Add(AddMinifigSlot(3, 5, currentIndex, ids[5]), 1, wxALL, 5); + sizer->Add(AddMinifigSlot(3, 6, currentIndex, ids[6]), 1, wxALL, 5); + + this->SetSizer(sizer); + this->Centre(wxBOTH); +} + +wxBoxSizer* MoveDimensionFigureDialog::AddMinifigSlot(uint8 pad, uint8 index, uint8 currentIndex, std::optional<uint32> currentId) +{ + auto* panel = new wxBoxSizer(wxVERTICAL); + + auto* label = new wxStaticText(this, wxID_ANY, "None"); + if (currentId) + label->SetLabel(nsyshid::g_dimensionstoypad.FindFigure(currentId.value())); + + auto* moveButton = new wxButton(this, wxID_ANY, _("Move Here")); + if (index == currentIndex) + moveButton->SetLabelText("Pick up and Place"); + + moveButton->Bind(wxEVT_BUTTON, [pad, index, this](wxCommandEvent&) { + m_newPad = pad; + m_newIndex = index; + this->EndModal(1); + }); + + panel->Add(label, 1, wxALL, 5); + panel->Add(moveButton, 1, wxALL, 5); + + return panel; +} + +uint8 MoveDimensionFigureDialog::GetNewPad() const +{ + return m_newPad; +} + +uint8 MoveDimensionFigureDialog::GetNewIndex() const +{ + return m_newIndex; +} + +std::array<std::optional<uint32>, 7> EmulatedUSBDeviceFrame::GetCurrentMinifigs() +{ + return m_dimSlots; } \ No newline at end of file diff --git a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h index ae29a036..78c70a4a 100644 --- a/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h +++ b/src/gui/EmulatedUSBDevices/EmulatedUSBDeviceFrame.h @@ -17,33 +17,47 @@ class wxStaticBox; class wxString; class wxTextCtrl; -class EmulatedUSBDeviceFrame : public wxFrame { +class EmulatedUSBDeviceFrame : public wxFrame +{ public: EmulatedUSBDeviceFrame(wxWindow* parent); ~EmulatedUSBDeviceFrame(); + std::array<std::optional<uint32>, 7> GetCurrentMinifigs(); private: wxCheckBox* m_emulatePortal; wxCheckBox* m_emulateBase; + wxCheckBox* m_emulateToypad; std::array<wxTextCtrl*, nsyshid::MAX_SKYLANDERS> m_skylanderSlots; std::array<wxTextCtrl*, nsyshid::MAX_FIGURES> m_infinitySlots; + std::array<wxTextCtrl*, 7> m_dimensionSlots; std::array<std::optional<std::tuple<uint8, uint16, uint16>>, nsyshid::MAX_SKYLANDERS> m_skySlots; + std::array<std::optional<uint32>, 7> m_dimSlots; wxPanel* AddSkylanderPage(wxNotebook* notebook); wxPanel* AddInfinityPage(wxNotebook* notebook); + wxPanel* AddDimensionsPage(wxNotebook* notebook); wxBoxSizer* AddSkylanderRow(uint8 row_number, wxStaticBox* box); wxBoxSizer* AddInfinityRow(wxString name, uint8 row_number, wxStaticBox* box); + wxBoxSizer* AddDimensionPanel(uint8 pad, uint8 index, wxStaticBox* box); void LoadSkylander(uint8 slot); void LoadSkylanderPath(uint8 slot, wxString path); void CreateSkylander(uint8 slot); void ClearSkylander(uint8 slot); + void UpdateSkylanderEdits(); void LoadFigure(uint8 slot); void LoadFigurePath(uint8 slot, wxString path); void CreateFigure(uint8 slot); void ClearFigure(uint8 slot); - void UpdateSkylanderEdits(); + void LoadMinifig(uint8 pad, uint8 index); + void LoadMinifigPath(wxString path_name, uint8 pad, uint8 index); + void CreateMinifig(uint8 pad, uint8 index); + void ClearMinifig(uint8 pad, uint8 index); + void MoveMinifig(uint8 pad, uint8 index); }; -class CreateSkylanderDialog : public wxDialog { + +class CreateSkylanderDialog : public wxDialog +{ public: explicit CreateSkylanderDialog(wxWindow* parent, uint8 slot); wxString GetFilePath() const; @@ -52,11 +66,37 @@ class CreateSkylanderDialog : public wxDialog { wxString m_filePath; }; -class CreateInfinityFigureDialog : public wxDialog { +class CreateInfinityFigureDialog : public wxDialog +{ public: explicit CreateInfinityFigureDialog(wxWindow* parent, uint8 slot); wxString GetFilePath() const; protected: wxString m_filePath; +}; + +class CreateDimensionFigureDialog : public wxDialog +{ + public: + explicit CreateDimensionFigureDialog(wxWindow* parent); + wxString GetFilePath() const; + + protected: + wxString m_filePath; +}; + +class MoveDimensionFigureDialog : public wxDialog +{ + public: + explicit MoveDimensionFigureDialog(EmulatedUSBDeviceFrame* parent, uint8 currentIndex); + uint8 GetNewPad() const; + uint8 GetNewIndex() const; + + protected: + uint8 m_newIndex = 0; + uint8 m_newPad = 0; + + private: + wxBoxSizer* AddMinifigSlot(uint8 pad, uint8 index, uint8 oldIndex, std::optional<uint32> currentId); }; \ No newline at end of file From a5717e1b11fe2a6c2c1be0afbd4908d765a777af Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Fri, 8 Nov 2024 01:07:53 +0100 Subject: [PATCH 269/314] FST: Refactoring to fix a read bug + verify all reads - Fixes a bug where corrupted data would be returned when reading files from unhashed sections with non-block aligned offset or size - Added hash checks for all reads where possible. This means that FST now can automatically catch corruptions when they are encountered while reading from the volume --- src/Cafe/Filesystem/FST/FST.cpp | 379 ++++++++++++++++++++++---------- src/Cafe/Filesystem/FST/FST.h | 38 +++- 2 files changed, 301 insertions(+), 116 deletions(-) diff --git a/src/Cafe/Filesystem/FST/FST.cpp b/src/Cafe/Filesystem/FST/FST.cpp index 570671d4..f1255778 100644 --- a/src/Cafe/Filesystem/FST/FST.cpp +++ b/src/Cafe/Filesystem/FST/FST.cpp @@ -3,8 +3,7 @@ #include "Cemu/ncrypto/ncrypto.h" #include "Cafe/Filesystem/WUD/wud.h" #include "util/crypto/aes128.h" -#include "openssl/evp.h" /* EVP_Digest */ -#include "openssl/sha.h" /* SHA1 / SHA256_DIGEST_LENGTH */ +#include "openssl/sha.h" /* SHA1 / SHA256 */ #include "fstUtil.h" #include "FST.h" @@ -141,7 +140,7 @@ struct DiscPartitionTableHeader static constexpr uint32 MAGIC_VALUE = 0xCCA6E67B; /* +0x00 */ uint32be magic; - /* +0x04 */ uint32be sectorSize; // must be 0x8000? + /* +0x04 */ uint32be blockSize; // must be 0x8000? /* +0x08 */ uint8 partitionTableHash[20]; // hash of the data range at +0x800 to end of sector (0x8000) /* +0x1C */ uint32be numPartitions; }; @@ -164,10 +163,10 @@ struct DiscPartitionHeader static constexpr uint32 MAGIC_VALUE = 0xCC93A4F5; /* +0x00 */ uint32be magic; - /* +0x04 */ uint32be sectorSize; // must match DISC_SECTOR_SIZE + /* +0x04 */ uint32be sectorSize; // must match DISC_SECTOR_SIZE for hashed blocks /* +0x08 */ uint32be ukn008; - /* +0x0C */ uint32be ukn00C; + /* +0x0C */ uint32be ukn00C; // h3 array size? /* +0x10 */ uint32be h3HashNum; /* +0x14 */ uint32be fstSize; // in bytes /* +0x18 */ uint32be fstSector; // relative to partition start @@ -178,13 +177,15 @@ struct DiscPartitionHeader /* +0x24 */ uint8 fstHashType; /* +0x25 */ uint8 fstEncryptionType; // purpose of this isn't really understood. Maybe it controls which key is being used? (1 -> disc key, 2 -> partition key) - /* +0x26 */ uint8 versionA; - /* +0x27 */ uint8 ukn027; // also a version field? + /* +0x26 */ uint8be versionA; + /* +0x27 */ uint8be ukn027; // also a version field? // there is an array at +0x40 ? Related to H3 list. Also related to value at +0x0C and h3HashNum + /* +0x28 */ uint8be _uknOrPadding028[0x18]; + /* +0x40 */ uint8be h3HashArray[32]; // dynamic size. Only present if fstHashType != 0 }; -static_assert(sizeof(DiscPartitionHeader) == 0x28); +static_assert(sizeof(DiscPartitionHeader) == 0x40+0x20); bool FSTVolume::FindDiscKey(const fs::path& path, NCrypto::AesKey& discTitleKey) { @@ -269,7 +270,7 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d cemuLog_log(LogType::Force, "Disc image rejected because decryption failed"); return nullptr; } - if (partitionHeader->sectorSize != DISC_SECTOR_SIZE) + if (partitionHeader->blockSize != DISC_SECTOR_SIZE) { cemuLog_log(LogType::Force, "Disc image rejected because partition sector size is invalid"); return nullptr; @@ -336,6 +337,9 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d cemu_assert_debug(partitionHeaderSI.fstEncryptionType == 1); // todo - check other fields? + if(partitionHeaderSI.fstHashType == 0 && partitionHeaderSI.h3HashNum != 0) + cemuLog_log(LogType::Force, "FST: Partition uses unhashed blocks but stores a non-zero amount of H3 hashes"); + // GM partition DiscPartitionHeader partitionHeaderGM{}; if (!readPartitionHeader(partitionHeaderGM, gmPartitionIndex)) @@ -349,9 +353,10 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d // if decryption is necessary // load SI FST dataSource->SetBaseOffset((uint64)partitionArray[siPartitionIndex].partitionAddress * DISC_SECTOR_SIZE); - auto siFST = OpenFST(dataSource.get(), (uint64)partitionHeaderSI.fstSector * DISC_SECTOR_SIZE, partitionHeaderSI.fstSize, &discTitleKey, static_cast<FSTVolume::ClusterHashMode>(partitionHeaderSI.fstHashType)); + auto siFST = OpenFST(dataSource.get(), (uint64)partitionHeaderSI.fstSector * DISC_SECTOR_SIZE, partitionHeaderSI.fstSize, &discTitleKey, static_cast<FSTVolume::ClusterHashMode>(partitionHeaderSI.fstHashType), nullptr); if (!siFST) return nullptr; + cemu_assert_debug(!(siFST->HashIsDisabled() && partitionHeaderSI.h3HashNum != 0)); // if hash is disabled, no H3 data may be present // load ticket file for partition that we want to decrypt NCrypto::ETicketParser ticketParser; std::vector<uint8> ticketData = siFST->ExtractFile(fmt::format("{:02x}/title.tik", gmPartitionIndex)); @@ -360,16 +365,32 @@ FSTVolume* FSTVolume::OpenFromDiscImage(const fs::path& path, NCrypto::AesKey& d cemuLog_log(LogType::Force, "Disc image ticket file is invalid"); return nullptr; } +#if 0 + // each SI partition seems to contain a title.tmd that we could parse and which should have information about the associated GM partition + // but the console seems to ignore this file for disc images, at least when mounting, so we shouldn't rely on it either + std::vector<uint8> tmdData = siFST->ExtractFile(fmt::format("{:02x}/title.tmd", gmPartitionIndex)); + if (tmdData.empty()) + { + cemuLog_log(LogType::Force, "Disc image TMD file is missing"); + return nullptr; + } + // parse TMD + NCrypto::TMDParser tmdParser; + if (!tmdParser.parse(tmdData.data(), tmdData.size())) + { + cemuLog_log(LogType::Force, "Disc image TMD file is invalid"); + return nullptr; + } +#endif delete siFST; - NCrypto::AesKey gmTitleKey; ticketParser.GetTitleKey(gmTitleKey); - // load GM partition dataSource->SetBaseOffset((uint64)partitionArray[gmPartitionIndex].partitionAddress * DISC_SECTOR_SIZE); - FSTVolume* r = OpenFST(std::move(dataSource), (uint64)partitionHeaderGM.fstSector * DISC_SECTOR_SIZE, partitionHeaderGM.fstSize, &gmTitleKey, static_cast<FSTVolume::ClusterHashMode>(partitionHeaderGM.fstHashType)); + FSTVolume* r = OpenFST(std::move(dataSource), (uint64)partitionHeaderGM.fstSector * DISC_SECTOR_SIZE, partitionHeaderGM.fstSize, &gmTitleKey, static_cast<FSTVolume::ClusterHashMode>(partitionHeaderGM.fstHashType), nullptr); if (r) SET_FST_ERROR(OK); + cemu_assert_debug(!(r->HashIsDisabled() && partitionHeaderGM.h3HashNum != 0)); // if hash is disabled, no H3 data may be present return r; } @@ -426,15 +447,15 @@ FSTVolume* FSTVolume::OpenFromContentFolder(fs::path folderPath, ErrorCode* erro } // load FST // fstSize = size of first cluster? - FSTVolume* fstVolume = FSTVolume::OpenFST(std::move(dataSource), 0, fstSize, &titleKey, fstHashMode); + FSTVolume* fstVolume = FSTVolume::OpenFST(std::move(dataSource), 0, fstSize, &titleKey, fstHashMode, &tmdParser); if (fstVolume) SET_FST_ERROR(OK); return fstVolume; } -FSTVolume* FSTVolume::OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode) +FSTVolume* FSTVolume::OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode, NCrypto::TMDParser* optionalTMD) { - cemu_assert_debug(fstHashMode != ClusterHashMode::RAW || fstHashMode != ClusterHashMode::RAW2); + cemu_assert_debug(fstHashMode != ClusterHashMode::RAW || fstHashMode != ClusterHashMode::RAW_STREAM); if (fstSize < sizeof(FSTHeader)) return nullptr; constexpr uint64 FST_CLUSTER_OFFSET = 0; @@ -465,6 +486,34 @@ FSTVolume* FSTVolume::OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint3 clusterTable[i].offset = clusterDataTable[i].offset; clusterTable[i].size = clusterDataTable[i].size; clusterTable[i].hashMode = static_cast<FSTVolume::ClusterHashMode>((uint8)clusterDataTable[i].hashMode); + clusterTable[i].hasContentHash = false; // from the TMD file (H4?) + } + // if the TMD is available (when opening .app files) we can use the extra info from it to validate unhashed clusters + // each content entry in the TMD corresponds to one cluster used by the FST + if(optionalTMD) + { + if(numCluster != optionalTMD->GetContentList().size()) + { + cemuLog_log(LogType::Force, "FST: Number of clusters does not match TMD content list"); + return nullptr; + } + auto& contentList = optionalTMD->GetContentList(); + for(size_t i=0; i<contentList.size(); i++) + { + auto& cluster = clusterTable[i]; + auto& content = contentList[i]; + cluster.hasContentHash = true; + cluster.contentHashIsSHA1 = HAS_FLAG(contentList[i].contentFlags, NCrypto::TMDParser::TMDContentFlags::FLAG_SHA1); + cluster.contentSize = content.size; + static_assert(sizeof(content.hash32) == sizeof(cluster.contentHash32)); + memcpy(cluster.contentHash32, content.hash32, sizeof(cluster.contentHash32)); + // if unhashed mode, then initialize the hash context + if(cluster.hashMode == ClusterHashMode::RAW || cluster.hashMode == ClusterHashMode::RAW_STREAM) + { + cluster.singleHashCtx.reset(EVP_MD_CTX_new()); + EVP_DigestInit_ex(cluster.singleHashCtx.get(), cluster.contentHashIsSHA1 ? EVP_sha1() : EVP_sha256(), nullptr); + } + } } // preprocess FST table FSTHeader_FileEntry* fileTable = (FSTHeader_FileEntry*)(clusterDataTable + numCluster); @@ -491,16 +540,17 @@ FSTVolume* FSTVolume::OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint3 fstVolume->m_offsetFactor = fstHeader->offsetFactor; fstVolume->m_sectorSize = DISC_SECTOR_SIZE; fstVolume->m_partitionTitlekey = *partitionTitleKey; - std::swap(fstVolume->m_cluster, clusterTable); - std::swap(fstVolume->m_entries, fstEntries); - std::swap(fstVolume->m_nameStringTable, nameStringTable); + fstVolume->m_hashIsDisabled = fstHeader->hashIsDisabled != 0; + fstVolume->m_cluster = std::move(clusterTable); + fstVolume->m_entries = std::move(fstEntries); + fstVolume->m_nameStringTable = std::move(nameStringTable); return fstVolume; } -FSTVolume* FSTVolume::OpenFST(std::unique_ptr<FSTDataSource> dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode) +FSTVolume* FSTVolume::OpenFST(std::unique_ptr<FSTDataSource> dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode, NCrypto::TMDParser* optionalTMD) { FSTDataSource* ds = dataSource.release(); - FSTVolume* fstVolume = OpenFST(ds, fstOffset, fstSize, partitionTitleKey, fstHashMode); + FSTVolume* fstVolume = OpenFST(ds, fstOffset, fstSize, partitionTitleKey, fstHashMode, optionalTMD); if (!fstVolume) { delete ds; @@ -757,7 +807,7 @@ uint32 FSTVolume::ReadFile(FSTFileHandle& fileHandle, uint32 offset, uint32 size return 0; cemu_assert_debug(!HAS_FLAG(entry.GetFlags(), FSTEntry::FLAGS::FLAG_LINK)); FSTCluster& cluster = m_cluster[entry.fileInfo.clusterIndex]; - if (cluster.hashMode == ClusterHashMode::RAW || cluster.hashMode == ClusterHashMode::RAW2) + if (cluster.hashMode == ClusterHashMode::RAW || cluster.hashMode == ClusterHashMode::RAW_STREAM) return ReadFile_HashModeRaw(entry.fileInfo.clusterIndex, entry, offset, size, dataOut); else if (cluster.hashMode == ClusterHashMode::HASH_INTERLEAVED) return ReadFile_HashModeHashed(entry.fileInfo.clusterIndex, entry, offset, size, dataOut); @@ -765,87 +815,15 @@ uint32 FSTVolume::ReadFile(FSTFileHandle& fileHandle, uint32 offset, uint32 size return 0; } -uint32 FSTVolume::ReadFile_HashModeRaw(uint32 clusterIndex, FSTEntry& entry, uint32 readOffset, uint32 readSize, void* dataOut) -{ - const uint32 readSizeInput = readSize; - uint8* dataOutU8 = (uint8*)dataOut; - if (readOffset >= entry.fileInfo.fileSize) - return 0; - else if ((readOffset + readSize) >= entry.fileInfo.fileSize) - readSize = (entry.fileInfo.fileSize - readOffset); - - const FSTCluster& cluster = m_cluster[clusterIndex]; - uint64 clusterOffset = (uint64)cluster.offset * m_sectorSize; - uint64 absFileOffset = entry.fileInfo.fileOffset * m_offsetFactor + readOffset; - - // make sure the raw range we read is aligned to AES block size (16) - uint64 readAddrStart = absFileOffset & ~0xF; - uint64 readAddrEnd = (absFileOffset + readSize + 0xF) & ~0xF; - - bool usesInitialIV = readOffset < 16; - if (!usesInitialIV) - readAddrStart -= 16; // read previous AES block since we require it for the IV - uint32 prePadding = (uint32)(absFileOffset - readAddrStart); // number of extra bytes we read before readOffset (for AES alignment and IV calculation) - uint32 postPadding = (uint32)(readAddrEnd - (absFileOffset + readSize)); - - uint8 readBuffer[64 * 1024]; - // read first chunk - // if file read offset (readOffset) is within the first AES-block then use initial IV calculated from cluster index - // otherwise read previous AES-block is the IV (AES-CBC) - uint64 readAddrCurrent = readAddrStart; - uint32 rawBytesToRead = (uint32)std::min((readAddrEnd - readAddrStart), (uint64)sizeof(readBuffer)); - if (m_dataSource->readData(clusterIndex, clusterOffset, readAddrCurrent, readBuffer, rawBytesToRead) != rawBytesToRead) - { - cemuLog_log(LogType::Force, "FST read error in raw content"); - return 0; - } - readAddrCurrent += rawBytesToRead; - - uint8 iv[16]{}; - if (usesInitialIV) - { - // for the first AES block, the IV is initialized from cluster index - iv[0] = (uint8)(clusterIndex >> 8); - iv[1] = (uint8)(clusterIndex >> 0); - AES128_CBC_decrypt_updateIV(readBuffer, readBuffer, rawBytesToRead, m_partitionTitlekey.b, iv); - std::memcpy(dataOutU8, readBuffer + prePadding, rawBytesToRead - prePadding - postPadding); - dataOutU8 += (rawBytesToRead - prePadding - postPadding); - readSize -= (rawBytesToRead - prePadding - postPadding); - } - else - { - // IV is initialized from previous AES block (AES-CBC) - std::memcpy(iv, readBuffer, 16); - AES128_CBC_decrypt_updateIV(readBuffer + 16, readBuffer + 16, rawBytesToRead - 16, m_partitionTitlekey.b, iv); - std::memcpy(dataOutU8, readBuffer + prePadding, rawBytesToRead - prePadding - postPadding); - dataOutU8 += (rawBytesToRead - prePadding - postPadding); - readSize -= (rawBytesToRead - prePadding - postPadding); - } - - // read remaining chunks - while (readSize > 0) - { - uint32 bytesToRead = (uint32)std::min((uint32)sizeof(readBuffer), readSize); - uint32 alignedBytesToRead = (bytesToRead + 15) & ~0xF; - if (m_dataSource->readData(clusterIndex, clusterOffset, readAddrCurrent, readBuffer, alignedBytesToRead) != alignedBytesToRead) - { - cemuLog_log(LogType::Force, "FST read error in raw content"); - return 0; - } - AES128_CBC_decrypt_updateIV(readBuffer, readBuffer, alignedBytesToRead, m_partitionTitlekey.b, iv); - std::memcpy(dataOutU8, readBuffer, bytesToRead); - dataOutU8 += bytesToRead; - readSize -= bytesToRead; - readAddrCurrent += alignedBytesToRead; - } - - return readSizeInput - readSize; -} - constexpr size_t BLOCK_SIZE = 0x10000; constexpr size_t BLOCK_HASH_SIZE = 0x0400; constexpr size_t BLOCK_FILE_SIZE = 0xFC00; +struct FSTRawBlock +{ + std::vector<uint8> rawData; // unhashed block size depends on sector size field in partition header +}; + struct FSTHashedBlock { uint8 rawData[BLOCK_SIZE]; @@ -887,12 +865,160 @@ struct FSTHashedBlock static_assert(sizeof(FSTHashedBlock) == BLOCK_SIZE); +struct FSTCachedRawBlock +{ + FSTRawBlock blockData; + uint8 ivForNextBlock[16]; + uint64 lastAccess; +}; + struct FSTCachedHashedBlock { FSTHashedBlock blockData; uint64 lastAccess; }; +// Checks cache fill state and if necessary drops least recently accessed block from the cache. Optionally allows to recycle the released cache entry to cut down cost of memory allocation and clearing +void FSTVolume::TrimCacheIfRequired(FSTCachedRawBlock** droppedRawBlock, FSTCachedHashedBlock** droppedHashedBlock) +{ + // calculate size used by cache + size_t cacheSize = 0; + for (auto& itr : m_cacheDecryptedRawBlocks) + cacheSize += itr.second->blockData.rawData.size(); + for (auto& itr : m_cacheDecryptedHashedBlocks) + cacheSize += sizeof(FSTCachedHashedBlock) + sizeof(FSTHashedBlock); + // only trim if cache is full (larger than 2MB) + if (cacheSize < 2*1024*1024) // 2MB + return; + // scan both cache lists to find least recently accessed block to drop + auto dropRawItr = std::min_element(m_cacheDecryptedRawBlocks.begin(), m_cacheDecryptedRawBlocks.end(), [](const auto& a, const auto& b) -> bool + { return a.second->lastAccess < b.second->lastAccess; }); + auto dropHashedItr = std::min_element(m_cacheDecryptedHashedBlocks.begin(), m_cacheDecryptedHashedBlocks.end(), [](const auto& a, const auto& b) -> bool + { return a.second->lastAccess < b.second->lastAccess; }); + uint64 lastAccess = std::numeric_limits<uint64>::max(); + if(dropRawItr != m_cacheDecryptedRawBlocks.end()) + lastAccess = dropRawItr->second->lastAccess; + if(dropHashedItr != m_cacheDecryptedHashedBlocks.end()) + lastAccess = std::min<uint64>(lastAccess, dropHashedItr->second->lastAccess); + if(dropRawItr != m_cacheDecryptedRawBlocks.end() && dropRawItr->second->lastAccess == lastAccess) + { + if (droppedRawBlock) + *droppedRawBlock = dropRawItr->second; + else + delete dropRawItr->second; + m_cacheDecryptedRawBlocks.erase(dropRawItr); + return; + } + else if(dropHashedItr != m_cacheDecryptedHashedBlocks.end() && dropHashedItr->second->lastAccess == lastAccess) + { + if (droppedHashedBlock) + *droppedHashedBlock = dropHashedItr->second; + else + delete dropHashedItr->second; + m_cacheDecryptedHashedBlocks.erase(dropHashedItr); + } +} + +void FSTVolume::DetermineUnhashedBlockIV(uint32 clusterIndex, uint32 blockIndex, uint8 ivOut[16]) +{ + memset(ivOut, 0, sizeof(ivOut)); + if(blockIndex == 0) + { + ivOut[0] = (uint8)(clusterIndex >> 8); + ivOut[1] = (uint8)(clusterIndex >> 0); + } + else + { + // the last 16 encrypted bytes of the previous block are the IV (AES CBC) + // if the previous block is cached we can grab the IV from there. Otherwise we have to read the 16 bytes from the data source + uint32 prevBlockIndex = blockIndex - 1; + uint64 cacheBlockId = ((uint64)clusterIndex << (64 - 16)) | (uint64)prevBlockIndex; + auto itr = m_cacheDecryptedRawBlocks.find(cacheBlockId); + if (itr != m_cacheDecryptedRawBlocks.end()) + { + memcpy(ivOut, itr->second->ivForNextBlock, 16); + } + else + { + cemu_assert(m_sectorSize >= 16); + uint64 clusterOffset = (uint64)m_cluster[clusterIndex].offset * m_sectorSize; + uint8 prevIV[16]; + if (m_dataSource->readData(clusterIndex, clusterOffset, blockIndex * m_sectorSize - 16, prevIV, 16) != 16) + { + cemuLog_log(LogType::Force, "Failed to read IV for raw FST block"); + m_detectedCorruption = true; + return; + } + memcpy(ivOut, prevIV, 16); + } + } +} + +FSTCachedRawBlock* FSTVolume::GetDecryptedRawBlock(uint32 clusterIndex, uint32 blockIndex) +{ + FSTCluster& cluster = m_cluster[clusterIndex]; + uint64 clusterOffset = (uint64)cluster.offset * m_sectorSize; + // generate id for cache + uint64 cacheBlockId = ((uint64)clusterIndex << (64 - 16)) | (uint64)blockIndex; + // lookup block in cache + FSTCachedRawBlock* block = nullptr; + auto itr = m_cacheDecryptedRawBlocks.find(cacheBlockId); + if (itr != m_cacheDecryptedRawBlocks.end()) + { + block = itr->second; + block->lastAccess = ++m_cacheAccessCounter; + return block; + } + // if cache already full, drop least recently accessed block and recycle FSTCachedRawBlock object if possible + TrimCacheIfRequired(&block, nullptr); + if (!block) + block = new FSTCachedRawBlock(); + block->blockData.rawData.resize(m_sectorSize); + // block not cached, read new + block->lastAccess = ++m_cacheAccessCounter; + if (m_dataSource->readData(clusterIndex, clusterOffset, blockIndex * m_sectorSize, block->blockData.rawData.data(), m_sectorSize) != m_sectorSize) + { + cemuLog_log(LogType::Force, "Failed to read raw FST block"); + delete block; + m_detectedCorruption = true; + return nullptr; + } + // decrypt hash data + uint8 iv[16]{}; + DetermineUnhashedBlockIV(clusterIndex, blockIndex, iv); + memcpy(block->ivForNextBlock, block->blockData.rawData.data() + m_sectorSize - 16, 16); + AES128_CBC_decrypt(block->blockData.rawData.data(), block->blockData.rawData.data(), m_sectorSize, m_partitionTitlekey.b, iv); + // if this is the next block, then hash it + if(cluster.hasContentHash) + { + if(cluster.singleHashNumBlocksHashed == blockIndex) + { + cemu_assert_debug(!(cluster.contentSize % m_sectorSize)); // size should be multiple of sector size? Regardless, the hashing code below can handle non-aligned sizes + bool isLastBlock = blockIndex == (std::max<uint32>(cluster.contentSize / m_sectorSize, 1) - 1); + uint32 hashSize = m_sectorSize; + if(isLastBlock) + hashSize = cluster.contentSize - (uint64)blockIndex*m_sectorSize; + EVP_DigestUpdate(cluster.singleHashCtx.get(), block->blockData.rawData.data(), hashSize); + cluster.singleHashNumBlocksHashed++; + if(isLastBlock) + { + uint8 hash[32]; + EVP_DigestFinal_ex(cluster.singleHashCtx.get(), hash, nullptr); + if(memcmp(hash, cluster.contentHash32, cluster.contentHashIsSHA1 ? 20 : 32) != 0) + { + cemuLog_log(LogType::Force, "FST: Raw section hash mismatch"); + delete block; + m_detectedCorruption = true; + return nullptr; + } + } + } + } + // register in cache + m_cacheDecryptedRawBlocks.emplace(cacheBlockId, block); + return block; +} + FSTCachedHashedBlock* FSTVolume::GetDecryptedHashedBlock(uint32 clusterIndex, uint32 blockIndex) { const FSTCluster& cluster = m_cluster[clusterIndex]; @@ -908,22 +1034,17 @@ FSTCachedHashedBlock* FSTVolume::GetDecryptedHashedBlock(uint32 clusterIndex, ui block->lastAccess = ++m_cacheAccessCounter; return block; } - // if cache already full, drop least recently accessed block (but recycle the FSTHashedBlock* object) - if (m_cacheDecryptedHashedBlocks.size() >= 16) - { - auto dropItr = std::min_element(m_cacheDecryptedHashedBlocks.begin(), m_cacheDecryptedHashedBlocks.end(), [](const auto& a, const auto& b) -> bool - { return a.second->lastAccess < b.second->lastAccess; }); - block = dropItr->second; - m_cacheDecryptedHashedBlocks.erase(dropItr); - } - else + // if cache already full, drop least recently accessed block and recycle FSTCachedHashedBlock object if possible + TrimCacheIfRequired(nullptr, &block); + if (!block) block = new FSTCachedHashedBlock(); // block not cached, read new block->lastAccess = ++m_cacheAccessCounter; if (m_dataSource->readData(clusterIndex, clusterOffset, blockIndex * BLOCK_SIZE, block->blockData.rawData, BLOCK_SIZE) != BLOCK_SIZE) { - cemuLog_log(LogType::Force, "Failed to read FST block"); + cemuLog_log(LogType::Force, "Failed to read hashed FST block"); delete block; + m_detectedCorruption = true; return nullptr; } // decrypt hash data @@ -931,11 +1052,46 @@ FSTCachedHashedBlock* FSTVolume::GetDecryptedHashedBlock(uint32 clusterIndex, ui AES128_CBC_decrypt(block->blockData.getHashData(), block->blockData.getHashData(), BLOCK_HASH_SIZE, m_partitionTitlekey.b, iv); // decrypt file data AES128_CBC_decrypt(block->blockData.getFileData(), block->blockData.getFileData(), BLOCK_FILE_SIZE, m_partitionTitlekey.b, block->blockData.getH0Hash(blockIndex%16)); + // compare with H0 to verify data integrity + NCrypto::CHash160 h0; + SHA1(block->blockData.getFileData(), BLOCK_FILE_SIZE, h0.b); + uint32 h0Index = (blockIndex % 4096); + if (memcmp(h0.b, block->blockData.getH0Hash(h0Index & 0xF), sizeof(h0.b)) != 0) + { + cemuLog_log(LogType::Force, "FST: Hash H0 mismatch in hashed block (section {} index {})", clusterIndex, blockIndex); + delete block; + m_detectedCorruption = true; + return nullptr; + } // register in cache m_cacheDecryptedHashedBlocks.emplace(cacheBlockId, block); return block; } +uint32 FSTVolume::ReadFile_HashModeRaw(uint32 clusterIndex, FSTEntry& entry, uint32 readOffset, uint32 readSize, void* dataOut) +{ + uint8* dataOutU8 = (uint8*)dataOut; + if (readOffset >= entry.fileInfo.fileSize) + return 0; + else if ((readOffset + readSize) >= entry.fileInfo.fileSize) + readSize = (entry.fileInfo.fileSize - readOffset); + uint64 absFileOffset = entry.fileInfo.fileOffset * m_offsetFactor + readOffset; + uint32 remainingReadSize = readSize; + while (remainingReadSize > 0) + { + const FSTCachedRawBlock* rawBlock = this->GetDecryptedRawBlock(clusterIndex, absFileOffset/m_sectorSize); + if (!rawBlock) + break; + uint32 blockOffset = (uint32)(absFileOffset % m_sectorSize); + uint32 bytesToRead = std::min<uint32>(remainingReadSize, m_sectorSize - blockOffset); + std::memcpy(dataOutU8, rawBlock->blockData.rawData.data() + blockOffset, bytesToRead); + dataOutU8 += bytesToRead; + remainingReadSize -= bytesToRead; + absFileOffset += bytesToRead; + } + return readSize - remainingReadSize; +} + uint32 FSTVolume::ReadFile_HashModeHashed(uint32 clusterIndex, FSTEntry& entry, uint32 readOffset, uint32 readSize, void* dataOut) { /* @@ -966,7 +1122,6 @@ uint32 FSTVolume::ReadFile_HashModeHashed(uint32 clusterIndex, FSTEntry& entry, */ const FSTCluster& cluster = m_cluster[clusterIndex]; - uint64 clusterBaseOffset = (uint64)cluster.offset * m_sectorSize; uint64 fileReadOffset = entry.fileInfo.fileOffset * m_offsetFactor + readOffset; uint32 blockIndex = (uint32)(fileReadOffset / BLOCK_FILE_SIZE); uint32 bytesRemaining = readSize; @@ -1019,6 +1174,8 @@ bool FSTVolume::Next(FSTDirectoryIterator& directoryIterator, FSTFileHandle& fil FSTVolume::~FSTVolume() { + for (auto& itr : m_cacheDecryptedRawBlocks) + delete itr.second; for (auto& itr : m_cacheDecryptedHashedBlocks) delete itr.second; if (m_sourceIsOwned) @@ -1115,4 +1272,4 @@ bool FSTVerifier::VerifyHashedContentFile(FileStream* fileContent, const NCrypto void FSTVolumeTest() { FSTPathUnitTest(); -} \ No newline at end of file +} diff --git a/src/Cafe/Filesystem/FST/FST.h b/src/Cafe/Filesystem/FST/FST.h index 24fc39ea..601799ce 100644 --- a/src/Cafe/Filesystem/FST/FST.h +++ b/src/Cafe/Filesystem/FST/FST.h @@ -1,5 +1,6 @@ #pragma once #include "Cemu/ncrypto/ncrypto.h" +#include "openssl/evp.h" struct FSTFileHandle { @@ -45,6 +46,7 @@ public: ~FSTVolume(); uint32 GetFileCount() const; + bool HasCorruption() const { return m_detectedCorruption; } bool OpenFile(std::string_view path, FSTFileHandle& fileHandleOut, bool openOnlyFiles = false); @@ -86,15 +88,25 @@ private: enum class ClusterHashMode : uint8 { RAW = 0, // raw data + encryption, no hashing? - RAW2 = 1, // raw data + encryption, with hash stored in tmd? + RAW_STREAM = 1, // raw data + encryption, with hash stored in tmd? HASH_INTERLEAVED = 2, // hashes + raw interleaved in 0x10000 blocks (0x400 bytes of hashes at the beginning, followed by 0xFC00 bytes of data) }; struct FSTCluster { + FSTCluster() : singleHashCtx(nullptr, &EVP_MD_CTX_free) {} + uint32 offset; uint32 size; ClusterHashMode hashMode; + // extra data if TMD is available + bool hasContentHash; + uint8 contentHash32[32]; + bool contentHashIsSHA1; // if true then it's SHA1 (with extra bytes zeroed out), otherwise it's SHA256 + uint64 contentSize; // size of the content (in blocks) + // hash context for single hash mode (content hash must be available) + std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)> singleHashCtx; // unique_ptr to make this move-only + uint32 singleHashNumBlocksHashed{0}; }; struct FSTEntry @@ -164,17 +176,30 @@ private: bool m_sourceIsOwned{}; uint32 m_sectorSize{}; // for cluster offsets uint32 m_offsetFactor{}; // for file offsets + bool m_hashIsDisabled{}; // disables hash verification (for all clusters of this volume?) std::vector<FSTCluster> m_cluster; std::vector<FSTEntry> m_entries; std::vector<char> m_nameStringTable; NCrypto::AesKey m_partitionTitlekey; + bool m_detectedCorruption{false}; - /* Cache for decrypted hashed blocks */ + bool HashIsDisabled() const + { + return m_hashIsDisabled; + } + + /* Cache for decrypted raw and hashed blocks */ + std::unordered_map<uint64, struct FSTCachedRawBlock*> m_cacheDecryptedRawBlocks; std::unordered_map<uint64, struct FSTCachedHashedBlock*> m_cacheDecryptedHashedBlocks; uint64 m_cacheAccessCounter{}; + void DetermineUnhashedBlockIV(uint32 clusterIndex, uint32 blockIndex, uint8 ivOut[16]); + + struct FSTCachedRawBlock* GetDecryptedRawBlock(uint32 clusterIndex, uint32 blockIndex); struct FSTCachedHashedBlock* GetDecryptedHashedBlock(uint32 clusterIndex, uint32 blockIndex); + void TrimCacheIfRequired(struct FSTCachedRawBlock** droppedRawBlock, struct FSTCachedHashedBlock** droppedHashedBlock); + /* File reading */ uint32 ReadFile_HashModeRaw(uint32 clusterIndex, FSTEntry& entry, uint32 readOffset, uint32 readSize, void* dataOut); uint32 ReadFile_HashModeHashed(uint32 clusterIndex, FSTEntry& entry, uint32 readOffset, uint32 readSize, void* dataOut); @@ -185,7 +210,10 @@ private: /* +0x00 */ uint32be magic; /* +0x04 */ uint32be offsetFactor; /* +0x08 */ uint32be numCluster; - /* +0x0C */ uint32be ukn0C; + /* +0x0C */ uint8be hashIsDisabled; + /* +0x0D */ uint8be ukn0D; + /* +0x0E */ uint8be ukn0E; + /* +0x0F */ uint8be ukn0F; /* +0x10 */ uint32be ukn10; /* +0x14 */ uint32be ukn14; /* +0x18 */ uint32be ukn18; @@ -262,8 +290,8 @@ private: static_assert(sizeof(FSTHeader_FileEntry) == 0x10); - static FSTVolume* OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode); - static FSTVolume* OpenFST(std::unique_ptr<FSTDataSource> dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode); + static FSTVolume* OpenFST(FSTDataSource* dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode, NCrypto::TMDParser* optionalTMD); + static FSTVolume* OpenFST(std::unique_ptr<FSTDataSource> dataSource, uint64 fstOffset, uint32 fstSize, NCrypto::AesKey* partitionTitleKey, ClusterHashMode fstHashMode, NCrypto::TMDParser* optionalTMD); static bool ProcessFST(FSTHeader_FileEntry* fileTable, uint32 numFileEntries, uint32 numCluster, std::vector<char>& nameStringTable, std::vector<FSTEntry>& fstEntries); bool MatchFSTEntryName(FSTEntry& entry, std::string_view comparedName) From 66658351c1e274265ddc18643b761f7df1e21e11 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 10 Nov 2024 10:10:46 +0100 Subject: [PATCH 270/314] erreula: Rework implementation and fix bugs - ErrEula doesn't disappear on its own anymore. The expected behavior is for the game to call Disappear once a button has been selected. This fixes issues where the dialog would softlock in some games - Modernized code a bit - Added a subtle fade in/out effect --- src/Cafe/CafeSystem.cpp | 42 +-- src/Cafe/CafeSystem.h | 7 +- src/Cafe/OS/libs/coreinit/coreinit_Time.h | 7 +- src/Cafe/OS/libs/erreula/erreula.cpp | 423 ++++++++++++++-------- src/gui/MainWindow.cpp | 12 +- 5 files changed, 311 insertions(+), 180 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 51de3550..88e0ed3d 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -637,40 +637,40 @@ namespace CafeSystem fsc_unmount("/cemuBossStorage/", FSC_PRIORITY_BASE); } - STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId) + PREPARE_STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId) { cemuLog_log(LogType::Force, "Mounting title {:016x}", (uint64)titleId); sGameInfo_ForegroundTitle = CafeTitleList::GetGameInfo(titleId); if (!sGameInfo_ForegroundTitle.IsValid()) { cemuLog_log(LogType::Force, "Mounting failed: Game meta information is either missing, inaccessible or not valid (missing or invalid .xml files in code and meta folder)"); - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; } // check base TitleInfo& titleBase = sGameInfo_ForegroundTitle.GetBase(); if (!titleBase.IsValid()) - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; if(!titleBase.ParseXmlInfo()) - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; cemuLog_log(LogType::Force, "Base: {}", titleBase.GetPrintPath()); // mount base if (!titleBase.Mount("/vol/content", "content", FSC_PRIORITY_BASE) || !titleBase.Mount(GetInternalVirtualCodeFolder(), "code", FSC_PRIORITY_BASE)) { cemuLog_log(LogType::Force, "Mounting failed"); - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; } // check update TitleInfo& titleUpdate = sGameInfo_ForegroundTitle.GetUpdate(); if (titleUpdate.IsValid()) { if (!titleUpdate.ParseXmlInfo()) - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; cemuLog_log(LogType::Force, "Update: {}", titleUpdate.GetPrintPath()); // mount update if (!titleUpdate.Mount("/vol/content", "content", FSC_PRIORITY_PATCH) || !titleUpdate.Mount(GetInternalVirtualCodeFolder(), "code", FSC_PRIORITY_PATCH)) { cemuLog_log(LogType::Force, "Mounting failed"); - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; } } else @@ -682,20 +682,20 @@ namespace CafeSystem // todo - support for multi-title AOC TitleInfo& titleAOC = aocList[0]; if (!titleAOC.ParseXmlInfo()) - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; cemu_assert_debug(titleAOC.IsValid()); cemuLog_log(LogType::Force, "DLC: {}", titleAOC.GetPrintPath()); // mount AOC if (!titleAOC.Mount(fmt::format("/vol/aoc{:016x}", titleAOC.GetAppTitleId()), "content", FSC_PRIORITY_PATCH)) { cemuLog_log(LogType::Force, "Mounting failed"); - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; } } else cemuLog_log(LogType::Force, "DLC: Not present"); sForegroundTitleId = titleId; - return STATUS_CODE::SUCCESS; + return PREPARE_STATUS_CODE::SUCCESS; } void UnmountForegroundTitle() @@ -723,7 +723,7 @@ namespace CafeSystem } } - STATUS_CODE SetupExecutable() + PREPARE_STATUS_CODE SetupExecutable() { // set rpx path from cos.xml if available _pathToBaseExecutable = _pathToExecutable; @@ -755,7 +755,7 @@ namespace CafeSystem } } LoadMainExecutable(); - return STATUS_CODE::SUCCESS; + return PREPARE_STATUS_CODE::SUCCESS; } void SetupMemorySpace() @@ -769,7 +769,7 @@ namespace CafeSystem memory_unmapForCurrentTitle(); } - STATUS_CODE PrepareForegroundTitle(TitleId titleId) + PREPARE_STATUS_CODE PrepareForegroundTitle(TitleId titleId) { CafeTitleList::WaitForMandatoryScan(); sLaunchModeIsStandalone = false; @@ -780,21 +780,21 @@ namespace CafeSystem // mount mlc storage MountBaseDirectories(); // mount title folders - STATUS_CODE r = LoadAndMountForegroundTitle(titleId); - if (r != STATUS_CODE::SUCCESS) + PREPARE_STATUS_CODE r = LoadAndMountForegroundTitle(titleId); + if (r != PREPARE_STATUS_CODE::SUCCESS) return r; gameProfile_load(); // setup memory space and PPC recompiler SetupMemorySpace(); PPCRecompiler_init(); r = SetupExecutable(); // load RPX - if (r != STATUS_CODE::SUCCESS) + if (r != PREPARE_STATUS_CODE::SUCCESS) return r; InitVirtualMlcStorage(); - return STATUS_CODE::SUCCESS; + return PREPARE_STATUS_CODE::SUCCESS; } - STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path) + PREPARE_STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path) { sLaunchModeIsStandalone = true; cemuLog_log(LogType::Force, "Launching executable in standalone mode due to incorrect layout or missing meta files"); @@ -812,7 +812,7 @@ namespace CafeSystem if (!r) { cemuLog_log(LogType::Force, "Failed to mount {}", _pathToUtf8(contentPath)); - return STATUS_CODE::UNABLE_TO_MOUNT; + return PREPARE_STATUS_CODE::UNABLE_TO_MOUNT; } } } @@ -824,7 +824,7 @@ namespace CafeSystem // since a lot of systems (including save folder location) rely on a TitleId, we derive a placeholder id from the executable hash auto execData = fsc_extractFile(_pathToExecutable.c_str()); if (!execData) - return STATUS_CODE::INVALID_RPX; + return PREPARE_STATUS_CODE::INVALID_RPX; uint32 h = generateHashFromRawRPXData(execData->data(), execData->size()); sForegroundTitleId = 0xFFFFFFFF00000000ULL | (uint64)h; cemuLog_log(LogType::Force, "Generated placeholder TitleId: {:016x}", sForegroundTitleId); @@ -834,7 +834,7 @@ namespace CafeSystem // load executable SetupExecutable(); InitVirtualMlcStorage(); - return STATUS_CODE::SUCCESS; + return PREPARE_STATUS_CODE::SUCCESS; } void _LaunchTitleThread() diff --git a/src/Cafe/CafeSystem.h b/src/Cafe/CafeSystem.h index c4043a59..e9de8d7d 100644 --- a/src/Cafe/CafeSystem.h +++ b/src/Cafe/CafeSystem.h @@ -15,20 +15,19 @@ namespace CafeSystem virtual void CafeRecreateCanvas() = 0; }; - enum class STATUS_CODE + enum class PREPARE_STATUS_CODE { SUCCESS, INVALID_RPX, UNABLE_TO_MOUNT, // failed to mount through TitleInfo (most likely caused by an invalid or outdated path) - //BAD_META_DATA, - the title list only stores titles with valid meta, so this error code is impossible }; void Initialize(); void SetImplementation(SystemImplementation* impl); void Shutdown(); - STATUS_CODE PrepareForegroundTitle(TitleId titleId); - STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path); + PREPARE_STATUS_CODE PrepareForegroundTitle(TitleId titleId); + PREPARE_STATUS_CODE PrepareForegroundTitleFromStandaloneRPX(const fs::path& path); void LaunchForegroundTitle(); bool IsTitleRunning(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.h b/src/Cafe/OS/libs/coreinit/coreinit_Time.h index 018e8eb7..3aa92b99 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.h @@ -40,7 +40,12 @@ namespace coreinit inline TimerTicks ConvertNsToTimerTicks(uint64 ns) { - return ((GetTimerClock() / 31250LL) * ((ns)) / 32000LL); + return ((GetTimerClock() / 31250LL) * ((TimerTicks)ns) / 32000LL); + } + + inline TimerTicks ConvertMsToTimerTicks(uint64 ms) + { + return (TimerTicks)ms * GetTimerClock() / 1000LL; } }; diff --git a/src/Cafe/OS/libs/erreula/erreula.cpp b/src/Cafe/OS/libs/erreula/erreula.cpp index a7f2f35c..342e8b64 100644 --- a/src/Cafe/OS/libs/erreula/erreula.cpp +++ b/src/Cafe/OS/libs/erreula/erreula.cpp @@ -9,32 +9,45 @@ #include <wx/msgdlg.h> #include "Cafe/OS/libs/coreinit/coreinit_FS.h" +#include "Cafe/OS/libs/coreinit/coreinit_Time.h" #include "Cafe/OS/libs/vpad/vpad.h" namespace nn { namespace erreula { -#define RESULTTYPE_NONE 0 -#define RESULTTYPE_FINISH 1 -#define RESULTTYPE_NEXT 2 -#define RESULTTYPE_JUMP 3 -#define RESULTTYPE_PASSWORD 4 -#define ERRORTYPE_CODE 0 -#define ERRORTYPE_TEXT 1 -#define ERRORTYPE_TEXT_ONE_BUTTON 2 -#define ERRORTYPE_TEXT_TWO_BUTTON 3 - -#define ERREULA_STATE_HIDDEN 0 -#define ERREULA_STATE_APPEARING 1 -#define ERREULA_STATE_VISIBLE 2 -#define ERREULA_STATE_DISAPPEARING 3 - - struct AppearArg_t + enum class ErrorDialogType : uint32 { - AppearArg_t() = default; - AppearArg_t(const AppearArg_t& o) + Code = 0, + Text = 1, + TextOneButton = 2, + TextTwoButton = 3 + }; + + static const sint32 FADE_TIME = 80; + + enum class ErrEulaState : uint32 + { + Hidden = 0, + Appearing = 1, + Visible = 2, + Disappearing = 3 + }; + + enum class ResultType : uint32 + { + None = 0, + Finish = 1, + Next = 2, + Jump = 3, + Password = 4 + }; + + struct AppearError + { + AppearError() = default; + AppearError(const AppearError& o) { errorType = o.errorType; screenType = o.screenType; @@ -49,7 +62,7 @@ namespace erreula drawCursor = o.drawCursor; } - uint32be errorType; + betype<ErrorDialogType> errorType; uint32be screenType; uint32be controllerType; uint32be holdType; @@ -63,7 +76,9 @@ namespace erreula bool drawCursor{}; }; - static_assert(sizeof(AppearArg_t) == 0x2C); // maybe larger + using AppearArg = AppearError; + + static_assert(sizeof(AppearError) == 0x2C); // maybe larger struct HomeNixSignArg_t { @@ -80,6 +95,132 @@ namespace erreula static_assert(sizeof(ControllerInfo_t) == 0x14); // maybe larger + class ErrEulaInstance + { + public: + enum class BUTTON_SELECTION : uint32 + { + NONE = 0xFFFFFFFF, + LEFT = 0, + RIGHT = 1, + }; + + void Init() + { + m_buttonSelection = BUTTON_SELECTION::NONE; + m_resultCode = -1; + m_resultCodeForLeftButton = 0; + m_resultCodeForRightButton = 0; + SetState(ErrEulaState::Hidden); + } + + void DoAppearError(AppearArg* arg) + { + m_buttonSelection = BUTTON_SELECTION::NONE; + m_resultCode = -1; + m_resultCodeForLeftButton = -1; + m_resultCodeForRightButton = -1; + // for standard dialog its 0 and 1? + m_resultCodeForLeftButton = 0; + m_resultCodeForRightButton = 1; + SetState(ErrEulaState::Appearing); + } + + void DoDisappearError() + { + if(m_state != ErrEulaState::Visible) + return; + SetState(ErrEulaState::Disappearing); + } + + void DoCalc() + { + // appearing and disappearing state will automatically advance after some time + if (m_state == ErrEulaState::Appearing || m_state == ErrEulaState::Disappearing) + { + uint32 elapsedTick = coreinit::OSGetTime() - m_lastStateChange; + if (elapsedTick > coreinit::EspressoTime::ConvertMsToTimerTicks(FADE_TIME)) + { + SetState(m_state == ErrEulaState::Appearing ? ErrEulaState::Visible : ErrEulaState::Hidden); + } + } + } + + bool IsDecideSelectButtonError() const + { + return m_buttonSelection != BUTTON_SELECTION::NONE; + } + + bool IsDecideSelectLeftButtonError() const + { + return m_buttonSelection != BUTTON_SELECTION::LEFT; + } + + bool IsDecideSelectRightButtonError() const + { + return m_buttonSelection != BUTTON_SELECTION::RIGHT; + } + + void SetButtonSelection(BUTTON_SELECTION selection) + { + cemu_assert_debug(m_buttonSelection == BUTTON_SELECTION::NONE); + m_buttonSelection = selection; + cemu_assert_debug(selection == BUTTON_SELECTION::LEFT || selection == BUTTON_SELECTION::RIGHT); + m_resultCode = selection == BUTTON_SELECTION::LEFT ? m_resultCodeForLeftButton : m_resultCodeForRightButton; + } + + ErrEulaState GetState() const + { + return m_state; + } + + sint32 GetResultCode() const + { + return m_resultCode; + } + + ResultType GetResultType() const + { + if(m_resultCode == -1) + return ResultType::None; + if(m_resultCode < 10) + return ResultType::Finish; + if(m_resultCode >= 9999) + return ResultType::Next; + if(m_resultCode == 40) + return ResultType::Password; + return ResultType::Jump; + } + + float GetFadeTransparency() const + { + if(m_state == ErrEulaState::Appearing || m_state == ErrEulaState::Disappearing) + { + uint32 elapsedTick = coreinit::OSGetTime() - m_lastStateChange; + if(m_state == ErrEulaState::Appearing) + return std::min<float>(1.0f, (float)elapsedTick / (float)coreinit::EspressoTime::ConvertMsToTimerTicks(FADE_TIME)); + else + return std::max<float>(0.0f, 1.0f - (float)elapsedTick / (float)coreinit::EspressoTime::ConvertMsToTimerTicks(FADE_TIME)); + } + return 1.0f; + } + + private: + void SetState(ErrEulaState state) + { + m_state = state; + m_lastStateChange = coreinit::OSGetTime(); + } + + ErrEulaState m_state; + uint32 m_lastStateChange; + + /* +0x30 */ betype<sint32> m_resultCode; + /* +0x239C */ betype<BUTTON_SELECTION> m_buttonSelection; + /* +0x23A0 */ betype<sint32> m_resultCodeForLeftButton; + /* +0x23A4 */ betype<sint32> m_resultCodeForRightButton; + }; + struct ErrEula_t { SysAllocator<coreinit::OSMutex> mutex; @@ -87,17 +228,11 @@ namespace erreula uint32 langType; MEMPTR<coreinit::FSClient_t> fsClient; - AppearArg_t currentDialog; - uint32 state; - bool buttonPressed; - bool rightButtonPressed; + std::unique_ptr<ErrEulaInstance> errEulaInstance; + AppearError currentDialog; bool homeNixSignVisible; - - std::chrono::steady_clock::time_point stateTimer{}; } g_errEula = {}; - - std::wstring GetText(uint16be* text) { @@ -113,22 +248,61 @@ namespace erreula } - void export_ErrEulaCreate(PPCInterpreter_t* hCPU) + void ErrEulaCreate(void* workmem, uint32 regionType, uint32 langType, coreinit::FSClient_t* fsClient) { - ppcDefineParamMEMPTR(thisptr, uint8, 0); - ppcDefineParamU32(regionType, 1); - ppcDefineParamU32(langType, 2); - ppcDefineParamMEMPTR(fsClient, coreinit::FSClient_t, 3); - coreinit::OSLockMutex(&g_errEula.mutex); g_errEula.regionType = regionType; g_errEula.langType = langType; g_errEula.fsClient = fsClient; + cemu_assert_debug(!g_errEula.errEulaInstance); + g_errEula.errEulaInstance = std::make_unique<ErrEulaInstance>(); + g_errEula.errEulaInstance->Init(); coreinit::OSUnlockMutex(&g_errEula.mutex); + } - osLib_returnFromFunction(hCPU, 0); + void ErrEulaDestroy() + { + g_errEula.errEulaInstance.reset(); + } + + // check if any dialog button was selected + bool IsDecideSelectButtonError() + { + if(!g_errEula.errEulaInstance) + return false; + return g_errEula.errEulaInstance->IsDecideSelectButtonError(); + } + + // check if left dialog button was selected + bool IsDecideSelectLeftButtonError() + { + if(!g_errEula.errEulaInstance) + return false; + return g_errEula.errEulaInstance->IsDecideSelectLeftButtonError(); + } + + // check if right dialog button was selected + bool IsDecideSelectRightButtonError() + { + if(!g_errEula.errEulaInstance) + return false; + return g_errEula.errEulaInstance->IsDecideSelectRightButtonError(); + } + + sint32 GetResultCode() + { + if(!g_errEula.errEulaInstance) + return -1; + return g_errEula.errEulaInstance->GetResultCode(); + } + + ResultType GetResultType() + { + if(!g_errEula.errEulaInstance) + return ResultType::None; + return g_errEula.errEulaInstance->GetResultType(); } void export_AppearHomeNixSign(PPCInterpreter_t* hCPU) @@ -137,28 +311,24 @@ namespace erreula osLib_returnFromFunction(hCPU, 0); } - void export_AppearError(PPCInterpreter_t* hCPU) + void ErrEulaAppearError(AppearArg* arg) { - ppcDefineParamMEMPTR(arg, AppearArg_t, 0); - - g_errEula.currentDialog = *arg.GetPtr(); - g_errEula.state = ERREULA_STATE_APPEARING; - g_errEula.buttonPressed = false; - g_errEula.rightButtonPressed = false; - - g_errEula.stateTimer = tick_cached(); - - osLib_returnFromFunction(hCPU, 0); + g_errEula.currentDialog = *arg; + if(g_errEula.errEulaInstance) + g_errEula.errEulaInstance->DoAppearError(arg); } - void export_GetStateErrorViewer(PPCInterpreter_t* hCPU) + void ErrEulaDisappearError() { - osLib_returnFromFunction(hCPU, g_errEula.state); + if(g_errEula.errEulaInstance) + g_errEula.errEulaInstance->DoDisappearError(); } - void export_DisappearError(PPCInterpreter_t* hCPU) + + ErrEulaState ErrEulaGetStateErrorViewer() { - g_errEula.state = ERREULA_STATE_HIDDEN; - osLib_returnFromFunction(hCPU, 0); + if(!g_errEula.errEulaInstance) + return ErrEulaState::Hidden; + return g_errEula.errEulaInstance->GetState(); } void export_ChangeLang(PPCInterpreter_t* hCPU) @@ -168,27 +338,6 @@ namespace erreula osLib_returnFromFunction(hCPU, 0); } - void export_IsDecideSelectButtonError(PPCInterpreter_t* hCPU) - { - if (g_errEula.buttonPressed) - cemuLog_logDebug(LogType::Force, "IsDecideSelectButtonError: TRUE"); - osLib_returnFromFunction(hCPU, g_errEula.buttonPressed); - } - - void export_IsDecideSelectLeftButtonError(PPCInterpreter_t* hCPU) - { - if (g_errEula.buttonPressed) - cemuLog_logDebug(LogType::Force, "IsDecideSelectLeftButtonError: TRUE"); - osLib_returnFromFunction(hCPU, g_errEula.buttonPressed); - } - - void export_IsDecideSelectRightButtonError(PPCInterpreter_t* hCPU) - { - if (g_errEula.rightButtonPressed) - cemuLog_logDebug(LogType::Force, "IsDecideSelectRightButtonError: TRUE"); - osLib_returnFromFunction(hCPU, g_errEula.rightButtonPressed); - } - void export_IsAppearHomeNixSign(PPCInterpreter_t* hCPU) { osLib_returnFromFunction(hCPU, g_errEula.homeNixSignVisible); @@ -200,61 +349,19 @@ namespace erreula osLib_returnFromFunction(hCPU, 0); } - void export_GetResultType(PPCInterpreter_t* hCPU) + void ErrEulaCalc(ControllerInfo_t* controllerInfo) { - uint32 result = RESULTTYPE_NONE; - if (g_errEula.buttonPressed || g_errEula.rightButtonPressed) - { - cemuLog_logDebug(LogType::Force, "GetResultType: FINISH"); - result = RESULTTYPE_FINISH; - } - - osLib_returnFromFunction(hCPU, result); - } - - void export_Calc(PPCInterpreter_t* hCPU) - { - ppcDefineParamMEMPTR(controllerInfo, ControllerInfo_t, 0); - // TODO: check controller buttons bla to accept dialog? - osLib_returnFromFunction(hCPU, 0); + if(g_errEula.errEulaInstance) + g_errEula.errEulaInstance->DoCalc(); } void render(bool mainWindow) { - if(g_errEula.state == ERREULA_STATE_HIDDEN) + if(!g_errEula.errEulaInstance) return; - - if(g_errEula.state == ERREULA_STATE_APPEARING) - { - if(std::chrono::duration_cast<std::chrono::milliseconds>(tick_cached() - g_errEula.stateTimer).count() <= 1000) - { - return; - } - - g_errEula.state = ERREULA_STATE_VISIBLE; - g_errEula.stateTimer = tick_cached(); - } - /*else if(g_errEula.state == STATE_VISIBLE) - { - if (std::chrono::duration_cast<std::chrono::milliseconds>(tick_cached() - g_errEula.stateTimer).count() >= 1000) - { - g_errEula.state = STATE_DISAPPEARING; - g_errEula.stateTimer = tick_cached(); - return; - } - }*/ - else if(g_errEula.state == ERREULA_STATE_DISAPPEARING) - { - if (std::chrono::duration_cast<std::chrono::milliseconds>(tick_cached() - g_errEula.stateTimer).count() >= 2000) - { - g_errEula.state = ERREULA_STATE_HIDDEN; - g_errEula.stateTimer = tick_cached(); - } - + if(g_errEula.errEulaInstance->GetState() != ErrEulaState::Visible && g_errEula.errEulaInstance->GetState() != ErrEulaState::Appearing && g_errEula.errEulaInstance->GetState() != ErrEulaState::Disappearing) return; - } - - const AppearArg_t& appearArg = g_errEula.currentDialog; + const AppearError& appearArg = g_errEula.currentDialog; std::string text; const uint32 errorCode = (uint32)appearArg.errorCode; if (errorCode != 0) @@ -276,17 +383,28 @@ namespace erreula ImGui::SetNextWindowPos(position, ImGuiCond_Always, pivot); ImGui::SetNextWindowBgAlpha(0.9f); ImGui::PushFont(font); - + std::string title; if (appearArg.title) title = boost::nowide::narrow(GetText(appearArg.title.GetPtr())); - if(title.empty()) // ImGui doesn't allow empty titles, so set one if appearArg.title is not set or empty + if (title.empty()) // ImGui doesn't allow empty titles, so set one if appearArg.title is not set or empty title = "ErrEula"; + + float fadeTransparency = 1.0f; + if (g_errEula.errEulaInstance->GetState() == ErrEulaState::Appearing || g_errEula.errEulaInstance->GetState() == ErrEulaState::Disappearing) + { + fadeTransparency = g_errEula.errEulaInstance->GetFadeTransparency(); + } + + float originalAlpha = ImGui::GetStyle().Alpha; + ImGui::GetStyle().Alpha = fadeTransparency; + ImGui::SetNextWindowBgAlpha(0.9f * fadeTransparency); if (ImGui::Begin(title.c_str(), nullptr, kPopupFlags)) { const float startx = ImGui::GetWindowSize().x / 2.0f; + bool hasLeftButtonPressed = false, hasRightButtonPressed = false; - switch ((uint32)appearArg.errorType) + switch (appearArg.errorType) { default: { @@ -294,11 +412,10 @@ namespace erreula ImGui::TextUnformatted(text.c_str(), text.c_str() + text.size()); ImGui::Spacing(); ImGui::SetCursorPosX(startx - 50); - g_errEula.buttonPressed |= ImGui::Button("OK", {100, 0}); - + hasLeftButtonPressed = ImGui::Button("OK", {100, 0}); break; } - case ERRORTYPE_TEXT: + case ErrorDialogType::Text: { std::string txtTmp = "Unknown Error"; if (appearArg.text) @@ -309,10 +426,10 @@ namespace erreula ImGui::Spacing(); ImGui::SetCursorPosX(startx - 50); - g_errEula.buttonPressed |= ImGui::Button("OK", { 100, 0 }); + hasLeftButtonPressed = ImGui::Button("OK", { 100, 0 }); break; } - case ERRORTYPE_TEXT_ONE_BUTTON: + case ErrorDialogType::TextOneButton: { std::string txtTmp = "Unknown Error"; if (appearArg.text) @@ -328,10 +445,10 @@ namespace erreula float width = std::max(100.0f, ImGui::CalcTextSize(button1.c_str()).x + 10.0f); ImGui::SetCursorPosX(startx - (width / 2.0f)); - g_errEula.buttonPressed |= ImGui::Button(button1.c_str(), { width, 0 }); + hasLeftButtonPressed = ImGui::Button(button1.c_str(), { width, 0 }); break; } - case ERRORTYPE_TEXT_TWO_BUTTON: + case ErrorDialogType::TextTwoButton: { std::string txtTmp = "Unknown Error"; if (appearArg.text) @@ -352,42 +469,52 @@ namespace erreula float width2 = std::max(100.0f, ImGui::CalcTextSize(button2.c_str()).x + 10.0f); ImGui::SetCursorPosX(startx - (width1 / 2.0f) - (width2 / 2.0f) - 10); - g_errEula.buttonPressed |= ImGui::Button(button1.c_str(), { width1, 0 }); + hasLeftButtonPressed = ImGui::Button(button1.c_str(), { width1, 0 }); ImGui::SameLine(); - g_errEula.rightButtonPressed |= ImGui::Button(button2.c_str(), { width2, 0 }); + hasRightButtonPressed = ImGui::Button(button2.c_str(), { width2, 0 }); break; } } + if (!g_errEula.errEulaInstance->IsDecideSelectButtonError()) + { + if (hasLeftButtonPressed) + g_errEula.errEulaInstance->SetButtonSelection(ErrEulaInstance::BUTTON_SELECTION::LEFT); + if (hasRightButtonPressed) + g_errEula.errEulaInstance->SetButtonSelection(ErrEulaInstance::BUTTON_SELECTION::RIGHT); + } } ImGui::End(); ImGui::PopFont(); - - if(g_errEula.buttonPressed || g_errEula.rightButtonPressed) - { - g_errEula.state = ERREULA_STATE_DISAPPEARING; - g_errEula.stateTimer = tick_cached(); - } + ImGui::GetStyle().Alpha = originalAlpha; } void load() { + g_errEula.errEulaInstance.reset(); + OSInitMutexEx(&g_errEula.mutex, nullptr); - //osLib_addFunction("erreula", "ErrEulaCreate__3RplFPUcQ3_2nn7erreula10", export_ErrEulaCreate); // copy ctor? - osLib_addFunction("erreula", "ErrEulaCreate__3RplFPUcQ3_2nn7erreula10RegionTypeQ3_2nn7erreula8LangTypeP8FSClient", export_ErrEulaCreate); + cafeExportRegisterFunc(ErrEulaCreate, "erreula", "ErrEulaCreate__3RplFPUcQ3_2nn7erreula10RegionTypeQ3_2nn7erreula8LangTypeP8FSClient", LogType::Placeholder); + cafeExportRegisterFunc(ErrEulaDestroy, "erreula", "ErrEulaDestroy__3RplFv", LogType::Placeholder); + + cafeExportRegisterFunc(IsDecideSelectButtonError, "erreula", "ErrEulaIsDecideSelectButtonError__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(IsDecideSelectLeftButtonError, "erreula", "ErrEulaIsDecideSelectLeftButtonError__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(IsDecideSelectRightButtonError, "erreula", "ErrEulaIsDecideSelectRightButtonError__3RplFv", LogType::Placeholder); + + cafeExportRegisterFunc(GetResultCode, "erreula", "ErrEulaGetResultCode__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(GetResultType, "erreula", "ErrEulaGetResultType__3RplFv", LogType::Placeholder); + + cafeExportRegisterFunc(ErrEulaAppearError, "erreula", "ErrEulaAppearError__3RplFRCQ3_2nn7erreula9AppearArg", LogType::Placeholder); + cafeExportRegisterFunc(ErrEulaDisappearError, "erreula", "ErrEulaDisappearError__3RplFv", LogType::Placeholder); + cafeExportRegisterFunc(ErrEulaGetStateErrorViewer, "erreula", "ErrEulaGetStateErrorViewer__3RplFv", LogType::Placeholder); + + cafeExportRegisterFunc(ErrEulaCalc, "erreula", "ErrEulaCalc__3RplFRCQ3_2nn7erreula14ControllerInfo", LogType::Placeholder); + osLib_addFunction("erreula", "ErrEulaAppearHomeNixSign__3RplFRCQ3_2nn7erreula14HomeNixSignArg", export_AppearHomeNixSign); - osLib_addFunction("erreula", "ErrEulaAppearError__3RplFRCQ3_2nn7erreula9AppearArg", export_AppearError); - osLib_addFunction("erreula", "ErrEulaGetStateErrorViewer__3RplFv", export_GetStateErrorViewer); osLib_addFunction("erreula", "ErrEulaChangeLang__3RplFQ3_2nn7erreula8LangType", export_ChangeLang); - osLib_addFunction("erreula", "ErrEulaIsDecideSelectButtonError__3RplFv", export_IsDecideSelectButtonError); - osLib_addFunction("erreula", "ErrEulaCalc__3RplFRCQ3_2nn7erreula14ControllerInfo", export_Calc); - osLib_addFunction("erreula", "ErrEulaIsDecideSelectLeftButtonError__3RplFv", export_IsDecideSelectLeftButtonError); - osLib_addFunction("erreula", "ErrEulaIsDecideSelectRightButtonError__3RplFv", export_IsDecideSelectRightButtonError); osLib_addFunction("erreula", "ErrEulaIsAppearHomeNixSign__3RplFv", export_IsAppearHomeNixSign); osLib_addFunction("erreula", "ErrEulaDisappearHomeNixSign__3RplFv", export_DisappearHomeNixSign); - osLib_addFunction("erreula", "ErrEulaGetResultType__3RplFv", export_GetResultType); - osLib_addFunction("erreula", "ErrEulaDisappearError__3RplFv", export_DisappearError); } } } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c83ab16b..69ff4e99 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -483,20 +483,20 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } - CafeSystem::STATUS_CODE r = CafeSystem::PrepareForegroundTitle(baseTitleId); - if (r == CafeSystem::STATUS_CODE::INVALID_RPX) + CafeSystem::PREPARE_STATUS_CODE r = CafeSystem::PrepareForegroundTitle(baseTitleId); + if (r == CafeSystem::PREPARE_STATUS_CODE::INVALID_RPX) { cemu_assert_debug(false); return false; } - else if (r == CafeSystem::STATUS_CODE::UNABLE_TO_MOUNT) + else if (r == CafeSystem::PREPARE_STATUS_CODE::UNABLE_TO_MOUNT) { wxString t = _("Unable to mount title.\nMake sure the configured game paths are still valid and refresh the game list.\n\nFile which failed to load:\n"); t.append(_pathToUtf8(launchPath)); wxMessageBox(t, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); return false; } - else if (r != CafeSystem::STATUS_CODE::SUCCESS) + else if (r != CafeSystem::PREPARE_STATUS_CODE::SUCCESS) { wxString t = _("Failed to launch game."); t.append(_pathToUtf8(launchPath)); @@ -511,8 +511,8 @@ bool MainWindow::FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATE CafeTitleFileType fileType = DetermineCafeSystemFileType(launchPath); if (fileType == CafeTitleFileType::RPX || fileType == CafeTitleFileType::ELF) { - CafeSystem::STATUS_CODE r = CafeSystem::PrepareForegroundTitleFromStandaloneRPX(launchPath); - if (r != CafeSystem::STATUS_CODE::SUCCESS) + CafeSystem::PREPARE_STATUS_CODE r = CafeSystem::PrepareForegroundTitleFromStandaloneRPX(launchPath); + if (r != CafeSystem::PREPARE_STATUS_CODE::SUCCESS) { cemu_assert_debug(false); // todo wxString t = _("Failed to launch executable. Path: "); From 719c631f13c451e045903e79768e98e264a0e9b2 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Nov 2024 06:28:13 +0100 Subject: [PATCH 271/314] config: Fix receive_untested_updates using the wrong default --- src/config/CemuConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index f5ee7ab4..26f420a5 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -38,7 +38,7 @@ void CemuConfig::Load(XMLConfigParser& parser) fullscreen_menubar = parser.get("fullscreen_menubar", false); feral_gamemode = parser.get("feral_gamemode", false); check_update = parser.get("check_update", check_update); - receive_untested_updates = parser.get("receive_untested_updates", check_update); + receive_untested_updates = parser.get("receive_untested_updates", receive_untested_updates); save_screenshot = parser.get("save_screenshot", save_screenshot); did_show_vulkan_warning = parser.get("vk_warning", did_show_vulkan_warning); did_show_graphic_pack_download = parser.get("gp_download", did_show_graphic_pack_download); From 6f9f3d52ea12d3951b2d9d71806f18fea46140e3 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Wed, 13 Nov 2024 06:38:13 +0100 Subject: [PATCH 272/314] CI: Remove outdated workflow --- ...imental_release.yml => deploy_release.yml} | 4 +- .github/workflows/deploy_stable_release.yml | 85 ------------------- 2 files changed, 2 insertions(+), 87 deletions(-) rename .github/workflows/{deploy_experimental_release.yml => deploy_release.yml} (98%) delete mode 100644 .github/workflows/deploy_stable_release.yml diff --git a/.github/workflows/deploy_experimental_release.yml b/.github/workflows/deploy_release.yml similarity index 98% rename from .github/workflows/deploy_experimental_release.yml rename to .github/workflows/deploy_release.yml index 97e0c69e..2b9ee491 100644 --- a/.github/workflows/deploy_experimental_release.yml +++ b/.github/workflows/deploy_release.yml @@ -1,4 +1,4 @@ -name: Deploy experimental release +name: Deploy release on: workflow_dispatch: inputs: @@ -54,7 +54,7 @@ jobs: next_version_major: ${{ needs.calculate-version.outputs.next_version_major }} next_version_minor: ${{ needs.calculate-version.outputs.next_version_minor }} deploy: - name: Deploy experimental release + name: Deploy release runs-on: ubuntu-22.04 needs: [call-release-build, calculate-version] steps: diff --git a/.github/workflows/deploy_stable_release.yml b/.github/workflows/deploy_stable_release.yml deleted file mode 100644 index fd339e7d..00000000 --- a/.github/workflows/deploy_stable_release.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Create new release -on: - workflow_dispatch: - inputs: - PlaceholderInput: - description: PlaceholderInput - required: false -jobs: - call-release-build: - uses: ./.github/workflows/build.yml - with: - deploymode: release - deploy: - name: Deploy release - runs-on: ubuntu-20.04 - needs: call-release-build - steps: - - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v4 - with: - name: cemu-bin-linux-x64 - path: cemu-bin-linux-x64 - - - uses: actions/download-artifact@v4 - with: - name: cemu-appimage-x64 - path: cemu-appimage-x64 - - - uses: actions/download-artifact@v4 - with: - name: cemu-bin-windows-x64 - path: cemu-bin-windows-x64 - - - uses: actions/download-artifact@v4 - with: - name: cemu-bin-macos-x64 - path: cemu-bin-macos-x64 - - - name: Initialize - run: | - mkdir upload - sudo apt update -qq - sudo apt install -y zip - - - name: Get Cemu release version - run: | - gcc -o getversion .github/getversion.cpp - echo "Cemu CI version: $(./getversion)" - echo "CEMU_FOLDER_NAME=Cemu_$(./getversion)" >> $GITHUB_ENV - echo "CEMU_VERSION=$(./getversion)" >> $GITHUB_ENV - - - name: Create release from windows-bin - run: | - ls ./ - ls ./bin/ - cp -R ./bin ./${{ env.CEMU_FOLDER_NAME }} - mv cemu-bin-windows-x64/Cemu.exe ./${{ env.CEMU_FOLDER_NAME }}/Cemu.exe - zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-windows-x64.zip ${{ env.CEMU_FOLDER_NAME }} - rm -r ./${{ env.CEMU_FOLDER_NAME }} - - - name: Create appimage - run: | - VERSION=${{ env.CEMU_VERSION }} - echo "Cemu Version is $VERSION" - ls cemu-appimage-x64 - mv cemu-appimage-x64/Cemu-*-x86_64.AppImage upload/Cemu-$VERSION-x86_64.AppImage - - - name: Create release from ubuntu-bin - run: | - ls ./ - ls ./bin/ - cp -R ./bin ./${{ env.CEMU_FOLDER_NAME }} - mv cemu-bin-linux-x64/Cemu ./${{ env.CEMU_FOLDER_NAME }}/Cemu - zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-ubuntu-20.04-x64.zip ${{ env.CEMU_FOLDER_NAME }} - rm -r ./${{ env.CEMU_FOLDER_NAME }} - - - name: Create release from macos-bin - run: cp cemu-bin-macos-x64/Cemu.dmg upload/cemu-${{ env.CEMU_VERSION }}-macos-12-x64.dmg - - - name: Create release - run: | - wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.15.0/ghr_v0.15.0_linux_amd64.tar.gz - tar xvzf ghr.tar.gz; rm ghr.tar.gz - ghr_v0.15.0_linux_amd64/ghr -t ${{ secrets.GITHUB_TOKEN }} -n "Cemu ${{ env.CEMU_VERSION }}" -b "Changelog:" v${{ env.CEMU_VERSION }} ./upload From 269d5b9aabc2a346f441cae5e662fb32fbb7da41 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:02:43 +0100 Subject: [PATCH 273/314] Vulkan: Make scaling shaders compatible + fixes (#1392) --- src/Cafe/GraphicPack/GraphicPack2.cpp | 2 +- src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 9 +- .../Latte/Renderer/OpenGL/OpenGLRenderer.cpp | 11 +- .../HW/Latte/Renderer/RendererOuputShader.cpp | 211 +++++++----------- .../HW/Latte/Renderer/RendererOuputShader.h | 14 +- .../Renderer/Vulkan/LatteTextureViewVk.cpp | 10 + .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 27 +++ 7 files changed, 135 insertions(+), 149 deletions(-) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index c54c31cb..4b6cb095 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -960,7 +960,7 @@ bool GraphicPack2::Activate() auto option_upscale = rules.FindOption("upscaleMagFilter"); if(option_upscale && boost::iequals(*option_upscale, "NearestNeighbor")) m_output_settings.upscale_filter = LatteTextureView::MagFilter::kNearestNeighbor; - auto option_downscale = rules.FindOption("NearestNeighbor"); + auto option_downscale = rules.FindOption("downscaleMinFilter"); if (option_downscale && boost::iequals(*option_downscale, "NearestNeighbor")) m_output_settings.downscale_filter = LatteTextureView::MagFilter::kNearestNeighbor; } diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index ca6a2a4d..3bb6c7e3 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -933,13 +933,6 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa if (shader == nullptr) { sint32 scaling_filter = downscaling ? GetConfig().downscale_filter : GetConfig().upscale_filter; - - if (g_renderer->GetType() == RendererAPI::Vulkan) - { - // force linear or nearest neighbor filter - if(scaling_filter != kLinearFilter && scaling_filter != kNearestNeighborFilter) - scaling_filter = kLinearFilter; - } if (scaling_filter == kLinearFilter) { @@ -957,7 +950,7 @@ void LatteRenderTarget_copyToBackbuffer(LatteTextureView* textureView, bool isPa else shader = RendererOutputShader::s_bicubic_shader; - filter = LatteTextureView::MagFilter::kNearestNeighbor; + filter = LatteTextureView::MagFilter::kLinear; } else if (scaling_filter == kBicubicHermiteFilter) { diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp index cf134a5d..bbf988bc 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp @@ -570,13 +570,10 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu g_renderer->ClearColorbuffer(padView); } - sint32 effectiveWidth, effectiveHeight; - texView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); - shader_unbind(RendererShader::ShaderType::kGeometry); shader_bind(shader->GetVertexShader()); shader_bind(shader->GetFragmentShader()); - shader->SetUniformParameters(*texView, { effectiveWidth, effectiveHeight }, { imageWidth, imageHeight }); + shader->SetUniformParameters(*texView, {imageWidth, imageHeight}); // set viewport glViewportIndexedf(0, imageX, imageY, imageWidth, imageHeight); @@ -584,6 +581,12 @@ void OpenGLRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu LatteTextureViewGL* texViewGL = (LatteTextureViewGL*)texView; texture_bindAndActivate(texView, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texViewGL->samplerState.clampS = texViewGL->samplerState.clampT = 0xFF; + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, useLinearTexFilter ? GL_LINEAR : GL_NEAREST); + texViewGL->samplerState.filterMin = 0xFFFFFFFF; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, useLinearTexFilter ? GL_LINEAR : GL_NEAREST); texViewGL->samplerState.filterMag = 0xFFFFFFFF; diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp index cdbeb3f3..409dc24f 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp @@ -2,18 +2,7 @@ #include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h" const std::string RendererOutputShader::s_copy_shader_source = -R"(#version 420 - -#ifdef VULKAN -layout(location = 0) in vec2 passUV; -layout(binding = 0) uniform sampler2D textureSrc; -layout(location = 0) out vec4 colorOut0; -#else -in vec2 passUV; -layout(binding=0) uniform sampler2D textureSrc; -layout(location = 0) out vec4 colorOut0; -#endif - +R"( void main() { colorOut0 = vec4(texture(textureSrc, passUV).rgb,1.0); @@ -22,20 +11,6 @@ void main() const std::string RendererOutputShader::s_bicubic_shader_source = R"( -#version 420 - -#ifdef VULKAN -layout(location = 0) in vec2 passUV; -layout(binding = 0) uniform sampler2D textureSrc; -layout(binding = 1) uniform vec2 textureSrcResolution; -layout(location = 0) out vec4 colorOut0; -#else -in vec2 passUV; -layout(binding=0) uniform sampler2D textureSrc; -uniform vec2 textureSrcResolution; -layout(location = 0) out vec4 colorOut0; -#endif - vec4 cubic(float x) { float x2 = x * x; @@ -48,24 +23,23 @@ vec4 cubic(float x) return w / 6.0; } -vec4 bcFilter(vec2 texcoord, vec2 texscale) +vec4 bcFilter(vec2 uv, vec4 texelSize) { - float fx = fract(texcoord.x); - float fy = fract(texcoord.y); - texcoord.x -= fx; - texcoord.y -= fy; + vec2 pixel = uv*texelSize.zw - 0.5; + vec2 pixelFrac = fract(pixel); + vec2 pixelInt = pixel - pixelFrac; - vec4 xcubic = cubic(fx); - vec4 ycubic = cubic(fy); + vec4 xcubic = cubic(pixelFrac.x); + vec4 ycubic = cubic(pixelFrac.y); - vec4 c = vec4(texcoord.x - 0.5, texcoord.x + 1.5, texcoord.y - 0.5, texcoord.y + 1.5); + vec4 c = vec4(pixelInt.x - 0.5, pixelInt.x + 1.5, pixelInt.y - 0.5, pixelInt.y + 1.5); vec4 s = vec4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x + ycubic.y, ycubic.z + ycubic.w); vec4 offset = c + vec4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) / s; - vec4 sample0 = texture(textureSrc, vec2(offset.x, offset.z) * texscale); - vec4 sample1 = texture(textureSrc, vec2(offset.y, offset.z) * texscale); - vec4 sample2 = texture(textureSrc, vec2(offset.x, offset.w) * texscale); - vec4 sample3 = texture(textureSrc, vec2(offset.y, offset.w) * texscale); + vec4 sample0 = texture(textureSrc, vec2(offset.x, offset.z) * texelSize.xy); + vec4 sample1 = texture(textureSrc, vec2(offset.y, offset.z) * texelSize.xy); + vec4 sample2 = texture(textureSrc, vec2(offset.x, offset.w) * texelSize.xy); + vec4 sample3 = texture(textureSrc, vec2(offset.y, offset.w) * texelSize.xy); float sx = s.x / (s.x + s.y); float sy = s.z / (s.z + s.w); @@ -76,20 +50,13 @@ vec4 bcFilter(vec2 texcoord, vec2 texscale) } void main(){ - colorOut0 = vec4(bcFilter(passUV*textureSrcResolution, vec2(1.0,1.0)/textureSrcResolution).rgb,1.0); + vec4 texelSize = vec4( 1.0 / textureSrcResolution.xy, textureSrcResolution.xy); + colorOut0 = vec4(bcFilter(passUV, texelSize).rgb,1.0); } )"; const std::string RendererOutputShader::s_hermite_shader_source = -R"(#version 420 - -in vec4 gl_FragCoord; -in vec2 passUV; -layout(binding=0) uniform sampler2D textureSrc; -uniform vec2 textureSrcResolution; -uniform vec2 outputResolution; -layout(location = 0) out vec4 colorOut0; - +R"( // https://www.shadertoy.com/view/MllSzX vec3 CubicHermite (vec3 A, vec3 B, vec3 C, vec3 D, float t) @@ -111,7 +78,7 @@ vec3 BicubicHermiteTexture(vec2 uv, vec4 texelSize) vec2 frac = fract(pixel); pixel = floor(pixel) / texelSize.zw - vec2(texelSize.xy/2.0); - vec4 doubleSize = texelSize*texelSize; + vec4 doubleSize = texelSize*2.0; vec3 C00 = texture(textureSrc, pixel + vec2(-texelSize.x ,-texelSize.y)).rgb; vec3 C10 = texture(textureSrc, pixel + vec2( 0.0 ,-texelSize.y)).rgb; @@ -142,15 +109,17 @@ vec3 BicubicHermiteTexture(vec2 uv, vec4 texelSize) } void main(){ - vec4 texelSize = vec4( 1.0 / outputResolution.xy, outputResolution.xy); + vec4 texelSize = vec4( 1.0 / textureSrcResolution.xy, textureSrcResolution.xy); colorOut0 = vec4(BicubicHermiteTexture(passUV, texelSize), 1.0); } )"; RendererOutputShader::RendererOutputShader(const std::string& vertex_source, const std::string& fragment_source) { + auto finalFragmentSrc = PrependFragmentPreamble(fragment_source); + m_vertex_shader = g_renderer->shader_create(RendererShader::ShaderType::kVertex, 0, 0, vertex_source, false, false); - m_fragment_shader = g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, fragment_source, false, false); + m_fragment_shader = g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, finalFragmentSrc, false, false); m_vertex_shader->PreponeCompilation(true); m_fragment_shader->PreponeCompilation(true); @@ -163,74 +132,45 @@ RendererOutputShader::RendererOutputShader(const std::string& vertex_source, con if (g_renderer->GetType() == RendererAPI::OpenGL) { - m_attributes[0].m_loc_texture_src_resolution = m_vertex_shader->GetUniformLocation("textureSrcResolution"); - m_attributes[0].m_loc_input_resolution = m_vertex_shader->GetUniformLocation("inputResolution"); - m_attributes[0].m_loc_output_resolution = m_vertex_shader->GetUniformLocation("outputResolution"); + m_uniformLocations[0].m_loc_textureSrcResolution = m_vertex_shader->GetUniformLocation("textureSrcResolution"); + m_uniformLocations[0].m_loc_nativeResolution = m_vertex_shader->GetUniformLocation("nativeResolution"); + m_uniformLocations[0].m_loc_outputResolution = m_vertex_shader->GetUniformLocation("outputResolution"); - m_attributes[1].m_loc_texture_src_resolution = m_fragment_shader->GetUniformLocation("textureSrcResolution"); - m_attributes[1].m_loc_input_resolution = m_fragment_shader->GetUniformLocation("inputResolution"); - m_attributes[1].m_loc_output_resolution = m_fragment_shader->GetUniformLocation("outputResolution"); + m_uniformLocations[1].m_loc_textureSrcResolution = m_fragment_shader->GetUniformLocation("textureSrcResolution"); + m_uniformLocations[1].m_loc_nativeResolution = m_fragment_shader->GetUniformLocation("nativeResolution"); + m_uniformLocations[1].m_loc_outputResolution = m_fragment_shader->GetUniformLocation("outputResolution"); } - else - { - cemuLog_logDebug(LogType::Force, "RendererOutputShader() - todo for Vulkan"); - m_attributes[0].m_loc_texture_src_resolution = -1; - m_attributes[0].m_loc_input_resolution = -1; - m_attributes[0].m_loc_output_resolution = -1; - - m_attributes[1].m_loc_texture_src_resolution = -1; - m_attributes[1].m_loc_input_resolution = -1; - m_attributes[1].m_loc_output_resolution = -1; - } - } -void RendererOutputShader::SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& input_res, const Vector2i& output_res) const +void RendererOutputShader::SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& output_res) const { - float res[2]; - // vertex shader - if (m_attributes[0].m_loc_texture_src_resolution != -1) - { - res[0] = (float)texture_view.baseTexture->width; - res[1] = (float)texture_view.baseTexture->height; - m_vertex_shader->SetUniform2fv(m_attributes[0].m_loc_texture_src_resolution, res, 1); - } + sint32 effectiveWidth, effectiveHeight; + texture_view.baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); + auto setUniforms = [&](RendererShader* shader, const UniformLocations& locations){ + float res[2]; + if (locations.m_loc_textureSrcResolution != -1) + { + res[0] = (float)effectiveWidth; + res[1] = (float)effectiveHeight; + shader->SetUniform2fv(locations.m_loc_textureSrcResolution, res, 1); + } - if (m_attributes[0].m_loc_input_resolution != -1) - { - res[0] = (float)input_res.x; - res[1] = (float)input_res.y; - m_vertex_shader->SetUniform2fv(m_attributes[0].m_loc_input_resolution, res, 1); - } + if (locations.m_loc_nativeResolution != -1) + { + res[0] = (float)texture_view.baseTexture->width; + res[1] = (float)texture_view.baseTexture->height; + shader->SetUniform2fv(locations.m_loc_nativeResolution, res, 1); + } - if (m_attributes[0].m_loc_output_resolution != -1) - { - res[0] = (float)output_res.x; - res[1] = (float)output_res.y; - m_vertex_shader->SetUniform2fv(m_attributes[0].m_loc_output_resolution, res, 1); - } - - // fragment shader - if (m_attributes[1].m_loc_texture_src_resolution != -1) - { - res[0] = (float)texture_view.baseTexture->width; - res[1] = (float)texture_view.baseTexture->height; - m_fragment_shader->SetUniform2fv(m_attributes[1].m_loc_texture_src_resolution, res, 1); - } - - if (m_attributes[1].m_loc_input_resolution != -1) - { - res[0] = (float)input_res.x; - res[1] = (float)input_res.y; - m_fragment_shader->SetUniform2fv(m_attributes[1].m_loc_input_resolution, res, 1); - } - - if (m_attributes[1].m_loc_output_resolution != -1) - { - res[0] = (float)output_res.x; - res[1] = (float)output_res.y; - m_fragment_shader->SetUniform2fv(m_attributes[1].m_loc_output_resolution, res, 1); - } + if (locations.m_loc_outputResolution != -1) + { + res[0] = (float)output_res.x; + res[1] = (float)output_res.y; + shader->SetUniform2fv(locations.m_loc_outputResolution, res, 1); + } + }; + setUniforms(m_vertex_shader, m_uniformLocations[0]); + setUniforms(m_fragment_shader, m_uniformLocations[1]); } RendererOutputShader* RendererOutputShader::s_copy_shader; @@ -341,6 +281,27 @@ void main(){ )"; return vertex_source.str(); } + +std::string RendererOutputShader::PrependFragmentPreamble(const std::string& shaderSrc) +{ + return R"(#version 430 +#ifdef VULKAN +layout(push_constant) uniform pc { + vec2 textureSrcResolution; + vec2 nativeResolution; + vec2 outputResolution; +}; +#else +uniform vec2 textureSrcResolution; +uniform vec2 nativeResolution; +uniform vec2 outputResolution; +#endif + +layout(location = 0) in vec2 passUV; +layout(binding = 0) uniform sampler2D textureSrc; +layout(location = 0) out vec4 colorOut0; +)" + shaderSrc; +} void RendererOutputShader::InitializeStatic() { std::string vertex_source, vertex_source_ud; @@ -349,28 +310,18 @@ void RendererOutputShader::InitializeStatic() { vertex_source = GetOpenGlVertexSource(false); vertex_source_ud = GetOpenGlVertexSource(true); - - s_copy_shader = new RendererOutputShader(vertex_source, s_copy_shader_source); - s_copy_shader_ud = new RendererOutputShader(vertex_source_ud, s_copy_shader_source); - - s_bicubic_shader = new RendererOutputShader(vertex_source, s_bicubic_shader_source); - s_bicubic_shader_ud = new RendererOutputShader(vertex_source_ud, s_bicubic_shader_source); - - s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source); - s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source); } else { vertex_source = GetVulkanVertexSource(false); vertex_source_ud = GetVulkanVertexSource(true); - - s_copy_shader = new RendererOutputShader(vertex_source, s_copy_shader_source); - s_copy_shader_ud = new RendererOutputShader(vertex_source_ud, s_copy_shader_source); - - /* s_bicubic_shader = new RendererOutputShader(vertex_source, s_bicubic_shader_source); TODO - s_bicubic_shader_ud = new RendererOutputShader(vertex_source_ud, s_bicubic_shader_source); - - s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source); - s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source);*/ } + s_copy_shader = new RendererOutputShader(vertex_source, s_copy_shader_source); + s_copy_shader_ud = new RendererOutputShader(vertex_source_ud, s_copy_shader_source); + + s_bicubic_shader = new RendererOutputShader(vertex_source, s_bicubic_shader_source); + s_bicubic_shader_ud = new RendererOutputShader(vertex_source_ud, s_bicubic_shader_source); + + s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source); + s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source); } diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h index 398ac663..61b24c20 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h @@ -17,7 +17,7 @@ public: RendererOutputShader(const std::string& vertex_source, const std::string& fragment_source); virtual ~RendererOutputShader() = default; - void SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& input_res, const Vector2i& output_res) const; + void SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& output_res) const; RendererShader* GetVertexShader() const { @@ -43,16 +43,18 @@ public: static std::string GetVulkanVertexSource(bool render_upside_down); static std::string GetOpenGlVertexSource(bool render_upside_down); + static std::string PrependFragmentPreamble(const std::string& shaderSrc); + protected: RendererShader* m_vertex_shader; RendererShader* m_fragment_shader; - struct + struct UniformLocations { - sint32 m_loc_texture_src_resolution = -1; - sint32 m_loc_input_resolution = -1; - sint32 m_loc_output_resolution = -1; - } m_attributes[2]{}; + sint32 m_loc_textureSrcResolution = -1; + sint32 m_loc_nativeResolution = -1; + sint32 m_loc_outputResolution = -1; + } m_uniformLocations[2]{}; private: static const std::string s_copy_shader_source; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp index f0e2295e..de76f76d 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp @@ -202,6 +202,13 @@ VkSampler LatteTextureViewVk::GetDefaultTextureSampler(bool useLinearTexFilter) VkSamplerCreateInfo samplerInfo{}; samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; + // emulate OpenGL minFilters + // see note under: https://docs.vulkan.org/spec/latest/chapters/samplers.html#VkSamplerCreateInfo + // if maxLod = 0 then magnification is always performed + samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; + samplerInfo.minLod = 0.0f; + samplerInfo.maxLod = 0.25f; + if (useLinearTexFilter) { samplerInfo.magFilter = VK_FILTER_LINEAR; @@ -212,6 +219,9 @@ VkSampler LatteTextureViewVk::GetDefaultTextureSampler(bool useLinearTexFilter) samplerInfo.magFilter = VK_FILTER_NEAREST; samplerInfo.minFilter = VK_FILTER_NEAREST; } + samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; if (vkCreateSampler(m_device, &samplerInfo, nullptr, &sampler) != VK_SUCCESS) { diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 9ad2c5ca..37432eeb 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -2581,10 +2581,18 @@ VkPipeline VulkanRenderer::backbufferBlit_createGraphicsPipeline(VkDescriptorSet colorBlending.blendConstants[2] = 0.0f; colorBlending.blendConstants[3] = 0.0f; + VkPushConstantRange pushConstantRange{ + .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT, + .offset = 0, + .size = 3 * sizeof(float) * 2 // 3 vec2's + }; + VkPipelineLayoutCreateInfo pipelineLayoutInfo{}; pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipelineLayoutInfo.setLayoutCount = 1; pipelineLayoutInfo.pSetLayouts = &descriptorLayout; + pipelineLayoutInfo.pushConstantRangeCount = 1; + pipelineLayoutInfo.pPushConstantRanges = &pushConstantRange; VkResult result = vkCreatePipelineLayout(m_logicalDevice, &pipelineLayoutInfo, nullptr, &m_pipelineLayout); if (result != VK_SUCCESS) @@ -2956,6 +2964,25 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu vkCmdBindDescriptorSets(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &descriptSet, 0, nullptr); + // update push constants + Vector2f pushData[3]; + + // textureSrcResolution + sint32 effectiveWidth, effectiveHeight; + texView->baseTexture->GetEffectiveSize(effectiveWidth, effectiveHeight, 0); + pushData[0] = {(float)effectiveWidth, (float)effectiveHeight}; + + // nativeResolution + pushData[1] = { + (float)texViewVk->baseTexture->width, + (float)texViewVk->baseTexture->height, + }; + + // outputResolution + pushData[2] = {(float)imageWidth,(float)imageHeight}; + + vkCmdPushConstants(m_state.currentCommandBuffer, m_pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(float) * 2 * 3, &pushData); + vkCmdDraw(m_state.currentCommandBuffer, 6, 1, 0, 0); vkCmdEndRenderPass(m_state.currentCommandBuffer); From 2065ac5f635e48a6bf01ac480236783f46bcf0de Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:51:58 +0100 Subject: [PATCH 274/314] GfxPack: Better logging messages for diagnosing problems in rules.txt --- src/Cafe/GraphicPack/GraphicPack2.cpp | 42 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 4b6cb095..f21bb89d 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -345,7 +345,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) const auto preset_name = rules.FindOption("name"); if (!preset_name) { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": Preset in line {} skipped because it has no name option defined", m_name, rules.GetCurrentSectionLineNumber()); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": Preset in line {} skipped because it has no name option defined", GetNormalizedPathString(), rules.GetCurrentSectionLineNumber()); continue; } @@ -369,7 +369,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) } catch (const std::exception & ex) { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": Can't parse preset \"{}\": {}", m_name, *preset_name, ex.what()); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": Can't parse preset \"{}\": {}", GetNormalizedPathString(), *preset_name, ex.what()); } } else if (boost::iequals(currentSectionName, "RAM")) @@ -383,7 +383,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) { if (m_version <= 5) { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": [RAM] options are only available for graphic pack version 6 or higher", m_name, optionNameBuf); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": [RAM] options are only available for graphic pack version 6 or higher", GetNormalizedPathString(), optionNameBuf); throw std::exception(); } @@ -393,12 +393,12 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) { if (addrEnd <= addrStart) { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": start address (0x{:08x}) must be greater than end address (0x{:08x}) for {}", m_name, addrStart, addrEnd, optionNameBuf); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": start address (0x{:08x}) must be greater than end address (0x{:08x}) for {}", GetNormalizedPathString(), addrStart, addrEnd, optionNameBuf); throw std::exception(); } else if ((addrStart & 0xFFF) != 0 || (addrEnd & 0xFFF) != 0) { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": addresses for %s are not aligned to 0x1000", m_name, optionNameBuf); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": addresses for %s are not aligned to 0x1000", GetNormalizedPathString(), optionNameBuf); throw std::exception(); } else @@ -408,7 +408,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) } else { - cemuLog_log(LogType::Force, "Graphic pack \"{}\": has invalid syntax for option {}", m_name, optionNameBuf); + cemuLog_log(LogType::Force, "Graphic pack \"{}\": has invalid syntax for option {}", GetNormalizedPathString(), optionNameBuf); throw std::exception(); } } @@ -422,24 +422,32 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) std::unordered_map<std::string, std::vector<PresetPtr>> tmp_map; // all vars must be defined in the default preset vars before - for (const auto& entry : m_presets) + std::vector<std::pair<std::string, std::string>> mismatchingPresetVars; + for (const auto& presetEntry : m_presets) { - tmp_map[entry->category].emplace_back(entry); + tmp_map[presetEntry->category].emplace_back(presetEntry); - for (auto& kv : entry->variables) + for (auto& presetVar : presetEntry->variables) { - const auto it = m_preset_vars.find(kv.first); + const auto it = m_preset_vars.find(presetVar.first); if (it == m_preset_vars.cend()) { - cemuLog_log(LogType::Force, "Graphic pack: \"{}\" contains preset variables which are not defined in the default section", m_name); - throw std::exception(); + mismatchingPresetVars.emplace_back(presetEntry->name, presetVar.first); + continue; } - // overwrite var type with default var type - kv.second.first = it->second.first; + presetVar.second.first = it->second.first; } } + if(!mismatchingPresetVars.empty()) + { + cemuLog_log(LogType::Force, "Graphic pack \"{}\" contains preset variables which are not defined in the [Default] section:", GetNormalizedPathString()); + for (const auto& [presetName, varName] : mismatchingPresetVars) + cemuLog_log(LogType::Force, "Preset: {} Variable: {}", presetName, varName); + throw std::exception(); + } + // have first entry be default active for every category if no default= is set for(auto entry : get_values(tmp_map)) { @@ -469,7 +477,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) auto& p2 = kv.second[i + 1]; if (p1->variables.size() != p2->variables.size()) { - cemuLog_log(LogType::Force, "Graphic pack: \"{}\" contains inconsistent preset variables", m_name); + cemuLog_log(LogType::Force, "Graphic pack: \"{}\" contains inconsistent preset variables", GetNormalizedPathString()); throw std::exception(); } @@ -477,14 +485,14 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) std::set<std::string> keys2(get_keys(p2->variables).begin(), get_keys(p2->variables).end()); if (keys1 != keys2) { - cemuLog_log(LogType::Force, "Graphic pack: \"{}\" contains inconsistent preset variables", m_name); + cemuLog_log(LogType::Force, "Graphic pack: \"{}\" contains inconsistent preset variables", GetNormalizedPathString()); throw std::exception(); } if(p1->is_default) { if(has_default) - cemuLog_log(LogType::Force, "Graphic pack: \"{}\" has more than one preset with the default key set for the same category \"{}\"", m_name, p1->name); + cemuLog_log(LogType::Force, "Graphic pack: \"{}\" has more than one preset with the default key set for the same category \"{}\"", GetNormalizedPathString(), p1->name); p1->active = true; has_default = true; } From c3e29fb6199cfd297a86dd0f6bc0d92fe7dab3de Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 16 Nov 2024 13:45:33 +0100 Subject: [PATCH 275/314] Latte: Add support for shader instructions MIN_UINT and MAX_UINT Seen in the eShop version of Fatal Frame Also made some warnings less spammy since this game seems to trigger it a lot --- .../LatteDecompiler.cpp | 2 ++ .../LatteDecompilerAnalyzer.cpp | 2 ++ .../LatteDecompilerEmitGLSL.cpp | 20 +++++++++++-------- .../LatteDecompilerInstructions.h | 2 ++ src/Cafe/OS/libs/gx2/GX2_Shader.cpp | 2 +- src/input/emulated/VPADController.cpp | 2 +- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp index c3f7c19e..5972aacc 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.cpp @@ -370,6 +370,8 @@ bool LatteDecompiler_IsALUTransInstruction(bool isOP3, uint32 opcode) opcode == ALU_OP2_INST_LSHR_INT || opcode == ALU_OP2_INST_MAX_INT || opcode == ALU_OP2_INST_MIN_INT || + opcode == ALU_OP2_INST_MAX_UINT || + opcode == ALU_OP2_INST_MIN_UINT || opcode == ALU_OP2_INST_MOVA_FLOOR || opcode == ALU_OP2_INST_MOVA_INT || opcode == ALU_OP2_INST_SETE_DX10 || diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp index 19604e0c..ff64988c 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerAnalyzer.cpp @@ -140,6 +140,8 @@ bool _isIntegerInstruction(const LatteDecompilerALUInstruction& aluInstruction) case ALU_OP2_INST_SUB_INT: case ALU_OP2_INST_MAX_INT: case ALU_OP2_INST_MIN_INT: + case ALU_OP2_INST_MAX_UINT: + case ALU_OP2_INST_MIN_UINT: case ALU_OP2_INST_SETE_INT: case ALU_OP2_INST_SETGT_INT: case ALU_OP2_INST_SETGE_INT: diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 7a6605f8..e7ebcf3a 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -1415,19 +1415,23 @@ void _emitALUOP2InstructionCode(LatteDecompilerShaderContext* shaderContext, Lat } else if( aluInstruction->opcode == ALU_OP2_INST_ADD_INT ) _emitALUOperationBinary<LATTE_DECOMPILER_DTYPE_SIGNED_INT>(shaderContext, aluInstruction, " + "); - else if( aluInstruction->opcode == ALU_OP2_INST_MAX_INT || aluInstruction->opcode == ALU_OP2_INST_MIN_INT ) + else if( aluInstruction->opcode == ALU_OP2_INST_MAX_INT || aluInstruction->opcode == ALU_OP2_INST_MIN_INT || + aluInstruction->opcode == ALU_OP2_INST_MAX_UINT || aluInstruction->opcode == ALU_OP2_INST_MIN_UINT) { // not verified + bool isUnsigned = aluInstruction->opcode == ALU_OP2_INST_MAX_UINT || aluInstruction->opcode == ALU_OP2_INST_MIN_UINT; + auto opType = isUnsigned ? LATTE_DECOMPILER_DTYPE_UNSIGNED_INT : LATTE_DECOMPILER_DTYPE_SIGNED_INT; _emitInstructionOutputVariableName(shaderContext, aluInstruction); - if( aluInstruction->opcode == ALU_OP2_INST_MAX_INT ) - src->add(" = max("); + src->add(" = "); + _emitTypeConversionPrefix(shaderContext, opType, outputType); + if( aluInstruction->opcode == ALU_OP2_INST_MAX_INT || aluInstruction->opcode == ALU_OP2_INST_MAX_UINT ) + src->add("max("); else - src->add(" = min("); - _emitTypeConversionPrefix(shaderContext, LATTE_DECOMPILER_DTYPE_SIGNED_INT, outputType); - _emitOperandInputCode(shaderContext, aluInstruction, 0, LATTE_DECOMPILER_DTYPE_SIGNED_INT); + src->add("min("); + _emitOperandInputCode(shaderContext, aluInstruction, 0, opType); src->add(", "); - _emitOperandInputCode(shaderContext, aluInstruction, 1, LATTE_DECOMPILER_DTYPE_SIGNED_INT); - _emitTypeConversionSuffix(shaderContext, LATTE_DECOMPILER_DTYPE_SIGNED_INT, outputType); + _emitOperandInputCode(shaderContext, aluInstruction, 1, opType); + _emitTypeConversionSuffix(shaderContext, opType, outputType); src->add(");" _CRLF); } else if( aluInstruction->opcode == ALU_OP2_INST_SUB_INT ) diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h index 4cb1982e..6c029b46 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h @@ -60,6 +60,8 @@ #define ALU_OP2_INST_SUB_INT (0x035) // integer instruction #define ALU_OP2_INST_MAX_INT (0x036) // integer instruction #define ALU_OP2_INST_MIN_INT (0x037) // integer instruction +#define ALU_OP2_INST_MAX_UINT (0x038) // integer instruction +#define ALU_OP2_INST_MIN_UINT (0x039) // integer instruction #define ALU_OP2_INST_SETE_INT (0x03A) // integer instruction #define ALU_OP2_INST_SETGT_INT (0x03B) // integer instruction #define ALU_OP2_INST_SETGE_INT (0x03C) // integer instruction diff --git a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp index dfbbfcff..7a153737 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Shader.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Shader.cpp @@ -421,7 +421,7 @@ namespace GX2 { if(aluRegisterOffset&0x8000) { - cemuLog_logDebug(LogType::Force, "_GX2SubmitUniformReg(): Unhandled loop const special case or invalid offset"); + cemuLog_logDebugOnce(LogType::Force, "_GX2SubmitUniformReg(): Unhandled loop const special case or invalid offset"); return; } if((aluRegisterOffset+sizeInU32s) > 0x400) diff --git a/src/input/emulated/VPADController.cpp b/src/input/emulated/VPADController.cpp index f1ab1bc4..81615c9b 100644 --- a/src/input/emulated/VPADController.cpp +++ b/src/input/emulated/VPADController.cpp @@ -408,7 +408,7 @@ bool VPADController::push_rumble(uint8* pattern, uint8 length) std::scoped_lock lock(m_rumble_mutex); if (m_rumble_queue.size() >= 5) { - cemuLog_logDebug(LogType::Force, "too many cmds"); + cemuLog_logDebugOnce(LogType::Force, "VPADControlMotor(): Pattern too long"); return false; } From 7b513f1744a7952abf2fb927c27b2c09a2c992f4 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 17 Nov 2024 09:52:44 +0100 Subject: [PATCH 276/314] Latte: Add workaround for infinite loop in Fatal Frame shaders --- src/config/ActiveSettings.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index 560f2986..f81f8336 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -198,14 +198,20 @@ bool ActiveSettings::ShaderPreventInfiniteLoopsEnabled() { const uint64 titleId = CafeSystem::GetForegroundTitleId(); // workaround for NSMBU (and variants) having a bug where shaders can get stuck in infinite loops - // update: As of Cemu 1.20.0 this should no longer be required + // Fatal Frame has an actual infinite loop in shader 0xb6a67c19f6472e00 encountered during a cutscene for the second drop (eShop version only?) + // update: As of Cemu 1.20.0 this should no longer be required for NSMBU/NSLU due to fixes with uniform handling. But we leave it here for good measure + // todo - Once we add support for loop config registers this workaround should become unnecessary return /* NSMBU JP */ titleId == 0x0005000010101C00 || /* NSMBU US */ titleId == 0x0005000010101D00 || /* NSMBU EU */ titleId == 0x0005000010101E00 || /* NSMBU+L US */ titleId == 0x000500001014B700 || /* NSMBU+L EU */ titleId == 0x000500001014B800 || /* NSLU US */ titleId == 0x0005000010142300 || - /* NSLU EU */ titleId == 0x0005000010142400; + /* NSLU EU */ titleId == 0x0005000010142400 || + /* Project Zero: Maiden of Black Water (EU) */ titleId == 0x00050000101D0300 || + /* Fatal Frame: Maiden of Black Water (US) */ titleId == 0x00050000101D0600 || + /* Project Zero: Maiden of Black Water (JP) */ titleId == 0x000500001014D200 || + /* Project Zero: Maiden of Black Water (Trial, EU) */ titleId == 0x00050000101D3F00; } bool ActiveSettings::FlushGPUCacheOnSwap() From 409f12b13a2d67f18465c2920ab04a4d5ab27ae6 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 17 Nov 2024 10:38:39 +0100 Subject: [PATCH 277/314] coreinit: Fix calculation of thread total awake time --- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 2f3808b7..db457047 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -1114,13 +1114,13 @@ namespace coreinit thread->requestFlags = (OSThread_t::REQUEST_FLAG_BIT)(thread->requestFlags & OSThread_t::REQUEST_FLAG_CANCEL); // remove all flags except cancel flag // update total cycles - uint64 remainingCycles = std::min((uint64)hCPU->remainingCycles, (uint64)thread->quantumTicks); - uint64 executedCycles = thread->quantumTicks - remainingCycles; - if (executedCycles < hCPU->skippedCycles) + sint64 executedCycles = (sint64)thread->quantumTicks - (sint64)hCPU->remainingCycles; + executedCycles = std::max<sint64>(executedCycles, 0); + if (executedCycles < (sint64)hCPU->skippedCycles) executedCycles = 0; else executedCycles -= hCPU->skippedCycles; - thread->totalCycles += executedCycles; + thread->totalCycles += (uint64)executedCycles; // store context and set current thread to null __OSThreadStoreContext(hCPU, thread); OSSetCurrentThread(OSGetCoreId(), nullptr); From 90eb2e01f405e502ed33fea330352e167c4a14db Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Fri, 22 Nov 2024 12:43:12 +0000 Subject: [PATCH 278/314] nsyshid/dimensions: add missing return (#1425) --- src/Cafe/OS/libs/nsyshid/Dimensions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Cafe/OS/libs/nsyshid/Dimensions.cpp b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp index f328dde7..8a2acc76 100644 --- a/src/Cafe/OS/libs/nsyshid/Dimensions.cpp +++ b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp @@ -675,6 +675,7 @@ namespace nsyshid figureChangeResponse[13] = GenerateChecksum(figureChangeResponse, 13); m_figureAddedRemovedResponses.push(figureChangeResponse); + return true; } bool DimensionsUSB::CancelRemove(uint8 index) From 073523768692c1adb994ce2f07d1c29530de41e6 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Sat, 30 Nov 2024 22:05:50 +0000 Subject: [PATCH 279/314] Input: Move pairing dialog button and source (#1424) --- src/gui/CMakeLists.txt | 4 ++-- src/gui/input/InputSettings2.cpp | 9 +++++++++ src/gui/{ => input}/PairingDialog.cpp | 2 +- src/gui/{ => input}/PairingDialog.h | 0 src/gui/input/panels/WiimoteInputPanel.cpp | 12 ------------ 5 files changed, 12 insertions(+), 15 deletions(-) rename src/gui/{ => input}/PairingDialog.cpp (99%) rename src/gui/{ => input}/PairingDialog.h (100%) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 02f96a9c..e1a04ec0 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -75,6 +75,8 @@ add_library(CemuGui input/InputAPIAddWindow.h input/InputSettings2.cpp input/InputSettings2.h + input/PairingDialog.cpp + input/PairingDialog.h input/panels/ClassicControllerInputPanel.cpp input/panels/ClassicControllerInputPanel.h input/panels/InputPanel.cpp @@ -97,8 +99,6 @@ add_library(CemuGui MemorySearcherTool.h PadViewFrame.cpp PadViewFrame.h - PairingDialog.cpp - PairingDialog.h TitleManager.cpp TitleManager.h EmulatedUSBDevices/EmulatedUSBDeviceFrame.cpp diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 72bf4f7d..2ae8a74b 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -20,6 +20,8 @@ #include "gui/input/InputAPIAddWindow.h" #include "input/ControllerFactory.h" +#include "gui/input/PairingDialog.h" + #include "gui/input/panels/VPADInputPanel.h" #include "gui/input/panels/ProControllerInputPanel.h" @@ -252,6 +254,13 @@ wxWindow* InputSettings2::initialize_page(size_t index) page_data.m_controller_api_remove = remove_api; } + auto* pairingDialog = new wxButton(page, wxID_ANY, _("Pair Wii/Wii U Controller")); + pairingDialog->Bind(wxEVT_BUTTON, [this](wxEvent&) { + PairingDialog pairing_dialog(this); + pairing_dialog.ShowModal(); + }); + sizer->Add(pairingDialog, wxGBPosition(5, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL | wxALL, 5); + // controller auto* controller_bttns = new wxBoxSizer(wxHORIZONTAL); auto* settings = new wxButton(page, wxID_ANY, _("Settings"), wxDefaultPosition, wxDefaultSize, 0); diff --git a/src/gui/PairingDialog.cpp b/src/gui/input/PairingDialog.cpp similarity index 99% rename from src/gui/PairingDialog.cpp rename to src/gui/input/PairingDialog.cpp index f90e6d13..03d6315b 100644 --- a/src/gui/PairingDialog.cpp +++ b/src/gui/input/PairingDialog.cpp @@ -1,5 +1,5 @@ #include "gui/wxgui.h" -#include "gui/PairingDialog.h" +#include "PairingDialog.h" #if BOOST_OS_WINDOWS #include <bluetoothapis.h> diff --git a/src/gui/PairingDialog.h b/src/gui/input/PairingDialog.h similarity index 100% rename from src/gui/PairingDialog.h rename to src/gui/input/PairingDialog.h diff --git a/src/gui/input/panels/WiimoteInputPanel.cpp b/src/gui/input/panels/WiimoteInputPanel.cpp index 050baad1..44a7c001 100644 --- a/src/gui/input/panels/WiimoteInputPanel.cpp +++ b/src/gui/input/panels/WiimoteInputPanel.cpp @@ -12,7 +12,6 @@ #include "input/emulated/WiimoteController.h" #include "gui/helpers/wxHelpers.h" #include "gui/components/wxInputDraw.h" -#include "gui/PairingDialog.h" constexpr WiimoteController::ButtonId g_kFirstColumnItems[] = { @@ -40,11 +39,6 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent) auto* main_sizer = new wxBoxSizer(wxVERTICAL); auto* horiz_main_sizer = new wxBoxSizer(wxHORIZONTAL); - auto* pair_button = new wxButton(this, wxID_ANY, _("Pair a Wii or Wii U controller")); - pair_button->Bind(wxEVT_BUTTON, &WiimoteInputPanel::on_pair_button, this); - horiz_main_sizer->Add(pair_button); - horiz_main_sizer->AddSpacer(10); - auto* extensions_sizer = new wxBoxSizer(wxHORIZONTAL); horiz_main_sizer->Add(extensions_sizer, wxSizerFlags(0).Align(wxALIGN_CENTER_VERTICAL)); @@ -264,9 +258,3 @@ void WiimoteInputPanel::load_controller(const EmulatedControllerPtr& emulated_co set_active_device_type(wiimote->get_device_type()); } } - -void WiimoteInputPanel::on_pair_button(wxCommandEvent& event) -{ - PairingDialog pairing_dialog(this); - pairing_dialog.ShowModal(); -} From 80a6057512240b14f6aa6ab45ba955e25a1c7acf Mon Sep 17 00:00:00 2001 From: Jeremy Kescher <jeremy@kescher.at> Date: Mon, 2 Dec 2024 01:01:22 +0100 Subject: [PATCH 280/314] build: Fix linker failure with glslang 15.0.0 (#1436) --- src/Cafe/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 0901fece..76dba007 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -532,6 +532,12 @@ set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CON target_include_directories(CemuCafe PUBLIC "../") +if (glslang_VERSION VERSION_LESS "15.0.0") + set(glslang_target "glslang::SPIRV") +else() + set(glslang_target "glslang") +endif() + target_link_libraries(CemuCafe PRIVATE CemuAsm CemuAudio @@ -547,7 +553,7 @@ target_link_libraries(CemuCafe PRIVATE Boost::nowide CURL::libcurl fmt::fmt - glslang::SPIRV + ${glslang_target} ih264d OpenSSL::Crypto OpenSSL::SSL From eca7374567bff66a22b0d210f15744bcaafb8ad3 Mon Sep 17 00:00:00 2001 From: neebyA <126654084+neebyA@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:19:15 -0800 Subject: [PATCH 281/314] Set version for macOS bundle (#1431) --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3792ab85..79471321 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,8 +82,8 @@ if (MACOS_BUNDLE) set(MACOSX_BUNDLE_ICON_FILE "cemu.icns") set(MACOSX_BUNDLE_GUI_IDENTIFIER "info.cemu.Cemu") set(MACOSX_BUNDLE_BUNDLE_NAME "Cemu") - set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${CMAKE_PROJECT_VERSION}) - set(MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}) + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}") + set(MACOSX_BUNDLE_BUNDLE_VERSION "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}") set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2024 Cemu Project") set(MACOSX_BUNDLE_CATEGORY "public.app-category.games") From 40d9664d1c23a7a1ff6e0197a77a4358032b870a Mon Sep 17 00:00:00 2001 From: Cemu-Language CI <github-actions@github.com> Date: Sat, 7 Dec 2024 07:14:20 +0000 Subject: [PATCH 282/314] Update translation files --- bin/resources/ar/â€â€cemu.mo | Bin 0 -> 81849 bytes bin/resources/de/cemu.mo | Bin 65571 -> 69412 bytes bin/resources/ru/cemu.mo | Bin 90752 -> 91888 bytes bin/resources/sv/cemu.mo | Bin 15821 -> 67980 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 bin/resources/ar/â€â€cemu.mo diff --git a/bin/resources/ar/â€â€cemu.mo b/bin/resources/ar/â€â€cemu.mo new file mode 100644 index 0000000000000000000000000000000000000000..4062628be1486a0ffe6a0d2731c6853e4b133880 GIT binary patch literal 81849 zcmcGX2Y_8g_5W`u2`s&LxS^y#vLti@64ME!EZKyP@OJlY_L1Fv%f8(dAV3I7AV^UG zMMb29giu0As47YkM6uB1EhvIu2mPslsFeTbd(PbZ?rxT%zu$lL^1ai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kLq}*&m&^{uHWvBMG3zFu{+#s*)0T z-r`4AWW%9IlQ6--;a)CjpSL7L>Dn<L@V&61Fy}~iMbU~#36|TlS>ZtdCKV=7@r<@a zIJq#uBnJC7y5N^YX@+2|!x+hN(P#>h>oY75?8dY}j4FgJJsC92A{;`&(0Z?RBGUpf z8G4b~>8iFAQ+^3Fw;3G`35t_(@klch-gCGur>;MnT-~e-BTLYsWb;jljXsX1Kc}UI zYOC`8#!ExR_=kzWW6(&n^ld~8&&+PFzwpeYu^6E^q(t^T02m2ROQ<AbUdIn|v_)AJ z^bofJN`*m8H1jmmiIPYQT~Jwe`FIs1i{X=8k;F4UW<G`ob%=vUkjlh8EU_Ibsw`Mm zmR3^#Bym)I(83+}d(n{KLMCJi3p&Q}p`uHduUx)yHh||ZtiE0c(<HM&Q2i4+6Gk$H zKYZP;?IOG2+6EM8TOZkj$dUv_F{q1Wdd}*pZL(umyF9+NM)N2m;hAr%&cFqd>w9OT z@6X?V?raU;dhWa58BE-^RZO}?7$&jXj^9$Z2Bgig&43p8``AKT9tRtDHZ-oh`NkO= zUisPUSFc|`bK^I!4Og!G?9FSd3opO+!i6(;yFx#trCqhSQ!@a5{o=1Kow4!tf4$BZ ze9zeU#>JlxS8rU4+au=ItUX7{@{n_;IJJ1GSZ`R{cARd0qKyp1<78I?ak|_h`~q@^ zTt(()xPIx<wRf++vvmgjyT{BT;~W|9j9#$5wb{3Q?<XjP{nA<jdpsqBuHr)m8CHb! z!LYcK)?Sgu_%b(@rL2YLEe>SdmvR%30qb}AgB*uHS!(MFtH)uc!$>kS6+u4Mz}68` Vgzj&`LH}xLZ2dy=?u{P|{|}7B5uN}5 literal 0 HcmV?d00001 diff --git a/bin/resources/de/cemu.mo b/bin/resources/de/cemu.mo index 8dc4e8cc9ec032d5dcd38af5359b3246398a7e0a..cd9edd3cb981068219006dd4b84921e7b6169b00 100644 GIT binary patch delta 25224 zcmchf2Xs``{_oE~XrXrygagtgp@^UqArN{Ch9;meNhZmdWF}4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vOR$w|pO_#ZjRyOQ@% zww3rqx2mR0NST(rhuBW)?xD6>i{jo}xo=y_WbfU3lJ_Hx?MVJ6<x{tAr22uB$=sU6 ztp}2mis||LNbTo|dsHoD3hr_9gq?KBbRa2tdr9}a`QH@xsB`osDS5ZI?Omj|YK4+l zdAqYMWfJA)ssFE@{{Jsq@@hsokwMc*9=I=gtL9{0nNztnZ&?~AB_}2){U1}OI(qgl zGgFh)f_gz4dx*_&r_6*&?&KuRU-Gu(eJPU`c`CZH?~bY9DipfAe@9oFz}?rPTv=TI E1BADx(*OVf diff --git a/bin/resources/sv/cemu.mo b/bin/resources/sv/cemu.mo index 3e850b365f93c9190904a00dc65da40718ab6c6e..c8fd68ee6a01d9e46e65852673262b289852d362 100644 GIT binary patch literal 67980 zcmcef37i~N)%Gjw3_G%~6$q0AGD8yfu!QWyY-45;cClxsXQr8+?xDLU$$$}178PU@ zZ~+yR#SL+dilVOs6l4=*Q`rO*1O>zmQStjf=iI8Uo($^yzTfxtZ)%>pw{G3#+;h)8 z=iFOWPj0)x6%oJv){mmyz}n7HG<}08x@W3lqv+0AQM3hk7q~h2D7YE;9Jnd?YQQ%F zZZO;9w*-}LCvaDA9Jm#DG`J<$1}eW(zzx76xFdKPxGnera1-!qa2xP?a6|B$pzgml z#NPvMP54Q$8GI##cbMbp#)BIXe=yht9tmy?9s{cWZJ_c$0o)KQhHwScedmCx&jsMy zz)yn8=d0lM;H{wQ`BQL1@NrQ2J`=*f1y$Z_py=@iC^~F3*UQ}j)b$CV=rI{ozDI&; zXFIqd*a@oKK2Y~p!F|B@fvVr<K-J^Bpvu1kRKE9v>c2-p<@+m8>HY@p1a2_T!@Gkj zzZn!g4*)j+XM>{8{1AU4sPc>8cHp}~<##D~0QhlGbh-~zd!GSSzn4MPf6OsnpUpwl zXBSZECxaV<v%!tPh2SP&JE-zb0>vLia0l=la1-#VfY*V#@1_v`I;iq)1$Ez@py={6 zsCK>xioSmVb>BwwJ>M-rwRar2CwMTZ`Y#X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+{wla4EU%>soUR$tF-g12yEvR2+D zd?!~?*XE?-<BT<s`A6)OrIsC-l>g0Hb8BUQId^ehAqz~<S|k{3Ul_%BB5^ou5d$>S zz2#}=)ueextEc5X3U=MfnprH7-SiXEl@-4{B`G|!%J!V_@2yrbx2=^-ueJbQsXC0* I$@Jv>FAgnol>h($ From e2d0871ca34ab9c20bd9939e661c299067b04124 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 7 Dec 2024 07:48:30 +0100 Subject: [PATCH 283/314] Camera: Set error code in CAMInit Fixes Hunter's Trophy 2 crashing on boot --- src/Cafe/OS/libs/camera/camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/camera/camera.cpp b/src/Cafe/OS/libs/camera/camera.cpp index 4debb37f..03e01bfc 100644 --- a/src/Cafe/OS/libs/camera/camera.cpp +++ b/src/Cafe/OS/libs/camera/camera.cpp @@ -181,7 +181,7 @@ namespace camera sint32 CAMInit(uint32 cameraId, CAMInitInfo_t* camInitInfo, uint32be* error) { CameraInstance* camInstance = new CameraInstance(camInitInfo->width, camInitInfo->height, camInitInfo->handlerFuncPtr); - + *error = 0; // Hunter's Trophy 2 will fail to boot if we don't set this std::unique_lock<std::recursive_mutex> _lock(g_mutex_camera); if (g_cameraCounter == 0) { From 356cf0e5e00a17a632ee6c845072a877c96c8eaf Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:23:11 +0100 Subject: [PATCH 284/314] Multiple smaller HLE improvements --- src/Cafe/OS/RPL/rpl_structs.h | 2 +- src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp | 14 +++++++++++++- src/Cafe/OS/libs/coreinit/coreinit_GHS.h | 4 ++++ src/Cafe/OS/libs/coreinit/coreinit_Thread.h | 2 +- src/Cafe/OS/libs/gx2/GX2_Resource.cpp | 6 ++++++ src/Cafe/OS/libs/nsysnet/nsysnet.cpp | 11 +++-------- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Cafe/OS/RPL/rpl_structs.h b/src/Cafe/OS/RPL/rpl_structs.h index 998ec8d7..c66f6136 100644 --- a/src/Cafe/OS/RPL/rpl_structs.h +++ b/src/Cafe/OS/RPL/rpl_structs.h @@ -116,7 +116,7 @@ typedef struct /* +0x34 */ uint32be ukn34; /* +0x38 */ uint32be ukn38; /* +0x3C */ uint32be ukn3C; - /* +0x40 */ uint32be toolkitVersion; + /* +0x40 */ uint32be minimumToolkitVersion; /* +0x44 */ uint32be ukn44; /* +0x48 */ uint32be ukn48; /* +0x4C */ uint32be ukn4C; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp b/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp index e2864fb9..33c8eedc 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_GHS.cpp @@ -156,12 +156,22 @@ namespace coreinit return ¤tThread->crt.eh_mem_manage; } - void* __gh_errno_ptr() + sint32be* __gh_errno_ptr() { OSThread_t* currentThread = coreinit::OSGetCurrentThread(); return ¤tThread->context.ghs_errno; } + void __gh_set_errno(sint32 errNo) + { + *__gh_errno_ptr() = errNo; + } + + sint32 __gh_get_errno() + { + return *__gh_errno_ptr(); + } + void* __get_eh_store_globals() { OSThread_t* currentThread = coreinit::OSGetCurrentThread(); @@ -272,6 +282,8 @@ namespace coreinit cafeExportRegister("coreinit", __get_eh_globals, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_mem_manage, LogType::Placeholder); cafeExportRegister("coreinit", __gh_errno_ptr, LogType::Placeholder); + cafeExportRegister("coreinit", __gh_set_errno, LogType::Placeholder); + cafeExportRegister("coreinit", __gh_get_errno, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_store_globals, LogType::Placeholder); cafeExportRegister("coreinit", __get_eh_store_globals_tdeh, LogType::Placeholder); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_GHS.h b/src/Cafe/OS/libs/coreinit/coreinit_GHS.h index 0ac09e94..5f000732 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_GHS.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_GHS.h @@ -4,5 +4,9 @@ namespace coreinit { void PrepareGHSRuntime(); + sint32be* __gh_errno_ptr(); + void __gh_set_errno(sint32 errNo); + sint32 __gh_get_errno(); + void InitializeGHS(); }; \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h index df787bf0..1a93022b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.h @@ -38,7 +38,7 @@ struct OSContext_t /* +0x1E0 */ uint64be fp_ps1[32]; /* +0x2E0 */ uint64be coretime[3]; /* +0x2F8 */ uint64be starttime; - /* +0x300 */ uint32be ghs_errno; // returned by __gh_errno_ptr() (used by socketlasterr) + /* +0x300 */ sint32be ghs_errno; // returned by __gh_errno_ptr() (used by socketlasterr) /* +0x304 */ uint32be affinity; /* +0x308 */ uint32be upmc1; /* +0x30C */ uint32be upmc2; diff --git a/src/Cafe/OS/libs/gx2/GX2_Resource.cpp b/src/Cafe/OS/libs/gx2/GX2_Resource.cpp index 97f51a0d..a6029de9 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Resource.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Resource.cpp @@ -87,6 +87,11 @@ namespace GX2 return true; } + void GX2RSetBufferName(GX2RBuffer* buffer, const char* name) + { + // no-op in production builds + } + void* GX2RLockBufferEx(GX2RBuffer* buffer, uint32 resFlags) { return buffer->GetPtr(); @@ -226,6 +231,7 @@ namespace GX2 cafeExportRegister("gx2", GX2RCreateBufferUserMemory, LogType::GX2); cafeExportRegister("gx2", GX2RDestroyBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RBufferExists, LogType::GX2); + cafeExportRegister("gx2", GX2RSetBufferName, LogType::GX2); cafeExportRegister("gx2", GX2RLockBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RUnlockBufferEx, LogType::GX2); cafeExportRegister("gx2", GX2RInvalidateBuffer, LogType::GX2); diff --git a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp index 5a0ddc59..c83915db 100644 --- a/src/Cafe/OS/libs/nsysnet/nsysnet.cpp +++ b/src/Cafe/OS/libs/nsysnet/nsysnet.cpp @@ -3,6 +3,7 @@ #include "Cafe/OS/libs/coreinit/coreinit_Thread.h" #include "Cafe/IOSU/legacy/iosu_crypto.h" #include "Cafe/OS/libs/coreinit/coreinit_Time.h" +#include "Cafe/OS/libs/coreinit/coreinit_GHS.h" #include "Common/socket.h" @@ -117,20 +118,14 @@ void nsysnetExport_socket_lib_finish(PPCInterpreter_t* hCPU) osLib_returnFromFunction(hCPU, 0); // 0 -> Success } -static uint32be* __gh_errno_ptr() -{ - OSThread_t* osThread = coreinit::OSGetCurrentThread(); - return &osThread->context.ghs_errno; -} - void _setSockError(sint32 errCode) { - *(uint32be*)__gh_errno_ptr() = (uint32)errCode; + coreinit::__gh_set_errno(errCode); } sint32 _getSockError() { - return (sint32)*(uint32be*)__gh_errno_ptr(); + return coreinit::__gh_get_errno(); } // error translation modes for _translateError From 934cb5460577dd4f672ae3d9c918826e50073934 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:24:59 +0100 Subject: [PATCH 285/314] Properly check if MLC is writeable --- src/gui/CemuApp.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 50ff3b89..c4b1f4e4 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -234,6 +234,12 @@ void CemuApp::InitializeExistingMLCOrFail(fs::path mlc) g_config.Save(); } } + else + { + // default path is not writeable. Just let the user know and quit. Unsure if it would be a good idea to ask the user to choose an alternative path instead + wxMessageBox(formatWxString(_("Cemu failed to write to the default mlc directory.\nThe path is:\n{}"), wxHelper::FromPath(mlc)), _("Error"), wxOK | wxCENTRE | wxICON_ERROR); + exit(0); + } } bool CemuApp::OnInit() @@ -507,6 +513,13 @@ bool CemuApp::CreateDefaultMLCFiles(const fs::path& mlc) file.flush(); file.close(); } + // create a dummy file in the mlc folder to check if it's writable + const auto dummyFile = fs::path(mlc).append("writetestdummy"); + std::ofstream file(dummyFile); + if (!file.is_open()) + return false; + file.close(); + fs::remove(dummyFile); } catch (const std::exception& ex) { From dd0af0a56fa3c6b8a82f60c19e67bbe06d673d0e Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Sat, 7 Dec 2024 11:02:40 +0000 Subject: [PATCH 286/314] Linux: Allow connecting Wiimotes via L2CAP (#1353) --- .github/workflows/build.yml | 4 +- BUILD.md | 6 +- CMakeLists.txt | 7 + cmake/Findbluez.cmake | 20 + src/gui/input/PairingDialog.cpp | 394 ++++++++++-------- src/gui/input/PairingDialog.h | 2 +- src/input/CMakeLists.txt | 10 + .../api/Wiimote/WiimoteControllerProvider.cpp | 120 ++++-- .../api/Wiimote/WiimoteControllerProvider.h | 6 +- src/input/api/Wiimote/WiimoteDevice.h | 3 +- .../api/Wiimote/hidapi/HidapiWiimote.cpp | 7 +- src/input/api/Wiimote/hidapi/HidapiWiimote.h | 4 +- src/input/api/Wiimote/l2cap/L2CapWiimote.cpp | 148 +++++++ src/input/api/Wiimote/l2cap/L2CapWiimote.h | 22 + 14 files changed, 532 insertions(+), 221 deletions(-) create mode 100644 cmake/Findbluez.cmake create mode 100644 src/input/api/Wiimote/l2cap/L2CapWiimote.cpp create mode 100644 src/input/api/Wiimote/l2cap/L2CapWiimote.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72bbcf52..6ae4b892 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: - name: "Install system dependencies" run: | sudo apt update -qq - sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev nasm ninja-build + sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev nasm ninja-build libbluetooth-dev - name: "Setup cmake" uses: jwlawson/actions-setup-cmake@v2 @@ -96,7 +96,7 @@ jobs: - name: "Install system dependencies" run: | sudo apt update -qq - sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build appstream + sudo apt install -y clang-15 cmake freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev nasm ninja-build appstream libbluetooth-dev - name: "Build AppImage" run: | diff --git a/BUILD.md b/BUILD.md index 44d69c6c..41de928e 100644 --- a/BUILD.md +++ b/BUILD.md @@ -46,10 +46,10 @@ To compile Cemu, a recent enough compiler and STL with C++20 support is required ### Dependencies #### For Arch and derivatives: -`sudo pacman -S --needed base-devel clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` +`sudo pacman -S --needed base-devel bluez-libs clang cmake freeglut git glm gtk3 libgcrypt libpulse libsecret linux-headers llvm nasm ninja systemd unzip zip` #### For Debian, Ubuntu and derivatives: -`sudo apt install -y cmake curl clang-15 freeglut3-dev git libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libtool nasm ninja-build` +`sudo apt install -y cmake curl clang-15 freeglut3-dev git libbluetooth-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libtool nasm ninja-build` You may also need to install `libusb-1.0-0-dev` as a workaround for an issue with the vcpkg hidapi package. @@ -57,7 +57,7 @@ At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clan `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` #### For Fedora and derivatives: -`sudo dnf install clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel zlib-static` +`sudo dnf install bluez-libs clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel zlib-static` ### Build Cemu diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b5cff6c..cf04b235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ endif() if (UNIX AND NOT APPLE) option(ENABLE_WAYLAND "Build with Wayland support" ON) option(ENABLE_FERAL_GAMEMODE "Enables Feral Interactive GameMode Support" ON) + option(ENABLE_BLUEZ "Build with Bluez support" ON) endif() option(ENABLE_OPENGL "Enables the OpenGL backend" ON) @@ -179,6 +180,12 @@ if (UNIX AND NOT APPLE) endif() find_package(GTK3 REQUIRED) + if(ENABLE_BLUEZ) + find_package(bluez REQUIRED) + set(ENABLE_WIIMOTE ON) + add_compile_definitions(HAS_BLUEZ) + endif() + endif() if (ENABLE_VULKAN) diff --git a/cmake/Findbluez.cmake b/cmake/Findbluez.cmake new file mode 100644 index 00000000..007cdac9 --- /dev/null +++ b/cmake/Findbluez.cmake @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda <andrea@pappacoda.it> +# SPDX-License-Identifier: ISC + +find_package(bluez CONFIG) +if (NOT bluez_FOUND) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_search_module(bluez IMPORTED_TARGET GLOBAL bluez-1.0 bluez) + if (bluez_FOUND) + add_library(bluez::bluez ALIAS PkgConfig::bluez) + endif () + endif () +endif () + +find_package_handle_standard_args(bluez + REQUIRED_VARS + bluez_LINK_LIBRARIES + bluez_FOUND + VERSION_VAR bluez_VERSION +) diff --git a/src/gui/input/PairingDialog.cpp b/src/gui/input/PairingDialog.cpp index 03d6315b..350fce81 100644 --- a/src/gui/input/PairingDialog.cpp +++ b/src/gui/input/PairingDialog.cpp @@ -4,233 +4,297 @@ #if BOOST_OS_WINDOWS #include <bluetoothapis.h> #endif +#if BOOST_OS_LINUX +#include <bluetooth/bluetooth.h> +#include <bluetooth/hci.h> +#include <bluetooth/hci_lib.h> +#include <input/api/Wiimote/l2cap/L2CapWiimote.h> +#endif wxDECLARE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); wxDEFINE_EVENT(wxEVT_PROGRESS_PAIR, wxCommandEvent); PairingDialog::PairingDialog(wxWindow* parent) - : wxDialog(parent, wxID_ANY, _("Pairing..."), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) + : wxDialog(parent, wxID_ANY, _("Pairing..."), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxCLOSE_BOX) { - auto* sizer = new wxBoxSizer(wxVERTICAL); - m_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(350, 20), wxGA_HORIZONTAL); - m_gauge->SetValue(0); - sizer->Add(m_gauge, 0, wxALL | wxEXPAND, 5); + auto* sizer = new wxBoxSizer(wxVERTICAL); + m_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(350, 20), wxGA_HORIZONTAL); + m_gauge->SetValue(0); + sizer->Add(m_gauge, 0, wxALL | wxEXPAND, 5); - auto* rows = new wxFlexGridSizer(0, 2, 0, 0); - rows->AddGrowableCol(1); + auto* rows = new wxFlexGridSizer(0, 2, 0, 0); + rows->AddGrowableCol(1); - m_text = new wxStaticText(this, wxID_ANY, _("Searching for controllers...")); - rows->Add(m_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); + m_text = new wxStaticText(this, wxID_ANY, _("Searching for controllers...")); + rows->Add(m_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5); - { - auto* right_side = new wxBoxSizer(wxHORIZONTAL); + { + auto* right_side = new wxBoxSizer(wxHORIZONTAL); - m_cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); - m_cancelButton->Bind(wxEVT_BUTTON, &PairingDialog::OnCancelButton, this); - right_side->Add(m_cancelButton, 0, wxALL, 5); + m_cancelButton = new wxButton(this, wxID_ANY, _("Cancel")); + m_cancelButton->Bind(wxEVT_BUTTON, &PairingDialog::OnCancelButton, this); + right_side->Add(m_cancelButton, 0, wxALL, 5); - rows->Add(right_side, 1, wxALIGN_RIGHT, 5); - } + rows->Add(right_side, 1, wxALIGN_RIGHT, 5); + } - sizer->Add(rows, 0, wxALL | wxEXPAND, 5); + sizer->Add(rows, 0, wxALL | wxEXPAND, 5); - SetSizerAndFit(sizer); - Centre(wxBOTH); + SetSizerAndFit(sizer); + Centre(wxBOTH); - Bind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); - Bind(wxEVT_PROGRESS_PAIR, &PairingDialog::OnGaugeUpdate, this); + Bind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); + Bind(wxEVT_PROGRESS_PAIR, &PairingDialog::OnGaugeUpdate, this); - m_thread = std::thread(&PairingDialog::WorkerThread, this); + m_thread = std::thread(&PairingDialog::WorkerThread, this); } PairingDialog::~PairingDialog() { - Unbind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); + Unbind(wxEVT_CLOSE_WINDOW, &PairingDialog::OnClose, this); } void PairingDialog::OnClose(wxCloseEvent& event) { - event.Skip(); + event.Skip(); - m_threadShouldQuit = true; - if (m_thread.joinable()) - m_thread.join(); + m_threadShouldQuit = true; + if (m_thread.joinable()) + m_thread.join(); } void PairingDialog::OnCancelButton(const wxCommandEvent& event) { - Close(); + Close(); } void PairingDialog::OnGaugeUpdate(wxCommandEvent& event) { - PairingState state = (PairingState)event.GetInt(); + PairingState state = (PairingState)event.GetInt(); - switch (state) - { - case PairingState::Pairing: - { - m_text->SetLabel(_("Found controller. Pairing...")); - m_gauge->SetValue(50); - break; - } + switch (state) + { + case PairingState::Pairing: + { + m_text->SetLabel(_("Found controller. Pairing...")); + m_gauge->SetValue(50); + break; + } - case PairingState::Finished: - { - m_text->SetLabel(_("Successfully paired the controller.")); - m_gauge->SetValue(100); - m_cancelButton->SetLabel(_("Close")); - break; - } + case PairingState::Finished: + { + m_text->SetLabel(_("Successfully paired the controller.")); + m_gauge->SetValue(100); + m_cancelButton->SetLabel(_("Close")); + break; + } - case PairingState::NoBluetoothAvailable: - { - m_text->SetLabel(_("Failed to find a suitable Bluetooth radio.")); - m_gauge->SetValue(0); - m_cancelButton->SetLabel(_("Close")); - break; - } + case PairingState::NoBluetoothAvailable: + { + m_text->SetLabel(_("Failed to find a suitable Bluetooth radio.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } - case PairingState::BluetoothFailed: - { - m_text->SetLabel(_("Failed to search for controllers.")); - m_gauge->SetValue(0); - m_cancelButton->SetLabel(_("Close")); - break; - } + case PairingState::SearchFailed: + { + m_text->SetLabel(_("Failed to find controllers.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } - case PairingState::PairingFailed: - { - m_text->SetLabel(_("Failed to pair with the found controller.")); - m_gauge->SetValue(0); - m_cancelButton->SetLabel(_("Close")); - break; - } + case PairingState::PairingFailed: + { + m_text->SetLabel(_("Failed to pair with the found controller.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } - case PairingState::BluetoothUnusable: - { - m_text->SetLabel(_("Please use your system's Bluetooth manager instead.")); - m_gauge->SetValue(0); - m_cancelButton->SetLabel(_("Close")); - break; - } + case PairingState::BluetoothUnusable: + { + m_text->SetLabel(_("Please use your system's Bluetooth manager instead.")); + m_gauge->SetValue(0); + m_cancelButton->SetLabel(_("Close")); + break; + } - - default: - { - break; - } - } + default: + { + break; + } + } } -void PairingDialog::WorkerThread() -{ - const std::wstring wiimoteName = L"Nintendo RVL-CNT-01"; - const std::wstring wiiUProControllerName = L"Nintendo RVL-CNT-01-UC"; - #if BOOST_OS_WINDOWS - const GUID bthHidGuid = {0x00001124,0x0000,0x1000,{0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB}}; +void PairingDialog::WorkerThread() +{ + const std::wstring wiimoteName = L"Nintendo RVL-CNT-01"; + const std::wstring wiiUProControllerName = L"Nintendo RVL-CNT-01-UC"; - const BLUETOOTH_FIND_RADIO_PARAMS radioFindParams = - { - .dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS) - }; + const GUID bthHidGuid = {0x00001124, 0x0000, 0x1000, {0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}}; - HANDLE radio = INVALID_HANDLE_VALUE; - HBLUETOOTH_RADIO_FIND radioFind = BluetoothFindFirstRadio(&radioFindParams, &radio); - if (radioFind == nullptr) - { - UpdateCallback(PairingState::NoBluetoothAvailable); - return; - } + const BLUETOOTH_FIND_RADIO_PARAMS radioFindParams = + { + .dwSize = sizeof(BLUETOOTH_FIND_RADIO_PARAMS)}; - BluetoothFindRadioClose(radioFind); + HANDLE radio = INVALID_HANDLE_VALUE; + HBLUETOOTH_RADIO_FIND radioFind = BluetoothFindFirstRadio(&radioFindParams, &radio); + if (radioFind == nullptr) + { + UpdateCallback(PairingState::NoBluetoothAvailable); + return; + } - BLUETOOTH_RADIO_INFO radioInfo = - { - .dwSize = sizeof(BLUETOOTH_RADIO_INFO) - }; + BluetoothFindRadioClose(radioFind); - DWORD result = BluetoothGetRadioInfo(radio, &radioInfo); - if (result != ERROR_SUCCESS) - { - UpdateCallback(PairingState::NoBluetoothAvailable); - return; - } + BLUETOOTH_RADIO_INFO radioInfo = + { + .dwSize = sizeof(BLUETOOTH_RADIO_INFO)}; - const BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = - { - .dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), + DWORD result = BluetoothGetRadioInfo(radio, &radioInfo); + if (result != ERROR_SUCCESS) + { + UpdateCallback(PairingState::NoBluetoothAvailable); + return; + } - .fReturnAuthenticated = FALSE, - .fReturnRemembered = FALSE, - .fReturnUnknown = TRUE, - .fReturnConnected = FALSE, + const BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = + { + .dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), - .fIssueInquiry = TRUE, - .cTimeoutMultiplier = 5, + .fReturnAuthenticated = FALSE, + .fReturnRemembered = FALSE, + .fReturnUnknown = TRUE, + .fReturnConnected = FALSE, - .hRadio = radio - }; + .fIssueInquiry = TRUE, + .cTimeoutMultiplier = 5, - BLUETOOTH_DEVICE_INFO info = - { - .dwSize = sizeof(BLUETOOTH_DEVICE_INFO) - }; + .hRadio = radio}; - while (!m_threadShouldQuit) - { - HBLUETOOTH_DEVICE_FIND deviceFind = BluetoothFindFirstDevice(&searchParams, &info); - if (deviceFind == nullptr) - { - UpdateCallback(PairingState::BluetoothFailed); - return; - } + BLUETOOTH_DEVICE_INFO info = + { + .dwSize = sizeof(BLUETOOTH_DEVICE_INFO)}; - while (!m_threadShouldQuit) - { - if (info.szName == wiimoteName || info.szName == wiiUProControllerName) - { - BluetoothFindDeviceClose(deviceFind); + while (!m_threadShouldQuit) + { + HBLUETOOTH_DEVICE_FIND deviceFind = BluetoothFindFirstDevice(&searchParams, &info); + if (deviceFind == nullptr) + { + UpdateCallback(PairingState::SearchFailed); + return; + } - UpdateCallback(PairingState::Pairing); + while (!m_threadShouldQuit) + { + if (info.szName == wiimoteName || info.szName == wiiUProControllerName) + { + BluetoothFindDeviceClose(deviceFind); - wchar_t passwd[6] = { radioInfo.address.rgBytes[0], radioInfo.address.rgBytes[1], radioInfo.address.rgBytes[2], radioInfo.address.rgBytes[3], radioInfo.address.rgBytes[4], radioInfo.address.rgBytes[5] }; - DWORD bthResult = BluetoothAuthenticateDevice(nullptr, radio, &info, passwd, 6); - if (bthResult != ERROR_SUCCESS) - { - UpdateCallback(PairingState::PairingFailed); - return; - } + UpdateCallback(PairingState::Pairing); - bthResult = BluetoothSetServiceState(radio, &info, &bthHidGuid, BLUETOOTH_SERVICE_ENABLE); - if (bthResult != ERROR_SUCCESS) - { - UpdateCallback(PairingState::PairingFailed); - return; - } + wchar_t passwd[6] = {radioInfo.address.rgBytes[0], radioInfo.address.rgBytes[1], radioInfo.address.rgBytes[2], radioInfo.address.rgBytes[3], radioInfo.address.rgBytes[4], radioInfo.address.rgBytes[5]}; + DWORD bthResult = BluetoothAuthenticateDevice(nullptr, radio, &info, passwd, 6); + if (bthResult != ERROR_SUCCESS) + { + UpdateCallback(PairingState::PairingFailed); + return; + } - UpdateCallback(PairingState::Finished); - return; - } + bthResult = BluetoothSetServiceState(radio, &info, &bthHidGuid, BLUETOOTH_SERVICE_ENABLE); + if (bthResult != ERROR_SUCCESS) + { + UpdateCallback(PairingState::PairingFailed); + return; + } - BOOL nextDevResult = BluetoothFindNextDevice(deviceFind, &info); - if (nextDevResult == FALSE) - { - break; - } - } + UpdateCallback(PairingState::Finished); + return; + } - BluetoothFindDeviceClose(deviceFind); - } -#else - UpdateCallback(PairingState::BluetoothUnusable); -#endif + BOOL nextDevResult = BluetoothFindNextDevice(deviceFind, &info); + if (nextDevResult == FALSE) + { + break; + } + } + + BluetoothFindDeviceClose(deviceFind); + } } +#elif BOOST_OS_LINUX +void PairingDialog::WorkerThread() +{ + constexpr static uint8_t LIAC_LAP[] = {0x00, 0x8b, 0x9e}; + constexpr static auto isWiimoteName = [](std::string_view name) { + return name == "Nintendo RVL-CNT-01" || name == "Nintendo RVL-CNT-01-TR"; + }; + + // Get default BT device + const auto hostId = hci_get_route(nullptr); + if (hostId < 0) + { + UpdateCallback(PairingState::NoBluetoothAvailable); + return; + } + + // Search for device + inquiry_info* infos = nullptr; + m_cancelButton->Disable(); + const auto respCount = hci_inquiry(hostId, 7, 4, LIAC_LAP, &infos, IREQ_CACHE_FLUSH); + m_cancelButton->Enable(); + if (respCount <= 0) + { + UpdateCallback(PairingState::SearchFailed); + return; + } + stdx::scope_exit infoFree([&]() { bt_free(infos);}); + + if (m_threadShouldQuit) + return; + + // Open dev to read name + const auto hostDev = hci_open_dev(hostId); + stdx::scope_exit devClose([&]() { hci_close_dev(hostDev);}); + + char nameBuffer[HCI_MAX_NAME_LENGTH] = {}; + + bool foundADevice = false; + // Get device name and compare. Would use product and vendor id from SDP, but many third-party Wiimotes don't store them + for (const auto& devInfo : std::span(infos, respCount)) + { + const auto& addr = devInfo.bdaddr; + const auto err = hci_read_remote_name(hostDev, &addr, HCI_MAX_NAME_LENGTH, nameBuffer, + 2000); + if (m_threadShouldQuit) + return; + if (err || !isWiimoteName(nameBuffer)) + continue; + + L2CapWiimote::AddCandidateAddress(addr); + foundADevice = true; + const auto& b = addr.b; + cemuLog_log(LogType::Force, "Pairing Dialog: Found '{}' with address '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'", + nameBuffer, b[5], b[4], b[3], b[2], b[1], b[0]); + } + if (foundADevice) + UpdateCallback(PairingState::Finished); + else + UpdateCallback(PairingState::SearchFailed); +} +#else +void PairingDialog::WorkerThread() +{ + UpdateCallback(PairingState::BluetoothUnusable); +} +#endif void PairingDialog::UpdateCallback(PairingState state) { - auto* event = new wxCommandEvent(wxEVT_PROGRESS_PAIR); - event->SetInt((int)state); - wxQueueEvent(this, event); + auto* event = new wxCommandEvent(wxEVT_PROGRESS_PAIR); + event->SetInt((int)state); + wxQueueEvent(this, event); } \ No newline at end of file diff --git a/src/gui/input/PairingDialog.h b/src/gui/input/PairingDialog.h index 6c7612d1..02cab4fc 100644 --- a/src/gui/input/PairingDialog.h +++ b/src/gui/input/PairingDialog.h @@ -17,7 +17,7 @@ private: Pairing, Finished, NoBluetoothAvailable, - BluetoothFailed, + SearchFailed, PairingFailed, BluetoothUnusable }; diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index 9f7873a1..004dc2ba 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -73,6 +73,11 @@ if (ENABLE_WIIMOTE) api/Wiimote/hidapi/HidapiWiimote.cpp api/Wiimote/hidapi/HidapiWiimote.h ) + if (UNIX AND NOT APPLE) + target_sources(CemuInput PRIVATE + api/Wiimote/l2cap/L2CapWiimote.cpp + api/Wiimote/l2cap/L2CapWiimote.h) + endif() endif () @@ -97,3 +102,8 @@ endif() if (ENABLE_WXWIDGETS) target_link_libraries(CemuInput PRIVATE wx::base wx::core) endif() + + +if (UNIX AND NOT APPLE) + target_link_libraries(CemuInput PRIVATE bluez::bluez) +endif () \ No newline at end of file diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.cpp b/src/input/api/Wiimote/WiimoteControllerProvider.cpp index c80f3fbe..221d75a7 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.cpp +++ b/src/input/api/Wiimote/WiimoteControllerProvider.cpp @@ -2,7 +2,12 @@ #include "input/api/Wiimote/NativeWiimoteController.h" #include "input/api/Wiimote/WiimoteMessages.h" +#ifdef HAS_HIDAPI #include "input/api/Wiimote/hidapi/HidapiWiimote.h" +#endif +#ifdef HAS_BLUEZ +#include "input/api/Wiimote/l2cap/L2CapWiimote.h" +#endif #include <numbers> #include <queue> @@ -12,6 +17,7 @@ WiimoteControllerProvider::WiimoteControllerProvider() { m_reader_thread = std::thread(&WiimoteControllerProvider::reader_thread, this); m_writer_thread = std::thread(&WiimoteControllerProvider::writer_thread, this); + m_connectionThread = std::thread(&WiimoteControllerProvider::connectionThread, this); } WiimoteControllerProvider::~WiimoteControllerProvider() @@ -21,48 +27,51 @@ WiimoteControllerProvider::~WiimoteControllerProvider() m_running = false; m_writer_thread.join(); m_reader_thread.join(); + m_connectionThread.join(); } } std::vector<std::shared_ptr<ControllerBase>> WiimoteControllerProvider::get_controllers() { + m_connectedDeviceMutex.lock(); + auto devices = m_connectedDevices; + m_connectedDeviceMutex.unlock(); + std::scoped_lock lock(m_device_mutex); - std::queue<uint32> disconnected_wiimote_indices; - for (auto i{0u}; i < m_wiimotes.size(); ++i){ - if (!(m_wiimotes[i].connected = m_wiimotes[i].device->write_data({kStatusRequest, 0x00}))){ - disconnected_wiimote_indices.push(i); - } - } - - const auto valid_new_device = [&](std::shared_ptr<WiimoteDevice> & device) { - const auto writeable = device->write_data({kStatusRequest, 0x00}); - const auto not_already_connected = - std::none_of(m_wiimotes.cbegin(), m_wiimotes.cend(), - [device](const auto& it) { - return (*it.device == *device) && it.connected; - }); - return writeable && not_already_connected; - }; - - for (auto& device : WiimoteDevice_t::get_devices()) + for (auto& device : devices) { - if (!valid_new_device(device)) + const auto writeable = device->write_data({kStatusRequest, 0x00}); + if (!writeable) continue; - // Replace disconnected wiimotes - if (!disconnected_wiimote_indices.empty()){ - const auto idx = disconnected_wiimote_indices.front(); - disconnected_wiimote_indices.pop(); - m_wiimotes.replace(idx, std::make_unique<Wiimote>(device)); - } - // Otherwise add them - else { - m_wiimotes.push_back(std::make_unique<Wiimote>(device)); - } + bool isDuplicate = false; + ssize_t lowestReplaceableIndex = -1; + for (ssize_t i = m_wiimotes.size() - 1; i >= 0; --i) + { + const auto& wiimoteDevice = m_wiimotes[i].device; + if (wiimoteDevice) + { + if (*wiimoteDevice == *device) + { + isDuplicate = true; + break; + } + continue; + } + + lowestReplaceableIndex = i; + } + if (isDuplicate) + continue; + if (lowestReplaceableIndex != -1) + m_wiimotes.replace(lowestReplaceableIndex, std::make_unique<Wiimote>(device)); + else + m_wiimotes.push_back(std::make_unique<Wiimote>(device)); } std::vector<std::shared_ptr<ControllerBase>> result; + result.reserve(m_wiimotes.size()); for (size_t i = 0; i < m_wiimotes.size(); ++i) { result.emplace_back(std::make_shared<NativeWiimoteController>(i)); @@ -74,7 +83,7 @@ std::vector<std::shared_ptr<ControllerBase>> WiimoteControllerProvider::get_cont bool WiimoteControllerProvider::is_connected(size_t index) { std::shared_lock lock(m_device_mutex); - return index < m_wiimotes.size() && m_wiimotes[index].connected; + return index < m_wiimotes.size() && m_wiimotes[index].device; } bool WiimoteControllerProvider::is_registered_device(size_t index) @@ -141,6 +150,30 @@ WiimoteControllerProvider::WiimoteState WiimoteControllerProvider::get_state(siz return {}; } +void WiimoteControllerProvider::connectionThread() +{ + SetThreadName("Wiimote-connect"); + while (m_running.load(std::memory_order_relaxed)) + { + std::vector<WiimoteDevicePtr> devices; +#ifdef HAS_HIDAPI + const auto& hidDevices = HidapiWiimote::get_devices(); + std::ranges::move(hidDevices, std::back_inserter(devices)); +#endif +#ifdef HAS_BLUEZ + const auto& l2capDevices = L2CapWiimote::get_devices(); + std::ranges::move(l2capDevices, std::back_inserter(devices)); +#endif + { + std::scoped_lock lock(m_connectedDeviceMutex); + m_connectedDevices.clear(); + std::ranges::move(devices, std::back_inserter(m_connectedDevices)); + } + std::this_thread::sleep_for(std::chrono::seconds(2)); + } +} + + void WiimoteControllerProvider::reader_thread() { SetThreadName("Wiimote-reader"); @@ -148,7 +181,7 @@ void WiimoteControllerProvider::reader_thread() while (m_running.load(std::memory_order_relaxed)) { const auto now = std::chrono::steady_clock::now(); - if (std::chrono::duration_cast<std::chrono::seconds>(now - lastCheck) > std::chrono::seconds(2)) + if (std::chrono::duration_cast<std::chrono::seconds>(now - lastCheck) > std::chrono::milliseconds(500)) { // check for new connected wiimotes get_controllers(); @@ -160,11 +193,16 @@ void WiimoteControllerProvider::reader_thread() for (size_t index = 0; index < m_wiimotes.size(); ++index) { auto& wiimote = m_wiimotes[index]; - if (!wiimote.connected) + if (!wiimote.device) continue; const auto read_data = wiimote.device->read_data(); - if (!read_data || read_data->empty()) + if (!read_data) + { + wiimote.device.reset(); + continue; + } + if (read_data->empty()) continue; receivedAnyPacket = true; @@ -921,18 +959,18 @@ void WiimoteControllerProvider::writer_thread() if (index != (size_t)-1 && !data.empty()) { - if (m_wiimotes[index].rumble) + auto& wiimote = m_wiimotes[index]; + if (!wiimote.device) + continue; + if (wiimote.rumble) data[1] |= 1; - - m_wiimotes[index].connected = m_wiimotes[index].device->write_data(data); - if (m_wiimotes[index].connected) + if (!wiimote.device->write_data(data)) { - m_wiimotes[index].data_ts = std::chrono::high_resolution_clock::now(); + wiimote.device.reset(); + wiimote.rumble = false; } else - { - m_wiimotes[index].rumble = false; - } + wiimote.data_ts = std::chrono::high_resolution_clock::now(); } device_lock.unlock(); diff --git a/src/input/api/Wiimote/WiimoteControllerProvider.h b/src/input/api/Wiimote/WiimoteControllerProvider.h index 7629b641..90f28d5c 100644 --- a/src/input/api/Wiimote/WiimoteControllerProvider.h +++ b/src/input/api/Wiimote/WiimoteControllerProvider.h @@ -77,16 +77,17 @@ public: private: std::atomic_bool m_running = false; std::thread m_reader_thread, m_writer_thread; - std::shared_mutex m_device_mutex; + std::thread m_connectionThread; + std::vector<WiimoteDevicePtr> m_connectedDevices; + std::mutex m_connectedDeviceMutex; struct Wiimote { Wiimote(WiimoteDevicePtr device) : device(std::move(device)) {} WiimoteDevicePtr device; - std::atomic_bool connected = true; std::atomic_bool rumble = false; std::shared_mutex mutex; @@ -103,6 +104,7 @@ private: void reader_thread(); void writer_thread(); + void connectionThread(); void calibrate(size_t index); IRMode set_ir_camera(size_t index, bool state); diff --git a/src/input/api/Wiimote/WiimoteDevice.h b/src/input/api/Wiimote/WiimoteDevice.h index 7938bbdf..8ea5b321 100644 --- a/src/input/api/Wiimote/WiimoteDevice.h +++ b/src/input/api/Wiimote/WiimoteDevice.h @@ -9,8 +9,7 @@ public: virtual bool write_data(const std::vector<uint8>& data) = 0; virtual std::optional<std::vector<uint8_t>> read_data() = 0; - virtual bool operator==(WiimoteDevice& o) const = 0; - bool operator!=(WiimoteDevice& o) const { return *this == o; } + virtual bool operator==(const WiimoteDevice& o) const = 0; }; using WiimoteDevicePtr = std::shared_ptr<WiimoteDevice>; diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp index db185675..5780909f 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.cpp @@ -47,8 +47,11 @@ std::vector<WiimoteDevicePtr> HidapiWiimote::get_devices() { return wiimote_devices; } -bool HidapiWiimote::operator==(WiimoteDevice& o) const { - return static_cast<HidapiWiimote const&>(o).m_path == m_path; +bool HidapiWiimote::operator==(const WiimoteDevice& rhs) const { + auto other = dynamic_cast<const HidapiWiimote*>(&rhs); + if (!other) + return false; + return m_path == other->m_path; } HidapiWiimote::~HidapiWiimote() { diff --git a/src/input/api/Wiimote/hidapi/HidapiWiimote.h b/src/input/api/Wiimote/hidapi/HidapiWiimote.h index 858cb1f3..952a36f0 100644 --- a/src/input/api/Wiimote/hidapi/HidapiWiimote.h +++ b/src/input/api/Wiimote/hidapi/HidapiWiimote.h @@ -10,7 +10,7 @@ public: bool write_data(const std::vector<uint8> &data) override; std::optional<std::vector<uint8>> read_data() override; - bool operator==(WiimoteDevice& o) const override; + bool operator==(const WiimoteDevice& o) const override; static std::vector<WiimoteDevicePtr> get_devices(); @@ -19,5 +19,3 @@ private: const std::string m_path; }; - -using WiimoteDevice_t = HidapiWiimote; \ No newline at end of file diff --git a/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp b/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp new file mode 100644 index 00000000..28a123f3 --- /dev/null +++ b/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp @@ -0,0 +1,148 @@ +#include "L2CapWiimote.h" +#include <bluetooth/l2cap.h> + +constexpr auto comparator = [](const bdaddr_t& a, const bdaddr_t& b) { + return bacmp(&a, &b); +}; + +static auto s_addresses = std::map<bdaddr_t, bool, decltype(comparator)>(comparator); +static std::mutex s_addressMutex; + +static bool AttemptConnect(int sockFd, const sockaddr_l2& addr) +{ + auto res = connect(sockFd, reinterpret_cast<const sockaddr*>(&addr), + sizeof(sockaddr_l2)); + if (res == 0) + return true; + return connect(sockFd, reinterpret_cast<const sockaddr*>(&addr), + sizeof(sockaddr_l2)) == 0; +} + +static bool AttemptSetNonBlock(int sockFd) +{ + return fcntl(sockFd, F_SETFL, fcntl(sockFd, F_GETFL) | O_NONBLOCK) == 0; +} + +L2CapWiimote::L2CapWiimote(int recvFd, int sendFd, bdaddr_t addr) + : m_recvFd(recvFd), m_sendFd(sendFd), m_addr(addr) +{ +} + +L2CapWiimote::~L2CapWiimote() +{ + close(m_recvFd); + close(m_sendFd); + const auto& b = m_addr.b; + cemuLog_logDebug(LogType::Force, "Wiimote at {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x} disconnected", b[5], b[4], b[3], b[2], b[1], b[0]); + + // Re-add to candidate vec + s_addressMutex.lock(); + s_addresses[m_addr] = false; + s_addressMutex.unlock(); +} + +void L2CapWiimote::AddCandidateAddress(bdaddr_t addr) +{ + std::scoped_lock lock(s_addressMutex); + s_addresses.try_emplace(addr, false); +} + +std::vector<WiimoteDevicePtr> L2CapWiimote::get_devices() +{ + s_addressMutex.lock(); + std::vector<bdaddr_t> unconnected; + for (const auto& [addr, connected] : s_addresses) + { + if (!connected) + unconnected.push_back(addr); + } + s_addressMutex.unlock(); + + std::vector<WiimoteDevicePtr> outDevices; + for (const auto& addr : unconnected) + { + // Socket for sending data to controller, PSM 0x11 + auto sendFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); + if (sendFd < 0) + { + cemuLog_logDebug(LogType::Force, "Failed to open send socket: {}", strerror(errno)); + continue; + } + + sockaddr_l2 sendAddr{}; + sendAddr.l2_family = AF_BLUETOOTH; + sendAddr.l2_psm = htobs(0x11); + sendAddr.l2_bdaddr = addr; + + if (!AttemptConnect(sendFd, sendAddr) || !AttemptSetNonBlock(sendFd)) + { + const auto& b = addr.b; + cemuLog_logDebug(LogType::Force, "Failed to connect send socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", + b[5], b[4], b[3], b[2], b[1], b[0], strerror(errno)); + close(sendFd); + continue; + } + + // Socket for receiving data from controller, PSM 0x13 + auto recvFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); + if (recvFd < 0) + { + cemuLog_logDebug(LogType::Force, "Failed to open recv socket: {}", strerror(errno)); + close(sendFd); + continue; + } + sockaddr_l2 recvAddr{}; + recvAddr.l2_family = AF_BLUETOOTH; + recvAddr.l2_psm = htobs(0x13); + recvAddr.l2_bdaddr = addr; + + if (!AttemptConnect(recvFd, recvAddr) || !AttemptSetNonBlock(recvFd)) + { + const auto& b = addr.b; + cemuLog_logDebug(LogType::Force, "Failed to connect recv socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", + b[5], b[4], b[3], b[2], b[1], b[0], strerror(errno)); + close(sendFd); + close(recvFd); + continue; + } + outDevices.emplace_back(std::make_shared<L2CapWiimote>(sendFd, recvFd, addr)); + + s_addressMutex.lock(); + s_addresses[addr] = true; + s_addressMutex.unlock(); + } + return outDevices; +} + +bool L2CapWiimote::write_data(const std::vector<uint8>& data) +{ + const auto size = data.size(); + cemu_assert_debug(size < 23); + uint8 buffer[23]; + // All outgoing messages must be prefixed with 0xA2 + buffer[0] = 0xA2; + std::memcpy(buffer + 1, data.data(), size); + const auto outSize = size + 1; + return send(m_sendFd, buffer, outSize, 0) == outSize; +} + +std::optional<std::vector<uint8>> L2CapWiimote::read_data() +{ + uint8 buffer[23]; + const auto nBytes = recv(m_sendFd, buffer, 23, 0); + + if (nBytes < 0 && errno == EWOULDBLOCK) + return std::vector<uint8>{}; + // All incoming messages must be prefixed with 0xA1 + if (nBytes < 2 || buffer[0] != 0xA1) + return std::nullopt; + return std::vector(buffer + 1, buffer + 1 + nBytes - 1); +} + +bool L2CapWiimote::operator==(const WiimoteDevice& rhs) const +{ + auto mote = dynamic_cast<const L2CapWiimote*>(&rhs); + if (!mote) + return false; + return bacmp(&m_addr, &mote->m_addr) == 0; +} \ No newline at end of file diff --git a/src/input/api/Wiimote/l2cap/L2CapWiimote.h b/src/input/api/Wiimote/l2cap/L2CapWiimote.h new file mode 100644 index 00000000..cc8d071b --- /dev/null +++ b/src/input/api/Wiimote/l2cap/L2CapWiimote.h @@ -0,0 +1,22 @@ +#pragma once +#include <input/api/Wiimote/WiimoteDevice.h> +#include <bluetooth/bluetooth.h> + +class L2CapWiimote : public WiimoteDevice +{ + public: + L2CapWiimote(int recvFd, int sendFd, bdaddr_t addr); + ~L2CapWiimote() override; + + bool write_data(const std::vector<uint8>& data) override; + std::optional<std::vector<uint8>> read_data() override; + bool operator==(const WiimoteDevice& o) const override; + + static void AddCandidateAddress(bdaddr_t addr); + static std::vector<WiimoteDevicePtr> get_devices(); + private: + int m_recvFd; + int m_sendFd; + bdaddr_t m_addr; +}; + From adab729f43ca27bc81280be764b32f11a350308e Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:33:34 +0100 Subject: [PATCH 287/314] UI: Correctly handle unicode paths during save export --- src/gui/TitleManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/TitleManager.cpp b/src/gui/TitleManager.cpp index 00e7992f..4a4f7f56 100644 --- a/src/gui/TitleManager.cpp +++ b/src/gui/TitleManager.cpp @@ -632,7 +632,7 @@ void TitleManager::OnSaveExport(wxCommandEvent& event) const auto persistent_id = (uint32)(uintptr_t)m_save_account_list->GetClientData(selection_index); - wxFileDialog path_dialog(this, _("Select a target file to export the save entry"), entry->path.string(), wxEmptyString, + wxFileDialog path_dialog(this, _("Select a target file to export the save entry"), wxHelper::FromPath(entry->path), wxEmptyString, fmt::format("{}|*.zip", _("Exported save entry (*.zip)")), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (path_dialog.ShowModal() != wxID_OK || path_dialog.GetPath().IsEmpty()) return; From 6aaad1eb83819bcfb9109da2e5e09b1f8d776722 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 15 Dec 2024 21:47:05 +0100 Subject: [PATCH 288/314] Debugger: Added right click context menu to disasm view + small fixes --- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 28 +++++++ src/Cafe/HW/Espresso/Debugger/Debugger.h | 1 + src/gui/debugger/DebuggerWindow2.cpp | 11 ++- src/gui/debugger/DebuggerWindow2.h | 2 + src/gui/debugger/DisasmCtrl.cpp | 86 +++++++++++++++++----- src/gui/debugger/DisasmCtrl.h | 13 ++++ 6 files changed, 121 insertions(+), 20 deletions(-) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index e7369af6..1fed07cd 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -447,6 +447,34 @@ bool debugger_hasPatch(uint32 address) return false; } +void debugger_removePatch(uint32 address) +{ + for (sint32 i = 0; i < debuggerState.patches.size(); i++) + { + auto& patch = debuggerState.patches[i]; + if (address < patch->address || address >= (patch->address + patch->length)) + continue; + MPTR startAddress = patch->address; + MPTR endAddress = patch->address + patch->length; + // remove any breakpoints overlapping with the patch + for (auto& bp : debuggerState.breakpoints) + { + if (bp->address + 4 > startAddress && bp->address < endAddress) + { + bp->enabled = false; + debugger_updateExecutionBreakpoint(bp->address); + } + } + // restore original data + memcpy(MEMPTR<void>(startAddress).GetPtr(), patch->origData.data(), patch->length); + PPCRecompiler_invalidateRange(startAddress, endAddress); + // remove patch + delete patch; + debuggerState.patches.erase(debuggerState.patches.begin() + i); + return; + } +} + void debugger_stepInto(PPCInterpreter_t* hCPU, bool updateDebuggerWindow = true) { bool isRecEnabled = ppcRecompilerEnabled; diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.h b/src/Cafe/HW/Espresso/Debugger/Debugger.h index 717df28a..249c47b8 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.h +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.h @@ -114,6 +114,7 @@ void debugger_updateExecutionBreakpoint(uint32 address, bool forceRestore = fals void debugger_createPatch(uint32 address, std::span<uint8> patchData); bool debugger_hasPatch(uint32 address); +void debugger_removePatch(uint32 address); void debugger_forceBreak(); // force breakpoint at the next possible instruction bool debugger_isTrapped(); diff --git a/src/gui/debugger/DebuggerWindow2.cpp b/src/gui/debugger/DebuggerWindow2.cpp index 969e40bd..9f25cf96 100644 --- a/src/gui/debugger/DebuggerWindow2.cpp +++ b/src/gui/debugger/DebuggerWindow2.cpp @@ -64,6 +64,7 @@ wxBEGIN_EVENT_TABLE(DebuggerWindow2, wxFrame) EVT_COMMAND(wxID_ANY, wxEVT_RUN, DebuggerWindow2::OnRunProgram) EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_LOADED, DebuggerWindow2::OnNotifyModuleLoaded) EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_UNLOADED, DebuggerWindow2::OnNotifyModuleUnloaded) + EVT_COMMAND(wxID_ANY, wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, DebuggerWindow2::OnDisasmCtrlGotoAddress) // file menu EVT_MENU(MENU_ID_FILE_EXIT, DebuggerWindow2::OnExit) // window @@ -383,6 +384,12 @@ void DebuggerWindow2::OnMoveIP(wxCommandEvent& event) m_disasm_ctrl->CenterOffset(ip); } +void DebuggerWindow2::OnDisasmCtrlGotoAddress(wxCommandEvent& event) +{ + uint32 address = static_cast<uint32>(event.GetExtraLong()); + UpdateModuleLabel(address); +} + void DebuggerWindow2::OnParentMove(const wxPoint& main_position, const wxSize& main_size) { m_main_position = main_position; @@ -416,7 +423,7 @@ void DebuggerWindow2::OnNotifyModuleLoaded(wxCommandEvent& event) void DebuggerWindow2::OnNotifyModuleUnloaded(wxCommandEvent& event) { - RPLModule* module = (RPLModule*)event.GetClientData(); + RPLModule* module = (RPLModule*)event.GetClientData(); // todo - the RPL module is already unloaded at this point. Find a better way to handle this SaveModuleStorage(module, true); m_module_window->OnGameLoaded(); m_symbol_window->OnGameLoaded(); @@ -659,7 +666,7 @@ void DebuggerWindow2::CreateMenuBar() void DebuggerWindow2::UpdateModuleLabel(uint32 address) { - if(address == 0) + if (address == 0) address = m_disasm_ctrl->GetViewBaseAddress(); RPLModule* module = RPLLoader_FindModuleByCodeAddr(address); diff --git a/src/gui/debugger/DebuggerWindow2.h b/src/gui/debugger/DebuggerWindow2.h index 0ca44c44..145b5e1d 100644 --- a/src/gui/debugger/DebuggerWindow2.h +++ b/src/gui/debugger/DebuggerWindow2.h @@ -86,6 +86,8 @@ private: void OnMoveIP(wxCommandEvent& event); void OnNotifyModuleLoaded(wxCommandEvent& event); void OnNotifyModuleUnloaded(wxCommandEvent& event); + // events from DisasmCtrl + void OnDisasmCtrlGotoAddress(wxCommandEvent& event); void CreateMenuBar(); void UpdateModuleLabel(uint32 address = 0); diff --git a/src/gui/debugger/DisasmCtrl.cpp b/src/gui/debugger/DisasmCtrl.cpp index c2cd5722..2f38d55e 100644 --- a/src/gui/debugger/DisasmCtrl.cpp +++ b/src/gui/debugger/DisasmCtrl.cpp @@ -15,6 +15,8 @@ #include "Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h" #include <wx/mstream.h> // for wxMemoryInputStream +wxDEFINE_EVENT(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, wxCommandEvent); + #define MAX_SYMBOL_LEN (120) #define COLOR_DEBUG_ACTIVE_BP 0xFFFFA0FF @@ -74,6 +76,8 @@ DisasmCtrl::DisasmCtrl(wxWindow* parent, const wxWindowID& id, const wxPoint& po auto tooltip_sizer = new wxBoxSizer(wxVERTICAL); tooltip_sizer->Add(new wxStaticText(m_tooltip_window, wxID_ANY, wxEmptyString), 0, wxALL, 5); m_tooltip_window->SetSizer(tooltip_sizer); + + Bind(wxEVT_MENU, &DisasmCtrl::OnContextMenuEntryClicked, this, IDContextMenu_ToggleBreakpoint, IDContextMenu_Last); } void DisasmCtrl::Init() @@ -662,29 +666,67 @@ void DisasmCtrl::CopyToClipboard(std::string text) { #endif } +static uint32 GetUnrelocatedAddress(MPTR address) +{ + RPLModule* rplModule = RPLLoader_FindModuleByCodeAddr(address); + if (!rplModule) + return 0; + if (address >= rplModule->regionMappingBase_text.GetMPTR() && address < (rplModule->regionMappingBase_text.GetMPTR() + rplModule->regionSize_text)) + return 0x02000000 + (address - rplModule->regionMappingBase_text.GetMPTR()); + return 0; +} + void DisasmCtrl::OnContextMenu(const wxPoint& position, uint32 line) { - wxPoint pos = position; auto optVirtualAddress = LinePixelPosToAddress(position.y - GetViewStart().y * m_line_height); if (!optVirtualAddress) return; MPTR virtualAddress = *optVirtualAddress; + m_contextMenuAddress = virtualAddress; + // show dialog + wxMenu menu; + menu.Append(IDContextMenu_ToggleBreakpoint, _("Toggle breakpoint")); + if(debugger_hasPatch(virtualAddress)) + menu.Append(IDContextMenu_RestoreOriginalInstructions, _("Restore original instructions")); + menu.AppendSeparator(); + menu.Append(IDContextMenu_CopyAddress, _("Copy address")); + uint32 unrelocatedAddress = GetUnrelocatedAddress(virtualAddress); + if (unrelocatedAddress && unrelocatedAddress != virtualAddress) + menu.Append(IDContextMenu_CopyUnrelocatedAddress, _("Copy virtual address (for IDA/Ghidra)")); + PopupMenu(&menu); +} - // address - if (pos.x <= OFFSET_ADDRESS + OFFSET_ADDRESS_RELATIVE) +void DisasmCtrl::OnContextMenuEntryClicked(wxCommandEvent& event) +{ + switch(event.GetId()) { - CopyToClipboard(fmt::format("{:#10x}", virtualAddress)); - return; - } - else if (pos.x <= OFFSET_ADDRESS + OFFSET_ADDRESS_RELATIVE + OFFSET_DISASSEMBLY) - { - // double-clicked on disassembly (operation and operand data) - return; - } - else - { - // comment - return; + case IDContextMenu_ToggleBreakpoint: + { + debugger_toggleExecuteBreakpoint(m_contextMenuAddress); + wxCommandEvent evt(wxEVT_BREAKPOINT_CHANGE); + wxPostEvent(this->m_parent, evt); + break; + } + case IDContextMenu_RestoreOriginalInstructions: + { + debugger_removePatch(m_contextMenuAddress); + wxCommandEvent evt(wxEVT_BREAKPOINT_CHANGE); // This also refreshes the disassembly view + wxPostEvent(this->m_parent, evt); + break; + } + case IDContextMenu_CopyAddress: + { + CopyToClipboard(fmt::format("{:#10x}", m_contextMenuAddress)); + break; + } + case IDContextMenu_CopyUnrelocatedAddress: + { + uint32 unrelocatedAddress = GetUnrelocatedAddress(m_contextMenuAddress); + CopyToClipboard(fmt::format("{:#10x}", unrelocatedAddress)); + break; + } + default: + UNREACHABLE; } } @@ -722,7 +764,6 @@ std::optional<MPTR> DisasmCtrl::LinePixelPosToAddress(sint32 posY) if (posY < 0) return std::nullopt; - sint32 lineIndex = posY / m_line_height; if (lineIndex >= m_lineToAddress.size()) return std::nullopt; @@ -751,8 +792,6 @@ void DisasmCtrl::CenterOffset(uint32 offset) m_active_line = line; RefreshLine(m_active_line); - - debug_printf("scroll to %x\n", debuggerState.debugSession.instructionPointer); } void DisasmCtrl::GoToAddressDialog() @@ -765,6 +804,10 @@ void DisasmCtrl::GoToAddressDialog() auto value = goto_dialog.GetValue().ToStdString(); std::transform(value.begin(), value.end(), value.begin(), tolower); + // trim any leading spaces + while(!value.empty() && value[0] == ' ') + value.erase(value.begin()); + debugger_addParserSymbols(parser); // try to parse expression as hex value first (it should interpret 1234 as 0x1234, not 1234) @@ -773,17 +816,24 @@ void DisasmCtrl::GoToAddressDialog() const auto result = (uint32)parser.Evaluate("0x"+value); m_lastGotoTarget = result; CenterOffset(result); + wxCommandEvent evt(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS); + evt.SetExtraLong(static_cast<long>(result)); + wxPostEvent(GetParent(), evt); } else if (parser.IsConstantExpression(value)) { const auto result = (uint32)parser.Evaluate(value); m_lastGotoTarget = result; CenterOffset(result); + wxCommandEvent evt(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS); + evt.SetExtraLong(static_cast<long>(result)); + wxPostEvent(GetParent(), evt); } else { try { + // if not a constant expression (i.e. relying on unknown variables), then evaluating will throw an exception with a detailed error message const auto _ = (uint32)parser.Evaluate(value); } catch (const std::exception& ex) diff --git a/src/gui/debugger/DisasmCtrl.h b/src/gui/debugger/DisasmCtrl.h index 993d5697..5a67e49a 100644 --- a/src/gui/debugger/DisasmCtrl.h +++ b/src/gui/debugger/DisasmCtrl.h @@ -1,9 +1,20 @@ #pragma once #include "gui/components/TextList.h" +wxDECLARE_EVENT(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, wxCommandEvent); // Notify parent that goto address operation completed. Event contains the address that was jumped to. + class DisasmCtrl : public TextList { + enum + { + IDContextMenu_ToggleBreakpoint = wxID_HIGHEST + 1, + IDContextMenu_RestoreOriginalInstructions, + IDContextMenu_CopyAddress, + IDContextMenu_CopyUnrelocatedAddress, + IDContextMenu_Last + }; public: + DisasmCtrl(wxWindow* parent, const wxWindowID& id, const wxPoint& pos, const wxSize& size, long style); void Init(); @@ -26,6 +37,7 @@ protected: void OnKeyPressed(sint32 key_code, const wxPoint& position) override; void OnMouseDClick(const wxPoint& position, uint32 line) override; void OnContextMenu(const wxPoint& position, uint32 line) override; + void OnContextMenuEntryClicked(wxCommandEvent& event); bool OnShowTooltip(const wxPoint& position, uint32 line) override; void ScrollWindow(int dx, int dy, const wxRect* prect) override; @@ -40,6 +52,7 @@ private: sint32 m_mouse_line, m_mouse_line_drawn; sint32 m_active_line; uint32 m_lastGotoTarget{}; + uint32 m_contextMenuAddress{}; // code region info uint32 currentCodeRegionStart; uint32 currentCodeRegionEnd; From b53b223ba9b45974cd80674d8de9c6e736e34ae9 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Mon, 16 Dec 2024 02:38:43 +0100 Subject: [PATCH 289/314] Vulkan: Use cache for sampler objects --- .../HW/Latte/Core/LattePerformanceMonitor.h | 1 + src/Cafe/HW/Latte/Renderer/Vulkan/VKRBase.h | 48 ++++++-- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 110 +++++++++++++++++- .../Renderer/Vulkan/VulkanRendererCore.cpp | 8 +- 4 files changed, 152 insertions(+), 15 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h index 713e094e..ac75bb1b 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h @@ -124,6 +124,7 @@ typedef struct LattePerfStatCounter numGraphicPipelines; LattePerfStatCounter numImages; LattePerfStatCounter numImageViews; + LattePerfStatCounter numSamplers; LattePerfStatCounter numRenderPass; LattePerfStatCounter numFramebuffer; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRBase.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRBase.h index f79bd2dc..9c7e03f3 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRBase.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRBase.h @@ -19,7 +19,7 @@ public: virtual ~VKRMoveableRefCounter() { - cemu_assert_debug(refCount == 0); + cemu_assert_debug(m_refCount == 0); // remove references #ifdef CEMU_DEBUG_ASSERT @@ -30,7 +30,11 @@ public: } #endif for (auto itr : refs) - itr->ref->refCount--; + { + itr->ref->m_refCount--; + if (itr->ref->m_refCount == 0) + itr->ref->RefCountReachedZero(); + } refs.clear(); delete selfRef; selfRef = nullptr; @@ -41,8 +45,8 @@ public: VKRMoveableRefCounter(VKRMoveableRefCounter&& rhs) noexcept { this->refs = std::move(rhs.refs); - this->refCount = rhs.refCount; - rhs.refCount = 0; + this->m_refCount = rhs.m_refCount; + rhs.m_refCount = 0; this->selfRef = rhs.selfRef; rhs.selfRef = nullptr; this->selfRef->ref = this; @@ -57,7 +61,7 @@ public: void addRef(VKRMoveableRefCounter* refTarget) { this->refs.emplace_back(refTarget->selfRef); - refTarget->refCount++; + refTarget->m_refCount++; #ifdef CEMU_DEBUG_ASSERT // add reverse ref @@ -68,16 +72,23 @@ public: // methods to directly increment/decrement ref counter (for situations where no external object is available) void incRef() { - this->refCount++; + m_refCount++; } void decRef() { - this->refCount--; + m_refCount--; + if (m_refCount == 0) + RefCountReachedZero(); } protected: - int refCount{}; + virtual void RefCountReachedZero() + { + // does nothing by default + } + + int m_refCount{}; private: VKRMoveableRefCounterRef* selfRef; std::vector<VKRMoveableRefCounterRef*> refs; @@ -88,7 +99,7 @@ private: void moveObj(VKRMoveableRefCounter&& rhs) { this->refs = std::move(rhs.refs); - this->refCount = rhs.refCount; + this->m_refCount = rhs.m_refCount; this->selfRef = rhs.selfRef; this->selfRef->ref = this; } @@ -131,6 +142,25 @@ public: VkSampler m_textureDefaultSampler[2] = { VK_NULL_HANDLE, VK_NULL_HANDLE }; // relict from LatteTextureViewVk, get rid of it eventually }; + +class VKRObjectSampler : public VKRDestructibleObject +{ + public: + VKRObjectSampler(VkSamplerCreateInfo* samplerInfo); + ~VKRObjectSampler() override; + + static VKRObjectSampler* GetOrCreateSampler(VkSamplerCreateInfo* samplerInfo); + static void DestroyCache(); + + void RefCountReachedZero() override; // sampler objects are destroyed when not referenced anymore + + VkSampler GetSampler() const { return m_sampler; } + private: + static std::unordered_map<uint64, VKRObjectSampler*> s_samplerCache; + VkSampler m_sampler{ VK_NULL_HANDLE }; + uint64 m_hash; +}; + class VKRObjectRenderPass : public VKRDestructibleObject { public: diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 37432eeb..eae6daf2 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -672,6 +672,8 @@ VulkanRenderer::~VulkanRenderer() if (m_commandPool != VK_NULL_HANDLE) vkDestroyCommandPool(m_logicalDevice, m_commandPool, nullptr); + VKRObjectSampler::DestroyCache(); + // destroy debug callback if (m_debugCallback) { @@ -3707,6 +3709,7 @@ void VulkanRenderer::AppendOverlayDebugInfo() ImGui::Text("DS StorageBuf %u", performanceMonitor.vk.numDescriptorStorageBuffers.get()); ImGui::Text("Images %u", performanceMonitor.vk.numImages.get()); ImGui::Text("ImageView %u", performanceMonitor.vk.numImageViews.get()); + ImGui::Text("ImageSampler %u", performanceMonitor.vk.numSamplers.get()); ImGui::Text("RenderPass %u", performanceMonitor.vk.numRenderPass.get()); ImGui::Text("Framebuffer %u", performanceMonitor.vk.numFramebuffer.get()); m_spinlockDestructionQueue.lock(); @@ -3752,7 +3755,7 @@ void VKRDestructibleObject::flagForCurrentCommandBuffer() bool VKRDestructibleObject::canDestroy() { - if (refCount > 0) + if (m_refCount > 0) return false; return VulkanRenderer::GetInstance()->HasCommandBufferFinished(m_lastCmdBufferId); } @@ -3793,6 +3796,111 @@ VKRObjectTextureView::~VKRObjectTextureView() performanceMonitor.vk.numImageViews.decrement(); } +static uint64 CalcHashSamplerCreateInfo(const VkSamplerCreateInfo& info) +{ + uint64 h = 0xcbf29ce484222325ULL; + auto fnvHashCombine = [](uint64_t &h, auto val) { + using T = decltype(val); + static_assert(sizeof(T) <= 8); + uint64_t val64 = 0; + std::memcpy(&val64, &val, sizeof(val)); + h ^= val64; + h *= 0x100000001b3ULL; + }; + cemu_assert_debug(info.sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); + fnvHashCombine(h, info.flags); + fnvHashCombine(h, info.magFilter); + fnvHashCombine(h, info.minFilter); + fnvHashCombine(h, info.mipmapMode); + fnvHashCombine(h, info.addressModeU); + fnvHashCombine(h, info.addressModeV); + fnvHashCombine(h, info.addressModeW); + fnvHashCombine(h, info.mipLodBias); + fnvHashCombine(h, info.anisotropyEnable); + if(info.anisotropyEnable == VK_TRUE) + fnvHashCombine(h, info.maxAnisotropy); + fnvHashCombine(h, info.compareEnable); + if(info.compareEnable == VK_TRUE) + fnvHashCombine(h, info.compareOp); + fnvHashCombine(h, info.minLod); + fnvHashCombine(h, info.maxLod); + fnvHashCombine(h, info.borderColor); + fnvHashCombine(h, info.unnormalizedCoordinates); + // handle custom border color + VkBaseOutStructure* ext = (VkBaseOutStructure*)info.pNext; + while(ext) + { + if(ext->sType == VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT) + { + auto* extInfo = (VkSamplerCustomBorderColorCreateInfoEXT*)ext; + fnvHashCombine(h, extInfo->customBorderColor.uint32[0]); + fnvHashCombine(h, extInfo->customBorderColor.uint32[1]); + fnvHashCombine(h, extInfo->customBorderColor.uint32[2]); + fnvHashCombine(h, extInfo->customBorderColor.uint32[3]); + } + else + { + cemu_assert_unimplemented(); + } + ext = ext->pNext; + } + return h; +} + +std::unordered_map<uint64, VKRObjectSampler*> VKRObjectSampler::s_samplerCache; + +VKRObjectSampler::VKRObjectSampler(VkSamplerCreateInfo* samplerInfo) +{ + auto* vulkanRenderer = VulkanRenderer::GetInstance(); + if (vkCreateSampler(vulkanRenderer->GetLogicalDevice(), samplerInfo, nullptr, &m_sampler) != VK_SUCCESS) + vulkanRenderer->UnrecoverableError("Failed to create texture sampler"); + performanceMonitor.vk.numSamplers.increment(); + m_hash = CalcHashSamplerCreateInfo(*samplerInfo); +} + +VKRObjectSampler::~VKRObjectSampler() +{ + vkDestroySampler(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_sampler, nullptr); + performanceMonitor.vk.numSamplers.decrement(); + // remove from cache + auto it = s_samplerCache.find(m_hash); + if(it != s_samplerCache.end()) + s_samplerCache.erase(it); +} + +void VKRObjectSampler::RefCountReachedZero() +{ + VulkanRenderer::GetInstance()->ReleaseDestructibleObject(this); +} + +VKRObjectSampler* VKRObjectSampler::GetOrCreateSampler(VkSamplerCreateInfo* samplerInfo) +{ + auto* vulkanRenderer = VulkanRenderer::GetInstance(); + uint64 hash = CalcHashSamplerCreateInfo(*samplerInfo); + auto it = s_samplerCache.find(hash); + if (it != s_samplerCache.end()) + { + auto* sampler = it->second; + return sampler; + } + auto* sampler = new VKRObjectSampler(samplerInfo); + s_samplerCache[hash] = sampler; + return sampler; +} + +void VKRObjectSampler::DestroyCache() +{ + // assuming all other objects which depend on vkSampler are destroyed, this cache should also have been emptied already + // but just to be sure lets still clear the cache + cemu_assert_debug(s_samplerCache.empty()); + for(auto& sampler : s_samplerCache) + { + cemu_assert_debug(sampler.second->m_refCount == 0); + delete sampler.second; + } + s_samplerCache.clear(); +} + VKRObjectRenderPass::VKRObjectRenderPass(AttachmentInfo_t& attachmentInfo, sint32 colorAttachmentCount) { // generate helper hash for pipeline state diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 3a684072..dd39bd88 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -727,7 +727,6 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo* VkSamplerCustomBorderColorCreateInfoEXT samplerCustomBorderColor{}; - VkSampler sampler; VkSamplerCreateInfo samplerInfo{}; samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; @@ -899,10 +898,9 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo* } } } - - if (vkCreateSampler(m_logicalDevice, &samplerInfo, nullptr, &sampler) != VK_SUCCESS) - UnrecoverableError("Failed to create texture sampler"); - info.sampler = sampler; + VKRObjectSampler* samplerObj = VKRObjectSampler::GetOrCreateSampler(&samplerInfo); + vkObjDS->addRef(samplerObj); + info.sampler = samplerObj->GetSampler(); textureArray.emplace_back(info); } From 3738ccd2e676aa2c2cf2cdd5f08d5ac8dd221f57 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:55:23 +0100 Subject: [PATCH 290/314] Play bootSound.btsnd while shaders/pipelines are compiling (#1047) --- src/Cafe/HW/Latte/Core/LatteShaderCache.cpp | 122 +++++++++++++++++++- src/Cafe/OS/libs/snd_core/ax_out.cpp | 79 ++----------- src/audio/CubebAPI.cpp | 2 +- src/audio/DirectSoundAPI.cpp | 2 +- src/audio/IAudioAPI.cpp | 42 +++++++ src/audio/IAudioAPI.h | 9 +- src/audio/XAudio27API.cpp | 17 ++- src/audio/XAudio27API.h | 2 + src/audio/XAudio2API.cpp | 13 ++- src/audio/XAudio2API.h | 2 + src/config/CemuConfig.cpp | 2 + src/config/CemuConfig.h | 16 ++- src/gui/GeneralSettings2.cpp | 56 ++------- src/gui/GeneralSettings2.h | 1 + src/util/CMakeLists.txt | 2 + src/util/bootSound/BootSoundReader.cpp | 51 ++++++++ src/util/bootSound/BootSoundReader.h | 20 ++++ 17 files changed, 310 insertions(+), 128 deletions(-) create mode 100644 src/util/bootSound/BootSoundReader.cpp create mode 100644 src/util/bootSound/BootSoundReader.h diff --git a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp index 9576eb2e..9b24de45 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp @@ -25,6 +25,9 @@ #include "util/helpers/Serializer.h" #include <wx/msgdlg.h> +#include <audio/IAudioAPI.h> +#include <util/bootSound/BootSoundReader.h> +#include <thread> #if BOOST_OS_WINDOWS #include <psapi.h> @@ -155,6 +158,118 @@ bool LoadTGAFile(const std::vector<uint8>& buffer, TGAFILE *tgaFile) return true; } +class BootSoundPlayer +{ + public: + BootSoundPlayer() = default; + ~BootSoundPlayer() + { + m_stopRequested = true; + } + + void StartSound() + { + if (!m_bootSndPlayThread.joinable()) + { + m_fadeOutRequested = false; + m_stopRequested = false; + m_bootSndPlayThread = std::thread{[this]() { + StreamBootSound(); + }}; + } + } + + void FadeOutSound() + { + m_fadeOutRequested = true; + } + + void ApplyFadeOutEffect(std::span<sint16> samples, uint64& fadeOutSample, uint64 fadeOutDuration) + { + for (size_t i = 0; i < samples.size(); i += 2) + { + const float decibel = (float)fadeOutSample / fadeOutDuration * -60.0f; + const float volumeFactor = pow(10, decibel / 20); + samples[i] *= volumeFactor; + samples[i + 1] *= volumeFactor; + fadeOutSample++; + } + } + + void StreamBootSound() + { + SetThreadName("bootsnd"); + constexpr sint32 sampleRate = 48'000; + constexpr sint32 bitsPerSample = 16; + constexpr sint32 samplesPerBlock = sampleRate / 10; // block is 1/10th of a second + constexpr sint32 nChannels = 2; + static_assert(bitsPerSample % 8 == 0, "bits per sample is not a multiple of 8"); + + AudioAPIPtr bootSndAudioDev; + + try + { + bootSndAudioDev = IAudioAPI::CreateDeviceFromConfig(true, sampleRate, nChannels, samplesPerBlock, bitsPerSample); + if(!bootSndAudioDev) + return; + } + catch (const std::runtime_error& ex) + { + cemuLog_log(LogType::Force, "Failed to initialise audio device for bootup sound"); + return; + } + bootSndAudioDev->SetAudioDelayOverride(4); + bootSndAudioDev->Play(); + + std::string sndPath = fmt::format("{}/meta/{}", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()), "bootSound.btsnd"); + sint32 fscStatus = FSC_STATUS_UNDEFINED; + + if(!fsc_doesFileExist(sndPath.c_str())) + return; + + FSCVirtualFile* bootSndFileHandle = fsc_open(sndPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus); + if(!bootSndFileHandle) + { + cemuLog_log(LogType::Force, "failed to open bootSound.btsnd"); + return; + } + + constexpr sint32 audioBlockSize = samplesPerBlock * (bitsPerSample/8) * nChannels; + BootSoundReader bootSndFileReader(bootSndFileHandle, audioBlockSize); + + uint64 fadeOutSample = 0; // track how far into the fadeout + constexpr uint64 fadeOutDuration = sampleRate * 2; // fadeout should last 2 seconds + while(fadeOutSample < fadeOutDuration && !m_stopRequested) + { + while (bootSndAudioDev->NeedAdditionalBlocks()) + { + sint16* data = bootSndFileReader.getSamples(); + if(data == nullptr) + { + // break outer loop + m_stopRequested = true; + break; + } + if(m_fadeOutRequested) + ApplyFadeOutEffect({data, samplesPerBlock * nChannels}, fadeOutSample, fadeOutDuration); + + bootSndAudioDev->FeedBlock(data); + } + // sleep for the duration of a single block + std::this_thread::sleep_for(std::chrono::milliseconds(samplesPerBlock / (sampleRate/ 1'000))); + } + + if(bootSndFileHandle) + fsc_close(bootSndFileHandle); + } + + private: + std::thread m_bootSndPlayThread; + std::atomic_bool m_fadeOutRequested = false; + std::atomic_bool m_stopRequested = false; +}; +static BootSoundPlayer g_bootSndPlayer; + void LatteShaderCache_finish() { if (g_renderer->GetType() == RendererAPI::Vulkan) @@ -299,6 +414,9 @@ void LatteShaderCache_Load() loadBackgroundTexture(true, g_shaderCacheLoaderState.textureTVId); loadBackgroundTexture(false, g_shaderCacheLoaderState.textureDRCId); + if(GetConfig().play_boot_sound) + g_bootSndPlayer.StartSound(); + sint32 numLoadedShaders = 0; uint32 loadIndex = 0; @@ -365,6 +483,8 @@ void LatteShaderCache_Load() g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureTVId); if (g_shaderCacheLoaderState.textureDRCId) g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureDRCId); + + g_bootSndPlayer.FadeOutSound(); } void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateFunc, bool isPipelines) @@ -805,4 +925,4 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path fs::remove(pathGenericPre1_25_0, ec); } } -} +} \ No newline at end of file diff --git a/src/Cafe/OS/libs/snd_core/ax_out.cpp b/src/Cafe/OS/libs/snd_core/ax_out.cpp index 40b9c643..a88807f2 100644 --- a/src/Cafe/OS/libs/snd_core/ax_out.cpp +++ b/src/Cafe/OS/libs/snd_core/ax_out.cpp @@ -396,90 +396,35 @@ namespace snd_core void AXOut_init() { - auto& config = GetConfig(); - const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api; numQueuedFramesSndGeneric = 0; std::unique_lock lock(g_audioMutex); if (!g_tvAudio) { - sint32 channels; - switch (config.tv_channels) + try { - case 0: - channels = 1; // will mix mono sound on both output channels - break; - case 2: - channels = 6; - break; - default: // stereo - channels = 2; - break; + g_tvAudio = IAudioAPI::CreateDeviceFromConfig(true, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16); } - - IAudioAPI::DeviceDescriptionPtr device_description; - if (IAudioAPI::IsAudioAPIAvailable(audio_api)) + catch (std::runtime_error& ex) { - auto devices = IAudioAPI::GetDevices(audio_api); - const auto it = std::find_if(devices.begin(), devices.end(), [&config](const auto& d) {return d->GetIdentifier() == config.tv_device; }); - if (it != devices.end()) - device_description = *it; - } - - if (device_description) - { - try - { - g_tvAudio = IAudioAPI::CreateDevice((IAudioAPI::AudioAPI)config.audio_api, device_description, 48000, channels, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16); - g_tvAudio->SetVolume(config.tv_volume); - } - catch (std::runtime_error& ex) - { - cemuLog_log(LogType::Force, "can't initialize tv audio: {}", ex.what()); - exit(0); - } + cemuLog_log(LogType::Force, "can't initialize tv audio: {}", ex.what()); + exit(0); } } if (!g_padAudio) { - sint32 channels; - switch (config.pad_channels) + try { - case 0: - channels = 1; // will mix mono sound on both output channels - break; - case 2: - channels = 6; - break; - default: // stereo - channels = 2; - break; + g_padAudio = IAudioAPI::CreateDeviceFromConfig(false, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16); + if(g_padAudio) + g_padVolume = g_padAudio->GetVolume(); } - - IAudioAPI::DeviceDescriptionPtr device_description; - if (IAudioAPI::IsAudioAPIAvailable(audio_api)) + catch (std::runtime_error& ex) { - auto devices = IAudioAPI::GetDevices(audio_api); - const auto it = std::find_if(devices.begin(), devices.end(), [&config](const auto& d) {return d->GetIdentifier() == config.pad_device; }); - if (it != devices.end()) - device_description = *it; - } - - if (device_description) - { - try - { - g_padAudio = IAudioAPI::CreateDevice((IAudioAPI::AudioAPI)config.audio_api, device_description, 48000, channels, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16); - g_padAudio->SetVolume(config.pad_volume); - g_padVolume = config.pad_volume; - } - catch (std::runtime_error& ex) - { - cemuLog_log(LogType::Force, "can't initialize pad audio: {}", ex.what()); - exit(0); - } + cemuLog_log(LogType::Force, "can't initialize pad audio: {}", ex.what()); + exit(0); } } } diff --git a/src/audio/CubebAPI.cpp b/src/audio/CubebAPI.cpp index 2b4aec41..f98fa601 100644 --- a/src/audio/CubebAPI.cpp +++ b/src/audio/CubebAPI.cpp @@ -114,7 +114,7 @@ CubebAPI::~CubebAPI() bool CubebAPI::NeedAdditionalBlocks() const { std::shared_lock lock(m_mutex); - return m_buffer.size() < s_audioDelay * m_bytesPerBlock; + return m_buffer.size() < GetAudioDelay() * m_bytesPerBlock; } bool CubebAPI::FeedBlock(sint16* data) diff --git a/src/audio/DirectSoundAPI.cpp b/src/audio/DirectSoundAPI.cpp index 8c2f7245..eabd3a7e 100644 --- a/src/audio/DirectSoundAPI.cpp +++ b/src/audio/DirectSoundAPI.cpp @@ -210,7 +210,7 @@ void DirectSoundAPI::SetVolume(sint32 volume) bool DirectSoundAPI::NeedAdditionalBlocks() const { std::shared_lock lock(m_mutex); - return m_buffer.size() < s_audioDelay; + return m_buffer.size() < GetAudioDelay(); } std::vector<DirectSoundAPI::DeviceDescriptionPtr> DirectSoundAPI::GetDevices() diff --git a/src/audio/IAudioAPI.cpp b/src/audio/IAudioAPI.cpp index d078900b..587526ab 100644 --- a/src/audio/IAudioAPI.cpp +++ b/src/audio/IAudioAPI.cpp @@ -97,7 +97,40 @@ bool IAudioAPI::IsAudioAPIAvailable(AudioAPI api) return false; } +AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(bool TV, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample) +{ + auto& config = GetConfig(); + sint32 channels = CemuConfig::AudioChannelsToNChannels(TV ? config.tv_channels : config.pad_channels); + return CreateDeviceFromConfig(TV, rate, channels, samples_per_block, bits_per_sample); +} +AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(bool TV, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample) +{ + AudioAPIPtr audioAPIDev; + + auto& config = GetConfig(); + + const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api; + auto& selectedDevice = TV ? config.tv_device : config.pad_device; + + if(selectedDevice.empty()) + return {}; + + IAudioAPI::DeviceDescriptionPtr device_description; + if (IAudioAPI::IsAudioAPIAvailable(audio_api)) + { + auto devices = IAudioAPI::GetDevices(audio_api); + const auto it = std::find_if(devices.begin(), devices.end(), [&selectedDevice](const auto& d) {return d->GetIdentifier() == selectedDevice; }); + if (it != devices.end()) + device_description = *it; + } + if (!device_description) + throw std::runtime_error("failed to find selected device while trying to create audio device"); + + audioAPIDev = CreateDevice(audio_api, device_description, rate, channels, samples_per_block, bits_per_sample); + audioAPIDev->SetVolume(TV ? config.tv_volume : config.pad_volume); + return audioAPIDev; +} AudioAPIPtr IAudioAPI::CreateDevice(AudioAPI api, const DeviceDescriptionPtr& device, sint32 samplerate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample) { @@ -167,3 +200,12 @@ std::vector<IAudioAPI::DeviceDescriptionPtr> IAudioAPI::GetDevices(AudioAPI api) } } +void IAudioAPI::SetAudioDelayOverride(uint32 delay) +{ + m_audioDelayOverride = delay; +} + +uint32 IAudioAPI::GetAudioDelay() const +{ + return m_audioDelayOverride > 0 ? m_audioDelayOverride : s_audioDelay; +} diff --git a/src/audio/IAudioAPI.h b/src/audio/IAudioAPI.h index 935e3024..8fb510db 100644 --- a/src/audio/IAudioAPI.h +++ b/src/audio/IAudioAPI.h @@ -55,11 +55,15 @@ public: virtual bool FeedBlock(sint16* data) = 0; virtual bool Play() = 0; virtual bool Stop() = 0; + void SetAudioDelayOverride(uint32 delay); + uint32 GetAudioDelay() const; static void PrintLogging(); static void InitializeStatic(); static bool IsAudioAPIAvailable(AudioAPI api); - + + static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(bool TV, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample); + static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(bool TV, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample); static std::unique_ptr<IAudioAPI> CreateDevice(AudioAPI api, const DeviceDescriptionPtr& device, sint32 samplerate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample); static std::vector<DeviceDescriptionPtr> GetDevices(AudioAPI api); @@ -75,9 +79,10 @@ protected: bool m_playing = false; static std::array<bool, AudioAPIEnd> s_availableApis; - static uint32 s_audioDelay; + uint32 m_audioDelayOverride = 0; private: + static uint32 s_audioDelay; void InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample); }; diff --git a/src/audio/XAudio27API.cpp b/src/audio/XAudio27API.cpp index 9901b29b..cfb21c67 100644 --- a/src/audio/XAudio27API.cpp +++ b/src/audio/XAudio27API.cpp @@ -33,8 +33,8 @@ XAudio27API::XAudio27API(uint32 device_id, uint32 samplerate, uint32 channels, u m_wfx.Format.nChannels = channels; m_wfx.Format.nSamplesPerSec = samplerate; m_wfx.Format.wBitsPerSample = bits_per_sample; - m_wfx.Format.nBlockAlign = (m_wfx.Format.nChannels * m_wfx.Format.wBitsPerSample) / 8; // must equal (nChannels × wBitsPerSample) / 8 - m_wfx.Format.nAvgBytesPerSec = m_wfx.Format.nSamplesPerSec * m_wfx.Format.nBlockAlign; // must equal nSamplesPerSec × nBlockAlign. + m_wfx.Format.nBlockAlign = (m_wfx.Format.nChannels * m_wfx.Format.wBitsPerSample) / 8; // must equal (nChannels × wBitsPerSample) / 8 + m_wfx.Format.nAvgBytesPerSec = m_wfx.Format.nSamplesPerSec * m_wfx.Format.nBlockAlign; // must equal nSamplesPerSec × nBlockAlign. m_wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); m_wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; @@ -199,9 +199,7 @@ bool XAudio27API::FeedBlock(sint16* data) // check if we queued too many blocks if(m_blocks_queued >= kBlockCount) { - XAUDIO2_VOICE_STATE state{}; - m_source_voice->GetState(&state); - m_blocks_queued = state.BuffersQueued; + m_blocks_queued = GetQueuedBuffers(); if (m_blocks_queued >= kBlockCount) { @@ -222,7 +220,14 @@ bool XAudio27API::FeedBlock(sint16* data) return true; } +uint32 XAudio27API::GetQueuedBuffers() const +{ + XAUDIO2_VOICE_STATE state{}; + m_source_voice->GetState(&state); + return state.BuffersQueued; +} + bool XAudio27API::NeedAdditionalBlocks() const { - return m_blocks_queued < s_audioDelay; + return GetQueuedBuffers() < GetAudioDelay(); } diff --git a/src/audio/XAudio27API.h b/src/audio/XAudio27API.h index badab8f6..4288dcc7 100644 --- a/src/audio/XAudio27API.h +++ b/src/audio/XAudio27API.h @@ -47,6 +47,8 @@ public: static std::vector<DeviceDescriptionPtr> GetDevices(); private: + uint32 GetQueuedBuffers() const; + struct XAudioDeleter { void operator()(IXAudio2* ptr) const; diff --git a/src/audio/XAudio2API.cpp b/src/audio/XAudio2API.cpp index 512bcccd..c92fd451 100644 --- a/src/audio/XAudio2API.cpp +++ b/src/audio/XAudio2API.cpp @@ -270,9 +270,7 @@ bool XAudio2API::FeedBlock(sint16* data) // check if we queued too many blocks if (m_blocks_queued >= kBlockCount) { - XAUDIO2_VOICE_STATE state{}; - m_source_voice->GetState(&state); - m_blocks_queued = state.BuffersQueued; + m_blocks_queued = GetQueuedBuffers(); if (m_blocks_queued >= kBlockCount) { @@ -293,7 +291,14 @@ bool XAudio2API::FeedBlock(sint16* data) return true; } +uint32 XAudio2API::GetQueuedBuffers() const +{ + XAUDIO2_VOICE_STATE state{}; + m_source_voice->GetState(&state); + return state.BuffersQueued; +} + bool XAudio2API::NeedAdditionalBlocks() const { - return m_blocks_queued < s_audioDelay; + return GetQueuedBuffers() < GetAudioDelay(); } diff --git a/src/audio/XAudio2API.h b/src/audio/XAudio2API.h index 1f7057f0..b5bb0296 100644 --- a/src/audio/XAudio2API.h +++ b/src/audio/XAudio2API.h @@ -46,6 +46,8 @@ public: static const std::vector<DeviceDescriptionPtr>& GetDevices() { return s_devices; } private: + uint32 GetQueuedBuffers() const; + static const std::vector<DeviceDescriptionPtr>& RefreshDevices(); struct XAudioDeleter diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 26f420a5..6bb7ac34 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -46,6 +46,7 @@ void CemuConfig::Load(XMLConfigParser& parser) fullscreen = parser.get("fullscreen", fullscreen); proxy_server = parser.get("proxy_server", ""); disable_screensaver = parser.get("disable_screensaver", disable_screensaver); + play_boot_sound = parser.get("play_boot_sound", play_boot_sound); console_language = parser.get("console_language", console_language.GetInitValue()); window_position.x = parser.get("window_position").get("x", -1); @@ -370,6 +371,7 @@ void CemuConfig::Save(XMLConfigParser& parser) config.set<bool>("fullscreen", fullscreen); config.set("proxy_server", proxy_server.GetValue().c_str()); config.set<bool>("disable_screensaver", disable_screensaver); + config.set<bool>("play_boot_sound", play_boot_sound); // config.set("cpu_mode", cpu_mode.GetValue()); //config.set("console_region", console_region.GetValue()); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index be131266..191614a2 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -380,6 +380,7 @@ struct CemuConfig #endif ConfigValue<bool> disable_screensaver{DISABLE_SCREENSAVER_DEFAULT}; #undef DISABLE_SCREENSAVER_DEFAULT + ConfigValue<bool> play_boot_sound{false}; std::vector<std::string> game_paths; std::mutex game_cache_entries_mutex; @@ -524,7 +525,20 @@ struct CemuConfig ConfigValue<bool> emulate_dimensions_toypad{false}; }emulated_usb_devices{}; - private: + static int AudioChannelsToNChannels(AudioChannels kStereo) + { + switch (kStereo) + { + case 0: + return 1; // will mix mono sound on both output channels + case 2: + return 6; + default: // stereo + return 2; + } + } + + private: GameEntry* GetGameEntryByTitleId(uint64 titleId); GameEntry* CreateGameEntry(uint64 titleId); }; diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index eaada7cb..9b763229 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -207,8 +207,10 @@ wxPanel* GeneralSettings2::AddGeneralPage(wxNotebook* notebook) #if BOOST_OS_MACOS m_disable_screensaver->Enable(false); #endif - - // InsertEmptyRow(); + m_play_boot_sound = new wxCheckBox(box, wxID_ANY, _("Enable intro sound")); + m_play_boot_sound->SetToolTip(_("Play bootSound file while compiling shaders/pipelines.")); + second_row->Add(m_play_boot_sound, 0, botflag, 5); + CountRowElement(); m_auto_update = new wxCheckBox(box, wxID_ANY, _("Automatically check for updates")); m_auto_update->SetToolTip(_("Automatically checks for new cemu versions on startup")); @@ -936,13 +938,15 @@ void GeneralSettings2::StoreConfig() #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) config.feral_gamemode = m_feral_gamemode->IsChecked(); #endif + config.play_boot_sound = m_play_boot_sound->IsChecked(); config.disable_screensaver = m_disable_screensaver->IsChecked(); // Toggle while a game is running if (CafeSystem::IsTitleRunning()) { ScreenSaver::SetInhibit(config.disable_screensaver); } - + + // -1 is default wx widget value -> set to dummy 0 so mainwindow and padwindow will update it config.window_position = m_save_window_position_size->IsChecked() ? Vector2i{ 0,0 } : Vector2i{-1,-1}; config.window_size = m_save_window_position_size->IsChecked() ? Vector2i{ 0,0 } : Vector2i{-1,-1}; @@ -1574,6 +1578,7 @@ void GeneralSettings2::ApplyConfig() m_save_screenshot->SetValue(config.save_screenshot); m_disable_screensaver->SetValue(config.disable_screensaver); + m_play_boot_sound->SetValue(config.play_boot_sound); #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) m_feral_gamemode->SetValue(config.feral_gamemode); #endif @@ -1776,20 +1781,7 @@ void GeneralSettings2::UpdateAudioDevice() if (m_game_launched && g_tvAudio) channels = g_tvAudio->GetChannels(); else - { - switch (config.tv_channels) - { - case 0: - channels = 1; - break; - case 2: - channels = 6; - break; - default: // stereo - channels = 2; - break; - } - } + channels = CemuConfig::AudioChannelsToNChannels(config.tv_channels); try { @@ -1824,20 +1816,7 @@ void GeneralSettings2::UpdateAudioDevice() if (m_game_launched && g_padAudio) channels = g_padAudio->GetChannels(); else - { - switch (config.pad_channels) - { - case 0: - channels = 1; - break; - case 2: - channels = 6; - break; - default: // stereo - channels = 2; - break; - } - } + channels = CemuConfig::AudioChannelsToNChannels(config.pad_channels); try { @@ -1873,20 +1852,7 @@ void GeneralSettings2::UpdateAudioDevice() if (m_game_launched && g_inputAudio) channels = g_inputAudio->GetChannels(); else - { - switch (config.input_channels) - { - case 0: - channels = 1; - break; - case 2: - channels = 6; - break; - default: // stereo - channels = 2; - break; - } - } + channels = CemuConfig::AudioChannelsToNChannels(config.input_channels); try { diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index b1ab01e8..7fbfecc1 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -43,6 +43,7 @@ private: wxCheckBox* m_discord_presence, *m_fullscreen_menubar; wxCheckBox* m_auto_update, *m_receive_untested_releases, *m_save_screenshot; wxCheckBox* m_disable_screensaver; + wxCheckBox* m_play_boot_sound; #if BOOST_OS_LINUX && defined(ENABLE_FERAL_GAMEMODE) wxCheckBox* m_feral_gamemode; #endif diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 5ac5ebfd..881b20b6 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(CemuUtil boost/bluetooth.h + bootSound/BootSoundReader.cpp + bootSound/BootSoundReader.h ChunkedHeap/ChunkedHeap.h containers/flat_hash_map.hpp containers/IntervalBucketContainer.h diff --git a/src/util/bootSound/BootSoundReader.cpp b/src/util/bootSound/BootSoundReader.cpp new file mode 100644 index 00000000..f6b00615 --- /dev/null +++ b/src/util/bootSound/BootSoundReader.cpp @@ -0,0 +1,51 @@ +#include "BootSoundReader.h" +#include "Cafe/CafeSystem.h" + +BootSoundReader::BootSoundReader(FSCVirtualFile* bootsndFile, sint32 blockSize) : bootsndFile(bootsndFile), blockSize(blockSize) +{ + // crash if this constructor is invoked with a blockSize that has a different number of samples per channel + cemu_assert(blockSize % (sizeof(sint16be) * 2) == 0); + + fsc_setFileSeek(bootsndFile, 0); + fsc_readFile(bootsndFile, &muteBits, 4); + fsc_readFile(bootsndFile, &loopPoint, 4); + + buffer.resize(blockSize / sizeof(sint16)); + bufferBE.resize(blockSize / sizeof(sint16be)); + + // workaround: SM3DW has incorrect loop point + const auto titleId = CafeSystem::GetForegroundTitleId(); + if(titleId == 0x0005000010145D00 || titleId == 0x0005000010145C00 || titleId == 0x0005000010106100) + loopPoint = 113074; +} + +sint16* BootSoundReader::getSamples() +{ + size_t totalRead = 0; + const size_t loopPointOffset = 8 + loopPoint * 4; + while (totalRead < blockSize) + { + auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize - totalRead); + if (read == 0) + { + cemuLog_log(LogType::Force, "failed to read PCM samples from bootSound.btsnd"); + return nullptr; + } + if (read % (sizeof(sint16be) * 2) != 0) + { + cemuLog_log(LogType::Force, "failed to play bootSound.btsnd: reading PCM data stopped at an odd number of samples (is the file corrupt?)"); + return nullptr; + } + + std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin() + (totalRead / sizeof(sint16))); + totalRead += read; + if (totalRead < blockSize) + fsc_setFileSeek(bootsndFile, loopPointOffset); + } + + // handle case where the end of a block of samples lines up with the end of the file + if(fsc_getFileSeek(bootsndFile) == fsc_getFileSize(bootsndFile)) + fsc_setFileSeek(bootsndFile, loopPointOffset); + + return buffer.data(); +} diff --git a/src/util/bootSound/BootSoundReader.h b/src/util/bootSound/BootSoundReader.h new file mode 100644 index 00000000..1953b4be --- /dev/null +++ b/src/util/bootSound/BootSoundReader.h @@ -0,0 +1,20 @@ +#pragma once +#include "Cafe/Filesystem/fsc.h" + +class BootSoundReader +{ + public: + BootSoundReader() = delete; + BootSoundReader(FSCVirtualFile* bootsndFile, sint32 blockSize); + + sint16* getSamples(); + + private: + FSCVirtualFile* bootsndFile{}; + sint32 blockSize{}; + + uint32be muteBits{}; + uint32be loopPoint{}; + std::vector<sint16> buffer{}; + std::vector<sint16be> bufferBE{}; +}; From 2b0cbf7f6b6c34c748585d255ee7756ff592a502 Mon Sep 17 00:00:00 2001 From: Mike Lothian <mike@fireburn.co.uk> Date: Wed, 18 Dec 2024 21:15:42 +0000 Subject: [PATCH 291/314] Fix building against Boost 1.87.0 (#1455) --- src/input/api/DSU/DSUControllerProvider.cpp | 4 +--- src/input/api/DSU/DSUControllerProvider.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/input/api/DSU/DSUControllerProvider.cpp b/src/input/api/DSU/DSUControllerProvider.cpp index 37f92774..fa00277c 100644 --- a/src/input/api/DSU/DSUControllerProvider.cpp +++ b/src/input/api/DSU/DSUControllerProvider.cpp @@ -78,9 +78,7 @@ bool DSUControllerProvider::connect() using namespace boost::asio; ip::udp::resolver resolver(m_io_service); - const ip::udp::resolver::query query(ip::udp::v4(), get_settings().ip, fmt::format("{}", get_settings().port), - ip::udp::resolver::query::canonical_name); - m_receiver_endpoint = *resolver.resolve(query); + m_receiver_endpoint = *resolver.resolve(get_settings().ip, fmt::format("{}", get_settings().port)).cbegin(); if (m_socket.is_open()) m_socket.close(); diff --git a/src/input/api/DSU/DSUControllerProvider.h b/src/input/api/DSU/DSUControllerProvider.h index dfa4d7b8..692da619 100644 --- a/src/input/api/DSU/DSUControllerProvider.h +++ b/src/input/api/DSU/DSUControllerProvider.h @@ -102,7 +102,7 @@ private: std::condition_variable m_writer_cond; uint32 m_uid; - boost::asio::io_service m_io_service; + boost::asio::io_context m_io_service; boost::asio::ip::udp::endpoint m_receiver_endpoint; boost::asio::ip::udp::socket m_socket; From 1e30d72658151a5304f5625a8acdf6aae31b6c58 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Mon, 30 Dec 2024 17:49:51 +0000 Subject: [PATCH 292/314] build: Add ALLOW_PORTABLE flag (#1464) * Add ALLOW_PORTABLE cmake flag * Also check that `portable` is a directory --- CMakeLists.txt | 1 + src/gui/CMakeLists.txt | 4 ++++ src/gui/CemuApp.cpp | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf04b235..2352389e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.21.1) option(ENABLE_VCPKG "Enable the vcpkg package manager" ON) option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF) +option(ALLOW_PORTABLE "Allow Cemu to be run in portable mode" ON) # used by CI script to set version: set(EMULATOR_VERSION_MAJOR "0" CACHE STRING "") diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index e1a04ec0..7cdc208e 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -178,3 +178,7 @@ endif() if(WIN32) target_link_libraries(CemuGui PRIVATE bthprops) endif() + +if(ALLOW_PORTABLE) + target_compile_definitions(CemuGui PRIVATE CEMU_ALLOW_PORTABLE) +endif () \ No newline at end of file diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index c4b1f4e4..c3606292 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -88,12 +88,14 @@ void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for Windo fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); fs::path portablePath = exePath.parent_path() / "portable"; data_path = exePath.parent_path(); // the data path is always the same as the exe path - if (fs::exists(portablePath, ec)) +#ifdef CEMU_ALLOW_PORTABLE + if (fs::is_directory(portablePath, ec)) { isPortable = true; user_data_path = config_path = cache_path = portablePath; } else +#endif { fs::path roamingPath = GetAppDataRoamingPath() / "Cemu"; user_data_path = config_path = cache_path = roamingPath; @@ -124,12 +126,13 @@ void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for Linux fs::path portablePath = exePath.parent_path() / "portable"; // GetExecutablePath returns the AppImage's temporary mount location wxString appImagePath; - if (wxGetEnv(("APPIMAGE"), &appImagePath)) + if (wxGetEnv("APPIMAGE", &appImagePath)) { exePath = wxHelper::MakeFSPath(appImagePath); portablePath = exePath.parent_path() / "portable"; } - if (fs::exists(portablePath, ec)) +#ifdef CEMU_ALLOW_PORTABLE + if (fs::is_directory(portablePath, ec)) { isPortable = true; user_data_path = config_path = cache_path = portablePath; @@ -137,6 +140,7 @@ void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for Linux data_path = exePath.parent_path(); } else +#endif { SetAppName("Cemu"); wxString appName = GetAppName(); @@ -167,16 +171,18 @@ void CemuApp::DeterminePaths(std::set<fs::path>& failedWriteAccess) // for MacOS fs::path user_data_path, config_path, cache_path, data_path; auto standardPaths = wxStandardPaths::Get(); fs::path exePath(wxHelper::MakeFSPath(standardPaths.GetExecutablePath())); - // If run from an app bundle, use its parent directory - fs::path appPath = exePath.parent_path().parent_path().parent_path(); - fs::path portablePath = appPath.extension() == ".app" ? appPath.parent_path() / "portable" : exePath.parent_path() / "portable"; - if (fs::exists(portablePath, ec)) + // If run from an app bundle, use its parent directory + fs::path appPath = exePath.parent_path().parent_path().parent_path(); + fs::path portablePath = appPath.extension() == ".app" ? appPath.parent_path() / "portable" : exePath.parent_path() / "portable"; +#ifdef CEMU_ALLOW_PORTABLE + if (fs::is_directory(portablePath, ec)) { isPortable = true; user_data_path = config_path = cache_path = portablePath; data_path = exePath.parent_path(); } else +#endif { SetAppName("Cemu"); wxString appName = GetAppName(); From 4b792aa4d2599c2e04865309e34cd3af9de728e4 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:38:42 +0100 Subject: [PATCH 293/314] debug: Fix shader dumping (#1466) --- src/Cafe/HW/Latte/Core/LatteShader.cpp | 10 ++++------ src/gui/MainWindow.cpp | 4 +--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteShader.cpp b/src/Cafe/HW/Latte/Core/LatteShader.cpp index 77f16468..d9f0a5dd 100644 --- a/src/Cafe/HW/Latte/Core/LatteShader.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShader.cpp @@ -451,9 +451,8 @@ void LatteShader_DumpShader(uint64 baseHash, uint64 auxHash, LatteDecompilerShad suffix = "gs"; else if (shader->shaderType == LatteConst::ShaderType::Pixel) suffix = "ps"; - fs::path dumpPath = "dump/shaders"; - dumpPath /= fmt::format("{:016x}_{:016x}_{}.txt", baseHash, auxHash, suffix); - FileStream* fs = FileStream::createFile2(dumpPath); + + FileStream* fs = FileStream::createFile2(ActiveSettings::GetUserDataPath("dump/shaders/{:016x}_{:016x}_{}.txt", baseHash, auxHash, suffix)); if (fs) { if (shader->strBuf_shaderSource) @@ -479,9 +478,8 @@ void LatteShader_DumpRawShader(uint64 baseHash, uint64 auxHash, uint32 type, uin suffix = "copy"; else if (type == SHADER_DUMP_TYPE_COMPUTE) suffix = "compute"; - fs::path dumpPath = "dump/shaders"; - dumpPath /= fmt::format("{:016x}_{:016x}_{}.bin", baseHash, auxHash, suffix); - FileStream* fs = FileStream::createFile2(dumpPath); + + FileStream* fs = FileStream::createFile2(ActiveSettings::GetUserDataPath("dump/shaders/{:016x}_{:016x}_{}.bin", baseHash, auxHash, suffix)); if (fs) { fs->writeData(programCode, programLen); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 69ff4e99..4801706a 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1113,9 +1113,7 @@ void MainWindow::OnDebugDumpUsedShaders(wxCommandEvent& event) { try { - // create directory - const fs::path path(ActiveSettings::GetUserDataPath()); - fs::create_directories(path / "dump" / "shaders"); + fs::create_directories(ActiveSettings::GetUserDataPath("dump/shaders")); } catch (const std::exception & ex) { From 92021db2307161a2df0cc2cfa4d3498444ab6888 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Sun, 5 Jan 2025 04:08:13 +0100 Subject: [PATCH 294/314] Use one CPU emulation thread for --force-interpreter (#1467) --- src/Cafe/CafeSystem.cpp | 3 ++- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 88e0ed3d..1bf3755e 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -9,6 +9,7 @@ #include "audio/IAudioAPI.h" #include "audio/IAudioInputAPI.h" #include "config/ActiveSettings.h" +#include "config/LaunchSettings.h" #include "Cafe/TitleList/GameInfo.h" #include "Cafe/GraphicPack/GraphicPack2.h" #include "util/helpers/SystemException.h" @@ -843,7 +844,7 @@ namespace CafeSystem module->TitleStart(); cemu_initForGame(); // enter scheduler - if (ActiveSettings::GetCPUMode() == CPUMode::MulticoreRecompiler) + if (ActiveSettings::GetCPUMode() == CPUMode::MulticoreRecompiler && !LaunchSettings::ForceInterpreter()) coreinit::OSSchedulerBegin(3); else coreinit::OSSchedulerBegin(1); diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 1fed07cd..37e374d6 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -575,7 +575,7 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) debuggerState.debugSession.stepInto = false; debuggerState.debugSession.stepOver = false; debuggerState.debugSession.run = false; - while (true) + while (debuggerState.debugSession.isTrapped) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); // check for step commands From f61539a2624a8034aadc9eb5ab2555e628234804 Mon Sep 17 00:00:00 2001 From: brysma1 <brysma@proton.me> Date: Tue, 7 Jan 2025 22:22:55 -0500 Subject: [PATCH 295/314] Update build instructions for fedora and add troubleshooting step for alternative architectures (#1468) --- BUILD.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index 41de928e..662be96d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -57,7 +57,7 @@ At Step 3 in [Build Cemu using cmake and clang](#build-cemu-using-cmake-and-clan `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/clang-15 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-15 -G Ninja -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja` #### For Fedora and derivatives: -`sudo dnf install bluez-libs clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel zlib-devel zlib-static` +`sudo dnf install bluez-libs-devel clang cmake cubeb-devel freeglut-devel git glm-devel gtk3-devel kernel-headers libgcrypt-devel libsecret-devel libtool libusb1-devel llvm nasm ninja-build perl-core systemd-devel wayland-protocols-devel zlib-devel zlib-static` ### Build Cemu @@ -120,6 +120,9 @@ This section refers to running `cmake -S...` (truncated). * Compiling failed during rebuild after `git pull` with an error that mentions RPATH * Add the following and try running the command again: * `-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON` +* Environment variable `VCPKG_FORCE_SYSTEM_BINARIES` must be set. + * Execute the folowing and then try running the command again: + * `export VCPKG_FORCE_SYSTEM_BINARIES=1` * If you are getting a random error, read the [package-name-and-platform]-out.log and [package-name-and-platform]-err.log for the actual reason to see if you might be lacking the headers from a dependency. From 1923b7a7c4bef1555430a4474591d75960a1959b Mon Sep 17 00:00:00 2001 From: rcaridade145 <rcaridade145@gmail.com> Date: Sun, 12 Jan 2025 11:37:56 +0000 Subject: [PATCH 296/314] Vulkan: Added R5_G6_B5_UNORM to supported readback formats (#1430) --- src/Cafe/HW/Latte/Renderer/Vulkan/TextureReadbackVk.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/TextureReadbackVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/TextureReadbackVk.cpp index b055fe7e..bce23b59 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/TextureReadbackVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/TextureReadbackVk.cpp @@ -22,7 +22,7 @@ uint32 LatteTextureReadbackInfoVk::GetImageSize(LatteTextureView* textureView) cemu_assert(textureFormat == VK_FORMAT_R8G8B8A8_UNORM); return baseTexture->width * baseTexture->height * 4; } - else if (textureView->format == Latte::E_GX2SURFFMT::R8_UNORM) + else if (textureView->format == Latte::E_GX2SURFFMT::R8_UNORM ) { cemu_assert(textureFormat == VK_FORMAT_R8_UNORM); return baseTexture->width * baseTexture->height * 1; @@ -79,6 +79,13 @@ uint32 LatteTextureReadbackInfoVk::GetImageSize(LatteTextureView* textureView) // todo - if driver does not support VK_FORMAT_D24_UNORM_S8_UINT this is represented as VK_FORMAT_D32_SFLOAT_S8_UINT which is 8 bytes return baseTexture->width * baseTexture->height * 4; } + else if (textureView->format == Latte::E_GX2SURFFMT::R5_G6_B5_UNORM ) + { + if(textureFormat == VK_FORMAT_R5G6B5_UNORM_PACK16){ + return baseTexture->width * baseTexture->height * 2; + } + return 0; + } else { cemuLog_log(LogType::Force, "Unsupported texture readback format {:04x}", (uint32)textureView->format); From 8dd809d725ece390f9103f689d7665ce2865034f Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 12 Jan 2025 12:39:02 +0100 Subject: [PATCH 297/314] Latte: Implement better index caching (#1443) --- .../HW/Latte/Core/LatteCommandProcessor.cpp | 15 ++ src/Cafe/HW/Latte/Core/LatteIndices.cpp | 112 ++++++++---- src/Cafe/HW/Latte/Core/LatteIndices.h | 2 +- src/Cafe/HW/Latte/Core/LatteOverlay.cpp | 6 + .../HW/Latte/Core/LattePerformanceMonitor.cpp | 3 +- .../HW/Latte/Core/LattePerformanceMonitor.h | 6 + src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp | 1 - .../HW/Latte/Renderer/OpenGL/OpenGLRenderer.h | 17 +- src/Cafe/HW/Latte/Renderer/Renderer.h | 11 +- .../Renderer/Vulkan/VKRMemoryManager.cpp | 149 +++++++++++++-- .../Latte/Renderer/Vulkan/VKRMemoryManager.h | 160 ++++++++++++++--- .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 12 +- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 5 +- .../Renderer/Vulkan/VulkanRendererCore.cpp | 29 +-- src/Common/precompiled.h | 19 ++ src/util/ChunkedHeap/ChunkedHeap.h | 170 +++++++++--------- 16 files changed, 526 insertions(+), 191 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp index 167911b6..a8f81901 100644 --- a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp +++ b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp @@ -141,6 +141,14 @@ private: void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx); +// called whenever the GPU runs out of commands or hits a wait condition (semaphores, HLE waits) +void LatteCP_signalEnterWait() +{ + // based on the assumption that games won't do a rugpull and swap out buffer data in the middle of an uninterrupted sequence of drawcalls, + // we only flush caches when the GPU goes idle or has to wait for any operation + LatteIndices_invalidateAll(); +} + /* * Read a U32 from the command buffer * If no data is available then wait in a busy loop @@ -466,6 +474,8 @@ LatteCMDPtr LatteCP_itWaitRegMem(LatteCMDPtr cmd, uint32 nWords) const uint32 GPU7_WAIT_MEM_OP_GREATER = 6; const uint32 GPU7_WAIT_MEM_OP_NEVER = 7; + LatteCP_signalEnterWait(); + bool stalls = false; if ((word0 & 0x10) != 0) { @@ -594,6 +604,7 @@ LatteCMDPtr LatteCP_itMemSemaphore(LatteCMDPtr cmd, uint32 nWords) else if(SEM_SIGNAL == 7) { // wait + LatteCP_signalEnterWait(); size_t loopCount = 0; while (true) { @@ -1305,11 +1316,13 @@ void LatteCP_processCommandBuffer(DrawPassContext& drawPassCtx) } case IT_HLE_TRIGGER_SCANBUFFER_SWAP: { + LatteCP_signalEnterWait(); LatteCP_itHLESwapScanBuffer(cmdData, nWords); break; } case IT_HLE_WAIT_FOR_FLIP: { + LatteCP_signalEnterWait(); LatteCP_itHLEWaitForFlip(cmdData, nWords); break; } @@ -1594,12 +1607,14 @@ void LatteCP_ProcessRingbuffer() } case IT_HLE_TRIGGER_SCANBUFFER_SWAP: { + LatteCP_signalEnterWait(); LatteCP_itHLESwapScanBuffer(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 64; break; } case IT_HLE_WAIT_FOR_FLIP: { + LatteCP_signalEnterWait(); LatteCP_itHLEWaitForFlip(cmd, nWords); timerRecheck += CP_TIMER_RECHECK / 1; break; diff --git a/src/Cafe/HW/Latte/Core/LatteIndices.cpp b/src/Cafe/HW/Latte/Core/LatteIndices.cpp index 6e1d7455..aec51725 100644 --- a/src/Cafe/HW/Latte/Core/LatteIndices.cpp +++ b/src/Cafe/HW/Latte/Core/LatteIndices.cpp @@ -1,6 +1,7 @@ #include "Cafe/HW/Latte/Core/LatteConst.h" #include "Cafe/HW/Latte/Renderer/Renderer.h" #include "Cafe/HW/Latte/ISA/RegDefines.h" +#include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" #include "Common/cpu_features.h" #if defined(ARCH_X86_64) && defined(__GNUC__) @@ -9,32 +10,53 @@ struct { - const void* lastPtr; - uint32 lastCount; - LattePrimitiveMode lastPrimitiveMode; - LatteIndexType lastIndexType; - // output - uint32 indexMin; - uint32 indexMax; - Renderer::INDEX_TYPE renderIndexType; - uint32 outputCount; - uint32 indexBufferOffset; - uint32 indexBufferIndex; + struct CacheEntry + { + // input data + const void* lastPtr; + uint32 lastCount; + LattePrimitiveMode lastPrimitiveMode; + LatteIndexType lastIndexType; + uint64 lastUsed; + // output + uint32 indexMin; + uint32 indexMax; + Renderer::INDEX_TYPE renderIndexType; + uint32 outputCount; + Renderer::IndexAllocation indexAllocation; + }; + std::array<CacheEntry, 8> entry; + uint64 currentUsageCounter{0}; }LatteIndexCache{}; void LatteIndices_invalidate(const void* memPtr, uint32 size) { - if (LatteIndexCache.lastPtr >= memPtr && (LatteIndexCache.lastPtr < ((uint8*)memPtr + size)) ) + for(auto& entry : LatteIndexCache.entry) { - LatteIndexCache.lastPtr = nullptr; - LatteIndexCache.lastCount = 0; + if (entry.lastPtr >= memPtr && (entry.lastPtr < ((uint8*)memPtr + size)) ) + { + if(entry.lastPtr != nullptr) + g_renderer->indexData_releaseIndexMemory(entry.indexAllocation); + entry.lastPtr = nullptr; + entry.lastCount = 0; + } } } void LatteIndices_invalidateAll() { - LatteIndexCache.lastPtr = nullptr; - LatteIndexCache.lastCount = 0; + for(auto& entry : LatteIndexCache.entry) + { + if (entry.lastPtr != nullptr) + g_renderer->indexData_releaseIndexMemory(entry.indexAllocation); + entry.lastPtr = nullptr; + entry.lastCount = 0; + } +} + +uint64 LatteIndices_GetNextUsageIndex() +{ + return LatteIndexCache.currentUsageCounter++; } uint32 LatteIndices_calculateIndexOutputSize(LattePrimitiveMode primitiveMode, LatteIndexType indexType, uint32 count) @@ -532,7 +554,7 @@ void LatteIndices_alternativeCalculateIndexMinMax(const void* indexData, LatteIn } } -void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 count, LattePrimitiveMode primitiveMode, uint32& indexMin, uint32& indexMax, Renderer::INDEX_TYPE& renderIndexType, uint32& outputCount, uint32& indexBufferOffset, uint32& indexBufferIndex) +void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 count, LattePrimitiveMode primitiveMode, uint32& indexMin, uint32& indexMax, Renderer::INDEX_TYPE& renderIndexType, uint32& outputCount, Renderer::IndexAllocation& indexAllocation) { // what this should do: // [x] use fast SIMD-based index decoding @@ -542,17 +564,18 @@ void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 // [ ] better cache implementation, allow to cache across frames // reuse from cache if data didn't change - if (LatteIndexCache.lastPtr == indexData && - LatteIndexCache.lastCount == count && - LatteIndexCache.lastPrimitiveMode == primitiveMode && - LatteIndexCache.lastIndexType == indexType) + auto cacheEntry = std::find_if(LatteIndexCache.entry.begin(), LatteIndexCache.entry.end(), [indexData, count, primitiveMode, indexType](const auto& entry) { - indexMin = LatteIndexCache.indexMin; - indexMax = LatteIndexCache.indexMax; - renderIndexType = LatteIndexCache.renderIndexType; - outputCount = LatteIndexCache.outputCount; - indexBufferOffset = LatteIndexCache.indexBufferOffset; - indexBufferIndex = LatteIndexCache.indexBufferIndex; + return entry.lastPtr == indexData && entry.lastCount == count && entry.lastPrimitiveMode == primitiveMode && entry.lastIndexType == indexType; + }); + if (cacheEntry != LatteIndexCache.entry.end()) + { + indexMin = cacheEntry->indexMin; + indexMax = cacheEntry->indexMax; + renderIndexType = cacheEntry->renderIndexType; + outputCount = cacheEntry->outputCount; + indexAllocation = cacheEntry->indexAllocation; + cacheEntry->lastUsed = LatteIndices_GetNextUsageIndex(); return; } @@ -576,10 +599,12 @@ void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 indexMin = 0; indexMax = std::max(count, 1u)-1; renderIndexType = Renderer::INDEX_TYPE::NONE; + indexAllocation = {}; return; // no indices } // query index buffer from renderer - void* indexOutputPtr = g_renderer->indexData_reserveIndexMemory(indexOutputSize, indexBufferOffset, indexBufferIndex); + indexAllocation = g_renderer->indexData_reserveIndexMemory(indexOutputSize); + void* indexOutputPtr = indexAllocation.mem; // decode indices indexMin = std::numeric_limits<uint32>::max(); @@ -704,16 +729,25 @@ void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 // recalculate index range but filter out primitive restart index LatteIndices_alternativeCalculateIndexMinMax(indexData, indexType, count, indexMin, indexMax); } - g_renderer->indexData_uploadIndexMemory(indexBufferOffset, indexOutputSize); + g_renderer->indexData_uploadIndexMemory(indexAllocation); + performanceMonitor.cycle[performanceMonitor.cycleIndex].indexDataUploaded += indexOutputSize; + // get least recently used cache entry + auto lruEntry = std::min_element(LatteIndexCache.entry.begin(), LatteIndexCache.entry.end(), [](const auto& a, const auto& b) + { + return a.lastUsed < b.lastUsed; + }); + // invalidate previous allocation + if(lruEntry->lastPtr != nullptr) + g_renderer->indexData_releaseIndexMemory(lruEntry->indexAllocation); // update cache - LatteIndexCache.lastPtr = indexData; - LatteIndexCache.lastCount = count; - LatteIndexCache.lastPrimitiveMode = primitiveMode; - LatteIndexCache.lastIndexType = indexType; - LatteIndexCache.indexMin = indexMin; - LatteIndexCache.indexMax = indexMax; - LatteIndexCache.renderIndexType = renderIndexType; - LatteIndexCache.outputCount = outputCount; - LatteIndexCache.indexBufferOffset = indexBufferOffset; - LatteIndexCache.indexBufferIndex = indexBufferIndex; + lruEntry->lastPtr = indexData; + lruEntry->lastCount = count; + lruEntry->lastPrimitiveMode = primitiveMode; + lruEntry->lastIndexType = indexType; + lruEntry->indexMin = indexMin; + lruEntry->indexMax = indexMax; + lruEntry->renderIndexType = renderIndexType; + lruEntry->outputCount = outputCount; + lruEntry->indexAllocation = indexAllocation; + lruEntry->lastUsed = LatteIndices_GetNextUsageIndex(); } diff --git a/src/Cafe/HW/Latte/Core/LatteIndices.h b/src/Cafe/HW/Latte/Core/LatteIndices.h index 917d7991..8aace24e 100644 --- a/src/Cafe/HW/Latte/Core/LatteIndices.h +++ b/src/Cafe/HW/Latte/Core/LatteIndices.h @@ -4,4 +4,4 @@ void LatteIndices_invalidate(const void* memPtr, uint32 size); void LatteIndices_invalidateAll(); -void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 count, LattePrimitiveMode primitiveMode, uint32& indexMin, uint32& indexMax, Renderer::INDEX_TYPE& renderIndexType, uint32& outputCount, uint32& indexBufferOffset, uint32& indexBufferIndex); \ No newline at end of file +void LatteIndices_decode(const void* indexData, LatteIndexType indexType, uint32 count, LattePrimitiveMode primitiveMode, uint32& indexMin, uint32& indexMax, Renderer::INDEX_TYPE& renderIndexType, uint32& outputCount, Renderer::IndexAllocation& indexAllocation); \ No newline at end of file diff --git a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp index 238f85e8..e6edb904 100644 --- a/src/Cafe/HW/Latte/Core/LatteOverlay.cpp +++ b/src/Cafe/HW/Latte/Core/LatteOverlay.cpp @@ -107,7 +107,13 @@ void LatteOverlay_renderOverlay(ImVec2& position, ImVec2& pivot, sint32 directio ImGui::Text("VRAM: %dMB / %dMB", g_state.vramUsage, g_state.vramTotal); if (config.overlay.debug) + { + // general debug info + ImGui::Text("--- Debug info ---"); + ImGui::Text("IndexUploadPerFrame: %dKB", (performanceMonitor.stats.indexDataUploadPerFrame+1023)/1024); + // backend specific info g_renderer->AppendOverlayDebugInfo(); + } position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; } diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp index f2767446..14dfe9a9 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.cpp @@ -74,7 +74,6 @@ void LattePerformanceMonitor_frameEnd() uniformBankDataUploadedPerFrame /= 1024ULL; uint32 uniformBankCountUploadedPerFrame = (uint32)(uniformBankUploadedCount / (uint64)elapsedFrames); uint64 indexDataUploadPerFrame = (indexDataUploaded / (uint64)elapsedFrames); - indexDataUploadPerFrame /= 1024ULL; double fps = (double)elapsedFrames2S * 1000.0 / (double)totalElapsedTimeFPS; uint32 shaderBindsPerFrame = shaderBindCounter / elapsedFrames; @@ -82,7 +81,7 @@ void LattePerformanceMonitor_frameEnd() uint32 rlps = (uint32)((uint64)recompilerLeaveCount * 1000ULL / (uint64)totalElapsedTime); uint32 tlps = (uint32)((uint64)threadLeaveCount * 1000ULL / (uint64)totalElapsedTime); // set stats - + performanceMonitor.stats.indexDataUploadPerFrame = indexDataUploadPerFrame; // next counter cycle sint32 nextCycleIndex = (performanceMonitor.cycleIndex + 1) % PERFORMANCE_MONITOR_TRACK_CYCLES; performanceMonitor.cycle[nextCycleIndex].drawCallCounter = 0; diff --git a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h index ac75bb1b..dbc3cff9 100644 --- a/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h +++ b/src/Cafe/HW/Latte/Core/LattePerformanceMonitor.h @@ -132,6 +132,12 @@ typedef struct LattePerfStatCounter numDrawBarriersPerFrame; LattePerfStatCounter numBeginRenderpassPerFrame; }vk; + + // calculated stats (per frame) + struct + { + uint32 indexDataUploadPerFrame; + }stats; }performanceMonitor_t; extern performanceMonitor_t performanceMonitor; diff --git a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp index 3bb6c7e3..2efef5bf 100644 --- a/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp +++ b/src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp @@ -11,7 +11,6 @@ #include "Cafe/HW/Latte/Core/LattePerformanceMonitor.h" #include "Cafe/GraphicPack/GraphicPack2.h" #include "config/ActiveSettings.h" -#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h" #include "gui/guiWrapper.h" #include "Cafe/OS/libs/erreula/erreula.h" #include "input/InputManager.h" diff --git a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h index 313ea3c0..e29e9d4c 100644 --- a/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h @@ -102,16 +102,21 @@ public: static void SetAttributeArrayState(uint32 index, bool isEnabled, sint32 aluDivisor); static void SetArrayElementBuffer(GLuint arrayElementBuffer); - // index - void* indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) override + // index (not used by OpenGL renderer yet) + IndexAllocation indexData_reserveIndexMemory(uint32 size) override { - assert_dbg(); - return nullptr; + cemu_assert_unimplemented(); + return {}; } - void indexData_uploadIndexMemory(uint32 offset, uint32 size) override + void indexData_releaseIndexMemory(IndexAllocation& allocation) override { - assert_dbg(); + cemu_assert_unimplemented(); + } + + void indexData_uploadIndexMemory(IndexAllocation& allocation) override + { + cemu_assert_unimplemented(); } // uniform diff --git a/src/Cafe/HW/Latte/Renderer/Renderer.h b/src/Cafe/HW/Latte/Renderer/Renderer.h index 0b694bb9..77d588b9 100644 --- a/src/Cafe/HW/Latte/Renderer/Renderer.h +++ b/src/Cafe/HW/Latte/Renderer/Renderer.h @@ -138,8 +138,15 @@ public: virtual void draw_endSequence() = 0; // index - virtual void* indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) = 0; - virtual void indexData_uploadIndexMemory(uint32 offset, uint32 size) = 0; + struct IndexAllocation + { + void* mem; // pointer to index data inside buffer + void* rendererInternal; // for renderer use + }; + + virtual IndexAllocation indexData_reserveIndexMemory(uint32 size) = 0; + virtual void indexData_releaseIndexMemory(IndexAllocation& allocation) = 0; + virtual void indexData_uploadIndexMemory(IndexAllocation& allocation) = 0; // occlusion queries virtual LatteQueryObject* occlusionQuery_create() = 0; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp index c4f47a2b..3494dbc5 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp @@ -23,11 +23,11 @@ void VKRSynchronizedRingAllocator::allocateAdditionalUploadBuffer(uint32 sizeReq AllocatorBuffer_t newBuffer{}; newBuffer.writeIndex = 0; newBuffer.basePtr = nullptr; - if (m_bufferType == BUFFER_TYPE::STAGING) + if (m_bufferType == VKR_BUFFER_TYPE::STAGING) m_vkrMemMgr->CreateBuffer(bufferAllocSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, newBuffer.vk_buffer, newBuffer.vk_mem); - else if (m_bufferType == BUFFER_TYPE::INDEX) + else if (m_bufferType == VKR_BUFFER_TYPE::INDEX) m_vkrMemMgr->CreateBuffer(bufferAllocSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, newBuffer.vk_buffer, newBuffer.vk_mem); - else if (m_bufferType == BUFFER_TYPE::STRIDE) + else if (m_bufferType == VKR_BUFFER_TYPE::STRIDE) m_vkrMemMgr->CreateBuffer(bufferAllocSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, newBuffer.vk_buffer, newBuffer.vk_mem); else cemu_assert_debug(false); @@ -53,7 +53,7 @@ VKRSynchronizedRingAllocator::AllocatorReservation_t VKRSynchronizedRingAllocato uint32 distanceToSyncPoint; if (!itr.queue_syncPoints.empty()) { - if(itr.queue_syncPoints.front().offset < itr.writeIndex) + if (itr.queue_syncPoints.front().offset < itr.writeIndex) distanceToSyncPoint = 0xFFFFFFFF; else distanceToSyncPoint = itr.queue_syncPoints.front().offset - itr.writeIndex; @@ -100,7 +100,7 @@ VKRSynchronizedRingAllocator::AllocatorReservation_t VKRSynchronizedRingAllocato void VKRSynchronizedRingAllocator::FlushReservation(AllocatorReservation_t& uploadReservation) { - cemu_assert_debug(m_bufferType == BUFFER_TYPE::STAGING); // only the staging buffer isn't coherent + cemu_assert_debug(m_bufferType == VKR_BUFFER_TYPE::STAGING); // only the staging buffer isn't coherent // todo - use nonCoherentAtomSize for flush size (instead of hardcoded constant) VkMappedMemoryRange flushedRange{}; flushedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; @@ -167,6 +167,70 @@ void VKRSynchronizedRingAllocator::GetStats(uint32& numBuffers, size_t& totalBuf } } +/* VKRSynchronizedHeapAllocator */ + +VKRSynchronizedHeapAllocator::VKRSynchronizedHeapAllocator(class VKRMemoryManager* vkMemoryManager, VKR_BUFFER_TYPE bufferType, size_t minimumBufferAllocSize) + : m_vkrMemMgr(vkMemoryManager), m_chunkedHeap(bufferType, minimumBufferAllocSize) {}; + +VKRSynchronizedHeapAllocator::AllocatorReservation* VKRSynchronizedHeapAllocator::AllocateBufferMemory(uint32 size, uint32 alignment) +{ + CHAddr addr = m_chunkedHeap.alloc(size, alignment); + m_activeAllocations.emplace_back(addr); + AllocatorReservation* res = m_poolAllocatorReservation.allocObj(); + res->bufferIndex = addr.chunkIndex; + res->bufferOffset = addr.offset; + res->size = size; + res->memPtr = m_chunkedHeap.GetChunkPtr(addr.chunkIndex) + addr.offset; + m_chunkedHeap.GetChunkVkMemInfo(addr.chunkIndex, res->vkBuffer, res->vkMem); + return res; +} + +void VKRSynchronizedHeapAllocator::FreeReservation(AllocatorReservation* uploadReservation) +{ + // put the allocation on a delayed release queue for the current command buffer + uint64 currentCommandBufferId = VulkanRenderer::GetInstance()->GetCurrentCommandBufferId(); + auto it = std::find_if(m_activeAllocations.begin(), m_activeAllocations.end(), [&uploadReservation](const TrackedAllocation& allocation) { return allocation.allocation.chunkIndex == uploadReservation->bufferIndex && allocation.allocation.offset == uploadReservation->bufferOffset; }); + cemu_assert_debug(it != m_activeAllocations.end()); + m_releaseQueue[currentCommandBufferId].emplace_back(it->allocation); + m_activeAllocations.erase(it); + m_poolAllocatorReservation.freeObj(uploadReservation); +} + +void VKRSynchronizedHeapAllocator::FlushReservation(AllocatorReservation* uploadReservation) +{ + if (m_chunkedHeap.RequiresFlush(uploadReservation->bufferIndex)) + { + VkMappedMemoryRange flushedRange{}; + flushedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; + flushedRange.memory = uploadReservation->vkMem; + flushedRange.offset = uploadReservation->bufferOffset; + flushedRange.size = uploadReservation->size; + vkFlushMappedMemoryRanges(VulkanRenderer::GetInstance()->GetLogicalDevice(), 1, &flushedRange); + } +} + +void VKRSynchronizedHeapAllocator::CleanupBuffer(uint64 latestFinishedCommandBufferId) +{ + auto it = m_releaseQueue.begin(); + while (it != m_releaseQueue.end()) + { + if (it->first <= latestFinishedCommandBufferId) + { + // release allocations + for(auto& addr : it->second) + m_chunkedHeap.free(addr); + it = m_releaseQueue.erase(it); + continue; + } + it++; + } +} + +void VKRSynchronizedHeapAllocator::GetStats(uint32& numBuffers, size_t& totalBufferSize, size_t& freeBufferSize) const +{ + m_chunkedHeap.GetStats(numBuffers, totalBufferSize, freeBufferSize); +} + /* VkTextureChunkedHeap */ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) @@ -175,7 +239,7 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA m_list_chunkInfo.resize(m_list_chunkInfo.size() + 1); // pad minimumAllocationSize to 32KB alignment - minimumAllocationSize = (minimumAllocationSize + (32*1024-1)) & ~(32 * 1024 - 1); + minimumAllocationSize = (minimumAllocationSize + (32 * 1024 - 1)) & ~(32 * 1024 - 1); uint32 allocationSize = 1024 * 1024 * 128; if (chunkIndex == 0) @@ -189,8 +253,7 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA std::vector<uint32> deviceLocalMemoryTypeIndices = m_vkrMemoryManager->FindMemoryTypes(m_typeFilter, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); std::vector<uint32> hostLocalMemoryTypeIndices = m_vkrMemoryManager->FindMemoryTypes(m_typeFilter, 0); // remove device local memory types from host local vector - auto pred = [&deviceLocalMemoryTypeIndices](const uint32& v) ->bool - { + auto pred = [&deviceLocalMemoryTypeIndices](const uint32& v) -> bool { return std::find(deviceLocalMemoryTypeIndices.begin(), deviceLocalMemoryTypeIndices.end(), v) != deviceLocalMemoryTypeIndices.end(); }; hostLocalMemoryTypeIndices.erase(std::remove_if(hostLocalMemoryTypeIndices.begin(), hostLocalMemoryTypeIndices.end(), pred), hostLocalMemoryTypeIndices.end()); @@ -206,7 +269,7 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA allocInfo.memoryTypeIndex = memType; VkDeviceMemory imageMemory; - VkResult r = vkAllocateMemory(m_device, &allocInfo, nullptr, &imageMemory); + VkResult r = vkAllocateMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), &allocInfo, nullptr, &imageMemory); if (r != VK_SUCCESS) continue; m_list_chunkInfo[chunkIndex].mem = imageMemory; @@ -221,7 +284,7 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA allocInfo.memoryTypeIndex = memType; VkDeviceMemory imageMemory; - VkResult r = vkAllocateMemory(m_device, &allocInfo, nullptr, &imageMemory); + VkResult r = vkAllocateMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), &allocInfo, nullptr, &imageMemory); if (r != VK_SUCCESS) continue; m_list_chunkInfo[chunkIndex].mem = imageMemory; @@ -238,6 +301,68 @@ uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumA return 0; } +/* VkBufferChunkedHeap */ + +VKRBuffer* VKRBuffer::Create(VKR_BUFFER_TYPE bufferType, size_t bufferSize, VkMemoryPropertyFlags properties) +{ + auto* memMgr = VulkanRenderer::GetInstance()->GetMemoryManager(); + VkBuffer buffer; + VkDeviceMemory bufferMemory; + bool allocSuccess; + if (bufferType == VKR_BUFFER_TYPE::STAGING) + allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, properties, buffer, bufferMemory); + else if (bufferType == VKR_BUFFER_TYPE::INDEX) + allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, properties, buffer, bufferMemory); + else if (bufferType == VKR_BUFFER_TYPE::STRIDE) + allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, properties, buffer, bufferMemory); + else + cemu_assert_debug(false); + if (!allocSuccess) + return nullptr; + + VKRBuffer* bufferObj = new VKRBuffer(buffer, bufferMemory); + // if host visible, then map buffer + void* data = nullptr; + if (properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + { + vkMapMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), bufferMemory, 0, bufferSize, 0, &data); + bufferObj->m_requiresFlush = !HAS_FLAG(properties, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + } + bufferObj->m_mappedMemory = (uint8*)data; + return bufferObj; +} + +VKRBuffer::~VKRBuffer() +{ + if (m_mappedMemory) + vkUnmapMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_bufferMemory); + if (m_bufferMemory != VK_NULL_HANDLE) + vkFreeMemory(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_bufferMemory, nullptr); + if (m_buffer != VK_NULL_HANDLE) + vkDestroyBuffer(VulkanRenderer::GetInstance()->GetLogicalDevice(), m_buffer, nullptr); +} + +VkBufferChunkedHeap::~VkBufferChunkedHeap() +{ + for (auto& chunk : m_chunkBuffers) + delete chunk; +} + +uint32 VkBufferChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) +{ + size_t allocationSize = std::max<size_t>(m_minimumBufferAllocationSize, minimumAllocationSize); + VKRBuffer* buffer = VKRBuffer::Create(m_bufferType, allocationSize, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + if(!buffer) + buffer = VKRBuffer::Create(m_bufferType, allocationSize, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); + if(!buffer) + VulkanRenderer::GetInstance()->UnrecoverableError("Failed to allocate buffer memory for VkBufferChunkedHeap"); + cemu_assert_debug(buffer); + cemu_assert_debug(m_chunkBuffers.size() == chunkIndex); + m_chunkBuffers.emplace_back(buffer); + // todo - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT might be worth it? + return allocationSize; +} + uint32_t VKRMemoryManager::FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) const { VkPhysicalDeviceMemoryProperties memProperties; @@ -423,7 +548,7 @@ bool VKRMemoryManager::CreateBufferFromHostMemory(void* hostPointer, VkDeviceSiz importHostMem.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT; importHostMem.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; importHostMem.pHostPointer = hostPointer; - // VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT or + // VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT or // VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT // whats the difference ? @@ -469,7 +594,7 @@ VkImageMemAllocation* VKRMemoryManager::imageMemoryAllocate(VkImage image) auto it = map_textureHeap.find(typeFilter); if (it == map_textureHeap.end()) { - texHeap = new VkTextureChunkedHeap(this, typeFilter, m_vkr->GetLogicalDevice()); + texHeap = new VkTextureChunkedHeap(this, typeFilter); map_textureHeap.emplace(typeFilter, texHeap); } else diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h index bf2d919b..08af5882 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h @@ -2,6 +2,36 @@ #include "Cafe/HW/Latte/Renderer/Renderer.h" #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" #include "util/ChunkedHeap/ChunkedHeap.h" +#include "util/helpers/MemoryPool.h" + +enum class VKR_BUFFER_TYPE +{ + STAGING, // staging upload buffer + INDEX, // buffer for index data + STRIDE, // buffer for stride-adjusted vertex data +}; + +class VKRBuffer +{ + public: + static VKRBuffer* Create(VKR_BUFFER_TYPE bufferType, size_t bufferSize, VkMemoryPropertyFlags properties); + ~VKRBuffer(); + + VkBuffer GetVkBuffer() const { return m_buffer; } + VkDeviceMemory GetVkBufferMemory() const { return m_bufferMemory; } + + uint8* GetPtr() const { return m_mappedMemory; } + + bool RequiresFlush() const { return m_requiresFlush; } + + private: + VKRBuffer(VkBuffer buffer, VkDeviceMemory bufferMem) : m_buffer(buffer), m_bufferMemory(bufferMem) { }; + + VkBuffer m_buffer; + VkDeviceMemory m_bufferMemory; + uint8* m_mappedMemory; + bool m_requiresFlush{false}; +}; struct VkImageMemAllocation { @@ -14,18 +44,16 @@ struct VkImageMemAllocation uint32 getAllocationSize() { return allocationSize; } }; -class VkTextureChunkedHeap : private ChunkedHeap +class VkTextureChunkedHeap : private ChunkedHeap<> { public: - VkTextureChunkedHeap(class VKRMemoryManager* memoryManager, uint32 typeFilter, VkDevice device) : m_vkrMemoryManager(memoryManager), m_typeFilter(typeFilter), m_device(device) { }; + VkTextureChunkedHeap(class VKRMemoryManager* memoryManager, uint32 typeFilter) : m_vkrMemoryManager(memoryManager), m_typeFilter(typeFilter) { }; struct ChunkInfo { VkDeviceMemory mem; }; - uint32 allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) override; - CHAddr allocMem(uint32 size, uint32 alignment) { if (alignment < 4) @@ -43,11 +71,6 @@ public: this->free(addr); } - void setDevice(VkDevice dev) - { - m_device = dev; - } - VkDeviceMemory getChunkMem(uint32 index) { if (index >= m_list_chunkInfo.size()) @@ -57,28 +80,73 @@ public: void getStatistics(uint32& totalHeapSize, uint32& allocatedBytes) const { - totalHeapSize = numHeapBytes; - allocatedBytes = numAllocatedBytes; + totalHeapSize = m_numHeapBytes; + allocatedBytes = m_numAllocatedBytes; } - VkDevice m_device; + private: + uint32 allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) override; + uint32 m_typeFilter{ 0xFFFFFFFF }; class VKRMemoryManager* m_vkrMemoryManager; std::vector<ChunkInfo> m_list_chunkInfo; }; +class VkBufferChunkedHeap : private ChunkedHeap<> +{ + public: + VkBufferChunkedHeap(VKR_BUFFER_TYPE bufferType, size_t minimumBufferAllocationSize) : m_bufferType(bufferType), m_minimumBufferAllocationSize(minimumBufferAllocationSize) { }; + ~VkBufferChunkedHeap(); + + using ChunkedHeap::alloc; + using ChunkedHeap::free; + + uint8* GetChunkPtr(uint32 index) const + { + if (index >= m_chunkBuffers.size()) + return nullptr; + return m_chunkBuffers[index]->GetPtr(); + } + + void GetChunkVkMemInfo(uint32 index, VkBuffer& buffer, VkDeviceMemory& mem) + { + if (index >= m_chunkBuffers.size()) + { + buffer = VK_NULL_HANDLE; + mem = VK_NULL_HANDLE; + return; + } + buffer = m_chunkBuffers[index]->GetVkBuffer(); + mem = m_chunkBuffers[index]->GetVkBufferMemory(); + } + + void GetStats(uint32& numBuffers, size_t& totalBufferSize, size_t& freeBufferSize) const + { + numBuffers = m_chunkBuffers.size(); + totalBufferSize = m_numHeapBytes; + freeBufferSize = m_numHeapBytes - m_numAllocatedBytes; + } + + bool RequiresFlush(uint32 index) const + { + if (index >= m_chunkBuffers.size()) + return false; + return m_chunkBuffers[index]->RequiresFlush(); + } + + private: + uint32 allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) override; + + VKR_BUFFER_TYPE m_bufferType; + std::vector<VKRBuffer*> m_chunkBuffers; + size_t m_minimumBufferAllocationSize; +}; + // a circular ring-buffer which tracks and releases memory per command-buffer class VKRSynchronizedRingAllocator { public: - enum class BUFFER_TYPE - { - STAGING, // staging upload buffer - INDEX, // buffer for index data - STRIDE, // buffer for stride-adjusted vertex data - }; - - VKRSynchronizedRingAllocator(class VulkanRenderer* vkRenderer, class VKRMemoryManager* vkMemoryManager, BUFFER_TYPE bufferType, uint32 minimumBufferAllocSize) : m_vkr(vkRenderer), m_vkrMemMgr(vkMemoryManager), m_bufferType(bufferType), m_minimumBufferAllocSize(minimumBufferAllocSize) {}; + VKRSynchronizedRingAllocator(class VulkanRenderer* vkRenderer, class VKRMemoryManager* vkMemoryManager, VKR_BUFFER_TYPE bufferType, uint32 minimumBufferAllocSize) : m_vkr(vkRenderer), m_vkrMemMgr(vkMemoryManager), m_bufferType(bufferType), m_minimumBufferAllocSize(minimumBufferAllocSize) {}; VKRSynchronizedRingAllocator(const VKRSynchronizedRingAllocator&) = delete; // disallow copy struct BufferSyncPoint_t @@ -126,13 +194,53 @@ private: const class VulkanRenderer* m_vkr; const class VKRMemoryManager* m_vkrMemMgr; - const BUFFER_TYPE m_bufferType; + const VKR_BUFFER_TYPE m_bufferType; const uint32 m_minimumBufferAllocSize; std::vector<AllocatorBuffer_t> m_buffers; }; +// heap style allocator with released memory being freed after the current command buffer finishes +class VKRSynchronizedHeapAllocator +{ + struct TrackedAllocation + { + TrackedAllocation(CHAddr allocation) : allocation(allocation) {}; + CHAddr allocation; + }; + + public: + VKRSynchronizedHeapAllocator(class VKRMemoryManager* vkMemoryManager, VKR_BUFFER_TYPE bufferType, size_t minimumBufferAllocSize); + VKRSynchronizedHeapAllocator(const VKRSynchronizedHeapAllocator&) = delete; // disallow copy + + struct AllocatorReservation + { + VkBuffer vkBuffer; + VkDeviceMemory vkMem; + uint8* memPtr; + uint32 bufferOffset; + uint32 size; + uint32 bufferIndex; + }; + + AllocatorReservation* AllocateBufferMemory(uint32 size, uint32 alignment); + void FreeReservation(AllocatorReservation* uploadReservation); + void FlushReservation(AllocatorReservation* uploadReservation); + + void CleanupBuffer(uint64 latestFinishedCommandBufferId); + + void GetStats(uint32& numBuffers, size_t& totalBufferSize, size_t& freeBufferSize) const; + private: + const class VKRMemoryManager* m_vkrMemMgr; + VkBufferChunkedHeap m_chunkedHeap; + // allocations + std::vector<TrackedAllocation> m_activeAllocations; + MemoryPool<AllocatorReservation> m_poolAllocatorReservation{32}; + // release queue + std::unordered_map<uint64, std::vector<CHAddr>> m_releaseQueue; +}; + void LatteIndices_invalidateAll(); class VKRMemoryManager @@ -140,9 +248,9 @@ class VKRMemoryManager friend class VKRSynchronizedRingAllocator; public: VKRMemoryManager(class VulkanRenderer* renderer) : - m_stagingBuffer(renderer, this, VKRSynchronizedRingAllocator::BUFFER_TYPE::STAGING, 32u * 1024 * 1024), - m_indexBuffer(renderer, this, VKRSynchronizedRingAllocator::BUFFER_TYPE::INDEX, 4u * 1024 * 1024), - m_vertexStrideMetalBuffer(renderer, this, VKRSynchronizedRingAllocator::BUFFER_TYPE::STRIDE, 4u * 1024 * 1024) + m_stagingBuffer(renderer, this, VKR_BUFFER_TYPE::STAGING, 32u * 1024 * 1024), + m_indexBuffer(this, VKR_BUFFER_TYPE::INDEX, 4u * 1024 * 1024), + m_vertexStrideMetalBuffer(renderer, this, VKR_BUFFER_TYPE::STRIDE, 4u * 1024 * 1024) { m_vkr = renderer; } @@ -167,7 +275,7 @@ public: } VKRSynchronizedRingAllocator& getStagingAllocator() { return m_stagingBuffer; }; // allocator for texture/attribute/uniform uploads - VKRSynchronizedRingAllocator& getIndexAllocator() { return m_indexBuffer; }; // allocator for index data + VKRSynchronizedHeapAllocator& GetIndexAllocator() { return m_indexBuffer; }; // allocator for index data VKRSynchronizedRingAllocator& getMetalStrideWorkaroundAllocator() { return m_vertexStrideMetalBuffer; }; // allocator for stride-adjusted vertex data void cleanupBuffers(uint64 latestFinishedCommandBufferId) @@ -202,6 +310,6 @@ public: private: class VulkanRenderer* m_vkr; VKRSynchronizedRingAllocator m_stagingBuffer; - VKRSynchronizedRingAllocator m_indexBuffer; + VKRSynchronizedHeapAllocator m_indexBuffer; VKRSynchronizedRingAllocator m_vertexStrideMetalBuffer; }; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index eae6daf2..66369c10 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -681,6 +681,9 @@ VulkanRenderer::~VulkanRenderer() vkDestroyDebugUtilsMessengerEXT(m_instance, m_debugCallback, nullptr); } + // destroy memory manager + delete memoryManager; + // destroy instance, devices if (m_instance != VK_NULL_HANDLE) { @@ -692,9 +695,6 @@ VulkanRenderer::~VulkanRenderer() vkDestroyInstance(m_instance, nullptr); } - // destroy memory manager - delete memoryManager; - // crashes? //glslang::FinalizeProcess(); } @@ -3701,7 +3701,7 @@ void VulkanRenderer::bufferCache_copyStreamoutToMainBuffer(uint32 srcOffset, uin void VulkanRenderer::AppendOverlayDebugInfo() { - ImGui::Text("--- Vulkan info ---"); + ImGui::Text("--- Vulkan debug info ---"); ImGui::Text("GfxPipelines %u", performanceMonitor.vk.numGraphicPipelines.get()); ImGui::Text("DescriptorSets %u", performanceMonitor.vk.numDescriptorSets.get()); ImGui::Text("DS ImgSamplers %u", performanceMonitor.vk.numDescriptorSamplerTextures.get()); @@ -3719,7 +3719,7 @@ void VulkanRenderer::AppendOverlayDebugInfo() ImGui::Text("BeginRP/f %u", performanceMonitor.vk.numBeginRenderpassPerFrame.get()); ImGui::Text("Barriers/f %u", performanceMonitor.vk.numDrawBarriersPerFrame.get()); - ImGui::Text("--- Cache info ---"); + ImGui::Text("--- Cache debug info ---"); uint32 bufferCacheHeapSize = 0; uint32 bufferCacheAllocationSize = 0; @@ -3739,7 +3739,7 @@ void VulkanRenderer::AppendOverlayDebugInfo() ImGui::SameLine(60.0f); ImGui::Text("%06uKB / %06uKB Buffers: %u", ((uint32)(totalSize - freeSize) + 1023) / 1024, ((uint32)totalSize + 1023) / 1024, (uint32)numBuffers); - memoryManager->getIndexAllocator().GetStats(numBuffers, totalSize, freeSize); + memoryManager->GetIndexAllocator().GetStats(numBuffers, totalSize, freeSize); ImGui::Text("Index"); ImGui::SameLine(60.0f); ImGui::Text("%06uKB / %06uKB Buffers: %u", ((uint32)(totalSize - freeSize) + 1023) / 1024, ((uint32)totalSize + 1023) / 1024, (uint32)numBuffers); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 52c1c6ed..5ef4558d 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -328,8 +328,9 @@ public: RendererShader* shader_create(RendererShader::ShaderType type, uint64 baseHash, uint64 auxHash, const std::string& source, bool isGameShader, bool isGfxPackShader) override; - void* indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) override; - void indexData_uploadIndexMemory(uint32 offset, uint32 size) override; + IndexAllocation indexData_reserveIndexMemory(uint32 size) override; + void indexData_releaseIndexMemory(IndexAllocation& allocation) override; + void indexData_uploadIndexMemory(IndexAllocation& allocation) override; // externally callable void GetTextureFormatInfoVK(Latte::E_GX2SURFFMT format, bool isDepth, Latte::E_DIM dim, sint32 width, sint32 height, FormatInfoVK* formatInfoOut); diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index dd39bd88..198a32cb 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -357,18 +357,20 @@ PipelineInfo* VulkanRenderer::draw_getOrCreateGraphicsPipeline(uint32 indexCount return draw_createGraphicsPipeline(indexCount); } -void* VulkanRenderer::indexData_reserveIndexMemory(uint32 size, uint32& offset, uint32& bufferIndex) +Renderer::IndexAllocation VulkanRenderer::indexData_reserveIndexMemory(uint32 size) { - auto& indexAllocator = this->memoryManager->getIndexAllocator(); - auto resv = indexAllocator.AllocateBufferMemory(size, 32); - offset = resv.bufferOffset; - bufferIndex = resv.bufferIndex; - return resv.memPtr; + VKRSynchronizedHeapAllocator::AllocatorReservation* resv = memoryManager->GetIndexAllocator().AllocateBufferMemory(size, 32); + return { resv->memPtr, resv }; } -void VulkanRenderer::indexData_uploadIndexMemory(uint32 offset, uint32 size) +void VulkanRenderer::indexData_releaseIndexMemory(IndexAllocation& allocation) { - // does nothing since the index buffer memory is coherent + memoryManager->GetIndexAllocator().FreeReservation((VKRSynchronizedHeapAllocator::AllocatorReservation*)allocation.rendererInternal); +} + +void VulkanRenderer::indexData_uploadIndexMemory(IndexAllocation& allocation) +{ + memoryManager->GetIndexAllocator().FlushReservation((VKRSynchronizedHeapAllocator::AllocatorReservation*)allocation.rendererInternal); } float s_vkUniformData[512 * 4]; @@ -1413,14 +1415,15 @@ void VulkanRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 uint32 hostIndexCount; uint32 indexMin = 0; uint32 indexMax = 0; - uint32 indexBufferOffset = 0; - uint32 indexBufferIndex = 0; - LatteIndices_decode(memory_getPointerFromVirtualOffset(indexDataMPTR), indexType, count, primitiveMode, indexMin, indexMax, hostIndexType, hostIndexCount, indexBufferOffset, indexBufferIndex); - + Renderer::IndexAllocation indexAllocation; + LatteIndices_decode(memory_getPointerFromVirtualOffset(indexDataMPTR), indexType, count, primitiveMode, indexMin, indexMax, hostIndexType, hostIndexCount, indexAllocation); + VKRSynchronizedHeapAllocator::AllocatorReservation* indexReservation = (VKRSynchronizedHeapAllocator::AllocatorReservation*)indexAllocation.rendererInternal; // update index binding bool isPrevIndexData = false; if (hostIndexType != INDEX_TYPE::NONE) { + uint32 indexBufferIndex = indexReservation->bufferIndex; + uint32 indexBufferOffset = indexReservation->bufferOffset; if (m_state.activeIndexBufferOffset != indexBufferOffset || m_state.activeIndexBufferIndex != indexBufferIndex || m_state.activeIndexType != hostIndexType) { m_state.activeIndexType = hostIndexType; @@ -1433,7 +1436,7 @@ void VulkanRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32 vkType = VK_INDEX_TYPE_UINT32; else cemu_assert(false); - vkCmdBindIndexBuffer(m_state.currentCommandBuffer, memoryManager->getIndexAllocator().GetBufferByIndex(indexBufferIndex), indexBufferOffset, vkType); + vkCmdBindIndexBuffer(m_state.currentCommandBuffer, indexReservation->vkBuffer, indexBufferOffset, vkType); } else isPrevIndexData = true; diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index d4df4343..3dfeaf74 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -274,6 +274,25 @@ inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, #define NOEXPORT __attribute__ ((visibility ("hidden"))) #endif +#if defined(_MSC_VER) +#define FORCE_INLINE __forceinline +#elif defined(__GNUC__) || defined(__clang__) +#define FORCE_INLINE inline __attribute__((always_inline)) +#else +#define FORCE_INLINE +#endif + +FORCE_INLINE inline int BSF(uint32 v) // returns index of first bit set, counting from LSB. If v is 0 then result is undefined +{ +#if defined(_MSC_VER) + return _tzcnt_u32(v); // TZCNT requires BMI1. But if not supported it will execute as BSF +#elif defined(__GNUC__) || defined(__clang__) + return __builtin_ctz(v); +#else + return std::countr_zero(v); +#endif +} + // On aarch64 we handle some of the x86 intrinsics by implementing them as wrappers #if defined(__aarch64__) diff --git a/src/util/ChunkedHeap/ChunkedHeap.h b/src/util/ChunkedHeap/ChunkedHeap.h index abc45429..21a1b868 100644 --- a/src/util/ChunkedHeap/ChunkedHeap.h +++ b/src/util/ChunkedHeap/ChunkedHeap.h @@ -1,35 +1,39 @@ #pragma once +#include <util/helpers/MemoryPool.h> + struct CHAddr { uint32 offset; uint32 chunkIndex; + void* internal; // AllocRange - CHAddr(uint32 _offset, uint32 _chunkIndex) : offset(_offset), chunkIndex(_chunkIndex) {}; + CHAddr(uint32 _offset, uint32 _chunkIndex, void* internal = nullptr) : offset(_offset), chunkIndex(_chunkIndex), internal(internal) {}; CHAddr() : offset(0xFFFFFFFF), chunkIndex(0xFFFFFFFF) {}; bool isValid() { return chunkIndex != 0xFFFFFFFF; }; static CHAddr getInvalid() { return CHAddr(0xFFFFFFFF, 0xFFFFFFFF); }; }; +template<uint32 TMinimumAlignment = 32> class ChunkedHeap { - struct allocRange_t + struct AllocRange { - allocRange_t* nextFree{}; - allocRange_t* prevFree{}; - allocRange_t* prevOrdered{}; - allocRange_t* nextOrdered{}; + AllocRange* nextFree{}; + AllocRange* prevFree{}; + AllocRange* prevOrdered{}; + AllocRange* nextOrdered{}; uint32 offset; uint32 chunkIndex; uint32 size; bool isFree; - allocRange_t(uint32 _offset, uint32 _chunkIndex, uint32 _size, bool _isFree) : offset(_offset), chunkIndex(_chunkIndex), size(_size), isFree(_isFree), nextFree(nullptr) {}; + AllocRange(uint32 _offset, uint32 _chunkIndex, uint32 _size, bool _isFree) : offset(_offset), chunkIndex(_chunkIndex), size(_size), isFree(_isFree), nextFree(nullptr) {}; }; - struct chunk_t + struct Chunk { - std::unordered_map<uint32, allocRange_t*> map_allocatedRange; + uint32 size; }; public: @@ -47,45 +51,32 @@ public: _free(addr); } - virtual uint32 allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) - { - return 0; - } + virtual uint32 allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) = 0; private: unsigned ulog2(uint32 v) { - static const unsigned MUL_DE_BRUIJN_BIT[] = - { - 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, - 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 - }; - - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - - return MUL_DE_BRUIJN_BIT[(v * 0x07C4ACDDu) >> 27]; + cemu_assert_debug(v != 0); + return 31 - std::countl_zero(v); } - void trackFreeRange(allocRange_t* range) + void trackFreeRange(AllocRange* range) { // get index of msb cemu_assert_debug(range->size != 0); // size of zero is not allowed uint32 bucketIndex = ulog2(range->size); - range->nextFree = bucketFreeRange[bucketIndex]; - if (bucketFreeRange[bucketIndex]) - bucketFreeRange[bucketIndex]->prevFree = range; + range->nextFree = m_bucketFreeRange[bucketIndex]; + if (m_bucketFreeRange[bucketIndex]) + m_bucketFreeRange[bucketIndex]->prevFree = range; range->prevFree = nullptr; - bucketFreeRange[bucketIndex] = range; + m_bucketFreeRange[bucketIndex] = range; + m_bucketUseMask |= (1u << bucketIndex); } - void forgetFreeRange(allocRange_t* range, uint32 bucketIndex) + void forgetFreeRange(AllocRange* range, uint32 bucketIndex) { - allocRange_t* prevRange = range->prevFree; - allocRange_t* nextRange = range->nextFree; + AllocRange* prevRange = range->prevFree; + AllocRange* nextRange = range->nextFree; if (prevRange) { prevRange->nextFree = nextRange; @@ -94,36 +85,42 @@ private: } else { - if (bucketFreeRange[bucketIndex] != range) - assert_dbg(); - bucketFreeRange[bucketIndex] = nextRange; + cemu_assert_debug(m_bucketFreeRange[bucketIndex] == range); + m_bucketFreeRange[bucketIndex] = nextRange; if (nextRange) nextRange->prevFree = nullptr; + else + m_bucketUseMask &= ~(1u << bucketIndex); } } bool allocateChunk(uint32 minimumAllocationSize) { - uint32 chunkIndex = (uint32)list_chunks.size(); - list_chunks.emplace_back(new chunk_t()); + uint32 chunkIndex = (uint32)m_chunks.size(); + m_chunks.emplace_back(); uint32 chunkSize = allocateNewChunk(chunkIndex, minimumAllocationSize); + cemu_assert_debug((chunkSize%TMinimumAlignment) == 0); // chunk size should be a multiple of the minimum alignment if (chunkSize == 0) return false; - allocRange_t* range = new allocRange_t(0, chunkIndex, chunkSize, true); + cemu_assert_debug(chunkSize < 0x80000000u); // chunk size must be below 2GB + AllocRange* range = m_allocEntriesPool.allocObj(0, chunkIndex, chunkSize, true); trackFreeRange(range); - numHeapBytes += chunkSize; + m_numHeapBytes += chunkSize; return true; } - void _allocFrom(allocRange_t* range, uint32 bucketIndex, uint32 allocOffset, uint32 allocSize) + void _allocFrom(AllocRange* range, uint32 bucketIndex, uint32 allocOffset, uint32 allocSize) { + cemu_assert_debug(allocSize > 0); // remove the range from the chain of free ranges forgetFreeRange(range, bucketIndex); // split head, allocation and tail into separate ranges - if (allocOffset > range->offset) + uint32 headBytes = allocOffset - range->offset; + if (headBytes > 0) { // alignment padding -> create free range - allocRange_t* head = new allocRange_t(range->offset, range->chunkIndex, allocOffset - range->offset, true); + cemu_assert_debug(headBytes >= TMinimumAlignment); + AllocRange* head = m_allocEntriesPool.allocObj(range->offset, range->chunkIndex, headBytes, true); trackFreeRange(head); if (range->prevOrdered) range->prevOrdered->nextOrdered = head; @@ -131,10 +128,12 @@ private: head->nextOrdered = range; range->prevOrdered = head; } - if ((allocOffset + allocSize) < (range->offset + range->size)) // todo - create only if it's more than a couple of bytes? + uint32 tailBytes = (range->offset + range->size) - (allocOffset + allocSize); + if (tailBytes > 0) { // tail -> create free range - allocRange_t* tail = new allocRange_t((allocOffset + allocSize), range->chunkIndex, (range->offset + range->size) - (allocOffset + allocSize), true); + cemu_assert_debug(tailBytes >= TMinimumAlignment); + AllocRange* tail = m_allocEntriesPool.allocObj((allocOffset + allocSize), range->chunkIndex, tailBytes, true); trackFreeRange(tail); if (range->nextOrdered) range->nextOrdered->prevOrdered = tail; @@ -149,36 +148,51 @@ private: CHAddr _alloc(uint32 size, uint32 alignment) { + cemu_assert_debug(size <= (0x7FFFFFFFu-TMinimumAlignment)); + // make sure size is not zero and align it + if(size == 0) [[unlikely]] + size = TMinimumAlignment; + else + size = (size + (TMinimumAlignment - 1)) & ~(TMinimumAlignment - 1); // find smallest bucket to scan uint32 alignmentM1 = alignment - 1; uint32 bucketIndex = ulog2(size); - while (bucketIndex < 32) + // check if the bucket is available + if( !(m_bucketUseMask & (1u << bucketIndex)) ) { - allocRange_t* range = bucketFreeRange[bucketIndex]; + // skip to next non-empty bucket + uint32 nextIndex = BSF(m_bucketUseMask>>bucketIndex); + bucketIndex += nextIndex; + } + while (bucketIndex < 31) + { + AllocRange* range = m_bucketFreeRange[bucketIndex]; while (range) { if (range->size >= size) { // verify if aligned allocation fits uint32 alignedOffset = (range->offset + alignmentM1) & ~alignmentM1; - uint32 alignmentLoss = alignedOffset - range->offset; - if (alignmentLoss < range->size && (range->size - alignmentLoss) >= size) + uint32 endOffset = alignedOffset + size; + if((range->offset+range->size) >= endOffset) { _allocFrom(range, bucketIndex, alignedOffset, size); - list_chunks[range->chunkIndex]->map_allocatedRange.emplace(alignedOffset, range); - numAllocatedBytes += size; - return CHAddr(alignedOffset, range->chunkIndex); + m_numAllocatedBytes += size; + return CHAddr(alignedOffset, range->chunkIndex, range); } } range = range->nextFree; } - bucketIndex++; // try higher bucket + // check next non-empty bucket or skip to end + bucketIndex++; + uint32 emptyBuckets = BSF(m_bucketUseMask>>bucketIndex); + bucketIndex += emptyBuckets; } - if(allocationLimitReached) + if(m_allocationLimitReached) return CHAddr(0xFFFFFFFF, 0xFFFFFFFF); if (!allocateChunk(size)) { - allocationLimitReached = true; + m_allocationLimitReached = true; return CHAddr(0xFFFFFFFF, 0xFFFFFFFF); } return _alloc(size, alignment); @@ -186,24 +200,16 @@ private: void _free(CHAddr addr) { - auto it = list_chunks[addr.chunkIndex]->map_allocatedRange.find(addr.offset); - if (it == list_chunks[addr.chunkIndex]->map_allocatedRange.end()) + if(!addr.internal) { cemuLog_log(LogType::Force, "Internal heap error. {:08x} {:08x}", addr.chunkIndex, addr.offset); - cemuLog_log(LogType::Force, "Debug info:"); - for (auto& rangeItr : list_chunks[addr.chunkIndex]->map_allocatedRange) - { - cemuLog_log(LogType::Force, "{:08x} {:08x}", rangeItr.second->offset, rangeItr.second->size); - } return; } - - allocRange_t* range = it->second; - numAllocatedBytes -= it->second->size; - list_chunks[range->chunkIndex]->map_allocatedRange.erase(it); + AllocRange* range = (AllocRange*)addr.internal; + m_numAllocatedBytes -= range->size; // try merge left or right - allocRange_t* prevRange = range->prevOrdered; - allocRange_t* nextRange = range->nextOrdered; + AllocRange* prevRange = range->prevOrdered; + AllocRange* nextRange = range->nextOrdered; if (prevRange && prevRange->isFree) { if (nextRange && nextRange->isFree) @@ -216,8 +222,8 @@ private: forgetFreeRange(prevRange, ulog2(prevRange->size)); prevRange->size = newSize; trackFreeRange(prevRange); - delete range; - delete nextRange; + m_allocEntriesPool.freeObj(range); + m_allocEntriesPool.freeObj(nextRange); } else { @@ -228,7 +234,7 @@ private: forgetFreeRange(prevRange, ulog2(prevRange->size)); prevRange->size = newSize; trackFreeRange(prevRange); - delete range; + m_allocEntriesPool.freeObj(range); } } else if (nextRange && nextRange->isFree) @@ -242,7 +248,7 @@ private: range->prevOrdered->nextOrdered = nextRange; nextRange->prevOrdered = range->prevOrdered; trackFreeRange(nextRange); - delete range; + m_allocEntriesPool.freeObj(range); } else { @@ -265,7 +271,7 @@ private: for (uint32 i = 0; i < 32; i++) { - allocRange_t* ar = bucketFreeRange[i]; + AllocRange* ar = m_bucketFreeRange[i]; while (ar) { availableRange_t dbgRange; @@ -278,7 +284,7 @@ private: if (itr.chunkIndex != dbgRange.chunkIndex) continue; if (itr.offset < (dbgRange.offset + dbgRange.size) && (itr.offset + itr.size) >(dbgRange.offset)) - assert_dbg(); + cemu_assert_error(); } availRanges.emplace_back(dbgRange); @@ -290,14 +296,16 @@ private: } private: - std::vector<chunk_t*> list_chunks; - allocRange_t* bucketFreeRange[32]{}; - bool allocationLimitReached = false; + std::vector<Chunk> m_chunks; + uint32 m_bucketUseMask{0x80000000}; // bitmask indicating non-empty buckets. MSB always set to provide an upper bound for BSF instruction + AllocRange* m_bucketFreeRange[32]{}; // we are only using 31 entries since the MSB is reserved (thus chunks equal or larger than 2^31 are not allowed) + bool m_allocationLimitReached = false; + MemoryPool<AllocRange> m_allocEntriesPool{64}; public: // statistics - uint32 numHeapBytes{}; // total size of the heap - uint32 numAllocatedBytes{}; + uint32 m_numHeapBytes{}; // total size of the heap + uint32 m_numAllocatedBytes{}; }; class VGenericHeap @@ -633,7 +641,7 @@ public: uint32 getCurrentBlockOffset() const { return m_currentBlockOffset; } uint8* getCurrentBlockPtr() const { return m_currentBlockPtr; } - + private: void allocateAdditionalChunk() { From 0a5908502147c9d35189bdbfe38ba6d5bebd0f76 Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Sun, 12 Jan 2025 13:33:24 +0000 Subject: [PATCH 298/314] nsyshid: Make Libusb the Windows backend (#1471) --- CMakeLists.txt | 17 - src/Cafe/CMakeLists.txt | 21 +- .../OS/libs/nsyshid/AttachDefaultBackends.cpp | 23 - src/Cafe/OS/libs/nsyshid/Backend.h | 36 +- src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 186 +++++--- src/Cafe/OS/libs/nsyshid/BackendLibusb.h | 25 +- .../OS/libs/nsyshid/BackendWindowsHID.cpp | 444 ------------------ src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h | 66 --- src/Cafe/OS/libs/nsyshid/Dimensions.cpp | 9 +- src/Cafe/OS/libs/nsyshid/Dimensions.h | 6 +- src/Cafe/OS/libs/nsyshid/Infinity.cpp | 11 +- src/Cafe/OS/libs/nsyshid/Infinity.h | 8 +- src/Cafe/OS/libs/nsyshid/Skylander.cpp | 21 +- src/Cafe/OS/libs/nsyshid/Skylander.h | 8 +- src/Cafe/OS/libs/nsyshid/nsyshid.cpp | 304 ++++++++---- 15 files changed, 412 insertions(+), 773 deletions(-) delete mode 100644 src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp delete mode 100644 src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2352389e..560728f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,23 +124,6 @@ if (WIN32) endif() option(ENABLE_CUBEB "Enabled cubeb backend" ON) -# usb hid backends -if (WIN32) - option(ENABLE_NSYSHID_WINDOWS_HID "Enables the native Windows HID backend for nsyshid" ON) -endif () -# libusb and windows hid backends shouldn't be active at the same time; otherwise we'd see all devices twice! -if (NOT ENABLE_NSYSHID_WINDOWS_HID) - option(ENABLE_NSYSHID_LIBUSB "Enables the libusb backend for nsyshid" ON) -else () - set(ENABLE_NSYSHID_LIBUSB OFF CACHE BOOL "" FORCE) -endif () -if (ENABLE_NSYSHID_WINDOWS_HID) - add_compile_definitions(NSYSHID_ENABLE_BACKEND_WINDOWS_HID) -endif () -if (ENABLE_NSYSHID_LIBUSB) - add_compile_definitions(NSYSHID_ENABLE_BACKEND_LIBUSB) -endif () - option(ENABLE_WXWIDGETS "Build with wxWidgets UI (Currently required)" ON) set(THREADS_PREFER_PTHREAD_FLAG true) diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 76dba007..d51d58d5 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -463,8 +463,6 @@ add_library(CemuCafe OS/libs/nsyshid/BackendEmulated.h OS/libs/nsyshid/BackendLibusb.cpp OS/libs/nsyshid/BackendLibusb.h - OS/libs/nsyshid/BackendWindowsHID.cpp - OS/libs/nsyshid/BackendWindowsHID.h OS/libs/nsyshid/Dimensions.cpp OS/libs/nsyshid/Dimensions.h OS/libs/nsyshid/Infinity.cpp @@ -569,15 +567,16 @@ if (ENABLE_WAYLAND) target_link_libraries(CemuCafe PUBLIC Wayland::Client) endif() -if (ENABLE_NSYSHID_LIBUSB) - if (ENABLE_VCPKG) - find_package(PkgConfig REQUIRED) - pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) - target_link_libraries(CemuCafe PRIVATE PkgConfig::libusb) - else () - find_package(libusb MODULE REQUIRED) - target_link_libraries(CemuCafe PRIVATE libusb::libusb) - endif () +if (ENABLE_VCPKG) + if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${VCPKG_INSTALLED_DIR}/x64-windows/tools/pkgconf/pkgconf.exe") + endif() + find_package(PkgConfig REQUIRED) + pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0) + target_link_libraries(CemuCafe PRIVATE PkgConfig::libusb) +else () + find_package(libusb MODULE REQUIRED) + target_link_libraries(CemuCafe PRIVATE libusb::libusb) endif () if (ENABLE_WXWIDGETS) diff --git a/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp index fc8e496c..67eb0240 100644 --- a/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp +++ b/src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp @@ -1,24 +1,12 @@ #include "nsyshid.h" #include "Backend.h" #include "BackendEmulated.h" - -#if NSYSHID_ENABLE_BACKEND_LIBUSB - #include "BackendLibusb.h" -#endif - -#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID - -#include "BackendWindowsHID.h" - -#endif - namespace nsyshid::backend { void AttachDefaultBackends() { -#if NSYSHID_ENABLE_BACKEND_LIBUSB // add libusb backend { auto backendLibusb = std::make_shared<backend::libusb::BackendLibusb>(); @@ -27,17 +15,6 @@ namespace nsyshid::backend AttachBackend(backendLibusb); } } -#endif // NSYSHID_ENABLE_BACKEND_LIBUSB -#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID - // add windows hid backend - { - auto backendWindowsHID = std::make_shared<backend::windows::BackendWindowsHID>(); - if (backendWindowsHID->IsInitialisedOk()) - { - AttachBackend(backendWindowsHID); - } - } -#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID // add emulated backend { auto backendEmulated = std::make_shared<backend::emulated::BackendEmulated>(); diff --git a/src/Cafe/OS/libs/nsyshid/Backend.h b/src/Cafe/OS/libs/nsyshid/Backend.h index 12362773..67dad4fe 100644 --- a/src/Cafe/OS/libs/nsyshid/Backend.h +++ b/src/Cafe/OS/libs/nsyshid/Backend.h @@ -1,5 +1,4 @@ -#ifndef CEMU_NSYSHID_BACKEND_H -#define CEMU_NSYSHID_BACKEND_H +#pragma once #include <list> #include <memory> @@ -26,9 +25,9 @@ namespace nsyshid struct TransferCommand { uint8* data; - sint32 length; + uint32 length; - TransferCommand(uint8* data, sint32 length) + TransferCommand(uint8* data, uint32 length) : data(data), length(length) { } @@ -39,7 +38,7 @@ namespace nsyshid { sint32 bytesRead; - ReadMessage(uint8* data, sint32 length, sint32 bytesRead) + ReadMessage(uint8* data, uint32 length, sint32 bytesRead) : bytesRead(bytesRead), TransferCommand(data, length) { } @@ -50,7 +49,7 @@ namespace nsyshid { sint32 bytesWritten; - WriteMessage(uint8* data, sint32 length, sint32 bytesWritten) + WriteMessage(uint8* data, uint32 length, sint32 bytesWritten) : bytesWritten(bytesWritten), TransferCommand(data, length) { } @@ -59,14 +58,11 @@ namespace nsyshid struct ReportMessage final : TransferCommand { - uint8* reportData; - sint32 length; - uint8* originalData; - sint32 originalLength; + uint8 reportType; + uint8 reportId; - ReportMessage(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) - : reportData(reportData), length(length), originalData(originalData), - originalLength(originalLength), TransferCommand(reportData, length) + ReportMessage(uint8 reportType, uint8 reportId, uint8* data, uint32 length) + : reportType(reportType), reportId(reportId), TransferCommand(data, length) { } using TransferCommand::TransferCommand; @@ -77,7 +73,8 @@ namespace nsyshid static_assert(offsetof(HID_t, ifIndex) == 0xC, ""); static_assert(offsetof(HID_t, protocol) == 0xE, ""); - class Device { + class Device + { public: Device() = delete; @@ -131,16 +128,21 @@ namespace nsyshid virtual bool GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) = 0; + virtual bool SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) = 0; + virtual bool SetProtocol(uint8 ifIndex, uint8 protocol) = 0; virtual bool SetReport(ReportMessage* message) = 0; }; - class Backend { + class Backend + { public: Backend(); @@ -188,5 +190,3 @@ namespace nsyshid void AttachDefaultBackends(); } } // namespace nsyshid - -#endif // CEMU_NSYSHID_BACKEND_H diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp index ab355136..a7deef90 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -1,7 +1,5 @@ #include "BackendLibusb.h" -#if NSYSHID_ENABLE_BACKEND_LIBUSB - namespace nsyshid::backend::libusb { BackendLibusb::BackendLibusb() @@ -16,7 +14,7 @@ namespace nsyshid::backend::libusb { m_ctx = nullptr; cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb: failed to initialize libusb, return code: {}", - m_initReturnCode); + m_initReturnCode); return; } @@ -35,8 +33,8 @@ namespace nsyshid::backend::libusb if (ret != LIBUSB_SUCCESS) { cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb: failed to register hotplug callback with return code {}", - ret); + "nsyshid::BackendLibusb: failed to register hotplug callback with return code {}", + ret); } else { @@ -53,8 +51,8 @@ namespace nsyshid::backend::libusb if (ret != 0) { cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb: hotplug thread: error handling events: {}", - ret); + "nsyshid::BackendLibusb: hotplug thread: error handling events: {}", + ret); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } } @@ -139,8 +137,8 @@ namespace nsyshid::backend::libusb case LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED: { cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb::OnHotplug(): device arrived: {:04x}:{:04x}", - desc.idVendor, - desc.idProduct); + desc.idVendor, + desc.idProduct); auto device = CheckAndCreateDevice(dev); if (device != nullptr) { @@ -167,8 +165,8 @@ namespace nsyshid::backend::libusb case LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT: { cemuLog_logDebug(LogType::Force, "nsyshid::BackendLibusb::OnHotplug(): device left: {:04x}:{:04x}", - desc.idVendor, - desc.idProduct); + desc.idVendor, + desc.idProduct); auto device = FindLibusbDevice(dev); if (device != nullptr) { @@ -204,7 +202,7 @@ namespace nsyshid::backend::libusb if (ret < 0) { cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb::FindLibusbDevice(): failed to get device descriptor"); + "nsyshid::BackendLibusb::FindLibusbDevice(): failed to get device descriptor"); return nullptr; } uint8 busNumber = libusb_get_bus_number(dev); @@ -269,7 +267,7 @@ namespace nsyshid::backend::libusb if (desc.idVendor == 0x0e6f && desc.idProduct == 0x0241) { cemuLog_logDebug(LogType::Force, - "nsyshid::BackendLibusb::CheckAndCreateDevice(): lego dimensions portal detected"); + "nsyshid::BackendLibusb::CheckAndCreateDevice(): lego dimensions portal detected"); } auto device = std::make_shared<DeviceLibusb>(m_ctx, desc.idVendor, @@ -446,12 +444,13 @@ namespace nsyshid::backend::libusb } this->m_handleInUseCounter = 0; } + + int ret = ClaimAllInterfaces(0); + + if (ret != 0) { - int ret = ClaimAllInterfaces(0); - if (ret != 0) - { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::open(): cannot claim interface"); - } + cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::open(): cannot claim interface for config 0"); + return false; } } @@ -475,7 +474,7 @@ namespace nsyshid::backend::libusb { m_handleInUseCounterDecremented.wait(lock); } - libusb_release_interface(handle, 0); + ReleaseAllInterfacesForCurrentConfig(); libusb_close(handle); m_handleInUseCounter = -1; m_handleInUseCounterDecremented.notify_all(); @@ -493,21 +492,26 @@ namespace nsyshid::backend::libusb if (!handleLock->IsValid()) { cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::read(): cannot read from a non-opened device\n"); + "nsyshid::DeviceLibusb::read(): cannot read from a non-opened device\n"); return ReadResult::Error; } + for (int i = 0; i < m_config_descriptors.size(); i++) + { + ClaimAllInterfaces(i); + } + const unsigned int timeout = 50; int actualLength = 0; int ret = 0; do { - ret = libusb_bulk_transfer(handleLock->GetHandle(), - this->m_libusbEndpointIn, - message->data, - message->length, - &actualLength, - timeout); + ret = libusb_interrupt_transfer(handleLock->GetHandle(), + this->m_libusbEndpointIn, + message->data, + message->length, + &actualLength, + timeout); } while (ret == LIBUSB_ERROR_TIMEOUT && actualLength == 0 && IsOpened()); @@ -521,8 +525,8 @@ namespace nsyshid::backend::libusb return ReadResult::Success; } cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::read(): failed with error code: {}", - ret); + "nsyshid::DeviceLibusb::read(): failed at endpoint 0x{:02x} with error message: {}", this->m_libusbEndpointIn, + libusb_error_name(ret)); return ReadResult::Error; } @@ -532,18 +536,23 @@ namespace nsyshid::backend::libusb if (!handleLock->IsValid()) { cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::write(): cannot write to a non-opened device\n"); + "nsyshid::DeviceLibusb::write(): cannot write to a non-opened device\n"); return WriteResult::Error; } + for (int i = 0; i < m_config_descriptors.size(); i++) + { + ClaimAllInterfaces(i); + } + message->bytesWritten = 0; int actualLength = 0; - int ret = libusb_bulk_transfer(handleLock->GetHandle(), - this->m_libusbEndpointOut, - message->data, - message->length, - &actualLength, - 0); + int ret = libusb_interrupt_transfer(handleLock->GetHandle(), + this->m_libusbEndpointOut, + message->data, + message->length, + &actualLength, + 0); if (ret == 0) { @@ -556,14 +565,14 @@ namespace nsyshid::backend::libusb return WriteResult::Success; } cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::write(): failed with error code: {}", - ret); + "nsyshid::DeviceLibusb::write(): failed with error code: {}", + ret); return WriteResult::Error; } bool DeviceLibusb::GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) { @@ -579,7 +588,6 @@ namespace nsyshid::backend::libusb struct libusb_config_descriptor* conf = nullptr; libusb_device* dev = libusb_get_device(handleLock->GetHandle()); int ret = libusb_get_active_config_descriptor(dev, &conf); - if (ret == 0) { std::vector<uint8> configurationDescriptor(conf->wTotalLength); @@ -656,7 +664,6 @@ namespace nsyshid::backend::libusb extraReadPointer += bLength; } } - for (int endpointIndex = 0; endpointIndex < altsetting.bNumEndpoints; endpointIndex++) { // endpoint descriptor @@ -681,24 +688,61 @@ namespace nsyshid::backend::libusb uint32 bytesWritten = currentWritePtr - &configurationDescriptor[0]; libusb_free_config_descriptor(conf); cemu_assert_debug(bytesWritten <= conf->wTotalLength); - memcpy(output, &configurationDescriptor[0], std::min<uint32>(outputMaxLength, bytesWritten)); return true; } - else - { - cemuLog_logDebug(LogType::Force, - "nsyshid::DeviceLibusb::getDescriptor(): failed to get config descriptor with error code: {}", - ret); - return false; - } } else { - cemu_assert_unimplemented(); + uint16 wValue = uint16(descType) << 8 | uint16(descIndex); + // HID Get_Descriptor requests are handled via libusb_control_transfer + int ret = libusb_control_transfer(handleLock->GetHandle(), + LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_ENDPOINT_IN, + LIBUSB_REQUEST_GET_DESCRIPTOR, + wValue, + lang, + output, + outputMaxLength, + 0); + if (ret != outputMaxLength) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::GetDescriptor(): Control Transfer Failed: {}", libusb_error_name(ret)); + return false; + } } - return false; + return true; + } + + bool DeviceLibusb::SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) + { + auto handleLock = AquireHandleLock(); + if (!handleLock->IsValid()) + { + cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetIdle(): device is not opened"); + return false; + } + + uint16 wValue = uint16(duration) << 8 | uint16(reportId); + + // HID Set_Idle requests are handled via libusb_control_transfer + int ret = libusb_control_transfer(handleLock->GetHandle(), + LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT, + HID_CLASS_SET_IDLE, // Defined in HID Class Specific Requests (7.2) + wValue, + ifIndex, + nullptr, + 0, + 0); + + if (ret != 0) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetIdle(): Control Transfer Failed: {}", libusb_error_name(ret)); + return false; + } + return true; } template<typename Configs, typename Function> @@ -767,18 +811,22 @@ namespace nsyshid::backend::libusb cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetProtocol(): device is not opened"); return false; } - if (m_interfaceIndex != ifIndex) - m_interfaceIndex = ifIndex; - ReleaseAllInterfacesForCurrentConfig(); - int ret = libusb_set_configuration(AquireHandleLock()->GetHandle(), protocol); - if (ret == LIBUSB_SUCCESS) - ret = ClaimAllInterfaces(protocol); + int ret = libusb_control_transfer(handleLock->GetHandle(), + LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT, + HID_CLASS_SET_PROTOCOL, // Defined in HID Class Specific Requests (7.2) + protocol, + ifIndex, + nullptr, + 0, + 0); - if (ret == LIBUSB_SUCCESS) - return true; - - return false; + if (ret != 0) + { + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetProtocol(): Control Transfer Failed: {}", libusb_error_name(ret)); + return false; + } + return true; } bool DeviceLibusb::SetReport(ReportMessage* message) @@ -790,18 +838,20 @@ namespace nsyshid::backend::libusb return false; } + uint16 wValue = uint16(message->reportType) << 8 | uint16(message->reportId); + int ret = libusb_control_transfer(handleLock->GetHandle(), LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE | LIBUSB_ENDPOINT_OUT, - LIBUSB_REQUEST_SET_CONFIGURATION, - 512, - 0, - message->originalData, - message->originalLength, + HID_CLASS_SET_REPORT, // Defined in HID Class Specific Requests (7.2) + wValue, + m_interfaceIndex, + message->data, + uint16(message->length & 0xFFFF), 0); - if (ret != message->originalLength) + if (ret != message->length) { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): Control Transfer Failed: {}", libusb_error_name(ret)); + cemuLog_logDebug(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): Control Transfer Failed at interface {} : {}", m_interfaceIndex, libusb_error_name(ret)); return false; } return true; @@ -854,5 +904,3 @@ namespace nsyshid::backend::libusb return m_handle; } } // namespace nsyshid::backend::libusb - -#endif // NSYSHID_ENABLE_BACKEND_LIBUSB diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h index a7b23769..6b2d8e1a 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.h +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.h @@ -1,15 +1,20 @@ -#ifndef CEMU_NSYSHID_BACKEND_LIBUSB_H -#define CEMU_NSYSHID_BACKEND_LIBUSB_H - #include "nsyshid.h" -#if NSYSHID_ENABLE_BACKEND_LIBUSB - #include <libusb-1.0/libusb.h> #include "Backend.h" namespace nsyshid::backend::libusb { + enum : uint8 + { + HID_CLASS_GET_REPORT = 0x01, + HID_CLASS_GET_IDLE = 0x02, + HID_CLASS_GET_PROTOCOL = 0x03, + HID_CLASS_SET_REPORT = 0x09, + HID_CLASS_SET_IDLE = 0x0A, + HID_CLASS_SET_PROTOCOL = 0x0B + }; + class BackendLibusb : public nsyshid::Backend { public: BackendLibusb(); @@ -75,10 +80,14 @@ namespace nsyshid::backend::libusb bool GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) override; + bool SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; int ClaimAllInterfaces(uint8 config_num); @@ -134,7 +143,3 @@ namespace nsyshid::backend::libusb std::unique_ptr<HandleLock> AquireHandleLock(); }; } // namespace nsyshid::backend::libusb - -#endif // NSYSHID_ENABLE_BACKEND_LIBUSB - -#endif // CEMU_NSYSHID_BACKEND_LIBUSB_H diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp deleted file mode 100644 index 267111b2..00000000 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.cpp +++ /dev/null @@ -1,444 +0,0 @@ -#include "BackendWindowsHID.h" - -#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID - -#include <setupapi.h> -#include <initguid.h> -#include <hidsdi.h> - -#pragma comment(lib, "Setupapi.lib") -#pragma comment(lib, "hid.lib") - -DEFINE_GUID(GUID_DEVINTERFACE_HID, - 0x4D1E55B2L, 0xF16F, 0x11CF, 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30); - -namespace nsyshid::backend::windows -{ - BackendWindowsHID::BackendWindowsHID() - { - } - - void BackendWindowsHID::AttachVisibleDevices() - { - // add all currently connected devices - HDEVINFO hDevInfo; - SP_DEVICE_INTERFACE_DATA DevIntfData; - PSP_DEVICE_INTERFACE_DETAIL_DATA DevIntfDetailData; - SP_DEVINFO_DATA DevData; - - DWORD dwSize, dwMemberIdx; - - hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, NULL, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); - - if (hDevInfo != INVALID_HANDLE_VALUE) - { - DevIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - dwMemberIdx = 0; - - SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, - dwMemberIdx, &DevIntfData); - - while (GetLastError() != ERROR_NO_MORE_ITEMS) - { - DevData.cbSize = sizeof(DevData); - SetupDiGetDeviceInterfaceDetail( - hDevInfo, &DevIntfData, NULL, 0, &dwSize, NULL); - - DevIntfDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - dwSize); - DevIntfDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - - if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &DevIntfData, - DevIntfDetailData, dwSize, &dwSize, &DevData)) - { - HANDLE hHIDDevice = OpenDevice(DevIntfDetailData->DevicePath); - if (hHIDDevice != INVALID_HANDLE_VALUE) - { - auto device = CheckAndCreateDevice(DevIntfDetailData->DevicePath, hHIDDevice); - if (device != nullptr) - { - if (IsDeviceWhitelisted(device->m_vendorId, device->m_productId)) - { - if (!AttachDevice(device)) - { - cemuLog_log(LogType::Force, - "nsyshid::BackendWindowsHID: failed to attach device: {:04x}:{:04x}", - device->m_vendorId, - device->m_productId); - } - } - } - CloseHandle(hHIDDevice); - } - } - HeapFree(GetProcessHeap(), 0, DevIntfDetailData); - // next - SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_DEVINTERFACE_HID, ++dwMemberIdx, &DevIntfData); - } - SetupDiDestroyDeviceInfoList(hDevInfo); - } - } - - BackendWindowsHID::~BackendWindowsHID() - { - } - - bool BackendWindowsHID::IsInitialisedOk() - { - return true; - } - - std::shared_ptr<Device> BackendWindowsHID::CheckAndCreateDevice(wchar_t* devicePath, HANDLE hDevice) - { - HIDD_ATTRIBUTES hidAttr; - hidAttr.Size = sizeof(HIDD_ATTRIBUTES); - if (HidD_GetAttributes(hDevice, &hidAttr) == FALSE) - return nullptr; - - auto device = std::make_shared<DeviceWindowsHID>(hidAttr.VendorID, - hidAttr.ProductID, - 1, - 2, - 0, - _wcsdup(devicePath)); - // get additional device info - sint32 maxPacketInputLength = -1; - sint32 maxPacketOutputLength = -1; - PHIDP_PREPARSED_DATA ppData = nullptr; - if (HidD_GetPreparsedData(hDevice, &ppData)) - { - HIDP_CAPS caps; - if (HidP_GetCaps(ppData, &caps) == HIDP_STATUS_SUCCESS) - { - // length includes the report id byte - maxPacketInputLength = caps.InputReportByteLength - 1; - maxPacketOutputLength = caps.OutputReportByteLength - 1; - } - HidD_FreePreparsedData(ppData); - } - if (maxPacketInputLength <= 0 || maxPacketInputLength >= 0xF000) - { - cemuLog_logDebug(LogType::Force, "HID: Input packet length not available or out of range (length = {})", maxPacketInputLength); - maxPacketInputLength = 0x20; - } - if (maxPacketOutputLength <= 0 || maxPacketOutputLength >= 0xF000) - { - cemuLog_logDebug(LogType::Force, "HID: Output packet length not available or out of range (length = {})", maxPacketOutputLength); - maxPacketOutputLength = 0x20; - } - - device->m_maxPacketSizeRX = maxPacketInputLength; - device->m_maxPacketSizeTX = maxPacketOutputLength; - - return device; - } - - DeviceWindowsHID::DeviceWindowsHID(uint16 vendorId, - uint16 productId, - uint8 interfaceIndex, - uint8 interfaceSubClass, - uint8 protocol, - wchar_t* devicePath) - : Device(vendorId, - productId, - interfaceIndex, - interfaceSubClass, - protocol), - m_devicePath(devicePath), - m_hFile(INVALID_HANDLE_VALUE) - { - } - - DeviceWindowsHID::~DeviceWindowsHID() - { - if (m_hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(m_hFile); - m_hFile = INVALID_HANDLE_VALUE; - } - } - - bool DeviceWindowsHID::Open() - { - if (IsOpened()) - { - return true; - } - m_hFile = OpenDevice(m_devicePath); - if (m_hFile == INVALID_HANDLE_VALUE) - { - return false; - } - HidD_SetNumInputBuffers(m_hFile, 2); // don't cache too many reports - return true; - } - - void DeviceWindowsHID::Close() - { - if (m_hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(m_hFile); - m_hFile = INVALID_HANDLE_VALUE; - } - } - - bool DeviceWindowsHID::IsOpened() - { - return m_hFile != INVALID_HANDLE_VALUE; - } - - Device::ReadResult DeviceWindowsHID::Read(ReadMessage* message) - { - message->bytesRead = 0; - DWORD bt; - OVERLAPPED ovlp = {0}; - ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - uint8* tempBuffer = (uint8*)malloc(message->length + 1); - sint32 transferLength = 0; // minus report byte - - _debugPrintHex("HID_READ_BEFORE", message->data, message->length); - - cemuLog_logDebug(LogType::Force, "HidRead Begin (Length 0x{:08x})", message->length); - BOOL readResult = ReadFile(this->m_hFile, tempBuffer, message->length + 1, &bt, &ovlp); - if (readResult != FALSE) - { - // sometimes we get the result immediately - if (bt == 0) - transferLength = 0; - else - transferLength = bt - 1; - cemuLog_logDebug(LogType::Force, "HidRead Result received immediately (error 0x{:08x}) Length 0x{:08x}", - GetLastError(), transferLength); - } - else - { - // wait for result - cemuLog_logDebug(LogType::Force, "HidRead WaitForResult (error 0x{:08x})", GetLastError()); - // async hid read is never supposed to return unless there is a response? Lego Dimensions stops HIDRead calls as soon as one of them fails with a non-zero error (which includes time out) - DWORD r = WaitForSingleObject(ovlp.hEvent, 2000 * 100); - if (r == WAIT_TIMEOUT) - { - cemuLog_logDebug(LogType::Force, "HidRead internal timeout (error 0x{:08x})", GetLastError()); - // return -108 in case of timeout - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return ReadResult::ErrorTimeout; - } - - cemuLog_logDebug(LogType::Force, "HidRead WaitHalfComplete"); - GetOverlappedResult(this->m_hFile, &ovlp, &bt, false); - if (bt == 0) - transferLength = 0; - else - transferLength = bt - 1; - cemuLog_logDebug(LogType::Force, "HidRead WaitComplete Length: 0x{:08x}", transferLength); - } - sint32 returnCode = 0; - ReadResult result = ReadResult::Success; - if (bt != 0) - { - memcpy(message->data, tempBuffer + 1, transferLength); - sint32 hidReadLength = transferLength; - - char debugOutput[1024] = {0}; - for (sint32 i = 0; i < transferLength; i++) - { - sprintf(debugOutput + i * 3, "%02x ", tempBuffer[1 + i]); - } - cemuLog_logDebug(LogType::Force, "HIDRead data: {}", debugOutput); - - message->bytesRead = transferLength; - result = ReadResult::Success; - } - else - { - cemuLog_log(LogType::Force, "Failed HID read"); - result = ReadResult::Error; - } - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return result; - } - - Device::WriteResult DeviceWindowsHID::Write(WriteMessage* message) - { - message->bytesWritten = 0; - DWORD bt; - OVERLAPPED ovlp = {0}; - ovlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - uint8* tempBuffer = (uint8*)malloc(message->length + 1); - memcpy(tempBuffer + 1, message->data, message->length); - tempBuffer[0] = 0; // report byte? - - cemuLog_logDebug(LogType::Force, "HidWrite Begin (Length 0x{:08x})", message->length); - BOOL writeResult = WriteFile(this->m_hFile, tempBuffer, message->length + 1, &bt, &ovlp); - if (writeResult != FALSE) - { - // sometimes we get the result immediately - cemuLog_logDebug(LogType::Force, "HidWrite Result received immediately (error 0x{:08x}) Length 0x{:08x}", - GetLastError()); - } - else - { - // wait for result - cemuLog_logDebug(LogType::Force, "HidWrite WaitForResult (error 0x{:08x})", GetLastError()); - // todo - check for error type - DWORD r = WaitForSingleObject(ovlp.hEvent, 2000); - if (r == WAIT_TIMEOUT) - { - cemuLog_logDebug(LogType::Force, "HidWrite internal timeout"); - // return -108 in case of timeout - free(tempBuffer); - CloseHandle(ovlp.hEvent); - return WriteResult::ErrorTimeout; - } - - cemuLog_logDebug(LogType::Force, "HidWrite WaitHalfComplete"); - GetOverlappedResult(this->m_hFile, &ovlp, &bt, false); - cemuLog_logDebug(LogType::Force, "HidWrite WaitComplete"); - } - - free(tempBuffer); - CloseHandle(ovlp.hEvent); - - if (bt != 0) - { - message->bytesWritten = message->length; - return WriteResult::Success; - } - return WriteResult::Error; - } - - bool DeviceWindowsHID::GetDescriptor(uint8 descType, - uint8 descIndex, - uint8 lang, - uint8* output, - uint32 outputMaxLength) - { - if (!IsOpened()) - { - cemuLog_logDebug(LogType::Force, "nsyshid::DeviceWindowsHID::getDescriptor(): device is not opened"); - return false; - } - if (descType == 0x02) - { - uint8 configurationDescriptor[0x29]; - - uint8* currentWritePtr; - - // configuration descriptor - currentWritePtr = configurationDescriptor + 0; - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 2; // bDescriptorType - *(uint16be*)(currentWritePtr + 2) = 0x0029; // wTotalLength - *(uint8*)(currentWritePtr + 4) = 1; // bNumInterfaces - *(uint8*)(currentWritePtr + 5) = 1; // bConfigurationValue - *(uint8*)(currentWritePtr + 6) = 0; // iConfiguration - *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes - *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower - currentWritePtr = currentWritePtr + 9; - // configuration descriptor - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType - *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber - *(uint8*)(currentWritePtr + 3) = 0; // bAlternateSetting - *(uint8*)(currentWritePtr + 4) = 2; // bNumEndpoints - *(uint8*)(currentWritePtr + 5) = 3; // bInterfaceClass - *(uint8*)(currentWritePtr + 6) = 0; // bInterfaceSubClass - *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol - *(uint8*)(currentWritePtr + 8) = 0; // iInterface - currentWritePtr = currentWritePtr + 9; - // configuration descriptor - *(uint8*)(currentWritePtr + 0) = 9; // bLength - *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType - *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID - *(uint8*)(currentWritePtr + 4) = 0x00; // bCountryCode - *(uint8*)(currentWritePtr + 5) = 0x01; // bNumDescriptors - *(uint8*)(currentWritePtr + 6) = 0x22; // bDescriptorType - *(uint16be*)(currentWritePtr + 7) = 0x001D; // wDescriptorLength - currentWritePtr = currentWritePtr + 9; - // endpoint descriptor 1 - *(uint8*)(currentWritePtr + 0) = 7; // bLength - *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType - *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress - *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 4) = - this->m_maxPacketSizeRX; // wMaxPacketSize - *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval - currentWritePtr = currentWritePtr + 7; - // endpoint descriptor 2 - *(uint8*)(currentWritePtr + 0) = 7; // bLength - *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType - *(uint8*)(currentWritePtr + 2) = 0x02; // bEndpointAddress - *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 4) = - this->m_maxPacketSizeTX; // wMaxPacketSize - *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval - currentWritePtr = currentWritePtr + 7; - - cemu_assert_debug((currentWritePtr - configurationDescriptor) == 0x29); - - memcpy(output, configurationDescriptor, - std::min<uint32>(outputMaxLength, sizeof(configurationDescriptor))); - return true; - } - else - { - cemu_assert_unimplemented(); - } - return false; - } - - bool DeviceWindowsHID::SetProtocol(uint8 ifIndex, uint8 protocol) - { - // ToDo: implement this - // pretend that everything is fine - return true; - } - - bool DeviceWindowsHID::SetReport(ReportMessage* message) - { - sint32 retryCount = 0; - while (true) - { - BOOL r = HidD_SetOutputReport(this->m_hFile, message->reportData, message->length); - if (r != FALSE) - break; - Sleep(20); // retry - retryCount++; - if (retryCount >= 50) - { - cemuLog_log(LogType::Force, "nsyshid::DeviceWindowsHID::SetReport(): HID SetReport failed"); - return false; - } - } - return true; - } - - HANDLE OpenDevice(wchar_t* devicePath) - { - return CreateFile(devicePath, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, - NULL); - } - - void _debugPrintHex(std::string prefix, uint8* data, size_t len) - { - char debugOutput[1024] = {0}; - len = std::min(len, (size_t)100); - for (sint32 i = 0; i < len; i++) - { - sprintf(debugOutput + i * 3, "%02x ", data[i]); - } - cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); - } -} // namespace nsyshid::backend::windows - -#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID diff --git a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h b/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h deleted file mode 100644 index 9a8a78e9..00000000 --- a/src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef CEMU_NSYSHID_BACKEND_WINDOWS_HID_H -#define CEMU_NSYSHID_BACKEND_WINDOWS_HID_H - -#include "nsyshid.h" - -#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID - -#include "Backend.h" - -namespace nsyshid::backend::windows -{ - class BackendWindowsHID : public nsyshid::Backend { - public: - BackendWindowsHID(); - - ~BackendWindowsHID(); - - bool IsInitialisedOk() override; - - protected: - void AttachVisibleDevices() override; - - private: - std::shared_ptr<Device> CheckAndCreateDevice(wchar_t* devicePath, HANDLE hDevice); - }; - - class DeviceWindowsHID : public nsyshid::Device { - public: - DeviceWindowsHID(uint16 vendorId, - uint16 productId, - uint8 interfaceIndex, - uint8 interfaceSubClass, - uint8 protocol, - wchar_t* devicePath); - - ~DeviceWindowsHID(); - - bool Open() override; - - void Close() override; - - bool IsOpened() override; - - ReadResult Read(ReadMessage* message) override; - - WriteResult Write(WriteMessage* message) override; - - bool GetDescriptor(uint8 descType, uint8 descIndex, uint8 lang, uint8* output, uint32 outputMaxLength) override; - - bool SetProtocol(uint8 ifIndex, uint8 protocol) override; - - bool SetReport(ReportMessage* message) override; - - private: - wchar_t* m_devicePath; - HANDLE m_hFile; - }; - - HANDLE OpenDevice(wchar_t* devicePath); - - void _debugPrintHex(std::string prefix, uint8* data, size_t len); -} // namespace nsyshid::backend::windows - -#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID - -#endif // CEMU_NSYSHID_BACKEND_WINDOWS_HID_H diff --git a/src/Cafe/OS/libs/nsyshid/Dimensions.cpp b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp index 8a2acc76..b23560f1 100644 --- a/src/Cafe/OS/libs/nsyshid/Dimensions.cpp +++ b/src/Cafe/OS/libs/nsyshid/Dimensions.cpp @@ -426,7 +426,7 @@ namespace nsyshid bool DimensionsToypadDevice::GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) { @@ -489,6 +489,13 @@ namespace nsyshid return true; } + bool DimensionsToypadDevice::SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) + { + return true; + } + bool DimensionsToypadDevice::SetProtocol(uint8 ifIndex, uint8 protocol) { cemuLog_log(LogType::Force, "Toypad Protocol"); diff --git a/src/Cafe/OS/libs/nsyshid/Dimensions.h b/src/Cafe/OS/libs/nsyshid/Dimensions.h index d5a2a529..00ceff9e 100644 --- a/src/Cafe/OS/libs/nsyshid/Dimensions.h +++ b/src/Cafe/OS/libs/nsyshid/Dimensions.h @@ -25,10 +25,14 @@ namespace nsyshid bool GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) override; + bool SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; bool SetReport(ReportMessage* message) override; diff --git a/src/Cafe/OS/libs/nsyshid/Infinity.cpp b/src/Cafe/OS/libs/nsyshid/Infinity.cpp index ac793109..94ef817e 100644 --- a/src/Cafe/OS/libs/nsyshid/Infinity.cpp +++ b/src/Cafe/OS/libs/nsyshid/Infinity.cpp @@ -387,7 +387,7 @@ namespace nsyshid bool InfinityBaseDevice::GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) { @@ -450,6 +450,13 @@ namespace nsyshid return true; } + bool InfinityBaseDevice::SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) + { + return true; + } + bool InfinityBaseDevice::SetProtocol(uint8 ifIndex, uint8 protocol) { return true; @@ -492,7 +499,7 @@ namespace nsyshid return response; } - void InfinityUSB::SendCommand(uint8* buf, sint32 originalLength) + void InfinityUSB::SendCommand(uint8* buf, uint32 length) { const uint8 command = buf[2]; const uint8 sequence = buf[3]; diff --git a/src/Cafe/OS/libs/nsyshid/Infinity.h b/src/Cafe/OS/libs/nsyshid/Infinity.h index aa98fd15..81942abd 100644 --- a/src/Cafe/OS/libs/nsyshid/Infinity.h +++ b/src/Cafe/OS/libs/nsyshid/Infinity.h @@ -26,10 +26,14 @@ namespace nsyshid bool GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) override; + bool SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; bool SetReport(ReportMessage* message) override; @@ -53,7 +57,7 @@ namespace nsyshid void Save(); }; - void SendCommand(uint8* buf, sint32 originalLength); + void SendCommand(uint8* buf, uint32 length); std::array<uint8, 32> GetStatus(); void GetBlankResponse(uint8 sequence, std::array<uint8, 32>& replyBuf); diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.cpp b/src/Cafe/OS/libs/nsyshid/Skylander.cpp index 1b4515ef..9fab17b6 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.cpp +++ b/src/Cafe/OS/libs/nsyshid/Skylander.cpp @@ -564,7 +564,7 @@ namespace nsyshid bool SkylanderPortalDevice::GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) { @@ -583,7 +583,7 @@ namespace nsyshid *(uint8*)(currentWritePtr + 7) = 0x80; // bmAttributes *(uint8*)(currentWritePtr + 8) = 0xFA; // MaxPower currentWritePtr = currentWritePtr + 9; - // configuration descriptor + // interface descriptor *(uint8*)(currentWritePtr + 0) = 9; // bLength *(uint8*)(currentWritePtr + 1) = 0x04; // bDescriptorType *(uint8*)(currentWritePtr + 2) = 0; // bInterfaceNumber @@ -594,7 +594,7 @@ namespace nsyshid *(uint8*)(currentWritePtr + 7) = 0; // bInterfaceProtocol *(uint8*)(currentWritePtr + 8) = 0; // iInterface currentWritePtr = currentWritePtr + 9; - // configuration descriptor + // HID descriptor *(uint8*)(currentWritePtr + 0) = 9; // bLength *(uint8*)(currentWritePtr + 1) = 0x21; // bDescriptorType *(uint16be*)(currentWritePtr + 2) = 0x0111; // bcdHID @@ -608,7 +608,7 @@ namespace nsyshid *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType *(uint8*)(currentWritePtr + 2) = 0x81; // bEndpointAddress *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint16be*)(currentWritePtr + 4) = 0x0040; // wMaxPacketSize *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval currentWritePtr = currentWritePtr + 7; // endpoint descriptor 2 @@ -616,7 +616,7 @@ namespace nsyshid *(uint8*)(currentWritePtr + 1) = 0x05; // bDescriptorType *(uint8*)(currentWritePtr + 2) = 0x02; // bEndpointAddress *(uint8*)(currentWritePtr + 3) = 0x03; // bmAttributes - *(uint16be*)(currentWritePtr + 4) = 0x40; // wMaxPacketSize + *(uint16be*)(currentWritePtr + 4) = 0x0040; // wMaxPacketSize *(uint8*)(currentWritePtr + 6) = 0x01; // bInterval currentWritePtr = currentWritePtr + 7; @@ -627,6 +627,13 @@ namespace nsyshid return true; } + bool SkylanderPortalDevice::SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) + { + return true; + } + bool SkylanderPortalDevice::SetProtocol(uint8 ifIndex, uint8 protocol) { return true; @@ -634,12 +641,12 @@ namespace nsyshid bool SkylanderPortalDevice::SetReport(ReportMessage* message) { - g_skyportal.ControlTransfer(message->originalData, message->originalLength); + g_skyportal.ControlTransfer(message->data, message->length); std::this_thread::sleep_for(std::chrono::milliseconds(1)); return true; } - void SkylanderUSB::ControlTransfer(uint8* buf, sint32 originalLength) + void SkylanderUSB::ControlTransfer(uint8* buf, uint32 length) { std::array<uint8, 64> interruptResponse = {}; switch (buf[0]) diff --git a/src/Cafe/OS/libs/nsyshid/Skylander.h b/src/Cafe/OS/libs/nsyshid/Skylander.h index 986ef185..9b9580b0 100644 --- a/src/Cafe/OS/libs/nsyshid/Skylander.h +++ b/src/Cafe/OS/libs/nsyshid/Skylander.h @@ -26,10 +26,14 @@ namespace nsyshid bool GetDescriptor(uint8 descType, uint8 descIndex, - uint8 lang, + uint16 lang, uint8* output, uint32 outputMaxLength) override; + bool SetIdle(uint8 ifIndex, + uint8 reportId, + uint8 duration) override; + bool SetProtocol(uint8 ifIndex, uint8 protocol) override; bool SetReport(ReportMessage* message) override; @@ -70,7 +74,7 @@ namespace nsyshid uint8 blue = 0; }; - void ControlTransfer(uint8* buf, sint32 originalLength); + void ControlTransfer(uint8* buf, uint32 length); void Activate(); void Deactivate(); diff --git a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp index 99a736d9..2fe6da07 100644 --- a/src/Cafe/OS/libs/nsyshid/nsyshid.cpp +++ b/src/Cafe/OS/libs/nsyshid/nsyshid.cpp @@ -305,47 +305,37 @@ namespace nsyshid osLib_returnFromFunction(hCPU, 0); } - void export_HIDGetDescriptor(PPCInterpreter_t* hCPU) + void _debugPrintHex(const std::string prefix, const uint8* data, size_t size) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU8(descType, 1); // r4 - ppcDefineParamU8(descIndex, 2); // r5 - ppcDefineParamU8(lang, 3); // r6 - ppcDefineParamUStr(output, 4); // r7 - ppcDefineParamU32(outputMaxLength, 5); // r8 - ppcDefineParamMPTR(cbFuncMPTR, 6); // r9 - ppcDefineParamMPTR(cbParamMPTR, 7); // r10 + constexpr size_t BYTES_PER_LINE = 16; - int returnValue = -1; - std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); - if (device) + std::string out; + for (size_t row_start = 0; row_start < size; row_start += BYTES_PER_LINE) { - memset(output, 0, outputMaxLength); - if (device->GetDescriptor(descType, descIndex, lang, output, outputMaxLength)) + out += fmt::format("{:06x}: ", row_start); + for (size_t i = 0; i < BYTES_PER_LINE; ++i) { - returnValue = 0; + if (row_start + i < size) + { + out += fmt::format("{:02x} ", data[row_start + i]); + } + else + { + out += " "; + } } - else + out += " "; + for (size_t i = 0; i < BYTES_PER_LINE; ++i) { - returnValue = -1; + if (row_start + i < size) + { + char c = static_cast<char>(data[row_start + i]); + out += std::isprint(c, std::locale::classic()) ? c : '.'; + } } + out += "\n"; } - else - { - cemu_assert_suspicious(); - } - osLib_returnFromFunction(hCPU, returnValue); - } - - void _debugPrintHex(std::string prefix, uint8* data, size_t len) - { - char debugOutput[1024] = {0}; - len = std::min(len, (size_t)100); - for (sint32 i = 0; i < len; i++) - { - sprintf(debugOutput + i * 3, "%02x ", data[i]); - } - cemuLog_logDebug(LogType::Force, "[{}] Data: {}", prefix, debugOutput); + cemuLog_logDebug(LogType::Force, "[{}] Data: \n{}", prefix, out); } void DoHIDTransferCallback(MPTR callbackFuncMPTR, MPTR callbackParamMPTR, uint32 hidHandle, uint32 errorCode, @@ -354,26 +344,152 @@ namespace nsyshid coreinitAsyncCallback_add(callbackFuncMPTR, 5, hidHandle, errorCode, buffer, length, callbackParamMPTR); } - void export_HIDSetIdle(PPCInterpreter_t* hCPU) + void _hidGetDescriptorAsync(std::shared_ptr<Device> device, uint8 descType, uint8 descIndex, uint16 lang, uint8* output, uint32 outputMaxLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) { - ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(ifIndex, 1); // r4 - ppcDefineParamU32(ukn, 2); // r5 - ppcDefineParamU32(duration, 3); // r6 - ppcDefineParamMPTR(callbackFuncMPTR, 4); // r7 - ppcDefineParamMPTR(callbackParamMPTR, 5); // r8 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetIdle(...)"); - - // todo - if (callbackFuncMPTR) + if (device->GetDescriptor(descType, descIndex, lang, output, outputMaxLength)) { - DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + 0, + 0, + 0); } else { - cemu_assert_unimplemented(); + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + -1, + 0, + 0); + } + } + + void export_HIDGetDescriptor(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU8(descType, 1); // r4 + ppcDefineParamU8(descIndex, 2); // r5 + ppcDefineParamU16(lang, 3); // r6 + ppcDefineParamUStr(output, 4); // r7 + ppcDefineParamU32(outputMaxLength, 5); // r8 + ppcDefineParamMPTR(cbFuncMPTR, 6); // r9 + ppcDefineParamMPTR(cbParamMPTR, 7); // r10 + cemuLog_logDebug(LogType::Force, "nsyshid.HIDGetDescriptor(0x{:08x}, 0x{:02x}, 0x{:02x}, 0x{:04x}, 0x{:x}, 0x{:08x}, 0x{:08x}, 0x{:08x})", + hCPU->gpr[3], hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7], hCPU->gpr[8], hCPU->gpr[9], hCPU->gpr[10]); + + std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); + if (device == nullptr) + { + cemuLog_log(LogType::Force, "nsyshid.HIDGetDescriptor(): Unable to find device with hid handle {}", hidHandle); + osLib_returnFromFunction(hCPU, -1); + return; + } + + // issue request (synchronous or asynchronous) + sint32 returnCode = 0; + if (cbFuncMPTR == MPTR_NULL) + { + // synchronous + returnCode = -1; + if (device->GetDescriptor(descType, descIndex, lang, output, outputMaxLength)) + { + returnCode = outputMaxLength; + } + } + else + { + // asynchronous + std::thread(&_hidGetDescriptorAsync, device, descType, descIndex, lang, output, outputMaxLength, cbFuncMPTR, cbParamMPTR) + .detach(); + returnCode = 0; + } + osLib_returnFromFunction(hCPU, returnCode); + } + + void _hidSetIdleAsync(std::shared_ptr<Device> device, uint8 ifIndex, uint8 reportId, uint8 duration, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + { + if (device->SetIdle(ifIndex, reportId, duration)) + { + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + 0, + 0, + 0); + } + else + { + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + -1, + 0, + 0); + } + } + + void export_HIDSetIdle(PPCInterpreter_t* hCPU) + { + ppcDefineParamU32(hidHandle, 0); // r3 + ppcDefineParamU8(ifIndex, 1); // r4 + ppcDefineParamU8(reportId, 2); // r5 + ppcDefineParamU8(duration, 3); // r6 + ppcDefineParamMPTR(callbackFuncMPTR, 4); // r7 + ppcDefineParamMPTR(callbackParamMPTR, 5); // r8 + cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetIdle(0x{:08x}, 0x{:02x}, 0x{:02x}, 0x{:02x}, 0x{:08x}, 0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7], hCPU->gpr[8]); + + std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); + if (device == nullptr) + { + cemuLog_log(LogType::Force, "nsyshid.HIDSetIdle(): Unable to find device with hid handle {}", hidHandle); + osLib_returnFromFunction(hCPU, -1); + return; + } + + // issue request (synchronous or asynchronous) + sint32 returnCode = 0; + if (callbackFuncMPTR == MPTR_NULL) + { + // synchronous + returnCode = -1; + if (device->SetIdle(ifIndex, reportId, duration)) + { + returnCode = 0; + } + } + else + { + // asynchronous + std::thread(&_hidSetIdleAsync, device, ifIndex, reportId, duration, callbackFuncMPTR, callbackParamMPTR) + .detach(); + returnCode = 0; + } + osLib_returnFromFunction(hCPU, returnCode); + } + + void _hidSetProtocolAsync(std::shared_ptr<Device> device, uint8 ifIndex, uint8 protocol, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + { + if (device->SetProtocol(ifIndex, protocol)) + { + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + 0, + 0, + 0); + } + else + { + DoHIDTransferCallback(callbackFuncMPTR, + callbackParamMPTR, + device->m_hid->handle, + -1, + 0, + 0); } - osLib_returnFromFunction(hCPU, 0); // for non-async version, return number of bytes transferred } void export_HIDSetProtocol(PPCInterpreter_t* hCPU) @@ -383,51 +499,51 @@ namespace nsyshid ppcDefineParamU8(protocol, 2); // r5 ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(...)"); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(0x{:08x}, 0x{:02x}, 0x{:02x}, 0x{:08x}, 0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); - sint32 returnCode = -1; - if (device) + if (device == nullptr) { - if (!device->IsOpened()) + cemuLog_log(LogType::Force, "nsyshid.HIDSetProtocol(): Unable to find device with hid handle {}", hidHandle); + osLib_returnFromFunction(hCPU, -1); + return; + } + // issue request (synchronous or asynchronous) + sint32 returnCode = 0; + if (callbackFuncMPTR == MPTR_NULL) + { + // synchronous + returnCode = -1; + if (device->SetProtocol(ifIndex, protocol)) { - cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetProtocol(): error: device is not opened"); - } - else - { - if (device->SetProtocol(ifIndex, protocol)) - { - returnCode = 0; - } + returnCode = 0; } } else { - cemu_assert_suspicious(); - } - - if (callbackFuncMPTR) - { - DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, hidHandle, 0, MPTR_NULL, 0); + // asynchronous + std::thread(&_hidSetProtocolAsync, device, ifIndex, protocol, callbackFuncMPTR, callbackParamMPTR) + .detach(); + returnCode = 0; } osLib_returnFromFunction(hCPU, returnCode); } // handler for async HIDSetReport transfers - void _hidSetReportAsync(std::shared_ptr<Device> device, uint8* reportData, sint32 length, - uint8* originalData, - sint32 originalLength, MPTR callbackFuncMPTR, MPTR callbackParamMPTR) + void _hidSetReportAsync(std::shared_ptr<Device> device, uint8 reportType, uint8 reportId, uint8* data, uint32 length, + MPTR callbackFuncMPTR, MPTR callbackParamMPTR) { cemuLog_logDebug(LogType::Force, "_hidSetReportAsync begin"); - ReportMessage message(reportData, length, originalData, originalLength); + ReportMessage message(reportType, reportId, data, length); if (device->SetReport(&message)) { DoHIDTransferCallback(callbackFuncMPTR, callbackParamMPTR, device->m_hid->handle, 0, - memory_getVirtualOffsetFromPointer(originalData), - originalLength); + memory_getVirtualOffsetFromPointer(data), + length); } else { @@ -435,24 +551,22 @@ namespace nsyshid callbackParamMPTR, device->m_hid->handle, -1, - memory_getVirtualOffsetFromPointer(originalData), - 0); + memory_getVirtualOffsetFromPointer(data), + length); } - free(reportData); } // handler for synchronous HIDSetReport transfers - sint32 _hidSetReportSync(std::shared_ptr<Device> device, uint8* reportData, sint32 length, - uint8* originalData, sint32 originalLength, coreinit::OSEvent* event) + sint32 _hidSetReportSync(std::shared_ptr<Device> device, uint8 reportType, uint8 reportId, + uint8* data, uint32 length, coreinit::OSEvent* event) { - _debugPrintHex("_hidSetReportSync Begin", reportData, length); + _debugPrintHex("_hidSetReportSync Begin", data, length); sint32 returnCode = 0; - ReportMessage message(reportData, length, originalData, originalLength); + ReportMessage message(reportType, reportId, data, length); if (device->SetReport(&message)) { - returnCode = originalLength; + returnCode = length; } - free(reportData); cemuLog_logDebug(LogType::Force, "_hidSetReportSync end. returnCode: {}", returnCode); coreinit::OSSignalEvent(event); return returnCode; @@ -461,19 +575,19 @@ namespace nsyshid void export_HIDSetReport(PPCInterpreter_t* hCPU) { ppcDefineParamU32(hidHandle, 0); // r3 - ppcDefineParamU32(reportRelatedUkn, 1); // r4 - ppcDefineParamU32(reportId, 2); // r5 + ppcDefineParamU8(reportType, 1); // r4 + ppcDefineParamU8(reportId, 2); // r5 ppcDefineParamUStr(data, 3); // r6 ppcDefineParamU32(dataLength, 4); // r7 ppcDefineParamMPTR(callbackFuncMPTR, 5); // r8 ppcDefineParamMPTR(callbackParamMPTR, 6); // r9 - cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetReport({},0x{:02x},0x{:02x},...)", hidHandle, reportRelatedUkn, - reportId); + cemuLog_logDebug(LogType::Force, "nsyshid.HIDSetReport(0x{:08x}, 0x{:02x}, 0x{:02x}, 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x})", hCPU->gpr[3], + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7], hCPU->gpr[8], hCPU->gpr[9]); _debugPrintHex("HIDSetReport", data, dataLength); #ifdef CEMU_DEBUG_ASSERT - if (reportRelatedUkn != 2 || reportId != 0) + if (reportType != 2 || reportId != 0) assert_dbg(); #endif @@ -485,15 +599,6 @@ namespace nsyshid return; } - // prepare report data - // note: Currently we need to pad the data to 0x20 bytes for it to work (plus one extra byte for HidD_SetOutputReport) - // Does IOSU pad data to 0x20 byte? Also check if this is specific to Skylanders portal - sint32 paddedLength = (dataLength + 0x1F) & ~0x1F; - uint8* reportData = (uint8*)malloc(paddedLength + 1); - memset(reportData, 0, paddedLength + 1); - reportData[0] = 0; - memcpy(reportData + 1, data, dataLength); - // issue request (synchronous or asynchronous) sint32 returnCode = 0; if (callbackFuncMPTR == MPTR_NULL) @@ -501,15 +606,14 @@ namespace nsyshid // synchronous StackAllocator<coreinit::OSEvent> event; coreinit::OSInitEvent(&event, coreinit::OSEvent::EVENT_STATE::STATE_NOT_SIGNALED, coreinit::OSEvent::EVENT_MODE::MODE_AUTO); - std::future<sint32> res = std::async(std::launch::async, &_hidSetReportSync, device, reportData, - paddedLength + 1, data, dataLength, &event); + std::future<sint32> res = std::async(std::launch::async, &_hidSetReportSync, device, reportType, reportId, data, dataLength, &event); coreinit::OSWaitEvent(&event); returnCode = res.get(); } else { // asynchronous - std::thread(&_hidSetReportAsync, device, reportData, paddedLength + 1, data, dataLength, + std::thread(&_hidSetReportAsync, device, reportType, reportId, data, dataLength, callbackFuncMPTR, callbackParamMPTR) .detach(); returnCode = 0; @@ -586,7 +690,7 @@ namespace nsyshid ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 cemuLog_logDebug(LogType::Force, "nsyshid.HIDRead(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], - hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); if (device == nullptr) @@ -683,7 +787,7 @@ namespace nsyshid ppcDefineParamMPTR(callbackFuncMPTR, 3); // r6 ppcDefineParamMPTR(callbackParamMPTR, 4); // r7 cemuLog_logDebug(LogType::Force, "nsyshid.HIDWrite(0x{:x},0x{:08x},0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], - hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); + hCPU->gpr[4], hCPU->gpr[5], hCPU->gpr[6], hCPU->gpr[7]); std::shared_ptr<Device> device = GetDeviceByHandle(hidHandle, true); if (device == nullptr) @@ -718,7 +822,7 @@ namespace nsyshid ppcDefineParamTypePtr(ukn0, uint32be, 1); ppcDefineParamTypePtr(ukn1, uint32be, 2); cemuLog_logDebug(LogType::Force, "nsyshid.HIDDecodeError(0x{:08x},0x{:08x},0x{:08x})", hCPU->gpr[3], - hCPU->gpr[4], hCPU->gpr[5]); + hCPU->gpr[4], hCPU->gpr[5]); // todo *ukn0 = 0x3FF; From 07cd402531852537fb109f8dcd63d6627b856087 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 12 Jan 2025 18:33:15 +0100 Subject: [PATCH 299/314] Update precompiled.h --- src/Common/precompiled.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index 3dfeaf74..bda75cef 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -279,10 +279,10 @@ inline uint64 _udiv128(uint64 highDividend, uint64 lowDividend, uint64 divisor, #elif defined(__GNUC__) || defined(__clang__) #define FORCE_INLINE inline __attribute__((always_inline)) #else -#define FORCE_INLINE +#define FORCE_INLINE inline #endif -FORCE_INLINE inline int BSF(uint32 v) // returns index of first bit set, counting from LSB. If v is 0 then result is undefined +FORCE_INLINE int BSF(uint32 v) // returns index of first bit set, counting from LSB. If v is 0 then result is undefined { #if defined(_MSC_VER) return _tzcnt_u32(v); // TZCNT requires BMI1. But if not supported it will execute as BSF @@ -616,4 +616,4 @@ namespace stdx scope_exit& operator=(scope_exit) = delete; void release() { m_released = true;} }; -} \ No newline at end of file +} From eab1b24320454ef60d6172dd41dfa8379b3015ac Mon Sep 17 00:00:00 2001 From: Joshua de Reeper <joshua@dereeper.co.nz> Date: Sun, 12 Jan 2025 19:20:48 +0000 Subject: [PATCH 300/314] nsyshid: Initialise interface index as 0 (#1473) --- src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp index a7deef90..b5dd0e0f 100644 --- a/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp +++ b/src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp @@ -272,7 +272,7 @@ namespace nsyshid::backend::libusb auto device = std::make_shared<DeviceLibusb>(m_ctx, desc.idVendor, desc.idProduct, - 1, + 0, 2, 0, libusb_get_bus_number(dev), From 4ac65159efd14bec4cb0c74dde5b11100ad7f7d6 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier <contact@amb.tf> Date: Thu, 16 Jan 2025 11:54:29 +0000 Subject: [PATCH 301/314] Fix building against fmt 11.1.0 (#1474) --- src/Cafe/GameProfile/GameProfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index ee92107a..2a83b3fe 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -147,7 +147,7 @@ bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, T& } // test enum name - if(boost::iequals(fmt::format("{}", v), *option_value)) + if(boost::iequals(fmt::format("{}", fmt::underlying(v)), *option_value)) { option = v; return true; From 5bd253a1f84b5c410023744edf46896547f770d8 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:29:12 +0100 Subject: [PATCH 302/314] Revert "Fix building against fmt 11.1.0 (#1474)" Reverting commit 4ac65159efd14bec4cb0c74dde5b11100ad7f7d6 because game profile enums use the stringifying formatters from config.h and are not supposed to store raw integers --- src/Cafe/GameProfile/GameProfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index 2a83b3fe..ee92107a 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -147,7 +147,7 @@ bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, T& } // test enum name - if(boost::iequals(fmt::format("{}", fmt::underlying(v)), *option_value)) + if(boost::iequals(fmt::format("{}", v), *option_value)) { option = v; return true; From 372c314f0630a6d0ae1cb303f696071efbc72717 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:02:09 +0100 Subject: [PATCH 303/314] fix building with fmt11 and GCC --- src/Cafe/GameProfile/GameProfile.cpp | 2 +- src/config/CemuConfig.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index ee92107a..ea303226 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -140,7 +140,7 @@ bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, T& for(const T& v : T()) { // test integer option - if (boost::iequals(fmt::format("{}", static_cast<typename std::underlying_type<T>::type>(v)), *option_value)) + if (boost::iequals(fmt::format("{}", fmt::underlying(v)), *option_value)) { option = v; return true; diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 191614a2..62665f6d 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -192,7 +192,7 @@ ENABLE_ENUM_ITERATORS(CrashDump, CrashDump::Disabled, CrashDump::Enabled); #endif template <> -struct fmt::formatter<PrecompiledShaderOption> : formatter<string_view> { +struct fmt::formatter<const PrecompiledShaderOption> : formatter<string_view> { template <typename FormatContext> auto format(const PrecompiledShaderOption c, FormatContext &ctx) const { string_view name; @@ -207,7 +207,7 @@ struct fmt::formatter<PrecompiledShaderOption> : formatter<string_view> { } }; template <> -struct fmt::formatter<AccurateShaderMulOption> : formatter<string_view> { +struct fmt::formatter<const AccurateShaderMulOption> : formatter<string_view> { template <typename FormatContext> auto format(const AccurateShaderMulOption c, FormatContext &ctx) const { string_view name; @@ -221,7 +221,7 @@ struct fmt::formatter<AccurateShaderMulOption> : formatter<string_view> { } }; template <> -struct fmt::formatter<CPUMode> : formatter<string_view> { +struct fmt::formatter<const CPUMode> : formatter<string_view> { template <typename FormatContext> auto format(const CPUMode c, FormatContext &ctx) const { string_view name; @@ -238,7 +238,7 @@ struct fmt::formatter<CPUMode> : formatter<string_view> { } }; template <> -struct fmt::formatter<CPUModeLegacy> : formatter<string_view> { +struct fmt::formatter<const CPUModeLegacy> : formatter<string_view> { template <typename FormatContext> auto format(const CPUModeLegacy c, FormatContext &ctx) const { string_view name; @@ -255,7 +255,7 @@ struct fmt::formatter<CPUModeLegacy> : formatter<string_view> { } }; template <> -struct fmt::formatter<CafeConsoleRegion> : formatter<string_view> { +struct fmt::formatter<const CafeConsoleRegion> : formatter<string_view> { template <typename FormatContext> auto format(const CafeConsoleRegion v, FormatContext &ctx) const { string_view name; @@ -276,7 +276,7 @@ struct fmt::formatter<CafeConsoleRegion> : formatter<string_view> { } }; template <> -struct fmt::formatter<CafeConsoleLanguage> : formatter<string_view> { +struct fmt::formatter<const CafeConsoleLanguage> : formatter<string_view> { template <typename FormatContext> auto format(const CafeConsoleLanguage v, FormatContext &ctx) { string_view name; @@ -302,7 +302,7 @@ struct fmt::formatter<CafeConsoleLanguage> : formatter<string_view> { #if BOOST_OS_WINDOWS template <> -struct fmt::formatter<CrashDump> : formatter<string_view> { +struct fmt::formatter<const CrashDump> : formatter<string_view> { template <typename FormatContext> auto format(const CrashDump v, FormatContext &ctx) { string_view name; @@ -319,7 +319,7 @@ struct fmt::formatter<CrashDump> : formatter<string_view> { }; #elif BOOST_OS_UNIX template <> -struct fmt::formatter<CrashDump> : formatter<string_view> { +struct fmt::formatter<const CrashDump> : formatter<string_view> { template <typename FormatContext> auto format(const CrashDump v, FormatContext &ctx) { string_view name; From 4f9eea07e045e0d8b0e14dfced29795641cd128e Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 23 Jan 2025 20:35:43 +0100 Subject: [PATCH 304/314] CI: Update action version --- .github/workflows/generate_pot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_pot.yml b/.github/workflows/generate_pot.yml index 7dfa86f8..b057d441 100644 --- a/.github/workflows/generate_pot.yml +++ b/.github/workflows/generate_pot.yml @@ -35,7 +35,7 @@ jobs: -o cemu.pot - name: Upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: POT file path: ./cemu.pot From e834515f430c8d8eaee6be6e1a5a4f16fcbca8d9 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Thu, 23 Jan 2025 21:20:03 +0100 Subject: [PATCH 305/314] Vulkan: Improve post-shutdown cleanup and minor improvements (#1401) --- src/Cafe/HW/Latte/Core/LatteShaderCache.cpp | 5 +- src/Cafe/HW/Latte/Core/LatteThread.cpp | 1 + .../HW/Latte/Renderer/RendererOuputShader.cpp | 20 +++- .../HW/Latte/Renderer/RendererOuputShader.h | 9 +- .../Renderer/Vulkan/RendererShaderVk.cpp | 3 + .../Latte/Renderer/Vulkan/SwapchainInfoVk.cpp | 2 +- .../Latte/Renderer/Vulkan/SwapchainInfoVk.h | 2 +- .../Renderer/Vulkan/VKRMemoryManager.cpp | 79 ++++++--------- .../Latte/Renderer/Vulkan/VKRMemoryManager.h | 11 +-- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h | 3 + .../Latte/Renderer/Vulkan/VulkanRenderer.cpp | 96 ++++++++++++++----- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 8 +- .../Renderer/Vulkan/VulkanRendererCore.cpp | 30 ++---- .../Renderer/Vulkan/VulkanSurfaceCopy.cpp | 30 +++++- src/imgui/imgui_impl_vulkan.cpp | 9 ++ 15 files changed, 190 insertions(+), 118 deletions(-) diff --git a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp index 9b24de45..0d427e34 100644 --- a/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp +++ b/src/Cafe/HW/Latte/Core/LatteShaderCache.cpp @@ -485,6 +485,9 @@ void LatteShaderCache_Load() g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureDRCId); g_bootSndPlayer.FadeOutSound(); + + if(Latte_GetStopSignal()) + LatteThread_Exit(); } void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateFunc, bool isPipelines) @@ -625,8 +628,6 @@ void LatteShaderCache_LoadVulkanPipelineCache(uint64 cacheTitleId) g_shaderCacheLoaderState.loadedPipelines = 0; LatteShaderCache_ShowProgress(LatteShaderCache_updatePipelineLoadingProgress, true); pipelineCache.EndLoading(); - if(Latte_GetStopSignal()) - LatteThread_Exit(); } bool LatteShaderCache_updatePipelineLoadingProgress() diff --git a/src/Cafe/HW/Latte/Core/LatteThread.cpp b/src/Cafe/HW/Latte/Core/LatteThread.cpp index 8874ecf4..92a7fdbb 100644 --- a/src/Cafe/HW/Latte/Core/LatteThread.cpp +++ b/src/Cafe/HW/Latte/Core/LatteThread.cpp @@ -257,6 +257,7 @@ void LatteThread_Exit() LatteSHRC_UnloadAll(); // close disk cache LatteShaderCache_Close(); + RendererOutputShader::ShutdownStatic(); // destroy renderer but make sure that g_renderer remains valid until the destructor has finished if (g_renderer) { diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp index 409dc24f..3a00c36a 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp @@ -118,8 +118,8 @@ RendererOutputShader::RendererOutputShader(const std::string& vertex_source, con { auto finalFragmentSrc = PrependFragmentPreamble(fragment_source); - m_vertex_shader = g_renderer->shader_create(RendererShader::ShaderType::kVertex, 0, 0, vertex_source, false, false); - m_fragment_shader = g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, finalFragmentSrc, false, false); + m_vertex_shader.reset(g_renderer->shader_create(RendererShader::ShaderType::kVertex, 0, 0, vertex_source, false, false)); + m_fragment_shader.reset(g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, finalFragmentSrc, false, false)); m_vertex_shader->PreponeCompilation(true); m_fragment_shader->PreponeCompilation(true); @@ -169,8 +169,8 @@ void RendererOutputShader::SetUniformParameters(const LatteTextureView& texture_ shader->SetUniform2fv(locations.m_loc_outputResolution, res, 1); } }; - setUniforms(m_vertex_shader, m_uniformLocations[0]); - setUniforms(m_fragment_shader, m_uniformLocations[1]); + setUniforms(m_vertex_shader.get(), m_uniformLocations[0]); + setUniforms(m_fragment_shader.get(), m_uniformLocations[1]); } RendererOutputShader* RendererOutputShader::s_copy_shader; @@ -325,3 +325,15 @@ void RendererOutputShader::InitializeStatic() s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source); s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source); } + +void RendererOutputShader::ShutdownStatic() +{ + delete s_copy_shader; + delete s_copy_shader_ud; + + delete s_bicubic_shader; + delete s_bicubic_shader_ud; + + delete s_hermit_shader; + delete s_hermit_shader_ud; +} diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h index 61b24c20..b12edf8b 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h @@ -21,15 +21,16 @@ public: RendererShader* GetVertexShader() const { - return m_vertex_shader; + return m_vertex_shader.get(); } RendererShader* GetFragmentShader() const { - return m_fragment_shader; + return m_fragment_shader.get(); } static void InitializeStatic(); + static void ShutdownStatic(); static RendererOutputShader* s_copy_shader; static RendererOutputShader* s_copy_shader_ud; @@ -46,8 +47,8 @@ public: static std::string PrependFragmentPreamble(const std::string& shaderSrc); protected: - RendererShader* m_vertex_shader; - RendererShader* m_fragment_shader; + std::unique_ptr<RendererShader> m_vertex_shader; + std::unique_ptr<RendererShader> m_fragment_shader; struct UniformLocations { diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp index 50f2c2d6..8a66c81b 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp @@ -211,6 +211,9 @@ RendererShaderVk::~RendererShaderVk() { while (!list_pipelineInfo.empty()) delete list_pipelineInfo[0]; + + VkDevice vkDev = VulkanRenderer::GetInstance()->GetLogicalDevice(); + vkDestroyShaderModule(vkDev, m_shader_module, nullptr); } void RendererShaderVk::Init() diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp index 56a3ab12..47dafc98 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.cpp @@ -60,7 +60,7 @@ void SwapchainInfoVk::Create() VkAttachmentDescription colorAttachment = {}; colorAttachment.format = m_surfaceFormat.format; colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT; - colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h index 7023f291..c4977c08 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/SwapchainInfoVk.h @@ -70,6 +70,7 @@ struct SwapchainInfoVk VkSurfaceFormatKHR m_surfaceFormat{}; VkSwapchainKHR m_swapchain{}; Vector2i m_desiredExtent{}; + VkExtent2D m_actualExtent{}; uint32 swapchainImageIndex = (uint32)-1; uint64 m_presentId = 1; uint64 m_queueDepth = 0; // number of frames with pending presentation requests @@ -92,5 +93,4 @@ private: VkSemaphore m_currentSemaphore = VK_NULL_HANDLE; std::array<uint32, 2> m_swapchainQueueFamilyIndices; - VkExtent2D m_actualExtent{}; }; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp index 3494dbc5..54ca20cf 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.cpp @@ -4,6 +4,14 @@ /* VKRSynchronizedMemoryBuffer */ +VKRSynchronizedRingAllocator::~VKRSynchronizedRingAllocator() +{ + for(auto& buf : m_buffers) + { + m_vkrMemMgr->DeleteBuffer(buf.vk_buffer, buf.vk_mem); + } +} + void VKRSynchronizedRingAllocator::addUploadBufferSyncPoint(AllocatorBuffer_t& buffer, uint32 offset) { auto cmdBufferId = m_vkr->GetCurrentCommandBufferId(); @@ -233,6 +241,15 @@ void VKRSynchronizedHeapAllocator::GetStats(uint32& numBuffers, size_t& totalBuf /* VkTextureChunkedHeap */ +VkTextureChunkedHeap::~VkTextureChunkedHeap() +{ + VkDevice device = VulkanRenderer::GetInstance()->GetLogicalDevice(); + for (auto& i : m_list_chunkInfo) + { + vkFreeMemory(device, i.mem, nullptr); + } +} + uint32 VkTextureChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumAllocationSize) { cemu_assert_debug(m_list_chunkInfo.size() == chunkIndex); @@ -310,11 +327,11 @@ VKRBuffer* VKRBuffer::Create(VKR_BUFFER_TYPE bufferType, size_t bufferSize, VkMe VkDeviceMemory bufferMemory; bool allocSuccess; if (bufferType == VKR_BUFFER_TYPE::STAGING) - allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, properties, buffer, bufferMemory); + allocSuccess = memMgr->CreateBuffer(bufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, properties, buffer, bufferMemory); else if (bufferType == VKR_BUFFER_TYPE::INDEX) - allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, properties, buffer, bufferMemory); + allocSuccess = memMgr->CreateBuffer(bufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, properties, buffer, bufferMemory); else if (bufferType == VKR_BUFFER_TYPE::STRIDE) - allocSuccess = memMgr->CreateBuffer2(bufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, properties, buffer, bufferMemory); + allocSuccess = memMgr->CreateBuffer(bufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, properties, buffer, bufferMemory); else cemu_assert_debug(false); if (!allocSuccess) @@ -363,28 +380,14 @@ uint32 VkBufferChunkedHeap::allocateNewChunk(uint32 chunkIndex, uint32 minimumAl return allocationSize; } -uint32_t VKRMemoryManager::FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) const -{ - VkPhysicalDeviceMemoryProperties memProperties; - vkGetPhysicalDeviceMemoryProperties(m_vkr->GetPhysicalDevice(), &memProperties); - - for (uint32 i = 0; i < memProperties.memoryTypeCount; i++) - { - if ((typeFilter & (1 << i)) != 0 && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) - return i; - } - m_vkr->UnrecoverableError(fmt::format("failed to find suitable memory type ({0:#08x} {1:#08x})", typeFilter, properties).c_str()); - return 0; -} - -bool VKRMemoryManager::FindMemoryType2(uint32 typeFilter, VkMemoryPropertyFlags properties, uint32& memoryIndex) const +bool VKRMemoryManager::FindMemoryType(uint32 typeFilter, VkMemoryPropertyFlags properties, uint32& memoryIndex) const { VkPhysicalDeviceMemoryProperties memProperties; vkGetPhysicalDeviceMemoryProperties(m_vkr->GetPhysicalDevice(), &memProperties); for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) { - if (typeFilter & (1 << i) && memProperties.memoryTypes[i].propertyFlags == properties) + if (typeFilter & (1 << i) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) { memoryIndex = i; return true; @@ -455,31 +458,7 @@ size_t VKRMemoryManager::GetTotalMemoryForBufferType(VkBufferUsageFlags usage, V return total; } -void VKRMemoryManager::CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const -{ - VkBufferCreateInfo bufferInfo{}; - bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - bufferInfo.usage = usage; - bufferInfo.size = size; - bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - if (vkCreateBuffer(m_vkr->GetLogicalDevice(), &bufferInfo, nullptr, &buffer) != VK_SUCCESS) - m_vkr->UnrecoverableError("Failed to create buffer"); - - VkMemoryRequirements memRequirements; - vkGetBufferMemoryRequirements(m_vkr->GetLogicalDevice(), buffer, &memRequirements); - - VkMemoryAllocateInfo allocInfo{}; - allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - allocInfo.allocationSize = memRequirements.size; - allocInfo.memoryTypeIndex = FindMemoryType(memRequirements.memoryTypeBits, properties); - - if (vkAllocateMemory(m_vkr->GetLogicalDevice(), &allocInfo, nullptr, &bufferMemory) != VK_SUCCESS) - m_vkr->UnrecoverableError("Failed to allocate buffer memory"); - if (vkBindBufferMemory(m_vkr->GetLogicalDevice(), buffer, bufferMemory, 0) != VK_SUCCESS) - m_vkr->UnrecoverableError("Failed to bind buffer memory"); -} - -bool VKRMemoryManager::CreateBuffer2(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const +bool VKRMemoryManager::CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const { VkBufferCreateInfo bufferInfo{}; bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -488,7 +467,7 @@ bool VKRMemoryManager::CreateBuffer2(VkDeviceSize size, VkBufferUsageFlags usage bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; if (vkCreateBuffer(m_vkr->GetLogicalDevice(), &bufferInfo, nullptr, &buffer) != VK_SUCCESS) { - cemuLog_log(LogType::Force, "Failed to create buffer (CreateBuffer2)"); + cemuLog_log(LogType::Force, "Failed to create buffer (CreateBuffer)"); return false; } @@ -498,7 +477,7 @@ bool VKRMemoryManager::CreateBuffer2(VkDeviceSize size, VkBufferUsageFlags usage VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; - if (!FindMemoryType2(memRequirements.memoryTypeBits, properties, allocInfo.memoryTypeIndex)) + if (!FindMemoryType(memRequirements.memoryTypeBits, properties, allocInfo.memoryTypeIndex)) { vkDestroyBuffer(m_vkr->GetLogicalDevice(), buffer, nullptr); return false; @@ -511,7 +490,7 @@ bool VKRMemoryManager::CreateBuffer2(VkDeviceSize size, VkBufferUsageFlags usage if (vkBindBufferMemory(m_vkr->GetLogicalDevice(), buffer, bufferMemory, 0) != VK_SUCCESS) { vkDestroyBuffer(m_vkr->GetLogicalDevice(), buffer, nullptr); - cemuLog_log(LogType::Force, "Failed to bind buffer (CreateBuffer2)"); + cemuLog_log(LogType::Force, "Failed to bind buffer (CreateBuffer)"); return false; } return true; @@ -533,7 +512,7 @@ bool VKRMemoryManager::CreateBufferFromHostMemory(void* hostPointer, VkDeviceSiz if (vkCreateBuffer(m_vkr->GetLogicalDevice(), &bufferInfo, nullptr, &buffer) != VK_SUCCESS) { - cemuLog_log(LogType::Force, "Failed to create buffer (CreateBuffer2)"); + cemuLog_log(LogType::Force, "Failed to create buffer (CreateBuffer)"); return false; } @@ -554,7 +533,7 @@ bool VKRMemoryManager::CreateBufferFromHostMemory(void* hostPointer, VkDeviceSiz allocInfo.pNext = &importHostMem; - if (!FindMemoryType2(memRequirements.memoryTypeBits, properties, allocInfo.memoryTypeIndex)) + if (!FindMemoryType(memRequirements.memoryTypeBits, properties, allocInfo.memoryTypeIndex)) { vkDestroyBuffer(m_vkr->GetLogicalDevice(), buffer, nullptr); return false; @@ -598,7 +577,7 @@ VkImageMemAllocation* VKRMemoryManager::imageMemoryAllocate(VkImage image) map_textureHeap.emplace(typeFilter, texHeap); } else - texHeap = it->second; + texHeap = it->second.get(); // alloc mem from heap uint32 allocationSize = (uint32)memRequirements.size; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h index 08af5882..b81b65ea 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VKRMemoryManager.h @@ -48,6 +48,7 @@ class VkTextureChunkedHeap : private ChunkedHeap<> { public: VkTextureChunkedHeap(class VKRMemoryManager* memoryManager, uint32 typeFilter) : m_vkrMemoryManager(memoryManager), m_typeFilter(typeFilter) { }; + ~VkTextureChunkedHeap(); struct ChunkInfo { @@ -148,6 +149,7 @@ class VKRSynchronizedRingAllocator public: VKRSynchronizedRingAllocator(class VulkanRenderer* vkRenderer, class VKRMemoryManager* vkMemoryManager, VKR_BUFFER_TYPE bufferType, uint32 minimumBufferAllocSize) : m_vkr(vkRenderer), m_vkrMemMgr(vkMemoryManager), m_bufferType(bufferType), m_minimumBufferAllocSize(minimumBufferAllocSize) {}; VKRSynchronizedRingAllocator(const VKRSynchronizedRingAllocator&) = delete; // disallow copy + ~VKRSynchronizedRingAllocator(); struct BufferSyncPoint_t { @@ -256,7 +258,7 @@ public: } // texture memory management - std::unordered_map<uint32, VkTextureChunkedHeap*> map_textureHeap; // one heap per memory type + std::unordered_map<uint32, std::unique_ptr<VkTextureChunkedHeap>> map_textureHeap; // one heap per memory type std::vector<uint8> m_textureUploadBuffer; // texture upload buffer @@ -286,9 +288,7 @@ public: m_vertexStrideMetalBuffer.CleanupBuffer(latestFinishedCommandBufferId); } - // memory helpers - uint32_t FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) const; - bool FindMemoryType2(uint32 typeFilter, VkMemoryPropertyFlags properties, uint32& memoryIndex) const; // searches for exact properties. Can gracefully fail without throwing exception (returns false) + bool FindMemoryType(uint32 typeFilter, VkMemoryPropertyFlags properties, uint32& memoryIndex) const; // searches for exact properties. Can gracefully fail without throwing exception (returns false) std::vector<uint32> FindMemoryTypes(uint32_t typeFilter, VkMemoryPropertyFlags properties) const; // image memory allocation @@ -298,8 +298,7 @@ public: // buffer management size_t GetTotalMemoryForBufferType(VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, size_t minimumBufferSize = 16 * 1024 * 1024); - void CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const; - bool CreateBuffer2(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const; // same as CreateBuffer but doesn't throw exception on failure + bool CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const; // same as CreateBuffer but doesn't throw exception on failure bool CreateBufferFromHostMemory(void* hostPointer, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory) const; void DeleteBuffer(VkBuffer& buffer, VkDeviceMemory& deviceMem) const; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h index 6bde2a0b..ae2a62f2 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h @@ -165,6 +165,7 @@ VKFUNC_DEVICE(vkCmdDraw); VKFUNC_DEVICE(vkCmdCopyBufferToImage); VKFUNC_DEVICE(vkCmdCopyImageToBuffer); VKFUNC_DEVICE(vkCmdClearColorImage); +VKFUNC_DEVICE(vkCmdClearAttachments); VKFUNC_DEVICE(vkCmdBindIndexBuffer); VKFUNC_DEVICE(vkCmdBindVertexBuffers); VKFUNC_DEVICE(vkCmdDrawIndexed); @@ -198,6 +199,7 @@ VKFUNC_DEVICE(vkCmdEndTransformFeedbackEXT); // query VKFUNC_DEVICE(vkCreateQueryPool); +VKFUNC_DEVICE(vkDestroyQueryPool); VKFUNC_DEVICE(vkCmdResetQueryPool); VKFUNC_DEVICE(vkCmdBeginQuery); VKFUNC_DEVICE(vkCmdEndQuery); @@ -236,6 +238,7 @@ VKFUNC_DEVICE(vkAllocateDescriptorSets); VKFUNC_DEVICE(vkFreeDescriptorSets); VKFUNC_DEVICE(vkUpdateDescriptorSets); VKFUNC_DEVICE(vkCreateDescriptorPool); +VKFUNC_DEVICE(vkDestroyDescriptorPool); VKFUNC_DEVICE(vkDestroyDescriptorSetLayout); #undef VKFUNC_INIT diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 66369c10..4ff2faac 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -439,7 +439,7 @@ VulkanRenderer::VulkanRenderer() GetDeviceFeatures(); // init memory manager - memoryManager = new VKRMemoryManager(this); + memoryManager.reset(new VKRMemoryManager(this)); try { @@ -577,15 +577,15 @@ VulkanRenderer::VulkanRenderer() void* bufferPtr; // init ringbuffer for uniform vars m_uniformVarBufferMemoryIsCoherent = false; - if (memoryManager->CreateBuffer2(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) + if (memoryManager->CreateBuffer(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) m_uniformVarBufferMemoryIsCoherent = true; - else if (memoryManager->CreateBuffer2(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) + else if (memoryManager->CreateBuffer(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) m_uniformVarBufferMemoryIsCoherent = true; // unified memory - else if (memoryManager->CreateBuffer2(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) + else if (memoryManager->CreateBuffer(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory)) m_uniformVarBufferMemoryIsCoherent = true; else { - memoryManager->CreateBuffer2(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory); + memoryManager->CreateBuffer(UNIFORMVAR_RINGBUFFER_SIZE, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, m_uniformVarBuffer, m_uniformVarBufferMemory); } if (!m_uniformVarBufferMemoryIsCoherent) @@ -628,6 +628,31 @@ VulkanRenderer::~VulkanRenderer() m_pipeline_cache_semaphore.notify(); m_pipeline_cache_save_thread.join(); + vkDestroyPipelineCache(m_logicalDevice, m_pipeline_cache, nullptr); + + if(!m_backbufferBlitDescriptorSetCache.empty()) + { + std::vector<VkDescriptorSet> freeVector; + freeVector.reserve(m_backbufferBlitDescriptorSetCache.size()); + std::transform(m_backbufferBlitDescriptorSetCache.begin(), m_backbufferBlitDescriptorSetCache.end(), std::back_inserter(freeVector), [](auto& i) { + return i.second; + }); + vkFreeDescriptorSets(m_logicalDevice, m_descriptorPool, freeVector.size(), freeVector.data()); + } + + vkDestroyDescriptorPool(m_logicalDevice, m_descriptorPool, nullptr); + + for(auto& i : m_backbufferBlitPipelineCache) + { + vkDestroyPipeline(m_logicalDevice, i.second, nullptr); + } + m_backbufferBlitPipelineCache = {}; + + if(m_occlusionQueries.queryPool != VK_NULL_HANDLE) + vkDestroyQueryPool(m_logicalDevice, m_occlusionQueries.queryPool, nullptr); + + vkDestroyDescriptorSetLayout(m_logicalDevice, m_swapchainDescriptorSetLayout, nullptr); + // shut down imgui ImGui_ImplVulkan_Shutdown(); @@ -640,10 +665,6 @@ VulkanRenderer::~VulkanRenderer() memoryManager->DeleteBuffer(m_xfbRingBuffer, m_xfbRingBufferMemory); memoryManager->DeleteBuffer(m_occlusionQueries.bufferQueryResults, m_occlusionQueries.memoryQueryResults); memoryManager->DeleteBuffer(m_bufferCache, m_bufferCacheMemory); - // texture memory - // todo - // upload buffers - // todo m_padSwapchainInfo = nullptr; m_mainSwapchainInfo = nullptr; @@ -666,6 +687,12 @@ VulkanRenderer::~VulkanRenderer() it = VK_NULL_HANDLE; } + for(auto& sem : m_commandBufferSemaphores) + { + vkDestroySemaphore(m_logicalDevice, sem, nullptr); + sem = VK_NULL_HANDLE; + } + if (m_pipelineLayout != VK_NULL_HANDLE) vkDestroyPipelineLayout(m_logicalDevice, m_pipelineLayout, nullptr); @@ -681,8 +708,11 @@ VulkanRenderer::~VulkanRenderer() vkDestroyDebugUtilsMessengerEXT(m_instance, m_debugCallback, nullptr); } + while(!m_destructionQueue.empty()) + ProcessDestructionQueue(); + // destroy memory manager - delete memoryManager; + memoryManager.reset(); // destroy instance, devices if (m_instance != VK_NULL_HANDLE) @@ -825,7 +855,14 @@ void VulkanRenderer::HandleScreenshotRequest(LatteTextureView* texView, bool pad VkMemoryAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.allocationSize = memRequirements.size; - allocInfo.memoryTypeIndex = memoryManager->FindMemoryType(memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + uint32 memIndex; + bool foundMemory = memoryManager->FindMemoryType(memRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, memIndex); + if(!foundMemory) + { + cemuLog_log(LogType::Force, "Screenshot request failed due to incompatible vulkan memory types."); + return; + } + allocInfo.memoryTypeIndex = memIndex; if (vkAllocateMemory(m_logicalDevice, &allocInfo, nullptr, &imageMemory) != VK_SUCCESS) { @@ -1608,6 +1645,7 @@ void VulkanRenderer::Initialize() void VulkanRenderer::Shutdown() { + DeleteFontTextures(); Renderer::Shutdown(); SubmitCommandBuffer(); WaitDeviceIdle(); @@ -1808,7 +1846,6 @@ void VulkanRenderer::ImguiEnd() vkCmdEndRenderPass(m_state.currentCommandBuffer); } -std::vector<LatteTextureVk*> g_imgui_textures; // TODO manage better ImTextureID VulkanRenderer::GenerateTexture(const std::vector<uint8>& data, const Vector2i& size) { try @@ -1838,6 +1875,7 @@ void VulkanRenderer::DeleteTexture(ImTextureID id) void VulkanRenderer::DeleteFontTextures() { + WaitDeviceIdle(); ImGui_ImplVulkan_DestroyFontsTexture(); } @@ -1876,7 +1914,7 @@ void VulkanRenderer::InitFirstCommandBuffer() vkResetFences(m_logicalDevice, 1, &m_cmd_buffer_fences[m_commandBufferIndex]); VkCommandBufferBeginInfo beginInfo{}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; + beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; vkBeginCommandBuffer(m_state.currentCommandBuffer, &beginInfo); vkCmdSetViewport(m_state.currentCommandBuffer, 0, 1, &m_state.currentViewport); @@ -1998,7 +2036,7 @@ void VulkanRenderer::SubmitCommandBuffer(VkSemaphore signalSemaphore, VkSemaphor VkCommandBufferBeginInfo beginInfo{}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; + beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; vkBeginCommandBuffer(m_state.currentCommandBuffer, &beginInfo); // make sure some states are set for this command buffer @@ -2519,9 +2557,8 @@ VkPipeline VulkanRenderer::backbufferBlit_createGraphicsPipeline(VkDescriptorSet hash += (uint64)(chainInfo.m_usesSRGB); hash += ((uint64)padView) << 1; - static std::unordered_map<uint64, VkPipeline> s_pipeline_cache; - const auto it = s_pipeline_cache.find(hash); - if (it != s_pipeline_cache.cend()) + const auto it = m_backbufferBlitPipelineCache.find(hash); + if (it != m_backbufferBlitPipelineCache.cend()) return it->second; std::vector<VkPipelineShaderStageCreateInfo> shaderStages; @@ -2625,7 +2662,7 @@ VkPipeline VulkanRenderer::backbufferBlit_createGraphicsPipeline(VkDescriptorSet throw std::runtime_error(fmt::format("Failed to create graphics pipeline: {}", result)); } - s_pipeline_cache[hash] = pipeline; + m_backbufferBlitPipelineCache[hash] = pipeline; m_pipeline_cache_semaphore.notify(); return pipeline; @@ -2922,9 +2959,6 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu LatteTextureViewVk* texViewVk = (LatteTextureViewVk*)texView; draw_endRenderPass(); - if (clearBackground) - ClearColorbuffer(padView); - // barrier for input texture VkMemoryBarrier memoryBarrier{}; memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; @@ -2961,6 +2995,16 @@ void VulkanRenderer::DrawBackbufferQuad(LatteTextureView* texView, RendererOutpu vkCmdBeginRenderPass(m_state.currentCommandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); + if (clearBackground) + { + VkClearAttachment clearAttachment{}; + clearAttachment.clearValue = {0,0,0,0}; + clearAttachment.colorAttachment = 0; + clearAttachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + VkClearRect clearExtent = {{{0,0},chainInfo.m_actualExtent}, 0, 1}; + vkCmdClearAttachments(m_state.currentCommandBuffer, 1, &clearAttachment, 1, &clearExtent); + } + vkCmdBindPipeline(m_state.currentCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); m_state.currentPipeline = pipeline; @@ -3025,9 +3069,8 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS hash += (uint64)texViewVk->GetViewRGBA(); hash += (uint64)texViewVk->GetDefaultTextureSampler(useLinearTexFilter); - static std::unordered_map<uint64, VkDescriptorSet> s_set_cache; - const auto it = s_set_cache.find(hash); - if (it != s_set_cache.cend()) + const auto it = m_backbufferBlitDescriptorSetCache.find(hash); + if (it != m_backbufferBlitDescriptorSetCache.cend()) return it->second; VkDescriptorSetAllocateInfo allocInfo = {}; @@ -3058,7 +3101,7 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS vkUpdateDescriptorSets(m_logicalDevice, 1, &descriptorWrites, 0, nullptr); performanceMonitor.vk.numDescriptorSamplerTextures.increment(); - s_set_cache[hash] = result; + m_backbufferBlitDescriptorSetCache[hash] = result; return result; } @@ -3191,7 +3234,8 @@ VkDescriptorSetInfo::~VkDescriptorSetInfo() performanceMonitor.vk.numDescriptorDynUniformBuffers.decrement(statsNumDynUniformBuffers); performanceMonitor.vk.numDescriptorStorageBuffers.decrement(statsNumStorageBuffers); - VulkanRenderer::GetInstance()->ReleaseDestructibleObject(m_vkObjDescriptorSet); + auto renderer = VulkanRenderer::GetInstance(); + renderer->ReleaseDestructibleObject(m_vkObjDescriptorSet); m_vkObjDescriptorSet = nullptr; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 5ef4558d..f1450487 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -137,8 +137,8 @@ class VulkanRenderer : public Renderer public: // memory management - VKRMemoryManager* memoryManager{}; - VKRMemoryManager* GetMemoryManager() const { return memoryManager; }; + std::unique_ptr<VKRMemoryManager> memoryManager; + VKRMemoryManager* GetMemoryManager() const { return memoryManager.get(); }; VkSupportedFormatInfo_t m_supportedFormatInfo; @@ -583,6 +583,8 @@ private: std::shared_mutex m_pipeline_cache_save_mutex; std::thread m_pipeline_cache_save_thread; VkPipelineCache m_pipeline_cache{ nullptr }; + std::unordered_map<uint64, VkPipeline> m_backbufferBlitPipelineCache; + std::unordered_map<uint64, VkDescriptorSet> m_backbufferBlitDescriptorSetCache; VkPipelineLayout m_pipelineLayout{nullptr}; VkCommandPool m_commandPool{ nullptr }; @@ -860,7 +862,7 @@ private: memBarrier.pNext = nullptr; VkPipelineStageFlags srcStages = VK_PIPELINE_STAGE_TRANSFER_BIT; - VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + VkPipelineStageFlags dstStages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; memBarrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; memBarrier.dstAccessMask = 0; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp index 198a32cb..3e23b0aa 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRendererCore.cpp @@ -900,6 +900,7 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo* } } } + VKRObjectSampler* samplerObj = VKRObjectSampler::GetOrCreateSampler(&samplerInfo); vkObjDS->addRef(samplerObj); info.sampler = samplerObj->GetSampler(); @@ -1163,28 +1164,17 @@ void VulkanRenderer::draw_prepareDescriptorSets(PipelineInfo* pipeline_info, VkD const auto geometryShader = LatteSHRC_GetActiveGeometryShader(); const auto pixelShader = LatteSHRC_GetActivePixelShader(); - - if (vertexShader) - { - auto descriptorSetInfo = draw_getOrCreateDescriptorSet(pipeline_info, vertexShader); + auto prepareShaderDescriptors = [this, &pipeline_info](LatteDecompilerShader* shader) -> VkDescriptorSetInfo* { + if (!shader) + return nullptr; + auto descriptorSetInfo = draw_getOrCreateDescriptorSet(pipeline_info, shader); descriptorSetInfo->m_vkObjDescriptorSet->flagForCurrentCommandBuffer(); - vertexDS = descriptorSetInfo; - } + return descriptorSetInfo; + }; - if (pixelShader) - { - auto descriptorSetInfo = draw_getOrCreateDescriptorSet(pipeline_info, pixelShader); - descriptorSetInfo->m_vkObjDescriptorSet->flagForCurrentCommandBuffer(); - pixelDS = descriptorSetInfo; - - } - - if (geometryShader) - { - auto descriptorSetInfo = draw_getOrCreateDescriptorSet(pipeline_info, geometryShader); - descriptorSetInfo->m_vkObjDescriptorSet->flagForCurrentCommandBuffer(); - geometryDS = descriptorSetInfo; - } + vertexDS = prepareShaderDescriptors(vertexShader); + pixelDS = prepareShaderDescriptors(pixelShader); + geometryDS = prepareShaderDescriptors(geometryShader); } void VulkanRenderer::draw_updateVkBlendConstants() diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp index bf33ed90..f98eb452 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanSurfaceCopy.cpp @@ -76,6 +76,30 @@ struct CopySurfacePipelineInfo CopySurfacePipelineInfo() = default; CopySurfacePipelineInfo(VkDevice device) : m_device(device) {} CopySurfacePipelineInfo(const CopySurfacePipelineInfo& info) = delete; + ~CopySurfacePipelineInfo() + { + auto renderer = VulkanRenderer::GetInstance(); + renderer->ReleaseDestructibleObject(vkObjRenderPass); + renderer->ReleaseDestructibleObject(vkObjPipeline); + + for(auto& i : map_framebuffers) + { + for(auto& fb : i.second.m_array) + { + renderer->ReleaseDestructibleObject(fb->vkObjFramebuffer); + renderer->ReleaseDestructibleObject(fb->vkObjImageView); + } + } + + for(auto& i : map_descriptors) + { + for(auto& descriptor : i.second.m_array) + { + renderer->ReleaseDestructibleObject(descriptor->vkObjImageView); + renderer->ReleaseDestructibleObject(descriptor->vkObjDescriptorSet); + } + } + } VkDevice m_device = nullptr; @@ -842,5 +866,9 @@ void VulkanRenderer::surfaceCopy_notifyTextureRelease(LatteTextureVk* hostTextur void VulkanRenderer::surfaceCopy_cleanup() { - // todo - release m_copySurfacePipelineCache etc + for(auto& i : m_copySurfacePipelineCache) + { + delete i.second; + } + m_copySurfacePipelineCache = {}; } diff --git a/src/imgui/imgui_impl_vulkan.cpp b/src/imgui/imgui_impl_vulkan.cpp index 723f153c..f9a23166 100644 --- a/src/imgui/imgui_impl_vulkan.cpp +++ b/src/imgui/imgui_impl_vulkan.cpp @@ -465,6 +465,15 @@ void ImGui_ImplVulkan_DestroyFontsTexture() if (g_FontView) { vkDestroyImageView(v->Device, g_FontView, v->Allocator); g_FontView = VK_NULL_HANDLE; } if (g_FontImage) { vkDestroyImage(v->Device, g_FontImage, v->Allocator); g_FontImage = VK_NULL_HANDLE; } if (g_FontMemory) { vkFreeMemory(v->Device, g_FontMemory, v->Allocator); g_FontMemory = VK_NULL_HANDLE; } + + ImGuiIO& io = ImGui::GetIO(); + auto texture = io.Fonts->TexID; + if(texture != (ImTextureID)nullptr) + { + ImGui_ImplVulkan_DeleteTexture(texture); + delete (ImGuiTexture*)texture; + io.Fonts->TexID = nullptr; + } } bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer) From c714e8cb6bbf86b3430cb94159374cf83ed52df4 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 30 Jan 2025 03:32:24 +0100 Subject: [PATCH 306/314] coreinit: Time to tick conversion is unsigned The result is treated as signed in most cases, but the calculation uses unsigned arithmetic. As a concrete example where this matters, DS VC passes -1 (2^64-1) to OSWaitEventWithTimeout which internally causes an overflow. But only with unsigned arithmetic this will result in a large positive number that behaves like the intended infinite timeout. With signed arithmetic the result is negative and the events will timeout immediately. --- src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp | 8 +++----- src/Cafe/OS/libs/coreinit/coreinit_Time.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp index c144c384..e81cc577 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Synchronization.cpp @@ -73,8 +73,6 @@ namespace coreinit } } - uint64 coreinit_getOSTime(); - bool OSWaitEventWithTimeout(OSEvent* event, uint64 timeout) { __OSLockScheduler(); @@ -95,14 +93,14 @@ namespace coreinit // workaround for a bad implementation in some Unity games (like Qube Directors Cut, see FEventWiiU::Wait) // where the the return value of OSWaitEventWithTimeout is ignored and instead the game measures the elapsed time to determine if a timeout occurred - timeout = timeout * 98ULL / 100ULL; // 98% (we want the function to return slightly before the actual timeout) + if (timeout < 0x00FFFFFFFFFFFFFFULL) + timeout = timeout * 98ULL / 100ULL; // 98% (we want the function to return slightly before the actual timeout) WaitEventWithTimeoutData data; data.thread = OSGetCurrentThread(); data.threadQueue = &event->threadQueue; data.hasTimeout = false; - - auto hostAlarm = coreinit::OSHostAlarmCreate(coreinit::coreinit_getOSTime() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout), 0, _OSWaitEventWithTimeoutHandler, &data); + auto hostAlarm = coreinit::OSHostAlarmCreate(OSGetTime() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout), 0, _OSWaitEventWithTimeoutHandler, &data); event->threadQueue.queueAndWait(OSGetCurrentThread()); coreinit::OSHostAlarmDestroy(hostAlarm); if (data.hasTimeout) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.h b/src/Cafe/OS/libs/coreinit/coreinit_Time.h index 3aa92b99..37bd5f88 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.h @@ -40,12 +40,12 @@ namespace coreinit inline TimerTicks ConvertNsToTimerTicks(uint64 ns) { - return ((GetTimerClock() / 31250LL) * ((TimerTicks)ns) / 32000LL); + return static_cast<TimerTicks>((static_cast<uint64>(GetTimerClock()) / 31250ULL) * (ns) / 32000ULL); } inline TimerTicks ConvertMsToTimerTicks(uint64 ms) { - return (TimerTicks)ms * GetTimerClock() / 1000LL; + return static_cast<TimerTicks>(ms * static_cast<uint64>(GetTimerClock()) / 1000ULL); } }; From ec2d7c086a3b2cc4f40897ae9978d4699e273b02 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 30 Jan 2025 03:49:17 +0100 Subject: [PATCH 307/314] coreinit: Clean up time functions --- .../Espresso/Recompiler/PPCRecompilerX64.cpp | 4 +-- .../HW/Latte/Core/LatteCommandProcessor.cpp | 2 +- src/Cafe/IOSU/legacy/iosu_acp.cpp | 6 ++-- src/Cafe/OS/libs/camera/camera.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Alarm.cpp | 8 ++--- .../OS/libs/coreinit/coreinit_Spinlock.cpp | 8 ++--- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 2 +- src/Cafe/OS/libs/coreinit/coreinit_Time.cpp | 31 +++++++------------ src/Cafe/OS/libs/coreinit/coreinit_Time.h | 12 +++---- src/Cafe/OS/libs/dmae/dmae.cpp | 2 +- src/Cafe/OS/libs/gx2/GX2.cpp | 2 +- src/Cafe/OS/libs/gx2/GX2_Misc.cpp | 2 +- src/Cafe/OS/libs/nn_acp/nn_acp.cpp | 2 +- src/Cafe/OS/libs/padscore/padscore.cpp | 2 +- src/Cafe/OS/libs/vpad/vpad.cpp | 4 +-- .../dialogs/SaveImport/SaveImportWindow.cpp | 2 +- 16 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp index a30295b5..97b2c14c 100644 --- a/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp +++ b/src/Cafe/HW/Espresso/Recompiler/PPCRecompilerX64.cpp @@ -114,13 +114,13 @@ void* ATTR_MS_ABI PPCRecompiler_virtualHLE(PPCInterpreter_t* hCPU, uint32 hleFun void ATTR_MS_ABI PPCRecompiler_getTBL(PPCInterpreter_t* hCPU, uint32 gprIndex) { - uint64 coreTime = coreinit::coreinit_getTimerTick(); + uint64 coreTime = coreinit::OSGetSystemTime(); hCPU->gpr[gprIndex] = (uint32)(coreTime&0xFFFFFFFF); } void ATTR_MS_ABI PPCRecompiler_getTBU(PPCInterpreter_t* hCPU, uint32 gprIndex) { - uint64 coreTime = coreinit::coreinit_getTimerTick(); + uint64 coreTime = coreinit::OSGetSystemTime(); hCPU->gpr[gprIndex] = (uint32)((coreTime>>32)&0xFFFFFFFF); } diff --git a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp index a8f81901..f592cc9e 100644 --- a/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp +++ b/src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp @@ -799,7 +799,7 @@ LatteCMDPtr LatteCP_itHLESampleTimer(LatteCMDPtr cmd, uint32 nWords) { cemu_assert_debug(nWords == 1); MPTR timerMPTR = (MPTR)LatteReadCMD(); - memory_writeU64(timerMPTR, coreinit::coreinit_getTimerTick()); + memory_writeU64(timerMPTR, coreinit::OSGetSystemTime()); return cmd; } diff --git a/src/Cafe/IOSU/legacy/iosu_acp.cpp b/src/Cafe/IOSU/legacy/iosu_acp.cpp index f5144ee6..6a9e6b89 100644 --- a/src/Cafe/IOSU/legacy/iosu_acp.cpp +++ b/src/Cafe/IOSU/legacy/iosu_acp.cpp @@ -469,7 +469,7 @@ namespace iosu entry->ukn0C = 0; entry->sizeA = _swapEndianU64(0); // ukn entry->sizeB = _swapEndianU64(dirSize); - entry->time = _swapEndianU64((coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK)); + entry->time = _swapEndianU64((coreinit::OSGetTime() / ESPRESSO_TIMER_CLOCK)); sprintf(entry->path, "%susr/save/%08x/%08x/meta/", devicePath, (uint32)(titleId >> 32), (uint32)(titleId & 0xFFFFFFFF)); count++; } @@ -504,7 +504,7 @@ namespace iosu entry->ukn0C = 0; entry->sizeA = _swapEndianU64(0); entry->sizeB = _swapEndianU64(0); - entry->time = _swapEndianU64((coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK)); + entry->time = _swapEndianU64((coreinit::OSGetTime() / ESPRESSO_TIMER_CLOCK)); sprintf(entry->path, "%susr/save/%08x/%08x/meta/", devicePath, (uint32)(titleId >> 32), (uint32)(titleId & 0xFFFFFFFF)); count++; } @@ -584,7 +584,7 @@ namespace iosu uint64 _ACPGetTimestamp() { - return coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK; + return coreinit::OSGetTime() / ESPRESSO_TIMER_CLOCK; } nnResult ACPUpdateSaveTimeStamp(uint32 persistentId, uint64 titleId, ACPDeviceType deviceType) diff --git a/src/Cafe/OS/libs/camera/camera.cpp b/src/Cafe/OS/libs/camera/camera.cpp index 03e01bfc..efb8013d 100644 --- a/src/Cafe/OS/libs/camera/camera.cpp +++ b/src/Cafe/OS/libs/camera/camera.cpp @@ -186,7 +186,7 @@ namespace camera if (g_cameraCounter == 0) { coreinit::OSCreateAlarm(g_alarm_camera.GetPtr()); - coreinit::OSSetPeriodicAlarm(g_alarm_camera.GetPtr(), coreinit::coreinit_getOSTime(), (uint64)ESPRESSO_TIMER_CLOCK / 60ull, RPLLoader_MakePPCCallable(ppcCAMUpdate60)); + coreinit::OSSetPeriodicAlarm(g_alarm_camera.GetPtr(), coreinit::OSGetTime(), (uint64)ESPRESSO_TIMER_CLOCK / 60ull, RPLLoader_MakePPCCallable(ppcCAMUpdate60)); } g_cameraCounter++; diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Alarm.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Alarm.cpp index f7e58115..ae2d1e63 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Alarm.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Alarm.cpp @@ -166,7 +166,7 @@ namespace coreinit void alarm_update() { cemu_assert_debug(!__OSHasSchedulerLock()); - uint64 currentTick = coreinit::coreinit_getOSTime(); + uint64 currentTick = coreinit::OSGetTime(); if (!OSHostAlarm::quickCheckForAlarm(currentTick)) return; __OSLockScheduler(); @@ -233,7 +233,7 @@ namespace coreinit if (period == 0) return; - uint64 currentTime = coreinit_getOSTime(); + uint64 currentTime = OSGetTime(); uint64 ticksSinceStart = currentTime - startTime; uint64 numPeriods = ticksSinceStart / period; @@ -267,7 +267,7 @@ namespace coreinit void OSSetAlarm(OSAlarm_t* alarm, uint64 delayInTicks, MPTR handlerFunc) { __OSLockScheduler(); - __OSInitiateAlarm(alarm, coreinit_getOSTime() + delayInTicks, 0, handlerFunc, false); + __OSInitiateAlarm(alarm, OSGetTime() + delayInTicks, 0, handlerFunc, false); __OSUnlockScheduler(); } @@ -310,7 +310,7 @@ namespace coreinit while( true ) { OSWaitEvent(g_alarmEvent.GetPtr()); - uint64 currentTick = coreinit_getOSTime(); + uint64 currentTick = OSGetTime(); while (true) { // get alarm to fire diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp index 5201d441..3d235107 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Spinlock.cpp @@ -86,11 +86,11 @@ namespace coreinit else { // loop until lock acquired or timeout occurred - uint64 timeoutValue = coreinit_getTimerTick() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout); + uint64 timeoutValue = OSGetSystemTime() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout); while (!spinlock->ownerThread.atomic_compare_exchange(nullptr, currentThread)) { OSYieldThread(); - if (coreinit_getTimerTick() >= timeoutValue) + if (OSGetSystemTime() >= timeoutValue) { return false; } @@ -182,11 +182,11 @@ namespace coreinit else { // loop until lock acquired or timeout occurred - uint64 timeoutValue = coreinit_getTimerTick() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout); + uint64 timeoutValue = OSGetSystemTime() + coreinit::EspressoTime::ConvertNsToTimerTicks(timeout); while (!spinlock->ownerThread.atomic_compare_exchange(nullptr, currentThread)) { OSYieldThread(); - if (coreinit_getTimerTick() >= timeoutValue) + if (OSGetSystemTime() >= timeoutValue) { return false; } diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index db457047..870d1850 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -655,7 +655,7 @@ namespace coreinit StackAllocator<OSThreadQueue> _threadQueue; OSInitThreadQueue(_threadQueue.GetPointer()); __OSLockScheduler(); - OSHostAlarm* hostAlarm = OSHostAlarmCreate(coreinit_getOSTime() + ticks, 0, _OSSleepTicks_alarmHandler, _threadQueue.GetPointer()); + OSHostAlarm* hostAlarm = OSHostAlarmCreate(OSGetTime() + ticks, 0, _OSSleepTicks_alarmHandler, _threadQueue.GetPointer()); _threadQueue.GetPointer()->queueAndWait(OSGetCurrentThread()); OSHostAlarmDestroy(hostAlarm); __OSUnlockScheduler(); diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp index d6fc27b2..50a404f4 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.cpp @@ -3,38 +3,32 @@ namespace coreinit { - - uint64 coreinit_getTimerTick() + uint64 coreinit_GetMFTB() { // bus clock is 1/5th of core clock // timer clock is 1/4th of bus clock return PPCInterpreter_getMainCoreCycleCounter() / 20ULL; } - uint64 coreinit_getOSTime() + uint64 OSGetSystemTime() { - return coreinit_getTimerTick() + ppcCyclesSince2000TimerClock; - } - - void export_OSGetTick(PPCInterpreter_t* hCPU) - { - uint64 osTime = coreinit_getOSTime(); - osLib_returnFromFunction(hCPU, (uint32)osTime); + return coreinit_GetMFTB(); } uint64 OSGetTime() { - return coreinit_getOSTime(); + return OSGetSystemTime() + ppcCyclesSince2000TimerClock; } - void export_OSGetSystemTime(PPCInterpreter_t* hCPU) + uint32 OSGetSystemTick() { - osLib_returnFromFunction64(hCPU, coreinit_getTimerTick()); + return static_cast<uint32>(coreinit_GetMFTB()); } - void export_OSGetSystemTick(PPCInterpreter_t* hCPU) + uint32 OSGetTick() { - osLib_returnFromFunction(hCPU, (uint32)coreinit_getTimerTick()); + uint64 osTime = OSGetTime(); + return static_cast<uint32>(osTime); } uint32 getLeapDaysUntilYear(uint32 year) @@ -360,14 +354,13 @@ namespace coreinit void InitializeTimeAndCalendar() { cafeExportRegister("coreinit", OSGetTime, LogType::Placeholder); - osLib_addFunction("coreinit", "OSGetSystemTime", export_OSGetSystemTime); - osLib_addFunction("coreinit", "OSGetTick", export_OSGetTick); - osLib_addFunction("coreinit", "OSGetSystemTick", export_OSGetSystemTick); + cafeExportRegister("coreinit", OSGetSystemTime, LogType::Placeholder); + cafeExportRegister("coreinit", OSGetTick, LogType::Placeholder); + cafeExportRegister("coreinit", OSGetSystemTick, LogType::Placeholder); cafeExportRegister("coreinit", OSTicksToCalendarTime, LogType::Placeholder); cafeExportRegister("coreinit", OSCalendarTimeToTicks, LogType::Placeholder); - //timeTest(); } }; \ No newline at end of file diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Time.h b/src/Cafe/OS/libs/coreinit/coreinit_Time.h index 37bd5f88..380ccf1d 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Time.h +++ b/src/Cafe/OS/libs/coreinit/coreinit_Time.h @@ -50,15 +50,11 @@ namespace coreinit }; void OSTicksToCalendarTime(uint64 ticks, OSCalendarTime_t* calenderStruct); + + uint64 OSGetSystemTime(); uint64 OSGetTime(); - - uint64 coreinit_getOSTime(); - uint64 coreinit_getTimerTick(); - - static uint64 OSGetSystemTime() - { - return coreinit_getTimerTick(); - } + uint32 OSGetSystemTick(); + uint32 OSGetTick(); void InitializeTimeAndCalendar(); }; diff --git a/src/Cafe/OS/libs/dmae/dmae.cpp b/src/Cafe/OS/libs/dmae/dmae.cpp index 6b3e8d0d..7c513784 100644 --- a/src/Cafe/OS/libs/dmae/dmae.cpp +++ b/src/Cafe/OS/libs/dmae/dmae.cpp @@ -11,7 +11,7 @@ uint64 dmaeRetiredTimestamp = 0; uint64 dmae_getTimestamp() { - return coreinit::coreinit_getTimerTick(); + return coreinit::OSGetSystemTime(); } void dmae_setRetiredTimestamp(uint64 timestamp) diff --git a/src/Cafe/OS/libs/gx2/GX2.cpp b/src/Cafe/OS/libs/gx2/GX2.cpp index c2ea34a4..593d31fb 100644 --- a/src/Cafe/OS/libs/gx2/GX2.cpp +++ b/src/Cafe/OS/libs/gx2/GX2.cpp @@ -322,7 +322,7 @@ uint64 _prevReturnedGPUTime = 0; uint64 Latte_GetTime() { - uint64 gpuTime = coreinit::coreinit_getTimerTick(); + uint64 gpuTime = coreinit::OSGetSystemTime(); gpuTime *= 20000ULL; if (gpuTime <= _prevReturnedGPUTime) gpuTime = _prevReturnedGPUTime + 1; // avoid ever returning identical timestamps diff --git a/src/Cafe/OS/libs/gx2/GX2_Misc.cpp b/src/Cafe/OS/libs/gx2/GX2_Misc.cpp index 2111238a..3c7ea3f9 100644 --- a/src/Cafe/OS/libs/gx2/GX2_Misc.cpp +++ b/src/Cafe/OS/libs/gx2/GX2_Misc.cpp @@ -54,7 +54,7 @@ void gx2Export_GX2GetGPUTimeout(PPCInterpreter_t* hCPU) void gx2Export_GX2SampleTopGPUCycle(PPCInterpreter_t* hCPU) { cemuLog_log(LogType::GX2, "GX2SampleTopGPUCycle(0x{:08x})", hCPU->gpr[3]); - memory_writeU64(hCPU->gpr[3], coreinit::coreinit_getTimerTick()); + memory_writeU64(hCPU->gpr[3], coreinit::OSGetSystemTime()); osLib_returnFromFunction(hCPU, 0); } diff --git a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp index 37ea471f..9cde0213 100644 --- a/src/Cafe/OS/libs/nn_acp/nn_acp.cpp +++ b/src/Cafe/OS/libs/nn_acp/nn_acp.cpp @@ -315,7 +315,7 @@ namespace acp ppcDefineParamU32BEPtr(timestamp64, 0); ppcDefineParamU32BEPtr(ukn, 1); // probably timezone or offset? Could also be a bool for success/failed - uint64 t = coreinit::coreinit_getOSTime() + (uint64)((sint64)(ppcCyclesSince2000_UTC - ppcCyclesSince2000) / 20LL); + uint64 t = coreinit::OSGetTime() + (uint64)((sint64)(ppcCyclesSince2000_UTC - ppcCyclesSince2000) / 20LL); timestamp64[0] = (uint32)(t >> 32); timestamp64[1] = (uint32)(t & 0xFFFFFFFF); diff --git a/src/Cafe/OS/libs/padscore/padscore.cpp b/src/Cafe/OS/libs/padscore/padscore.cpp index 0a577b97..2f359748 100644 --- a/src/Cafe/OS/libs/padscore/padscore.cpp +++ b/src/Cafe/OS/libs/padscore/padscore.cpp @@ -760,7 +760,7 @@ namespace padscore void start() { OSCreateAlarm(&g_padscore.alarm); - const uint64 start_tick = coreinit::coreinit_getOSTime(); + const uint64 start_tick = coreinit::OSGetTime(); const uint64 period_tick = coreinit::EspressoTime::GetTimerClock() / 200; // every 5ms MPTR handler = PPCInterpreter_makeCallableExportDepr(TickFunction); OSSetPeriodicAlarm(&g_padscore.alarm, start_tick, period_tick, handler); diff --git a/src/Cafe/OS/libs/vpad/vpad.cpp b/src/Cafe/OS/libs/vpad/vpad.cpp index ded4304d..21c1c9e5 100644 --- a/src/Cafe/OS/libs/vpad/vpad.cpp +++ b/src/Cafe/OS/libs/vpad/vpad.cpp @@ -267,7 +267,7 @@ namespace vpad { if (channel <= 1 && vpadDelayEnabled) { - uint64 currentTime = coreinit::coreinit_getOSTime(); + uint64 currentTime = coreinit::OSGetTime(); const auto dif = currentTime - vpad::g_vpad.controller_data[channel].drcLastCallTime; if (dif <= (ESPRESSO_TIMER_CLOCK / 60ull)) { @@ -1149,7 +1149,7 @@ namespace vpad void start() { coreinit::OSCreateAlarm(&g_vpad.alarm); - const uint64 start_tick = coreinit::coreinit_getOSTime(); + const uint64 start_tick = coreinit::OSGetTime(); const uint64 period_tick = coreinit::EspressoTime::GetTimerClock() * 5 / 1000; const MPTR handler = PPCInterpreter_makeCallableExportDepr(TickFunction); coreinit::OSSetPeriodicAlarm(&g_vpad.alarm, start_tick, period_tick, handler); diff --git a/src/gui/dialogs/SaveImport/SaveImportWindow.cpp b/src/gui/dialogs/SaveImport/SaveImportWindow.cpp index b31f24b2..1b1fecbf 100644 --- a/src/gui/dialogs/SaveImport/SaveImportWindow.cpp +++ b/src/gui/dialogs/SaveImport/SaveImportWindow.cpp @@ -304,7 +304,7 @@ void SaveImportWindow::OnImport(wxCommandEvent& event) auto new_node = info_node.append_child("account"); new_node.append_attribute("persistentId").set_value(new_persistend_id_string.c_str()); auto timestamp = new_node.append_child("timestamp"); - timestamp.text().set(fmt::format("{:016x}", coreinit::coreinit_getOSTime() / ESPRESSO_TIMER_CLOCK).c_str()); // TODO time not initialized yet? + timestamp.text().set(fmt::format("{:016x}", coreinit::OSGetTime() / ESPRESSO_TIMER_CLOCK).c_str()); // TODO time not initialized yet? if(!doc.save_file(saveinfo.c_str())) cemuLog_log(LogType::Force, "couldn't insert save entry in saveinfo.xml: {}", _pathToUtf8(saveinfo)); From a6fb0a48eb437a8a41c13b782ac8ae0433bf8f98 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Tue, 4 Feb 2025 09:56:33 +0000 Subject: [PATCH 308/314] BUILD.md: Provide more info about build configuration flags (#1486) --- BUILD.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/BUILD.md b/BUILD.md index 662be96d..31c26531 100644 --- a/BUILD.md +++ b/BUILD.md @@ -192,3 +192,41 @@ Then install the dependencies: If CMake complains about Cemu already being compiled or another similar error, try deleting the `CMakeCache.txt` file inside the `build` folder and retry building. +## CMake configure flags +Some flags can be passed during CMake configure to customise which features are enabled on build. + +Example usage: `cmake -S . -B build -DCMAKE_BUILD_TYPE=release -DENABLE_SDL=ON -DENABLE_VULKAN=OFF` + +### All platforms +| Flag | | Description | Default | Note | +|--------------------|:--|-----------------------------------------------------------------------------|---------|--------------------| +| ALLOW_PORTABLE | | Allow Cemu to use the `portable` directory to store configs and data | ON | | +| CEMU_CXX_FLAGS | | Flags passed straight to the compiler, e.g. `-march=native`, `-Wall`, `/W3` | "" | | +| ENABLE_CUBEB | | Enable cubeb audio backend | ON | | +| ENABLE_DISCORD_RPC | | Enable Discord Rich presence support | ON | | +| ENABLE_OPENGL | | Enable OpenGL graphics backend | ON | Currently required | +| ENABLE_HIDAPI | | Enable HIDAPI (used for Wiimote controller API) | ON | | +| ENABLE_SDL | | Enable SDLController controller API | ON | Currently required | +| ENABLE_VCPKG | | Use VCPKG package manager to obtain dependencies | ON | | +| ENABLE_VULKAN | | Enable the Vulkan graphics backend | ON | | +| ENABLE_WXWIDGETS | | Enable wxWidgets UI | ON | Currently required | + +### Windows +| Flag | Description | Default | Note | +|--------------------|-----------------------------------|---------|--------------------| +| ENABLE_DIRECTAUDIO | Enable DirectAudio audio backend | ON | Currently required | +| ENABLE_DIRECTINPUT | Enable DirectInput controller API | ON | Currently required | +| ENABLE_XAUDIO | Enable XAudio audio backend | ON | | +| ENABLE_XINPUT | Enable XInput controller API | ON | | + +### Linux +| Flag | Description | Default | +|-----------------------|----------------------------------------------------|---------| +| ENABLE_BLUEZ | Build with Bluez (used for Wiimote controller API) | ON | +| ENABLE_FERAL_GAMEMODE | Enable Feral Interactive GameMode support | ON | +| ENABLE_WAYLAND | Enable Wayland support | ON | + +### macOS +| Flag | Description | Default | +|--------------|------------------------------------------------|---------| +| MACOS_BUNDLE | MacOS executable will be an application bundle | OFF | From ebb5ab53e23b94961d2340d359fb04d8416b1d1d Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Fri, 14 Feb 2025 19:56:51 +0000 Subject: [PATCH 309/314] Add menu item for opening shader cache directory (#1494) --- src/gui/MainWindow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 4801706a..48bdd7d7 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -77,6 +77,7 @@ enum MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, + MAINFRAME_MENU_ID_FILE_OPEN_SHADERCACHE_FOLDER, MAINFRAME_MENU_ID_FILE_EXIT, MAINFRAME_MENU_ID_FILE_END_EMULATION, MAINFRAME_MENU_ID_FILE_RECENT_0, @@ -169,6 +170,7 @@ EVT_MENU(MAINFRAME_MENU_ID_FILE_LOAD, MainWindow::OnFileMenu) EVT_MENU(MAINFRAME_MENU_ID_FILE_INSTALL_UPDATE, MainWindow::OnInstallUpdate) EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, MainWindow::OnOpenFolder) EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, MainWindow::OnOpenFolder) +EVT_MENU(MAINFRAME_MENU_ID_FILE_OPEN_SHADERCACHE_FOLDER, MainWindow::OnOpenFolder) EVT_MENU(MAINFRAME_MENU_ID_FILE_EXIT, MainWindow::OnFileExit) EVT_MENU(MAINFRAME_MENU_ID_FILE_END_EMULATION, MainWindow::OnFileMenu) EVT_MENU_RANGE(MAINFRAME_MENU_ID_FILE_RECENT_0 + 0, MAINFRAME_MENU_ID_FILE_RECENT_LAST, MainWindow::OnFileMenu) @@ -673,10 +675,15 @@ void MainWindow::OnFileMenu(wxCommandEvent& event) void MainWindow::OnOpenFolder(wxCommandEvent& event) { - if(event.GetId() == MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER) + const auto id = event.GetId(); + if(id == MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER) wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetUserDataPath())); - else if(event.GetId() == MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER) + else if(id == MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER) wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetMlcPath())); + else if (id == MAINFRAME_MENU_ID_FILE_OPEN_SHADERCACHE_FOLDER) + wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetCachePath("shaderCache"))); + + } void MainWindow::OnInstallUpdate(wxCommandEvent& event) @@ -2099,6 +2106,7 @@ void MainWindow::RecreateMenu() m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_CEMU_FOLDER, _("&Open Cemu folder")); m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER, _("&Open MLC folder")); + m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_OPEN_SHADERCACHE_FOLDER, _("Open &shader cache folder")); m_fileMenu->AppendSeparator(); m_exitMenuItem = m_fileMenu->Append(MAINFRAME_MENU_ID_FILE_EXIT, _("&Exit")); From 31d2db6f78a72feda9e3804060eb4364188c8553 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Tue, 4 Mar 2025 17:58:18 +0100 Subject: [PATCH 310/314] OpenGL: Add explicit/matching qualifiers in output shader interface fixes issues with old intel drivers --- src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp index 3a00c36a..afe53a16 100644 --- a/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp +++ b/src/Cafe/HW/Latte/Renderer/RendererOuputShader.cpp @@ -187,8 +187,8 @@ std::string RendererOutputShader::GetOpenGlVertexSource(bool render_upside_down) // vertex shader std::ostringstream vertex_source; vertex_source << - R"(#version 400 -out vec2 passUV; + R"(#version 420 +layout(location = 0) smooth out vec2 passUV; out gl_PerVertex { @@ -297,7 +297,7 @@ uniform vec2 nativeResolution; uniform vec2 outputResolution; #endif -layout(location = 0) in vec2 passUV; +layout(location = 0) smooth in vec2 passUV; layout(binding = 0) uniform sampler2D textureSrc; layout(location = 0) out vec4 colorOut0; )" + shaderSrc; From 186e92221a387ccad76cdfda661cd1bd94d82429 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Fri, 7 Mar 2025 23:40:17 +0100 Subject: [PATCH 311/314] debugger: allow printing registers using logging breakpoint placeholders (#1510) This allows a savy user, developer or modder to change the comment field of a logging breakpoint to include placeholders such as {r3} or {f3} to log the register values whenever that code is hit. --- src/Cafe/HW/Espresso/Debugger/Debugger.cpp | 68 +++++++++++++++++++--- src/Cafe/HW/Espresso/Debugger/Debugger.h | 2 +- src/gui/debugger/BreakpointWindow.cpp | 12 ++-- src/gui/debugger/DisasmCtrl.cpp | 12 +++- src/gui/debugger/DisasmCtrl.h | 1 + 5 files changed, 78 insertions(+), 17 deletions(-) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp index 37e374d6..e84c9fda 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.cpp +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.cpp @@ -8,6 +8,7 @@ #include "gui/debugger/DebuggerWindow2.h" #include "Cafe/OS/libs/coreinit/coreinit.h" +#include "util/helpers/helpers.h" #if BOOST_OS_WINDOWS #include <Windows.h> @@ -136,11 +137,6 @@ void debugger_createCodeBreakpoint(uint32 address, uint8 bpType) debugger_updateExecutionBreakpoint(address); } -void debugger_createExecuteBreakpoint(uint32 address) -{ - debugger_createCodeBreakpoint(address, DEBUGGER_BP_T_NORMAL); -} - namespace coreinit { std::vector<std::thread::native_handle_type>& OSGetSchedulerThreads(); @@ -294,8 +290,23 @@ void debugger_toggleExecuteBreakpoint(uint32 address) } else { - // create new breakpoint - debugger_createExecuteBreakpoint(address); + // create new execution breakpoint + debugger_createCodeBreakpoint(address, DEBUGGER_BP_T_NORMAL); + } +} + +void debugger_toggleLoggingBreakpoint(uint32 address) +{ + auto existingBP = debugger_getFirstBP(address, DEBUGGER_BP_T_LOGGING); + if (existingBP) + { + // delete existing breakpoint + debugger_deleteBreakpoint(existingBP); + } + else + { + // create new logging breakpoint + debugger_createCodeBreakpoint(address, DEBUGGER_BP_T_LOGGING); } } @@ -538,7 +549,48 @@ void debugger_enterTW(PPCInterpreter_t* hCPU) { if (bp->bpType == DEBUGGER_BP_T_LOGGING && bp->enabled) { - std::string logName = !bp->comment.empty() ? "Breakpoint '"+boost::nowide::narrow(bp->comment)+"'" : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address); + std::string comment = !bp->comment.empty() ? boost::nowide::narrow(bp->comment) : fmt::format("Breakpoint at 0x{:08X} (no comment)", bp->address); + + auto replacePlaceholders = [&](const std::string& prefix, const auto& formatFunc) + { + size_t pos = 0; + while ((pos = comment.find(prefix, pos)) != std::string::npos) + { + size_t endPos = comment.find('}', pos); + if (endPos == std::string::npos) + break; + + try + { + if (int regNum = ConvertString<int>(comment.substr(pos + prefix.length(), endPos - pos - prefix.length())); regNum >= 0 && regNum < 32) + { + std::string replacement = formatFunc(regNum); + comment.replace(pos, endPos - pos + 1, replacement); + pos += replacement.length(); + } + else + { + pos = endPos + 1; + } + } + catch (...) + { + pos = endPos + 1; + } + } + }; + + // Replace integer register placeholders {rX} + replacePlaceholders("{r", [&](int regNum) { + return fmt::format("0x{:08X}", hCPU->gpr[regNum]); + }); + + // Replace floating point register placeholders {fX} + replacePlaceholders("{f", [&](int regNum) { + return fmt::format("{}", hCPU->fpr[regNum].fpr); + }); + + std::string logName = "Breakpoint '" + comment + "'"; std::string logContext = fmt::format("Thread: {:08x} LR: 0x{:08x}", MEMPTR<OSThread_t>(coreinit::OSGetCurrentThread()).GetMPTR(), hCPU->spr.LR, cemuLog_advancedPPCLoggingEnabled() ? " Stack Trace:" : ""); cemuLog_log(LogType::Force, "[Debugger] {} was executed! {}", logName, logContext); if (cemuLog_advancedPPCLoggingEnabled()) diff --git a/src/Cafe/HW/Espresso/Debugger/Debugger.h b/src/Cafe/HW/Espresso/Debugger/Debugger.h index 249c47b8..c220eb8a 100644 --- a/src/Cafe/HW/Espresso/Debugger/Debugger.h +++ b/src/Cafe/HW/Espresso/Debugger/Debugger.h @@ -100,8 +100,8 @@ extern debuggerState_t debuggerState; // new API DebuggerBreakpoint* debugger_getFirstBP(uint32 address); void debugger_createCodeBreakpoint(uint32 address, uint8 bpType); -void debugger_createExecuteBreakpoint(uint32 address); void debugger_toggleExecuteBreakpoint(uint32 address); // create/remove execute breakpoint +void debugger_toggleLoggingBreakpoint(uint32 address); // create/remove logging breakpoint void debugger_toggleBreakpoint(uint32 address, bool state, DebuggerBreakpoint* bp); void debugger_createMemoryBreakpoint(uint32 address, bool onRead, bool onWrite); diff --git a/src/gui/debugger/BreakpointWindow.cpp b/src/gui/debugger/BreakpointWindow.cpp index 63b92626..658a51ad 100644 --- a/src/gui/debugger/BreakpointWindow.cpp +++ b/src/gui/debugger/BreakpointWindow.cpp @@ -202,14 +202,14 @@ void BreakpointWindow::OnLeftDClick(wxMouseEvent& event) auto it = debuggerState.breakpoints.begin(); std::advance(it, index); - wxTextEntryDialog set_value_dialog(this, _("Enter a new comment."), wxString::Format(_("Set comment for breakpoint at address %08x"), address), (*it)->comment); - if (set_value_dialog.ShowModal() == wxID_OK) + const wxString dialogTitle = (*it)->bpType == DEBUGGER_BP_T_LOGGING ? _("Enter a new logging message") : _("Enter a new comment"); + const wxString dialogMessage = (*it)->bpType == DEBUGGER_BP_T_LOGGING ? _("Set logging message when code at address %08x is ran.\nUse placeholders like {r3} or {f3} to log register values") : _("Set comment for breakpoint at address %08x"); + wxTextEntryDialog set_comment_dialog(this, dialogMessage, dialogTitle, (*it)->comment); + if (set_comment_dialog.ShowModal() == wxID_OK) { - (*it)->comment = set_value_dialog.GetValue().ToStdWstring(); - m_breakpoints->SetItem(index, ColumnComment, set_value_dialog.GetValue()); + (*it)->comment = set_comment_dialog.GetValue().ToStdWstring(); + m_breakpoints->SetItem(index, ColumnComment, set_comment_dialog.GetValue()); } - - return; } } diff --git a/src/gui/debugger/DisasmCtrl.cpp b/src/gui/debugger/DisasmCtrl.cpp index 2f38d55e..e74d64b9 100644 --- a/src/gui/debugger/DisasmCtrl.cpp +++ b/src/gui/debugger/DisasmCtrl.cpp @@ -538,7 +538,7 @@ void DisasmCtrl::OnKeyPressed(sint32 key_code, const wxPoint& position) auto optVirtualAddress = LinePixelPosToAddress(position.y); switch (key_code) { - case WXK_F9: + case WXK_F9: { if (optVirtualAddress) { @@ -549,7 +549,7 @@ void DisasmCtrl::OnKeyPressed(sint32 key_code, const wxPoint& position) } return; } - case 'G': + case 'G': { if(IsKeyDown(WXK_CONTROL)) { @@ -686,6 +686,7 @@ void DisasmCtrl::OnContextMenu(const wxPoint& position, uint32 line) // show dialog wxMenu menu; menu.Append(IDContextMenu_ToggleBreakpoint, _("Toggle breakpoint")); + menu.Append(IDContextMenu_ToggleLoggingBreakpoint, _("Toggle logging point")); if(debugger_hasPatch(virtualAddress)) menu.Append(IDContextMenu_RestoreOriginalInstructions, _("Restore original instructions")); menu.AppendSeparator(); @@ -707,6 +708,13 @@ void DisasmCtrl::OnContextMenuEntryClicked(wxCommandEvent& event) wxPostEvent(this->m_parent, evt); break; } + case IDContextMenu_ToggleLoggingBreakpoint: + { + debugger_toggleLoggingBreakpoint(m_contextMenuAddress); + wxCommandEvent evt(wxEVT_BREAKPOINT_CHANGE); + wxPostEvent(this->m_parent, evt); + break; + } case IDContextMenu_RestoreOriginalInstructions: { debugger_removePatch(m_contextMenuAddress); diff --git a/src/gui/debugger/DisasmCtrl.h b/src/gui/debugger/DisasmCtrl.h index 5a67e49a..b526e8f9 100644 --- a/src/gui/debugger/DisasmCtrl.h +++ b/src/gui/debugger/DisasmCtrl.h @@ -8,6 +8,7 @@ class DisasmCtrl : public TextList enum { IDContextMenu_ToggleBreakpoint = wxID_HIGHEST + 1, + IDContextMenu_ToggleLoggingBreakpoint, IDContextMenu_RestoreOriginalInstructions, IDContextMenu_CopyAddress, IDContextMenu_CopyUnrelocatedAddress, From 8b5cafa98e7149399b3fcffa8746f40bbec18d86 Mon Sep 17 00:00:00 2001 From: capitalistspz <keipitalists@proton.me> Date: Thu, 13 Mar 2025 00:09:45 +0000 Subject: [PATCH 312/314] Wiimote/L2CAP: More accurate descriptions for descriptors (#1512) --- src/input/api/Wiimote/l2cap/L2CapWiimote.cpp | 62 ++++++++++---------- src/input/api/Wiimote/l2cap/L2CapWiimote.h | 6 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp b/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp index 28a123f3..a6bdf574 100644 --- a/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp +++ b/src/input/api/Wiimote/l2cap/L2CapWiimote.cpp @@ -23,15 +23,15 @@ static bool AttemptSetNonBlock(int sockFd) return fcntl(sockFd, F_SETFL, fcntl(sockFd, F_GETFL) | O_NONBLOCK) == 0; } -L2CapWiimote::L2CapWiimote(int recvFd, int sendFd, bdaddr_t addr) - : m_recvFd(recvFd), m_sendFd(sendFd), m_addr(addr) +L2CapWiimote::L2CapWiimote(int controlFd, int dataFd, bdaddr_t addr) + : m_controlFd(controlFd), m_dataFd(dataFd), m_addr(addr) { } L2CapWiimote::~L2CapWiimote() { - close(m_recvFd); - close(m_sendFd); + close(m_dataFd); + close(m_controlFd); const auto& b = m_addr.b; cemuLog_logDebug(LogType::Force, "Wiimote at {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x} disconnected", b[5], b[4], b[3], b[2], b[1], b[0]); @@ -61,51 +61,51 @@ std::vector<WiimoteDevicePtr> L2CapWiimote::get_devices() std::vector<WiimoteDevicePtr> outDevices; for (const auto& addr : unconnected) { - // Socket for sending data to controller, PSM 0x11 - auto sendFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); - if (sendFd < 0) + // Control socket, PSM 0x11, needs to be open for the data socket to be opened + auto controlFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); + if (controlFd < 0) { - cemuLog_logDebug(LogType::Force, "Failed to open send socket: {}", strerror(errno)); + cemuLog_logDebug(LogType::Force, "Failed to open control socket: {}", strerror(errno)); continue; } - sockaddr_l2 sendAddr{}; - sendAddr.l2_family = AF_BLUETOOTH; - sendAddr.l2_psm = htobs(0x11); - sendAddr.l2_bdaddr = addr; + sockaddr_l2 controlAddr{}; + controlAddr.l2_family = AF_BLUETOOTH; + controlAddr.l2_psm = htobs(0x11); + controlAddr.l2_bdaddr = addr; - if (!AttemptConnect(sendFd, sendAddr) || !AttemptSetNonBlock(sendFd)) + if (!AttemptConnect(controlFd, controlAddr) || !AttemptSetNonBlock(controlFd)) { const auto& b = addr.b; - cemuLog_logDebug(LogType::Force, "Failed to connect send socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", + cemuLog_logDebug(LogType::Force, "Failed to connect control socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", b[5], b[4], b[3], b[2], b[1], b[0], strerror(errno)); - close(sendFd); + close(controlFd); continue; } - // Socket for receiving data from controller, PSM 0x13 - auto recvFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); - if (recvFd < 0) + // Socket for sending and receiving data from controller, PSM 0x13 + auto dataFd = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); + if (dataFd < 0) { - cemuLog_logDebug(LogType::Force, "Failed to open recv socket: {}", strerror(errno)); - close(sendFd); + cemuLog_logDebug(LogType::Force, "Failed to open data socket: {}", strerror(errno)); + close(controlFd); continue; } - sockaddr_l2 recvAddr{}; - recvAddr.l2_family = AF_BLUETOOTH; - recvAddr.l2_psm = htobs(0x13); - recvAddr.l2_bdaddr = addr; + sockaddr_l2 dataAddr{}; + dataAddr.l2_family = AF_BLUETOOTH; + dataAddr.l2_psm = htobs(0x13); + dataAddr.l2_bdaddr = addr; - if (!AttemptConnect(recvFd, recvAddr) || !AttemptSetNonBlock(recvFd)) + if (!AttemptConnect(dataFd, dataAddr) || !AttemptSetNonBlock(dataFd)) { const auto& b = addr.b; - cemuLog_logDebug(LogType::Force, "Failed to connect recv socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", + cemuLog_logDebug(LogType::Force, "Failed to connect data socket to '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}': {}", b[5], b[4], b[3], b[2], b[1], b[0], strerror(errno)); - close(sendFd); - close(recvFd); + close(dataFd); + close(controlFd); continue; } - outDevices.emplace_back(std::make_shared<L2CapWiimote>(sendFd, recvFd, addr)); + outDevices.emplace_back(std::make_shared<L2CapWiimote>(controlFd, dataFd, addr)); s_addressMutex.lock(); s_addresses[addr] = true; @@ -123,13 +123,13 @@ bool L2CapWiimote::write_data(const std::vector<uint8>& data) buffer[0] = 0xA2; std::memcpy(buffer + 1, data.data(), size); const auto outSize = size + 1; - return send(m_sendFd, buffer, outSize, 0) == outSize; + return send(m_dataFd, buffer, outSize, 0) == outSize; } std::optional<std::vector<uint8>> L2CapWiimote::read_data() { uint8 buffer[23]; - const auto nBytes = recv(m_sendFd, buffer, 23, 0); + const auto nBytes = recv(m_dataFd, buffer, 23, 0); if (nBytes < 0 && errno == EWOULDBLOCK) return std::vector<uint8>{}; diff --git a/src/input/api/Wiimote/l2cap/L2CapWiimote.h b/src/input/api/Wiimote/l2cap/L2CapWiimote.h index cc8d071b..0b6c5c19 100644 --- a/src/input/api/Wiimote/l2cap/L2CapWiimote.h +++ b/src/input/api/Wiimote/l2cap/L2CapWiimote.h @@ -5,7 +5,7 @@ class L2CapWiimote : public WiimoteDevice { public: - L2CapWiimote(int recvFd, int sendFd, bdaddr_t addr); + L2CapWiimote(int controlFd, int dataFd, bdaddr_t addr); ~L2CapWiimote() override; bool write_data(const std::vector<uint8>& data) override; @@ -15,8 +15,8 @@ class L2CapWiimote : public WiimoteDevice static void AddCandidateAddress(bdaddr_t addr); static std::vector<WiimoteDevicePtr> get_devices(); private: - int m_recvFd; - int m_sendFd; + int m_controlFd; + int m_dataFd; bdaddr_t m_addr; }; From 57ff99ce536149d177cb9958c5919e6aa4914180 Mon Sep 17 00:00:00 2001 From: mitoposter <weebcel@japanese.wives.forsale> Date: Wed, 19 Mar 2025 16:06:55 +0000 Subject: [PATCH 313/314] cubeb: Show default device option even if enumerating devices fails (#1515) --- src/audio/CubebAPI.cpp | 12 ++++++------ src/audio/CubebInputAPI.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/audio/CubebAPI.cpp b/src/audio/CubebAPI.cpp index f98fa601..f6d5d516 100644 --- a/src/audio/CubebAPI.cpp +++ b/src/audio/CubebAPI.cpp @@ -183,17 +183,17 @@ void CubebAPI::Destroy() std::vector<IAudioAPI::DeviceDescriptionPtr> CubebAPI::GetDevices() { - cubeb_device_collection devices; - if (cubeb_enumerate_devices(s_context, CUBEB_DEVICE_TYPE_OUTPUT, &devices) != CUBEB_OK) - return {}; - std::vector<DeviceDescriptionPtr> result; - result.reserve(devices.count + 1); // Reserve space for the default device - // Add the default device to the list auto defaultDevice = std::make_shared<CubebDeviceDescription>(nullptr, "default", L"Default Device"); result.emplace_back(defaultDevice); + cubeb_device_collection devices; + if (cubeb_enumerate_devices(s_context, CUBEB_DEVICE_TYPE_OUTPUT, &devices) != CUBEB_OK) + return result; + + result.reserve(devices.count + 1); // The default device already occupies one element + for (size_t i = 0; i < devices.count; ++i) { // const auto& device = devices.device[i]; diff --git a/src/audio/CubebInputAPI.cpp b/src/audio/CubebInputAPI.cpp index c0fa73f4..a9faa9c8 100644 --- a/src/audio/CubebInputAPI.cpp +++ b/src/audio/CubebInputAPI.cpp @@ -175,17 +175,17 @@ void CubebInputAPI::Destroy() std::vector<IAudioInputAPI::DeviceDescriptionPtr> CubebInputAPI::GetDevices() { - cubeb_device_collection devices; - if (cubeb_enumerate_devices(s_context, CUBEB_DEVICE_TYPE_INPUT, &devices) != CUBEB_OK) - return {}; - std::vector<DeviceDescriptionPtr> result; - result.reserve(devices.count + 1); // Reserve space for the default device - // Add the default device to the list auto defaultDevice = std::make_shared<CubebDeviceDescription>(nullptr, "default", L"Default Device"); result.emplace_back(defaultDevice); + cubeb_device_collection devices; + if (cubeb_enumerate_devices(s_context, CUBEB_DEVICE_TYPE_INPUT, &devices) != CUBEB_OK) + return result; + + result.reserve(devices.count + 1); // The default device already occupies one element + for (size_t i = 0; i < devices.count; ++i) { // const auto& device = devices.device[i]; From c4eab08f308e33d6501550976943b701997a0036 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 3 Apr 2025 17:35:09 +0200 Subject: [PATCH 314/314] Update vcpkg --- dependencies/vcpkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/vcpkg b/dependencies/vcpkg index a4275b7e..533a5fda 160000 --- a/dependencies/vcpkg +++ b/dependencies/vcpkg @@ -1 +1 @@ -Subproject commit a4275b7eee79fb24ec2e135481ef5fce8b41c339 +Subproject commit 533a5fda5c0646d1771345fb572e759283444d5f