diff options
| -rw-r--r-- | src/core/hle/kernel/k_affinity_mask.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_process.cpp | 26 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_process.h | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 11 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 59 |
5 files changed, 55 insertions, 51 deletions
diff --git a/src/core/hle/kernel/k_affinity_mask.h b/src/core/hle/kernel/k_affinity_mask.h index b906895fc..cf704ce87 100644 --- a/src/core/hle/kernel/k_affinity_mask.h +++ b/src/core/hle/kernel/k_affinity_mask.h | |||
| @@ -31,8 +31,6 @@ public: | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | constexpr void SetAffinity(s32 core, bool set) { | 33 | constexpr void SetAffinity(s32 core, bool set) { |
| 34 | ASSERT(0 <= core && core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); | ||
| 35 | |||
| 36 | if (set) { | 34 | if (set) { |
| 37 | this->mask |= GetCoreBit(core); | 35 | this->mask |= GetCoreBit(core); |
| 38 | } else { | 36 | } else { |
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 265ac6fa1..85c506979 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp | |||
| @@ -146,6 +146,13 @@ ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::st | |||
| 146 | // Open a reference to the resource limit. | 146 | // Open a reference to the resource limit. |
| 147 | process->resource_limit->Open(); | 147 | process->resource_limit->Open(); |
| 148 | 148 | ||
| 149 | // Clear remaining fields. | ||
| 150 | process->num_running_threads = 0; | ||
| 151 | process->is_signaled = false; | ||
| 152 | process->exception_thread = nullptr; | ||
| 153 | process->is_suspended = false; | ||
| 154 | process->schedule_count = 0; | ||
| 155 | |||
| 149 | return ResultSuccess; | 156 | return ResultSuccess; |
| 150 | } | 157 | } |
| 151 | 158 | ||
| @@ -157,20 +164,17 @@ KResourceLimit* KProcess::GetResourceLimit() const { | |||
| 157 | return resource_limit; | 164 | return resource_limit; |
| 158 | } | 165 | } |
| 159 | 166 | ||
| 160 | void KProcess::IncrementThreadCount() { | 167 | void KProcess::IncrementRunningThreadCount() { |
| 161 | ASSERT(num_threads >= 0); | 168 | ASSERT(num_running_threads.load() >= 0); |
| 162 | num_created_threads++; | 169 | ++num_running_threads; |
| 163 | |||
| 164 | if (const auto count = ++num_threads; count > peak_num_threads) { | ||
| 165 | peak_num_threads = count; | ||
| 166 | } | ||
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | void KProcess::DecrementThreadCount() { | 172 | void KProcess::DecrementRunningThreadCount() { |
| 170 | ASSERT(num_threads > 0); | 173 | ASSERT(num_running_threads.load() > 0); |
| 171 | 174 | ||
| 172 | if (const auto count = --num_threads; count == 0) { | 175 | if (const auto prev = num_running_threads--; prev == 1) { |
| 173 | LOG_WARNING(Kernel, "Process termination is not fully implemented."); | 176 | // TODO(bunnei): Process termination to be implemented when multiprocess is supported. |
| 177 | UNIMPLEMENTED_MSG("KProcess termination is not implemennted!"); | ||
| 174 | } | 178 | } |
| 175 | } | 179 | } |
| 176 | 180 | ||
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index c2a672021..38b446350 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h | |||
| @@ -235,8 +235,8 @@ public: | |||
| 235 | ++schedule_count; | 235 | ++schedule_count; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | void IncrementThreadCount(); | 238 | void IncrementRunningThreadCount(); |
| 239 | void DecrementThreadCount(); | 239 | void DecrementRunningThreadCount(); |
| 240 | 240 | ||
| 241 | void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { | 241 | void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { |
| 242 | running_threads[core] = thread; | 242 | running_threads[core] = thread; |
| @@ -473,9 +473,7 @@ private: | |||
| 473 | bool is_suspended{}; | 473 | bool is_suspended{}; |
| 474 | bool is_initialized{}; | 474 | bool is_initialized{}; |
| 475 | 475 | ||
| 476 | std::atomic<s32> num_created_threads{}; | 476 | std::atomic<u16> num_running_threads{}; |
| 477 | std::atomic<u16> num_threads{}; | ||
| 478 | u16 peak_num_threads{}; | ||
| 479 | 477 | ||
| 480 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; | 478 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; |
| 481 | std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; | 479 | std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; |
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index f42abb8a1..de3ffe0c7 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -215,7 +215,6 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s | |||
| 215 | 215 | ||
| 216 | parent = owner; | 216 | parent = owner; |
| 217 | parent->Open(); | 217 | parent->Open(); |
| 218 | parent->IncrementThreadCount(); | ||
| 219 | } | 218 | } |
| 220 | 219 | ||
| 221 | // Initialize thread context. | 220 | // Initialize thread context. |
| @@ -327,11 +326,6 @@ void KThread::Finalize() { | |||
| 327 | } | 326 | } |
| 328 | } | 327 | } |
| 329 | 328 | ||
| 330 | // Decrement the parent process's thread count. | ||
| 331 | if (parent != nullptr) { | ||
| 332 | parent->DecrementThreadCount(); | ||
| 333 | } | ||
| 334 | |||
| 335 | // Perform inherited finalization. | 329 | // Perform inherited finalization. |
| 336 | KSynchronizationObject::Finalize(); | 330 | KSynchronizationObject::Finalize(); |
| 337 | } | 331 | } |
| @@ -1011,7 +1005,7 @@ ResultCode KThread::Run() { | |||
| 1011 | if (IsUserThread() && IsSuspended()) { | 1005 | if (IsUserThread() && IsSuspended()) { |
| 1012 | this->UpdateState(); | 1006 | this->UpdateState(); |
| 1013 | } | 1007 | } |
| 1014 | owner->IncrementThreadCount(); | 1008 | owner->IncrementRunningThreadCount(); |
| 1015 | } | 1009 | } |
| 1016 | 1010 | ||
| 1017 | // Set our state and finish. | 1011 | // Set our state and finish. |
| @@ -1026,10 +1020,11 @@ ResultCode KThread::Run() { | |||
| 1026 | void KThread::Exit() { | 1020 | void KThread::Exit() { |
| 1027 | ASSERT(this == GetCurrentThreadPointer(kernel)); | 1021 | ASSERT(this == GetCurrentThreadPointer(kernel)); |
| 1028 | 1022 | ||
| 1029 | // Release the thread resource hint from parent. | 1023 | // Release the thread resource hint, running thread count from parent. |
| 1030 | if (parent != nullptr) { | 1024 | if (parent != nullptr) { |
| 1031 | parent->GetResourceLimit()->Release(Kernel::LimitableResource::Threads, 0, 1); | 1025 | parent->GetResourceLimit()->Release(Kernel::LimitableResource::Threads, 0, 1); |
| 1032 | resource_limit_release_hint = true; | 1026 | resource_limit_release_hint = true; |
| 1027 | parent->DecrementRunningThreadCount(); | ||
| 1033 | } | 1028 | } |
| 1034 | 1029 | ||
| 1035 | // Perform termination. | 1030 | // Perform termination. |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d2132b408..7029287a9 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -147,7 +147,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { | |||
| 147 | // Retrieve the names from Qt | 147 | // Retrieve the names from Qt |
| 148 | if (param.Get("engine", "") == "keyboard") { | 148 | if (param.Get("engine", "") == "keyboard") { |
| 149 | const QString button_str = GetKeyName(param.Get("code", 0)); | 149 | const QString button_str = GetKeyName(param.Get("code", 0)); |
| 150 | return QObject::tr("%1%2").arg(toggle, button_str); | 150 | return QObject::tr("%1%2%3").arg(toggle, inverted, button_str); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | if (common_button_name == Common::Input::ButtonNames::Invalid) { | 153 | if (common_button_name == Common::Input::ButtonNames::Invalid) { |
| @@ -341,7 +341,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 341 | emulated_controller->SetButtonParam(button_id, {}); | 341 | emulated_controller->SetButtonParam(button_id, {}); |
| 342 | button_map[button_id]->setText(tr("[not set]")); | 342 | button_map[button_id]->setText(tr("[not set]")); |
| 343 | }); | 343 | }); |
| 344 | if (param.Has("button") || param.Has("hat")) { | 344 | if (param.Has("code") || param.Has("button") || param.Has("hat")) { |
| 345 | context_menu.addAction(tr("Toggle button"), [&] { | 345 | context_menu.addAction(tr("Toggle button"), [&] { |
| 346 | const bool toggle_value = !param.Get("toggle", false); | 346 | const bool toggle_value = !param.Get("toggle", false); |
| 347 | param.Set("toggle", toggle_value); | 347 | param.Set("toggle", toggle_value); |
| @@ -349,8 +349,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 349 | emulated_controller->SetButtonParam(button_id, param); | 349 | emulated_controller->SetButtonParam(button_id, param); |
| 350 | }); | 350 | }); |
| 351 | context_menu.addAction(tr("Invert button"), [&] { | 351 | context_menu.addAction(tr("Invert button"), [&] { |
| 352 | const bool toggle_value = !param.Get("inverted", false); | 352 | const bool invert_value = !param.Get("inverted", false); |
| 353 | param.Set("inverted", toggle_value); | 353 | param.Set("inverted", invert_value); |
| 354 | button_map[button_id]->setText(ButtonToText(param)); | 354 | button_map[button_id]->setText(ButtonToText(param)); |
| 355 | emulated_controller->SetButtonParam(button_id, param); | 355 | emulated_controller->SetButtonParam(button_id, param); |
| 356 | }); | 356 | }); |
| @@ -510,28 +510,37 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i | |||
| 510 | 510 | ||
| 511 | analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); | 511 | analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); |
| 512 | 512 | ||
| 513 | connect(analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, | 513 | connect( |
| 514 | [=, this](const QPoint& menu_location) { | 514 | analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, |
| 515 | QMenu context_menu; | 515 | [=, this](const QPoint& menu_location) { |
| 516 | Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); | 516 | QMenu context_menu; |
| 517 | context_menu.addAction(tr("Clear"), [&] { | 517 | Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); |
| 518 | param.Set("modifier", ""); | 518 | context_menu.addAction(tr("Clear"), [&] { |
| 519 | analog_map_modifier_button[analog_id]->setText(tr("[not set]")); | 519 | param.Set("modifier", ""); |
| 520 | emulated_controller->SetStickParam(analog_id, param); | 520 | analog_map_modifier_button[analog_id]->setText(tr("[not set]")); |
| 521 | }); | 521 | emulated_controller->SetStickParam(analog_id, param); |
| 522 | context_menu.addAction(tr("Toggle button"), [&] { | 522 | }); |
| 523 | Common::ParamPackage modifier_param = | 523 | context_menu.addAction(tr("Toggle button"), [&] { |
| 524 | Common::ParamPackage{param.Get("modifier", "")}; | 524 | Common::ParamPackage modifier_param = |
| 525 | const bool toggle_value = !modifier_param.Get("toggle", false); | 525 | Common::ParamPackage{param.Get("modifier", "")}; |
| 526 | modifier_param.Set("toggle", toggle_value); | 526 | const bool toggle_value = !modifier_param.Get("toggle", false); |
| 527 | param.Set("modifier", modifier_param.Serialize()); | 527 | modifier_param.Set("toggle", toggle_value); |
| 528 | analog_map_modifier_button[analog_id]->setText( | 528 | param.Set("modifier", modifier_param.Serialize()); |
| 529 | ButtonToText(modifier_param)); | 529 | analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); |
| 530 | emulated_controller->SetStickParam(analog_id, param); | 530 | emulated_controller->SetStickParam(analog_id, param); |
| 531 | }); | ||
| 532 | context_menu.exec( | ||
| 533 | analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); | ||
| 534 | }); | 531 | }); |
| 532 | context_menu.addAction(tr("Invert button"), [&] { | ||
| 533 | Common::ParamPackage modifier_param = | ||
| 534 | Common::ParamPackage{param.Get("modifier", "")}; | ||
| 535 | const bool invert_value = !modifier_param.Get("inverted", false); | ||
| 536 | modifier_param.Set("inverted", invert_value); | ||
| 537 | param.Set("modifier", modifier_param.Serialize()); | ||
| 538 | analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); | ||
| 539 | emulated_controller->SetStickParam(analog_id, param); | ||
| 540 | }); | ||
| 541 | context_menu.exec( | ||
| 542 | analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); | ||
| 543 | }); | ||
| 535 | 544 | ||
| 536 | connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), | 545 | connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), |
| 537 | [=, this] { | 546 | [=, this] { |