Commit 2b0cdcc1 by Brandon Jones Committed by Commit Bot

Implement EGL_ANGLE_explicit_context

Implementation of EGL_ANGLE_explicit_context. Includes new libGLESv2 entry points and exports, libANGLE entry points, extension declarations for eglGetProcAddress, and unit tests. Autogeneration scripts have been modified to produce entry points, exports, eglGetProcAddress function table, extension function pointers, and function declarations. Bug:angleproject:1395 Change-Id: I1b79c6069bbed05beb4700a32139a64ddc465c4c Reviewed-on: https://chromium-review.googlesource.com/1039865Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 390900a0
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
// clang-format off // clang-format off
#ifndef GL_ANGLE_explicit_context_gles1
#define GL_ANGLE_explicit_context_gles1
typedef void *GLeglContext;
#include "glext_explicit_context_autogen.inc"
#endif /* GL_ANGLE_explicit_context_gles1 */
// clang-format on // clang-format on
#endif // INCLUDE_GLES_GLEXT_ANGLE_H_ #endif // INCLUDE_GLES_GLEXT_ANGLE_H_
...@@ -546,6 +546,14 @@ GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewSideBySideANGLE(GLenum ...@@ -546,6 +546,14 @@ GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewSideBySideANGLE(GLenum
#define GL_SAMPLER_2D_RECT_ANGLE 0x8B63 #define GL_SAMPLER_2D_RECT_ANGLE 0x8B63
#endif /* GL_ANGLE_texture_rectangle */ #endif /* GL_ANGLE_texture_rectangle */
#ifndef GL_ANGLE_explicit_context
#define GL_ANGLE_explicit_context
typedef void *GLeglContext;
#include "gl2ext_explicit_context_autogen.inc"
#include "../GLES3/gl3ext_explicit_context_autogen.inc"
#include "../GLES3/gl31ext_explicit_context_autogen.inc"
#endif /* GL_ANGLE_explicit_context */
// clang-format on // clang-format on
#endif // INCLUDE_GLES2_GL2EXT_ANGLE_H_ #endif // INCLUDE_GLES2_GL2EXT_ANGLE_H_
...@@ -238,7 +238,9 @@ Extensions::Extensions() ...@@ -238,7 +238,9 @@ Extensions::Extensions()
textureRectangle(false), textureRectangle(false),
geometryShader(false), geometryShader(false),
pointSizeArray(false), pointSizeArray(false),
textureCubeMap(false) textureCubeMap(false),
explicitContextGles1(false),
explicitContext(false)
{ {
} }
...@@ -832,6 +834,8 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -832,6 +834,8 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_ANGLE_program_cache_control"] = esOnlyExtension(&Extensions::programCacheControl); map["GL_ANGLE_program_cache_control"] = esOnlyExtension(&Extensions::programCacheControl);
map["GL_ANGLE_texture_rectangle"] = enableableExtension(&Extensions::textureRectangle); map["GL_ANGLE_texture_rectangle"] = enableableExtension(&Extensions::textureRectangle);
map["GL_EXT_geometry_shader"] = enableableExtension(&Extensions::geometryShader); map["GL_EXT_geometry_shader"] = enableableExtension(&Extensions::geometryShader);
map["GL_ANGLE_explicit_context_gles1"] = enableableExtension(&Extensions::explicitContextGles1);
map["GL_ANGLE_explicit_context"] = enableableExtension(&Extensions::explicitContext);
// GLES1 extensinos // GLES1 extensinos
map["GL_OES_point_size_array"] = enableableExtension(&Extensions::pointSizeArray); map["GL_OES_point_size_array"] = enableableExtension(&Extensions::pointSizeArray);
map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMap); map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMap);
...@@ -1391,7 +1395,8 @@ ClientExtensions::ClientExtensions() ...@@ -1391,7 +1395,8 @@ ClientExtensions::ClientExtensions()
deviceCreationD3D11(false), deviceCreationD3D11(false),
x11Visual(false), x11Visual(false),
experimentalPresentPath(false), experimentalPresentPath(false),
clientGetAllProcAddresses(false) clientGetAllProcAddresses(false),
explicitContext(false)
{ {
} }
...@@ -1416,6 +1421,7 @@ std::vector<std::string> ClientExtensions::getStrings() const ...@@ -1416,6 +1421,7 @@ std::vector<std::string> ClientExtensions::getStrings() const
InsertExtensionString("EGL_ANGLE_x11_visual", x11Visual, &extensionStrings); InsertExtensionString("EGL_ANGLE_x11_visual", x11Visual, &extensionStrings);
InsertExtensionString("EGL_ANGLE_experimental_present_path", experimentalPresentPath, &extensionStrings); InsertExtensionString("EGL_ANGLE_experimental_present_path", experimentalPresentPath, &extensionStrings);
InsertExtensionString("EGL_KHR_client_get_all_proc_addresses", clientGetAllProcAddresses, &extensionStrings); InsertExtensionString("EGL_KHR_client_get_all_proc_addresses", clientGetAllProcAddresses, &extensionStrings);
InsertExtensionString("EGL_ANGLE_explicit_context", explicitContext, &extensionStrings);
// clang-format on // clang-format on
return extensionStrings; return extensionStrings;
......
...@@ -410,6 +410,12 @@ struct Extensions ...@@ -410,6 +410,12 @@ struct Extensions
bool pointSizeArray; bool pointSizeArray;
// GL_OES_texture_cube_map // GL_OES_texture_cube_map
bool textureCubeMap; bool textureCubeMap;
// EGL_ANGLE_explicit_context GL subextensions
// GL_ANGLE_explicit_context_gles1
bool explicitContextGles1;
// GL_ANGLE_explicit_context
bool explicitContext;
}; };
struct ExtensionInfo struct ExtensionInfo
...@@ -823,6 +829,9 @@ struct ClientExtensions ...@@ -823,6 +829,9 @@ struct ClientExtensions
// EGL_KHR_client_get_all_proc_addresses // EGL_KHR_client_get_all_proc_addresses
bool clientGetAllProcAddresses; bool clientGetAllProcAddresses;
// EGL_ANGLE_explicit_context
bool explicitContext;
}; };
} // namespace egl } // namespace egl
......
...@@ -265,7 +265,8 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -265,7 +265,8 @@ Context::Context(rx::EGLImplFactory *implFactory,
TextureManager *shareTextures, TextureManager *shareTextures,
MemoryProgramCache *memoryProgramCache, MemoryProgramCache *memoryProgramCache,
const egl::AttributeMap &attribs, const egl::AttributeMap &attribs,
const egl::DisplayExtensions &displayExtensions) const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions)
: mState(reinterpret_cast<ContextID>(this), : mState(reinterpret_cast<ContextID>(this),
shareContext ? &shareContext->mState : nullptr, shareContext ? &shareContext->mState : nullptr,
shareTextures, shareTextures,
...@@ -304,7 +305,7 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -304,7 +305,7 @@ Context::Context(rx::EGLImplFactory *implFactory,
mImplementation->setMemoryProgramCache(memoryProgramCache); mImplementation->setMemoryProgramCache(memoryProgramCache);
bool robustResourceInit = GetRobustResourceInit(attribs); bool robustResourceInit = GetRobustResourceInit(attribs);
initCaps(displayExtensions, robustResourceInit); initCaps(displayExtensions, clientExtensions, robustResourceInit);
initWorkarounds(); initWorkarounds();
mGLState.initialize(this, GetDebug(attribs), GetBindGeneratesResource(attribs), mGLState.initialize(this, GetDebug(attribs), GetBindGeneratesResource(attribs),
...@@ -3020,6 +3021,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const ...@@ -3020,6 +3021,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const
} }
Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions, Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit) const bool robustResourceInit) const
{ {
Extensions supportedExtensions = mImplementation->getNativeExtensions(); Extensions supportedExtensions = mImplementation->getNativeExtensions();
...@@ -3087,14 +3089,26 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di ...@@ -3087,14 +3089,26 @@ Extensions Context::generateSupportedExtensions(const egl::DisplayExtensions &di
// Enable the cache control query unconditionally. // Enable the cache control query unconditionally.
supportedExtensions.programCacheControl = true; supportedExtensions.programCacheControl = true;
// Enable EGL_ANGLE_explicit_context subextensions
if (clientExtensions.explicitContext)
{
// GL_ANGLE_explicit_context_gles1
supportedExtensions.explicitContextGles1 = true;
// GL_ANGLE_explicit_context
supportedExtensions.explicitContext = true;
}
return supportedExtensions; return supportedExtensions;
} }
void Context::initCaps(const egl::DisplayExtensions &displayExtensions, bool robustResourceInit) void Context::initCaps(const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit)
{ {
mCaps = mImplementation->getNativeCaps(); mCaps = mImplementation->getNativeCaps();
mSupportedExtensions = generateSupportedExtensions(displayExtensions, robustResourceInit); mSupportedExtensions =
generateSupportedExtensions(displayExtensions, clientExtensions, robustResourceInit);
mExtensions = mSupportedExtensions; mExtensions = mSupportedExtensions;
mLimitations = mImplementation->getNativeLimitations(); mLimitations = mImplementation->getNativeLimitations();
......
...@@ -72,7 +72,8 @@ class Context final : angle::NonCopyable ...@@ -72,7 +72,8 @@ class Context final : angle::NonCopyable
TextureManager *shareTextures, TextureManager *shareTextures,
MemoryProgramCache *memoryProgramCache, MemoryProgramCache *memoryProgramCache,
const egl::AttributeMap &attribs, const egl::AttributeMap &attribs,
const egl::DisplayExtensions &displayExtensions); const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions);
egl::Error onDestroy(const egl::Display *display); egl::Error onDestroy(const egl::Display *display);
~Context(); ~Context();
...@@ -1493,8 +1494,11 @@ class Context final : angle::NonCopyable ...@@ -1493,8 +1494,11 @@ class Context final : angle::NonCopyable
void initExtensionStrings(); void initExtensionStrings();
Extensions generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions, Extensions generateSupportedExtensions(const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit) const; bool robustResourceInit) const;
void initCaps(const egl::DisplayExtensions &displayExtensions, bool robustResourceInit); void initCaps(const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions,
bool robustResourceInit);
void updateCaps(); void updateCaps();
void initWorkarounds(); void initWorkarounds();
......
...@@ -522,8 +522,9 @@ Error Display::initialize() ...@@ -522,8 +522,9 @@ Error Display::initialize()
} }
mProxyContext.reset(nullptr); mProxyContext.reset(nullptr);
gl::Context *proxyContext = new gl::Context(mImplementation, nullptr, nullptr, nullptr, nullptr, gl::Context *proxyContext =
egl::AttributeMap(), mDisplayExtensions); new gl::Context(mImplementation, nullptr, nullptr, nullptr, nullptr, egl::AttributeMap(),
mDisplayExtensions, GetClientExtensions());
mProxyContext.reset(proxyContext); mProxyContext.reset(proxyContext);
mInitialized = true; mInitialized = true;
...@@ -793,7 +794,7 @@ Error Display::createContext(const Config *configuration, ...@@ -793,7 +794,7 @@ Error Display::createContext(const Config *configuration,
gl::Context *context = gl::Context *context =
new gl::Context(mImplementation, configuration, shareContext, shareTextures, cachePointer, new gl::Context(mImplementation, configuration, shareContext, shareTextures, cachePointer,
attribs, mDisplayExtensions); attribs, mDisplayExtensions, GetClientExtensions());
ASSERT(context != nullptr); ASSERT(context != nullptr);
mContextSet.insert(context); mContextSet.insert(context);
...@@ -1015,6 +1016,7 @@ static ClientExtensions GenerateClientExtensions() ...@@ -1015,6 +1016,7 @@ static ClientExtensions GenerateClientExtensions()
#endif #endif
extensions.clientGetAllProcAddresses = true; extensions.clientGetAllProcAddresses = true;
extensions.explicitContext = true;
return extensions; return extensions;
} }
......
...@@ -116,13 +116,19 @@ ...@@ -116,13 +116,19 @@
'../include/GLES/glplatform.h', '../include/GLES/glplatform.h',
'../include/GLES/glext.h', '../include/GLES/glext.h',
'../include/GLES/glext_angle.h', '../include/GLES/glext_angle.h',
'../include/GLES/glext_explicit_context_autogen.inc',
'../include/GLES2/gl2.h', '../include/GLES2/gl2.h',
'../include/GLES2/gl2ext.h', '../include/GLES2/gl2ext.h',
'../include/GLES2/gl2ext_angle.h', '../include/GLES2/gl2ext_angle.h',
'../include/GLES2/gl2ext_explicit_context_autogen.inc',
'../include/GLES2/gl2platform.h', '../include/GLES2/gl2platform.h',
'../include/GLES3/gl3.h', '../include/GLES3/gl3.h',
'../include/GLES3/gl3ext_angle.h',
'../include/GLES3/gl3ext_explicit_context_autogen.inc',
'../include/GLES3/gl3platform.h', '../include/GLES3/gl3platform.h',
'../include/GLES3/gl31.h', '../include/GLES3/gl31.h',
'../include/GLES3/gl31ext_angle.h',
'../include/GLES3/gl31ext_explicit_context_autogen.inc',
'../include/GLES3/gl32.h', '../include/GLES3/gl32.h',
'../include/GLSLANG/ShaderLang.h', '../include/GLSLANG/ShaderLang.h',
'../include/GLSLANG/ShaderVars.h', '../include/GLSLANG/ShaderVars.h',
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -14,6 +14,10 @@ from datetime import date ...@@ -14,6 +14,10 @@ from datetime import date
data_source_name = "proc_table_data.json" data_source_name = "proc_table_data.json"
out_file_name = "proc_table_autogen.cpp" out_file_name = "proc_table_autogen.cpp"
# The EGL_ANGLE_explicit_context extension is generated differently from other extensions.
# Toggle generation here.
support_egl_ANGLE_explicit_context = True
template_cpp = """// GENERATED FILE - DO NOT EDIT. template_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}. // Generated by {script_name} using data from {data_source_name}.
// //
...@@ -59,6 +63,9 @@ for description, functions in json_data.iteritems(): ...@@ -59,6 +63,9 @@ for description, functions in json_data.iteritems():
for function in functions: for function in functions:
if function.startswith("gl"): if function.startswith("gl"):
all_functions[function] = "gl::" + function[2:] all_functions[function] = "gl::" + function[2:]
# Special handling for EGL_ANGLE_explicit_context extension
if support_egl_ANGLE_explicit_context:
all_functions[function + "ContextANGLE"] = "gl::" + function[2:] + "ContextANGLE"
elif function.startswith("egl"): elif function.startswith("egl"):
all_functions[function] = "egl::" + function[3:] all_functions[function] = "egl::" + function[3:]
else: else:
...@@ -75,4 +82,3 @@ with open(out_file_name, 'wb') as out_file: ...@@ -75,4 +82,3 @@ with open(out_file_name, 'wb') as out_file:
num_procs = len(proc_data)) num_procs = len(proc_data))
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() out_file.close()
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
'<(angle_path)/src/tests/gl_tests/DXT1CompressedTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/DXT1CompressedTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/ETCTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/ETCTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/ExplicitContextTest.cpp',
'<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp', '<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp',
'<(angle_path)/src/tests/gl_tests/FloatingPointSurfaceTest.cpp', '<(angle_path)/src/tests/gl_tests/FloatingPointSurfaceTest.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp',
......
//
// Copyright 2018 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.
//
// ExplicitContextTest.cpp: Tests of the EGL_ANGLE_explicit_context extension
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
namespace angle
{
class ExplicitContextTest : public ANGLETest
{
protected:
ExplicitContextTest()
{
setWindowWidth(256);
setWindowHeight(256);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
// Test to ensure that the basic functionality of the extension works.
TEST_P(ExplicitContextTest, BasicTest)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_explicit_context") ||
!extensionEnabled("GL_ANGLE_explicit_context_gles1"));
EGLContext context = getEGLWindow()->getContext();
// Clear to green
glClearColorContextANGLE(context, 0.0f, 1.0f, 0.0f, 1.0f);
glClearContextANGLE(context, GL_COLOR_BUFFER_BIT);
// Check for green
EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255);
ASSERT_GL_NO_ERROR();
}
// Test to ensure that extension works with eglGetProcAddress
TEST_P(ExplicitContextTest, GetProcAddress)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_explicit_context") ||
!extensionEnabled("GL_ANGLE_explicit_context_gles1"));
EGLContext context = getEGLWindow()->getContext();
PFNGLCLEARCOLORCONTEXTANGLE clearColor = reinterpret_cast<PFNGLCLEARCOLORCONTEXTANGLE>(
eglGetProcAddress("glClearColorContextANGLE"));
PFNGLCLEARCONTEXTANGLE clear =
reinterpret_cast<PFNGLCLEARCONTEXTANGLE>(eglGetProcAddress("glClearContextANGLE"));
// Clear to green
clearColor(context, 1.0f, 0, 0, 1.0f);
clear(context, GL_COLOR_BUFFER_BIT);
// Check for green
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
EXPECT_GL_NO_ERROR();
}
// Test to ensure that a passed context of null results in a no-op
TEST_P(ExplicitContextTest, NullContext)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_explicit_context") ||
!extensionEnabled("GL_ANGLE_explicit_context_gles1"));
EGLContext context = getEGLWindow()->getContext();
// Set clear color to red
glClearColorContextANGLE(context, 1.0f, 0, 0, 1.0f);
// Clear to red
glClearContextANGLE(context, GL_COLOR_BUFFER_BIT);
// Set clear color to green
glClearColorContextANGLE(context, 0.0f, 1.0f, 0.0f, 1.0f);
// Call clear with null context, which should perform a silent no-op
glClearContextANGLE(nullptr, GL_COLOR_BUFFER_BIT);
// Check that the color is red
EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255);
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(ExplicitContextTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
} // namespace 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