diff --git a/samples/sample_util/SampleApplication.cpp b/samples/sample_util/SampleApplication.cpp index e5ce867bb..bfd1221ab 100644 --- a/samples/sample_util/SampleApplication.cpp +++ b/samples/sample_util/SampleApplication.cpp @@ -77,8 +77,10 @@ bool IsGLExtensionEnabled(const std::string &extName) SampleApplication::SampleApplication(std::string name, int argc, char **argv, - EGLint glesMajorVersion, - EGLint glesMinorVersion, + EGLenum clientType, + EGLint glMajorVersion, + EGLint glMinorVersion, + EGLint profileMask, uint32_t width, uint32_t height) : mName(std::move(name)), @@ -115,11 +117,11 @@ SampleApplication::SampleApplication(std::string name, if (useNativeGL) { #if defined(ANGLE_PLATFORM_WINDOWS) - mGLWindow = WGLWindow::New(glesMajorVersion, glesMinorVersion); + mGLWindow = WGLWindow::New(clientType, glMajorVersion, glMinorVersion, profileMask); mEntryPointsLib.reset(angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir)); mDriverType = angle::GLESDriverType::SystemWGL; #else - mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); + mGLWindow = EGLWindow::New(clientType, glMajorVersion, glMinorVersion, profileMask); mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension( angle::GetNativeEGLLibraryNameWithExtension(), angle::SearchType::SystemDir)); mDriverType = angle::GLESDriverType::SystemEGL; @@ -127,7 +129,8 @@ SampleApplication::SampleApplication(std::string name, } else { - mGLWindow = mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); + mGLWindow = mEGLWindow = + EGLWindow::New(clientType, glMajorVersion, glMinorVersion, profileMask); mEntryPointsLib.reset( angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir)); } diff --git a/samples/sample_util/SampleApplication.h b/samples/sample_util/SampleApplication.h index 848389d5e..d329c55d7 100644 --- a/samples/sample_util/SampleApplication.h +++ b/samples/sample_util/SampleApplication.h @@ -34,10 +34,12 @@ class SampleApplication SampleApplication(std::string name, int argc, char **argv, - EGLint glesMajorVersion = 2, - EGLint glesMinorVersion = 0, - uint32_t width = 1280, - uint32_t height = 720); + EGLenum clientType = EGL_OPENGL_ES_API, + EGLint glMajorVersion = 2, + EGLint glMinorVersion = 0, + EGLint profileMask = 0, + uint32_t width = 1280, + uint32_t height = 720); virtual ~SampleApplication(); virtual bool initialize(); diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h index 354018da3..e845357ff 100644 --- a/src/compiler/translator/SymbolTable.h +++ b/src/compiler/translator/SymbolTable.h @@ -313,6 +313,7 @@ class TSymbolTable : angle::NonCopyable, TSymbolTableBase { return mResources.UBOArgumentBufferBindingIndex; } + ShShaderSpec getShaderSpec() const { return mShaderSpec; } private: friend class TSymbolUniqueId; diff --git a/src/compiler/translator/tree_util/DriverUniform.cpp b/src/compiler/translator/tree_util/DriverUniform.cpp index e4303a748..ec5bf2902 100644 --- a/src/compiler/translator/tree_util/DriverUniform.cpp +++ b/src/compiler/translator/tree_util/DriverUniform.cpp @@ -283,8 +283,9 @@ TIntermTyped *DriverUniform::getHalfRenderArea() const TIntermTyped *DriverUniform::getFlipXY(TSymbolTable *symbolTable, DriverUniformFlip stage) const { TIntermTyped *flipXY = createDriverUniformRef(kFlipXY); - TIntermTyped *values = - CreateBuiltInUnaryFunctionCallNode("unpackSnorm4x8", flipXY, *symbolTable, 310); + TIntermTyped *values = CreateBuiltInUnaryFunctionCallNode( + "unpackSnorm4x8", flipXY, *symbolTable, + GetESSLOrGLSLVersion(symbolTable->getShaderSpec(), 310, 400)); if (stage == DriverUniformFlip::Fragment) { diff --git a/src/compiler/translator/tree_util/IntermNode_util.cpp b/src/compiler/translator/tree_util/IntermNode_util.cpp index 64a634150..8be662b3d 100644 --- a/src/compiler/translator/tree_util/IntermNode_util.cpp +++ b/src/compiler/translator/tree_util/IntermNode_util.cpp @@ -376,6 +376,11 @@ TIntermTyped *CreateBuiltInUnaryFunctionCallNode(const char *name, return CreateBuiltInFunctionCallNode(name, &seq, symbolTable, shaderVersion); } +int GetESSLOrGLSLVersion(ShShaderSpec spec, int esslVersion, int glslVersion) +{ + return IsDesktopGLSpec(spec) ? glslVersion : esslVersion; +} + // Returns true if a block ends in a branch (break, continue, return, etc). This is only correct // after PruneNoOps, because it expects empty blocks after a branch to have been already pruned, // i.e. a block can only end in a branch if its last statement is a branch or is a block ending in diff --git a/src/compiler/translator/tree_util/IntermNode_util.h b/src/compiler/translator/tree_util/IntermNode_util.h index 52757c456..06bf3ecf3 100644 --- a/src/compiler/translator/tree_util/IntermNode_util.h +++ b/src/compiler/translator/tree_util/IntermNode_util.h @@ -91,6 +91,8 @@ TIntermTyped *CreateBuiltInUnaryFunctionCallNode(const char *name, const TSymbolTable &symbolTable, int shaderVersion); +int GetESSLOrGLSLVersion(ShShaderSpec spec, int esslVersion, int glslVersion); + inline void GetSwizzleIndex(TVector *indexOut) {} template diff --git a/src/libANGLE/Compiler.cpp b/src/libANGLE/Compiler.cpp index cd18007b8..9c7d2111c 100644 --- a/src/libANGLE/Compiler.cpp +++ b/src/libANGLE/Compiler.cpp @@ -27,12 +27,20 @@ size_t gActiveCompilers = 0; ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion, bool isWebGL, - EGLenum clientType) + EGLenum clientType, + EGLint profileMask) { // For Desktop GL if (clientType == EGL_OPENGL_API) { - return SH_GL_COMPATIBILITY_SPEC; + if ((profileMask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT) != 0) + { + return SH_GL_CORE_SPEC; + } + else + { + return SH_GL_COMPATIBILITY_SPEC; + } } if (majorVersion >= 3) @@ -67,7 +75,8 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const State &state, egl::Disp mSpec(SelectShaderSpec(state.getClientMajorVersion(), state.getClientMinorVersion(), state.isWebGL(), - state.getClientType())), + state.getClientType(), + state.getProfileMask())), mOutputType(mImplementation->getTranslatorOutputType()), mResources() { diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index 9fa999180..d394e2f0a 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -169,6 +169,11 @@ Version GetClientVersion(egl::Display *display, const egl::AttributeMap &attribs } } +EGLint GetProfileMask(const egl::AttributeMap &attribs) +{ + return attribs.getAsInt(EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT); +} + GLenum GetResetStrategy(const egl::AttributeMap &attribs) { EGLAttrib resetStrategyExt = @@ -444,6 +449,7 @@ Context::Context(egl::Display *display, &mOverlay, clientType, GetClientVersion(display, attribs), + GetProfileMask(attribs), GetDebug(attribs), GetBindGeneratesResource(attribs), GetClientArraysEnabled(attribs), diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp index 53c6b7ca6..78fdf2206 100644 --- a/src/libANGLE/State.cpp +++ b/src/libANGLE/State.cpp @@ -335,6 +335,7 @@ State::State(const State *shareContextState, const OverlayType *overlay, const EGLenum clientType, const Version &clientVersion, + EGLint profileMask, bool debug, bool bindGeneratesResourceCHROMIUM, bool clientArraysEnabled, @@ -344,6 +345,7 @@ State::State(const State *shareContextState, bool hasProtectedContent) : mID({gIDCounter++}), mClientType(clientType), + mProfileMask(profileMask), mContextPriority(contextPriority), mHasProtectedContent(hasProtectedContent), mIsDebugContext(debug), diff --git a/src/libANGLE/State.h b/src/libANGLE/State.h index fa441ef9d..7d19a9eee 100644 --- a/src/libANGLE/State.h +++ b/src/libANGLE/State.h @@ -94,6 +94,7 @@ class State : angle::NonCopyable const OverlayType *overlay, const EGLenum clientType, const Version &clientVersion, + EGLint profileMask, bool debug, bool bindGeneratesResourceCHROMIUM, bool clientArraysEnabled, @@ -109,6 +110,7 @@ class State : angle::NonCopyable // Getters ContextID getContextID() const { return mID; } EGLenum getClientType() const { return mClientType; } + EGLint getProfileMask() const { return mProfileMask; } EGLenum getContextPriority() const { return mContextPriority; } bool hasProtectedContent() const { return mHasProtectedContent; } bool isDebugContext() const { return mIsDebugContext; } @@ -973,6 +975,7 @@ class State : angle::NonCopyable ContextID mID; EGLenum mClientType; + EGLint mProfileMask; EGLenum mContextPriority; bool mHasProtectedContent; bool mIsDebugContext; diff --git a/src/libANGLE/capture/FrameCapture.cpp b/src/libANGLE/capture/FrameCapture.cpp index 3c22eb072..c63e583db 100644 --- a/src/libANGLE/capture/FrameCapture.cpp +++ b/src/libANGLE/capture/FrameCapture.cpp @@ -6714,10 +6714,10 @@ void FrameCaptureShared::runMidExecutionCapture(const gl::Context *mainContext) shareGroup->finishAllContexts(); const gl::State &contextState = mainContext->getState(); - gl::State mainContextReplayState(nullptr, nullptr, nullptr, nullptr, nullptr, EGL_OPENGL_ES_API, - contextState.getClientVersion(), false, true, true, true, - false, EGL_CONTEXT_PRIORITY_MEDIUM_IMG, - contextState.hasProtectedContent()); + gl::State mainContextReplayState( + nullptr, nullptr, nullptr, nullptr, nullptr, contextState.getClientType(), + contextState.getClientVersion(), contextState.getProfileMask(), false, true, true, true, + false, EGL_CONTEXT_PRIORITY_MEDIUM_IMG, contextState.hasProtectedContent()); mainContextReplayState.initializeForCapture(mainContext); CaptureShareGroupMidExecutionSetup(mainContext, &mShareGroupSetupCalls, &mResourceTracker, @@ -6741,10 +6741,12 @@ void FrameCaptureShared::runMidExecutionCapture(const gl::Context *mainContext) } else { + const gl::State &shareContextState = shareContext->getState(); gl::State auxContextReplayState( - nullptr, nullptr, nullptr, nullptr, nullptr, EGL_OPENGL_ES_API, - shareContext->getState().getClientVersion(), false, true, true, true, false, - EGL_CONTEXT_PRIORITY_MEDIUM_IMG, shareContext->getState().hasProtectedContent()); + nullptr, nullptr, nullptr, nullptr, nullptr, shareContextState.getClientType(), + shareContextState.getClientVersion(), shareContextState.getProfileMask(), false, + true, true, true, false, EGL_CONTEXT_PRIORITY_MEDIUM_IMG, + shareContextState.hasProtectedContent()); auxContextReplayState.initializeForCapture(shareContext); CaptureMidExecutionSetup(shareContext, &frameCapture->getSetupCalls(), diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp index f5d1f4c93..1572707f7 100644 --- a/src/libANGLE/validationEGL.cpp +++ b/src/libANGLE/validationEGL.cpp @@ -1452,9 +1452,13 @@ bool ValidateCreateContextAttribute(const ValidationContext *val, break; case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR: - // Only valid for OpenGL (non-ES) contexts - val->setError(EGL_BAD_ATTRIBUTE); - return false; + if (val->eglThread->getAPI() != EGL_OPENGL_API) + { + // Only valid for OpenGL (non-ES) contexts + val->setError(EGL_BAD_ATTRIBUTE, "OpenGL profile mask requires an OpenGL context."); + return false; + } + break; case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: if (!display->getExtensions().createContextRobustness) @@ -1692,6 +1696,19 @@ bool ValidateCreateContextAttributeValue(const ValidationContext *val, case EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE: break; + case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR: + { + constexpr EGLint kValidProfileMaskFlags = + (EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT | + EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT); + if ((value & ~kValidProfileMaskFlags) != 0) + { + val->setError(EGL_BAD_ATTRIBUTE, "Invalid OpenGL profile mask."); + return false; + } + break; + } + case EGL_CONTEXT_FLAGS_KHR: { // Note: EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR does not apply to ES @@ -2329,78 +2346,93 @@ bool ValidateCreateContext(const ValidationContext *val, // Get the requested client version (default is 1) and check it is 2 or 3. EGLAttrib clientMajorVersion = attributes.get(EGL_CONTEXT_CLIENT_VERSION, 1); EGLAttrib clientMinorVersion = attributes.get(EGL_CONTEXT_MINOR_VERSION, 0); + EGLenum api = val->eglThread->getAPI(); - switch (clientMajorVersion) + switch (api) { - case 1: - if (clientMinorVersion != 0 && clientMinorVersion != 1) + case EGL_OPENGL_ES_API: + switch (clientMajorVersion) { - val->setError(EGL_BAD_ATTRIBUTE); - return false; - } - if (configuration == EGL_NO_CONFIG_KHR) - { - val->setError(EGL_BAD_MATCH); - return false; - } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES_BIT)) - { - val->setError(EGL_BAD_MATCH); - return false; + case 1: + if (clientMinorVersion != 0 && clientMinorVersion != 1) + { + val->setError(EGL_BAD_ATTRIBUTE); + return false; + } + if (configuration == EGL_NO_CONFIG_KHR) + { + val->setError(EGL_BAD_MATCH); + return false; + } + if ((configuration != EGL_NO_CONFIG_KHR) && + !(configuration->renderableType & EGL_OPENGL_ES_BIT)) + { + val->setError(EGL_BAD_MATCH); + return false; + } + break; + + case 2: + if (clientMinorVersion != 0) + { + val->setError(EGL_BAD_ATTRIBUTE); + return false; + } + if ((configuration != EGL_NO_CONFIG_KHR) && + !(configuration->renderableType & EGL_OPENGL_ES2_BIT)) + { + val->setError(EGL_BAD_MATCH); + return false; + } + break; + case 3: + if (clientMinorVersion < 0 || clientMinorVersion > 2) + { + val->setError(EGL_BAD_ATTRIBUTE); + return false; + } + if ((configuration != EGL_NO_CONFIG_KHR) && + !(configuration->renderableType & EGL_OPENGL_ES3_BIT)) + { + val->setError(EGL_BAD_MATCH); + return false; + } + if (display->getMaxSupportedESVersion() < + gl::Version(static_cast(clientMajorVersion), + static_cast(clientMinorVersion))) + { + gl::Version max = display->getMaxSupportedESVersion(); + val->setError(EGL_BAD_ATTRIBUTE, + "Requested GLES version (%" PRIxPTR ".%" PRIxPTR + ") is greater than " + "max supported (%d, %d).", + clientMajorVersion, clientMinorVersion, max.major, max.minor); + return false; + } + if ((attributes.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == + EGL_TRUE) && + (clientMinorVersion > 1)) + { + val->setError(EGL_BAD_ATTRIBUTE, + "Requested GLES version (%" PRIxPTR ".%" PRIxPTR + ") is greater than " + "max supported 3.1 for WebGL.", + clientMajorVersion, clientMinorVersion); + return false; + } + break; + default: + val->setError(EGL_BAD_ATTRIBUTE); + return false; } break; - case 2: - if (clientMinorVersion != 0) - { - val->setError(EGL_BAD_ATTRIBUTE); - return false; - } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES2_BIT)) - { - val->setError(EGL_BAD_MATCH); - return false; - } - break; - case 3: - if (clientMinorVersion < 0 || clientMinorVersion > 2) - { - val->setError(EGL_BAD_ATTRIBUTE); - return false; - } - if ((configuration != EGL_NO_CONFIG_KHR) && - !(configuration->renderableType & EGL_OPENGL_ES3_BIT)) - { - val->setError(EGL_BAD_MATCH); - return false; - } - if (display->getMaxSupportedESVersion() < - gl::Version(static_cast(clientMajorVersion), - static_cast(clientMinorVersion))) - { - gl::Version max = display->getMaxSupportedESVersion(); - val->setError(EGL_BAD_ATTRIBUTE, - "Requested GLES version (%" PRIxPTR ".%" PRIxPTR - ") is greater than " - "max supported (%d, %d).", - clientMajorVersion, clientMinorVersion, max.major, max.minor); - return false; - } - if ((attributes.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE) && - (clientMinorVersion > 1)) - { - val->setError(EGL_BAD_ATTRIBUTE, - "Requested GLES version (%" PRIxPTR ".%" PRIxPTR - ") is greater than " - "max supported 3.1 for WebGL.", - clientMajorVersion, clientMinorVersion); - return false; - } + case EGL_OPENGL_API: + // TODO: validate desktop OpenGL versions and profile mask break; + default: - val->setError(EGL_BAD_ATTRIBUTE); + val->setError(EGL_BAD_MATCH, "Unsupported API."); return false; } @@ -4930,12 +4962,12 @@ bool ValidateBindAPI(const ValidationContext *val, const EGLenum api) { switch (api) { + case EGL_OPENGL_ES_API: case EGL_OPENGL_API: + break; case EGL_OPENVG_API: val->setError(EGL_BAD_PARAMETER); return false; // Not supported by this implementation - case EGL_OPENGL_ES_API: - break; default: val->setError(EGL_BAD_PARAMETER); return false; diff --git a/src/tests/BUILD.gn b/src/tests/BUILD.gn index f0e066529..31c717c64 100644 --- a/src/tests/BUILD.gn +++ b/src/tests/BUILD.gn @@ -84,6 +84,10 @@ angle_static_library("angle_test_expectations") { config("angle_common_test_utils_config") { include_dirs = [ "." ] + defines = [] + if (angle_enable_gl_desktop) { + defines += [ "ANGLE_ENABLE_OPENGL_DESKTOP" ] + } } template("angle_common_test_utils") { diff --git a/src/tests/angle_end2end_tests.gni b/src/tests/angle_end2end_tests.gni index 5457bf081..64dbdf31b 100644 --- a/src/tests/angle_end2end_tests.gni +++ b/src/tests/angle_end2end_tests.gni @@ -60,6 +60,7 @@ angle_end2end_tests_sources = [ "gl_tests/DebugTest.cpp", "gl_tests/DepthStencilFormatsTest.cpp", "gl_tests/DepthStencilTest.cpp", + "gl_tests/DesktopGLSLTest.cpp", "gl_tests/DifferentStencilMasksTest.cpp", "gl_tests/DiscardFramebufferEXTTest.cpp", "gl_tests/DrawBaseVertexBaseInstanceTest.cpp", diff --git a/src/tests/capture_replay_tests/CaptureReplayTests.cpp b/src/tests/capture_replay_tests/CaptureReplayTests.cpp index 92fa65cdf..83e992d49 100644 --- a/src/tests/capture_replay_tests/CaptureReplayTests.cpp +++ b/src/tests/capture_replay_tests/CaptureReplayTests.cpp @@ -186,8 +186,13 @@ class CaptureReplayTests if (!mEGLWindow) { - mEGLWindow = EGLWindow::New(traceInfo.contextClientMajorVersion, - traceInfo.contextClientMinorVersion); + // TODO: to support desktop OpenGL traces, capture the client api and profile mask in + // TraceInfo + const EGLenum testClientAPI = EGL_OPENGL_ES_API; + const EGLint testProfileMask = 0; + + mEGLWindow = EGLWindow::New(testClientAPI, traceInfo.contextClientMajorVersion, + traceInfo.contextClientMinorVersion, testProfileMask); } ConfigParameters configParams; diff --git a/src/tests/egl_tests/EGLContextCompatibilityTest.cpp b/src/tests/egl_tests/EGLContextCompatibilityTest.cpp index bbf6813d7..c8d5d4531 100644 --- a/src/tests/egl_tests/EGLContextCompatibilityTest.cpp +++ b/src/tests/egl_tests/EGLContextCompatibilityTest.cpp @@ -112,7 +112,8 @@ std::vector GetConfigs(EGLDisplay display) PlatformParameters FromRenderer(EGLint renderer) { - return WithNoFixture(PlatformParameters(2, 0, EGLPlatformParameters(renderer))); + return WithNoFixture( + PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, EGLPlatformParameters(renderer))); } std::string EGLConfigName(EGLDisplay display, EGLConfig config) @@ -180,7 +181,7 @@ class EGLContextCompatibilityTest : public ANGLETestBase, public testing::Test EGLint dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, mRenderer, EGL_NONE}; mDisplay = eglGetPlatformDisplayEXT( - EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast(EGL_DEFAULT_DISPLAY), dispattrs); + EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast(EGL_DEFAULT_DISPLAY), dispattrs); ASSERT_TRUE(mDisplay != EGL_NO_DISPLAY); ASSERT_TRUE(eglInitialize(mDisplay, nullptr, nullptr) == EGL_TRUE); diff --git a/src/tests/gl_tests/DesktopGLSLTest.cpp b/src/tests/gl_tests/DesktopGLSLTest.cpp new file mode 100644 index 000000000..3a91551fd --- /dev/null +++ b/src/tests/gl_tests/DesktopGLSLTest.cpp @@ -0,0 +1,55 @@ +// +// Copyright 2022 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. +// + +#include "test_utils/ANGLETest.h" + +#include "test_utils/gl_raii.h" +#include "util/shader_utils.h" + +namespace angle +{ + +class DesktopGLSLTest : public ANGLETest<> +{ + protected: + DesktopGLSLTest() + { + setWindowWidth(128); + setWindowHeight(128); + setConfigRedBits(8); + setConfigGreenBits(8); + setConfigBlueBits(8); + setConfigAlphaBits(8); + } +}; + +// Simple test case of compiling a desktop OpenGL shader to verify that the shader compiler +// initializes. +TEST_P(DesktopGLSLTest, BasicCompilation) +{ + const char kVS[] = R"(#version 150 +in vec4 position; + +void main() +{ + gl_Position = position; +})"; + + const char kFS[] = R"(#version 150 +out vec4 fragColor; + +void main() +{ + fragColor = vec4(1.0, 0.5, 0.2, 1.0); +})"; + + ANGLE_GL_PROGRAM(testProgram, kVS, kFS); +} + +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DesktopGLSLTest); +ANGLE_INSTANTIATE_TEST_GL32_CORE(DesktopGLSLTest); + +} // namespace angle diff --git a/src/tests/gl_tests/FramebufferMultiviewTest.cpp b/src/tests/gl_tests/FramebufferMultiviewTest.cpp index dc655aae1..c68178aee 100644 --- a/src/tests/gl_tests/FramebufferMultiviewTest.cpp +++ b/src/tests/gl_tests/FramebufferMultiviewTest.cpp @@ -768,18 +768,18 @@ TEST_P(FramebufferMultiviewTest, NegativeMultisampledFramebufferTest) GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FramebufferMultiviewTest); ANGLE_INSTANTIATE_TEST(FramebufferMultiviewTest, - VertexShaderOpenGL(3, 0, ExtensionName::multiview), - VertexShaderVulkan(3, 0, ExtensionName::multiview), - GeomShaderD3D11(3, 0, ExtensionName::multiview), - VertexShaderOpenGL(3, 0, ExtensionName::multiview2), - VertexShaderVulkan(3, 0, ExtensionName::multiview2), - GeomShaderD3D11(3, 0, ExtensionName::multiview2)); + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2), + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2), + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2)); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FramebufferMultiviewLayeredClearTest); ANGLE_INSTANTIATE_TEST(FramebufferMultiviewLayeredClearTest, - VertexShaderOpenGL(3, 0, ExtensionName::multiview), - VertexShaderVulkan(3, 0, ExtensionName::multiview), - GeomShaderD3D11(3, 0, ExtensionName::multiview), - VertexShaderOpenGL(3, 0, ExtensionName::multiview2), - VertexShaderVulkan(3, 0, ExtensionName::multiview2), - GeomShaderD3D11(3, 0, ExtensionName::multiview2)); + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2), + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2), + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2)); diff --git a/src/tests/gl_tests/GLSLTest.cpp b/src/tests/gl_tests/GLSLTest.cpp index 4ac6599a9..db7bc9f65 100644 --- a/src/tests/gl_tests/GLSLTest.cpp +++ b/src/tests/gl_tests/GLSLTest.cpp @@ -15703,6 +15703,7 @@ void main() ANGLE_GL_PROGRAM(testProgram, kVS, kFS); } + } // anonymous namespace ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND(GLSLTest, diff --git a/src/tests/gl_tests/MultiviewDrawTest.cpp b/src/tests/gl_tests/MultiviewDrawTest.cpp index 9645ead34..049af4381 100644 --- a/src/tests/gl_tests/MultiviewDrawTest.cpp +++ b/src/tests/gl_tests/MultiviewDrawTest.cpp @@ -2241,46 +2241,53 @@ TEST_P(MultiviewRenderTest, FlatInterpolation2) MultiviewRenderTestParams VertexShaderOpenGL(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(0, VertexShaderOpenGL(3, 0, multiviewExtension)); + return MultiviewRenderTestParams( + 0, VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 0, 0, multiviewExtension)); } MultiviewRenderTestParams VertexShaderVulkan(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(0, VertexShaderVulkan(3, 0, multiviewExtension)); + return MultiviewRenderTestParams( + 0, VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 0, 0, multiviewExtension)); } MultiviewRenderTestParams GeomShaderD3D11(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(0, GeomShaderD3D11(3, 0, multiviewExtension)); + return MultiviewRenderTestParams( + 0, GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, multiviewExtension)); } MultiviewRenderTestParams VertexShaderD3D11(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(0, VertexShaderD3D11(3, 0, multiviewExtension)); + return MultiviewRenderTestParams( + 0, VertexShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, multiviewExtension)); } MultiviewRenderTestParams MultisampledVertexShaderOpenGL(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(2, VertexShaderOpenGL(3, 1, multiviewExtension)); + return MultiviewRenderTestParams( + 2, VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, 1, 0, multiviewExtension)); } MultiviewRenderTestParams MultisampledVertexShaderVulkan(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(2, VertexShaderVulkan(3, 1, multiviewExtension)); + return MultiviewRenderTestParams( + 2, VertexShaderVulkan(EGL_OPENGL_ES_API, 3, 1, 0, multiviewExtension)); } MultiviewRenderTestParams MultisampledVertexShaderD3D11(ExtensionName multiviewExtension) { - return MultiviewRenderTestParams(2, VertexShaderD3D11(3, 1, multiviewExtension)); + return MultiviewRenderTestParams( + 2, VertexShaderD3D11(EGL_OPENGL_ES_API, 3, 1, 0, multiviewExtension)); } -#define ALL_VERTEX_SHADER_CONFIGS(minor) \ - VertexShaderOpenGL(3, minor, ExtensionName::multiview), \ - VertexShaderVulkan(3, minor, ExtensionName::multiview), \ - VertexShaderD3D11(3, minor, ExtensionName::multiview), \ - VertexShaderOpenGL(3, minor, ExtensionName::multiview2), \ - VertexShaderVulkan(3, minor, ExtensionName::multiview2), \ - VertexShaderD3D11(3, minor, ExtensionName::multiview2) +#define ALL_VERTEX_SHADER_CONFIGS(minor) \ + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview), \ + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview), \ + VertexShaderD3D11(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview), \ + VertexShaderOpenGL(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview2), \ + VertexShaderVulkan(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview2), \ + VertexShaderD3D11(EGL_OPENGL_ES_API, 3, minor, 0, ExtensionName::multiview2) #define ALL_SINGLESAMPLE_CONFIGS() \ VertexShaderOpenGL(ExtensionName::multiview), VertexShaderVulkan(ExtensionName::multiview), \ @@ -2314,8 +2321,8 @@ ANGLE_INSTANTIATE_TEST(MultiviewOcclusionQueryTest, ALL_SINGLESAMPLE_CONFIGS()); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MultiviewProgramGenerationTest); ANGLE_INSTANTIATE_TEST(MultiviewProgramGenerationTest, ALL_VERTEX_SHADER_CONFIGS(0), - GeomShaderD3D11(3, 0, ExtensionName::multiview), - GeomShaderD3D11(3, 0, ExtensionName::multiview2)); + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview), + GeomShaderD3D11(EGL_OPENGL_ES_API, 3, 0, 0, ExtensionName::multiview2)); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MultiviewRenderPrimitiveTest); ANGLE_INSTANTIATE_TEST(MultiviewRenderPrimitiveTest, ALL_SINGLESAMPLE_CONFIGS()); diff --git a/src/tests/gl_tests/ProgramBinaryTest.cpp b/src/tests/gl_tests/ProgramBinaryTest.cpp index bbe4cb64e..3106c6eb1 100644 --- a/src/tests/gl_tests/ProgramBinaryTest.cpp +++ b/src/tests/gl_tests/ProgramBinaryTest.cpp @@ -1403,7 +1403,8 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParaminitializeGL(mOSWindow, mEntryPointsLib.get(), param.driver, param.eglParameters, configParams); diff --git a/src/tests/gl_tests/RendererTest.cpp b/src/tests/gl_tests/RendererTest.cpp index 767143259..ec6d84441 100644 --- a/src/tests/gl_tests/RendererTest.cpp +++ b/src/tests/gl_tests/RendererTest.cpp @@ -131,23 +131,14 @@ TEST_P(RendererTest, RequestedRendererCreated) EGLint glesMajorVersion = GetParam().majorVersion; EGLint glesMinorVersion = GetParam().minorVersion; - // Ensure that the renderer string contains the requested version number - if (glesMajorVersion == 3 && glesMinorVersion == 1) + std::ostringstream expectedVersionString; + if (GetParam().clientType == EGL_OPENGL_ES_API) { - ASSERT_NE(versionString.find(std::string("es 3.1")), std::string::npos); - } - else if (glesMajorVersion == 3 && glesMinorVersion == 0) - { - ASSERT_NE(versionString.find(std::string("es 3.0")), std::string::npos); - } - else if (glesMajorVersion == 2 && glesMinorVersion == 0) - { - ASSERT_NE(versionString.find(std::string("es 2.0")), std::string::npos); - } - else - { - FAIL() << "Unhandled GL ES client version."; + expectedVersionString << "es "; } + expectedVersionString << glesMajorVersion << "." << glesMinorVersion; + + ASSERT_NE(versionString.find(expectedVersionString.str()), std::string::npos); ASSERT_GL_NO_ERROR(); ASSERT_EGL_SUCCESS(); @@ -172,5 +163,6 @@ TEST_P(RendererTest, SimpleOperation) // Select configurations (e.g. which renderer, which GLES major version) these tests should be run // against. -ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND_ES31_AND_NULL(RendererTest); +ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND_ES31_AND_NULL_AND(RendererTest, + ANGLE_ALL_TEST_PLATFORMS_GL32_CORE); } // anonymous namespace diff --git a/src/tests/gl_tests/RobustBufferAccessBehaviorTest.cpp b/src/tests/gl_tests/RobustBufferAccessBehaviorTest.cpp index bdd8b566c..5ba60babe 100644 --- a/src/tests/gl_tests/RobustBufferAccessBehaviorTest.cpp +++ b/src/tests/gl_tests/RobustBufferAccessBehaviorTest.cpp @@ -46,7 +46,9 @@ class RobustBufferAccessBehaviorTest : public ANGLETest<> Library *driverLib = ANGLETestEnvironment::GetDriverLibrary(GLESDriverType::AngleEGL); - mEGLWindow = EGLWindow::New(GetParam().majorVersion, GetParam().minorVersion); + const PlatformParameters ¶ms = GetParam(); + mEGLWindow = EGLWindow::New(params.clientType, params.majorVersion, params.minorVersion, + params.profileMask); if (!mEGLWindow->initializeDisplay(mOSWindow, driverLib, GLESDriverType::AngleEGL, GetParam().eglParameters)) { diff --git a/src/tests/perf_tests/ANGLEPerfTest.cpp b/src/tests/perf_tests/ANGLEPerfTest.cpp index 59c674eb4..613e92a19 100644 --- a/src/tests/perf_tests/ANGLEPerfTest.cpp +++ b/src/tests/perf_tests/ANGLEPerfTest.cpp @@ -731,12 +731,14 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, switch (testParams.driver) { case GLESDriverType::AngleEGL: - mGLWindow = EGLWindow::New(testParams.majorVersion, testParams.minorVersion); + mGLWindow = EGLWindow::New(testParams.clientType, testParams.majorVersion, + testParams.minorVersion, testParams.profileMask); mEntryPointsLib.reset(OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, SearchType::ModuleDir)); break; case GLESDriverType::SystemEGL: #if defined(ANGLE_USE_UTIL_LOADER) && !defined(ANGLE_PLATFORM_WINDOWS) - mGLWindow = EGLWindow::New(testParams.majorVersion, testParams.minorVersion); + mGLWindow = EGLWindow::New(testParams.clientType, testParams.majorVersion, + testParams.minorVersion, testParams.profileMask); mEntryPointsLib.reset(OpenSharedLibraryWithExtension( GetNativeEGLLibraryNameWithExtension(), SearchType::SystemDir)); #else @@ -745,7 +747,8 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, break; case GLESDriverType::SystemWGL: #if defined(ANGLE_USE_UTIL_LOADER) && defined(ANGLE_PLATFORM_WINDOWS) - mGLWindow = WGLWindow::New(testParams.majorVersion, testParams.minorVersion); + mGLWindow = WGLWindow::New(testParams.clientType, testParams.majorVersion, + testParams.minorVersion, testParams.profileMask); mEntryPointsLib.reset(OpenSharedLibrary("opengl32", SearchType::SystemDir)); #else skipTest("WGL driver not available."); diff --git a/src/tests/test_utils/ANGLETest.cpp b/src/tests/test_utils/ANGLETest.cpp index 28ea2ace9..82e987f22 100644 --- a/src/tests/test_utils/ANGLETest.cpp +++ b/src/tests/test_utils/ANGLETest.cpp @@ -553,7 +553,8 @@ void ANGLETestBase::initOSWindow() case GLESDriverType::SystemEGL: { mFixture->eglWindow = - EGLWindow::New(mCurrentParams->majorVersion, mCurrentParams->minorVersion); + EGLWindow::New(mCurrentParams->clientType, mCurrentParams->majorVersion, + mCurrentParams->minorVersion, mCurrentParams->profileMask); break; } diff --git a/src/tests/test_utils/MultiviewTest.cpp b/src/tests/test_utils/MultiviewTest.cpp index 58a547d98..b0ad04663 100644 --- a/src/tests/test_utils/MultiviewTest.cpp +++ b/src/tests/test_utils/MultiviewTest.cpp @@ -231,36 +231,44 @@ std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams & return os; } -MultiviewImplementationParams VertexShaderOpenGL(GLint majorVersion, +MultiviewImplementationParams VertexShaderOpenGL(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension) { - return MultiviewImplementationParams(majorVersion, minorVersion, egl_platform::OPENGL(), - multiviewExtension); + return MultiviewImplementationParams(clientType, majorVersion, minorVersion, profileMask, + egl_platform::OPENGL(), multiviewExtension); } -MultiviewImplementationParams VertexShaderVulkan(GLint majorVersion, +MultiviewImplementationParams VertexShaderVulkan(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension) { - return MultiviewImplementationParams(majorVersion, minorVersion, egl_platform::VULKAN(), - multiviewExtension); + return MultiviewImplementationParams(clientType, majorVersion, minorVersion, profileMask, + egl_platform::VULKAN(), multiviewExtension); } -MultiviewImplementationParams VertexShaderD3D11(GLint majorVersion, +MultiviewImplementationParams VertexShaderD3D11(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension) { - return MultiviewImplementationParams(majorVersion, minorVersion, egl_platform::D3D11(), - multiviewExtension); + return MultiviewImplementationParams(clientType, majorVersion, minorVersion, profileMask, + egl_platform::D3D11(), multiviewExtension); } -MultiviewImplementationParams GeomShaderD3D11(GLint majorVersion, +MultiviewImplementationParams GeomShaderD3D11(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension) { return MultiviewImplementationParams( - majorVersion, minorVersion, + clientType, majorVersion, minorVersion, profileMask, egl_platform::D3D11().enable(Feature::SelectViewInGeometryShader), multiviewExtension); } diff --git a/src/tests/test_utils/MultiviewTest.h b/src/tests/test_utils/MultiviewTest.h index 54f7a98ef..bacdb2071 100644 --- a/src/tests/test_utils/MultiviewTest.h +++ b/src/tests/test_utils/MultiviewTest.h @@ -62,28 +62,42 @@ void AttachMultiviewTextures(GLenum target, struct MultiviewImplementationParams : public PlatformParameters { - MultiviewImplementationParams(GLint majorVersion, + MultiviewImplementationParams(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, const EGLPlatformParameters &eglPlatformParameters, ExtensionName multiviewExtension) - : PlatformParameters(majorVersion, minorVersion, eglPlatformParameters), + : PlatformParameters(clientType, + majorVersion, + minorVersion, + profileMask, + eglPlatformParameters), mMultiviewExtension(multiviewExtension) {} ExtensionName mMultiviewExtension; }; std::ostream &operator<<(std::ostream &os, const MultiviewImplementationParams ¶ms); -MultiviewImplementationParams VertexShaderOpenGL(GLint majorVersion, +MultiviewImplementationParams VertexShaderOpenGL(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension); -MultiviewImplementationParams VertexShaderVulkan(GLint majorVersion, +MultiviewImplementationParams VertexShaderVulkan(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension); -MultiviewImplementationParams VertexShaderD3D11(GLint majorVersion, +MultiviewImplementationParams VertexShaderD3D11(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension); -MultiviewImplementationParams GeomShaderD3D11(GLint majorVersion, +MultiviewImplementationParams GeomShaderD3D11(EGLenum clientType, + GLint majorVersion, GLint minorVersion, + EGLint profileMask, ExtensionName multiviewExtension); class MultiviewTestBase : public ANGLETestBase diff --git a/src/tests/test_utils/angle_test_configs.cpp b/src/tests/test_utils/angle_test_configs.cpp index 9a4c25e9c..537255e41 100644 --- a/src/tests/test_utils/angle_test_configs.cpp +++ b/src/tests/test_utils/angle_test_configs.cpp @@ -6,6 +6,7 @@ #include "test_utils/angle_test_configs.h" +#include "common/debug.h" #include "common/platform.h" #include "common/string_utils.h" #include "util/util_gl.h" @@ -38,24 +39,37 @@ bool HasFeatureOverride(const std::vector &overrides, Feature feature) } } // namespace -PlatformParameters::PlatformParameters() : PlatformParameters(2, 0, GLESDriverType::AngleEGL) {} +PlatformParameters::PlatformParameters() + : PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, GLESDriverType::AngleEGL) +{} -PlatformParameters::PlatformParameters(EGLint majorVersion, +PlatformParameters::PlatformParameters(EGLenum clientType, + EGLint majorVersion, EGLint minorVersion, + EGLint profileMask, const EGLPlatformParameters &eglPlatformParameters) : driver(GLESDriverType::AngleEGL), noFixture(false), eglParameters(eglPlatformParameters), + clientType(clientType), majorVersion(majorVersion), - minorVersion(minorVersion) + minorVersion(minorVersion), + profileMask(profileMask) { initDefaultParameters(); } -PlatformParameters::PlatformParameters(EGLint majorVersion, +PlatformParameters::PlatformParameters(EGLenum clientType, + EGLint majorVersion, EGLint minorVersion, + EGLint profileMask, GLESDriverType driver) - : driver(driver), noFixture(false), majorVersion(majorVersion), minorVersion(minorVersion) + : driver(driver), + noFixture(false), + clientType(clientType), + majorVersion(majorVersion), + minorVersion(minorVersion), + profileMask(profileMask) { initDefaultParameters(); } @@ -85,6 +99,11 @@ bool PlatformParameters::isANGLE() const return driver == GLESDriverType::AngleEGL; } +bool PlatformParameters::isDesktopOpenGLFrontend() const +{ + return clientType == EGL_OPENGL_API; +} + void PlatformParameters::initDefaultParameters() { // Default debug layers to enabled in tests. @@ -143,12 +162,49 @@ const char *GetRendererName(EGLint renderer) std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp) { - stream << "ES" << pp.majorVersion << "_"; + switch (pp.clientType) + { + case EGL_OPENGL_ES_API: + stream << "ES"; + break; + + case EGL_OPENGL_API: + stream << "GL"; + break; + + case EGL_OPENVG_API: + stream << "VG"; + break; + + default: + UNREACHABLE(); + stream << "Error"; + break; + } + + stream << pp.majorVersion << "_"; if (pp.minorVersion != 0) { stream << pp.minorVersion << "_"; } + if (pp.clientType == EGL_OPENGL_API) + { + if ((pp.profileMask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT) != 0) + { + stream << "Core_"; + } + if ((pp.profileMask & EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT) != 0) + { + stream << "Compatibility_"; + } + } + else + { + // Profile mask is only valid for desktop OpenGL contexts. + ASSERT(pp.profileMask == 0); + } + switch (pp.driver) { case GLESDriverType::AngleEGL: @@ -473,336 +529,352 @@ EGLPlatformParameters METAL() // ANGLE tests platforms PlatformParameters ES1_D3D9() { - return PlatformParameters(1, 0, egl_platform::D3D9()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::D3D9()); } PlatformParameters ES2_D3D9() { - return PlatformParameters(2, 0, egl_platform::D3D9()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D9()); } PlatformParameters ES1_D3D11() { - return PlatformParameters(1, 0, egl_platform::D3D11()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::D3D11()); } PlatformParameters ES2_D3D11() { - return PlatformParameters(2, 0, egl_platform::D3D11()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11()); } PlatformParameters ES2_D3D11_PRESENT_PATH_FAST() { - return PlatformParameters(2, 0, egl_platform::D3D11_PRESENT_PATH_FAST()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_PRESENT_PATH_FAST()); } PlatformParameters ES2_D3D11_FL11_0() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL11_0()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL11_0()); } PlatformParameters ES2_D3D11_FL10_1() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_1()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_1()); } PlatformParameters ES2_D3D11_FL10_0() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_0()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_0()); } PlatformParameters ES2_D3D11_WARP() { - return PlatformParameters(2, 0, egl_platform::D3D11_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_WARP()); } PlatformParameters ES2_D3D11_FL11_0_WARP() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL11_0_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL11_0_WARP()); } PlatformParameters ES2_D3D11_FL10_1_WARP() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_1_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_1_WARP()); } PlatformParameters ES2_D3D11_FL10_0_WARP() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_0_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_0_WARP()); } PlatformParameters ES2_D3D11_REFERENCE() { - return PlatformParameters(2, 0, egl_platform::D3D11_REFERENCE()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_REFERENCE()); } PlatformParameters ES2_D3D11_FL11_0_REFERENCE() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL11_0_REFERENCE()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL11_0_REFERENCE()); } PlatformParameters ES2_D3D11_FL10_1_REFERENCE() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_1_REFERENCE()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_1_REFERENCE()); } PlatformParameters ES2_D3D11_FL10_0_REFERENCE() { - return PlatformParameters(2, 0, egl_platform::D3D11_FL10_0_REFERENCE()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::D3D11_FL10_0_REFERENCE()); } PlatformParameters ES3_D3D11() { - return PlatformParameters(3, 0, egl_platform::D3D11()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11()); } PlatformParameters ES3_D3D11_FL11_1() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL11_1()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL11_1()); } PlatformParameters ES3_D3D11_FL11_0() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL11_0()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL11_0()); } PlatformParameters ES3_D3D11_FL10_1() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL10_1()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL10_1()); } PlatformParameters ES31_D3D11() { - return PlatformParameters(3, 1, egl_platform::D3D11()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::D3D11()); } PlatformParameters ES31_D3D11_FL11_1() { - return PlatformParameters(3, 1, egl_platform::D3D11_FL11_1()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::D3D11_FL11_1()); } PlatformParameters ES31_D3D11_FL11_0() { - return PlatformParameters(3, 1, egl_platform::D3D11_FL11_0()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::D3D11_FL11_0()); } PlatformParameters ES3_D3D11_WARP() { - return PlatformParameters(3, 0, egl_platform::D3D11_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_WARP()); } PlatformParameters ES3_D3D11_FL11_1_WARP() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL11_1_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL11_1_WARP()); } PlatformParameters ES3_D3D11_FL11_0_WARP() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL11_0_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL11_0_WARP()); } PlatformParameters ES3_D3D11_FL10_1_WARP() { - return PlatformParameters(3, 0, egl_platform::D3D11_FL10_1_WARP()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::D3D11_FL10_1_WARP()); } PlatformParameters ES1_OPENGLES() { - return PlatformParameters(1, 0, egl_platform::OPENGLES()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::OPENGLES()); } PlatformParameters ES2_OPENGLES() { - return PlatformParameters(2, 0, egl_platform::OPENGLES()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::OPENGLES()); } PlatformParameters ES2_OPENGLES(EGLint major, EGLint minor) { - return PlatformParameters(2, 0, egl_platform::OPENGLES(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::OPENGLES(major, minor)); } PlatformParameters ES3_OPENGLES() { - return PlatformParameters(3, 0, egl_platform::OPENGLES()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::OPENGLES()); } PlatformParameters ES3_OPENGLES(EGLint major, EGLint minor) { - return PlatformParameters(3, 0, egl_platform::OPENGLES(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::OPENGLES(major, minor)); } PlatformParameters ES31_OPENGLES() { - return PlatformParameters(3, 1, egl_platform::OPENGLES()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::OPENGLES()); } PlatformParameters ES31_OPENGLES(EGLint major, EGLint minor) { - return PlatformParameters(3, 1, egl_platform::OPENGLES(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::OPENGLES(major, minor)); } PlatformParameters ES1_OPENGL() { - return PlatformParameters(1, 0, egl_platform::OPENGL()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::OPENGL()); } PlatformParameters ES2_OPENGL() { - return PlatformParameters(2, 0, egl_platform::OPENGL()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::OPENGL()); } PlatformParameters ES2_OPENGL(EGLint major, EGLint minor) { - return PlatformParameters(2, 0, egl_platform::OPENGL(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::OPENGL(major, minor)); } PlatformParameters ES3_OPENGL() { - return PlatformParameters(3, 0, egl_platform::OPENGL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::OPENGL()); } PlatformParameters ES3_OPENGL(EGLint major, EGLint minor) { - return PlatformParameters(3, 0, egl_platform::OPENGL(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::OPENGL(major, minor)); } PlatformParameters ES31_OPENGL() { - return PlatformParameters(3, 1, egl_platform::OPENGL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::OPENGL()); } PlatformParameters ES31_OPENGL(EGLint major, EGLint minor) { - return PlatformParameters(3, 1, egl_platform::OPENGL(major, minor)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::OPENGL(major, minor)); } PlatformParameters ES1_NULL() { - return PlatformParameters(1, 0, EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, + EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); } PlatformParameters ES2_NULL() { - return PlatformParameters(2, 0, EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, + EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); } PlatformParameters ES3_NULL() { - return PlatformParameters(3, 0, EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, + EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); } PlatformParameters ES31_NULL() { - return PlatformParameters(3, 1, EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, + EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)); } PlatformParameters ES1_VULKAN() { - return PlatformParameters(1, 0, egl_platform::VULKAN()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::VULKAN()); } PlatformParameters ES1_VULKAN_NULL() { - return PlatformParameters(1, 0, egl_platform::VULKAN_NULL()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::VULKAN_NULL()); } PlatformParameters ES1_VULKAN_SWIFTSHADER() { - return PlatformParameters(1, 0, egl_platform::VULKAN_SWIFTSHADER()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::VULKAN_SWIFTSHADER()); } PlatformParameters ES2_VULKAN() { - return PlatformParameters(2, 0, egl_platform::VULKAN()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::VULKAN()); } PlatformParameters ES2_VULKAN_NULL() { - return PlatformParameters(2, 0, egl_platform::VULKAN_NULL()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::VULKAN_NULL()); } PlatformParameters ES2_VULKAN_SWIFTSHADER() { - return PlatformParameters(2, 0, egl_platform::VULKAN_SWIFTSHADER()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::VULKAN_SWIFTSHADER()); } PlatformParameters ES3_VULKAN() { - return PlatformParameters(3, 0, egl_platform::VULKAN()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::VULKAN()); } PlatformParameters ES3_VULKAN_NULL() { - return PlatformParameters(3, 0, egl_platform::VULKAN_NULL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::VULKAN_NULL()); } PlatformParameters ES3_VULKAN_SWIFTSHADER() { - return PlatformParameters(3, 0, egl_platform::VULKAN_SWIFTSHADER()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::VULKAN_SWIFTSHADER()); } PlatformParameters ES31_VULKAN() { - return PlatformParameters(3, 1, egl_platform::VULKAN()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::VULKAN()); } PlatformParameters ES31_VULKAN_NULL() { - return PlatformParameters(3, 1, egl_platform::VULKAN_NULL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::VULKAN_NULL()); } PlatformParameters ES31_VULKAN_SWIFTSHADER() { - return PlatformParameters(3, 1, egl_platform::VULKAN_SWIFTSHADER()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 1, 0, egl_platform::VULKAN_SWIFTSHADER()); } PlatformParameters ES32_VULKAN() { - return PlatformParameters(3, 2, egl_platform::VULKAN()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 2, 0, egl_platform::VULKAN()); } PlatformParameters ES32_VULKAN_NULL() { - return PlatformParameters(3, 2, egl_platform::VULKAN_NULL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 2, 0, egl_platform::VULKAN_NULL()); } PlatformParameters ES32_VULKAN_SWIFTSHADER() { - return PlatformParameters(3, 2, egl_platform::VULKAN_SWIFTSHADER()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 2, 0, egl_platform::VULKAN_SWIFTSHADER()); +} + +PlatformParameters GL32_CORE_VULKAN() +{ + return PlatformParameters(EGL_OPENGL_API, 3, 2, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, + egl_platform::VULKAN()); +} + +PlatformParameters GL32_CORE_VULKAN_SWIFTSHADER() +{ + return PlatformParameters(EGL_OPENGL_API, 3, 2, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, + egl_platform::VULKAN_SWIFTSHADER()); } PlatformParameters ES1_METAL() { - return PlatformParameters(1, 0, egl_platform::METAL()); + return PlatformParameters(EGL_OPENGL_ES_API, 1, 0, 0, egl_platform::METAL()); } PlatformParameters ES2_METAL() { - return PlatformParameters(2, 0, egl_platform::METAL()); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, egl_platform::METAL()); } PlatformParameters ES3_METAL() { - return PlatformParameters(3, 0, egl_platform::METAL()); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, egl_platform::METAL()); } PlatformParameters ES2_WGL() { - return PlatformParameters(2, 0, GLESDriverType::SystemWGL); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, GLESDriverType::SystemWGL); } PlatformParameters ES3_WGL() { - return PlatformParameters(3, 0, GLESDriverType::SystemWGL); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, GLESDriverType::SystemWGL); } PlatformParameters ES2_EGL() { - return PlatformParameters(2, 0, GLESDriverType::SystemEGL); + return PlatformParameters(EGL_OPENGL_ES_API, 2, 0, 0, GLESDriverType::SystemEGL); } PlatformParameters ES3_EGL() { - return PlatformParameters(3, 0, GLESDriverType::SystemEGL); + return PlatformParameters(EGL_OPENGL_ES_API, 3, 0, 0, GLESDriverType::SystemEGL); } } // namespace angle diff --git a/src/tests/test_utils/angle_test_configs.h b/src/tests/test_utils/angle_test_configs.h index 6292fedab..8d0ffa235 100644 --- a/src/tests/test_utils/angle_test_configs.h +++ b/src/tests/test_utils/angle_test_configs.h @@ -26,22 +26,30 @@ namespace angle struct PlatformParameters { PlatformParameters(); - PlatformParameters(EGLint majorVersion, + PlatformParameters(EGLenum clientType, + EGLint majorVersion, EGLint minorVersion, + EGLint profileMask, const EGLPlatformParameters &eglPlatformParameters); - PlatformParameters(EGLint majorVersion, EGLint minorVersion, GLESDriverType driver); + PlatformParameters(EGLenum clientType, + EGLint majorVersion, + EGLint minorVersion, + EGLint profileMask, + GLESDriverType driver); EGLint getRenderer() const; EGLint getDeviceType() const; bool isSwiftshader() const; bool isVulkan() const; bool isANGLE() const; + bool isDesktopOpenGLFrontend() const; void initDefaultParameters(); auto tie() const { - return std::tie(driver, noFixture, eglParameters, majorVersion, minorVersion); + return std::tie(driver, noFixture, eglParameters, clientType, majorVersion, minorVersion, + profileMask); } // Helpers to enable and disable ANGLE features. Expects a Feature::* value from @@ -62,8 +70,10 @@ struct PlatformParameters GLESDriverType driver; bool noFixture; EGLPlatformParameters eglParameters; + EGLenum clientType; EGLint majorVersion; EGLint minorVersion; + EGLint profileMask; }; const char *GetRendererName(EGLint renderer); @@ -192,6 +202,8 @@ PlatformParameters ES31_VULKAN_SWIFTSHADER(); PlatformParameters ES32_VULKAN(); PlatformParameters ES32_VULKAN_NULL(); PlatformParameters ES32_VULKAN_SWIFTSHADER(); +PlatformParameters GL32_CORE_VULKAN(); +PlatformParameters GL32_CORE_VULKAN_SWIFTSHADER(); PlatformParameters ES1_METAL(); PlatformParameters ES2_METAL(); diff --git a/src/tests/test_utils/angle_test_instantiate.cpp b/src/tests/test_utils/angle_test_instantiate.cpp index 17356ff8e..1e6c62a4a 100644 --- a/src/tests/test_utils/angle_test_instantiate.cpp +++ b/src/tests/test_utils/angle_test_instantiate.cpp @@ -47,7 +47,8 @@ bool IsAngleEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWind angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir)); #endif - EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion); + EGLWindow *eglWindow = + EGLWindow::New(param.clientType, param.majorVersion, param.minorVersion, param.profileMask); ConfigParameters configParams; bool result = eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::AngleEGL, @@ -63,7 +64,8 @@ bool IsSystemWGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWin std::unique_ptr openglLibrary( angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir)); - WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion); + WGLWindow *wglWindow = + WGLWindow::New(param.clientType, param.majorVersion, param.minorVersion, param.profileMask); ConfigParameters configParams; bool result = wglWindow->initializeGL(osWindow, openglLibrary.get(), angle::GLESDriverType::SystemWGL, @@ -84,7 +86,8 @@ bool IsSystemEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWin eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension(), SearchType::SystemDir)); - EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion); + EGLWindow *eglWindow = + EGLWindow::New(param.clientType, param.majorVersion, param.minorVersion, param.profileMask); ConfigParameters configParams; bool result = eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::SystemEGL, @@ -441,6 +444,14 @@ bool IsConfigAllowlisted(const SystemInfo &systemInfo, const PlatformParameters return false; } +// Skip test configs that target the desktop OpenGL frontend when it's not enabled. +#if !defined(ANGLE_ENABLE_OPENGL_DESKTOP) + if (param.isDesktopOpenGLFrontend()) + { + return false; + } +#endif + if (IsWindows()) { switch (param.driver) diff --git a/src/tests/test_utils/angle_test_instantiate.h b/src/tests/test_utils/angle_test_instantiate.h index f3dae4bc7..9940deb3f 100644 --- a/src/tests/test_utils/angle_test_instantiate.h +++ b/src/tests/test_utils/angle_test_instantiate.h @@ -145,6 +145,8 @@ struct CombinedPrintToStringParamName #define ANGLE_ALL_TEST_PLATFORMS_ES32 \ ES32_VULKAN(), ES32_VULKAN().enable(Feature::AsyncCommandQueue) +#define ANGLE_ALL_TEST_PLATFORMS_GL32_CORE GL32_CORE_VULKAN(), GL32_CORE_VULKAN_SWIFTSHADER() + #define ANGLE_ALL_TEST_PLATFORMS_NULL ES2_NULL(), ES3_NULL(), ES31_NULL() // Instantiate the test once for each GLES1 platform @@ -197,6 +199,18 @@ struct CombinedPrintToStringParamName INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ testing::PrintToStringParamName()) +// Instantiate the test once for each desktop GL 3.2 core platform +#define ANGLE_INSTANTIATE_TEST_GL32_CORE(testName) \ + const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_GL32_CORE}; \ + INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ + testing::PrintToStringParamName()) + +#define ANGLE_INSTANTIATE_TEST_GL32_CORE_AND(testName, ...) \ + const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_GL32_CORE, \ + __VA_ARGS__}; \ + INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ + testing::PrintToStringParamName()) + // Multiple ES Version macros #define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(testName) \ const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES2, \ @@ -231,6 +245,13 @@ struct CombinedPrintToStringParamName INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ testing::PrintToStringParamName()) +#define ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND_ES31_AND_NULL_AND(testName, ...) \ + const PlatformParameters testName##params[] = { \ + ANGLE_ALL_TEST_PLATFORMS_ES2, ANGLE_ALL_TEST_PLATFORMS_ES3, ANGLE_ALL_TEST_PLATFORMS_ES31, \ + ANGLE_ALL_TEST_PLATFORMS_NULL, __VA_ARGS__}; \ + INSTANTIATE_TEST_SUITE_P(, testName, ANGLE_INSTANTIATE_TEST_PLATFORMS(testName), \ + testing::PrintToStringParamName()) + #define ANGLE_INSTANTIATE_TEST_ES3_AND_ES31(testName) \ const PlatformParameters testName##params[] = {ANGLE_ALL_TEST_PLATFORMS_ES3, \ ANGLE_ALL_TEST_PLATFORMS_ES31}; \ diff --git a/util/EGLWindow.cpp b/util/EGLWindow.cpp index 150129823..03f5f68cc 100644 --- a/util/EGLWindow.cpp +++ b/util/EGLWindow.cpp @@ -51,15 +51,24 @@ void ConfigParameters::reset() } // GLWindowBase implementation. -GLWindowBase::GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion) - : mClientMajorVersion(glesMajorVersion), mClientMinorVersion(glesMinorVersion) +GLWindowBase::GLWindowBase(EGLenum clientType, + GLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask) + : mClientType(clientType), + mClientMajorVersion(glesMajorVersion), + mClientMinorVersion(glesMinorVersion), + mProfileMask(profileMask) {} GLWindowBase::~GLWindowBase() = default; // EGLWindow implementation. -EGLWindow::EGLWindow(EGLint glesMajorVersion, EGLint glesMinorVersion) - : GLWindowBase(glesMajorVersion, glesMinorVersion), +EGLWindow::EGLWindow(EGLenum clientType, + EGLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask) + : GLWindowBase(clientType, glesMajorVersion, glesMinorVersion, profileMask), mConfig(0), mDisplay(EGL_NO_DISPLAY), mSurface(EGL_NO_SURFACE), @@ -495,7 +504,7 @@ EGLContext EGLWindow::createContext(EGLContext share, EGLint *extraAttributes) return EGL_NO_CONTEXT; } - eglBindAPI(EGL_OPENGL_ES_API); + eglBindAPI(mClientType); if (eglGetError() != EGL_SUCCESS) { fprintf(stderr, "Error on eglBindAPI.\n"); @@ -518,6 +527,12 @@ EGLContext EGLWindow::createContext(EGLContext share, EGLint *extraAttributes) contextAttributes.push_back(EGL_CONTEXT_MINOR_VERSION_KHR); contextAttributes.push_back(mClientMinorVersion); + if (mProfileMask != 0) + { + contextAttributes.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK); + contextAttributes.push_back(mProfileMask); + } + // Note that the Android loader currently doesn't handle this flag despite reporting 1.5. // Work around this by only using the debug bit when we request a debug context. if (hasDebug && mConfigParams.debug) @@ -829,9 +844,12 @@ void GLWindowBase::Delete(GLWindowBase **window) } // static -EGLWindow *EGLWindow::New(EGLint glesMajorVersion, EGLint glesMinorVersion) +EGLWindow *EGLWindow::New(EGLenum clientType, + EGLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask) { - return new EGLWindow(glesMajorVersion, glesMinorVersion); + return new EGLWindow(clientType, glesMajorVersion, glesMinorVersion, profileMask); } // static diff --git a/util/EGLWindow.h b/util/EGLWindow.h index be60da0a1..905702afa 100644 --- a/util/EGLWindow.h +++ b/util/EGLWindow.h @@ -88,6 +88,8 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable // It should also be possible to set multisample and floating point framebuffers. EGLint getClientMajorVersion() const { return mClientMajorVersion; } EGLint getClientMinorVersion() const { return mClientMinorVersion; } + EGLenum getClientType() const { return mClientType; } + EGLint getProfileMask() const { return mProfileMask; } virtual bool initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary, @@ -140,11 +142,16 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable const ConfigParameters &getConfigParams() const { return mConfigParams; } protected: - GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion); + GLWindowBase(EGLenum clientType, + EGLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask); virtual ~GLWindowBase(); + EGLenum mClientType; EGLint mClientMajorVersion; EGLint mClientMinorVersion; + EGLint mProfileMask; EGLPlatformParameters mPlatform; ConfigParameters mConfigParams; }; @@ -152,7 +159,10 @@ class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase { public: - static EGLWindow *New(EGLint glesMajorVersion, EGLint glesMinorVersion); + static EGLWindow *New(EGLenum clientType, + EGLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask); static void Delete(EGLWindow **window); static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); @@ -231,7 +241,10 @@ class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase bool isDisplayInitialized() const { return mDisplay != EGL_NO_DISPLAY; } private: - EGLWindow(EGLint glesMajorVersion, EGLint glesMinorVersion); + EGLWindow(EGLenum clientType, + EGLint glesMajorVersion, + EGLint glesMinorVersion, + EGLint profileMask); ~EGLWindow() override; EGLConfig mConfig; diff --git a/util/windows/WGLWindow.cpp b/util/windows/WGLWindow.cpp index 31458a883..be2745687 100644 --- a/util/windows/WGLWindow.cpp +++ b/util/windows/WGLWindow.cpp @@ -114,8 +114,8 @@ std::vector GetPixelFormatAttributes(const ConfigParameters &configParams) } // namespace -WGLWindow::WGLWindow(int glesMajorVersion, int glesMinorVersion) - : GLWindowBase(glesMajorVersion, glesMinorVersion), +WGLWindow::WGLWindow(EGLenum clientType, int majorVersion, int minorVersion, int profileMask) + : GLWindowBase(clientType, majorVersion, minorVersion, profileMask), mDeviceContext(nullptr), mWGLContext(nullptr), mWindow(nullptr) @@ -269,17 +269,34 @@ HGLRC WGLWindow::createContext(const ConfigParameters &configParams, HGLRC share // Tear down the context and create another with ES2 compatibility. _wglDeleteContext(context); - // This could be extended to cover ES1 compatiblity. - int kCreateAttribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, - mClientMajorVersion, - WGL_CONTEXT_MINOR_VERSION_ARB, - mClientMinorVersion, - WGL_CONTEXT_PROFILE_MASK_ARB, - WGL_CONTEXT_ES2_PROFILE_BIT_EXT, - 0, - 0}; + // This could be extended to cover ES1 compatibility and desktop GL profiles. + int profileMask = 0; + if (mClientType == EGL_OPENGL_ES_API) + { + profileMask = WGL_CONTEXT_ES2_PROFILE_BIT_EXT; + } + else + { + if ((mProfileMask & EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT) != 0) + { + profileMask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + } + if ((mProfileMask & EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT) != 0) + { + profileMask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + } + } - context = _wglCreateContextAttribsARB(mDeviceContext, shareContext, kCreateAttribs); + const int createAttribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, + mClientMajorVersion, + WGL_CONTEXT_MINOR_VERSION_ARB, + mClientMinorVersion, + WGL_CONTEXT_PROFILE_MASK_ARB, + profileMask, + 0, + 0}; + + context = _wglCreateContextAttribsARB(mDeviceContext, shareContext, createAttribs); if (!context) { std::cerr << "Failed to create an ES2 compatible WGL context." << std::endl; @@ -439,9 +456,9 @@ angle::GenericProc WGLWindow::getProcAddress(const char *name) } // static -WGLWindow *WGLWindow::New(int glesMajorVersion, int glesMinorVersion) +WGLWindow *WGLWindow::New(EGLenum clientType, int majorVersion, int minorVersion, int profileMask) { - return new WGLWindow(glesMajorVersion, glesMinorVersion); + return new WGLWindow(clientType, majorVersion, minorVersion, profileMask); } // static diff --git a/util/windows/WGLWindow.h b/util/windows/WGLWindow.h index 795c9262b..80bd5131d 100644 --- a/util/windows/WGLWindow.h +++ b/util/windows/WGLWindow.h @@ -24,7 +24,7 @@ class Library; class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase { public: - static WGLWindow *New(int glesMajorVersion, int glesMinorVersion); + static WGLWindow *New(EGLenum clientType, int majorVersion, int minorVersion, int profileMask); static void Delete(WGLWindow **window); // Internally initializes GL resources. @@ -74,7 +74,7 @@ class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase bool makeCurrent(HGLRC context); private: - WGLWindow(int glesMajorVersion, int glesMinorVersion); + WGLWindow(EGLenum clientType, int majorVersion, int minorVersion, int profileMask); ~WGLWindow() override; // OS resources.