add system property to override the backend selection

On Android, set `debug.filament.backend` to the desired backend:
0: default
1: gl/gles
2: vulkan
3: metal
4: noop

example:
   `adb shell setprop debug.filament.backend 2`

This will affect all filament apps on the device.

This sets the backed as if it was set from the public API.
This commit is contained in:
Mathias Agopian
2021-06-02 12:11:51 -07:00
committed by Mathias Agopian
parent e0a8284fcf
commit 384d6921f6
+10
View File
@@ -20,6 +20,7 @@
#include <utils/debug.h>
#if defined(ANDROID)
#include <sys/system_properties.h>
#if defined(FILAMENT_SUPPORTS_OPENGL) && !defined(FILAMENT_USE_EXTERNAL_GLES3)
#include "opengl/PlatformEGLAndroid.h"
#endif
@@ -82,6 +83,15 @@ Platform::~Platform() noexcept = default;
DefaultPlatform* DefaultPlatform::create(Backend* backend) noexcept {
SYSTRACE_CALL();
assert_invariant(backend);
#if defined(ANDROID)
char scratch[PROP_VALUE_MAX + 1];
int length = __system_property_get("debug.filament.backend", scratch);
if (length > 0) {
*backend = Backend(atoi(scratch));
}
#endif
if (*backend == Backend::DEFAULT) {
*backend = Backend::OPENGL;
}