Compare commits

..

3 Commits

Author SHA1 Message Date
c23f367262 service: Undo plgldr change 2024-01-06 01:48:27 +02:00
0e4e8aa45a thread: Release resource limit in Thread::Stop 2024-01-06 01:14:06 +02:00
12880e9170 core: Config plg_ldr after its creation
* Also use service manager to retrieve the service
2024-01-05 23:50:10 +02:00
108 changed files with 1446 additions and 735 deletions

View File

@ -121,7 +121,7 @@ function(download_moltenvk)
set(MOLTENVK_TAR "${CMAKE_BINARY_DIR}/externals/MoltenVK.tar")
if (NOT EXISTS ${MOLTENVK_DIR})
if (NOT EXISTS ${MOLTENVK_TAR})
file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/download/v1.2.7-rc1/MoltenVK-all.tar
file(DOWNLOAD https://github.com/KhronosGroup/MoltenVK/releases/latest/download/MoltenVK-all.tar
${MOLTENVK_TAR} SHOW_PROGRESS)
endif()

View File

@ -12,19 +12,18 @@ QPushButton#GraphicsAPIStatusBarButton:hover {
border: 1px solid #76797C;
}
QPushButton#TogglableStatusBarButton {
color: #959595;
QPushButton#3DOptionStatusBarButton {
color: #A5A5A5;
font-weight: bold;
border: 1px solid transparent;
background-color: transparent;
padding: 0px 3px 0px 3px;
text-align: center;
min-width: 60px;
min-height: 20px;
}
QPushButton#TogglableStatusBarButton:checked {
color: #00FF00;
}
QPushButton#TogglableStatusBarButton:hover {
QPushButton#3DOptionStatusBarButton:hover {
border: 1px solid #76797C;
}

View File

@ -1,3 +1,19 @@
QPushButton#TogglableStatusBarButton {
color: #959595;
border: 1px solid transparent;
background-color: transparent;
padding: 0px 3px 0px 3px;
text-align: center;
}
QPushButton#TogglableStatusBarButton:checked {
color: palette(text);
}
QPushButton#TogglableStatusBarButton:hover {
border: 1px solid #76797C;
}
QPushButton#GraphicsAPIStatusBarButton {
color: #656565;
border: 1px solid transparent;
@ -10,23 +26,6 @@ QPushButton#GraphicsAPIStatusBarButton:hover {
border: 1px solid #76797C;
}
QPushButton#TogglableStatusBarButton {
min-width: 0px;
color: #656565;
border: 1px solid transparent;
background-color: transparent;
padding: 0px 3px 0px 3px;
text-align: center;
}
QPushButton#TogglableStatusBarButton:checked {
color: #00FF00;
}
QPushButton#TogglableStatusBarButton:hover {
border: 1px solid #76797C;
}
QToolTip {
border: 1px solid #76797C;
background-color: #5A7566;

View File

@ -395,6 +395,9 @@ if(USE_SYSTEM_VULKAN_HEADERS)
else()
target_include_directories(vulkan-headers SYSTEM INTERFACE ./vulkan-headers/include)
endif()
if (APPLE)
target_include_directories(vulkan-headers SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK)
endif()
# adrenotools
if (ANDROID AND "arm64" IN_LIST ARCHITECTURE)

1071
externals/moltenvk/mvk_config.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -215,8 +215,6 @@ void Config::ReadValues() {
} catch (...) {
}
}
ReadSetting("System", Settings::values.init_ticks_type);
ReadSetting("System", Settings::values.init_ticks_override);
ReadSetting("System", Settings::values.plugin_loader_enabled);
ReadSetting("System", Settings::values.allow_plugin_loader);

View File

@ -288,14 +288,6 @@ init_clock =
# Note: 3DS can only handle times later then Jan 1 2000
init_time =
# The system ticks count to use when citra starts
# 0: Random (default), 1: Fixed
init_ticks_type =
# Tick count to use when init_ticks_type is set to Fixed.
# Defaults to 0.
init_ticks_override =
# Plugin loader state, if enabled plugins will be loaded from the SD card.
# You can also set if homebrew apps are allowed to enable the plugin loader
plugin_loader =

View File

@ -81,8 +81,8 @@ jstring Java_org_citra_citra_1emu_model_GameInfo_getTitle(JNIEnv* env, jobject o
Loader::SMDH::TitleLanguage language = Loader::SMDH::TitleLanguage::English;
// Get the title from SMDH in UTF-16 format
std::u16string title{reinterpret_cast<char16_t*>(
smdh->titles[static_cast<std::size_t>(language)].long_title.data())};
std::u16string title{
reinterpret_cast<char16_t*>(smdh->titles[static_cast<size_t>(language)].long_title.data())};
return ToJString(env, Common::UTF16ToUTF8(title).data());
}
@ -93,8 +93,8 @@ jstring Java_org_citra_citra_1emu_model_GameInfo_getCompany(JNIEnv* env, jobject
// Get the Publisher's name from SMDH in UTF-16 format
char16_t* publisher;
publisher = reinterpret_cast<char16_t*>(
smdh->titles[static_cast<std::size_t>(language)].publisher.data());
publisher =
reinterpret_cast<char16_t*>(smdh->titles[static_cast<size_t>(language)].publisher.data());
return ToJString(env, Common::UTF16ToUTF8(publisher).data());
}

View File

@ -661,8 +661,8 @@ void Java_org_citra_citra_1emu_NativeLibrary_removeAmiibo([[maybe_unused]] JNIEn
JNIEXPORT jobject JNICALL Java_org_citra_citra_1emu_utils_CiaInstallWorker_installCIA(
JNIEnv* env, jobject jobj, jstring jpath) {
std::string path = GetJString(env, jpath);
Service::AM::InstallStatus res = Service::AM::InstallCIA(
path, [env, jobj](std::size_t total_bytes_read, std::size_t file_size) {
Service::AM::InstallStatus res =
Service::AM::InstallCIA(path, [env, jobj](size_t total_bytes_read, size_t file_size) {
env->CallVoidMethod(jobj, IDCache::GetCiaInstallHelperSetProgress(),
static_cast<jint>(file_size), static_cast<jint>(total_bytes_read));
});

View File

@ -148,7 +148,7 @@ ALsizei OpenALSink::Impl::Callback(void* impl_, void* buffer, ALsizei buffer_siz
return 0;
}
const std::size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16));
const size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16));
impl->cb(reinterpret_cast<s16*>(buffer), num_frames);
return buffer_size_in_bytes;

View File

@ -83,7 +83,7 @@ void SDL2Sink::Impl::Callback(void* impl_, u8* buffer, int buffer_size_in_bytes)
if (!impl || !impl->cb)
return;
const std::size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16));
const size_t num_frames = buffer_size_in_bytes / (2 * sizeof(s16));
impl->cb(reinterpret_cast<s16*>(buffer), num_frames);
}

View File

@ -225,8 +225,6 @@ void Config::ReadValues() {
std::chrono::system_clock::from_time_t(std::mktime(&t)).time_since_epoch())
.count();
}
ReadSetting("System", Settings::values.init_ticks_type);
ReadSetting("System", Settings::values.init_ticks_override);
ReadSetting("System", Settings::values.plugin_loader_enabled);
ReadSetting("System", Settings::values.allow_plugin_loader);
@ -236,7 +234,7 @@ void Config::ReadValues() {
std::string offset_string =
sdl2_config->GetString("System", "init_time_offset", default_init_time_offset);
std::size_t sep_index = offset_string.find(' ');
size_t sep_index = offset_string.find(' ');
if (sep_index == std::string::npos) {
LOG_ERROR(Config, "Failed to parse init_time_offset. Using 0 00:00:00");

View File

@ -307,14 +307,6 @@ init_clock =
# Note: 3DS can only handle times later then Jan 1 2000
init_time =
# The system ticks count to use when citra starts
# 0: Random (default), 1: Fixed
init_ticks_type =
# Tick count to use when init_ticks_type is set to Fixed.
# Defaults to 0.
init_ticks_override =
[Camera]
# Which camera engine to use for the right outer camera
# blank (default): a dummy camera that always returns black image

View File

@ -54,11 +54,8 @@ const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> Config:
// This must be in alphabetical order according to action name as it must have the same order as
// UISetting::values.shortcuts, which is alphabetically ordered.
// clang-format off
const std::array<UISettings::Shortcut, 30> Config::default_hotkeys {{
{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::ApplicationShortcut}},
{QStringLiteral("Audio Mute/Unmute"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::WindowShortcut}},
{QStringLiteral("Audio Volume Down"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::WindowShortcut}},
{QStringLiteral("Audio Volume Up"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::WindowShortcut}},
const std::array<UISettings::Shortcut, 28> Config::default_hotkeys {{
{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral(""), Qt::ApplicationShortcut}},
{QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::WidgetWithChildrenShortcut}},
{QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}},
{QStringLiteral("Decrease 3D Factor"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+-"), Qt::ApplicationShortcut}},
@ -71,6 +68,7 @@ const std::array<UISettings::Shortcut, 30> Config::default_hotkeys {{
{QStringLiteral("Load Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F2"), Qt::WidgetWithChildrenShortcut}},
{QStringLiteral("Load File"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+O"), Qt::WidgetWithChildrenShortcut}},
{QStringLiteral("Load from Newest Slot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+V"), Qt::WindowShortcut}},
{QStringLiteral("Mute Audio"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+M"), Qt::WindowShortcut}},
{QStringLiteral("Remove Amiibo"), QStringLiteral("Main Window"), {QStringLiteral("F3"), Qt::ApplicationShortcut}},
{QStringLiteral("Restart Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F6"), Qt::WindowShortcut}},
{QStringLiteral("Rotate Screens Upright"), QStringLiteral("Main Window"), {QStringLiteral("F8"), Qt::WindowShortcut}},
@ -687,8 +685,6 @@ void Config::ReadSystemValues() {
ReadBasicSetting(Settings::values.init_clock);
ReadBasicSetting(Settings::values.init_time);
ReadBasicSetting(Settings::values.init_time_offset);
ReadBasicSetting(Settings::values.init_ticks_type);
ReadBasicSetting(Settings::values.init_ticks_override);
ReadBasicSetting(Settings::values.plugin_loader_enabled);
ReadBasicSetting(Settings::values.allow_plugin_loader);
}
@ -768,7 +764,6 @@ void Config::ReadUIValues() {
ReadBasicSetting(UISettings::values.callout_flags);
ReadBasicSetting(UISettings::values.show_console);
ReadBasicSetting(UISettings::values.pause_when_in_background);
ReadBasicSetting(UISettings::values.mute_when_in_background);
ReadBasicSetting(UISettings::values.hide_mouse);
}
@ -1176,8 +1171,6 @@ void Config::SaveSystemValues() {
WriteBasicSetting(Settings::values.init_clock);
WriteBasicSetting(Settings::values.init_time);
WriteBasicSetting(Settings::values.init_time_offset);
WriteBasicSetting(Settings::values.init_ticks_type);
WriteBasicSetting(Settings::values.init_ticks_override);
WriteBasicSetting(Settings::values.plugin_loader_enabled);
WriteBasicSetting(Settings::values.allow_plugin_loader);
}
@ -1240,7 +1233,6 @@ void Config::SaveUIValues() {
WriteBasicSetting(UISettings::values.callout_flags);
WriteBasicSetting(UISettings::values.show_console);
WriteBasicSetting(UISettings::values.pause_when_in_background);
WriteBasicSetting(UISettings::values.mute_when_in_background);
WriteBasicSetting(UISettings::values.hide_mouse);
}

View File

@ -26,7 +26,7 @@ public:
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons;
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs;
static const std::array<UISettings::Shortcut, 30> default_hotkeys;
static const std::array<UISettings::Shortcut, 28> default_hotkeys;
private:
void Initialize(const std::string& config_name);

View File

@ -74,8 +74,6 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue());
ui->toggle_background_pause->setChecked(
UISettings::values.pause_when_in_background.GetValue());
ui->toggle_background_mute->setChecked(
UISettings::values.mute_when_in_background.GetValue());
ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue());
ui->toggle_update_check->setChecked(
@ -176,7 +174,6 @@ void ConfigureGeneral::ApplyConfiguration() {
if (Settings::IsConfiguringGlobal()) {
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked();
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
UISettings::values.check_for_update_on_start = ui->toggle_update_check->isChecked();

View File

@ -36,13 +36,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_background_mute">
<property name="text">
<string>Mute audio when in background</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_hide_mouse">
<property name="text">

View File

@ -230,8 +230,6 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent)
&ConfigureSystem::UpdateBirthdayComboBox);
connect(ui->combo_init_clock, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::UpdateInitTime);
connect(ui->combo_init_ticks_type, qOverload<int>(&QComboBox::currentIndexChanged), this,
&ConfigureSystem::UpdateInitTicks);
connect(ui->button_regenerate_console_id, &QPushButton::clicked, this,
&ConfigureSystem::RefreshConsoleID);
connect(ui->button_start_download, &QPushButton::clicked, this,
@ -295,11 +293,6 @@ void ConfigureSystem::SetConfiguration() {
QTime time = QTime::fromMSecsSinceStartOfDay(static_cast<int>(time_offset * 1000));
ui->edit_init_time_offset_time->setTime(time);
ui->combo_init_ticks_type->setCurrentIndex(
static_cast<u8>(Settings::values.init_ticks_type.GetValue()));
ui->edit_init_ticks_value->setText(
QString::number(Settings::values.init_ticks_override.GetValue()));
cfg = Service::CFG::GetModule(system);
ReadSystemSettings();
@ -420,11 +413,6 @@ void ConfigureSystem::ApplyConfiguration() {
static_cast<Settings::InitClock>(ui->combo_init_clock->currentIndex());
Settings::values.init_time = ui->edit_init_time->dateTime().toSecsSinceEpoch();
Settings::values.init_ticks_type =
static_cast<Settings::InitTicks>(ui->combo_init_ticks_type->currentIndex());
Settings::values.init_ticks_override =
static_cast<s64>(ui->edit_init_ticks_value->text().toLongLong());
s64 time_offset_time = ui->edit_init_time_offset_time->time().msecsSinceStartOfDay() / 1000;
s64 time_offset_days = ui->edit_init_time_offset_days->value() * 86400;
@ -474,7 +462,6 @@ void ConfigureSystem::ConfigureTime() {
SetConfiguration();
UpdateInitTime(ui->combo_init_clock->currentIndex());
UpdateInitTicks(ui->combo_init_ticks_type->currentIndex());
}
void ConfigureSystem::UpdateInitTime(int init_clock) {
@ -490,15 +477,6 @@ void ConfigureSystem::UpdateInitTime(int init_clock) {
ui->edit_init_time_offset_time->setVisible(!is_fixed_time && is_global);
}
void ConfigureSystem::UpdateInitTicks(int init_ticks_type) {
const bool is_global = Settings::IsConfiguringGlobal();
const bool is_fixed =
static_cast<Settings::InitTicks>(init_ticks_type) == Settings::InitTicks::Fixed;
ui->label_init_ticks_value->setVisible(is_fixed && is_global);
ui->edit_init_ticks_value->setVisible(is_fixed && is_global);
}
void ConfigureSystem::RefreshConsoleID() {
QMessageBox::StandardButton reply;
QString warning_text = tr("This will replace your current virtual 3DS with a new one. "
@ -534,8 +512,6 @@ void ConfigureSystem::SetupPerGameUI() {
ui->label_birthday->setVisible(false);
ui->label_init_clock->setVisible(false);
ui->label_init_time->setVisible(false);
ui->label_init_ticks_type->setVisible(false);
ui->label_init_ticks_value->setVisible(false);
ui->label_console_id->setVisible(false);
ui->label_sound->setVisible(false);
ui->label_language->setVisible(false);
@ -546,14 +522,12 @@ void ConfigureSystem::SetupPerGameUI() {
ui->combo_birthday->setVisible(false);
ui->combo_birthmonth->setVisible(false);
ui->combo_init_clock->setVisible(false);
ui->combo_init_ticks_type->setVisible(false);
ui->combo_sound->setVisible(false);
ui->combo_language->setVisible(false);
ui->combo_country->setVisible(false);
ui->label_init_time_offset->setVisible(false);
ui->edit_init_time_offset_days->setVisible(false);
ui->edit_init_time_offset_time->setVisible(false);
ui->edit_init_ticks_value->setVisible(false);
ui->toggle_system_setup->setVisible(false);
ui->button_regenerate_console_id->setVisible(false);
// Apps can change the state of the plugin loader, so plugins load

View File

@ -43,7 +43,6 @@ private:
void UpdateBirthdayComboBox(int birthmonth_index);
void UpdateInitTime(int init_clock);
void UpdateInitTicks(int init_ticks_type);
void RefreshConsoleID();
void SetupPerGameUI();

View File

@ -304,75 +304,34 @@
</layout>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_init_ticks_type">
<property name="text">
<string>Initial System Ticks</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="combo_init_ticks_type">
<item>
<property name="text">
<string>Random</string>
</property>
</item>
<item>
<property name="text">
<string>Fixed</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_init_ticks_value">
<property name="text">
<string>Initial System Ticks Override</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="edit_init_ticks_value">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>20</number>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_play_coins">
<property name="text">
<string>Play Coins:</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="9" column="1">
<widget class="QSpinBox" name="spinBox_play_coins">
<property name="maximum">
<number>300</number>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="toggle_system_setup">
<property name="text">
<string>Run System Setup when Home Menu is launched</string>
</property>
</widget>
</item>
<item row="13" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_console_id">
<property name="text">
<string>Console ID:</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="11" column="1">
<widget class="QPushButton" name="button_regenerate_console_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -388,35 +347,35 @@
</property>
</widget>
</item>
<item row="14" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_plugin_loader">
<property name="text">
<string>3GX Plugin Loader:</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="12" column="1">
<widget class="QCheckBox" name="plugin_loader">
<property name="text">
<string>Enable 3GX plugin loader</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="13" column="1">
<widget class="QCheckBox" name="allow_plugin_loader">
<property name="text">
<string>Allow games to change plugin loader state</string>
</property>
</widget>
</item>
<item row="16" column="0">
<item row="14" column="0">
<widget class="QLabel" name="label_nus_download">
<property name="text">
<string>Download System Files from Nitendo servers</string>
</property>
</widget>
</item>
<item row="16" column="1">
<item row="14" column="1">
<widget class="QWidget" name="body_nus_download">
<layout class="QHBoxLayout" name="horizontalLayout_nus_download">
<item>

View File

@ -420,38 +420,6 @@ void GMainWindow::InitializeWidgets() {
statusBar()->insertPermanentWidget(0, graphics_api_button);
volume_popup = new QWidget(this);
volume_popup->setWindowFlags(Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::Popup);
volume_popup->setLayout(new QVBoxLayout());
volume_popup->setMinimumWidth(200);
volume_slider = new QSlider(Qt::Horizontal);
volume_slider->setObjectName(QStringLiteral("volume_slider"));
volume_slider->setMaximum(100);
volume_slider->setPageStep(5);
connect(volume_slider, &QSlider::valueChanged, this, [this](int percentage) {
Settings::values.audio_muted = false;
const auto value = static_cast<float>(percentage) / volume_slider->maximum();
Settings::values.volume.SetValue(value);
UpdateVolumeUI();
});
volume_popup->layout()->addWidget(volume_slider);
volume_button = new QPushButton();
volume_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
volume_button->setFocusPolicy(Qt::NoFocus);
volume_button->setCheckable(true);
UpdateVolumeUI();
connect(volume_button, &QPushButton::clicked, this, [&] {
UpdateVolumeUI();
volume_popup->setVisible(!volume_popup->isVisible());
QRect rect = volume_button->geometry();
QPoint bottomLeft = statusBar()->mapToGlobal(rect.topLeft());
bottomLeft.setY(bottomLeft.y() - volume_popup->geometry().height());
volume_popup->setGeometry(QRect(bottomLeft, QSize(rect.width(), rect.height())));
});
statusBar()->insertPermanentWidget(1, volume_button);
statusBar()->addPermanentWidget(multiplayer_state->GetStatusText());
statusBar()->addPermanentWidget(multiplayer_state->GetStatusIcon());
@ -704,10 +672,8 @@ void GMainWindow::InitializeHotkeys() {
}
UpdateStatusBar();
});
connect_shortcut(QStringLiteral("Audio Mute/Unmute"), &GMainWindow::OnMute);
connect_shortcut(QStringLiteral("Audio Volume Down"), &GMainWindow::OnDecreaseVolume);
connect_shortcut(QStringLiteral("Audio Volume Up"), &GMainWindow::OnIncreaseVolume);
connect_shortcut(QStringLiteral("Mute Audio"),
[] { Settings::values.audio_muted = !Settings::values.audio_muted; });
// We use "static" here in order to avoid capturing by lambda due to a MSVC bug, which makes the
// variable hold a garbage value after this function exits
@ -778,33 +744,21 @@ void GMainWindow::RestoreUIState() {
}
void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
if (!UISettings::values.pause_when_in_background) {
return;
}
if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
state != Qt::ApplicationActive) {
LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
}
if (!emulation_running) {
return;
}
if (UISettings::values.pause_when_in_background) {
if (emu_thread->IsRunning() &&
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
auto_paused = true;
OnPauseGame();
} else if (!emu_thread->IsRunning() && auto_paused && state == Qt::ApplicationActive) {
auto_paused = false;
OnStartGame();
}
}
if (UISettings::values.mute_when_in_background) {
if (!Settings::values.audio_muted &&
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
Settings::values.audio_muted = true;
auto_muted = true;
} else if (auto_muted && state == Qt::ApplicationActive) {
Settings::values.audio_muted = false;
auto_muted = false;
}
UpdateVolumeUI();
if (ui->action_Pause->isEnabled() &&
(state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
auto_paused = true;
OnPauseGame();
} else if (emulation_running && !emu_thread->IsRunning() && auto_paused &&
state == Qt::ApplicationActive) {
auto_paused = false;
OnStartGame();
}
}
@ -1920,7 +1874,7 @@ void GMainWindow::OnStartGame() {
#endif
UpdateSaveStates();
UpdateStatusButtons();
UpdateAPIIndicator();
}
void GMainWindow::OnRestartGame() {
@ -1957,7 +1911,7 @@ void GMainWindow::OnStopGame() {
ShutdownGame();
graphics_api_button->setEnabled(true);
Settings::RestoreGlobalState(false);
UpdateStatusButtons();
UpdateAPIIndicator();
}
void GMainWindow::OnLoadComplete() {
@ -2198,7 +2152,7 @@ void GMainWindow::OnConfigure() {
}
UpdateSecondaryWindowVisibility();
UpdateBootHomeMenuState();
UpdateStatusButtons();
UpdateAPIIndicator();
} else {
Settings::values.input_profiles = old_input_profiles;
Settings::values.touch_from_button_maps = old_touch_from_button_maps;
@ -2628,57 +2582,6 @@ void GMainWindow::ShowMouseCursor() {
}
}
void GMainWindow::OnMute() {
Settings::values.audio_muted = !Settings::values.audio_muted;
UpdateVolumeUI();
}
void GMainWindow::OnDecreaseVolume() {
Settings::values.audio_muted = false;
const auto current_volume =
static_cast<s32>(Settings::values.volume.GetValue() * volume_slider->maximum());
int step = 5;
if (current_volume <= 30) {
step = 2;
}
if (current_volume <= 6) {
step = 1;
}
const auto value =
static_cast<float>(std::max(current_volume - step, 0)) / volume_slider->maximum();
Settings::values.volume.SetValue(value);
UpdateVolumeUI();
}
void GMainWindow::OnIncreaseVolume() {
Settings::values.audio_muted = false;
const auto current_volume =
static_cast<s32>(Settings::values.volume.GetValue() * volume_slider->maximum());
int step = 5;
if (current_volume < 30) {
step = 2;
}
if (current_volume < 6) {
step = 1;
}
const auto value = static_cast<float>(current_volume + step) / volume_slider->maximum();
Settings::values.volume.SetValue(value);
UpdateVolumeUI();
}
void GMainWindow::UpdateVolumeUI() {
const auto volume_value =
static_cast<int>(Settings::values.volume.GetValue() * volume_slider->maximum());
volume_slider->setValue(volume_value);
if (Settings::values.audio_muted) {
volume_button->setChecked(false);
volume_button->setText(tr("VOLUME: MUTE"));
} else {
volume_button->setChecked(true);
volume_button->setText(tr("VOLUME: %1%", "Volume percentage (e.g. 50%)").arg(volume_value));
}
}
void GMainWindow::UpdateAPIIndicator(bool update) {
static std::array graphics_apis = {QStringLiteral("SOFTWARE"), QStringLiteral("OPENGL"),
QStringLiteral("VULKAN")};
@ -2699,11 +2602,6 @@ void GMainWindow::UpdateAPIIndicator(bool update) {
graphics_api_button->setStyleSheet(style_sheet);
}
void GMainWindow::UpdateStatusButtons() {
UpdateAPIIndicator();
UpdateVolumeUI();
}
void GMainWindow::OnMouseActivity() {
ShowMouseCursor();
}
@ -3005,8 +2903,6 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const QString& file_nam
if (!is_powered_on) {
config->Save();
}
UpdateStatusButtons();
}
void GMainWindow::OnMoviePlaybackCompleted() {

View File

@ -267,10 +267,6 @@ private slots:
void OnLanguageChanged(const QString& locale);
void OnMouseActivity();
void OnDecreaseVolume();
void OnIncreaseVolume();
void OnMute();
private:
Q_INVOKABLE void OnMoviePlaybackCompleted();
void UpdateStatusBar();
@ -283,9 +279,7 @@ private:
void HideMouseCursor();
void ShowMouseCursor();
void OpenPerGameConfiguration(u64 title_id, const QString& file_name);
void UpdateVolumeUI();
void UpdateAPIIndicator(bool update = false);
void UpdateStatusButtons();
#ifdef __unix__
void SetGamemodeEnabled(bool state);
#endif
@ -307,9 +301,6 @@ private:
QLabel* game_fps_label = nullptr;
QLabel* emu_frametime_label = nullptr;
QPushButton* graphics_api_button = nullptr;
QPushButton* volume_button = nullptr;
QWidget* volume_popup = nullptr;
QSlider* volume_slider = nullptr;
QTimer status_bar_update_timer;
bool message_label_used_for_movie = false;
@ -325,7 +316,6 @@ private:
QString game_path;
bool auto_paused = false;
bool auto_muted = false;
QTimer mouse_hide_timer;
// Movie

View File

@ -25,7 +25,7 @@ bool QtImageInterface::DecodePNG(std::vector<u8>& dst, u32& width, u32& height,
image = image.convertToFormat(QImage::Format_RGBA8888);
// Write RGBA8 to vector
const std::size_t image_size = width * height * 4;
const size_t image_size = width * height * 4;
dst.resize(image_size);
std::memcpy(dst.data(), image.constBits(), image_size);

View File

@ -80,7 +80,6 @@ struct Values {
Settings::Setting<bool> save_state_warning{true, "saveStateWarning"};
Settings::Setting<bool> first_start{true, "firstStart"};
Settings::Setting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
Settings::Setting<bool> mute_when_in_background{false, "muteWhenInBackground"};
Settings::Setting<bool> hide_mouse{false, "hideInactiveMouse"};
bool updater_found;

View File

@ -30,7 +30,7 @@ namespace Common {
#ifdef __APPLE__
static std::string GetCPUString() {
char buf[128];
std::size_t buf_len = sizeof(buf);
size_t buf_len = sizeof(buf);
if (sysctlbyname("machdep.cpu.brand_string", &buf, &buf_len, NULL, 0) == -1) {
return "Unknown";
}

View File

@ -63,15 +63,15 @@ struct ABIFrameInfo {
};
inline ABIFrameInfo ABI_CalculateFrameSize(std::bitset<64> regs, std::size_t frame_size) {
const std::size_t gprs_count = (regs & ABI_ALL_GPRS).count();
const std::size_t fprs_count = (regs & ABI_ALL_FPRS).count();
const size_t gprs_count = (regs & ABI_ALL_GPRS).count();
const size_t fprs_count = (regs & ABI_ALL_FPRS).count();
const std::size_t gprs_size = (gprs_count + 1) / 2 * 16;
const std::size_t fprs_size = fprs_count * 16;
const size_t gprs_size = (gprs_count + 1) / 2 * 16;
const size_t fprs_size = fprs_count * 16;
std::size_t total_size = 0;
size_t total_size = 0;
total_size += gprs_size;
const std::size_t fprs_base_subtraction = total_size;
const size_t fprs_base_subtraction = total_size;
total_size += fprs_size;
total_size += frame_size;
@ -100,11 +100,11 @@ inline void ABI_PushRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs,
}
if (!gprs.empty()) {
for (std::size_t i = 0; i < gprs.size() - 1; i += 2) {
for (size_t i = 0; i < gprs.size() - 1; i += 2) {
code.STP(gprs[i], gprs[i + 1], SP, i * sizeof(u64));
}
if (gprs.size() % 2 == 1) {
const std::size_t i = gprs.size() - 1;
const size_t i = gprs.size() - 1;
code.STR(gprs[i], SP, i * sizeof(u64));
}
}
@ -121,11 +121,11 @@ inline void ABI_PushRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs,
}
if (!fprs.empty()) {
for (std::size_t i = 0; i < fprs.size() - 1; i += 2) {
for (size_t i = 0; i < fprs.size() - 1; i += 2) {
code.STP(fprs[i], fprs[i + 1], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2));
}
if (fprs.size() % 2 == 1) {
const std::size_t i = fprs.size() - 1;
const size_t i = fprs.size() - 1;
code.STR(fprs[i], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2));
}
}
@ -159,11 +159,11 @@ inline void ABI_PopRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs,
}
if (!gprs.empty()) {
for (std::size_t i = 0; i < gprs.size() - 1; i += 2) {
for (size_t i = 0; i < gprs.size() - 1; i += 2) {
code.LDP(gprs[i], gprs[i + 1], SP, i * sizeof(u64));
}
if (gprs.size() % 2 == 1) {
const std::size_t i = gprs.size() - 1;
const size_t i = gprs.size() - 1;
code.LDR(gprs[i], SP, i * sizeof(u64));
}
}
@ -180,11 +180,11 @@ inline void ABI_PopRegisters(oaknut::CodeGenerator& code, std::bitset<64> regs,
}
if (!fprs.empty()) {
for (std::size_t i = 0; i < fprs.size() - 1; i += 2) {
for (size_t i = 0; i < fprs.size() - 1; i += 2) {
code.LDP(fprs[i], fprs[i + 1], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2));
}
if (fprs.size() % 2 == 1) {
const std::size_t i = fprs.size() - 1;
const size_t i = fprs.size() - 1;
code.LDR(fprs[i], SP, frame_info.fprs_offset + i * (sizeof(u64) * 2));
}
}

View File

@ -16,10 +16,10 @@
namespace Common {
namespace detail {
constexpr std::size_t DefaultCapacity = 0x1000;
constexpr size_t DefaultCapacity = 0x1000;
} // namespace detail
template <typename T, std::size_t Capacity = detail::DefaultCapacity>
template <typename T, size_t Capacity = detail::DefaultCapacity>
class SPSCQueue {
static_assert((Capacity & (Capacity - 1)) == 0, "Capacity must be a power of two.");
@ -74,7 +74,7 @@ private:
template <PushMode Mode, typename... Args>
bool Emplace(Args&&... args) {
const std::size_t write_index = m_write_index.load(std::memory_order::relaxed);
const size_t write_index = m_write_index.load(std::memory_order::relaxed);
if constexpr (Mode == PushMode::Try) {
// Check if we have free slots to write to.
@ -92,7 +92,7 @@ private:
}
// Determine the position to write to.
const std::size_t pos = write_index % Capacity;
const size_t pos = write_index % Capacity;
// Emplace into the queue.
new (std::addressof(m_data[pos])) T(std::forward<Args>(args)...);
@ -109,7 +109,7 @@ private:
template <PopMode Mode>
bool Pop(T& t, [[maybe_unused]] std::stop_token stop_token = {}) {
const std::size_t read_index = m_read_index.load(std::memory_order::relaxed);
const size_t read_index = m_read_index.load(std::memory_order::relaxed);
if constexpr (Mode == PopMode::Try) {
// Check if the queue is empty.
@ -136,7 +136,7 @@ private:
}
// Determine the position to read from.
const std::size_t pos = read_index % Capacity;
const size_t pos = read_index % Capacity;
// Pop the data off the queue, moving it.
t = std::move(m_data[pos]);
@ -162,7 +162,7 @@ private:
std::mutex consumer_cv_mutex;
};
template <typename T, std::size_t Capacity = detail::DefaultCapacity>
template <typename T, size_t Capacity = detail::DefaultCapacity>
class MPSCQueue {
public:
template <typename... Args>
@ -202,7 +202,7 @@ private:
std::mutex write_mutex;
};
template <typename T, std::size_t Capacity = detail::DefaultCapacity>
template <typename T, size_t Capacity = detail::DefaultCapacity>
class MPMCQueue {
public:
template <typename... Args>

View File

@ -40,9 +40,11 @@
#define WORDS_BIGENDIAN 1
#endif
typedef std::uint8_t uint8;
typedef std::uint32_t uint32;
typedef std::uint64_t uint64;
using namespace std;
typedef uint8_t uint8;
typedef uint32_t uint32;
typedef uint64_t uint64;
namespace Common {
@ -150,19 +152,19 @@ static uint64 HashLen17to32(const char* s, std::size_t len) {
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
static std::pair<uint64, uint64> WeakHashLen32WithSeeds(uint64 w, uint64 x, uint64 y, uint64 z,
uint64 a, uint64 b) {
static pair<uint64, uint64> WeakHashLen32WithSeeds(uint64 w, uint64 x, uint64 y, uint64 z, uint64 a,
uint64 b) {
a += w;
b = Rotate(b + a + z, 21);
uint64 c = a;
a += x;
a += y;
b += Rotate(a, 44);
return std::make_pair(a + z, b + c);
return make_pair(a + z, b + c);
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
static std::pair<uint64, uint64> WeakHashLen32WithSeeds(const char* s, uint64 a, uint64 b) {
static pair<uint64, uint64> WeakHashLen32WithSeeds(const char* s, uint64 a, uint64 b) {
return WeakHashLen32WithSeeds(Fetch64(s), Fetch64(s + 8), Fetch64(s + 16), Fetch64(s + 24), a,
b);
}
@ -205,8 +207,8 @@ uint64 CityHash64(const char* s, std::size_t len) {
uint64 x = Fetch64(s + len - 40);
uint64 y = Fetch64(s + len - 16) + Fetch64(s + len - 56);
uint64 z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24));
std::pair<uint64, uint64> v = WeakHashLen32WithSeeds(s + len - 64, len, z);
std::pair<uint64, uint64> w = WeakHashLen32WithSeeds(s + len - 32, y + k1, x);
pair<uint64, uint64> v = WeakHashLen32WithSeeds(s + len - 64, len, z);
pair<uint64, uint64> w = WeakHashLen32WithSeeds(s + len - 32, y + k1, x);
x = x * k1 + Fetch64(s);
// Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
@ -274,7 +276,7 @@ uint128 CityHash128WithSeed(const char* s, std::size_t len, uint128 seed) {
// We expect len >= 128 to be the common case. Keep 56 bytes of state:
// v, w, x, y, and z.
std::pair<uint64, uint64> v, w;
pair<uint64, uint64> v, w;
uint64 x = Uint128Low64(seed);
uint64 y = Uint128High64(seed);
uint64 z = len * k1;

View File

@ -38,7 +38,7 @@ bool DynamicLibrary::Load(std::string_view filename) {
if (!handle) {
DWORD error_message_id = GetLastError();
LPSTR message_buffer = nullptr;
std::size_t size =
size_t size =
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, error_message_id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),

View File

@ -1159,7 +1159,7 @@ std::size_t IOFile::ReadImpl(void* data, std::size_t length, std::size_t data_si
}
#ifdef _WIN32
static std::size_t pread(int fd, void* buf, std::size_t count, uint64_t offset) {
static std::size_t pread(int fd, void* buf, size_t count, uint64_t offset) {
long unsigned int read_bytes = 0;
OVERLAPPED overlapped = {0};
HANDLE file = reinterpret_cast<HANDLE>(_get_osfhandle(fd));

View File

@ -37,7 +37,7 @@ static inline u64 ComputeStructHash64(const T& data) noexcept {
* Combines the seed parameter with the provided hash, producing a new unique hash
* Implementation from: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
*/
[[nodiscard]] inline u64 HashCombine(const u64 seed, const u64 hash) {
inline u64 HashCombine(const u64 seed, const u64 hash) {
return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
}

View File

@ -39,7 +39,7 @@ void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) {
namespace std {
namespace polyfill {
using stop_state_callback = std::size_t;
using stop_state_callback = size_t;
class stop_state {
public:

View File

@ -28,11 +28,6 @@ enum class InitClock : u32 {
FixedTime = 1,
};
enum class InitTicks : u32 {
Random = 0,
Fixed = 1,
};
enum class LayoutOption : u32 {
Default,
SingleScreen,
@ -442,8 +437,6 @@ struct Values {
Setting<InitClock> init_clock{InitClock::SystemTime, "init_clock"};
Setting<u64> init_time{946681277ULL, "init_time"};
Setting<s64> init_time_offset{0, "init_time_offset"};
Setting<InitTicks> init_ticks_type{InitTicks::Random, "init_ticks_type"};
Setting<s64> init_ticks_override{0, "init_ticks_override"};
Setting<bool> plugin_loader_enabled{false, "plugin_loader"};
Setting<bool> allow_plugin_loader{true, "allow_plugin_loader"};

View File

@ -31,9 +31,9 @@ template <class T>
class SlotVector {
public:
~SlotVector() noexcept {
std::size_t index = 0;
size_t index = 0;
for (u64 bits : stored_bitset) {
for (std::size_t bit = 0; bits; ++bit, bits >>= 1) {
for (size_t bit = 0; bits; ++bit, bits >>= 1) {
if ((bits & 1) != 0) {
values[index + bit].object.~T();
}
@ -81,7 +81,7 @@ public:
ResetStorageBit(id.index);
}
std::size_t size() const noexcept {
size_t size() const noexcept {
return values_capacity - free_list.size();
}
@ -126,12 +126,12 @@ private:
return free_index;
}
void Reserve(std::size_t new_capacity) noexcept {
void Reserve(size_t new_capacity) noexcept {
Entry* const new_values = new Entry[new_capacity];
std::size_t index = 0;
size_t index = 0;
for (u64 bits : stored_bitset) {
for (std::size_t bit = 0; bits; ++bit, bits >>= 1) {
const std::size_t i = index + bit;
for (size_t bit = 0; bits; ++bit, bits >>= 1) {
const size_t i = index + bit;
if ((bits & 1) == 0) {
continue;
}
@ -144,7 +144,7 @@ private:
stored_bitset.resize((new_capacity + 63) / 64);
const std::size_t old_free_size = free_list.size();
const size_t old_free_size = free_list.size();
free_list.resize(old_free_size + (new_capacity - values_capacity));
std::iota(free_list.begin() + old_free_size, free_list.end(),
static_cast<u32>(values_capacity));
@ -155,7 +155,7 @@ private:
}
Entry* values = nullptr;
std::size_t values_capacity = 0;
size_t values_capacity = 0;
std::vector<u64> stored_bitset;
std::vector<u32> free_list;
@ -165,7 +165,7 @@ private:
template <>
struct std::hash<Common::SlotId> {
std::size_t operator()(const Common::SlotId& id) const noexcept {
size_t operator()(const Common::SlotId& id) const noexcept {
return std::hash<u32>{}(id.index);
}
};

View File

@ -23,23 +23,23 @@ namespace Common {
// a cache which evicts the least recently used item when it is full
// the cache elements are statically allocated.
template <class Key, class Value, std::size_t Size>
template <class Key, class Value, size_t Size>
class StaticLRUCache {
public:
using key_type = Key;
using value_type = Value;
using list_type = std::list<std::pair<Key, std::size_t>>;
using list_type = std::list<std::pair<Key, size_t>>;
using array_type = std::array<Value, Size>;
StaticLRUCache() = default;
~StaticLRUCache() = default;
std::size_t size() const {
size_t size() const {
return m_list.size();
}
constexpr std::size_t capacity() const {
constexpr size_t capacity() const {
return m_array.size();
}
@ -59,7 +59,7 @@ public:
// lookup value in the cache
auto i = find(key);
if (i == m_list.cend()) {
std::size_t next_index = size();
size_t next_index = size();
// insert item into the cache, but first check if it is full
if (next_index >= capacity()) {
// cache is full, evict the least recently used item
@ -97,10 +97,10 @@ private:
[&key](const auto& el) { return el.first == key; });
}
std::size_t evict() {
size_t evict() {
// evict item from the end of most recently used list
typename list_type::iterator i = --m_list.end();
std::size_t evicted_index = i->second;
size_t evicted_index = i->second;
m_list.erase(i);
return evicted_index;
}

View File

@ -9,7 +9,7 @@
namespace Common {
template <std::size_t N>
template <size_t N>
struct StringLiteral {
constexpr StringLiteral(const char (&str)[N]) {
std::copy_n(str, N, value);

View File

@ -101,7 +101,7 @@ void SetCurrentThreadName(const char* name) {
#elif defined(__linux__)
// Linux limits thread names to 15 characters and will outright reject any
// attempt to set a longer name with ERANGE.
std::string truncated(name, std::min(strlen(name), static_cast<std::size_t>(15)));
std::string truncated(name, std::min(strlen(name), static_cast<size_t>(15)));
if (int e = pthread_setname_np(pthread_self(), truncated.c_str())) {
errno = e;
LOG_ERROR(Common, "Failed to set thread name to '{}': {}", truncated, GetLastErrorMsg());

View File

@ -25,7 +25,7 @@ class StatefulThreadWorker {
static constexpr bool with_state = !std::is_same_v<StateType, void>;
struct DummyCallable {
int operator()(std::size_t) const noexcept {
int operator()(size_t) const noexcept {
return 0;
}
};
@ -33,13 +33,12 @@ class StatefulThreadWorker {
using Task =
std::conditional_t<with_state, UniqueFunction<void, StateType*>, UniqueFunction<void>>;
using StateMaker =
std::conditional_t<with_state, std::function<StateType(std::size_t)>, DummyCallable>;
std::conditional_t<with_state, std::function<StateType(size_t)>, DummyCallable>;
public:
explicit StatefulThreadWorker(std::size_t num_workers, std::string_view name,
StateMaker func = {})
explicit StatefulThreadWorker(size_t num_workers, std::string_view name, StateMaker func = {})
: workers_queued{num_workers}, thread_name{name} {
const auto lambda = [this, func](std::stop_token stop_token, std::size_t index) {
const auto lambda = [this, func](std::stop_token stop_token, size_t index) {
Common::SetCurrentThreadName(thread_name.data());
{
[[maybe_unused]] std::conditional_t<with_state, StateType, int> state{func(index)};
@ -70,7 +69,7 @@ public:
wait_condition.notify_all();
};
threads.reserve(num_workers);
for (std::size_t i = 0; i < num_workers; ++i) {
for (size_t i = 0; i < num_workers; ++i) {
threads.emplace_back(lambda, i);
}
}
@ -111,10 +110,10 @@ private:
std::mutex queue_mutex;
std::condition_variable_any condition;
std::condition_variable wait_condition;
std::atomic<std::size_t> work_scheduled{};
std::atomic<std::size_t> work_done{};
std::atomic<std::size_t> workers_stopped{};
std::atomic<std::size_t> workers_queued{};
std::atomic<size_t> work_scheduled{};
std::atomic<size_t> work_done{};
std::atomic<size_t> workers_stopped{};
std::atomic<size_t> workers_queued{};
std::string_view thread_name;
std::vector<std::jthread> threads;
};

View File

@ -13,8 +13,8 @@ namespace {
template <Common::StringLiteral haystack, Common::StringLiteral needle>
constexpr u32 GetMatchingBitsFromStringLiteral() {
u32 result = 0;
for (std::size_t i = 0; i < haystack.strlen; i++) {
for (std::size_t a = 0; a < needle.strlen; a++) {
for (size_t i = 0; i < haystack.strlen; i++) {
for (size_t a = 0; a < needle.strlen; a++) {
if (haystack.value[i] == needle.value[a]) {
result |= 1 << (haystack.strlen - 1 - i);
}

View File

@ -296,20 +296,6 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
return init_result;
}
// Restore any parameters that should be carried through a reset.
if (restore_deliver_arg.has_value()) {
if (auto apt = Service::APT::GetModule(*this)) {
apt->GetAppletManager()->SetDeliverArg(restore_deliver_arg);
}
restore_deliver_arg.reset();
}
if (restore_plugin_context.has_value()) {
if (auto plg_ldr = Service::PLGLDR::GetService(*this)) {
plg_ldr->SetPluginLoaderContext(restore_plugin_context.value());
}
restore_plugin_context.reset();
}
telemetry_session->AddInitialInfo(*app_loader);
std::shared_ptr<Kernel::Process> process;
const Loader::ResultStatus load_result{app_loader->Load(process)};
@ -393,8 +379,7 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
memory = std::make_unique<Memory::MemorySystem>(*this);
timing = std::make_unique<Timing>(num_cores, Settings::values.cpu_clock_percentage.GetValue(),
movie.GetOverrideBaseTicks());
timing = std::make_unique<Timing>(num_cores, Settings::values.cpu_clock_percentage.GetValue());
kernel = std::make_unique<Kernel::KernelSystem>(
*memory, *timing, [this] { PrepareReschedule(); }, memory_mode, num_cores, n3ds_hw_caps,
@ -622,13 +607,10 @@ void System::Reset() {
// reloading.
// TODO: Properly implement the reset
// Save the APT deliver arg and plugin loader context across resets.
// This is needed as we don't currently support proper app jumping.
// Since the system is completely reinitialized, we'll have to store the deliver arg manually.
boost::optional<Service::APT::DeliverArg> deliver_arg;
if (auto apt = Service::APT::GetModule(*this)) {
restore_deliver_arg = apt->GetAppletManager()->ReceiveDeliverArg();
}
if (auto plg_ldr = Service::PLGLDR::GetService(*this)) {
restore_plugin_context = plg_ldr->GetPluginLoaderContext();
deliver_arg = apt->GetAppletManager()->ReceiveDeliverArg();
}
Shutdown();
@ -641,6 +623,11 @@ void System::Reset() {
// Reload the system with the same setting
[[maybe_unused]] const System::ResultStatus result =
Load(*m_emu_window, m_filepath, m_secondary_window);
// Restore the deliver arg.
if (auto apt = Service::APT::GetModule(*this)) {
apt->GetAppletManager()->SetDeliverArg(std::move(deliver_arg));
}
}
void System::ApplySettings() {

View File

@ -8,13 +8,10 @@
#include <memory>
#include <mutex>
#include <string>
#include <boost/optional.hpp>
#include <boost/serialization/version.hpp>
#include "common/common_types.h"
#include "core/arm/arm_interface.h"
#include "core/cheats/cheats.h"
#include "core/hle/service/apt/applet_manager.h"
#include "core/hle/service/plgldr/plgldr.h"
#include "core/movie.h"
#include "core/perf_stats.h"
@ -447,9 +444,6 @@ private:
std::function<bool()> mic_permission_func;
bool mic_permission_granted = false;
boost::optional<Service::APT::DeliverArg> restore_deliver_arg;
boost::optional<Service::PLGLDR::PLG_LDR::PluginLoaderContext> restore_plugin_context;
friend class boost::serialization::access;
template <typename Archive>
void serialize(Archive& ar, const unsigned int file_version);

View File

@ -3,11 +3,9 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <random>
#include <tuple>
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/settings.h"
#include "core/core_timing.h"
namespace Core {
@ -21,28 +19,15 @@ bool Timing::Event::operator<(const Timing::Event& right) const {
return std::tie(time, fifo_order) < std::tie(right.time, right.fifo_order);
}
Timing::Timing(std::size_t num_cores, u32 cpu_clock_percentage, s64 override_base_ticks) {
// Generate non-zero base tick count to simulate time the system ran before launching the game.
// This accounts for games that rely on the system tick to seed randomness.
const auto base_ticks = override_base_ticks >= 0 ? override_base_ticks : GenerateBaseTicks();
Timing::Timing(std::size_t num_cores, u32 cpu_clock_percentage) {
timers.resize(num_cores);
for (std::size_t i = 0; i < num_cores; ++i) {
timers[i] = std::make_shared<Timer>(base_ticks);
timers[i] = std::make_shared<Timer>();
}
UpdateClockSpeed(cpu_clock_percentage);
current_timer = timers[0].get();
}
s64 Timing::GenerateBaseTicks() {
if (Settings::values.init_ticks_type.GetValue() == Settings::InitTicks::Fixed) {
return Settings::values.init_ticks_override.GetValue();
}
// Bounded to 32 bits to make sure we don't generate too high of a counter and risk overflowing.
std::mt19937 random_gen(std::random_device{}());
return random_gen();
}
void Timing::UpdateClockSpeed(u32 cpu_clock_percentage) {
for (auto& timer : timers) {
timer->cpu_clock_scale = 100.0 / cpu_clock_percentage;
@ -161,7 +146,7 @@ std::shared_ptr<Timing::Timer> Timing::GetTimer(std::size_t cpu_id) {
return timers[cpu_id];
}
Timing::Timer::Timer(s64 base_ticks) : executed_ticks(base_ticks) {}
Timing::Timer::Timer() = default;
Timing::Timer::~Timer() {
MoveEvents();

View File

@ -185,7 +185,7 @@ public:
class Timer {
public:
Timer(s64 base_ticks = 0);
Timer();
~Timer();
s64 GetMaxSliceLength() const;
@ -249,7 +249,7 @@ public:
friend class boost::serialization::access;
};
explicit Timing(std::size_t num_cores, u32 cpu_clock_percentage, s64 override_base_ticks = -1);
explicit Timing(std::size_t num_cores, u32 cpu_clock_percentage);
~Timing(){};
@ -290,9 +290,6 @@ public:
event_queue_locked = false;
}
/// Generates a random tick count to seed the system tick timer with.
static s64 GenerateBaseTicks();
private:
// unordered_map stores each element separately as a linked list node so pointers to
// elements remain stable regardless of rehashes/resizing.

View File

@ -1073,7 +1073,7 @@ std::vector<FormatInfo> ListFormats() {
continue;
}
out.push_back({current->name, ToStdString(current->long_name), extensions,
out.push_back({current->name, ToStdString(current->long_name), std::move(extensions),
std::move(supported_video_codecs), std::move(supported_audio_codecs),
GetOptionList(current->priv_class, true)});
}

View File

@ -57,9 +57,9 @@ static bool LZSS_Decompress(std::span<const u8> compressed, std::span<u8> decomp
u32 buffer_top_and_bottom;
std::memcpy(&buffer_top_and_bottom, footer, sizeof(u32));
std::size_t out = decompressed.size();
std::size_t index = compressed.size() - ((buffer_top_and_bottom >> 24) & 0xFF);
std::size_t stop_index = compressed.size() - (buffer_top_and_bottom & 0xFFFFFF);
size_t out = decompressed.size();
size_t index = compressed.size() - ((buffer_top_and_bottom >> 24) & 0xFF);
size_t stop_index = compressed.size() - (buffer_top_and_bottom & 0xFFFFFF);
std::memset(decompressed.data(), 0, decompressed.size());
std::memcpy(decompressed.data(), compressed.data(), compressed.size());

View File

@ -131,7 +131,7 @@ public:
return m_offset;
}
bool Seek(std::size_t offset) {
bool Seek(size_t offset) {
if (offset > m_size)
return false;
m_offset = offset;
@ -242,7 +242,7 @@ private:
if (m_target_relative_offset + length > m_target.size())
return false;
// Byte by byte copy.
for (std::size_t i = 0; i < length; ++i)
for (size_t i = 0; i < length; ++i)
m_target.data()[m_target.Tell() + i] = m_target.data()[m_target_relative_offset++];
m_target.Seek(m_target.Tell() + length);
return true;

View File

@ -357,7 +357,7 @@ void FileSys::Plugin3GXLoader::MapBootloader(Kernel::Process& process, Kernel::K
// Write bootloader
kernel.memory.WriteBlock(
process, _3GX_exe_load_addr - bootloader_memory_size, bootloader.data(),
std::min<std::size_t>(bootloader.size() * sizeof(u32), bootloader_memory_size));
std::min<size_t>(bootloader.size() * sizeof(u32), bootloader_memory_size));
game_instructions[0] = 0xE51FF004; // ldr pc, [pc, #-4]
game_instructions[1] = _3GX_exe_load_addr - bootloader_memory_size;

View File

@ -72,7 +72,7 @@ private:
Kernel::Process& process, Kernel::KernelSystem& kernel,
Service::PLGLDR::PLG_LDR& plg_ldr);
static constexpr std::size_t bootloader_memory_size = 0x1000;
static constexpr size_t bootloader_memory_size = 0x1000;
static void MapBootloader(Kernel::Process& process, Kernel::KernelSystem& kernel,
u32 memory_offset, std::span<const u32> exe_load_func,
const u32_le* exe_load_args, u32 checksum_size, u32 exe_checksum,

View File

@ -16,7 +16,7 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length,
return 0; // Crypto++ does not like zero size buffer
const auto segments = BreakupRead(offset, length);
std::size_t read_progress = 0;
size_t read_progress = 0;
// Skip cache if the read is too big
if (segments.size() == 1 && segments[0].second > cache_line_size) {
@ -33,8 +33,8 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length,
// TODO(PabloMK7): Make cache thread safe, read the comment in CacheReady function.
// std::unique_lock<std::shared_mutex> read_guard(cache_mutex);
for (const auto& seg : segments) {
std::size_t read_size = cache_line_size;
std::size_t page = OffsetToPage(seg.first);
size_t read_size = cache_line_size;
size_t page = OffsetToPage(seg.first);
// Check if segment is in cache
auto cache_entry = cache.request(page);
if (!cache_entry.first) {
@ -51,7 +51,7 @@ std::size_t DirectRomFSReader::ReadFile(std::size_t offset, std::size_t length,
LOG_TRACE(Service_FS, "RomFS Cache HIT: page={}, length={}, into={}", page, seg.second,
(seg.first - page));
}
std::size_t copy_amount =
size_t copy_amount =
(read_size > (seg.first - page))
? std::min((seg.first - page) + seg.second, read_size) - (seg.first - page)
: 0;
@ -98,10 +98,10 @@ std::vector<std::pair<std::size_t, std::size_t>> DirectRomFSReader::BreakupRead(
return ret;
}
std::size_t curr_offset = offset;
size_t curr_offset = offset;
while (length) {
std::size_t next_page = OffsetToPage(curr_offset + cache_line_size);
std::size_t curr_page_len = std::min(length, next_page - curr_offset);
size_t next_page = OffsetToPage(curr_offset + cache_line_size);
size_t curr_page_len = std::min(length, next_page - curr_offset);
ret.push_back(std::make_pair(curr_offset, curr_page_len));
curr_offset = next_page;
length -= curr_page_len;

View File

@ -67,8 +67,8 @@ private:
u64 data_size;
// Total cache size: 128KB
static constexpr std::size_t cache_line_size = (1 << 13); // About 8KB
static constexpr std::size_t cache_line_count = 16;
static constexpr size_t cache_line_size = (1 << 13); // About 8KB
static constexpr size_t cache_line_count = 16;
Common::StaticLRUCache<std::size_t, std::array<u8, cache_line_size>, cache_line_count> cache;
// TODO(PabloMK7): Make cache thread safe, read the comment in CacheReady function.

View File

@ -22,22 +22,22 @@ std::shared_ptr<ResourceLimit> ResourceLimit::Create(KernelSystem& kernel, std::
}
s32 ResourceLimit::GetCurrentValue(ResourceLimitType type) const {
const auto index = static_cast<std::size_t>(type);
const auto index = static_cast<size_t>(type);
return m_current_values[index];
}
s32 ResourceLimit::GetLimitValue(ResourceLimitType type) const {
const auto index = static_cast<std::size_t>(type);
const auto index = static_cast<size_t>(type);
return m_limit_values[index];
}
void ResourceLimit::SetLimitValue(ResourceLimitType type, s32 value) {
const auto index = static_cast<std::size_t>(type);
const auto index = static_cast<size_t>(type);
m_limit_values[index] = value;
}
bool ResourceLimit::Reserve(ResourceLimitType type, s32 amount) {
const auto index = static_cast<std::size_t>(type);
const auto index = static_cast<size_t>(type);
const s32 limit = m_limit_values[index];
const s32 new_value = m_current_values[index] + amount;
if (new_value > limit) {
@ -50,7 +50,7 @@ bool ResourceLimit::Reserve(ResourceLimitType type, s32 amount) {
}
bool ResourceLimit::Release(ResourceLimitType type, s32 amount) {
const auto index = static_cast<std::size_t>(type);
const auto index = static_cast<size_t>(type);
const s32 value = m_current_values[index];
if (amount > value) {
LOG_ERROR(Kernel, "Amount {} exceeds current value {} for resource type {}", amount, value,

View File

@ -68,7 +68,7 @@ public:
bool Release(ResourceLimitType type, s32 amount);
private:
using ResourceArray = std::array<s32, static_cast<std::size_t>(ResourceLimitType::Max)>;
using ResourceArray = std::array<s32, static_cast<size_t>(ResourceLimitType::Max)>;
ResourceArray m_limit_values{};
ResourceArray m_current_values{};
std::string m_name;

View File

@ -127,7 +127,7 @@ Result SharedMemory::Map(Process& target_process, VAddr address, MemoryPermissio
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
LOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match",
GetObjectId(), address, name);
return ResultInvalidCombination;
}

View File

@ -1686,8 +1686,8 @@ Result SVC::AcceptSession(Handle* out_server_session, Handle server_port_handle)
return current_process->handle_table.Create(out_server_session, std::move(session));
}
static void CopyStringPart(char* out, const char* in, std::size_t offset, std::size_t max_length) {
std::size_t str_size = strlen(in);
static void CopyStringPart(char* out, const char* in, size_t offset, size_t max_length) {
size_t str_size = strlen(in);
if (offset < str_size) {
strncpy(out, in + offset, max_length - 1);
out[max_length - 1] = '\0';

View File

@ -244,7 +244,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds, bool thread_safe_mode) {
// Don't schedule a wakeup if the thread wants to wait forever
if (nanoseconds == -1)
return;
std::size_t core = thread_safe_mode ? core_id : std::numeric_limits<std::size_t>::max();
size_t core = thread_safe_mode ? core_id : std::numeric_limits<std::size_t>::max();
thread_manager.kernel.timing.ScheduleEvent(nsToCycles(nanoseconds),
thread_manager.ThreadWakeupEventType, thread_id,

View File

@ -228,9 +228,8 @@ void AppletManager::CancelAndSendParameter(const MessageParameter& parameter) {
parameter.sender_id, parameter.destination_id, parameter.signal, parameter.buffer.size());
// If the applet is being HLEd, send directly to the applet.
const auto applet = hle_applets[parameter.destination_id];
if (applet != nullptr) {
applet->ReceiveParameter(parameter);
if (hle_applets.contains(parameter.destination_id)) {
hle_applets[parameter.destination_id]->ReceiveParameter(parameter);
} else {
// Otherwise, send the parameter the LLE way.
next_parameter = parameter;
@ -576,7 +575,7 @@ Result AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
}
// If we weren't able to load the native applet title, try to fallback to an HLE implementation.
if (hle_applets[applet_id] != nullptr) {
if (hle_applets.contains(applet_id)) {
LOG_WARNING(Service_APT, "Applet has already been started id={:03X}", applet_id);
return ResultSuccess;
} else {
@ -603,7 +602,7 @@ Result AppletManager::PreloadLibraryApplet(AppletId applet_id) {
}
// If we weren't able to load the native applet title, try to fallback to an HLE implementation.
if (hle_applets[applet_id] != nullptr) {
if (hle_applets.contains(applet_id)) {
LOG_WARNING(Service_APT, "Applet has already been started id={:08X}", applet_id);
return ResultSuccess;
} else {
@ -713,7 +712,6 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id,
.signal = SignalType::DspSleep,
.object = std::move(object),
});
return ResultSuccess;
}
auto sys_lib_slot = GetAppletSlotFromPos(AppletPos::SysLibrary);
@ -729,7 +727,6 @@ Result AppletManager::SendDspSleep(AppletId from_applet_id,
.signal = SignalType::DspSleep,
.object = std::move(object),
});
return ResultSuccess;
}
return ResultSuccess;
@ -1497,13 +1494,13 @@ void AppletManager::LoadInputDevices() {
/// Handles updating the current Applet every time it's called.
void AppletManager::HLEAppletUpdateEvent(std::uintptr_t user_data, s64 cycles_late) {
const auto id = static_cast<AppletId>(user_data);
const auto applet = hle_applets[id];
if (applet == nullptr) {
if (!hle_applets.contains(id)) {
// Dead applet, exit event loop.
LOG_WARNING(Service_APT, "Attempted to update missing applet id={:03X}", id);
LOG_WARNING(Service_APT, "Attempted to update dead applet id={:03X}", id);
return;
}
const auto applet = hle_applets[id];
if (applet->IsActive()) {
applet->Update();
}

View File

@ -34,13 +34,14 @@ void Module::SessionData::serialize(Archive& ar, const unsigned int) {
}
SERIALIZE_IMPL(Module::SessionData)
std::shared_ptr<OnlineService> Module::Interface::GetSessionService(Kernel::HLERequestContext& ctx,
IPC::RequestParser& rp) {
std::shared_ptr<OnlineService> Module::Interface::GetSessionService(
Kernel::HLERequestContext& ctx) {
const auto session_data = GetSessionData(ctx.Session());
if (session_data == nullptr || session_data->online_service == nullptr) {
LOG_WARNING(Service_BOSS, "Client attempted to use uninitialized BOSS session.");
// TODO: Error code for uninitialized session.
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultUnknown);
return nullptr;
@ -180,7 +181,7 @@ void Module::Interface::RegisterTask(Kernel::HLERequestContext& ctx) {
const u8 unk_param3 = rp.Pop<u8>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -200,7 +201,7 @@ void Module::Interface::UnregisterTask(Kernel::HLERequestContext& ctx) {
const u8 unk_param2 = rp.Pop<u8>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -229,7 +230,7 @@ void Module::Interface::ReconfigureTask(Kernel::HLERequestContext& ctx) {
void Module::Interface::GetTaskIdList(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -261,7 +262,7 @@ void Module::Interface::GetNsDataIdList(Kernel::HLERequestContext& ctx) {
const u32 start_ns_data_id = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -287,7 +288,7 @@ void Module::Interface::GetNsDataIdList1(Kernel::HLERequestContext& ctx) {
const u32 start_ns_data_id = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -313,7 +314,7 @@ void Module::Interface::GetNsDataIdList2(Kernel::HLERequestContext& ctx) {
const u32 start_ns_data_id = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -339,7 +340,7 @@ void Module::Interface::GetNsDataIdList3(Kernel::HLERequestContext& ctx) {
const u32 start_ns_data_id = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -363,7 +364,7 @@ void Module::Interface::SendProperty(Kernel::HLERequestContext& ctx) {
const u32 size = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -393,7 +394,7 @@ void Module::Interface::ReceiveProperty(Kernel::HLERequestContext& ctx) {
const u32 size = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -635,7 +636,7 @@ void Module::Interface::GetNsDataHeaderInfo(Kernel::HLERequestContext& ctx) {
const auto size = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -656,7 +657,7 @@ void Module::Interface::ReadNsData(Kernel::HLERequestContext& ctx) {
const auto size = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}
@ -728,7 +729,7 @@ void Module::Interface::GetNsDataLastUpdate(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const u32 ns_data_id = rp.Pop<u32>();
const auto online_service = GetSessionService(ctx, rp);
const auto online_service = GetSessionService(ctx);
if (online_service == nullptr) {
return;
}

View File

@ -16,10 +16,6 @@ namespace Core {
class System;
}
namespace IPC {
class RequestParser;
}
namespace Service::BOSS {
class Module final {
@ -972,8 +968,7 @@ public:
protected:
std::shared_ptr<Module> boss;
std::shared_ptr<OnlineService> GetSessionService(Kernel::HLERequestContext& ctx,
IPC::RequestParser& rp);
std::shared_ptr<OnlineService> GetSessionService(Kernel::HLERequestContext& ctx);
};
private:

View File

@ -19,14 +19,6 @@
namespace Service::BOSS {
namespace ErrCodes {
enum {
TaskNotFound = 51,
NsDataNotFound = 64,
UnknownPropertyID = 77,
};
}
OnlineService::OnlineService(u64 program_id_, u64 extdata_id_)
: program_id(program_id_), extdata_id(extdata_id_) {}
@ -168,9 +160,9 @@ Result OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& buffe
std::string task_id(size, 0);
buffer.Read(task_id.data(), 0, size);
if (task_id_list.erase(task_id) == 0) {
LOG_WARNING(Service_BOSS, "TaskId '{}' not in list", task_id);
return {ErrCodes::TaskNotFound, ErrorModule::BOSS, ErrorSummary::InvalidState,
ErrorLevel::Status};
LOG_WARNING(Service_BOSS, "TaskId not in list");
// TODO: Proper error code.
return ResultUnknown;
}
return ResultSuccess;
@ -237,10 +229,9 @@ std::vector<FileSys::Entry> OnlineService::GetBossExtDataFiles(
do {
boss_files.resize(boss_files.size() + files_to_read);
entry_count = dir->Read(files_to_read, boss_files.data() + (i++ * files_to_read));
} while (entry_count > files_to_read);
} while (files_to_read <= entry_count);
// Resize to trim off unused entries from the final read.
boss_files.resize((i - 1) * files_to_read + entry_count);
boss_files.resize(i * files_to_read + entry_count);
return boss_files;
}
@ -348,8 +339,8 @@ Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHead
const auto entry = GetNsDataEntryFromId(ns_data_id);
if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
return {ErrCodes::NsDataNotFound, ErrorModule::BOSS, ErrorSummary::InvalidState,
ErrorLevel::Status};
// TODO: Proper error code.
return ResultUnknown;
}
static constexpr std::array EXPECTED_NS_DATA_HEADER_INFO_SIZES = {
@ -407,13 +398,13 @@ Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHead
}
}
ResultVal<std::size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset,
const u32 size, Kernel::MappedBuffer& buffer) {
ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer) {
std::optional<NsDataEntry> entry = GetNsDataEntryFromId(ns_data_id);
if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
return Result(ErrCodes::NsDataNotFound, ErrorModule::BOSS, ErrorSummary::InvalidState,
ErrorLevel::Status);
// TODO: Proper error code.
return ResultUnknown;
}
if (entry->header.payload_size < size + offset) {
@ -465,8 +456,8 @@ Result OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedB
const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
return Result(ErrCodes::UnknownPropertyID, ErrorModule::BOSS, ErrorSummary::Internal,
ErrorLevel::Status);
// TODO: Proper error code.
return ResultUnknown;
}
auto& prop = current_props.properties[property_id];
@ -494,7 +485,6 @@ Result OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedB
std::visit(overload{[&](u8& cur_prop) { read_pod(cur_prop); },
[&](u16& cur_prop) { read_pod(cur_prop); },
[&](u32& cur_prop) { read_pod(cur_prop); },
[&](u64& cur_prop) { read_pod(cur_prop); },
[&](std::vector<u8>& cur_prop) { read_vector(cur_prop); },
[&](std::vector<u32>& cur_prop) { read_vector(cur_prop); }},
prop);
@ -506,8 +496,8 @@ Result OnlineService::ReceiveProperty(const u16 id, const u32 size, Kernel::Mapp
const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
return {ErrCodes::UnknownPropertyID, ErrorModule::BOSS, ErrorSummary::Internal,
ErrorLevel::Status};
// TODO: Proper error code.
return ResultUnknown;
}
auto write_pod = [&]<typename T>(T& cur_prop) {
@ -531,7 +521,6 @@ Result OnlineService::ReceiveProperty(const u16 id, const u32 size, Kernel::Mapp
std::visit(overload{[&](u8& cur_prop) { write_pod(cur_prop); },
[&](u16& cur_prop) { write_pod(cur_prop); },
[&](u32& cur_prop) { write_pod(cur_prop); },
[&](u64& cur_prop) { write_pod(cur_prop); },
[&](std::vector<u8>& cur_prop) { write_vector(cur_prop); },
[&](std::vector<u32>& cur_prop) { write_vector(cur_prop); }},
prop);

View File

@ -36,11 +36,11 @@ constexpr u32 BOSS_EXTDATA_HEADER_LENGTH = 0x18;
constexpr u32 BOSS_S_ENTRY_SIZE = 0xC00;
constexpr u32 BOSS_SAVE_HEADER_SIZE = 4;
constexpr std::size_t TASK_ID_SIZE = 8;
constexpr std::size_t URL_SIZE = 0x200;
constexpr std::size_t HEADERS_SIZE = 0x360;
constexpr std::size_t CERTIDLIST_SIZE = 3;
constexpr std::size_t TASKIDLIST_SIZE = 0x400;
constexpr size_t TASK_ID_SIZE = 8;
constexpr size_t URL_SIZE = 0x200;
constexpr size_t HEADERS_SIZE = 0x360;
constexpr size_t CERTIDLIST_SIZE = 3;
constexpr size_t TASKIDLIST_SIZE = 0x400;
constexpr std::array<u8, 8> boss_system_savedata_id{
0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x01, 0x00,
@ -113,7 +113,7 @@ struct BossSSData {
std::array<u8, URL_SIZE> url;
};
using BossTaskProperty = std::variant<u8, u16, u32, u64, std::vector<u8>, std::vector<u32>>;
using BossTaskProperty = std::variant<u8, u16, u32, std::vector<u8>, std::vector<u32>>;
struct BossTaskProperties {
bool task_result;
std::map<PropertyID, BossTaskProperty> properties{
@ -145,25 +145,6 @@ struct BossTaskProperties {
{static_cast<PropertyID>(0x1A), u8()},
{static_cast<PropertyID>(0x1B), u32()},
{static_cast<PropertyID>(0x1C), u32()},
{static_cast<PropertyID>(0x1D), u8()},
{static_cast<PropertyID>(0x1E), u8()},
{static_cast<PropertyID>(0x1F), u8()},
{static_cast<PropertyID>(0x20), u8()},
{static_cast<PropertyID>(0x21), u8()},
{static_cast<PropertyID>(0x22), u8()},
{static_cast<PropertyID>(0x23), u32()},
{static_cast<PropertyID>(0x24), u8()},
{static_cast<PropertyID>(0x25), u32()},
{static_cast<PropertyID>(0x26), u32()},
{static_cast<PropertyID>(0x27), u32()},
{static_cast<PropertyID>(0x28), u64()},
{static_cast<PropertyID>(0x29), u64()},
{static_cast<PropertyID>(0x2A), u32()},
{static_cast<PropertyID>(0x2B), u32()},
{static_cast<PropertyID>(0x2C), u8()},
{static_cast<PropertyID>(0x2D), u16()},
{static_cast<PropertyID>(0x2E), u16()},
{static_cast<PropertyID>(0x2F), std::vector<u8>(0x40)},
{PropertyID::TotalTasks, u16()},
{PropertyID::TaskIdList, std::vector<u8>(TASKIDLIST_SIZE)},
{static_cast<PropertyID>(0x3B), u32()},
@ -188,8 +169,8 @@ public:
std::optional<NsDataEntry> GetNsDataEntryFromId(const u32 ns_data_id);
Result GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer);
ResultVal<std::size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer);
ResultVal<size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer);
Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);

View File

@ -649,7 +649,7 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
buffer = {};
}
dest_buffer.Write(buffer.data(), 0,
std::min(static_cast<std::size_t>(dest_buffer_size), buffer.size()));
std::min(static_cast<size_t>(dest_buffer_size), buffer.size()));
rb.Push(ResultSuccess);
rb.PushMappedBuffer(param_buffer);

View File

@ -384,7 +384,7 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
"Config block 0x{:X} with flags {} and size {} was not found, creating "
"from defaults.",
block_id, accesss_flag, size);
const auto& default_block = GetDefaultConfigBlock(static_cast<ConfigBlockID>(block_id));
auto default_block = GetDefaultConfigBlock(static_cast<ConfigBlockID>(block_id));
auto result = CreateConfigBlock(block_id, static_cast<u16>(default_block.data.size()),
default_block.access_flags, default_block.data.data());
if (!result.IsSuccess()) {

View File

@ -173,9 +173,9 @@ void DSP_DSP::ReadPipeIfPossible(Kernel::HLERequestContext& ctx) {
void DSP_DSP::LoadComponent(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const auto size = rp.Pop<u32>();
const auto prog_mask = rp.Pop<u16>();
const auto data_mask = rp.Pop<u16>();
const u32 size = rp.Pop<u32>();
const u32 prog_mask = rp.Pop<u32>();
const u32 data_mask = rp.Pop<u32>();
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
@ -188,7 +188,7 @@ void DSP_DSP::LoadComponent(Kernel::HLERequestContext& ctx) {
system.DSP().LoadComponent(component_data);
LOG_INFO(Service_DSP, "called size=0x{:X}, prog_mask=0x{:04X}, data_mask=0x{:04X}", size,
LOG_INFO(Service_DSP, "called size=0x{:X}, prog_mask=0x{:08X}, data_mask=0x{:08X}", size,
prog_mask, data_mask);
}

View File

@ -107,7 +107,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
Result ret{0};
Kernel::MappedBuffer* buffer;
std::unique_ptr<u8*> data;
std::size_t read_size;
size_t read_size;
};
auto async_data = std::make_shared<AsyncData>();

View File

@ -112,9 +112,9 @@ static URLInfo SplitUrl(const std::string& url) {
};
}
static std::size_t WriteHeaders(httplib::Stream& stream,
std::span<const Context::RequestHeader> headers) {
std::size_t write_len = 0;
static size_t WriteHeaders(httplib::Stream& stream,
std::span<const Context::RequestHeader> headers) {
size_t write_len = 0;
for (const auto& header : headers) {
auto len = stream.write_format("%s: %s\r\n", header.name.c_str(), header.value.c_str());
if (len < 0) {
@ -130,8 +130,8 @@ static std::size_t WriteHeaders(httplib::Stream& stream,
return write_len;
}
static std::size_t HandleHeaderWrite(std::vector<Context::RequestHeader>& pending_headers,
httplib::Stream& strm, httplib::Headers& httplib_headers) {
static size_t HandleHeaderWrite(std::vector<Context::RequestHeader>& pending_headers,
httplib::Stream& strm, httplib::Headers& httplib_headers) {
std::vector<Context::RequestHeader> final_headers;
std::vector<Context::RequestHeader>::iterator it_pending_headers;
httplib::Headers::iterator it_httplib_headers;
@ -508,7 +508,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
}
Context& http_context = GetContext(async_data->context_handle);
const std::size_t remaining_data =
const size_t remaining_data =
http_context.response.body.size() - http_context.current_copied_data;
if (async_data->buffer_size >= remaining_data) {

View File

@ -217,7 +217,7 @@ public:
std::future<void> request_future;
std::atomic<u64> current_download_size_bytes;
std::atomic<u64> total_download_size_bytes;
std::size_t current_copied_data;
size_t current_copied_data;
bool uses_default_client_cert{};
httplib::Response response;

View File

@ -238,7 +238,7 @@ void ExtraHID::SendHIDStatus() {
float x, y;
std::tie(x, y) = c_stick->GetStatus();
ExtraHIDResponse response{};
ExtraHIDResponse response;
response.c_stick.header.Assign(static_cast<u8>(ResponseID::PollHID));
response.c_stick.c_stick_x.Assign(static_cast<u32>(C_STICK_CENTER + C_STICK_RADIUS * x));
response.c_stick.c_stick_y.Assign(static_cast<u32>(C_STICK_CENTER + C_STICK_RADIUS * y));

View File

@ -163,7 +163,7 @@ void IR_RST::Shutdown(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_IR, "called");
}
IR_RST::IR_RST(Core::System& system) : ServiceFramework("ir:rst", 2), system(system) {
IR_RST::IR_RST(Core::System& system) : ServiceFramework("ir:rst", 1), system(system) {
using namespace Kernel;
// Note: these two kernel objects are even available before Initialize service function is
// called.

View File

@ -66,7 +66,6 @@ PLG_LDR::PLG_LDR(Core::System& system_) : ServiceFramework{"plg:ldr", 1}, system
template <class Archive>
void PLG_LDR::PluginLoaderContext::serialize(Archive& ar, const unsigned int) {
ar& is_enabled;
ar& allow_game_change;
ar& plugin_loaded;
ar& is_default_path;
ar& plugin_path;
@ -79,7 +78,6 @@ void PLG_LDR::PluginLoaderContext::serialize(Archive& ar, const unsigned int) {
ar& exe_load_checksum;
ar& load_exe_func;
ar& load_exe_args;
ar& plugin_fb_addr;
}
SERIALIZE_IMPL(PLG_LDR::PluginLoaderContext)
@ -87,6 +85,8 @@ template <class Archive>
void PLG_LDR::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& plgldr_context;
ar& plugin_fb_addr;
ar& allow_game_change;
}
SERIALIZE_IMPL(PLG_LDR)
@ -191,7 +191,7 @@ void PLG_LDR::SetEnabled(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
bool enabled = rp.Pop<u32>() == 1;
bool can_change = enabled == plgldr_context.is_enabled || plgldr_context.allow_game_change;
bool can_change = enabled == plgldr_context.is_enabled || allow_game_change;
if (can_change) {
plgldr_context.is_enabled = enabled;
Settings::values.plugin_loader_enabled.SetValue(enabled);

View File

@ -52,7 +52,6 @@ public:
friend class boost::serialization::access;
};
bool is_enabled = true;
bool allow_game_change = true;
bool plugin_loaded = false;
bool is_default_path = false;
std::string plugin_path = "";
@ -70,8 +69,6 @@ public:
std::vector<u32> load_exe_func;
u32_le load_exe_args[4] = {0};
PAddr plugin_fb_addr = 0;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
@ -85,12 +82,6 @@ public:
ResultVal<Kernel::Handle> GetMemoryChangedHandle(Kernel::KernelSystem& kernel);
void OnMemoryChanged(Kernel::Process& process, Kernel::KernelSystem& kernel);
PluginLoaderContext& GetPluginLoaderContext() {
return plgldr_context;
}
void SetPluginLoaderContext(PluginLoaderContext& context) {
plgldr_context = context;
}
void SetEnabled(bool enabled) {
plgldr_context.is_enabled = enabled;
}
@ -98,22 +89,24 @@ public:
return plgldr_context.is_enabled;
}
void SetAllowGameChangeState(bool allow) {
plgldr_context.allow_game_change = allow;
allow_game_change = allow;
}
bool GetAllowGameChangeState() {
return plgldr_context.allow_game_change;
return allow_game_change;
}
void SetPluginFBAddr(PAddr addr) {
plgldr_context.plugin_fb_addr = addr;
plugin_fb_addr = addr;
}
PAddr GetPluginFBAddr() {
return plgldr_context.plugin_fb_addr;
return plugin_fb_addr;
}
private:
Core::System& system;
PluginLoaderContext plgldr_context;
PAddr plugin_fb_addr = 0;
bool allow_game_change = true;
void IsEnabled(Kernel::HLERequestContext& ctx);
void SetEnabled(Kernel::HLERequestContext& ctx);

View File

@ -1102,7 +1102,7 @@ void SOC_U::SendToOther(Kernel::HLERequestContext& ctx) {
#endif // _WIN32
std::vector<u8> input_buff(len);
input_mapped_buff.Read(input_buff.data(), 0,
std::min(input_mapped_buff.GetSize(), static_cast<std::size_t>(len)));
std::min(input_mapped_buff.GetSize(), static_cast<size_t>(len)));
s32 ret = -1;
if (addr_len > 0) {
@ -1853,7 +1853,7 @@ void SOC_U::GetSockOpt(Kernel::HLERequestContext& ctx) {
if (err == SOCKET_ERROR_VALUE) {
err = TranslateError(GET_ERRNO);
} else {
platform_data.resize(static_cast<std::size_t>(platform_data_size));
platform_data.resize(static_cast<size_t>(platform_data_size));
TranslateSockOptDataFromPlatform(optval, platform_data, level_opt.first,
level_opt.second);
}

View File

@ -16,7 +16,7 @@ class AppLoader_THREEDSX final : public AppLoader {
public:
AppLoader_THREEDSX(Core::System& system_, FileUtil::IOFile&& file, const std::string& filename,
const std::string& filepath)
: AppLoader(system_, std::move(file)), filename(filename), filepath(filepath) {}
: AppLoader(system_, std::move(file)), filename(std::move(filename)), filepath(filepath) {}
/**
* Returns the type of the file

View File

@ -691,7 +691,12 @@ std::vector<VAddr> MemorySystem::PhysicalToVirtualAddressForRasterizer(PAddr add
if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) {
return {addr - VRAM_PADDR + VRAM_VADDR};
}
// NOTE: Order matters here.
if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
return {addr - FCRAM_PADDR + LINEAR_HEAP_VADDR, addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
if (addr >= FCRAM_PADDR_END && addr < FCRAM_N3DS_PADDR_END) {
return {addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
auto plg_ldr = Service::PLGLDR::GetService(impl->system);
if (plg_ldr) {
auto fb_addr = plg_ldr->GetPluginFBAddr();
@ -699,12 +704,6 @@ std::vector<VAddr> MemorySystem::PhysicalToVirtualAddressForRasterizer(PAddr add
return {addr - fb_addr + PLUGIN_3GX_FB_VADDR};
}
}
if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) {
return {addr - FCRAM_PADDR + LINEAR_HEAP_VADDR, addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
if (addr >= FCRAM_PADDR_END && addr < FCRAM_N3DS_PADDR_END) {
return {addr - FCRAM_PADDR + NEW_LINEAR_HEAP_VADDR};
}
// While the physical <-> virtual mapping is 1:1 for the regions supported by the cache,
// some games (like Pokemon Super Mystery Dungeon) will try to use textures that go beyond
// the end address of VRAM, causing the Virtual->Physical translation to fail when flushing

View File

@ -120,9 +120,8 @@ struct CTMHeader {
std::array<char, 32> author; /// Author of the movie
u32_le rerecord_count; /// Number of rerecords when making the movie
u64_le input_count; /// Number of inputs (button and pad states) when making the movie
s64_le timing_base_ticks; /// The base system tick count to initialize core timing with.
std::array<u8, 156> reserved; /// Make heading 256 bytes so it has consistent size
std::array<u8, 164> reserved; /// Make heading 256 bytes so it has consistent size
};
static_assert(sizeof(CTMHeader) == 256, "CTMHeader should be 256 bytes");
#pragma pack(pop)
@ -159,7 +158,6 @@ void Movie::serialize(Archive& ar, const unsigned int file_version) {
ar& recorded_input_;
ar& init_time;
ar& base_ticks;
if (Archive::is_loading::value) {
u64 savestate_movie_id;
@ -455,10 +453,6 @@ u64 Movie::GetOverrideInitTime() const {
return init_time;
}
s64 Movie::GetOverrideBaseTicks() const {
return base_ticks;
}
Movie::ValidationResult Movie::ValidateHeader(const CTMHeader& header) const {
if (header_magic_bytes != header.filetype) {
LOG_ERROR(Movie, "Playback file does not have valid header");
@ -493,7 +487,6 @@ void Movie::SaveMovie() {
header.filetype = header_magic_bytes;
header.program_id = program_id;
header.clock_init_time = init_time;
header.timing_base_ticks = base_ticks;
header.id = id;
std::memcpy(header.author.data(), record_movie_author.data(),
@ -598,7 +591,6 @@ void Movie::PrepareForPlayback(const std::string& movie_file) {
return;
init_time = header.value().clock_init_time;
base_ticks = header.value().timing_base_ticks;
}
void Movie::PrepareForRecording() {
@ -613,8 +605,6 @@ void Movie::PrepareForRecording() {
} else {
init_time = Settings::values.init_time.GetValue();
}
base_ticks = Timing::GenerateBaseTicks();
}
Movie::ValidationResult Movie::ValidateMovie(const std::string& movie_file) const {
@ -671,7 +661,6 @@ void Movie::Shutdown() {
current_byte = 0;
current_input = 0;
init_time = 0;
base_ticks = -1;
id = 0;
}

View File

@ -74,9 +74,6 @@ public:
/// Get the init time that would override the one in the settings
u64 GetOverrideInitTime() const;
/// Get the base system ticks value that would override the one generated by core timing
s64 GetOverrideBaseTicks() const;
struct MovieMetadata {
u64 program_id;
std::string author;
@ -171,8 +168,7 @@ private:
std::string record_movie_file;
std::string record_movie_author;
u64 init_time; // Clock init time override for RNG consistency
s64 base_ticks = -1; // Core timing base system ticks override for RNG consistency
u64 init_time; // Clock init time override for RNG consistency
std::vector<u8> recorded_input;
std::size_t current_byte = 0;

View File

@ -48,8 +48,8 @@ static std::string GetSaveStatePath(u64 program_id, u64 movie_id, u32 slot) {
}
static bool ValidateSaveState(const CSTHeader& header, SaveStateInfo& info, u64 program_id,
u64 movie_id) {
const auto path = GetSaveStatePath(program_id, movie_id, info.slot);
u64 movie_id, u32 slot) {
const auto path = GetSaveStatePath(program_id, movie_id, slot);
if (header.filetype != header_magic_bytes) {
LOG_WARNING(Core, "Invalid save state file {}", path);
return false;
@ -112,7 +112,7 @@ std::vector<SaveStateInfo> ListSaveStates(u64 program_id, u64 movie_id) {
LOG_ERROR(Core, "Could not read from file {}", path);
continue;
}
if (!ValidateSaveState(header, info, program_id, movie_id)) {
if (!ValidateSaveState(header, info, program_id, movie_id, slot)) {
continue;
}
@ -185,8 +185,7 @@ void System::LoadState(u32 slot) {
// validate header
SaveStateInfo info;
info.slot = slot;
if (!ValidateSaveState(header, info, title_id, movie_id)) {
if (!ValidateSaveState(header, info, title_id, movie_id, slot)) {
throw std::runtime_error("Invalid savestate");
}

View File

@ -207,7 +207,7 @@ void CustomTexManager::PrepareDumping(u64 title_id) {
void CustomTexManager::PreloadTextures(const std::atomic_bool& stop_run,
const VideoCore::DiskResourceLoadCallback& callback) {
u64 size_sum = 0;
std::size_t preloaded = 0;
size_t preloaded = 0;
const u64 sys_mem = Common::GetMemInfo().total_physical_memory;
const u64 recommended_min_mem = 2_GiB;
@ -343,7 +343,7 @@ bool CustomTexManager::ReadConfig(u64 title_id, bool options_only) {
const auto& textures = json["textures"];
for (const auto& material : textures.items()) {
std::size_t idx{};
size_t idx{};
const u64 hash = std::stoull(material.key(), &idx, 16);
if (!idx) {
LOG_ERROR(Render, "Key {} is invalid, skipping", material.key());

View File

@ -29,7 +29,7 @@ struct GPU::Impl {
Core::Timing& timing;
Core::System& system;
Memory::MemorySystem& memory;
std::shared_ptr<Pica::DebugContext> debug_context;
Pica::DebugContext& debug_context;
Pica::PicaCore pica;
GraphicsDebugger gpu_debugger;
std::unique_ptr<RendererBase> renderer;
@ -41,7 +41,7 @@ struct GPU::Impl {
explicit Impl(Core::System& system, Frontend::EmuWindow& emu_window,
Frontend::EmuWindow* secondary_window)
: timing{system.CoreTiming()}, system{system}, memory{system.Memory()},
debug_context{Pica::g_debug_context}, pica{memory, debug_context},
debug_context{*Pica::g_debug_context}, pica{memory, debug_context},
renderer{VideoCore::CreateRenderer(emu_window, secondary_window, pica, system)},
rasterizer{renderer->Rasterizer()}, sw_blitter{std::make_unique<SwRenderer::SwBlitter>(
memory, rasterizer)} {}
@ -201,9 +201,7 @@ void GPU::Execute(const Service::GSP::Command& command) {
}
// Notify debugger that a GSP command was processed.
if (impl->debug_context) {
impl->debug_context->OnEvent(Pica::DebugContext::Event::GSPCommandProcessed, &command);
}
impl->debug_context.OnEvent(Pica::DebugContext::Event::GSPCommandProcessed, &command);
}
void GPU::SetBufferSwap(u32 screen_id, const Service::GSP::FrameBufferInfo& info) {
@ -225,9 +223,7 @@ void GPU::SetBufferSwap(u32 screen_id, const Service::GSP::FrameBufferInfo& info
framebuffer.active_fb = info.shown_fb;
// Notify debugger about the buffer swap.
if (impl->debug_context) {
impl->debug_context->OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
}
impl->debug_context.OnEvent(Pica::DebugContext::Event::BufferSwapped, nullptr);
if (screen_id == 0) {
MicroProfileFlip();
@ -386,9 +382,7 @@ void GPU::MemoryTransfer() {
MICROPROFILE_SCOPE(GPU_DisplayTransfer);
// Notify debugger about the display transfer.
if (impl->debug_context) {
impl->debug_context->OnEvent(Pica::DebugContext::Event::IncomingDisplayTransfer, nullptr);
}
impl->debug_context.OnEvent(Pica::DebugContext::Event::IncomingDisplayTransfer, nullptr);
// Perform memory transfer
if (config.is_texture_copy) {

View File

@ -7,7 +7,6 @@
#include <algorithm>
#include <functional>
#include <vector>
#include "common/logging/log.h"
#include "core/hle/service/gsp/gsp_command.h"
namespace VideoCore {

View File

@ -4,7 +4,6 @@
#pragma once
#include "common/common_funcs.h"
#include "common/vector_math.h"
#include "video_core/pica_types.h"

View File

@ -30,10 +30,9 @@ union CommandHeader {
};
static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!");
PicaCore::PicaCore(Memory::MemorySystem& memory_, std::shared_ptr<DebugContext> debug_context_)
: memory{memory_}, debug_context{std::move(debug_context_)}, geometry_pipeline{regs.internal,
gs_unit,
gs_setup},
PicaCore::PicaCore(Memory::MemorySystem& memory_, DebugContext& debug_context_)
: memory{memory_}, debug_context{debug_context_}, geometry_pipeline{regs.internal, gs_unit,
gs_setup},
shader_engine{CreateEngine(Settings::values.use_shader_jit.GetValue())} {
SetFramebufferDefaults();
@ -139,10 +138,8 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
DebugUtils::OnPicaRegWrite(id, mask, regs.internal.reg_array[id]);
// Track events.
if (debug_context) {
debug_context->OnEvent(DebugContext::Event::PicaCommandLoaded, &id);
SCOPE_EXIT({ debug_context->OnEvent(DebugContext::Event::PicaCommandProcessed, &id); });
}
debug_context.OnEvent(DebugContext::Event::PicaCommandLoaded, &id);
SCOPE_EXIT({ debug_context.OnEvent(DebugContext::Event::PicaCommandProcessed, &id); });
switch (id) {
// Trigger IRQ
@ -256,10 +253,6 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
case PICA_REG_INDEX(vs.bool_uniforms):
vs_setup.WriteUniformBoolReg(regs.internal.vs.bool_uniforms.Value());
if (!regs.internal.pipeline.gs_unit_exclusive_configuration &&
regs.internal.pipeline.use_gs == PipelineRegs::UseGS::No) {
gs_setup.WriteUniformBoolReg(regs.internal.vs.bool_uniforms.Value());
}
break;
case PICA_REG_INDEX(vs.int_uniforms[0]):
@ -268,10 +261,6 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
case PICA_REG_INDEX(vs.int_uniforms[3]): {
const u32 index = (id - PICA_REG_INDEX(vs.int_uniforms[0]));
vs_setup.WriteUniformIntReg(index, regs.internal.vs.GetIntUniform(index));
if (!regs.internal.pipeline.gs_unit_exclusive_configuration &&
regs.internal.pipeline.use_gs == PipelineRegs::UseGS::No) {
gs_setup.WriteUniformIntReg(index, regs.internal.vs.GetIntUniform(index));
}
break;
}
@ -283,11 +272,7 @@ void PicaCore::WriteInternalReg(u32 id, u32 value, u32 mask) {
case PICA_REG_INDEX(vs.uniform_setup.set_value[5]):
case PICA_REG_INDEX(vs.uniform_setup.set_value[6]):
case PICA_REG_INDEX(vs.uniform_setup.set_value[7]): {
const auto index = vs_setup.WriteUniformFloatReg(regs.internal.vs, value);
if (!regs.internal.pipeline.gs_unit_exclusive_configuration &&
regs.internal.pipeline.use_gs == PipelineRegs::UseGS::No && index) {
gs_setup.uniforms.f[index.value()] = vs_setup.uniforms.f[index.value()];
}
vs_setup.WriteUniformFloatReg(regs.internal.vs, value);
break;
}
@ -410,7 +395,7 @@ void PicaCore::SubmitImmediate(u32 value) {
return;
}
constexpr std::size_t IMMEDIATE_MODE_INDEX = 0xF;
constexpr size_t IMMEDIATE_MODE_INDEX = 0xF;
auto& setup = regs.internal.pipeline.vs_default_attributes_setup;
if (setup.index > IMMEDIATE_MODE_INDEX) {
@ -442,12 +427,9 @@ void PicaCore::DrawImmediate() {
shader_engine->SetupBatch(vs_setup, regs.internal.vs.main_offset);
// Track vertex in the debug recorder.
if (debug_context) {
debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation,
std::addressof(immediate.input_vertex));
SCOPE_EXIT(
{ debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); });
}
debug_context.OnEvent(DebugContext::Event::VertexShaderInvocation,
std::addressof(immediate.input_vertex));
SCOPE_EXIT({ debug_context.OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); });
ShaderUnit shader_unit;
AttributeBuffer output{};
@ -477,11 +459,8 @@ void PicaCore::DrawArrays(bool is_indexed) {
MICROPROFILE_SCOPE(GPU_Drawing);
// Track vertex in the debug recorder.
if (debug_context) {
debug_context->OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr);
SCOPE_EXIT(
{ debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); });
}
debug_context.OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr);
SCOPE_EXIT({ debug_context.OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); });
const bool accelerate_draw = [this] {
// Geometry shaders cannot be accelerated due to register preservation.
@ -575,10 +554,8 @@ void PicaCore::LoadVertices(bool is_indexed) {
loader.LoadVertex(base_address, index, vertex, input, input_default_attributes);
// Record vertex processing to the debugger.
if (debug_context) {
debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation,
std::addressof(input));
}
debug_context.OnEvent(DebugContext::Event::VertexShaderInvocation,
std::addressof(input));
// Invoke the vertex shader for this vertex.
shader_unit.LoadInput(regs.internal.vs, input);

View File

@ -29,7 +29,7 @@ class ShaderEngine;
class PicaCore {
public:
explicit PicaCore(Memory::MemorySystem& memory, std::shared_ptr<DebugContext> debug_context_);
explicit PicaCore(Memory::MemorySystem& memory, DebugContext& debug_context_);
~PicaCore();
void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
@ -53,7 +53,7 @@ private:
public:
union Regs {
static constexpr std::size_t NUM_REGS = 0x732;
static constexpr size_t NUM_REGS = 0x732;
struct {
u32 hardware_id;
@ -274,7 +274,7 @@ private:
private:
Memory::MemorySystem& memory;
VideoCore::RasterizerInterface* rasterizer;
std::shared_ptr<DebugContext> debug_context;
DebugContext& debug_context;
Service::GSP::InterruptHandler signal_interrupt;
GeometryPipeline geometry_pipeline;
PrimitiveAssembler primitive_assembler;

View File

@ -4,12 +4,7 @@
#pragma once
#include <fmt/format.h>
#include <string>
#include "common/assert.h"
#include "common/bit_field.h"
#include "common/common_funcs.h"
namespace Pica {

View File

@ -5,7 +5,6 @@
#pragma once
#include <array>
#include "common/assert.h"
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/math_util.h"

View File

@ -2,10 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "common/bit_set.h"
#include "common/hash.h"
#include "common/logging/log.h"
#include "video_core/pica/regs_shader.h"
#include "video_core/pica/shader_setup.h"
@ -27,23 +25,21 @@ void ShaderSetup::WriteUniformIntReg(u32 index, const Common::Vec4<u8> values) {
uniforms.i[index] = values;
}
std::optional<u32> ShaderSetup::WriteUniformFloatReg(ShaderRegs& config, u32 value) {
void ShaderSetup::WriteUniformFloatReg(ShaderRegs& config, u32 value) {
auto& uniform_setup = config.uniform_setup;
const bool is_float32 = uniform_setup.IsFloat32();
if (!uniform_queue.Push(value, is_float32)) {
return std::nullopt;
return;
}
const auto uniform = uniform_queue.Get(is_float32);
if (uniform_setup.index >= uniforms.f.size()) {
LOG_ERROR(HW_GPU, "Invalid float uniform index {}", uniform_setup.index.Value());
return std::nullopt;
return;
}
const u32 index = uniform_setup.index.Value();
uniforms.f[index] = uniform;
uniform_setup.index.Assign(index + 1);
return index;
uniforms.f[uniform_setup.index] = uniform;
uniform_setup.index.Assign(uniform_setup.index + 1);
}
u64 ShaderSetup::GetProgramCodeHash() {

View File

@ -4,7 +4,6 @@
#pragma once
#include <optional>
#include "common/vector_math.h"
#include "video_core/pica/packed_attribute.h"
#include "video_core/pica_types.h"
@ -22,15 +21,15 @@ struct Uniforms {
std::array<bool, 16> b;
std::array<Common::Vec4<u8>, 4> i;
static std::size_t GetFloatUniformOffset(u32 index) {
static size_t GetFloatUniformOffset(u32 index) {
return offsetof(Uniforms, f) + index * sizeof(Common::Vec4<f24>);
}
static std::size_t GetBoolUniformOffset(u32 index) {
static size_t GetBoolUniformOffset(u32 index) {
return offsetof(Uniforms, b) + index * sizeof(bool);
}
static std::size_t GetIntUniformOffset(u32 index) {
static size_t GetIntUniformOffset(u32 index) {
return offsetof(Uniforms, i) + index * sizeof(Common::Vec4<u8>);
}
@ -59,7 +58,7 @@ public:
void WriteUniformIntReg(u32 index, const Common::Vec4<u8> values);
std::optional<u32> WriteUniformFloatReg(ShaderRegs& config, u32 value);
void WriteUniformFloatReg(ShaderRegs& config, u32 value);
u64 GetProgramCodeHash();

View File

@ -2,7 +2,6 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "common/bit_set.h"
#include "video_core/pica/regs_shader.h"
#include "video_core/pica/shader_unit.h"

View File

@ -33,15 +33,15 @@ struct ShaderUnit {
void WriteOutput(const ShaderRegs& config, AttributeBuffer& output);
static constexpr std::size_t InputOffset(s32 register_index) {
static constexpr size_t InputOffset(s32 register_index) {
return offsetof(ShaderUnit, input) + register_index * sizeof(Common::Vec4<f24>);
}
static constexpr std::size_t OutputOffset(s32 register_index) {
static constexpr size_t OutputOffset(s32 register_index) {
return offsetof(ShaderUnit, output) + register_index * sizeof(Common::Vec4<f24>);
}
static constexpr std::size_t TemporaryOffset(s32 register_index) {
static constexpr size_t TemporaryOffset(s32 register_index) {
return offsetof(ShaderUnit, temporary) + register_index * sizeof(Common::Vec4<f24>);
}

View File

@ -710,7 +710,7 @@ void RasterizerAccelerated::SyncCombinerColor() {
}
void RasterizerAccelerated::SyncTevConstColor(
const std::size_t stage_index, const Pica::TexturingRegs::TevStageConfig& tev_stage) {
const size_t stage_index, const Pica::TexturingRegs::TevStageConfig& tev_stage) {
const auto const_color = ColorRGBA8(tev_stage.const_color);
if (const_color == fs_uniform_block_data.data.const_color[stage_index]) {

View File

@ -777,7 +777,7 @@ typename RasterizerCache<T>::SurfaceRect_Tuple RasterizerCache<T>::GetTexCopySur
template <class T>
template <typename Func>
void RasterizerCache<T>::ForEachSurfaceInRegion(PAddr addr, std::size_t size, Func&& func) {
void RasterizerCache<T>::ForEachSurfaceInRegion(PAddr addr, size_t size, Func&& func) {
using FuncReturn = typename std::invoke_result<Func, SurfaceId, Surface&>::type;
static constexpr bool BOOL_BREAK = std::is_same_v<FuncReturn, bool>;
boost::container::small_vector<SurfaceId, 8> surfaces;

View File

@ -139,7 +139,7 @@ public:
private:
/// Iterate over all page indices in a range
template <typename Func>
void ForEachPage(PAddr addr, std::size_t size, Func&& func) {
void ForEachPage(PAddr addr, size_t size, Func&& func) {
static constexpr bool RETURNS_BOOL = std::is_same_v<std::invoke_result<Func, u64>, bool>;
const u64 page_end = (addr + size - 1) >> CITRA_PAGEBITS;
for (u64 page = addr >> CITRA_PAGEBITS; page <= page_end; ++page) {
@ -155,7 +155,7 @@ private:
/// Iterates over all the surfaces in a region calling func
template <typename Func>
void ForEachSurfaceInRegion(PAddr addr, std::size_t size, Func&& func);
void ForEachSurfaceInRegion(PAddr addr, size_t size, Func&& func);
/// Get the best surface match (and its match type) for the given flags
template <MatchFlags find_flags>

View File

@ -47,7 +47,7 @@ public:
/// Returns true if the surface contains a custom material with a normal map.
bool HasNormalMap() const noexcept;
bool Overlaps(PAddr overlap_addr, std::size_t overlap_size) const noexcept {
bool Overlaps(PAddr overlap_addr, size_t overlap_size) const noexcept {
const PAddr overlap_end = overlap_addr + static_cast<PAddr>(overlap_size);
return addr < overlap_end && overlap_addr < end;
}

View File

@ -310,7 +310,7 @@ void RendererOpenGL::InitOpenGLObjects() {
glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
Settings::values.bg_blue.GetValue(), 0.0f);
for (std::size_t i = 0; i < samplers.size(); i++) {
for (size_t i = 0; i < samplers.size(); i++) {
samplers[i].Create();
glSamplerParameteri(samplers[i].handle, GL_TEXTURE_MIN_FILTER,
i == 0 ? GL_NEAREST : GL_LINEAR);

View File

@ -78,12 +78,12 @@ void SwBlitter::TextureCopy(const Pica::DisplayTransferConfig& config) {
return;
}
const std::size_t contiguous_input_size =
const size_t contiguous_input_size =
config.texture_copy.size / input_width * (input_width + input_gap);
rasterizer->FlushRegion(config.GetPhysicalInputAddress(),
static_cast<u32>(contiguous_input_size));
const std::size_t contiguous_output_size =
const size_t contiguous_output_size =
config.texture_copy.size / output_width * (output_width + output_gap);
// Only need to flush output if it has a gap
@ -329,7 +329,7 @@ void SwBlitter::MemoryFill(const Pica::MemoryFillConfig& config) {
// Fill with 32-bit values
if (end > start) {
const u32 value = config.value_32bit;
const std::size_t len = (end - start) / sizeof(u32);
const size_t len = (end - start) / sizeof(u32);
for (std::size_t i = 0; i < len; ++i) {
std::memcpy(&start[i * sizeof(u32)], &value, sizeof(u32));
}

View File

@ -70,7 +70,7 @@ private:
Memory::MemorySystem& memory;
Pica::PicaCore& pica;
Pica::RegsInternal& regs;
std::size_t num_sw_threads;
size_t num_sw_threads;
Common::ThreadWorker sw_workers;
Framebuffer fb;
};

View File

@ -15,6 +15,10 @@
#include <vk_mem_alloc.h>
#ifdef __APPLE__
#include <mvk_config.h>
#endif
namespace Vulkan {
namespace {
@ -602,6 +606,12 @@ bool Instance::CreateDevice() {
#undef PROP_GET
#undef FEAT_SET
#ifdef __APPLE__
if (!SetMoltenVkConfig()) {
LOG_WARNING(Render_Vulkan, "Unable to set MoltenVK configuration");
}
#endif
try {
device = physical_device.createDeviceUnique(device_chain.get());
} catch (vk::ExtensionNotPresentError& err) {
@ -679,4 +689,42 @@ void Instance::CollectToolingInfo() {
}
}
bool Instance::SetMoltenVkConfig() {
#ifdef __APPLE__
size_t mvk_config_size = sizeof(MVKConfiguration);
MVKConfiguration mvk_config{};
const auto _vkGetMoltenVKConfigurationMVK =
library->GetSymbol<PFN_vkGetMoltenVKConfigurationMVK>("vkGetMoltenVKConfigurationMVK");
if (!_vkGetMoltenVKConfigurationMVK) {
return false;
}
const auto _vkSetMoltenVKConfigurationMVK =
library->GetSymbol<PFN_vkSetMoltenVKConfigurationMVK>("vkSetMoltenVKConfigurationMVK");
if (!_vkSetMoltenVKConfigurationMVK) {
return false;
}
if (_vkGetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size) !=
VK_SUCCESS) {
return false;
}
// Use synchronous queue submits if async presentation is enabled, to avoid threading
// indirection.
mvk_config.synchronousQueueSubmits = Settings::values.async_presentation.GetValue();
// If the device is lost, make an attempt to resume if possible to avoid crashes.
mvk_config.resumeLostDevice = true;
// Maximize concurrency to improve shader compilation performance.
mvk_config.shouldMaximizeConcurrentCompilation = true;
if (_vkSetMoltenVKConfigurationMVK(VK_NULL_HANDLE, &mvk_config, &mvk_config_size) !=
VK_SUCCESS) {
return false;
}
#endif
return true;
}
} // namespace Vulkan

View File

@ -289,6 +289,9 @@ private:
void CollectTelemetryParameters(Core::TelemetrySession& telemetry);
void CollectToolingInfo();
/// Sets MoltenVK configuration to the desired state.
bool SetMoltenVkConfig();
private:
std::shared_ptr<Common::DynamicLibrary> library;
vk::UniqueInstance instance;

View File

@ -543,7 +543,7 @@ void PipelineCache::BindTexelBuffer(u32 binding, vk::BufferView buffer_view) {
}
}
void PipelineCache::SetBufferOffset(u32 binding, std::size_t offset) {
void PipelineCache::SetBufferOffset(u32 binding, size_t offset) {
if (offsets[binding] != static_cast<u32>(offset)) {
offsets[binding] = static_cast<u32>(offset);
set_dirty[0] = true;

View File

@ -79,7 +79,7 @@ public:
void BindTexelBuffer(u32 binding, vk::BufferView buffer_view);
/// Sets the dynamic offset for the uniform buffer at binding
void SetBufferOffset(u32 binding, std::size_t offset);
void SetBufferOffset(u32 binding, size_t offset);
private:
/// Builds the rasterizer pipeline layout

Some files were not shown because too many files have changed in this diff Show More