Hash :
dcbcee8a
Author :
Date :
2025-05-15T10:39:55
Tests: Use eglGetPlatformDisplay()
From the EGL 1.5 spec:
Appendix F
Version 1.5
EGL version 1.5 was voted out of the Khronos Technical Working Group
on January 31, 2014, and formally approved by the Khronos Board of
Promoters on March 14, 2014.
EGL 1.5 is the sixth release of EGL. It introduces the following new
features (the EGL extension(s) each feature is based on are also shown
parenthetically):
* Platform support:
– Providing a mechanism for support of multiple platforms (such as
window systems or offscreen rendering frameworks) in a single EGL
implementation at runtime (EGL_EXT_platform_base).
Many tests use eglGetPlatformDisplayEXT() which is provided by the EGL
extension EGL_EXT_platform_base. With the promotion of the
EGL_EXT_platform_base functions to core EGL in version 1.5 and ANGLE
supporting EGL 1.5 (as of at least 2019), update the calls to use
eglGetPlatformDisplay().
This is in preparation for running the ANGLE end2end tests in Android,
which only exposes the EGL 1.5 functions, and not the
EGL_EXT_platform_base functions.
Bug: b/391967165
Test: angle_end2end_tests
Change-Id: I58109c3afe270f46db952e124ee3f5c11200ca35
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6552257
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
//
// Copyright 2015 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 <gtest/gtest.h>
#include "test_utils/ANGLETest.h"
using namespace angle;
class EGLQueryContextTest : public ANGLETest<>
{
public:
void testSetUp() override
{
int clientVersion = GetParam().majorVersion;
EGLAttrib dispattrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, GetParam().getRenderer(), EGL_NONE};
mDisplay = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
reinterpret_cast<void *>(EGL_DEFAULT_DISPLAY), dispattrs);
EXPECT_TRUE(mDisplay != EGL_NO_DISPLAY);
EXPECT_TRUE(eglInitialize(mDisplay, nullptr, nullptr) != EGL_FALSE);
EGLint ncfg;
EGLint cfgattrs[] = {EGL_RED_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_BLUE_SIZE,
8,
EGL_RENDERABLE_TYPE,
clientVersion == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT,
EGL_NONE};
EXPECT_TRUE(eglChooseConfig(mDisplay, cfgattrs, &mConfig, 1, &ncfg) != EGL_FALSE);
EXPECT_TRUE(ncfg == 1);
EGLint ctxattrs[] = {EGL_CONTEXT_CLIENT_VERSION, clientVersion, EGL_NONE};
mContext = eglCreateContext(mDisplay, mConfig, nullptr, ctxattrs);
EXPECT_TRUE(mContext != EGL_NO_CONTEXT);
EGLint surfaceType = EGL_NONE;
eglGetConfigAttrib(mDisplay, mConfig, EGL_SURFACE_TYPE, &surfaceType);
if (surfaceType & EGL_PBUFFER_BIT)
{
EGLint surfattrs[] = {EGL_WIDTH, 16, EGL_HEIGHT, 16, EGL_NONE};
mSurface = eglCreatePbufferSurface(mDisplay, mConfig, surfattrs);
EXPECT_TRUE(mSurface != EGL_NO_SURFACE);
}
}
void testTearDown() override
{
if (mDisplay != EGL_NO_DISPLAY)
{
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(mDisplay, mContext);
if (mSurface)
{
eglDestroySurface(mDisplay, mSurface);
}
eglTerminate(mDisplay);
}
ASSERT_EGL_SUCCESS() << "Error during test TearDown";
}
EGLDisplay mDisplay = EGL_NO_DISPLAY;
EGLConfig mConfig = EGL_NO_CONFIG_KHR;
EGLContext mContext = EGL_NO_CONTEXT;
EGLSurface mSurface = EGL_NO_SURFACE;
};
TEST_P(EGLQueryContextTest, GetConfigID)
{
EGLint configId, contextConfigId;
EXPECT_TRUE(eglGetConfigAttrib(mDisplay, mConfig, EGL_CONFIG_ID, &configId) != EGL_FALSE);
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONFIG_ID, &contextConfigId) != EGL_FALSE);
EXPECT_TRUE(configId == contextConfigId);
}
TEST_P(EGLQueryContextTest, GetClientType)
{
EGLint clientType;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_TYPE, &clientType) !=
EGL_FALSE);
EXPECT_TRUE(clientType == EGL_OPENGL_ES_API);
}
TEST_P(EGLQueryContextTest, GetClientVersion)
{
EGLint clientVersion;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_VERSION, &clientVersion) !=
EGL_FALSE);
EXPECT_GE(clientVersion, GetParam().majorVersion);
}
// Tests querying the client major version from the context.
TEST_P(EGLQueryContextTest, GetClientMajorVersion)
{
EGLint majorVersion;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_MAJOR_VERSION, &majorVersion) !=
EGL_FALSE);
EXPECT_GE(majorVersion, GetParam().majorVersion);
}
// Tests querying the client minor version from the context.
TEST_P(EGLQueryContextTest, GetClientMinorVersion)
{
EGLint minorVersion;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_MINOR_VERSION, &minorVersion) !=
EGL_FALSE);
EXPECT_GE(minorVersion, GetParam().minorVersion);
}
TEST_P(EGLQueryContextTest, GetRenderBufferNoSurface)
{
EGLint renderBuffer;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_RENDER_BUFFER, &renderBuffer) != EGL_FALSE);
EXPECT_TRUE(renderBuffer == EGL_NONE);
}
TEST_P(EGLQueryContextTest, GetRenderBufferBoundSurface)
{
ANGLE_SKIP_TEST_IF(!mSurface);
EGLint renderBuffer, contextRenderBuffer;
EXPECT_TRUE(eglQuerySurface(mDisplay, mSurface, EGL_RENDER_BUFFER, &renderBuffer) != EGL_FALSE);
EXPECT_TRUE(eglMakeCurrent(mDisplay, mSurface, mSurface, mContext) != EGL_FALSE);
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_RENDER_BUFFER, &contextRenderBuffer) !=
EGL_FALSE);
EXPECT_TRUE(renderBuffer == contextRenderBuffer);
ASSERT_EGL_SUCCESS();
}
TEST_P(EGLQueryContextTest, BadDisplay)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(EGL_NO_DISPLAY, mContext, EGL_CONTEXT_CLIENT_TYPE, &val) ==
EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_DISPLAY);
}
TEST_P(EGLQueryContextTest, NotInitialized)
{
EGLint val;
testTearDown();
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONTEXT_CLIENT_TYPE, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_NOT_INITIALIZED);
mDisplay = EGL_NO_DISPLAY;
mSurface = EGL_NO_SURFACE;
mContext = EGL_NO_CONTEXT;
}
TEST_P(EGLQueryContextTest, BadContext)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(mDisplay, EGL_NO_CONTEXT, EGL_CONTEXT_CLIENT_TYPE, &val) ==
EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_CONTEXT);
}
TEST_P(EGLQueryContextTest, BadAttribute)
{
EGLint val;
EXPECT_TRUE(eglQueryContext(mDisplay, mContext, EGL_HEIGHT, &val) == EGL_FALSE);
EXPECT_TRUE(eglGetError() == EGL_BAD_ATTRIBUTE);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLQueryContextTest);
ANGLE_INSTANTIATE_TEST(EGLQueryContextTest,
WithNoFixture(ES2_D3D9()),
WithNoFixture(ES2_D3D11()),
WithNoFixture(ES2_OPENGL()),
WithNoFixture(ES2_VULKAN()),
WithNoFixture(ES3_D3D11()),
WithNoFixture(ES3_OPENGL()));