This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Important
The Game Mode APIs are deprecated in Windows 10, version 1809 and later.
The Game Mode APIs for the Universal Windows Platform (UWP) allow you to produce the most optimized gaming experience by taking advantage of Game Mode in Windows 10. These APIs are located in the<expandedresources.h> header.
Note
These are Win32 APIs that are supported in UWP desktop and Xbox apps, as well as Win32 apps (except forReleaseExclusiveCpuSets, which isn't supported in Win32 apps).
Game Mode provides customers with the best possible gaming experience by fully utilizing the capacity of their current hardware. It does this by granting a game exclusive or priority access to hardware resources. These resources being dedicated to the game help it hit performance targets more consistently. The performance increase that comes from Game Mode is directly related to the number and impact of other activities running on the device.
Note
The app must be in the foreground and have focus before exclusive resources are granted.
Game Mode works by default for most Windows games, requiring no action or opt-in by the customer, and no work by the game developer. However, you can use the Game Mode API to take it a step further and programmatically query for available system resources, determining whether the operating system considers each resource as shared or exclusive. You can leverage the available system resources in a way that best fits your game design and the configuration of the customer's system.
By using theexpandedResources capability, you can explicitly declare that the game will work with Game Mode. As part of launching the game, the process will go into Game Mode with a set of defaults, and you can use the APIs to see what resources are available on the customer's device.
The Game Mode API has the following members:
Note
ReleaseExclusiveCpuSets requires theexpandedResources restricted capability, which you can select by openingPackage.appxmanifest in Visual Studio and navigating to theCapabilities tab. Alternatively, you can edit the file's code directly:
| XML |
|---|
|
This capability is granted on a per-title basis; contact your account manager for more information. You can publish a UWP app with this capability to the Store if it targets desktop, but if it targets Xbox it will be rejected in certification.
Games should callHasExpandedResources once per frame or game tick to determine whether exclusive resources have been granted. When they have been granted, the game can callGetSystemCpuSetInformation to understand what cores the game is eligible to use. Using this function, deeper inspection, such as getting cache details, can be achieved to rank the cores for performance. TheSYSTEM_CPU_SET_INFORMATION structure returned byGetSystemCpuSetInformation exposes details that the game can use to scale the number of threads it runs, and give threads the affinity for the appropriate cores usingSetThreadSelectedCpuSets.
When exclusive resources are revoked, such as when the game loses focus, the game will discover this by polling withHasExpandedResources, and can re-scale as appropriate. Some games may reduce the level of detail or use other tactics to maintain performance.
A small number of games may choose to callGetExpandedResourceExclusiveCpuCount to determine what CPU resources are available for exclusive use. Based on the developer's judgment, they may opt-out of CPU exclusivity by callingReleaseExclusiveCpuSets to get access to all cores, but at a higher latency due to other processes and system activities being scheduled on the same cores as the game. However, the game would still get access to other Game Mode resources, such as increased GPU prioritization. As withSetProcessDefaultCpuSets,ReleaseExclusiveCpuSets applies to the whole process.
While CPU resources may be revoked if the game exits Game Mode, memory resources, once granted, will never be revoked. Games can use APIs such asAppMemoryUsageLimit to understand what is available.
Games often do system inspection on startup to match the game experience against the system resources. Often, the methods used would involve some combination of how many CPUs are available, to scale the count of work queue threads appropriately.
| C++ |
|---|
|
HasExpandedResources should be called once per frame to detect state changes. This can be called in the main game loop that performs functions like collating inputs from devices and updating the world state.
| C++ |
|---|
|
| Topic | Description |
|---|---|
| GetExpandedResourceExclusiveCpuCount | Gets the expected number of exclusive CPU sets that are available to the app when in Game Mode. |
| HasExpandedResources | Gets the current resource state (that is, whether the app is running in Game Mode or shared mode). |
| ReleaseExclusiveCpuSets | Opts out of CPU exclusivity, giving the app access to all cores, but at the cost of having to share them with other processes. |