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