Skip to content

Commit

Permalink
Load Vulkan layer via settings regardless of GLES layer support (#3713)
Browse files Browse the repository at this point in the history
The logic to decide how to load the Vulkan interception layer was
based on GLES layer support. This change separates the two APIs, such
that the system settings are use to load the Vulkan interception layer
as soon as the Android version allows it, regardless of GLES layer
support.

Bug: b/147723153#comment61
  • Loading branch information
hevrard authored Jan 30, 2020
1 parent 11bd2b9 commit 2ec7aed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 11 additions & 8 deletions core/os/android/layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ import (

const eglLayersExt = "EGL_ANDROID_GLES_layers"

// SupportsLayersViaSystemSettings returns whether the given device supports
// loading GLES and Vulkan layers via the system settings.
func SupportsLayersViaSystemSettings(d Device) bool {
// TODO: this currently looks for the EGL extension that advertises the
// GLES layer loading capability. Technically, the extension could be
// absent, but the device could still support loading Vulkan layers via
// the settings. There doesn't appear to be a way to detect Vulkan support
// and we currently assume a device either supports both, or none.
// SupportsGLESLayersViaSystemSettings returns whether the given device supports
// loading GLES layers via the system settings.
func SupportsGLESLayersViaSystemSettings(d Device) bool {
exts := d.Instance().GetConfiguration().GetDrivers().GetOpengl().GetExtensions()
for _, ext := range exts {
if ext == eglLayersExt {
Expand All @@ -41,6 +36,14 @@ func SupportsLayersViaSystemSettings(d Device) bool {
return false
}

// SupportsVulkanLayersViaSystemSettings returns whether the given device supports
// loading Vulkan layers via the system settings.
func SupportsVulkanLayersViaSystemSettings(d Device) bool {
// Supported since Android P / API level 28
apiVersion := d.Instance().GetConfiguration().GetOS().GetAPIVersion()
return apiVersion >= 28
}

// SetupLayer initializes d to use either a Vulkan or GLES layer from layerPkgs
// limited to the app with package appPkg using the system settings and returns
// a cleanup to remove the layer settings.
Expand Down
7 changes: 6 additions & 1 deletion gapii/client/adb.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ func Start(ctx context.Context, p *android.InstalledPackage, a *android.Activity
})

isVulkan := o.APIs&VulkanAPI != uint32(0)
useLayers := android.SupportsLayersViaSystemSettings(d)
var useLayers bool
if isVulkan {
useLayers = android.SupportsVulkanLayersViaSystemSettings(d)
} else {
useLayers = android.SupportsGLESLayersViaSystemSettings(d)
}

if useLayers {
log.I(ctx, "Setting up Layer")
Expand Down

0 comments on commit 2ec7aed

Please sign in to comment.