From 10a8a4349f7b3518c4efaae2b1e18d75bf968423 Mon Sep 17 00:00:00 2001 From: Miguel Casas-Sanchez Date: Thu, 6 Mar 2025 20:44:22 -0800 Subject: [PATCH 1/2] Enable SwAngle for unit tests --- cobalt/build/configs/linux-x64x11/args.gn | 8 +++++++- ui/ozone/platform/starboard/ozone_platform_starboard.cc | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cobalt/build/configs/linux-x64x11/args.gn b/cobalt/build/configs/linux-x64x11/args.gn index 4029cfcebff1..8adf3ce24c36 100644 --- a/cobalt/build/configs/linux-x64x11/args.gn +++ b/cobalt/build/configs/linux-x64x11/args.gn @@ -2,9 +2,11 @@ import("//cobalt/build/configs/chromium_linux-x64x11/args.gn") import("//cobalt/build/configs/common.gn") use_ozone = true +ozone_auto_platforms = false +ozone_platform = "starboard" # Vulkan is a new rendering (and presentation, and more) API intended to replace -# E/GL(ES). Partners are only required to support upto GLES 2.0 : https://developers.google.com/youtube/cobalt/docs/reference/starboard/modules/16/gles#gles_version +# E/GL(ES). Partners are only required to support up to GLES 2.0 : https://developers.google.com/youtube/cobalt/docs/reference/starboard/modules/16/gles#gles_version # Disable Vulkan until we formally decide to support it. enable_vulkan = false @@ -19,6 +21,10 @@ enable_nacl = false # Overriding the flag from //ui/gl/features.gni use_static_angle = true +# Angle supports multiple backends. If Vulkan is engaged (for tests, SwAngle), +# then we don't want to have a real display. +angle_use_vulkan_null_display = true + # Disable udev use_udev = false diff --git a/ui/ozone/platform/starboard/ozone_platform_starboard.cc b/ui/ozone/platform/starboard/ozone_platform_starboard.cc index dbbd6198c1a9..2aa771ebe537 100644 --- a/ui/ozone/platform/starboard/ozone_platform_starboard.cc +++ b/ui/ozone/platform/starboard/ozone_platform_starboard.cc @@ -173,8 +173,6 @@ OzonePlatform* CreateOzonePlatformStarboard() { CHECK_EQ(cmd->GetSwitchValueASCII(switches::kUseGL), gl::kGLImplementationANGLEName) << " Unsupported " << switches::kUseGL << " implementation"; - } else { - cmd->AppendSwitchASCII(switches::kUseGL, gl::kGLImplementationANGLEName); } return new OzonePlatformStarboard(); From 13d5e59d347dd96282c1451a06ca9b5114c34aab Mon Sep 17 00:00:00 2001 From: Miguel Casas-Sanchez Date: Fri, 7 Mar 2025 10:58:05 -0800 Subject: [PATCH 2/2] Use a PBuffer EGLSurface for NPLB tests --- .../testing/fake_graphics_context_provider.cc | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/starboard/testing/fake_graphics_context_provider.cc b/starboard/testing/fake_graphics_context_provider.cc index 9385b864ac13..1898ff1d050a 100644 --- a/starboard/testing/fake_graphics_context_provider.cc +++ b/starboard/testing/fake_graphics_context_provider.cc @@ -44,6 +44,7 @@ #define EGL_CONTEXT_CLIENT_VERSION SB_EGL_CONTEXT_CLIENT_VERSION #define EGL_DEFAULT_DISPLAY SB_EGL_DEFAULT_DISPLAY #define EGL_GREEN_SIZE SB_EGL_GREEN_SIZE +#define EGL_HEIGHT SB_EGL_HEIGHT #define EGL_NONE SB_EGL_NONE #define EGL_NO_CONTEXT SB_EGL_NO_CONTEXT #define EGL_NO_DISPLAY SB_EGL_NO_DISPLAY @@ -54,6 +55,7 @@ #define EGL_RENDERABLE_TYPE SB_EGL_RENDERABLE_TYPE #define EGL_SUCCESS SB_EGL_SUCCESS #define EGL_SURFACE_TYPE SB_EGL_SURFACE_TYPE +#define EGL_WIDTH SB_EGL_WIDTH #define EGL_WINDOW_BIT SB_EGL_WINDOW_BIT #define EGL_CALL(x) \ @@ -73,24 +75,6 @@ namespace starboard { namespace testing { -namespace { - -EGLint const kAttributeList[] = {EGL_RED_SIZE, - 8, - EGL_GREEN_SIZE, - 8, - EGL_BLUE_SIZE, - 8, - EGL_ALPHA_SIZE, - 8, - EGL_SURFACE_TYPE, - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, - EGL_NONE}; - -} // namespace - FakeGraphicsContextProvider::FakeGraphicsContextProvider() : display_(EGL_NO_DISPLAY), surface_(EGL_NO_SURFACE), @@ -192,6 +176,20 @@ void FakeGraphicsContextProvider::InitializeEGL() { // from configs that do allow that. To handle that, we have to attempt // eglCreateWindowSurface() until we find a config that succeeds. + constexpr EGLint kAttributeList[] = {EGL_RED_SIZE, + 8, + EGL_GREEN_SIZE, + 8, + EGL_BLUE_SIZE, + 8, + EGL_ALPHA_SIZE, + 8, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT | EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, + EGL_OPENGL_ES2_BIT, + EGL_NONE}; + // First, query how many configs match the given attribute list. EGLint num_configs = 0; EGL_CALL(eglChooseConfig(display_, kAttributeList, NULL, 0, &num_configs)); @@ -203,16 +201,18 @@ void FakeGraphicsContextProvider::InitializeEGL() { EGL_CALL(eglChooseConfig(display_, kAttributeList, configs, num_configs, &num_configs)); - EGLNativeWindowType native_window = - (EGLNativeWindowType)SbWindowGetPlatformHandle(window_); + //EGLNativeWindowType native_window = + // (EGLNativeWindowType)SbWindowGetPlatformHandle(window_); EGLConfig config = EGLConfig(); - // Find the first config that successfully allow a window surface to be - // created. + // Find the first config that successfully allow a pBuffer surface (i.e. an + // offscreen EGLsurface) to be created. for (int config_number = 0; config_number < num_configs; ++config_number) { config = configs[config_number]; + constexpr EGLint kPBufferAttribs[] = {EGL_WIDTH, 1920, EGL_HEIGHT, 1080, + EGL_NONE}; surface_ = EGL_CALL_SIMPLE( - eglCreateWindowSurface(display_, config, native_window, NULL)); + eglCreatePbufferSurface(display_, config, kPBufferAttribs)); if (EGL_SUCCESS == EGL_CALL_SIMPLE(eglGetError())) { break; }