Hash :
4e0537ce
Author :
Date :
2025-06-13T11:23:58
EGLWindow: Query the Context version after creation Move GetCurrentContextVersion() from src/tests/egl_tests/EGLBackwardsCompatibleContextTest.cpp to util/util_gl.h, so it can be used by both the test and EGLWindow. Without EGL_ANGLE_create_context_backwards_compatible and specifying EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE = EGL_FALSE, ANGLE will create a context with the maximum conformant version the display supports. If the extension is not supported, we need to query the actual context version, so each test can behave accordingly. EGL 1.5 Spec 3.7.1.1 OpenGL and OpenGL ES Context Versions The context returned must be the specified version, or a later version which is backwards compatible with that version. It is expected that EGL_ANGLE_create_context_backwards_compatible is *not* supported when testing the system EGL. This change also adds a log message when the requested context version does not match the actual version. Bug: b/279980674 Change-Id: I58c0779db72c2afcc39c7d88a9a559b37698c994 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6653853 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
//
// 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.
//
// util_gl.h: Includes the right GL/EGL headers for static/shared link.
#ifndef UTIL_GL_H_
#define UTIL_GL_H_
#include "common/platform.h"
#if defined(ANGLE_USE_UTIL_LOADER)
# include "util/egl_loader_autogen.h"
# include "util/gles_loader_autogen.h"
# if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
# include "util/windows/wgl_loader_autogen.h"
# endif // defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_ENABLE_WINDOWS_UWP)
#else
# if !defined(GL_GLES_PROTOTYPES)
# error Config error. Should either be using the ANGLE GL loader or header prototypes.
# endif // !defined(GL_GLES_PROTOTYPES)
# include <EGL/egl.h>
# include <EGL/eglext.h>
# include "angle_gl.h"
#endif // defined(ANGLE_USE_UTIL_LOADER)
#include <string>
namespace angle
{
inline bool CheckExtensionExists(const char *allExtensions, const std::string &extName)
{
const std::string paddedExtensions = std::string(" ") + allExtensions + std::string(" ");
return paddedExtensions.find(std::string(" ") + extName + std::string(" ")) !=
std::string::npos;
}
inline std::pair<EGLint, EGLint> GetCurrentContextVersion()
{
const char *versionString = reinterpret_cast<const char *>(glGetString(GL_VERSION));
if ((versionString == nullptr) || strstr(versionString, "OpenGL ES") == nullptr)
{
return {0, 0};
}
return {versionString[10] - '0', versionString[12] - '0'};
}
} // namespace angle
#endif // UTIL_GL_H_