Commit 18caea37 authored by Emil Velikov's avatar Emil Velikov

utils: add initial WAFFLE_WGL support

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:
 - Add input handling (event_loop).

v2: Updated the instructions in the README.
v3: Update against upstream Waffle (no API breakage)
v4: s/Sleep/fprintf()+getchar()/ in the event_loop. Suggested by Jose.
Signed-off-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com> (v1)
parent 490b2baa
......@@ -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)
......
......@@ -144,15 +144,19 @@ http://www.opengl.org/registry/#headers
Copy header files to MSVC.
C:\Program Files\Microsoft Visual Studio 12.0\VC\include\GL
Download freeglut for MSVC.
http://www.transmissionzero.co.uk/software/freeglut-devel
Install pip.
http://www.pip-installer.org/en/latest/installing.html
Install python mako.
> c:\Python27\Scripts\pip.exe install mako
2.5.1 GLUT
----------
Download freeglut for MSVC.
http://www.transmissionzero.co.uk/software/freeglut-devel
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.
http://www.waffle-gl.org/
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
-------------------
......
......@@ -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
......
......@@ -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);
......
/*
* 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.
*/
fprintf(stderr, "Press any key when done.\n");
getchar();
}
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;
}
/*
* 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);
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment