Commit 98de826c by Jamie Madill Committed by Commit Bot

Platform: Fix initialization order in tests.

Because of the platform refactor in abf38572 we broke the way the tests override the D3D workarounds for the tiny depth/stencil bug. This change passes a pointer to the platform directly in the EGL init logic, which solves this issue. It also removes all decltype code in the platform header which might fix the UBSAN problem we were seeing previously. Also change a present mode selection error into a warning in the Vk back-end, since this was being triggered on AMD, but is safe. BUG=angleproject:2042 Change-Id: Ibbd0c69ce11a840cf4b33c616f56020001e553aa Reviewed-on: https://chromium-review.googlesource.com/513519Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 20805650
...@@ -183,6 +183,9 @@ std::string ToString(const T &value) ...@@ -183,6 +183,9 @@ std::string ToString(const T &value)
// Hidden enum for the NULL D3D device type. // Hidden enum for the NULL D3D device type.
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
// TODO(jmadill): Clean this up at some point.
#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x9999
#define ANGLE_TRY_CHECKED_MATH(result) \ #define ANGLE_TRY_CHECKED_MATH(result) \
if (!result.IsValid()) \ if (!result.IsValid()) \
{ \ { \
......
...@@ -254,7 +254,7 @@ void Display_logInfo(angle::PlatformMethods *platform, const char *infoMessage) ...@@ -254,7 +254,7 @@ void Display_logInfo(angle::PlatformMethods *platform, const char *infoMessage)
void ANGLESetDefaultDisplayPlatform(angle::EGLDisplayType display) void ANGLESetDefaultDisplayPlatform(angle::EGLDisplayType display)
{ {
angle::PlatformMethods *platformMethods = ANGLEPlatformCurrent(); angle::PlatformMethods *platformMethods = ANGLEPlatformCurrent();
if (platformMethods->logError != angle::ANGLE_logError) if (platformMethods->logError != angle::DefaultLogError)
{ {
// Don't reset pre-set Platform to Default // Don't reset pre-set Platform to Default
return; return;
...@@ -419,7 +419,17 @@ void Display::setAttributes(rx::DisplayImpl *impl, const AttributeMap &attribMap ...@@ -419,7 +419,17 @@ void Display::setAttributes(rx::DisplayImpl *impl, const AttributeMap &attribMap
Error Display::initialize() Error Display::initialize()
{ {
// TODO(jmadill): Store Platform in Display and init here. // TODO(jmadill): Store Platform in Display and init here.
ANGLESetDefaultDisplayPlatform(this); const angle::PlatformMethods *platformMethods =
reinterpret_cast<const angle::PlatformMethods *>(
mAttributeMap.get(EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX, 0));
if (platformMethods != nullptr)
{
*ANGLEPlatformCurrent() = *platformMethods;
}
else
{
ANGLESetDefaultDisplayPlatform(this);
}
gl::InitializeDebugAnnotations(&mAnnotator); gl::InitializeDebugAnnotations(&mAnnotator);
......
...@@ -47,7 +47,8 @@ VkPresentModeKHR GetDesiredPresentMode(const std::vector<VkPresentModeKHR> &pres ...@@ -47,7 +47,8 @@ VkPresentModeKHR GetDesiredPresentMode(const std::vector<VkPresentModeKHR> &pres
} }
} }
ERR() << "Desired present mode not available. Falling back to " << presentModes[0]; WARN() << "Present mode " << bestChoice << " not available. Falling back to "
<< presentModes[0];
return presentModes[0]; return presentModes[0];
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "ANGLETest.h" #include "ANGLETest.h"
#include "EGLWindow.h" #include "EGLWindow.h"
#include "OSWindow.h" #include "OSWindow.h"
#include "platform/Platform.h"
namespace angle namespace angle
{ {
...@@ -254,6 +253,13 @@ void ANGLETest::SetUp() ...@@ -254,6 +253,13 @@ void ANGLETest::SetUp()
needSwap = true; needSwap = true;
} }
mPlatformMethods.overrideWorkaroundsD3D = angle::TestPlatform_overrideWorkaroundsD3D;
mPlatformMethods.logError = angle::TestPlatform_logError;
mPlatformMethods.logWarning = angle::TestPlatform_logWarning;
mPlatformMethods.logInfo = angle::TestPlatform_logInfo;
mPlatformMethods.context = &mPlatformContext;
mEGLWindow->setPlatformMethods(&mPlatformMethods);
if (!mEGLWindow->initializeDisplayAndSurface(mOSWindow)) if (!mEGLWindow->initializeDisplayAndSurface(mOSWindow))
{ {
FAIL() << "egl display or surface init failed."; FAIL() << "egl display or surface init failed.";
...@@ -264,22 +270,6 @@ void ANGLETest::SetUp() ...@@ -264,22 +270,6 @@ void ANGLETest::SetUp()
FAIL() << "GL Context init failed."; FAIL() << "GL Context init failed.";
} }
if (mGLESLibrary)
{
auto initFunc = reinterpret_cast<angle::GetDisplayPlatformFunc>(
mGLESLibrary->getSymbol("ANGLEGetDisplayPlatform"));
if (initFunc)
{
angle::PlatformMethods *platformMethods = nullptr;
initFunc(mEGLWindow->getDisplay(), angle::g_PlatformMethodNames,
angle::g_NumPlatformMethods, &mPlatformContext, &platformMethods);
platformMethods->overrideWorkaroundsD3D = angle::TestPlatform_overrideWorkaroundsD3D;
platformMethods->logError = angle::TestPlatform_logError;
platformMethods->logWarning = angle::TestPlatform_logWarning;
platformMethods->logInfo = angle::TestPlatform_logInfo;
}
}
if (needSwap) if (needSwap)
{ {
// Swap the buffers so that the default framebuffer picks up the resize // Swap the buffers so that the default framebuffer picks up the resize
...@@ -299,6 +289,8 @@ void ANGLETest::SetUp() ...@@ -299,6 +289,8 @@ void ANGLETest::SetUp()
void ANGLETest::TearDown() void ANGLETest::TearDown()
{ {
mEGLWindow->setPlatformMethods(nullptr);
mPlatformContext.currentTest = nullptr; mPlatformContext.currentTest = nullptr;
checkD3D11SDKLayersMessages(); checkD3D11SDKLayersMessages();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "angle_test_configs.h" #include "angle_test_configs.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/vector_utils.h" #include "common/vector_utils.h"
#include "platform/Platform.h"
#include "shader_utils.h" #include "shader_utils.h"
#include "system_utils.h" #include "system_utils.h"
...@@ -305,6 +306,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -305,6 +306,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
// Used for indexed quad rendering // Used for indexed quad rendering
GLuint mQuadVertexBuffer; GLuint mQuadVertexBuffer;
angle::PlatformMethods mPlatformMethods;
TestPlatformContext mPlatformContext; TestPlatformContext mPlatformContext;
bool mDeferContextInit; bool mDeferContextInit;
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "OSWindow.h" #include "OSWindow.h"
#include "common/debug.h" #include "common/debug.h"
// TODO(jmadill): Clean this up at some point.
#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x9999
EGLPlatformParameters::EGLPlatformParameters() EGLPlatformParameters::EGLPlatformParameters()
: renderer(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE), : renderer(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE),
majorVersion(EGL_DONT_CARE), majorVersion(EGL_DONT_CARE),
...@@ -118,7 +121,8 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion, ...@@ -118,7 +121,8 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion,
mClientArraysEnabled(true), mClientArraysEnabled(true),
mRobustResourceInit(false), mRobustResourceInit(false),
mSwapInterval(-1), mSwapInterval(-1),
mSamples(-1) mSamples(-1),
mPlatformMethods(nullptr)
{ {
} }
...@@ -196,6 +200,13 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow) ...@@ -196,6 +200,13 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow)
displayAttributes.push_back(mVulkanLayersEnabled.value() ? EGL_TRUE : EGL_FALSE); displayAttributes.push_back(mVulkanLayersEnabled.value() ? EGL_TRUE : EGL_FALSE);
} }
if (mPlatformMethods)
{
static_assert(sizeof(EGLAttrib) == sizeof(mPlatformMethods), "Unexpected pointer size");
displayAttributes.push_back(EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX);
displayAttributes.push_back(reinterpret_cast<EGLAttrib>(mPlatformMethods));
}
displayAttributes.push_back(EGL_NONE); displayAttributes.push_back(EGL_NONE);
mDisplay = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE, mDisplay = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
......
...@@ -30,6 +30,11 @@ class OSWindow; ...@@ -30,6 +30,11 @@ class OSWindow;
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
#endif #endif
namespace angle
{
struct PlatformMethods;
}
struct ANGLE_EXPORT EGLPlatformParameters struct ANGLE_EXPORT EGLPlatformParameters
{ {
EGLint renderer; EGLint renderer;
...@@ -83,6 +88,10 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -83,6 +88,10 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; } void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; }
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; } void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
void setPlatformMethods(angle::PlatformMethods *platformMethods)
{
mPlatformMethods = platformMethods;
}
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
...@@ -104,6 +113,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -104,6 +113,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
bool isMultisample() const { return mMultisample; } bool isMultisample() const { return mMultisample; }
bool isDebugEnabled() const { return mDebug; } bool isDebugEnabled() const { return mDebug; }
EGLint getSwapInterval() const { return mSwapInterval; } EGLint getSwapInterval() const { return mSwapInterval; }
const angle::PlatformMethods *getPlatformMethods() const { return mPlatformMethods; }
// Internally initializes the Display, Surface and Context. // Internally initializes the Display, Surface and Context.
bool initializeGL(OSWindow *osWindow); bool initializeGL(OSWindow *osWindow);
...@@ -145,6 +155,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -145,6 +155,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
EGLint mSwapInterval; EGLint mSwapInterval;
EGLint mSamples; EGLint mSamples;
Optional<bool> mVulkanLayersEnabled; Optional<bool> mVulkanLayersEnabled;
angle::PlatformMethods *mPlatformMethods;
}; };
#endif // UTIL_EGLWINDOW_H_ #endif // UTIL_EGLWINDOW_H_
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