Hi,
On Thursday, July 21, 2016 10:10:12 Adam Jackson wrote:
> There was a patch series posted for Mesa a while ago to add these. It
> never went anywhere, possibly due to lack of interest, but Dave rightly
> pointed out we have no tests for them. So, here, have some tests.
Lately I had been playing on this too. I don't want to open up a
concurrent patch line but in case you find something from
my work useful: attached is the piglit test that I started. Feel free
to reuse whatever you like.
Thanks
Mathias
>From b1ea0cc7c70df96fe58b8973cb9c29f8a1dcd744 Mon Sep 17 00:00:00 2001
Message-Id: <b1ea0cc7c70df96fe58b8973cb9c29f8a1dcd744.1469168001.git.mathias.froehl...@gmx.net>
From: =?UTF-8?q?Mathias=20Fr=C3=B6hlich?= <[email protected]>
Date: Thu, 23 Jun 2016 08:01:21 +0200
Subject: [PATCH] egl: Add tests for EGL_EXT_device_base.
Signed-off-by: Mathias Froehlich <[email protected]>
---
tests/egl/spec/CMakeLists.txt | 1 +
.../egl/spec/egl_ext_device_base/CMakeLists.gl.txt | 15 ++
tests/egl/spec/egl_ext_device_base/CMakeLists.txt | 1 +
.../spec/egl_ext_device_base/nodisplay-context.c | 203 +++++++++++++++++++++
4 files changed, 220 insertions(+)
create mode 100644 tests/egl/spec/egl_ext_device_base/CMakeLists.gl.txt
create mode 100644 tests/egl/spec/egl_ext_device_base/CMakeLists.txt
create mode 100644 tests/egl/spec/egl_ext_device_base/nodisplay-context.c
diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt
index 5d5fc78..1c3603d 100644
--- a/tests/egl/spec/CMakeLists.txt
+++ b/tests/egl/spec/CMakeLists.txt
@@ -7,3 +7,4 @@ if (PIGLIT_HAS_X11)
add_subdirectory (egl_chromium_sync_control)
endif (PIGLIT_HAS_X11)
add_subdirectory (egl_khr_surfaceless_context)
+add_subdirectory (egl_ext_device_base)
diff --git a/tests/egl/spec/egl_ext_device_base/CMakeLists.gl.txt b/tests/egl/spec/egl_ext_device_base/CMakeLists.gl.txt
new file mode 100644
index 0000000..f302d75
--- /dev/null
+++ b/tests/egl/spec/egl_ext_device_base/CMakeLists.gl.txt
@@ -0,0 +1,15 @@
+
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${GLPROTO_INCLUDE_DIRS}
+)
+
+link_libraries (
+ ${EGL_LDFLAGS}
+ ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (egl-device-base-nodisplay-context nodisplay-context.c)
+
+# vim: ft=cmake:
diff --git a/tests/egl/spec/egl_ext_device_base/CMakeLists.txt b/tests/egl/spec/egl_ext_device_base/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/egl/spec/egl_ext_device_base/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/egl/spec/egl_ext_device_base/nodisplay-context.c b/tests/egl/spec/egl_ext_device_base/nodisplay-context.c
new file mode 100644
index 0000000..043f337
--- /dev/null
+++ b/tests/egl/spec/egl_ext_device_base/nodisplay-context.c
@@ -0,0 +1,203 @@
+/* Copyright © 2016 Mathias Fröhlich <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * @file nodisplay-context.c
+ * @brief Test getting an EGL context without display.
+ *
+ */
+
+#include "piglit-util-gl.h"
+#include "piglit-util-egl.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#ifndef EGL_EXT_device_base
+#define EGL_EXT_device_base 1
+typedef void *EGLDeviceEXT;
+#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0))
+#define EGL_BAD_DEVICE_EXT 0x322B
+#define EGL_DEVICE_EXT 0x322C
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value);
+typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value);
+#endif /* EGL_EXT_device_base */
+
+int
+main(int argc, char **argv)
+{
+ unsetenv("DISPLAY");
+ piglit_require_egl_extension(EGL_NO_DISPLAY, "EGL_EXT_device_base");
+ piglit_require_egl_extension(EGL_NO_DISPLAY, "EGL_EXT_platform_base");
+
+ PFNEGLQUERYDEVICEATTRIBEXTPROC eglQueryDeviceAttribEXT;
+ eglQueryDeviceAttribEXT = (void*) eglGetProcAddress("eglQueryDeviceAttribEXT");
+ if (!eglQueryDeviceAttribEXT) {
+ fprintf(stderr, "Failed to find eglQueryDeviceAttribEXT pointer\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT;
+ eglQueryDeviceStringEXT = (void*) eglGetProcAddress("eglQueryDeviceStringEXT");
+ if (!eglQueryDeviceStringEXT) {
+ fprintf(stderr, "Failed to find eglQueryDeviceStringEXT pointer\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
+ eglQueryDevicesEXT = (void*) eglGetProcAddress("eglQueryDevicesEXT");
+ if (!eglQueryDevicesEXT) {
+ fprintf(stderr, "Failed to find eglQueryDevicesEXT pointer\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ PFNEGLQUERYDISPLAYATTRIBEXTPROC eglQueryDisplayAttribEXT;
+ eglQueryDisplayAttribEXT = (void*) eglGetProcAddress("eglQueryDisplayAttribEXT");
+ if (!eglQueryDisplayAttribEXT) {
+ fprintf(stderr, "Failed to find eglQueryDisplayAttribEXT pointer\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
+ eglGetPlatformDisplayEXT = (void*) eglGetProcAddress("eglGetPlatformDisplayEXT");
+ if (!eglGetPlatformDisplayEXT) {
+ fprintf(stderr, "Failed to find eglGetPlatformDisplayEXT pointer\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (EGL_FALSE != eglQueryDevicesEXT(0, NULL, NULL)) {
+ fprintf(stderr, "Call #1 to eglQueryDevicesEXT succeeded\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+ fprintf(stderr, "Call #1 to eglQueryDevicesEXT delivered wrong error code\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ EGLint numDevices0;
+ if (EGL_TRUE != eglQueryDevicesEXT(0, NULL, &numDevices0)) {
+ fprintf(stderr, "Call #2 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ fprintf(stderr, "Call #2 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (numDevices0 < 1) {
+ fprintf(stderr, "Expect to find at least one device with call #2 to eglQueryDevicesEXT\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ EGLDeviceEXT* devices = calloc(numDevices0, sizeof(EGLDeviceEXT));
+ EGLint numDevices1;
+ if (EGL_FALSE != eglQueryDevicesEXT(0, devices, &numDevices1)) {
+ fprintf(stderr, "Call #3 to eglQueryDevicesEXT succeeded\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+ fprintf(stderr, "Call #3 to eglQueryDevicesEXT delivered wrong error code\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (EGL_TRUE != eglQueryDevicesEXT(1, devices, &numDevices1)) {
+ fprintf(stderr, "Call #4 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ fprintf(stderr, "Call #4 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (1 != numDevices1) {
+ fprintf(stderr, "Expect to find exactly one device with call #4 to eglQueryDevicesEXT\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (EGL_TRUE != eglQueryDevicesEXT(numDevices0, devices, &numDevices1)) {
+ fprintf(stderr, "Call #5 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ fprintf(stderr, "Call #5 to eglQueryDevicesEXT failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ if (numDevices0 != numDevices1) {
+ fprintf(stderr, "Expect to find the same device count with call #5 to eglQueryDevicesEXT\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ int i;
+ for (i = 0; i < numDevices1; ++i) {
+ EGLDisplay dpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[i], 0);
+ if (EGL_NO_DISPLAY == dpy) {
+ fprintf(stderr, "Expect to get a non zero display\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ EGLint major, minor;
+ if (EGL_TRUE != eglInitialize(dpy, &major, &minor)) {
+ fprintf(stderr, "Expect to be able to initialize the queried display\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ const EGLint attribs[] = {
+ EGL_SURFACE_TYPE, 0,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+ EGL_NONE
+ };
+ EGLint numConfigs;
+ EGLConfig cfg;
+ if (EGL_TRUE != eglChooseConfig(dpy, attribs, &cfg, 1, &numConfigs)) {
+ fprintf(stderr, "Choose config failed on queried display\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (EGL_TRUE != eglBindAPI(EGL_OPENGL_API)) {
+ fprintf(stderr, "Bind api failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ EGLContext ctx = eglCreateContext(dpy, cfg, EGL_NO_CONTEXT, NULL);
+ if (EGL_NO_CONTEXT == ctx) {
+ fprintf(stderr, "Create context failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ if (piglit_is_egl_extension_supported(dpy, "EGL_KHR_surfaceless_context")) {
+ if (EGL_TRUE != eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
+ fprintf(stderr, "Make current failed\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ /*FIXME draw something*/
+ }
+
+ if (EGL_TRUE != eglTerminate(dpy)) {
+ fprintf(stderr, "Expect to be able to terminate the queried display\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ }
+
+ free(devices);
+
+ piglit_report_result(PIGLIT_PASS);
+}
--
2.5.5
_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit