Commit a55e4b7a by Corentin Wallez

Enable compilation of dEQP tests on Linux

BUG=angleproject:1051 Change-Id: I158e59ca581b580825848e831d05064cdcc30d96 Reviewed-on: https://chromium-review.googlesource.com/276202Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent d3e7aa33
......@@ -330,6 +330,9 @@
'cflags':
[
'-fPIC',
],
'cflags_cc':
[
'-std=c++0x',
],
},
......
......@@ -22,10 +22,12 @@
#if (DE_OS == DE_OS_WIN32)
#include <Windows.h>
#elif (DE_OS == DE_OS_UNIX)
#include <sys/unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
// Located in tcuMain.cc in dEQP's sources.
int main(int argc, const char* argv[]);
tcu::Platform *createPlatform();
namespace
......@@ -57,14 +59,15 @@ deBool deIsDir(const char *filename)
return (attribs != INVALID_FILE_ATTRIBUTES) &&
((attribs & FILE_ATTRIBUTE_DIRECTORY) > 0);
}
#elif (DE_OS == DE_OS_UNIX)
deBool deIsDir(const char *filename)
{
struct stat st;
int result = stat(filename, &st);
return result == 0 && ((st.st_mode & S_IFDIR) == S_IFDIR);
}
#else
#error TODO(jmadill): support other platforms
//deBool deIsDir(const char *filename)
//{
// struct stat st;
// int result = stat(filename, &st);
// return result == 0 && ((st.st_mode & S_IFDIR) == S_IFDIR);
//}
#endif
const char *FindDataDir()
......@@ -127,7 +130,27 @@ bool InitPlatform()
// Exported to the tester app.
ANGLE_LIBTESTER_EXPORT int deqp_libtester_main(int argc, const char *argv[])
{
return main(argc, argv);
InitPlatform();
try
{
de::UniquePtr<tcu::App> app(new tcu::App(*g_platform, *g_archive, *g_log, *g_cmdLine));
// Main loop.
for (;;)
{
if (!app->iterate())
break;
}
}
catch (const std::exception &e)
{
deqp_libtester_shutdown_platform();
tcu::die("%s", e.what());
}
deqp_libtester_shutdown_platform();
return 0;
}
ANGLE_LIBTESTER_EXPORT void deqp_libtester_shutdown_platform()
......
......@@ -6,18 +6,24 @@
// angle_deqp_tests_main.cpp: Entry point for ANGLE's dEQP tests.
#include <direct.h>
#include <stdio.h>
#include <cstdio>
#include "angle_deqp_libtester.h"
#ifdef _WIN32
#include <direct.h>
#define chdir _chdir
#else
#include <unistd.h>
#endif
int main(int argc, const char *argv[])
{
const char * data_dir = ANGLE_DEQP_DIR "/data";
if (_chdir(data_dir) != 0)
if (chdir(data_dir) != 0)
{
printf("Error setting working directory\n");
printf("Error setting working directory to %s\n", data_dir);
}
deqp_libtester_main(argc, argv);
return deqp_libtester_main(argc, argv);
}
......@@ -18,7 +18,7 @@
*
*/
#include "tcuANGLEWin32NativeDisplayFactory.h"
#include "tcuANGLENativeDisplayFactory.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
......@@ -31,12 +31,14 @@
#include "OSPixmap.h"
#include "OSWindow.h"
#include "tcuTexture.hpp"
#include "tcuWin32API.h"
// Assume no call translation is needed
DE_STATIC_ASSERT(sizeof(eglw::EGLNativeDisplayType) == sizeof(HDC));
DE_STATIC_ASSERT(sizeof(eglw::EGLNativePixmapType) == sizeof(HBITMAP));
DE_STATIC_ASSERT(sizeof(eglw::EGLNativeWindowType) == sizeof(HWND));
#if (DE_OS == DE_OS_WIN32)
#define ANGLE_EGL_LIBRARY_NAME "libEGL.dll"
#elif (DE_OS == DE_OS_UNIX)
#define ANGLE_EGL_LIBRARY_NAME "libEGL.so"
#else
#error "Unsupported platform"
#endif
namespace tcu
{
......@@ -70,10 +72,10 @@ class ANGLENativeDisplay : public eglu::NativeDisplay
const eglw::EGLAttrib *getPlatformAttributes() const override { return &mPlatformAttributes[0]; }
const eglw::Library &getLibrary() const override { return mLibrary; }
HDC getDeviceContext() { return mDeviceContext; }
EGLNativeDisplayType getDeviceContext() { return mDeviceContext; }
private:
HDC mDeviceContext;
EGLNativeDisplayType mDeviceContext;
eglw::DefaultLibrary mLibrary;
std::vector<eglw::EGLAttrib> mPlatformAttributes;
};
......@@ -118,7 +120,7 @@ class NativeWindow : public eglu::NativeWindow
NativeWindow(ANGLENativeDisplay *nativeDisplay, const eglu::WindowParams &params, EventState *eventState);
~NativeWindow() override;
eglw::EGLNativeWindowType getLegacyNative() override { return mWindow->getNativeWindow(); }
eglw::EGLNativeWindowType getLegacyNative() override;
IVec2 getSurfaceSize() const override;
IVec2 getScreenSize() const override { return getSurfaceSize(); }
void processEvents() override;
......@@ -135,8 +137,8 @@ class NativeWindow : public eglu::NativeWindow
ANGLENativeDisplay::ANGLENativeDisplay(const std::vector<EGLAttrib> &attribs)
: eglu::NativeDisplay(DISPLAY_CAPABILITIES, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
mDeviceContext(static_cast<HDC>(EGL_DEFAULT_DISPLAY)),
mLibrary("libEGL.dll"),
mDeviceContext(EGL_DEFAULT_DISPLAY),
mLibrary(ANGLE_EGL_LIBRARY_NAME),
mPlatformAttributes(attribs)
{
}
......@@ -165,7 +167,7 @@ NativePixmap::~NativePixmap()
eglw::EGLNativePixmapType NativePixmap::getLegacyNative()
{
return mPixmap->getNativePixmap();
return reinterpret_cast<eglw::EGLNativePixmapType>(mPixmap->getNativePixmap());
}
// NativePixmapFactory
......@@ -256,6 +258,11 @@ NativeWindow::~NativeWindow()
delete mWindow;
}
eglw::EGLNativeWindowType NativeWindow::getLegacyNative()
{
return reinterpret_cast<eglw::EGLNativeWindowType>(mWindow->getNativeWindow());
}
IVec2 NativeWindow::getSurfaceSize() const
{
return IVec2(mWindow->getWidth(), mWindow->getHeight());
......@@ -291,10 +298,10 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
} // anonymous
ANGLEWin32NativeDisplayFactory::ANGLEWin32NativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
EventState *eventState)
ANGLENativeDisplayFactory::ANGLENativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
EventState *eventState)
: eglu::NativeDisplayFactory(name, description, DISPLAY_CAPABILITIES, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
mPlatformAttributes(platformAttributes)
{
......@@ -302,11 +309,11 @@ ANGLEWin32NativeDisplayFactory::ANGLEWin32NativeDisplayFactory(const std::string
m_nativePixmapRegistry.registerFactory(new NativePixmapFactory());
}
ANGLEWin32NativeDisplayFactory::~ANGLEWin32NativeDisplayFactory()
ANGLENativeDisplayFactory::~ANGLENativeDisplayFactory()
{
}
eglu::NativeDisplay *ANGLEWin32NativeDisplayFactory::createDisplay(const eglw::EGLAttrib *attribList) const
eglu::NativeDisplay *ANGLENativeDisplayFactory::createDisplay(const eglw::EGLAttrib *attribList) const
{
DE_UNREF(attribList);
return new ANGLENativeDisplay(mPlatformAttributes);
......
......@@ -31,7 +31,7 @@ namespace tcu
class EventState
{
public:
EventState::EventState()
EventState()
: mQuit(false)
{
}
......@@ -42,14 +42,14 @@ class EventState
bool mQuit;
};
class ANGLEWin32NativeDisplayFactory : public eglu::NativeDisplayFactory
class ANGLENativeDisplayFactory : public eglu::NativeDisplayFactory
{
public:
ANGLEWin32NativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
EventState *eventState);
~ANGLEWin32NativeDisplayFactory() override;
ANGLENativeDisplayFactory(const std::string &name,
const std::string &description,
const std::vector<eglw::EGLAttrib> &platformAttributes,
EventState *eventState);
~ANGLENativeDisplayFactory() override;
eglu::NativeDisplay *createDisplay(const eglw::EGLAttrib* attribList) const override;
......
......@@ -18,23 +18,24 @@
*
*/
#include "tcuANGLEWin32Platform.h"
#include "tcuANGLEPlatform.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "egluGLContextFactory.hpp"
#include "system_utils.h"
#include "tcuANGLEWin32NativeDisplayFactory.h"
#include "tcuANGLENativeDisplayFactory.h"
#include "tcuNullContextFactory.hpp"
namespace tcu
{
ANGLEWin32Platform::ANGLEWin32Platform()
ANGLEPlatform::ANGLEPlatform()
{
angle::SetLowPriorityProcess();
#if (DE_OS == DE_OS_WIN32)
#if defined(ANGLE_DEQP_GLES2_TESTS) || defined(ANGLE_DEQP_GLES3_TESTS)
std::vector<eglw::EGLAttrib> d3d11Attribs;
d3d11Attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
......@@ -43,10 +44,10 @@ ANGLEWin32Platform::ANGLEWin32Platform()
d3d11Attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
d3d11Attribs.push_back(EGL_NONE);
auto *d3d11Factory = new ANGLEWin32NativeDisplayFactory(
auto *d3d11Factory = new ANGLENativeDisplayFactory(
"angle-d3d11", "ANGLE D3D11 Display", d3d11Attribs, &mEvents);
m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);
#endif
#endif // defined(ANGLE_DEQP_GLES2_TESTS) || defined(ANGLE_DEQP_GLES3_TESTS)
#if defined(ANGLE_DEQP_GLES2_TESTS)
std::vector<eglw::EGLAttrib> d3d9Attribs;
......@@ -56,7 +57,7 @@ ANGLEWin32Platform::ANGLEWin32Platform()
d3d9Attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
d3d9Attribs.push_back(EGL_NONE);
auto *d3d9Factory = new ANGLEWin32NativeDisplayFactory(
auto *d3d9Factory = new ANGLENativeDisplayFactory(
"angle-d3d9", "ANGLE D3D9 Display", d3d9Attribs, &mEvents);
m_nativeDisplayFactoryRegistry.registerFactory(d3d9Factory);
......@@ -71,19 +72,22 @@ ANGLEWin32Platform::ANGLEWin32Platform()
d3d1193Attribs.push_back(3);
d3d1193Attribs.push_back(EGL_NONE);
auto *d3d1193Factory = new ANGLEWin32NativeDisplayFactory(
auto *d3d1193Factory = new ANGLENativeDisplayFactory(
"angle-d3d11-fl93", "ANGLE D3D11 FL9_3 Display", d3d1193Attribs, &mEvents);
m_nativeDisplayFactoryRegistry.registerFactory(d3d1193Factory);
#endif // defined(ANGLE_DEQP_GLES2_TESTS)
#endif // (DE_OS == DE_OS_WIN32)
#if defined(ANGLE_DEQP_GLES2_TESTS)
std::vector<eglw::EGLAttrib> glAttribs;
glAttribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
glAttribs.push_back(EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);
glAttribs.push_back(EGL_NONE);
auto *glFactory = new ANGLEWin32NativeDisplayFactory(
auto *glFactory = new ANGLENativeDisplayFactory(
"angle-gl", "ANGLE OpenGL Display", glAttribs, &mEvents);
m_nativeDisplayFactoryRegistry.registerFactory(glFactory);
#endif
#endif // defined(ANGLE_DEQP_GLES2_TESTS)
m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));
......@@ -91,11 +95,11 @@ ANGLEWin32Platform::ANGLEWin32Platform()
m_contextFactoryRegistry.registerFactory(new null::NullGLContextFactory());
}
ANGLEWin32Platform::~ANGLEWin32Platform()
ANGLEPlatform::~ANGLEPlatform()
{
}
bool ANGLEWin32Platform::processEvents()
bool ANGLEPlatform::processEvents()
{
return !mEvents.quitSignaled();
}
......@@ -105,5 +109,5 @@ bool ANGLEWin32Platform::processEvents()
// Create platform
tcu::Platform *createPlatform()
{
return new tcu::ANGLEWin32Platform();
return new tcu::ANGLEPlatform();
}
......@@ -29,18 +29,18 @@
# include "egluPlatform.hpp"
#endif
#include "tcuANGLEWin32NativeDisplayFactory.h"
#include "tcuANGLENativeDisplayFactory.h"
namespace tcu
{
class ANGLEWin32Platform : public tcu::Platform,
private glu::Platform,
private eglu::Platform
class ANGLEPlatform : public tcu::Platform,
private glu::Platform,
private eglu::Platform
{
public:
ANGLEWin32Platform();
~ANGLEWin32Platform();
ANGLEPlatform();
~ANGLEPlatform();
bool processEvents() override;
......
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