On 08/12/2014 11:18 AM, Emil Velikov wrote:
This will allow up to use waffle with it's upcoming WGL support for
s/up/us/
s/it's/its/
Windows. With that done, the final step to removing glut is to convert
piglit to use waffle for MacOS.
Current implementation does not have input handling/event loop, and as
such one needs to pass "-auto" when running individual tests, otherwise
the test will abort after being displayed for 8 seconds.
TODO:
- Bump the version requirement, once a WAFFLE_WGL is released.
- Update the instructions in the README.
- Add input handling (event_loop).
Signed-off-by: Emil Velikov <[email protected]>
---
CMakeLists.txt | 5 ++
tests/util/CMakeLists.txt | 5 ++
tests/util/piglit-dispatch.c | 19 +++--
.../piglit-framework-gl/piglit_wfl_framework.c | 10 +++
.../piglit-framework-gl/piglit_wgl_framework.c | 85 ++++++++++++++++++++++
.../piglit-framework-gl/piglit_wgl_framework.h | 29 ++++++++
.../piglit-framework-gl/piglit_winsys_framework.c | 7 ++
7 files changed, 155 insertions(+), 5 deletions(-)
create mode 100644 tests/util/piglit-framework-gl/piglit_wgl_framework.c
create mode 100644 tests/util/piglit-framework-gl/piglit_wgl_framework.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5807f63..39fd0d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,6 +123,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
pkg_check_modules(LIBDRM_INTEL QUIET libdrm_intel)
pkg_check_modules(XCB_DRI2 QUIET xcb-dri2)
pkg_check_modules(GLPROTO QUIET glproto)
+ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+ if (PIGLIT_USE_WAFFLE)
+ set(PIGLIT_HAS_WGL True)
+ add_definitions(-DPIGLIT_HAS_WGL)
+ endif()
ENDIF()
IF(PIGLIT_HAS_GLX)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index a9f5f07..10c5dbc 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -55,6 +55,11 @@ if(PIGLIT_USE_WAFFLE)
piglit-util-waffle.c
)
+ if(PIGLIT_HAS_WGL)
+ list(APPEND UTIL_GL_SOURCES
+ piglit-framework-gl/piglit_wgl_framework.c
+ )
+ endif()
if(PIGLIT_HAS_GBM)
list(APPEND UTIL_GL_SOURCES
piglit-framework-gl/piglit_gbm_framework.c
diff --git a/tests/util/piglit-dispatch.c b/tests/util/piglit-dispatch.c
index 4c5c956..602ddf1 100644
--- a/tests/util/piglit-dispatch.c
+++ b/tests/util/piglit-dispatch.c
@@ -27,6 +27,7 @@
#include <waffle.h>
#include "piglit-util-waffle.h"
#include "piglit-framework-gl.h"
+#include "piglit-framework-gl/piglit_wfl_framework.h"
#endif
/* Global state maintained by the Piglit dispatch mechanism: */
@@ -96,10 +97,14 @@ static enum waffle_enum piglit_waffle_dl = WAFFLE_DL_OPENGL;
static piglit_dispatch_function_ptr
get_wfl_core_proc(const char *name, int gl_10x_version)
{
- piglit_dispatch_function_ptr func;
+ piglit_dispatch_function_ptr func = NULL;
+ struct piglit_wfl_framework* wfl_fw;
- func = (piglit_dispatch_function_ptr)waffle_dl_sym(piglit_waffle_dl,
- name);
+ wfl_fw = piglit_wfl_framework(gl_fw);
+ if (wfl_fw && wfl_fw->display) {
+ func =
(piglit_dispatch_function_ptr)waffle_dl_sym(wfl_fw->display,
+
piglit_waffle_dl, name);
+ }
if (!func)
wfl_log_error(__FUNCTION__);
@@ -113,9 +118,13 @@ get_wfl_core_proc(const char *name, int gl_10x_version)
static piglit_dispatch_function_ptr
get_wfl_ext_proc(const char *name)
{
- piglit_dispatch_function_ptr func;
+ piglit_dispatch_function_ptr func = NULL;
+ struct piglit_wfl_framework* wfl_fw;
- func = (piglit_dispatch_function_ptr)waffle_get_proc_address(name);
+ wfl_fw = piglit_wfl_framework(gl_fw);
+ if (wfl_fw && wfl_fw->display) {
+ func =
(piglit_dispatch_function_ptr)waffle_get_proc_address(wfl_fw->display, name);
+ }
if (!func)
wfl_log_error(__FUNCTION__);
diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index 2fb2f61..143a204 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -109,6 +109,16 @@ piglit_wfl_framework_choose_platform(const struct
piglit_gl_test_config *test_co
#endif
}
+ else if (strcmp(env, "wgl") == 0) {
+#ifdef PIGLIT_HAS_WGL
+ return WAFFLE_PLATFORM_WGL;
+#else
+ fprintf(stderr, "environment var PIGLIT_PLATFORM=wgl, "
+ "but piglit was built without WGL support\n");
+ piglit_report_result(PIGLIT_FAIL);
+#endif
+ }
+
else {
fprintf(stderr, "environment var PIGLIT_PLATFORM has bad "
"value \"%s\"\n", env);
diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.c
b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
new file mode 100644
index 0000000..cb820e8
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2014 Emil Velikov
+ *
+ * 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.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#include "piglit-util-gl.h"
+#include "piglit_wl_framework.h"
+
+static void
+enter_event_loop(struct piglit_winsys_framework *winsys_fw)
+{
+
+ /* FINISHME: Write event loop for Windows.
+ *
+ * Until we have proper Windows/WGL support, give the user enough
+ * time to view the window by sleeping.
+ */
+ Sleep(8000);
+}
+
+static void
+show_window(struct piglit_winsys_framework *winsys_fw)
+{
+ waffle_window_show(winsys_fw->wfl_fw.window);
+}
+
+static void
+destroy(struct piglit_gl_framework *gl_fw)
+{
+ struct piglit_winsys_framework *winsys_fw=
piglit_winsys_framework(gl_fw);
+
+ if (winsys_fw == NULL)
+ return;
+
+ piglit_winsys_framework_teardown(winsys_fw);
+ free(winsys_fw);
+}
+
+struct piglit_gl_framework*
+piglit_wgl_framework_create(const struct piglit_gl_test_config *test_config)
+{
+ struct piglit_winsys_framework *winsys_fw = NULL;
+ struct piglit_gl_framework *gl_fw = NULL;
+ bool ok = true;
+
+ winsys_fw = calloc(1, sizeof(*winsys_fw));
+ gl_fw = &winsys_fw->wfl_fw.gl_fw;
+
+ ok = piglit_winsys_framework_init(winsys_fw, test_config,
+ WAFFLE_PLATFORM_WGL);
+ if (!ok)
+ goto fail;
Minor nit: removing the goto and simply writing:
if (!ok) {
destroy(gl_fw);
return NULL;
}
is actually less/simpler code.
+
+ winsys_fw->show_window = show_window;
+ winsys_fw->enter_event_loop = enter_event_loop;
+ gl_fw->destroy = destroy;
+
+ return gl_fw;
+
+fail:
+ destroy(gl_fw);
+ return NULL;
+}
diff --git a/tests/util/piglit-framework-gl/piglit_wgl_framework.h
b/tests/util/piglit-framework-gl/piglit_wgl_framework.h
new file mode 100644
index 0000000..4592328
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_wgl_framework.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2014 Emil Velikov
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include "piglit_winsys_framework.h"
+
+struct piglit_gl_framework*
+piglit_wgl_framework_create(const struct piglit_gl_test_config *test_config);
diff --git a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
index 6dc92f4..5d7dae1 100644
--- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
@@ -29,6 +29,7 @@
#include "piglit_gbm_framework.h"
#include "piglit_gl_framework.h"
+#include "piglit_wgl_framework.h"
#include "piglit_winsys_framework.h"
#include "piglit_wl_framework.h"
#include "piglit_x11_framework.h"
@@ -174,6 +175,12 @@ piglit_winsys_framework_factory(const struct
piglit_gl_test_config *test_config)
case WAFFLE_PLATFORM_WAYLAND:
return piglit_wl_framework_create(test_config);
#endif
+
+#ifdef PIGLIT_HAS_WGL
+ case WAFFLE_PLATFORM_WGL:
+ return piglit_wgl_framework_create(test_config);
+#endif
+
default:
assert(0);
return NULL;
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit