[Piglit] [PATCH 3/4] utils: add initial WAFFLE_WGL support

Jose Fonseca jfonseca at vmware.com
Sun Nov 23 01:38:56 PST 2014


On 21/11/14 19:52, Emil Velikov wrote:
> This will allow us to use waffle with its upcoming WGL support for
> 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.
>
> Waffle 1.5.0 is the first version that has WGL support.
>
> TODO:
>   - Bump the WAFFLE_API_VERSION ?
>   - Add input handling (event_loop).
>
> v2: Updated the instructions in the README.
> v3: Update against upstream Waffle (no API breakage)
>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> Reviewed-by: Brian Paul <brianp at vmware.com> (v1)
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>   CMakeLists.txt                                     |  7 +-
>   README                                             | 38 +++++++++-
>   tests/util/CMakeLists.txt                          |  5 ++
>   .../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, 177 insertions(+), 4 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 2f15971..6ba6df8 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -61,7 +61,7 @@ if(PIGLIT_USE_WAFFLE)
>   	# validates the required version at most once for the lifetime of the
>   	# source tree.  If someone changes the required version by editing the
>   	# CMakeLists, CMake fails to detect the new requirement.
> -	set(WAFFLE_REQUIRED_VERSION "1.3.0")
> +	set(WAFFLE_REQUIRED_VERSION "1.5.0")
>   	if(WAFFLE_VERSION VERSION_LESS WAFFLE_REQUIRED_VERSION)
>   		message(FATAL_ERROR "Found waffle-${WAFFLE_VERSION}, but "
>   		"piglit requires waffle-${WAFFLE_REQUIRED_VERSION}")
> @@ -128,6 +128,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/README b/README
> index 2917c3a..b894db7 100644
> --- a/README
> +++ b/README
> @@ -144,15 +144,19 @@ https://urldefense.proofpoint.com/v2/url?u=http-3A__www.opengl.org_registry_-23headers&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=3y85V6KdzlUHBt1KxdRI-P2NLS8glOYeinRQNq35c1s&s=ztTJS8Z32Jv57TIumkRCus2v_4cNcDra_Gk5GlmuZhA&e=
>   Copy header files to MSVC.
>   C:\Program Files\Microsoft Visual Studio 12.0\VC\include\GL
>
> -Download freeglut for MSVC.
> -https://urldefense.proofpoint.com/v2/url?u=http-3A__www.transmissionzero.co.uk_software_freeglut-2Ddevel&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=3y85V6KdzlUHBt1KxdRI-P2NLS8glOYeinRQNq35c1s&s=A4AC8xGOMJ4ZhSiOcb18hPF0ZVy8SCAXRzi86STeUtA&e=
> -
>   Install pip.
>   https://urldefense.proofpoint.com/v2/url?u=http-3A__www.pip-2Dinstaller.org_en_latest_installing.html&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=3y85V6KdzlUHBt1KxdRI-P2NLS8glOYeinRQNq35c1s&s=7hqsC23O2s9hrGnnwa5ChUmBMCJZ0zWc-vx_tPIJv2Q&e=
>
>   Install python mako.
>     > c:\Python27\Scripts\pip.exe install mako
>
> +
> +2.5.1 GLUT
> +----------
> +
> +Download freeglut for MSVC.
> +https://urldefense.proofpoint.com/v2/url?u=http-3A__www.transmissionzero.co.uk_software_freeglut-2Ddevel&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=3y85V6KdzlUHBt1KxdRI-P2NLS8glOYeinRQNq35c1s&s=A4AC8xGOMJ4ZhSiOcb18hPF0ZVy8SCAXRzi86STeUtA&e=
> +
>   Open Visual Studio Command Prompt.
>   Start Menu->All Programs->Visual Studio 2013->Visual Studio Tools->VS2013 x86 Native Tools Command Prompt
>   CD to piglit directory.
> @@ -172,6 +176,34 @@ File->Exit
>   Build from the Visual Studio Command Prompt.
>     > nmake
>
> +2.5.2 Waffle
> +------------
> +
> +Download waffle for MSVC.
> +https://urldefense.proofpoint.com/v2/url?u=http-3A__www.waffle-2Dgl.org_&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=3y85V6KdzlUHBt1KxdRI-P2NLS8glOYeinRQNq35c1s&s=KCnp0UDkw4lFD0D4fP1ue17xjDreOWGL3XeUR-VxWqY&e=
> +
> +Open the Command Prompt.
> +CD to piglit directory.
> +
> +Run CMake GUI.
> +  > C:\Program Files\CMake 2.8\bin\cmake-gui.exe .
> +Configure
> +  - 'Visual Studio 12 2013', or
> +  - 'Visual Studio 12 2013 Win64'
> +  - Use default native compilers
> +Set these variables in the Advanced view.
> +Note that the values provided are for reference purposed and may differ on your system.
> +  - PIGLIT_USE_WAFFLE, BOOL, TRUE
> +  - WAFFLE_VERSION, STRING, "1.5.0"
> +  - WAFFLE_INCLUDE_DIRS, PATH, ${waffle_root}\include\waffle
> +  - WAFFLE_LDFLAGS, FILEPATH, ${waffle_root}\lib\waffle-1.lib
> +  - GLEXT_INCLUDE_DIR, PATH, C:\Program Files\Microsoft Visual Studio 12.0\VC\include\GL
> +Configure
> +Generate
> +File->Exit
> +
> +Build from the Command Prompt.
> +  > cmake --build .
>
>   3. How to run tests
>   -------------------
> diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
> index 98eedd0..edc8469 100644
> --- a/tests/util/CMakeLists.txt
> +++ b/tests/util/CMakeLists.txt
> @@ -64,6 +64,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-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
> index c762b00..75fbacf 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);

Instead of Sleep for 8 secs, you could do

   fprintf(stderr, "Press any key when done.\n");
   getchar().

It would be more practical, and self-documenting.

Either way, series is

   Reviewed-by: Jose Fonseca <jfonseca at vmware.com>


Jose


> +}
> +
> +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;
> +
> +	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 4c50f0c..d9a40eb 100644
> --- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
> +++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
> @@ -31,6 +31,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"
> @@ -177,6 +178,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;
>



More information about the Piglit mailing list