Commit d32dae1b by Zhenyao Mo Committed by Commit Bot

Revert "EGL: Implement EGL_KHR_no_config_context"

This reverts commit c4b1fbd6. 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 <m.maiya@samsung.com> > Reviewed-by: Geoff Lang <geofflang@chromium.org> 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/+/1803789Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org>
parent 6caa2652
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts/generate_loader.py": "scripts/generate_loader.py":
"48c60c668bec42a80378179aae2acc61", "48c60c668bec42a80378179aae2acc61",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"a002559d0c36f3c78c08ba99f9849c6c", "cdf43c79a91f68bf8678b4c2cb75e9f1",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libEGL/egl_loader_autogen.cpp": "src/libEGL/egl_loader_autogen.cpp":
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"82d1e91d75d8935a44312da31adca77c", "82d1e91d75d8935a44312da31adca77c",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"a002559d0c36f3c78c08ba99f9849c6c", "cdf43c79a91f68bf8678b4c2cb75e9f1",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libANGLE/Context_gl_1_0_autogen.h": "src/libANGLE/Context_gl_1_0_autogen.h":
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
"82d1e91d75d8935a44312da31adca77c", "82d1e91d75d8935a44312da31adca77c",
"scripts/registry_xml.py": "scripts/registry_xml.py":
"a002559d0c36f3c78c08ba99f9849c6c", "cdf43c79a91f68bf8678b4c2cb75e9f1",
"scripts/wgl.xml": "scripts/wgl.xml":
"aa96419c582af2f6673430e2847693f4", "aa96419c582af2f6673430e2847693f4",
"src/libGL/proc_table_wgl_autogen.cpp": "src/libGL/proc_table_wgl_autogen.cpp":
......
...@@ -113,7 +113,6 @@ supported_egl_extensions = [ ...@@ -113,7 +113,6 @@ supported_egl_extensions = [
"EGL_KHR_debug", "EGL_KHR_debug",
"EGL_KHR_fence_sync", "EGL_KHR_fence_sync",
"EGL_KHR_image", "EGL_KHR_image",
"EGL_KHR_no_config_context",
"EGL_KHR_stream", "EGL_KHR_stream",
"EGL_KHR_stream_consumer_gltexture", "EGL_KHR_stream_consumer_gltexture",
"EGL_KHR_swap_buffers_with_damage", "EGL_KHR_swap_buffers_with_damage",
......
...@@ -1216,7 +1216,6 @@ std::vector<std::string> DisplayExtensions::getStrings() const ...@@ -1216,7 +1216,6 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_ANDROID_get_native_client_buffer", getNativeClientBufferANDROID, &extensionStrings); InsertExtensionString("EGL_ANDROID_get_native_client_buffer", getNativeClientBufferANDROID, &extensionStrings);
InsertExtensionString("EGL_ANDROID_native_fence_sync", nativeFenceSyncANDROID, &extensionStrings); InsertExtensionString("EGL_ANDROID_native_fence_sync", nativeFenceSyncANDROID, &extensionStrings);
InsertExtensionString("EGL_ANGLE_create_context_backwards_compatible", createContextBackwardsCompatible, &extensionStrings); InsertExtensionString("EGL_ANGLE_create_context_backwards_compatible", createContextBackwardsCompatible, &extensionStrings);
InsertExtensionString("EGL_KHR_no_config_context", noConfigContext, &extensionStrings);
// TODO(jmadill): Enable this when complete. // TODO(jmadill): Enable this when complete.
//InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings);
// clang-format on // clang-format on
......
...@@ -925,9 +925,6 @@ struct DisplayExtensions ...@@ -925,9 +925,6 @@ struct DisplayExtensions
// EGL_ANGLE_create_context_backwards_compatible // EGL_ANGLE_create_context_backwards_compatible
bool createContextBackwardsCompatible = false; bool createContextBackwardsCompatible = false;
// EGL_KHR_no_config_context
bool noConfigContext = false;
}; };
struct DeviceExtensions struct DeviceExtensions
......
...@@ -2909,14 +2909,7 @@ void QueryContextAttrib(const gl::Context *context, EGLint attribute, EGLint *va ...@@ -2909,14 +2909,7 @@ void QueryContextAttrib(const gl::Context *context, EGLint attribute, EGLint *va
switch (attribute) switch (attribute)
{ {
case EGL_CONFIG_ID: case EGL_CONFIG_ID:
if (context->getConfig() != EGL_NO_CONFIG_KHR) *value = context->getConfig()->configID;
{
*value = context->getConfig()->configID;
}
else
{
*value = 0;
}
break; break;
case EGL_CONTEXT_CLIENT_TYPE: case EGL_CONTEXT_CLIENT_TYPE:
*value = context->getClientType(); *value = context->getClientType();
......
...@@ -151,8 +151,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -151,8 +151,6 @@ void DisplayEGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->nativeFenceSyncANDROID = mEGL->hasExtension("EGL_ANDROID_native_fence_sync"); outExtensions->nativeFenceSyncANDROID = mEGL->hasExtension("EGL_ANDROID_native_fence_sync");
outExtensions->noConfigContext = mEGL->hasExtension("EGL_KHR_no_config_context");
DisplayGL::generateExtensions(outExtensions); DisplayGL::generateExtensions(outExtensions);
} }
......
...@@ -196,8 +196,6 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const ...@@ -196,8 +196,6 @@ void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
outExtensions->glRenderbufferImage = true; outExtensions->glRenderbufferImage = true;
outExtensions->imageNativeBuffer = outExtensions->imageNativeBuffer =
getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled; getRenderer()->getFeatures().supportsAndroidHardwareBuffer.enabled;
outExtensions->noConfigContext = true;
} }
void DisplayVk::generateCaps(egl::Caps *outCaps) const void DisplayVk::generateCaps(egl::Caps *outCaps) const
......
...@@ -968,19 +968,7 @@ Error ValidateCreateContext(Display *display, ...@@ -968,19 +968,7 @@ Error ValidateCreateContext(Display *display,
gl::Context *shareContext, gl::Context *shareContext,
const AttributeMap &attributes) const AttributeMap &attributes)
{ {
if (configuration) ANGLE_TRY(ValidateConfig(display, configuration));
{
ANGLE_TRY(ValidateConfig(display, configuration));
}
else
{
ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.noConfigContext)
{
return EglBadConfig();
}
}
// Get the requested client version (default is 1) and check it is 2 or 3. // Get the requested client version (default is 1) and check it is 2 or 3.
EGLAttrib clientMajorVersion = 1; EGLAttrib clientMajorVersion = 1;
...@@ -1203,12 +1191,7 @@ Error ValidateCreateContext(Display *display, ...@@ -1203,12 +1191,7 @@ Error ValidateCreateContext(Display *display,
{ {
return EglBadAttribute(); return EglBadAttribute();
} }
if (configuration == EGL_NO_CONFIG_KHR) if (!(configuration->renderableType & EGL_OPENGL_ES_BIT))
{
return EglBadMatch();
}
if ((configuration != EGL_NO_CONFIG_KHR) &&
!(configuration->renderableType & EGL_OPENGL_ES_BIT))
{ {
return EglBadMatch(); return EglBadMatch();
} }
...@@ -1219,8 +1202,7 @@ Error ValidateCreateContext(Display *display, ...@@ -1219,8 +1202,7 @@ Error ValidateCreateContext(Display *display,
{ {
return EglBadAttribute(); return EglBadAttribute();
} }
if ((configuration != EGL_NO_CONFIG_KHR) && if (!(configuration->renderableType & EGL_OPENGL_ES2_BIT))
!(configuration->renderableType & EGL_OPENGL_ES2_BIT))
{ {
return EglBadMatch(); return EglBadMatch();
} }
...@@ -1230,8 +1212,7 @@ Error ValidateCreateContext(Display *display, ...@@ -1230,8 +1212,7 @@ Error ValidateCreateContext(Display *display,
{ {
return EglBadAttribute(); return EglBadAttribute();
} }
if ((configuration != EGL_NO_CONFIG_KHR) && if (!(configuration->renderableType & EGL_OPENGL_ES3_BIT))
!(configuration->renderableType & EGL_OPENGL_ES3_BIT))
{ {
return EglBadMatch(); return EglBadMatch();
} }
...@@ -1793,65 +1774,32 @@ Error ValidateMakeCurrent(Display *display, Surface *draw, Surface *read, gl::Co ...@@ -1793,65 +1774,32 @@ Error ValidateMakeCurrent(Display *display, Surface *draw, Surface *read, gl::Co
if (read != EGL_NO_SURFACE) if (read != EGL_NO_SURFACE)
{ {
ANGLE_TRY(ValidateSurface(display, read)); 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 != read)
{ {
if (draw) if (draw)
{ {
ANGLE_TRY(ValidateCompatibleSurface(display, context, draw)); ANGLE_TRY(ValidateCompatibleConfigs(display, draw->getConfig(), draw,
context->getConfig(), draw->getType()));
} }
if (read) if (read)
{ {
ANGLE_TRY(ValidateCompatibleSurface(display, context, read)); ANGLE_TRY(ValidateCompatibleConfigs(display, read->getConfig(), read,
context->getConfig(), read->getType()));
} }
} }
return NoError(); return NoError();
} }
Error ValidateCompatibleSurface(const Display *display, Error ValidateCompatibleConfigs(const Display *display,
gl::Context *context, const Config *surfaceConfig,
const Surface *surface) 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()) if (!surface->flexibleSurfaceCompatibilityRequested())
{ {
...@@ -1888,10 +1836,11 @@ Error ValidateCompatibleSurface(const Display *display, ...@@ -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) if (!surfaceTypeCompat)
{ {
return EglBadMatch() << "Surface type is not compatible."; return EglBadMatch() << "Surface types are not compatible.";
} }
return NoError(); return NoError();
......
...@@ -233,9 +233,11 @@ Error ValidateChooseConfig(const Display *display, ...@@ -233,9 +233,11 @@ Error ValidateChooseConfig(const Display *display,
Error ValidateGetConfigs(const Display *display, EGLint configSize, EGLint *numConfig); Error ValidateGetConfigs(const Display *display, EGLint configSize, EGLint *numConfig);
// Other validation // Other validation
Error ValidateCompatibleSurface(const Display *display, Error ValidateCompatibleConfigs(const Display *display,
gl::Context *context, const Config *config1,
const Surface *surface); const Surface *surface,
const Config *config2,
EGLint surfaceType);
Error ValidateGetPlatformDisplay(EGLenum platform, Error ValidateGetPlatformDisplay(EGLenum platform,
void *native_display, void *native_display,
......
...@@ -138,7 +138,6 @@ angle_end2end_tests_sources = [ ...@@ -138,7 +138,6 @@ angle_end2end_tests_sources = [
"egl_tests/EGLContextSharingTest.cpp", "egl_tests/EGLContextSharingTest.cpp",
"egl_tests/EGLCreateContextAttribsTest.cpp", "egl_tests/EGLCreateContextAttribsTest.cpp",
"egl_tests/EGLDebugTest.cpp", "egl_tests/EGLDebugTest.cpp",
"egl_tests/EGLNoConfigContextTest.cpp",
"egl_tests/EGLProgramCacheControlTest.cpp", "egl_tests/EGLProgramCacheControlTest.cpp",
"egl_tests/EGLQueryContextTest.cpp", "egl_tests/EGLQueryContextTest.cpp",
"egl_tests/EGLRecordableTest.cpp", "egl_tests/EGLRecordableTest.cpp",
......
//
// 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 <gtest/gtest.h>
#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<void *>(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<EGLConfig> 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()));
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