apm_controller.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include "common/common_types.h"
  7. namespace Core::Timing {
  8. class CoreTiming;
  9. }
  10. namespace Service::APM {
  11. enum class PerformanceConfiguration : u32 {
  12. Config1 = 0x00010000,
  13. Config2 = 0x00010001,
  14. Config3 = 0x00010002,
  15. Config4 = 0x00020000,
  16. Config5 = 0x00020001,
  17. Config6 = 0x00020002,
  18. Config7 = 0x00020003,
  19. Config8 = 0x00020004,
  20. Config9 = 0x00020005,
  21. Config10 = 0x00020006,
  22. Config11 = 0x92220007,
  23. Config12 = 0x92220008,
  24. Config13 = 0x92220009,
  25. Config14 = 0x9222000A,
  26. Config15 = 0x9222000B,
  27. Config16 = 0x9222000C,
  28. };
  29. // This is nn::oe::CpuBoostMode
  30. enum class CpuBoostMode : u32 {
  31. Normal = 0, // Boost mode disabled
  32. FastLoad = 1, // CPU + GPU -> Config 13, 14, 15, or 16
  33. Partial = 2, // GPU Only -> Config 15 or 16
  34. };
  35. // This is nn::oe::PerformanceMode
  36. enum class PerformanceMode : s32 {
  37. Invalid = -1,
  38. Normal = 0,
  39. Boost = 1,
  40. };
  41. // Class to manage the state and change of the emulated system performance.
  42. // Specifically, this deals with PerformanceMode, which corresponds to the system being docked or
  43. // undocked, and PerformanceConfig which specifies the exact CPU, GPU, and Memory clocks to operate
  44. // at. Additionally, this manages 'Boost Mode', which allows games to temporarily overclock the
  45. // system during times of high load -- this simply maps to different PerformanceConfigs to use.
  46. class Controller {
  47. public:
  48. explicit Controller(Core::Timing::CoreTiming& core_timing_);
  49. ~Controller();
  50. void SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config);
  51. void SetFromCpuBoostMode(CpuBoostMode mode);
  52. PerformanceMode GetCurrentPerformanceMode() const;
  53. PerformanceConfiguration GetCurrentPerformanceConfiguration(PerformanceMode mode);
  54. private:
  55. void SetClockSpeed(u32 mhz);
  56. [[maybe_unused]] Core::Timing::CoreTiming& core_timing;
  57. std::map<PerformanceMode, PerformanceConfiguration> configs;
  58. };
  59. } // namespace Service::APM