GPU Preference Selection in AIR

AIR 28 has a feature where the AIR desktop application can be set to have a preference for the use of a specific GPU type:

  • The “discrete” (dedicated) for better performance, or
  • The “integrated” for better battery life.

This preference is set during the AIR application publication, thus ensuring that existing AIR content is not affected by this feature.

The new attribute in the application descriptor

For this feature, the gpuPreference attribute is introduced in the AIR application descriptor. AIR developers can specify either discrete or integrated for the attribute value to set a GPU preference. When the gpuPreference attribute is absent, the GPU type used is OS dependent, as is the case with previous versions of AIR.

<gpuPreference>(discrete|integrated)</gpuPreference>

Note: The value of the gpuPreference does not affect AIR applications that are launched by AIR Debug Launcher (ADL).

The support configuration for the feature

This feature is supported only on devices that are equipped with both an integrated GPU and a discrete GPU, and with OSes that support GPU switching functionality. Such a setup is more common on laptops than on desktops. This feature has been tested on Windows 10 devices equipped with Nvidia or AMD graphic cards, and Mac OS X version 10.12. In some cases, the effectiveness of the GPU preference selection has been device driver dependent.

Effectiveness of GPU Preference Selection.

Setting of the gpuPreference attribute does not guarantee the use of a GPU by the AIR application at all times. OS policies and device driver vendor tools settings may override the AIR gpuPreference attribute setting.

Note: AIR runtime forces Stage3D applications to use discrete GPU on Mac regardless of the value of the gpuPreference attribute. The intention of this enforcement is to avoid expensive cost of preparing the Stage3D rendering again such as loading of the GPU resources for adapting the change in the GPU type.

How to detect the assigned GPU type

The GPU type assigned to the AIR application can be detected by two ways, through a tool or a through a programmatic method. The detection works only when the renderMode attribute is set to direct.

Scout1) is a useful debugging tool to detect what GPU is assigned to an AIR application. GPU information is provided in “Session Info” in Scout, as shown in the following image.

Figure 1 : GPU information captured on Mac

Figure 2:GPU information captured on Windows

Known issues with the current version of Scout:

  • GPU information is not shown when an AIR application runs on top of DirectX11 on Windows 8 or above.
  • Scout lacks the ability to show proper GPU information if the GPU type being used is changed while the application is running. In such a scenario, AIR application needs to be relaunched so that Scout can capture what the current GPU is in the given setting.

The programmatical method to detect the GPU type assigned is through the use of the driver property of the StageVideoAvailablityEvent event. When AIR application registers an event handler for the StaveVideoAvailability event, the StageVideoAvailablityEvent event will fire upon assignment of the GPU type. In the event listener, the GPU information can be retrieved by use of the driver property. As a note, the driver property is available for AIR applications authored for SWF 26 or above.

References

  1. Getting Started With Adobe Scout : http://www.adobe.com/devnet/scout/articles/adobe-scout-getting-started.html

Comments are closed.