GPU clocks

A frame keeps the GPU half idle: the GPU waits while the frame's commands are recorded, then the game waits for the GPU. A driver that picks the GPU's clocks by how busy it is sees a GPU busy half the time and lowers them, which makes every frame slower, which keeps the GPU no busier. gpu_pstate (Settings) holds the clocks up while a game runs, on each system where a program without privileges can, and the log says the way taken or why there is none (src/common/gpu/vk/gpu_pstate.c, called once the Switch renderer has made its device).

ValueWhat it holds
auto (default)a discrete GPU's clocks, and a phone's Adreno's; a computer's integrated GPU's are left to its driver, as it shares its power with the CPU, whose threads a held GPU clock would take
onthose too
offnothing: the driver picks the clocks

Linux, AMD (amdgpu)

The runtime opens the render node of the device Vulkan made (VK_EXT_physical_device_drm gives its device number; sysfs's /sys/dev/char/MAJOR:MINOR/uevent its name), checks its kernel driver is amdgpu (DRM_IOCTL_VERSION), makes a context of its own (AMDGPU_CTX_OP_ALLOC_CTX) and sets the peak stable pstate on it (AMDGPU_CTX_OP_SET_STABLE_PSTATE, AMDGPU_CTX_STABLE_PSTATE_PEAK). The level reads profile_peak until the game ends.

NVIDIA's driver (Linux, Windows)

The device is made with VK_NV_low_latency2 where the driver has it (vk_nv_low_latency2), each swapchain with VkSwapchainLatencyCreateInfoNV, and vkSetLatencySleepModeNV asks the boost alone: lowLatencyMode off, so no sleep paces the game, and lowLatencyBoost on. The specification: "If lowLatencyMode is VK_FALSE, lowLatencyBoost will still hint to the GPU to increase its power state" (VkLatencySleepModeInfoNV); NVAPI's documentation of the same boost: it "will request the GPU run at max clocks even in scenarios where it is idle most of the frame and would normally try to save power" (nvapi.h, NvAPI_D3D_SetSleepMode). A setting of the swapchain, it ends with it, and needs no privilege. The extension requires presents with ids (VK_KHR_present_id with present_wait, or present_id2), which a run without a window does not turn on: the log then says there is no boost. Not checked on an NVIDIA GPU: none is at hand; the decision and its lines are (tests/vk_gpu_pstate.c).

Android, Adreno (kgsl)

kgsl, Qualcomm's kernel driver (under Qualcomm's Vulkan driver or Turnip), takes a power-level constraint per context: KGSL_PROP_PWR_CONSTRAINT with KGSL_CONSTRAINT_PWR_MAX on a context of the runtime's own (IOCTL_KGSL_DRAWCTXT_CREATE with KGSL_CONTEXT_PWR_CONSTRAINT), applied each time that context submits a command. A thread submits one CP_NOP every 40 ms while the game has presented a frame in the last 250 ms. kgsl holds the GPU's top level while those come, and drops the constraint once its last command retired and its interval passed, or once its context is gone (kgsl_pwrctrl_adjust_pwrlevel), which the process's end takes with it.

Other systems

No way for a program without privileges that the kernel or driver gives back when the game ends:

System and GPUWhat exists, and why it is not used
NVIDIA, other waysNVML's nvmlDeviceSetGpuLockedClocks: "Requires root/admin permissions" (nvml.h). nvidia-settings' GPUPowerMizerMode (NV-CONTROL): X11 only, and it stays set after the program ends, so a crash would leave it. NVAPI's driver profile setting "Power management mode" (PREFERRED_PSTATE_ID): a change to the player's saved driver profiles, which outlives the game
Linux, nouveau (NVK)no VK_NV_low_latency2; its clocks are the firmware's and debugfs', root's
Linux, Intel (i915, xe)I915_CONTEXT_PARAM_LOW_LATENCY and DRM_XE_EXEC_QUEUE_LOW_LATENCY_HINT are a frequency hint for the work of the context that carries it (GuC's policy, intel_guc_submission.c, xe_guc_submit.c), which is the Vulkan driver's, not a context of the runtime's own; gt_min_freq_mhz is root's
Linux, Qualcomm (msm), Arm (panfrost, panthor)msm's MSM_PARAM_SYSPROF needs CAP_SYS_ADMIN (adreno_gpu.c); panfrost's and panthor's clocks are devfreq's, root's
Windows, AMDADLX's manual tuning (SetGPUMinFrequency) changes the card's tuning that Adrenalin keeps until ResetToFactory, whatever the program does. D3D12's SetStablePowerState works only in Windows' developer mode, removes the device without it, and fixes clocks "significantly lower" than a game's
Windows, IntelD3D12's SetStablePowerState, as above
macOSno API sets a GPU's clocks. Game Mode (macOS 14) gives a full-screen game priority on the CPU and GPU from its bundle's category, not a held clock

Made from docs/layers/gpu/gpu-clocks.md at 69237645142c. GPL-3.0-or-later.