From f9c3eaf45730f6b507642fc2268110ea305baa87 Mon Sep 17 00:00:00 2001 From: Jonah Ryan-Davis Date: Tue, 19 Nov 2019 15:19:04 -0500 Subject: [PATCH] Add ability to disable all ANGLE features Chrome has a --disable-gpu-driver-bug-workarounds flag that needs to be able to be forwarded to ANGLE Bug: 1016377 Change-Id: Ied6c8656742e25c32d508b8bfe76a902d82bcf93 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1925249 Commit-Queue: Jonah Ryan-Davis Reviewed-by: Geoff Lang --- extensions/EGL_ANGLE_feature_control.txt | 7 +++++++ include/EGL/eglext_angle.h | 1 + src/libANGLE/Display.cpp | 9 +++++++-- src/libANGLE/Display.h | 1 + src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 5 ++++- src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp | 5 ++++- src/libANGLE/renderer/gl/RendererGL.cpp | 5 ++++- src/libANGLE/renderer/metal/DisplayMtl.mm | 6 +++++- src/libANGLE/renderer/vulkan/RendererVk.cpp | 5 ++++- 9 files changed, 37 insertions(+), 7 deletions(-) diff --git a/extensions/EGL_ANGLE_feature_control.txt b/extensions/EGL_ANGLE_feature_control.txt index ee86d7937..39dba5afd 100644 --- a/extensions/EGL_ANGLE_feature_control.txt +++ b/extensions/EGL_ANGLE_feature_control.txt @@ -85,15 +85,22 @@ New Tokens EGL_FEATURE_OVERRIDES_ENABLED_ANGLE 0x3466 EGL_FEATURE_OVERRIDES_DISABLED_ANGLE 0x3467 + EGL_FEATURE_ALL_DISABLED_ANGLE 0x3469 New Behavior + EGLDisplay eglGetPlatformDisplay(EGLenum platform, void + *native_display, const EGLAttrib *attrib_list); + The attribute following EGL_FEATURE_OVERRIDES_ENABLED_ANGLE or EGL_FEATURE_OVERRIDES_DISABLED_ANGLE should be of type char**, which should contain a null-terminated array of C strings naming the features to be enabled or disabled upon display creation. Any features unspecified in one of these arrays will be initialized with an internal heuristic. + The attribute following EGL_FEATURE_ALL_DISABLED_ANGLE should be + either EGL_TRUE to disable all features that are not overridden, + or EGL_FALSE to let ANGLE determine which features to enable. Add the following to the end of section 3.3 "EGL Queries": diff --git a/include/EGL/eglext_angle.h b/include/EGL/eglext_angle.h index 4349b835c..f2b33a8be 100644 --- a/include/EGL/eglext_angle.h +++ b/include/EGL/eglext_angle.h @@ -235,6 +235,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM(EGLDisplay dpy, #define EGL_FEATURE_OVERRIDES_ENABLED_ANGLE 0x3466 #define EGL_FEATURE_OVERRIDES_DISABLED_ANGLE 0x3467 #define EGL_FEATURE_CONDITION_ANGLE 0x3468 +#define EGL_FEATURE_ALL_DISABLED_ANGLE 0x3469 typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGIANGLEPROC) (EGLDisplay dpy, EGLint name, EGLint index); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBANGLEPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); #ifdef EGL_EGLEXT_PROTOTYPES diff --git a/src/libANGLE/Display.cpp b/src/libANGLE/Display.cpp index 44c319adc..e35dbfaef 100644 --- a/src/libANGLE/Display.cpp +++ b/src/libANGLE/Display.cpp @@ -365,7 +365,7 @@ void ANGLESetDefaultDisplayPlatform(angle::EGLDisplayType display) } // anonymous namespace -DisplayState::DisplayState() : label(nullptr) {} +DisplayState::DisplayState() : label(nullptr), featuresAllDisabled(false) {} DisplayState::~DisplayState() {} @@ -565,6 +565,8 @@ void Display::setAttributes(rx::DisplayImpl *impl, const AttributeMap &attribMap reinterpret_cast(mAttributeMap.get(EGL_FEATURE_OVERRIDES_DISABLED_ANGLE, 0)); mState.featureOverridesEnabled = EGLStringArrayToStringVector(featuresForceEnabled); mState.featureOverridesDisabled = EGLStringArrayToStringVector(featuresForceDisabled); + mState.featuresAllDisabled = + static_cast(mAttributeMap.get(EGL_FEATURE_ALL_DISABLED_ANGLE, 0)); } Error Display::initialize() @@ -610,7 +612,10 @@ Error Display::initialize() config.second.renderableType |= EGL_OPENGL_ES_BIT; } - initializeFrontendFeatures(); + if (!mState.featuresAllDisabled) + { + initializeFrontendFeatures(); + } mFeatures.clear(); mFrontendFeatures.populateFeatureList(&mFeatures); diff --git a/src/libANGLE/Display.h b/src/libANGLE/Display.h index 6b0c98116..a9ef0a275 100644 --- a/src/libANGLE/Display.h +++ b/src/libANGLE/Display.h @@ -57,6 +57,7 @@ struct DisplayState final : private angle::NonCopyable SurfaceSet surfaceSet; std::vector featureOverridesEnabled; std::vector featureOverridesDisabled; + bool featuresAllDisabled; }; // Constant coded here as a sanity limit. diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 261fbc6c7..cb2409167 100644 --- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -3840,7 +3840,10 @@ void Renderer11::generateCaps(gl::Caps *outCaps, void Renderer11::initializeFeatures(angle::FeaturesD3D *features) const { - d3d11::InitializeFeatures(mRenderer11DeviceCaps, mAdapterDescription, features); + if (!mDisplay->getState().featuresAllDisabled) + { + d3d11::InitializeFeatures(mRenderer11DeviceCaps, mAdapterDescription, features); + } OverrideFeaturesWithDisplayState(features, mDisplay->getState()); } diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index d021151df..1e889ec6c 100644 --- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -3009,7 +3009,10 @@ void Renderer9::generateCaps(gl::Caps *outCaps, void Renderer9::initializeFeatures(angle::FeaturesD3D *features) const { - d3d9::InitializeFeatures(features); + if (!mDisplay->getState().featuresAllDisabled) + { + d3d9::InitializeFeatures(features); + } OverrideFeaturesWithDisplayState(features, mDisplay->getState()); } diff --git a/src/libANGLE/renderer/gl/RendererGL.cpp b/src/libANGLE/renderer/gl/RendererGL.cpp index 37892eb6d..3f9fd312a 100644 --- a/src/libANGLE/renderer/gl/RendererGL.cpp +++ b/src/libANGLE/renderer/gl/RendererGL.cpp @@ -219,7 +219,10 @@ RendererGL::RendererGL(std::unique_ptr functions, mNativeParallelCompileEnabled(false) { ASSERT(mFunctions); - nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures); + if (!display->getState().featuresAllDisabled) + { + nativegl_gl::InitializeFeatures(mFunctions.get(), &mFeatures); + } OverrideFeaturesWithDisplayState(&mFeatures, display->getState()); mStateManager = new StateManagerGL(mFunctions.get(), getNativeCaps(), getNativeExtensions(), mFeatures); diff --git a/src/libANGLE/renderer/metal/DisplayMtl.mm b/src/libANGLE/renderer/metal/DisplayMtl.mm index 66e929cc7..f40a3f828 100644 --- a/src/libANGLE/renderer/metal/DisplayMtl.mm +++ b/src/libANGLE/renderer/metal/DisplayMtl.mm @@ -68,7 +68,11 @@ angle::Result DisplayMtl::initializeImpl(egl::Display *display) mCapsInitialized = false; GlslangInitialize(); - initializeFeatures(); + + if (!mState.featuresAllDisabled) + { + initializeFeatures(); + } ANGLE_TRY(mFormatTable.initialize(this)); diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp index c8c7ef9e2..ab37821ce 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.cpp +++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp @@ -1006,7 +1006,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF &mProvokingVertexFeatures); } - initFeatures(deviceExtensionNames); + if (!displayVk->getState().featuresAllDisabled) + { + initFeatures(deviceExtensionNames); + } OverrideFeaturesWithDisplayState(&mFeatures, displayVk->getState()); mFeaturesInitialized = true;