mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-06 02:09:55 +03:00
dEQP support: use OSWindow instead of tcuWin32Window
This is to help dEQP support become cross platform. BUG=angleproject:892 Change-Id: I4480b64a33b1725fb42769bf7dddef1b4ee27c83 Reviewed-on: https://chromium-review.googlesource.com/273594 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
@@ -772,6 +772,7 @@
|
||||
'angle_deqp_decpp',
|
||||
'angle_libpng',
|
||||
'<(angle_path)/src/angle.gyp:libEGL',
|
||||
'<(angle_path)/util/util.gyp:angle_util',
|
||||
],
|
||||
'include_dirs':
|
||||
[
|
||||
@@ -967,8 +968,6 @@
|
||||
'<(deqp_dir)/framework/platform/null/tcuNullContextFactory.hpp',
|
||||
'<(deqp_dir)/framework/platform/null/tcuNullRenderContext.cpp',
|
||||
'<(deqp_dir)/framework/platform/tcuMain.cpp',
|
||||
# TODO(jmadill): other platforms
|
||||
'<(deqp_dir)/framework/platform/win32/tcuWin32Window.cpp',
|
||||
'<(deqp_dir)/framework/qphelper/qpCrashHandler.c',
|
||||
'<(deqp_dir)/framework/qphelper/qpDebugOut.c',
|
||||
'<(deqp_dir)/framework/qphelper/qpInfo.c',
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
|
||||
#include "tcuANGLEWin32NativeDisplayFactory.h"
|
||||
|
||||
#include "egluDefs.hpp"
|
||||
#include "tcuWin32Window.hpp"
|
||||
#include "tcuWin32API.h"
|
||||
#include "tcuTexture.hpp"
|
||||
#include "deMemory.h"
|
||||
#include "deThread.h"
|
||||
#include "deClock.h"
|
||||
#include "eglwLibrary.hpp"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include "deClock.h"
|
||||
#include "deMemory.h"
|
||||
#include "deThread.h"
|
||||
#include "egluDefs.hpp"
|
||||
#include "eglwLibrary.hpp"
|
||||
#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));
|
||||
@@ -102,22 +102,22 @@ class NativePixmap : public eglu::NativePixmap
|
||||
class NativeWindowFactory : public eglu::NativeWindowFactory
|
||||
{
|
||||
public:
|
||||
NativeWindowFactory(HINSTANCE instance);
|
||||
NativeWindowFactory(EventState *eventState);
|
||||
~NativeWindowFactory() override {}
|
||||
|
||||
eglu::NativeWindow *createWindow(eglu::NativeDisplay *nativeDisplay, const eglu::WindowParams ¶ms) const override;
|
||||
|
||||
private:
|
||||
const HINSTANCE mInstance;
|
||||
EventState *mEvents;
|
||||
};
|
||||
|
||||
class NativeWindow : public eglu::NativeWindow
|
||||
{
|
||||
public:
|
||||
NativeWindow(ANGLENativeDisplay *nativeDisplay, HINSTANCE instance, const eglu::WindowParams ¶ms);
|
||||
NativeWindow(ANGLENativeDisplay *nativeDisplay, const eglu::WindowParams ¶ms, EventState *eventState);
|
||||
~NativeWindow() override;
|
||||
|
||||
eglw::EGLNativeWindowType getLegacyNative() override { return mWindow.getHandle(); }
|
||||
eglw::EGLNativeWindowType getLegacyNative() override { return mWindow->getNativeWindow(); }
|
||||
IVec2 getSurfaceSize() const override;
|
||||
IVec2 getScreenSize() const override { return getSurfaceSize(); }
|
||||
void processEvents() override;
|
||||
@@ -126,9 +126,10 @@ class NativeWindow : public eglu::NativeWindow
|
||||
void readScreenPixels(tcu::TextureLevel* dst) const override;
|
||||
|
||||
private:
|
||||
Win32Window mWindow;
|
||||
OSWindow *mWindow;
|
||||
eglu::WindowParams::Visibility mCurVisibility;
|
||||
deUint64 mSetVisibleTime; //!< Time window was set visible.
|
||||
EventState *mEvents;
|
||||
};
|
||||
|
||||
// ANGLE NativeDisplay
|
||||
@@ -216,27 +217,31 @@ eglu::NativePixmap *NativePixmapFactory::createPixmap(eglu::NativeDisplay* nativ
|
||||
|
||||
// NativeWindowFactory
|
||||
|
||||
NativeWindowFactory::NativeWindowFactory(HINSTANCE instance)
|
||||
NativeWindowFactory::NativeWindowFactory(EventState *eventState)
|
||||
: eglu::NativeWindowFactory("window", "ANGLE Window", WINDOW_CAPABILITIES),
|
||||
mInstance(instance)
|
||||
mEvents(eventState)
|
||||
{
|
||||
}
|
||||
|
||||
eglu::NativeWindow *NativeWindowFactory::createWindow (eglu::NativeDisplay* nativeDisplay, const eglu::WindowParams& params) const
|
||||
eglu::NativeWindow *NativeWindowFactory::createWindow(eglu::NativeDisplay* nativeDisplay, const eglu::WindowParams& params) const
|
||||
{
|
||||
return new NativeWindow(dynamic_cast<ANGLENativeDisplay*>(nativeDisplay), mInstance, params);
|
||||
return new NativeWindow(dynamic_cast<ANGLENativeDisplay*>(nativeDisplay), params, mEvents);
|
||||
}
|
||||
|
||||
// NativeWindow
|
||||
|
||||
NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay, HINSTANCE instance, const eglu::WindowParams& params)
|
||||
NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay, const eglu::WindowParams& params, EventState *eventState)
|
||||
: eglu::NativeWindow(WINDOW_CAPABILITIES),
|
||||
mWindow(instance,
|
||||
params.width == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_WIDTH : params.width,
|
||||
params.height == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_HEIGHT : params.height),
|
||||
mWindow(CreateOSWindow()),
|
||||
mCurVisibility(eglu::WindowParams::VISIBILITY_HIDDEN),
|
||||
mSetVisibleTime(0)
|
||||
mSetVisibleTime(0),
|
||||
mEvents(eventState)
|
||||
{
|
||||
bool initialized = mWindow->initialize("dEQP ANGLE Tests",
|
||||
params.width == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_WIDTH : params.width,
|
||||
params.height == eglu::WindowParams::SIZE_DONT_CARE ? DEFAULT_SURFACE_HEIGHT : params.height);
|
||||
TCU_CHECK(initialized);
|
||||
|
||||
if (params.visibility != eglu::WindowParams::VISIBILITY_DONT_CARE)
|
||||
setVisibility(params.visibility);
|
||||
}
|
||||
@@ -246,14 +251,14 @@ void NativeWindow::setVisibility(eglu::WindowParams::Visibility visibility)
|
||||
switch (visibility)
|
||||
{
|
||||
case eglu::WindowParams::VISIBILITY_HIDDEN:
|
||||
mWindow.setVisible(false);
|
||||
mWindow->setVisible(false);
|
||||
mCurVisibility = visibility;
|
||||
break;
|
||||
|
||||
case eglu::WindowParams::VISIBILITY_VISIBLE:
|
||||
case eglu::WindowParams::VISIBILITY_FULLSCREEN:
|
||||
// \todo [2014-03-12 pyry] Implement FULLSCREEN, or at least SW_MAXIMIZE.
|
||||
mWindow.setVisible(true);
|
||||
mWindow->setVisible(true);
|
||||
mCurVisibility = eglu::WindowParams::VISIBILITY_VISIBLE;
|
||||
mSetVisibleTime = deGetMicroseconds();
|
||||
break;
|
||||
@@ -265,21 +270,32 @@ void NativeWindow::setVisibility(eglu::WindowParams::Visibility visibility)
|
||||
|
||||
NativeWindow::~NativeWindow()
|
||||
{
|
||||
delete mWindow;
|
||||
}
|
||||
|
||||
IVec2 NativeWindow::getSurfaceSize() const
|
||||
{
|
||||
return mWindow.getSize();
|
||||
return IVec2(mWindow->getWidth(), mWindow->getHeight());
|
||||
}
|
||||
|
||||
void NativeWindow::processEvents()
|
||||
{
|
||||
mWindow.processEvents();
|
||||
mWindow->messageLoop();
|
||||
|
||||
// Look for a quit event to forward to the EventState
|
||||
Event event;
|
||||
while (mWindow->popEvent(&event))
|
||||
{
|
||||
if (event.Type == Event::EVENT_CLOSED)
|
||||
{
|
||||
mEvents->signalQuitEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::setSurfaceSize(IVec2 size)
|
||||
{
|
||||
mWindow.setSize(size.x(), size.y());
|
||||
mWindow->resize(size.x(), size.y());
|
||||
}
|
||||
|
||||
void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
@@ -301,7 +317,7 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
deSleep(WAIT_WINDOW_VISIBLE_MS - (deUint32)(timeSinceVisibleUs/1000));
|
||||
}
|
||||
|
||||
TCU_CHECK(GetClientRect(mWindow.getHandle(), &rect));
|
||||
TCU_CHECK(GetClientRect(mWindow->getNativeWindow(), &rect));
|
||||
|
||||
try
|
||||
{
|
||||
@@ -314,13 +330,13 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
screenDC = GetDC(DE_NULL);
|
||||
TCU_CHECK(screenDC);
|
||||
|
||||
windowDC = GetDC(mWindow.getHandle());
|
||||
windowDC = GetDC(mWindow->getNativeWindow());
|
||||
TCU_CHECK(windowDC);
|
||||
|
||||
tmpDC = CreateCompatibleDC(screenDC);
|
||||
TCU_CHECK(tmpDC != DE_NULL);
|
||||
|
||||
MapWindowPoints(mWindow.getHandle(), DE_NULL, (LPPOINT)&rect, 2);
|
||||
MapWindowPoints(mWindow->getNativeWindow() , DE_NULL, (LPPOINT)&rect, 2);
|
||||
|
||||
tmpBitmap = CreateCompatibleBitmap(screenDC, width, height);
|
||||
TCU_CHECK(tmpBitmap != DE_NULL);
|
||||
@@ -352,7 +368,7 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
ReleaseDC(DE_NULL, screenDC);
|
||||
screenDC = DE_NULL;
|
||||
|
||||
ReleaseDC(mWindow.getHandle(), windowDC);
|
||||
ReleaseDC(mWindow->getNativeWindow(), windowDC);
|
||||
windowDC = DE_NULL;
|
||||
|
||||
DeleteDC(tmpDC);
|
||||
@@ -364,7 +380,7 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
ReleaseDC(DE_NULL, screenDC);
|
||||
|
||||
if (windowDC)
|
||||
ReleaseDC(mWindow.getHandle(), windowDC);
|
||||
ReleaseDC(mWindow->getNativeWindow(), windowDC);
|
||||
|
||||
if (tmpBitmap)
|
||||
DeleteObject(tmpBitmap);
|
||||
@@ -381,12 +397,11 @@ void NativeWindow::readScreenPixels(tcu::TextureLevel *dst) const
|
||||
ANGLEWin32NativeDisplayFactory::ANGLEWin32NativeDisplayFactory(const std::string &name,
|
||||
const std::string &description,
|
||||
const std::vector<eglw::EGLAttrib> &platformAttributes,
|
||||
HINSTANCE instance)
|
||||
EventState *eventState)
|
||||
: eglu::NativeDisplayFactory(name, description, DISPLAY_CAPABILITIES, EGL_PLATFORM_ANGLE_ANGLE, "EGL_EXT_platform_base"),
|
||||
mPlatformAttributes(platformAttributes),
|
||||
mInstance(instance)
|
||||
mPlatformAttributes(platformAttributes)
|
||||
{
|
||||
m_nativeWindowRegistry.registerFactory(new NativeWindowFactory(mInstance));
|
||||
m_nativeWindowRegistry.registerFactory(new NativeWindowFactory(eventState));
|
||||
m_nativePixmapRegistry.registerFactory(new NativePixmapFactory());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,25 +24,37 @@
|
||||
#include "tcuDefs.hpp"
|
||||
#include "egluNativeDisplay.hpp"
|
||||
#include "eglwDefs.hpp"
|
||||
#include "tcuWin32API.h"
|
||||
|
||||
namespace tcu
|
||||
{
|
||||
|
||||
class EventState
|
||||
{
|
||||
public:
|
||||
EventState::EventState()
|
||||
: mQuit(false)
|
||||
{
|
||||
}
|
||||
bool quitSignaled() const { return mQuit; };
|
||||
void signalQuitEvent() { mQuit = true; };
|
||||
|
||||
private:
|
||||
bool mQuit;
|
||||
};
|
||||
|
||||
class ANGLEWin32NativeDisplayFactory : public eglu::NativeDisplayFactory
|
||||
{
|
||||
public:
|
||||
ANGLEWin32NativeDisplayFactory(const std::string &name,
|
||||
const std::string &description,
|
||||
const std::vector<eglw::EGLAttrib> &platformAttributes,
|
||||
HINSTANCE instance);
|
||||
EventState *eventState);
|
||||
~ANGLEWin32NativeDisplayFactory() override;
|
||||
|
||||
eglu::NativeDisplay *createDisplay(const eglw::EGLAttrib* attribList) const override;
|
||||
|
||||
private:
|
||||
std::vector<eglw::EGLAttrib> mPlatformAttributes;
|
||||
const HINSTANCE mInstance;
|
||||
};
|
||||
|
||||
} // tcu
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace tcu
|
||||
{
|
||||
|
||||
ANGLEWin32Platform::ANGLEWin32Platform()
|
||||
: mInstance(GetModuleHandle(nullptr))
|
||||
{
|
||||
// Set process priority to lower.
|
||||
// TODO(cwallez): add this to utils
|
||||
SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
|
||||
|
||||
#if defined(ANGLE_DEQP_GLES2_TESTS) || defined(ANGLE_DEQP_GLES3_TESTS)
|
||||
@@ -43,10 +43,9 @@ ANGLEWin32Platform::ANGLEWin32Platform()
|
||||
d3d11Attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_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(
|
||||
"angle-d3d11", "ANGLE D3D11 Display", d3d11Attribs, mInstance);
|
||||
"angle-d3d11", "ANGLE D3D11 Display", d3d11Attribs, &mEvents);
|
||||
m_nativeDisplayFactoryRegistry.registerFactory(d3d11Factory);
|
||||
#endif
|
||||
|
||||
@@ -57,10 +56,9 @@ ANGLEWin32Platform::ANGLEWin32Platform()
|
||||
d3d9Attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_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(
|
||||
"angle-d3d9", "ANGLE D3D9 Display", d3d9Attribs, mInstance);
|
||||
"angle-d3d9", "ANGLE D3D9 Display", d3d9Attribs, &mEvents);
|
||||
m_nativeDisplayFactoryRegistry.registerFactory(d3d9Factory);
|
||||
|
||||
std::vector<eglw::EGLAttrib> d3d1193Attribs;
|
||||
@@ -73,22 +71,18 @@ ANGLEWin32Platform::ANGLEWin32Platform()
|
||||
d3d1193Attribs.push_back(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE);
|
||||
d3d1193Attribs.push_back(3);
|
||||
d3d1193Attribs.push_back(EGL_NONE);
|
||||
d3d1193Attribs.push_back(EGL_NONE);
|
||||
|
||||
auto *d3d1193Factory = new ANGLEWin32NativeDisplayFactory(
|
||||
"angle-d3d11-fl93", "ANGLE D3D11 FL9_3 Display", d3d1193Attribs, mInstance);
|
||||
"angle-d3d11-fl93", "ANGLE D3D11 FL9_3 Display", d3d1193Attribs, &mEvents);
|
||||
m_nativeDisplayFactoryRegistry.registerFactory(d3d1193Factory);
|
||||
|
||||
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_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
|
||||
glAttribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE);
|
||||
glAttribs.push_back(EGL_NONE);
|
||||
glAttribs.push_back(EGL_NONE);
|
||||
|
||||
auto *glFactory = new ANGLEWin32NativeDisplayFactory(
|
||||
"angle-gl", "ANGLE OpenGL Display", glAttribs, mInstance);
|
||||
"angle-gl", "ANGLE OpenGL Display", glAttribs, &mEvents);
|
||||
m_nativeDisplayFactoryRegistry.registerFactory(glFactory);
|
||||
#endif
|
||||
|
||||
@@ -104,14 +98,7 @@ ANGLEWin32Platform::~ANGLEWin32Platform()
|
||||
|
||||
bool ANGLEWin32Platform::processEvents()
|
||||
{
|
||||
MSG msg;
|
||||
while (PeekMessage(&msg, reinterpret_cast<HWND>(-1), 0, 0, PM_REMOVE))
|
||||
{
|
||||
DispatchMessage(&msg);
|
||||
if (msg.message == WM_QUIT)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !mEvents.quitSignaled();
|
||||
}
|
||||
|
||||
} // tcu
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
# include "egluPlatform.hpp"
|
||||
#endif
|
||||
|
||||
#include "tcuANGLEWin32NativeDisplayFactory.h"
|
||||
|
||||
namespace tcu
|
||||
{
|
||||
|
||||
@@ -47,7 +49,7 @@ class ANGLEWin32Platform : public tcu::Platform,
|
||||
const eglu::Platform &getEGLPlatform() const override { return static_cast<const eglu::Platform&>(*this); }
|
||||
|
||||
private:
|
||||
HINSTANCE mInstance;
|
||||
EventState mEvents;
|
||||
};
|
||||
|
||||
} // tcu
|
||||
|
||||
Reference in New Issue
Block a user