[MISC] Allow user to override process priority class
This commit is contained in:
parent
82cb261140
commit
cf0ee05da6
|
@ -27,6 +27,8 @@ void ShutdownAndroidSystem();
|
||||||
void LaunchWebBrowser(const std::string_view url);
|
void LaunchWebBrowser(const std::string_view url);
|
||||||
void LaunchFileExplorer(const std::filesystem::path& path);
|
void LaunchFileExplorer(const std::filesystem::path& path);
|
||||||
|
|
||||||
|
bool SetProcessPriorityClass(const uint32_t priority_class);
|
||||||
|
|
||||||
enum class SimpleMessageBoxType {
|
enum class SimpleMessageBoxType {
|
||||||
Help,
|
Help,
|
||||||
Warning,
|
Warning,
|
||||||
|
|
|
@ -294,4 +294,6 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type, std::string_view message) {
|
||||||
// Java VM for the calling thread is needed.
|
// Java VM for the calling thread is needed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetProcessPriorityClass(const uint32_t priority_class) { return true; }
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -67,4 +67,6 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type, std::string_view message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetProcessPriorityClass(const uint32_t priority_class) { return true; }
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include "xenia/base/platform_win.h"
|
#include "xenia/base/platform_win.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
#include "xenia/base/system.h"
|
#include "xenia/base/system.h"
|
||||||
|
@ -48,4 +49,19 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type,
|
||||||
type_flags);
|
type_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::map<const uint32_t, DWORD> xeniaToWindowsPriorityClassMapping = {
|
||||||
|
{0, NORMAL_PRIORITY_CLASS},
|
||||||
|
{1, ABOVE_NORMAL_PRIORITY_CLASS},
|
||||||
|
{2, HIGH_PRIORITY_CLASS},
|
||||||
|
{3, REALTIME_PRIORITY_CLASS}};
|
||||||
|
|
||||||
|
bool SetProcessPriorityClass(const uint32_t priority_class) {
|
||||||
|
if (!xeniaToWindowsPriorityClassMapping.count(priority_class)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SetPriorityClass(GetCurrentProcess(),
|
||||||
|
xeniaToWindowsPriorityClassMapping[priority_class]);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -86,6 +86,12 @@ DECLARE_int32(user_language);
|
||||||
|
|
||||||
DECLARE_bool(allow_plugins);
|
DECLARE_bool(allow_plugins);
|
||||||
|
|
||||||
|
DEFINE_int32(priority_class, 0,
|
||||||
|
"Forces Xenia to use different process priority than default one. "
|
||||||
|
"It might affect performance and cause unexpected bugs. Possible "
|
||||||
|
"values: 0 - Normal, 1 - Above normal, 2 - High",
|
||||||
|
"General");
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
using namespace xe::literals;
|
using namespace xe::literals;
|
||||||
|
|
||||||
|
@ -125,6 +131,13 @@ Emulator::Emulator(const std::filesystem::path& command_line,
|
||||||
paused_(false),
|
paused_(false),
|
||||||
restoring_(false),
|
restoring_(false),
|
||||||
restore_fence_() {
|
restore_fence_() {
|
||||||
|
if (cvars::priority_class != 0) {
|
||||||
|
if (SetProcessPriorityClass(cvars::priority_class)) {
|
||||||
|
XELOGI("Higher priority class request: Successful. New priority: {}",
|
||||||
|
cvars::priority_class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32 == 1
|
#if XE_PLATFORM_WIN32 == 1
|
||||||
// Show a disclaimer that links to the quickstart
|
// Show a disclaimer that links to the quickstart
|
||||||
// guide the first time they ever open the emulator
|
// guide the first time they ever open the emulator
|
||||||
|
|
Loading…
Reference in New Issue