From d32dae1bb37ce71dcdebfff22bfab04e03382e93 Mon Sep 17 00:00:00 2001 From: Zhenyao Mo Date: Fri, 13 Sep 2019 22:06:56 +0000 Subject: [PATCH] Revert "EGL: Implement EGL_KHR_no_config_context" This reverts commit c4b1fbd69b12c0af30a58d0810f88d1301b8dabd. Reason for revert: https://crbug.com/1003971 Original change's description: > EGL: Implement EGL_KHR_no_config_context > > Add extension string and flag to all renderers that pass > Modify eglCreateContext to accept EGL_NO_CONFIG > Modify eglQueryContext per specification > Modify eglMakeCurrent to bypass surface-context config compatibility checks > Add check for client API > Create new end2end test EGLNoConfigContextTest > Disable on most renderers to prevent possible fail with future configs > > Bug: angleproject:3635 > Test: dEQP-EGL.functional.create_context.no_config* > angle_end2end_tests --gtest_filter=EGLNoConfigContextTest* > Change-Id: I7fbb137f1222ae7eebff4192013b7d3c5fcf0436 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1762709 > Commit-Queue: Mohan Maiya > Reviewed-by: Geoff Lang TBR=geofflang@chromium.org,timvp@google.com,jmadill@chromium.org,m.maiya@samsung.com,j.vigil@samsung.com Change-Id: I849aa796803e3cda9b480a39be813ef9105325bb No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:3635 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1803789 Reviewed-by: Zhenyao Mo Commit-Queue: Zhenyao Mo --- .../GL_EGL_WGL_loader.json | 2 +- .../GL_EGL_entry_points.json | 2 +- .../code_generation_hashes/proc_table.json | 2 +- scripts/registry_xml.py | 1 - src/libANGLE/Caps.cpp | 1 - src/libANGLE/Caps.h | 3 - src/libANGLE/queryutils.cpp | 9 +- src/libANGLE/renderer/gl/egl/DisplayEGL.cpp | 2 - src/libANGLE/renderer/vulkan/DisplayVk.cpp | 2 - src/libANGLE/validationEGL.cpp | 87 +++--------- src/libANGLE/validationEGL.h | 8 +- src/tests/angle_end2end_tests.gni | 1 - .../egl_tests/EGLNoConfigContextTest.cpp | 134 ------------------ 13 files changed, 27 insertions(+), 227 deletions(-) delete mode 100644 src/tests/egl_tests/EGLNoConfigContextTest.cpp diff --git a/scripts/code_generation_hashes/GL_EGL_WGL_loader.json b/scripts/code_generation_hashes/GL_EGL_WGL_loader.json index e6bd5031a..ce9527f9c 100644 --- a/scripts/code_generation_hashes/GL_EGL_WGL_loader.json +++ b/scripts/code_generation_hashes/GL_EGL_WGL_loader.json @@ -6,7 +6,7 @@ "scripts/generate_loader.py": "48c60c668bec42a80378179aae2acc61", "scripts/registry_xml.py": - "a002559d0c36f3c78c08ba99f9849c6c", + "cdf43c79a91f68bf8678b4c2cb75e9f1", "scripts/wgl.xml": "aa96419c582af2f6673430e2847693f4", "src/libEGL/egl_loader_autogen.cpp": diff --git a/scripts/code_generation_hashes/GL_EGL_entry_points.json b/scripts/code_generation_hashes/GL_EGL_entry_points.json index 890af5689..c73c53615 100644 --- a/scripts/code_generation_hashes/GL_EGL_entry_points.json +++ b/scripts/code_generation_hashes/GL_EGL_entry_points.json @@ -12,7 +12,7 @@ "scripts/gl_angle_ext.xml": "82d1e91d75d8935a44312da31adca77c", "scripts/registry_xml.py": - "a002559d0c36f3c78c08ba99f9849c6c", + "cdf43c79a91f68bf8678b4c2cb75e9f1", "scripts/wgl.xml": "aa96419c582af2f6673430e2847693f4", "src/libANGLE/Context_gl_1_0_autogen.h": diff --git a/scripts/code_generation_hashes/proc_table.json b/scripts/code_generation_hashes/proc_table.json index 6e72edc81..2a7574215 100644 --- a/scripts/code_generation_hashes/proc_table.json +++ b/scripts/code_generation_hashes/proc_table.json @@ -10,7 +10,7 @@ "scripts/gl_angle_ext.xml": "82d1e91d75d8935a44312da31adca77c", "scripts/registry_xml.py": - "a002559d0c36f3c78c08ba99f9849c6c", + "cdf43c79a91f68bf8678b4c2cb75e9f1", "scripts/wgl.xml": "aa96419c582af2f6673430e2847693f4", "src/libGL/proc_table_wgl_autogen.cpp": diff --git a/scripts/registry_xml.py b/scripts/registry_xml.py index b81930fad..1ac285894 100644 --- a/scripts/registry_xml.py +++ b/scripts/registry_xml.py @@ -113,7 +113,6 @@ supported_egl_extensions = [ "EGL_KHR_debug", "EGL_KHR_fence_sync", "EGL_KHR_image", - "EGL_KHR_no_config_context", "EGL_KHR_stream", "EGL_KHR_stream_consumer_gltexture", "EGL_KHR_swap_buffers_with_damage", diff --git a/src/libANGLE/Caps.cpp b/src/libANGLE/Caps.cpp index 8dd844cf2..cfceda24a 100644 --- a/src/libANGLE/Caps.cpp +++ b/src/libANGLE/Caps.cpp @@ -1216,7 +1216,6 @@ std::vector DisplayExtensions::getStrings() const InsertExtensionString("EGL_ANDROID_get_native_client_buffer", getNativeClientBufferANDROID, &extensionStrings); InsertExtensionString("EGL_ANDROID_native_fence_sync", nativeFenceSyncANDROID, &extensionStrings); InsertExtensionString("EGL_ANGLE_create_context_backwards_compatible", createContextBackwardsCompatible, &extensionStrings); - InsertExtensionString("EGL_KHR_no_config_context", noConfigContext, &extensionStrings); // TODO(jmadill): Enable this when complete. //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); // clang-format on diff --git a/src/libANGLE/Caps.h b/src/libANGLE/Caps.h index 90b2a8f0e..bd82e5beb 100644 --- a/src/libANGLE/Caps.h +++ b/src/libANGLE/Caps.h @@ -925,9 +925,6 @@ struct DisplayExtensions // EGL_ANGLE_create_context_backwards_compatible bool createContextBackwardsCompatible = false; - - // EGL_KHR_no_config_context - bool noConfigContext = false; }; struct DeviceExtensions diff --git a/src/libANGLE/queryutils.cpp b/src/libANGLE/queryutils.cpp index 18d8be9b3..5141e0416 100644 --- a/src/libANGLE/queryutils.cpp +++ b/src/libANGLE/queryutils.cpp @@ -2909,14 +2909,7 @@ void QueryContextAttrib(const gl::Context *context, EGLint attribute, EGLint *va switch (attribute) { case EGL_CONFIG_ID: - if (context->getConfig() != EGL_NO_CONFIG_KHR) - { - *value = context->getConfig()->configID; - } - else - { - *value = 0; - } + *value = context->getConfig()->configID; break; case EGL_CONTEXT_CLIENT_TYPE: *value = context->getClientType(); diff --git a/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp b/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp index 239fcc16c..a39df6fab 100644 --- a/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp +++ b/src/libANGLE/renderer/gl/egl/DisplayEGL.cpp @@ -151,8 +151,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const outExtensions->nativeFenceSyncANDROID = mEGL->hasExtension("EGL_ANDROID_native_fence_sync"); - outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context"); - DisplayGL::generateExtensions(outExtensions); } diff --git a/src/libANGLE/renderer/vulkan/DisplayVk.cpp b/src/libANGLE/renderer/vulkan/DisplayVk.cpp index bad2c8b12..cd929f63d 100644 --- a/src/libANGLE/renderer/vulkan/DisplayVk.cpp +++ b/src/libANGLE/renderer/vulkan/DisplayVk.cpp @@ -196,8 +196,6 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const outExtensions->glRenderbufferImage = true; outExtensions->imageNativeBuffer = getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled; - - outExtensions->noConfigContext = true; } void DisplayVk::generateCaps(egl::Caps *outCaps) const diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp index 845227e0f..e6d1e45b6 100644 --- a/src/libANGLE/validationEGL.cpp +++ b/src/libANGLE/validationEGL.cpp @@ -968,19 +968,7 @@ Error ValidateCreateContext(Display *display, gl::Context *shareContext, const AttributeMap &attributes) { - if (configuration) - { - ANGLE_TRY(ValidateConfig(display, configuration)); - } - else - { - ANGLE_TRY(ValidateDisplay(display)); - const DisplayExtensions &displayExtensions = display->getExtensions(); - if (!displayExtensions.noConfigContext) - { - return EglBadConfig(); - } - } + ANGLE_TRY(ValidateConfig(display, configuration)); // Get the requested client version (default is 1) and check it is 2 or 3. EGLAttrib clientMajorVersion = 1; @@ -1203,12 +1191,7 @@ Error ValidateCreateContext(Display *display, { return EglBadAttribute(); } - if (configuration == EGL_NO_CONFIG_KHR) - { - return EglBadMatch(); - } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES_BIT)) + if (!(configuration->renderableType & EGL_OPENGL_ES_BIT)) { return EglBadMatch(); } @@ -1219,8 +1202,7 @@ Error ValidateCreateContext(Display *display, { return EglBadAttribute(); } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES2_BIT)) + if (!(configuration->renderableType & EGL_OPENGL_ES2_BIT)) { return EglBadMatch(); } @@ -1230,8 +1212,7 @@ Error ValidateCreateContext(Display *display, { return EglBadAttribute(); } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES3_BIT)) + if (!(configuration->renderableType & EGL_OPENGL_ES3_BIT)) { return EglBadMatch(); } @@ -1793,65 +1774,32 @@ Error ValidateMakeCurrent(Display *display, Surface *draw, Surface *read, gl::Co if (read != EGL_NO_SURFACE) { ANGLE_TRY(ValidateSurface(display, read)); - ANGLE_TRY(ValidateCompatibleSurface(display, context, read)); + ANGLE_TRY(ValidateCompatibleConfigs(display, read->getConfig(), read, context->getConfig(), + read->getType())); } if (draw != read) { if (draw) { - ANGLE_TRY(ValidateCompatibleSurface(display, context, draw)); + ANGLE_TRY(ValidateCompatibleConfigs(display, draw->getConfig(), draw, + context->getConfig(), draw->getType())); } if (read) { - ANGLE_TRY(ValidateCompatibleSurface(display, context, read)); + ANGLE_TRY(ValidateCompatibleConfigs(display, read->getConfig(), read, + context->getConfig(), read->getType())); } } return NoError(); } -Error ValidateCompatibleSurface(const Display *display, - gl::Context *context, - const Surface *surface) +Error ValidateCompatibleConfigs(const Display *display, + const Config *surfaceConfig, + const Surface *surface, + const Config *contextConfig, + EGLint surfaceType) { - const Config *contextConfig = context->getConfig(); - const Config *surfaceConfig = surface->getConfig(); - - // Surface compatible with client API - only OPENGL_ES supported - switch (context->getClientMajorVersion()) - { - case 1: - if (!(surfaceConfig->renderableType & EGL_OPENGL_ES_BIT)) - { - return EglBadMatch() << "Surface not compatible with OpenGL ES 1.x."; - } - break; - case 2: - if (!(surfaceConfig->renderableType & EGL_OPENGL_ES2_BIT)) - { - return EglBadMatch() << "Surface not compatible with OpenGL ES 2.x."; - } - break; - case 3: - if (!(surfaceConfig->renderableType & EGL_OPENGL_ES3_BIT)) - { - return EglBadMatch() << "Surface not compatible with OpenGL ES 3.x."; - } - break; - default: - return EglBadMatch() << "Surface not compatible with Context API."; - } - - // EGL KHR no config context - if (context->getConfig() == EGL_NO_CONFIG_KHR) - { - const DisplayExtensions &displayExtensions = display->getExtensions(); - if (displayExtensions.noConfigContext) - { - return NoError(); - } - return EglBadMatch() << "Context with no config is not supported."; - } if (!surface->flexibleSurfaceCompatibilityRequested()) { @@ -1888,10 +1836,11 @@ Error ValidateCompatibleSurface(const Display *display, } } - bool surfaceTypeCompat = (surfaceConfig->surfaceType & contextConfig->surfaceType) != 0; + bool surfaceTypeCompat = + (surfaceConfig->surfaceType & contextConfig->surfaceType & surfaceType) != 0; if (!surfaceTypeCompat) { - return EglBadMatch() << "Surface type is not compatible."; + return EglBadMatch() << "Surface types are not compatible."; } return NoError(); diff --git a/src/libANGLE/validationEGL.h b/src/libANGLE/validationEGL.h index e2c39dbae..8b3773889 100644 --- a/src/libANGLE/validationEGL.h +++ b/src/libANGLE/validationEGL.h @@ -233,9 +233,11 @@ Error ValidateChooseConfig(const Display *display, Error ValidateGetConfigs(const Display *display, EGLint configSize, EGLint *numConfig); // Other validation -Error ValidateCompatibleSurface(const Display *display, - gl::Context *context, - const Surface *surface); +Error ValidateCompatibleConfigs(const Display *display, + const Config *config1, + const Surface *surface, + const Config *config2, + EGLint surfaceType); Error ValidateGetPlatformDisplay(EGLenum platform, void *native_display, diff --git a/src/tests/angle_end2end_tests.gni b/src/tests/angle_end2end_tests.gni index a2cf738af..9729b9acf 100644 --- a/src/tests/angle_end2end_tests.gni +++ b/src/tests/angle_end2end_tests.gni @@ -138,7 +138,6 @@ angle_end2end_tests_sources = [ "egl_tests/EGLContextSharingTest.cpp", "egl_tests/EGLCreateContextAttribsTest.cpp", "egl_tests/EGLDebugTest.cpp", - "egl_tests/EGLNoConfigContextTest.cpp", "egl_tests/EGLProgramCacheControlTest.cpp", "egl_tests/EGLQueryContextTest.cpp", "egl_tests/EGLRecordableTest.cpp", diff --git a/src/tests/egl_tests/EGLNoConfigContextTest.cpp b/src/tests/egl_tests/EGLNoConfigContextTest.cpp deleted file mode 100644 index 714b77613..000000000 --- a/src/tests/egl_tests/EGLNoConfigContextTest.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// -// Copyright 2019 The ANGLE Project Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -// -// EGLNoConfigContectTest.cpp: -// EGL extension EGL_KHR_no_config_context allows a context to be created -// without a config specified. This means all surfaces are compatible. -// As a result compatibility checks are circumvented. -// This test suite creates and verifies creating a configless context -// and then verifies simple rendering to ensure compatibility. -// - -#include - -#include "test_utils/ANGLETest.h" - -using namespace angle; - -class EGLNoConfigContextTest : public ANGLETest -{ - public: - EGLNoConfigContextTest() : mDisplay(EGL_NO_DISPLAY), mContext(EGL_NO_CONTEXT) {} - - void testSetUp() override - { - int clientVersion = GetParam().majorVersion; - - EGLint dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, GetParam().getRenderer(), EGL_NONE}; - mDisplay = eglGetPlatformDisplayEXT( - EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast(EGL_DEFAULT_DISPLAY), dispattrs); - EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY); - EXPECT_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr)); - - mExtensionSupported = IsEGLDisplayExtensionEnabled(mDisplay, "EGL_KHR_no_config_context"); - if (!mExtensionSupported) - { - return; // Not supported, don't create context - } - - EGLint ctxattrs[] = {EGL_CONTEXT_CLIENT_VERSION, clientVersion, EGL_NONE}; - mContext = eglCreateContext(mDisplay, EGL_NO_CONFIG_KHR, nullptr, ctxattrs); - EXPECT_TRUE(mContext != EGL_NO_CONTEXT); - } - - void testTearDown() override - { - if (mDisplay != EGL_NO_DISPLAY) - { - if (mContext != EGL_NO_CONTEXT) - { - eglDestroyContext(mDisplay, mContext); - mContext = EGL_NO_CONTEXT; - } - eglTerminate(mDisplay); - eglReleaseThread(); - } - ASSERT_EGL_SUCCESS() << "Error during test TearDown"; - } - - EGLDisplay mDisplay = EGL_NO_DISPLAY; - EGLContext mContext = EGL_NO_CONTEXT; - bool mExtensionSupported = false; -}; - -// Check that context has no config. -TEST_P(EGLNoConfigContextTest, QueryConfigID) -{ - ANGLE_SKIP_TEST_IF(!mExtensionSupported); - EXPECT_TRUE(mDisplay); - EXPECT_TRUE(mContext); - - EGLint configId = -1; - EXPECT_EGL_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONFIG_ID, &configId)); - EXPECT_TRUE(configId == 0); - ASSERT_EGL_SUCCESS(); -} - -// Any surface should be eglMakeCurrent compatible with no-config context. -// Do a glClear and glReadPixel to verify rendering. -TEST_P(EGLNoConfigContextTest, RenderCheck) -{ - ANGLE_SKIP_TEST_IF(!mExtensionSupported); - - // Get all the configs - EGLint count; - EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &count)); - EXPECT_TRUE(count > 0); - std::vector configs(count); - EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), count, &count)); - - // For each config, create PbufferSurface and do a render check - EGLSurface surface = EGL_NO_SURFACE; - for (auto config : configs) - { - const uint32_t kWidth = 1; - const uint32_t kHeight = 1; - - EGLint configId; - EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_CONFIG_ID, &configId)); - EGLint surfattrs[] = {EGL_WIDTH, kWidth, EGL_HEIGHT, kHeight, EGL_NONE}; - surface = eglCreatePbufferSurface(mDisplay, config, surfattrs); - EXPECT_TRUE(surface != EGL_NO_SURFACE); - - EGLint bufferSize = 0; - EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_BUFFER_SIZE, &bufferSize)); - - EXPECT_EGL_TRUE(eglMakeCurrent(mDisplay, surface, surface, mContext)); - ASSERT_EGL_SUCCESS() << "eglMakeCurrent failed with Config: " << configId << '\n'; - - // ClearColor RED - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - ASSERT_GL_NO_ERROR() << "glClear failed"; - - if (bufferSize > 32) - { // GL_FLOAT configs - EXPECT_PIXEL_COLOR32F_EQ(0, 0, kFloatRed); - } - else - { // GL_UNSIGNED_BYTE configs - EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); - } - - eglDestroySurface(mDisplay, surface); - surface = EGL_NO_SURFACE; - } -} - -ANGLE_INSTANTIATE_TEST(EGLNoConfigContextTest, - WithNoFixture(ES2_OPENGL()), - WithNoFixture(ES2_VULKAN()), - WithNoFixture(ES3_OPENGL()), - WithNoFixture(ES3_VULKAN()));