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
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// EGLNoConfigContectTest.cpp:
// EGL extension EGL_KHR_no_config_context allows a context to be created
// without a config specified. This means all surfaces are compatible.
// As a result compatibility checks are circumvented.
// This test suite creates and verifies creating a configless context
// and then verifies simple rendering to ensure compatibility.
//
#include <gtest/gtest.h>
#include "test_utils/ANGLETest.h"
using namespace angle;
class EGLNoConfigContextTest : public ANGLETest<>
{
public:
EGLNoConfigContextTest() : mDisplay(EGL_NO_DISPLAY), mContext(EGL_NO_CONTEXT) {}
void testSetUp() override
{
int clientVersion = GetParam().majorVersion;
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_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr));
mExtensionSupported = IsEGLDisplayExtensionEnabled(mDisplay, "EGL_KHR_no_config_context");
if (!mExtensionSupported)
{
return; // Not supported, don't create context
}
EGLint ctxattrs[] = {EGL_CONTEXT_CLIENT_VERSION, clientVersion, EGL_NONE};
mContext = eglCreateContext(mDisplay, EGL_NO_CONFIG_KHR, nullptr, ctxattrs);
EXPECT_TRUE(mContext != EGL_NO_CONTEXT);
}
void testTearDown() override
{
if (mDisplay != EGL_NO_DISPLAY)
{
if (mContext != EGL_NO_CONTEXT)
{
eglDestroyContext(mDisplay, mContext);
mContext = EGL_NO_CONTEXT;
}
eglTerminate(mDisplay);
eglReleaseThread();
}
ASSERT_EGL_SUCCESS() << "Error during test TearDown";
}
EGLDisplay mDisplay = EGL_NO_DISPLAY;
EGLContext mContext = EGL_NO_CONTEXT;
bool mExtensionSupported = false;
};
// Check that context has no config.
TEST_P(EGLNoConfigContextTest, QueryConfigID)
{
ANGLE_SKIP_TEST_IF(!mExtensionSupported);
EXPECT_TRUE(mDisplay);
EXPECT_TRUE(mContext);
EGLint configId = -1;
EXPECT_EGL_TRUE(eglQueryContext(mDisplay, mContext, EGL_CONFIG_ID, &configId));
EXPECT_TRUE(configId == 0);
ASSERT_EGL_SUCCESS();
}
// Any surface should be eglMakeCurrent compatible with no-config context.
// Do a glClear and glReadPixel to verify rendering.
TEST_P(EGLNoConfigContextTest, RenderCheck)
{
ANGLE_SKIP_TEST_IF(!mExtensionSupported);
// Get all the configs
EGLint count;
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, nullptr, 0, &count));
EXPECT_TRUE(count > 0);
std::vector<EGLConfig> configs(count);
EXPECT_EGL_TRUE(eglGetConfigs(mDisplay, configs.data(), count, &count));
// For each config, create PbufferSurface and do a render check
EGLSurface surface = EGL_NO_SURFACE;
for (auto config : configs)
{
const uint32_t kWidth = 1;
const uint32_t kHeight = 1;
EGLint configId;
EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_CONFIG_ID, &configId));
EGLint surfaceType;
EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_SURFACE_TYPE, &surfaceType));
EGLint bufferSize;
EXPECT_EGL_TRUE(eglGetConfigAttrib(mDisplay, config, EGL_BUFFER_SIZE, &bufferSize));
constexpr int kRGB8BitSize = 24; // RGB8 is 24 bits
if (isVulkanRenderer() && bufferSize == kRGB8BitSize &&
(surfaceType & EGL_PBUFFER_BIT) != EGL_PBUFFER_BIT)
{
// Skip this config, since the Vulkan backend doesn't support RGB8 pbuffer surfaces.
continue;
}
EGLint surfattrs[] = {EGL_WIDTH, kWidth, EGL_HEIGHT, kHeight, EGL_NONE};
surface = eglCreatePbufferSurface(mDisplay, config, surfattrs);
EXPECT_TRUE(surface != EGL_NO_SURFACE);
EXPECT_EGL_TRUE(eglMakeCurrent(mDisplay, surface, surface, mContext));
ASSERT_EGL_SUCCESS() << "eglMakeCurrent failed with Config: " << configId << '\n';
// ClearColor RED
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR() << "glClear failed";
if (bufferSize > 32)
{ // GL_FLOAT configs
EXPECT_PIXEL_COLOR32F_EQ(0, 0, kFloatRed);
}
else
{ // GL_UNSIGNED_BYTE configs
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
eglDestroySurface(mDisplay, surface);
surface = EGL_NO_SURFACE;
}
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(EGLNoConfigContextTest);
ANGLE_INSTANTIATE_TEST(EGLNoConfigContextTest,
WithNoFixture(ES2_OPENGL()),
WithNoFixture(ES2_VULKAN()),
WithNoFixture(ES3_OPENGL()),
WithNoFixture(ES3_VULKAN()));