Skip to content

Commit

Permalink
feat(PerformanceManager): Add Performance Manager and per game profiles.
Browse files Browse the repository at this point in the history
* Partially working Performance Manager

* Everything funtional again.

* Move PowerTools to ui/common. Partially working profile.

* Seems to be working

* fix bug preventing setting max cpu count

* Adjust notifications

* Fix bugs with thermal_profile vs thermal mode rename. Add safety for some property refrences. Move to dedicated shared_thread for performance manager. Various naming bugs squashed.

* adjust callbacks for better response in async environment.

* Add docked/undocked profiles. make all globals private. Fix bug with setting CPU cores from profile by adjusting the processing order after setting smt on/off.

* Fix mmultiple warnings. Fix monir bug with asus devices. Remove unused vars.

* Remove some bad assignments

* fix(LaunchManager): fix running app detection

* Use full game name for profile name

* Fix app detection of focused app

* Move gpu_freq setting to just AMD for now.

* Use thread pool instead of shared thread

---------

Co-authored-by: William Edwards <[email protected]>
  • Loading branch information
Derek J. Clark and ShadowApex authored Sep 5, 2023
1 parent aa051d7 commit cb327fd
Show file tree
Hide file tree
Showing 14 changed files with 1,212 additions and 584 deletions.
21 changes: 4 additions & 17 deletions core/global/launch_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,8 @@ func _get_app_name_from_proc(pid: int) -> String:
# Primary nw app ID method. Identifies the running app from steam's library.vdf
# and appmanifest_<app_id>.acf files.
func _get_name_from_steam_library() -> String:
var missing_app_id: int = -1
var focusable_apps := Gamescope.get_focusable_apps()
logger.debug("Focusable apps: " + str(focusable_apps))
for app_id in focusable_apps:
if app_id == Gamescope.OVERLAY_GAME_ID:
continue
if _is_app_id_running(app_id):
continue
missing_app_id = app_id
break
if missing_app_id < 0:
logger.error("Unable to identify app ID")
return ""
var missing_app_id := Gamescope.get_focused_app()

logger.debug("Found unclaimed app id: " +str(missing_app_id))
var steam_library_path := OS.get_environment("HOME") +"/.steam/steam"
var library_data := _parse_data_from_steam_file(steam_library_path + "/steamapps/libraryfolders.vdf")
Expand Down Expand Up @@ -481,8 +470,7 @@ func _detect_running_app(window_id: int) -> RunningApp:
var running_app := get_running_from_window_id(window_id)
if running_app:
logger.debug("Process is a child of " + running_app.launch_item.name)
return null
# return running_app
return running_app

# Identify the process ID. This is used to make the RunningApp as well as
# for the backup methods for identifying the app name.
Expand All @@ -495,8 +483,7 @@ func _detect_running_app(window_id: int) -> RunningApp:
running_app = _get_app_from_running_pid_groups(pid)
if running_app:
logger.debug("Process is a child of " + running_app.launch_item.name)
return null
# return running_app
return running_app

# If we couldn't find it, identify the app name and create a new RunningApp
logger.debug("Attmpting to identify app from the steam database.")
Expand Down
9 changes: 6 additions & 3 deletions core/global/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func _init() -> void:
platform = load("res://core/platform/handheld/asus/rog_ally_gen1.tres")
if FileAccess.file_exists(platform.thermal_policy_path):
logger.debug("Platform able to set thermal policy")
gpu.thermal_mode_capable = true
gpu.thermal_profile_capable = true
if PLATFORM.AOKZOE_GEN1 in flags:
platform = load("res://core/platform/handheld/aokzoe/aokzoe_gen1.tres")
if PLATFORM.AYANEO_GEN1 in flags:
Expand Down Expand Up @@ -395,16 +395,18 @@ func _read_gpu_info() -> GPUInfo:
apu_data = amd_apu_database.get_apu(cpu.model)
if apu_data:
gpu_info.tj_temp_capable = true
gpu_info.power_profile_capable = true
gpu_info.clk_capable = true
"GenuineIntel":
apu_data = intel_apu_database.get_apu(cpu.model)
# TODO: gpu_info.clk_capable = true
if not apu_data:
logger.info("No APU data for " + cpu.model)
return gpu_info

gpu_info.min_tdp = apu_data.min_tdp
gpu_info.max_tdp = apu_data.max_tdp
gpu_info.max_boost = apu_data.max_boost
gpu_info.clk_capable = true
gpu_info.tdp_capable = true
logger.debug("Found all APU data")

Expand Down Expand Up @@ -447,9 +449,10 @@ class GPUInfo extends Resource:
var model: String
var vendor: String
var tdp_capable: bool = false
var thermal_mode_capable: bool = false
var thermal_profile_capable: bool = false
var tj_temp_capable: bool = false
var clk_capable: bool = false
var min_tdp: float = -1
var max_tdp: float = -1
var max_boost: float = -1
var power_profile_capable: bool = false
Loading

0 comments on commit cb327fd

Please sign in to comment.