[Feat] (tools/cts): port dEQP MobileGL platform to desktop Linux

Guard the AImageReader window path behind __ANDROID__ and add a
mobilegl-desktop DEQP target so glcts can run against libMobileGL.so on a
Linux host via pbuffer surfaces (VK_EXT_headless_surface).
This commit is contained in:
BZLZHH
2026-07-31 14:50:18 -04:00
parent e86a9bbec5
commit 170ccda3e7
3 changed files with 63 additions and 7 deletions
+33 -7
View File
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------
* dEQP platform port for MobileGL on Android
* dEQP platform port for MobileGL (Android and desktop Linux)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,14 +28,17 @@
* - A real surface is always created. MobileGL rejects EGL_NO_SURFACE with
* EGL_BAD_MATCH, and --deqp-surface-type=fbo asks the platform for
* SURFACETYPE_DONT_CARE, so "no surface" is not an option.
* - Window surfaces are backed by an AImageReader rather than an Activity,
* which is what lets the suite run as a plain adb-shell binary. DirectVulkan
* needs this: its pbuffer path requires VK_EXT_headless_surface, which
* Adreno's Android driver does not expose.
* - On Android, window surfaces are backed by an AImageReader rather than an
* Activity, which is what lets the suite run as a plain adb-shell binary.
* DirectVulkan needs this: its pbuffer path requires VK_EXT_headless_surface,
* which Adreno's Android driver does not expose.
* - On desktop Linux, only pbuffer surfaces are offered. DirectVulkan's
* pbuffer path works there because desktop Vulkan loaders expose
* VK_EXT_headless_surface.
*
* Environment:
* MOBILEGL_CTS_LIB path/soname of the MobileGL library (default libMobileGL.so)
* MOBILEGL_CTS_SURFACE "window" (default) or "pbuffer"
* MOBILEGL_CTS_SURFACE "window" (Android default) or "pbuffer" (desktop default/only)
* MOBILEGL_BACKEND_TYPE read by MobileGL itself; set it before launching
*//*--------------------------------------------------------------------*/
@@ -58,9 +61,11 @@
#include "tcuPlatform.hpp"
#include "tcuRenderTarget.hpp"
#if defined(__ANDROID__)
#include <android/hardware_buffer.h>
#include <android/native_window.h>
#include <media/NdkImageReader.h>
#endif
using std::string;
using std::vector;
@@ -88,13 +93,24 @@ static string getLibraryName(void)
return (env && env[0]) ? string(env) : string("libMobileGL.so");
}
//! Window surfaces default on: they are the only kind DirectVulkan can use.
#if defined(__ANDROID__)
//! Window surfaces default on: they are the only kind DirectVulkan can use
//! on Android (its pbuffer path needs VK_EXT_headless_surface).
static bool useWindowSurface(void)
{
const char *env = std::getenv("MOBILEGL_CTS_SURFACE");
return !(env && string(env) == "pbuffer");
}
#else
//! Desktop: pbuffer only. VK_EXT_headless_surface is available there and no
//! Activity-free native window abstraction exists.
static bool useWindowSurface(void)
{
return false;
}
#endif
#if defined(__ANDROID__)
/*--------------------------------------------------------------------*//*!
* \brief A real ANativeWindow with no Activity behind it.
*
@@ -160,6 +176,12 @@ private:
AImageReader *m_reader;
ANativeWindow *m_window;
};
#else
//! Never instantiated on desktop; keeps EglRenderContext's member deletable.
class ImageReaderWindow
{
};
#endif
class GetProcFuncLoader : public glw::FunctionLoader
{
@@ -352,6 +374,7 @@ EglRenderContext::EglRenderContext(const glu::RenderConfig &config, const tcu::C
if (wantWindow)
{
#if defined(__ANDROID__)
m_window = new ImageReaderWindow(width, height);
eglw::EGLint visualId = 0;
@@ -361,6 +384,9 @@ EglRenderContext::EglRenderContext(const glu::RenderConfig &config, const tcu::C
m_eglSurface = m_egl.createWindowSurface(m_eglDisplay, eglConfig,
(eglw::EGLNativeWindowType)m_window->getWindow(), nullptr);
EGLU_CHECK_MSG(m_egl, "eglCreateWindowSurface()");
#else
throw tcu::NotSupportedError("Window surfaces are not supported by the desktop MobileGL platform");
#endif
}
else
{
+1
View File
@@ -21,6 +21,7 @@ CTS_TOOLS = os.path.dirname(HERE)
COPIES = [
(os.path.join(CTS_TOOLS, "platform"), "framework/platform/mobilegl", None),
(os.path.join(CTS_TOOLS, "targets"), "targets/mobilegl", ["mobilegl.cmake", "ndk-modern.cmake"]),
(os.path.join(CTS_TOOLS, "targets"), "targets/mobilegl-desktop", ["mobilegl-desktop.cmake"]),
]
+29
View File
@@ -0,0 +1,29 @@
#-------------------------------------------------------------------------
# VK-GL-CTS target: MobileGL on desktop Linux
#
# Builds glcts as a normal host executable that reaches OpenGL exclusively
# through libMobileGL.so, loaded at runtime via the eglw dynamic wrapper.
# Nothing here links libEGL or libGL: a conformance result must be
# unambiguously MobileGL's, never the system GL stack's.
#
# The platform port only offers pbuffer surfaces on desktop; DirectVulkan's
# pbuffer path works because desktop Vulkan exposes VK_EXT_headless_surface.
#-------------------------------------------------------------------------
message("*** Using MobileGL desktop target")
set(DEQP_TARGET_NAME "MobileGL")
# EGL comes from libMobileGL.so via the eglw dynamic wrapper, so the support
# flag is on but no import library is supplied.
set(DEQP_SUPPORT_EGL ON)
set(DEQP_EGL_LIBRARIES)
set(DEQP_GLES2_LIBRARIES)
set(DEQP_GLES3_LIBRARIES)
set(TCUTIL_PLATFORM_SRCS
mobilegl/tcuMobileGLPlatform.cpp
mobilegl/tcuMobileGLPlatform.hpp
)
list(APPEND TCUTIL_PLATFORM_LIBS dl pthread)