Hash :
de40b6e5
Author :
Date :
2025-06-06T13:18:09
tests: Add GetEglPlatform() Testing the system EGL library was recently added to ANGLE's end2end tests, breaking the assumption that the tests were interacting with the ANGLE EGL library directly. Many EGL end2end tests call eglGetPlatformDisplay() with the platform value EGL_PLATFORM_ANGLE_ANGLE. However, Android only allows EGL_PLATFORM_ANDROID_KHR, rejecting all other values (returning EGL_NO_DISPLAY). Add GetEglPlatform() to return the platform value to pass to eglGetPlatformDisplay(), based on things like the driver being tested and the OS the tests are running on. Currently, this only supports returning EGL_PLATFORM_ANDROID_KHR for SystemEGL+Android, and EGL_PLATFORM_ANGLE_ANGLE for everything else. Bug: b/279980674 Change-Id: Ib8d7970c8e178beb14ecc6a4f96156783e60c257 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6634554 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@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
//
// Copyright 2020 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.
//
// EGLDisplayLuidTest.cpp:
// Tests for the EGL_ANGLE_platform_angle_d3d_luid extension.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
class EGLDisplayLuidTest : public ANGLETest<>
{
protected:
EGLDisplayLuidTest() : mDisplay(EGL_NO_DISPLAY) {}
void testTearDown() override
{
if (mDisplay != EGL_NO_DISPLAY)
{
EXPECT_EGL_TRUE(eglTerminate(mDisplay));
EXPECT_EGL_SUCCESS();
}
}
void testInvalidAttribs(const EGLAttrib displayAttribs[])
{
EXPECT_EQ(eglGetPlatformDisplay(GetEglPlatform(), EGL_DEFAULT_DISPLAY, displayAttribs),
EGL_NO_DISPLAY);
EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
}
void testValidAttribs(const EGLAttrib displayAttribs[])
{
mDisplay = eglGetPlatformDisplay(GetEglPlatform(), EGL_DEFAULT_DISPLAY, displayAttribs);
EXPECT_EGL_SUCCESS();
EXPECT_NE(mDisplay, EGL_NO_DISPLAY);
// eglInitialize should succeed even if the LUID doesn't match an actual
// adapter on the system. The behavior in this case is that the default
// adapter is used.
EXPECT_EGL_TRUE(eglInitialize(mDisplay, nullptr, nullptr));
EXPECT_EGL_SUCCESS();
}
private:
EGLDisplay mDisplay;
};
// EGL_ANGLE_platform_angle_d3d_luid is only supported on D3D11. Verify failure
// if D3D9 is specified in the attributes.
TEST_P(EGLDisplayLuidTest, D3D9Failure)
{
EGLAttrib displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE, 1, EGL_NONE};
testInvalidAttribs(displayAttribs);
}
// Verify failure if the specified LUID is zero.
TEST_P(EGLDisplayLuidTest, ZeroLuidFailure)
{
EGLAttrib displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE,
0,
EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE,
0,
EGL_NONE};
testInvalidAttribs(displayAttribs);
}
TEST_P(EGLDisplayLuidTest, D3D11)
{
EGLAttrib displayAttribs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE, 1, EGL_NONE};
testValidAttribs(displayAttribs);
}
ANGLE_INSTANTIATE_TEST(EGLDisplayLuidTest, WithNoFixture(ES2_D3D9()), WithNoFixture(ES2_D3D11()));