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)
// Hidden enum for the NULL D3D device type.
#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) \
if (!result.IsValid()) \
{ \
......
......@@ -254,7 +254,7 @@ void Display_logInfo(angle::PlatformMethods *platform, const char *infoMessage)
void ANGLESetDefaultDisplayPlatform(angle::EGLDisplayType display)
{
angle::PlatformMethods *platformMethods = ANGLEPlatformCurrent();
if (platformMethods->logError != angle::ANGLE_logError)
if (platformMethods->logError != angle::DefaultLogError)
{
// Don't reset pre-set Platform to Default
return;
......@@ -419,7 +419,17 @@ void Display::setAttributes(rx::DisplayImpl *impl, const AttributeMap &attribMap
Error Display::initialize()
{
// 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);
......
......@@ -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];
}
......
......@@ -10,7 +10,6 @@
#include "ANGLETest.h"
#include "EGLWindow.h"
#include "OSWindow.h"
#include "platform/Platform.h"
namespace angle
{
......@@ -254,6 +253,13 @@ void ANGLETest::SetUp()
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))
{
FAIL() << "egl display or surface init failed.";
......@@ -264,22 +270,6 @@ void ANGLETest::SetUp()
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)
{
// Swap the buffers so that the default framebuffer picks up the resize
......@@ -299,6 +289,8 @@ void ANGLETest::SetUp()
void ANGLETest::TearDown()
{
mEGLWindow->setPlatformMethods(nullptr);
mPlatformContext.currentTest = nullptr;
checkD3D11SDKLayersMessages();
......
......@@ -18,6 +18,7 @@
#include "angle_test_configs.h"
#include "common/angleutils.h"
#include "common/vector_utils.h"
#include "platform/Platform.h"
#include "shader_utils.h"
#include "system_utils.h"
......@@ -305,6 +306,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
// Used for indexed quad rendering
GLuint mQuadVertexBuffer;
angle::PlatformMethods mPlatformMethods;
TestPlatformContext mPlatformContext;
bool mDeferContextInit;
......
......@@ -12,6 +12,9 @@
#include "OSWindow.h"
#include "common/debug.h"
// TODO(jmadill): Clean this up at some point.
#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x9999
EGLPlatformParameters::EGLPlatformParameters()
: renderer(EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE),
majorVersion(EGL_DONT_CARE),
......@@ -118,7 +121,8 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion,
mClientArraysEnabled(true),
mRobustResourceInit(false),
mSwapInterval(-1),
mSamples(-1)
mSamples(-1),
mPlatformMethods(nullptr)
{
}
......@@ -196,6 +200,13 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow)
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);
mDisplay = eglGetPlatformDisplay(EGL_PLATFORM_ANGLE_ANGLE,
......
......@@ -30,6 +30,11 @@ class OSWindow;
#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
#endif
namespace angle
{
struct PlatformMethods;
}
struct ANGLE_EXPORT EGLPlatformParameters
{
EGLint renderer;
......@@ -83,6 +88,10 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; }
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
void setPlatformMethods(angle::PlatformMethods *platformMethods)
{
mPlatformMethods = platformMethods;
}
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
......@@ -104,6 +113,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
bool isMultisample() const { return mMultisample; }
bool isDebugEnabled() const { return mDebug; }
EGLint getSwapInterval() const { return mSwapInterval; }
const angle::PlatformMethods *getPlatformMethods() const { return mPlatformMethods; }
// Internally initializes the Display, Surface and Context.
bool initializeGL(OSWindow *osWindow);
......@@ -145,6 +155,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
EGLint mSwapInterval;
EGLint mSamples;
Optional<bool> mVulkanLayersEnabled;
angle::PlatformMethods *mPlatformMethods;
};
#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