Commit eb63016d by Jamie Madill Committed by Commit Bot

Add environment overrides for ANGLE features.

Allows the application to override ANGLE behaviour without having to modify the code or use the ANGLE extension. Useful for testing with the command graph refactor. Adds a new string utility for parsing lists of strings from environment variables. Bug: angleproject:4029 Change-Id: Ibae93b743c0c385392cd259d9604ce2f2ed988dc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2037784Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 9c62f66c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// String helper functions. // String helper functions.
// //
#include "string_utils.h" #include "common/string_utils.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <sstream> #include <sstream>
#include "common/platform.h" #include "common/platform.h"
#include "common/system_utils.h"
namespace angle namespace angle
{ {
...@@ -209,4 +210,9 @@ bool ReplaceSubstring(std::string *str, ...@@ -209,4 +210,9 @@ bool ReplaceSubstring(std::string *str,
return true; return true;
} }
std::vector<std::string> GetStringsFromEnvironmentVar(const char *varName, const char *separator)
{
std::string environment = GetEnvironmentVar(varName);
return SplitString(environment, separator, TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY);
}
} // namespace angle } // namespace angle
...@@ -81,6 +81,9 @@ bool ReplaceSubstring(std::string *str, ...@@ -81,6 +81,9 @@ bool ReplaceSubstring(std::string *str,
const std::string &substring, const std::string &substring,
const std::string &replacement); const std::string &replacement);
// Split up a string parsed from an environment variable.
std::vector<std::string> GetStringsFromEnvironmentVar(const char *varName, const char *separator);
} // namespace angle } // namespace angle
#endif // LIBANGLE_STRING_UTILS_H_ #endif // LIBANGLE_STRING_UTILS_H_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// system_utils.cpp: Implementation of common functions // system_utils.cpp: Implementation of common functions
#include "system_utils.h" #include "common/system_utils.h"
namespace angle namespace angle
{ {
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "common/Optional.h" #include "common/Optional.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include <string>
namespace angle namespace angle
{ {
std::string GetExecutablePath(); std::string GetExecutablePath();
......
...@@ -1499,7 +1499,7 @@ void Display::initializeFrontendFeatures() ...@@ -1499,7 +1499,7 @@ void Display::initializeFrontendFeatures()
mImplementation->initializeFrontendFeatures(&mFrontendFeatures); mImplementation->initializeFrontendFeatures(&mFrontendFeatures);
rx::OverrideFeaturesWithDisplayState(&mFrontendFeatures, mState); rx::ApplyFeatureOverrides(&mFrontendFeatures, mState);
} }
const DisplayExtensions &Display::getExtensions() const const DisplayExtensions &Display::getExtensions() const
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "libANGLE/Overlay.h" #include "libANGLE/Overlay.h"
#include "common/string_utils.h"
#include "common/system_utils.h" #include "common/system_utils.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Overlay_font_autogen.h" #include "libANGLE/Overlay_font_autogen.h"
...@@ -61,18 +62,13 @@ void Overlay::destroy(const gl::Context *context) ...@@ -61,18 +62,13 @@ void Overlay::destroy(const gl::Context *context)
void Overlay::enableOverlayWidgetsFromEnvironment() void Overlay::enableOverlayWidgetsFromEnvironment()
{ {
std::istringstream angleOverlayWidgets(angle::GetEnvironmentVar("ANGLE_OVERLAY")); std::vector<std::string> enabledWidgets =
angle::GetStringsFromEnvironmentVar("ANGLE_OVERLAY", ":");
std::set<std::string> enabledWidgets;
std::string widget;
while (getline(angleOverlayWidgets, widget, ':'))
{
enabledWidgets.insert(widget);
}
for (const std::pair<const char *, WidgetId> &widgetName : kWidgetNames) for (const std::pair<const char *, WidgetId> &widgetName : kWidgetNames)
{ {
if (enabledWidgets.count(widgetName.first) > 0) if (std::find(enabledWidgets.begin(), enabledWidgets.end(), widgetName.first) !=
enabledWidgets.end())
{ {
mState.mOverlayWidgets[widgetName.second]->enabled = true; mState.mOverlayWidgets[widgetName.second]->enabled = true;
++mState.mEnabledWidgetCount; ++mState.mEnabledWidgetCount;
......
...@@ -3864,7 +3864,7 @@ void Renderer11::initializeFeatures(angle::FeaturesD3D *features) const ...@@ -3864,7 +3864,7 @@ void Renderer11::initializeFeatures(angle::FeaturesD3D *features) const
{ {
d3d11::InitializeFeatures(mRenderer11DeviceCaps, mAdapterDescription, features); d3d11::InitializeFeatures(mRenderer11DeviceCaps, mAdapterDescription, features);
} }
OverrideFeaturesWithDisplayState(features, mDisplay->getState()); ApplyFeatureOverrides(features, mDisplay->getState());
} }
DeviceImpl *Renderer11::createEGLDevice() DeviceImpl *Renderer11::createEGLDevice()
......
...@@ -3020,7 +3020,7 @@ void Renderer9::initializeFeatures(angle::FeaturesD3D *features) const ...@@ -3020,7 +3020,7 @@ void Renderer9::initializeFeatures(angle::FeaturesD3D *features) const
{ {
d3d9::InitializeFeatures(features); d3d9::InitializeFeatures(features);
} }
OverrideFeaturesWithDisplayState(features, mDisplay->getState()); ApplyFeatureOverrides(features, mDisplay->getState());
} }
DeviceImpl *Renderer9::createEGLDevice() DeviceImpl *Renderer9::createEGLDevice()
......
...@@ -224,7 +224,7 @@ RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions, ...@@ -224,7 +224,7 @@ RendererGL::RendererGL(std::unique_ptr<FunctionsGL> functions,
{ {
nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures); nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures);
} }
OverrideFeaturesWithDisplayState(&mFeatures, display->getState()); ApplyFeatureOverrides(&mFeatures, display->getState());
mStateManager = mStateManager =
new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions(), mFeatures); new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions(), mFeatures);
mBlitter = new BlitGL(mFunctions.get(), mFeatures, mStateManager); mBlitter = new BlitGL(mFunctions.get(), mFeatures, mStateManager);
......
...@@ -9,20 +9,20 @@ ...@@ -9,20 +9,20 @@
#include "libANGLE/renderer/renderer_utils.h" #include "libANGLE/renderer/renderer_utils.h"
#include "common/string_utils.h"
#include "common/system_utils.h"
#include "common/utilities.h"
#include "image_util/copyimage.h" #include "image_util/copyimage.h"
#include "image_util/imageformats.h" #include "image_util/imageformats.h"
#include "libANGLE/AttributeMap.h" #include "libANGLE/AttributeMap.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/Format.h" #include "libANGLE/renderer/Format.h"
#include "platform/Feature.h" #include "platform/Feature.h"
#include <string.h> #include <string.h>
#include "common/utilities.h"
namespace rx namespace rx
{ {
...@@ -794,11 +794,18 @@ gl::Rectangle ClipRectToScissor(const gl::State &glState, const gl::Rectangle &r ...@@ -794,11 +794,18 @@ gl::Rectangle ClipRectToScissor(const gl::State &glState, const gl::Rectangle &r
return rect; return rect;
} }
void OverrideFeaturesWithDisplayState(angle::FeatureSetBase *features, void ApplyFeatureOverrides(angle::FeatureSetBase *features, const egl::DisplayState &state)
const egl::DisplayState &state)
{ {
features->overrideFeatures(state.featureOverridesEnabled, true); features->overrideFeatures(state.featureOverridesEnabled, true);
features->overrideFeatures(state.featureOverridesDisabled, false); features->overrideFeatures(state.featureOverridesDisabled, false);
// Override with environment as well.
std::vector<std::string> overridesEnabled =
angle::GetStringsFromEnvironmentVar("ANGLE_FEATURE_OVERRIDES_ENABLED", ":");
std::vector<std::string> overridesDisabled =
angle::GetStringsFromEnvironmentVar("ANGLE_FEATURE_OVERRIDES_DISABLED", ":");
features->overrideFeatures(overridesEnabled, true);
features->overrideFeatures(overridesDisabled, false);
} }
void GetSamplePosition(GLsizei sampleCount, size_t index, GLfloat *xy) void GetSamplePosition(GLsizei sampleCount, size_t index, GLfloat *xy)
......
...@@ -235,8 +235,7 @@ angle::Result GetVertexRangeInfo(const gl::Context *context, ...@@ -235,8 +235,7 @@ angle::Result GetVertexRangeInfo(const gl::Context *context,
gl::Rectangle ClipRectToScissor(const gl::State &glState, const gl::Rectangle &rect, bool invertY); gl::Rectangle ClipRectToScissor(const gl::State &glState, const gl::Rectangle &rect, bool invertY);
// Helper method to intialize a FeatureSet with overrides from the DisplayState // Helper method to intialize a FeatureSet with overrides from the DisplayState
void OverrideFeaturesWithDisplayState(angle::FeatureSetBase *features, void ApplyFeatureOverrides(angle::FeatureSetBase *features, const egl::DisplayState &state);
const egl::DisplayState &state);
template <typename In> template <typename In>
uint32_t LineLoopRestartIndexCountHelper(GLsizei indexCount, const uint8_t *srcPtr) uint32_t LineLoopRestartIndexCountHelper(GLsizei indexCount, const uint8_t *srcPtr)
......
...@@ -543,7 +543,6 @@ gl::Version LimitVersionTo(const gl::Version &current, const gl::Version &lower) ...@@ -543,7 +543,6 @@ gl::Version LimitVersionTo(const gl::Version &current, const gl::Version &lower)
RendererVk::RendererVk() RendererVk::RendererVk()
: mDisplay(nullptr), : mDisplay(nullptr),
mCapsInitialized(false), mCapsInitialized(false),
mFeaturesInitialized(false),
mInstance(VK_NULL_HANDLE), mInstance(VK_NULL_HANDLE),
mEnableValidationLayers(false), mEnableValidationLayers(false),
mEnabledICD(vk::ICD::Default), mEnabledICD(vk::ICD::Default),
...@@ -1071,12 +1070,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -1071,12 +1070,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
queryDeviceExtensionFeatures(deviceExtensionNames); queryDeviceExtensionFeatures(deviceExtensionNames);
// Initialize features and workarounds. // Initialize features and workarounds.
if (!displayVk->getState().featuresAllDisabled) initFeatures(displayVk, deviceExtensionNames);
{
initFeatures(deviceExtensionNames);
}
OverrideFeaturesWithDisplayState(&mFeatures, displayVk->getState());
mFeaturesInitialized = true;
// Selectively enable KHR_MAINTENANCE1 to support viewport flipping. // Selectively enable KHR_MAINTENANCE1 to support viewport flipping.
if ((getFeatures().flipViewportY.enabled) && if ((getFeatures().flipViewportY.enabled) &&
...@@ -1441,8 +1435,14 @@ gl::Version RendererVk::getMaxConformantESVersion() const ...@@ -1441,8 +1435,14 @@ gl::Version RendererVk::getMaxConformantESVersion() const
return LimitVersionTo(getMaxSupportedESVersion(), {3, 0}); return LimitVersionTo(getMaxSupportedESVersion(), {3, 0});
} }
void RendererVk::initFeatures(const ExtensionNameList &deviceExtensionNames) void RendererVk::initFeatures(DisplayVk *displayVk, const ExtensionNameList &deviceExtensionNames)
{ {
if (displayVk->getState().featuresAllDisabled)
{
ApplyFeatureOverrides(&mFeatures, displayVk->getState());
return;
}
bool isAMD = IsAMD(mPhysicalDeviceProperties.vendorID); bool isAMD = IsAMD(mPhysicalDeviceProperties.vendorID);
bool isIntel = IsIntel(mPhysicalDeviceProperties.vendorID); bool isIntel = IsIntel(mPhysicalDeviceProperties.vendorID);
bool isNvidia = IsNvidia(mPhysicalDeviceProperties.vendorID); bool isNvidia = IsNvidia(mPhysicalDeviceProperties.vendorID);
...@@ -1565,6 +1565,8 @@ void RendererVk::initFeatures(const ExtensionNameList &deviceExtensionNames) ...@@ -1565,6 +1565,8 @@ void RendererVk::initFeatures(const ExtensionNameList &deviceExtensionNames)
angle::PlatformMethods *platform = ANGLEPlatformCurrent(); angle::PlatformMethods *platform = ANGLEPlatformCurrent();
platform->overrideFeaturesVk(platform, &mFeatures); platform->overrideFeaturesVk(platform, &mFeatures);
ApplyFeatureOverrides(&mFeatures, displayVk->getState());
} }
void RendererVk::initPipelineCacheVkKey() void RendererVk::initPipelineCacheVkKey()
......
...@@ -141,11 +141,7 @@ class RendererVk : angle::NonCopyable ...@@ -141,11 +141,7 @@ class RendererVk : angle::NonCopyable
// Issues a new serial for linked shader modules. Used in the pipeline cache. // Issues a new serial for linked shader modules. Used in the pipeline cache.
Serial issueShaderSerial(); Serial issueShaderSerial();
const angle::FeaturesVk &getFeatures() const const angle::FeaturesVk &getFeatures() const { return mFeatures; }
{
ASSERT(mFeaturesInitialized);
return mFeatures;
}
uint32_t getMaxVertexAttribDivisor() const { return mMaxVertexAttribDivisor; } uint32_t getMaxVertexAttribDivisor() const { return mMaxVertexAttribDivisor; }
VkDeviceSize getMaxVertexAttribStride() const { return mMaxVertexAttribStride; } VkDeviceSize getMaxVertexAttribStride() const { return mMaxVertexAttribStride; }
...@@ -230,7 +226,7 @@ class RendererVk : angle::NonCopyable ...@@ -230,7 +226,7 @@ class RendererVk : angle::NonCopyable
void queryDeviceExtensionFeatures(const ExtensionNameList &deviceExtensionNames); void queryDeviceExtensionFeatures(const ExtensionNameList &deviceExtensionNames);
void initFeatures(const ExtensionNameList &extensions); void initFeatures(DisplayVk *display, const ExtensionNameList &extensions);
void initPipelineCacheVkKey(); void initPipelineCacheVkKey();
angle::Result initPipelineCache(DisplayVk *display, angle::Result initPipelineCache(DisplayVk *display,
vk::PipelineCache *pipelineCache, vk::PipelineCache *pipelineCache,
...@@ -252,7 +248,6 @@ class RendererVk : angle::NonCopyable ...@@ -252,7 +248,6 @@ class RendererVk : angle::NonCopyable
mutable gl::TextureCapsMap mNativeTextureCaps; mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions; mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations; mutable gl::Limitations mNativeLimitations;
mutable bool mFeaturesInitialized;
mutable angle::FeaturesVk mFeatures; mutable angle::FeaturesVk mFeatures;
VkInstance mInstance; VkInstance mInstance;
......
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