Commit 65cd76a7 by Shahbaz Youssefi Committed by Commit Bot

Use env variable to select default backend

This is useful for situations where angle is substituted for the system library underneath an application oblivious to this change. The ANGLE_DEFAULT_PLATFORM variable is used when the display type is default to control the default back-end. Possible values are vulkan, gl and d3d11. If the value of this variable is not valid, or not supported by the current platform, the usual defaults are applied. Bug: angleproject:3125 Change-Id: I304b006e0a4149f78561038d01cede143640dafb Reviewed-on: https://chromium-review.googlesource.com/c/1450211Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent c09ae15c
......@@ -22,6 +22,8 @@
#include "common/debug.h"
#include "common/mathutil.h"
#include "common/platform.h"
#include "common/string_utils.h"
#include "common/system_utils.h"
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/Device.h"
......@@ -133,11 +135,50 @@ rx::DisplayImpl *CreateDisplayFromDevice(Device *eglDevice, const DisplayState &
return impl;
}
// On platforms with support for multiple back-ends, allow an environment variable to control
// the default. This is useful to run angle with benchmarks without having to modify the
// benchmark source. Possible values for this environment variable (ANGLE_DEFAULT_PLATFORM)
// are: vulkan, gl, d3d11.
EGLAttrib GetDisplayTypeFromEnvironment()
{
std::string angleDefaultEnv = angle::GetEnvironmentVar("ANGLE_DEFAULT_PLATFORM");
angle::ToLower(&angleDefaultEnv);
#if defined(ANGLE_ENABLE_VULKAN)
if (angleDefaultEnv == "vulkan")
{
return EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
}
#endif
#if defined(ANGLE_ENABLE_OPENGL)
if (angleDefaultEnv == "gl")
{
return EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
}
#endif
#if defined(ANGLE_ENABLE_D3D11)
if (angleDefaultEnv == "d3d11")
{
return EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
}
#endif
return EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
}
rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap, const DisplayState &state)
{
rx::DisplayImpl *impl = nullptr;
EGLAttrib displayType =
attribMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
if (displayType == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
{
displayType = GetDisplayTypeFromEnvironment();
}
switch (displayType)
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment