Commit abf38572 by Jamie Madill Committed by Commit Bot

Remove old C++ ANGLE platform.

Now that the new platform is in place, we can remove the old methods. Must be landed after https://codereview.chromium.org/2697463003/ BUG=angleproject:1892 BUG=chromium:678870 Change-Id: Ia29a3b120cf3521fc0409019c2e64e4dbc6f460d Reviewed-on: https://chromium-review.googlesource.com/441274 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent e8fb640d
......@@ -32,145 +32,9 @@
namespace angle
{
struct WorkaroundsD3D;
using TraceEventHandle = uint64_t;
using EGLDisplayType = void *;
class Platform
{
public:
// System --------------------------------------------------------------
// Wall clock time in seconds since the epoch.
// TODO(jmadill): investigate using an ANGLE internal time library
virtual double currentTime() { return 0; }
// Monotonically increasing time in seconds from an arbitrary fixed point in the past.
// This function is expected to return at least millisecond-precision values. For this reason,
// it is recommended that the fixed point be no further in the past than the epoch.
virtual double monotonicallyIncreasingTime() { return 0; }
// Logging ------------------------------------------------------------
// Log an error message within the platform implementation.
virtual void logError(const char *errorMessage) {}
// Log a warning message within the platform implementation.
virtual void logWarning(const char *warningMessage) {}
// Log an info message within the platform implementation.
virtual void logInfo(const char *infoMessage) {}
// Tracing --------
// Get a pointer to the enabled state of the given trace category. The
// embedder can dynamically change the enabled state as trace event
// recording is started and stopped by the application. Only long-lived
// literal strings should be given as the category name. The implementation
// expects the returned pointer to be held permanently in a local static. If
// the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
// addTraceEvent is expected to be called by the trace event macros.
virtual const unsigned char *getTraceCategoryEnabledFlag(const char *categoryName) { return 0; }
typedef uint64_t TraceEventHandle;
// Add a trace event to the platform tracing system. Depending on the actual
// enabled state, this event may be recorded or dropped.
// - phase specifies the type of event:
// - BEGIN ('B'): Marks the beginning of a scoped event.
// - END ('E'): Marks the end of a scoped event.
// - COMPLETE ('X'): Marks the beginning of a scoped event, but doesn't
// need a matching END event. Instead, at the end of the scope,
// updateTraceEventDuration() must be called with the TraceEventHandle
// returned from addTraceEvent().
// - INSTANT ('I'): Standalone, instantaneous event.
// - START ('S'): Marks the beginning of an asynchronous event (the end
// event can occur in a different scope or thread). The id parameter is
// used to match START/FINISH pairs.
// - FINISH ('F'): Marks the end of an asynchronous event.
// - COUNTER ('C'): Used to trace integer quantities that change over
// time. The argument values are expected to be of type int.
// - METADATA ('M'): Reserved for internal use.
// - categoryEnabled is the pointer returned by getTraceCategoryEnabledFlag.
// - name is the name of the event. Also used to match BEGIN/END and
// START/FINISH pairs.
// - id optionally allows events of the same name to be distinguished from
// each other. For example, to trace the consutruction and destruction of
// objects, specify the pointer as the id parameter.
// - timestamp should be a time value returned from monotonicallyIncreasingTime.
// - numArgs specifies the number of elements in argNames, argTypes, and
// argValues.
// - argNames is the array of argument names. Use long-lived literal strings
// or specify the COPY flag.
// - argTypes is the array of argument types:
// - BOOL (1): bool
// - UINT (2): unsigned long long
// - INT (3): long long
// - DOUBLE (4): double
// - POINTER (5): void*
// - STRING (6): char* (long-lived null-terminated char* string)
// - COPY_STRING (7): char* (temporary null-terminated char* string)
// - CONVERTABLE (8): WebConvertableToTraceFormat
// - argValues is the array of argument values. Each value is the unsigned
// long long member of a union of all supported types.
// - flags can be 0 or one or more of the following, ORed together:
// - COPY (0x1): treat all strings (name, argNames and argValues of type
// string) as temporary so that they will be copied by addTraceEvent.
// - HAS_ID (0x2): use the id argument to uniquely identify the event for
// matching with other events of the same name.
// - MANGLE_ID (0x4): specify this flag if the id parameter is the value
// of a pointer.
virtual TraceEventHandle addTraceEvent(char phase,
const unsigned char *categoryEnabledFlag,
const char *name,
unsigned long long id,
double timestamp,
int numArgs,
const char **argNames,
const unsigned char *argTypes,
const unsigned long long *argValues,
unsigned char flags)
{
return 0;
}
// Set the duration field of a COMPLETE trace event.
virtual void updateTraceEventDuration(const unsigned char *categoryEnabledFlag, const char *name, TraceEventHandle eventHandle) { }
// Callbacks for reporting histogram data.
// CustomCounts histogram has exponential bucket sizes, so that min=1, max=1000000, bucketCount=50 would do.
virtual void histogramCustomCounts(const char *name, int sample, int min, int max, int bucketCount) { }
// Enumeration histogram buckets are linear, boundaryValue should be larger than any possible sample value.
virtual void histogramEnumeration(const char *name, int sample, int boundaryValue) { }
// Unlike enumeration histograms, sparse histograms only allocate memory for non-empty buckets.
virtual void histogramSparse(const char *name, int sample) { }
// Boolean histograms track two-state variables.
virtual void histogramBoolean(const char *name, bool sample) { }
// Allows us to programatically override ANGLE's default workarounds for testing purposes.
virtual void overrideWorkaroundsD3D(WorkaroundsD3D *workaroundsD3D) {}
protected:
virtual ~Platform() { }
};
} // namespace angle
extern "C"
{
typedef void (ANGLE_APIENTRY *ANGLEPlatformInitializeFunc)(angle::Platform*);
ANGLE_PLATFORM_EXPORT void ANGLE_APIENTRY ANGLEPlatformInitialize(angle::Platform*);
typedef void (ANGLE_APIENTRY *ANGLEPlatformShutdownFunc)();
ANGLE_PLATFORM_EXPORT void ANGLE_APIENTRY ANGLEPlatformShutdown();
}
namespace angle
{
struct PlatformMethods;
// Use a C-like API to not trigger undefined calling behaviour.
......@@ -356,7 +220,7 @@ struct PlatformMethods
#undef ANGLE_PLATFORM_METHOD_DEF
// Subtrace one to account for the context pointer.
// Subtract one to account for the context pointer.
constexpr unsigned int g_NumPlatformMethods = (sizeof(PlatformMethods) / sizeof(uintptr_t)) - 1;
#define ANGLE_PLATFORM_METHOD_STRING(Name) #Name
......
......@@ -49,7 +49,7 @@ angle::TraceEventHandle AddTraceEvent(char phase,
return handle;
}
return static_cast<Platform::TraceEventHandle>(0);
return static_cast<angle::TraceEventHandle>(0);
}
} // namespace angle
......@@ -62,40 +62,12 @@
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#endif // defined(ANGLE_ENABLE_VULKAN)
// The log messages prepend the class name, so make this part of the angle namespace.
namespace angle
{
class DefaultPlatform : public angle::Platform
{
public:
DefaultPlatform() {}
~DefaultPlatform() override {}
};
std::unique_ptr<DefaultPlatform> g_defaultPlatform = nullptr;
} // namespace angle
namespace egl
{
namespace
{
void InitDefaultPlatformImpl()
{
if (ANGLEPlatformCurrent() == nullptr)
{
if (!angle::g_defaultPlatform)
{
angle::g_defaultPlatform.reset(new angle::DefaultPlatform());
}
ANGLEPlatformInitialize(angle::g_defaultPlatform.get());
}
}
typedef std::map<EGLNativeWindowType, Surface*> WindowSurfaceMap;
// Get a map of all EGL window surfaces to validate that no window has more than one EGL surface
// associated with it.
......@@ -256,9 +228,6 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap, const D
Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay,
const AttributeMap &attribMap)
{
// Initialize the global platform if not already
InitDefaultPlatformImpl();
Display *display = nullptr;
ANGLEPlatformDisplayMap *displays = GetANGLEPlatformDisplayMap();
......@@ -298,9 +267,6 @@ Display *Display::GetDisplayFromNativeDisplay(EGLNativeDisplayType nativeDisplay
Display *Display::GetDisplayFromDevice(Device *device)
{
// Initialize the global platform if not already
InitDefaultPlatformImpl();
Display *display = nullptr;
ASSERT(Device::IsValidDevice(device));
......@@ -409,8 +375,8 @@ void Display::setAttributes(rx::DisplayImpl *impl, const AttributeMap &attribMap
Error Display::initialize()
{
// Re-initialize default platform if it's needed
InitDefaultPlatformImpl();
// TODO(jmadill): Store Platform in Display and init here.
ANGLEResetDisplayPlatform(this);
gl::InitializeDebugAnnotations(&mAnnotator);
......@@ -514,7 +480,8 @@ void Display::terminate()
gl::UninitializeDebugAnnotations();
// Never de-init default platform.. terminate is not that final.
// TODO(jmadill): Store Platform in Display and deinit here.
ANGLEResetDisplayPlatform(this);
}
std::vector<const Config*> Display::getConfigs(const egl::AttributeMap &attribs) const
......
......@@ -14,101 +14,8 @@
namespace
{
angle::Platform *currentPlatform = nullptr;
// TODO(jmadill): Make methods owned by egl::Display.
angle::PlatformMethods g_platformMethods;
// TODO(jmadill): Remove all the Class_ methods once we switch Chromium to the new impl.
double Class_currentTime(angle::PlatformMethods *platform)
{
return currentPlatform->currentTime();
}
double Class_monotonicallyIncreasingTime(angle::PlatformMethods *platform)
{
return currentPlatform->monotonicallyIncreasingTime();
}
void Class_logError(angle::PlatformMethods *platform, const char *errorMessage)
{
currentPlatform->logError(errorMessage);
}
void Class_logWarning(angle::PlatformMethods *platform, const char *warningMessage)
{
currentPlatform->logWarning(warningMessage);
}
void Class_logInfo(angle::PlatformMethods *platform, const char *infoMessage)
{
currentPlatform->logInfo(infoMessage);
}
const unsigned char *Class_getTraceCategoryEnabledFlag(angle::PlatformMethods *platform,
const char *categoryName)
{
return currentPlatform->getTraceCategoryEnabledFlag(categoryName);
}
angle::TraceEventHandle Class_addTraceEvent(angle::PlatformMethods *platform,
char phase,
const unsigned char *categoryEnabledFlag,
const char *name,
unsigned long long id,
double timestamp,
int numArgs,
const char **argNames,
const unsigned char *argTypes,
const unsigned long long *argValues,
unsigned char flags)
{
return currentPlatform->addTraceEvent(phase, categoryEnabledFlag, name, id, timestamp, numArgs,
argNames, argTypes, argValues, flags);
}
void Class_updateTraceEventDuration(angle::PlatformMethods *platform,
const unsigned char *categoryEnabledFlag,
const char *name,
angle::TraceEventHandle eventHandle)
{
currentPlatform->updateTraceEventDuration(categoryEnabledFlag, name, eventHandle);
}
void Class_histogramCustomCounts(angle::PlatformMethods *platform,
const char *name,
int sample,
int min,
int max,
int bucketCount)
{
currentPlatform->histogramCustomCounts(name, sample, min, max, bucketCount);
}
void Class_histogramEnumeration(angle::PlatformMethods *platform,
const char *name,
int sample,
int boundaryValue)
{
currentPlatform->histogramEnumeration(name, sample, boundaryValue);
}
void Class_histogramSparse(angle::PlatformMethods *platform, const char *name, int sample)
{
currentPlatform->histogramSparse(name, sample);
}
void Class_histogramBoolean(angle::PlatformMethods *platform, const char *name, bool sample)
{
currentPlatform->histogramBoolean(name, sample);
}
void Class_overrideWorkaroundsD3D(angle::PlatformMethods *platform,
angle::WorkaroundsD3D *workaroundsD3D)
{
currentPlatform->overrideWorkaroundsD3D(workaroundsD3D);
}
} // anonymous namespace
angle::PlatformMethods *ANGLEPlatformCurrent()
......@@ -116,33 +23,6 @@ angle::PlatformMethods *ANGLEPlatformCurrent()
return &g_platformMethods;
}
void ANGLE_APIENTRY ANGLEPlatformInitialize(angle::Platform *platformImpl)
{
ASSERT(platformImpl != nullptr);
currentPlatform = platformImpl;
// TODO(jmadill): Migrate to platform methods.
g_platformMethods.addTraceEvent = Class_addTraceEvent;
g_platformMethods.currentTime = Class_currentTime;
g_platformMethods.getTraceCategoryEnabledFlag = Class_getTraceCategoryEnabledFlag;
g_platformMethods.histogramBoolean = Class_histogramBoolean;
g_platformMethods.histogramCustomCounts = Class_histogramCustomCounts;
g_platformMethods.histogramEnumeration = Class_histogramEnumeration;
g_platformMethods.histogramSparse = Class_histogramSparse;
g_platformMethods.logError = Class_logError;
g_platformMethods.logInfo = Class_logInfo;
g_platformMethods.logWarning = Class_logWarning;
g_platformMethods.monotonicallyIncreasingTime = Class_monotonicallyIncreasingTime;
g_platformMethods.overrideWorkaroundsD3D = Class_overrideWorkaroundsD3D;
g_platformMethods.updateTraceEventDuration = Class_updateTraceEventDuration;
}
void ANGLE_APIENTRY ANGLEPlatformShutdown()
{
currentPlatform = nullptr;
g_platformMethods = angle::PlatformMethods();
}
bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisplayType display,
const char *const methodNames[],
unsigned int methodNameCount,
......@@ -178,6 +58,5 @@ bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisplayType display,
void ANGLE_APIENTRY ANGLEResetDisplayPlatform(angle::EGLDisplayType display)
{
// TODO(jmadill): Store platform methods in display.
g_platformMethods = angle::PlatformMethods();
g_platformMethods.context = 0;
g_platformMethods = angle::PlatformMethods();
}
......@@ -1771,8 +1771,6 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *
INSERT_PROC_ADDRESS(egl, SwapBuffersWithDamageEXT);
// angle::Platform related entry points
INSERT_PROC_ADDRESS_NO_NS("ANGLEPlatformInitialize", ANGLEPlatformInitialize);
INSERT_PROC_ADDRESS_NO_NS("ANGLEPlatformShutdown", ANGLEPlatformShutdown);
INSERT_PROC_ADDRESS_NO_NS("ANGLEGetDisplayPlatform", ANGLEGetDisplayPlatform);
INSERT_PROC_ADDRESS_NO_NS("ANGLEResetDisplayPlatform", ANGLEResetDisplayPlatform);
......
......@@ -408,6 +408,5 @@ EXPORTS
glVertexBindingDivisor @412
; ANGLE Platform Implementation
ANGLEPlatformCurrent @290
ANGLEPlatformInitialize @291
ANGLEPlatformShutdown @292
ANGLEGetDisplayPlatform @290
ANGLEResetDisplayPlatform @291
......@@ -317,9 +317,6 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery)
// eglSwapBuffers, so we must call eglSwapBuffers before we lose the device.
ASSERT_EGL_TRUE(eglSwapBuffers(mDisplay, mSurface));
// Ignore expected error messages
IgnoreANGLEPlatformMessages();
// Trigger a lost device
trigger9_3DeviceLost();
......@@ -337,9 +334,6 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery)
ASSERT_EQ(EGL_NO_SURFACE, mSurface);
ASSERT_EGL_ERROR(EGL_BAD_ALLOC);
// No more error messages expected
EnableANGLEPlatformMessages();
// Get the D3D11 device out of the EGLDisplay again. It should be the same one as above.
EGLAttrib device = 0;
EGLAttrib newEglDevice = 0;
......
......@@ -80,9 +80,6 @@ class EGLX11VisualHintTest : public ::testing::TestWithParam<angle::PlatformPara
// Test that display creation fails if the visual ID passed in invalid.
TEST_P(EGLX11VisualHintTest, InvalidVisualID)
{
// The test platform will log an error in this negative test.
IgnoreANGLEPlatformMessages();
static const int gInvalidVisualId = -1;
auto attributes = getDisplayAttributes(gInvalidVisualId);
......
......@@ -17,56 +17,43 @@ using namespace testing;
namespace
{
// Only applies to D3D11
class CapturePlatform : public angle::Platform
struct Captures final : angle::NonCopyable
{
public:
CapturePlatform()
: mTimer(CreateTimer()),
mLoadDLLsMS(0),
mCreateDeviceMS(0),
mInitResourcesMS(0)
{
mTimer->start();
}
double currentTime() override;
void histogramCustomCounts(
const char *name, int sample, int min, int max, int bucketCount) override;
size_t getLoadDLLsMS() const { return mLoadDLLsMS; }
size_t getCreateDeviceMS() const { return mCreateDeviceMS; }
size_t getInitResourcesMS() const { return mInitResourcesMS; }
private:
Timer *mTimer;
size_t mLoadDLLsMS;
size_t mCreateDeviceMS;
size_t mInitResourcesMS;
Timer *timer = CreateTimer();
size_t loadDLLsMS = 0;
size_t createDeviceMS = 0;
size_t initResourcesMS = 0;
};
double CapturePlatform::currentTime()
double CapturePlatform_currentTime(angle::PlatformMethods *platformMethods)
{
return mTimer->getElapsedTime();
Captures *captures = static_cast<Captures *>(platformMethods->context);
return captures->timer->getElapsedTime();
}
void CapturePlatform::histogramCustomCounts(
const char *name, int sample, int /*min*/, int /*max*/, int /*bucketCount*/)
void CapturePlatform_histogramCustomCounts(angle::PlatformMethods *platformMethods,
const char *name,
int sample,
int /*min*/,
int /*max*/,
int /*bucketCount*/)
{
Captures *captures = static_cast<Captures *>(platformMethods->context);
// These must match the names of the histograms.
if (strcmp(name, "GPU.ANGLE.Renderer11InitializeDLLsMS") == 0)
{
mLoadDLLsMS += static_cast<size_t>(sample);
captures->loadDLLsMS += static_cast<size_t>(sample);
}
// Note: not captured in debug, due to creating a debug device
else if (strcmp(name, "GPU.ANGLE.D3D11CreateDeviceMS") == 0)
{
mCreateDeviceMS += static_cast<size_t>(sample);
captures->createDeviceMS += static_cast<size_t>(sample);
}
else if (strcmp(name, "GPU.ANGLE.Renderer11InitializeDeviceMS") == 0)
{
mInitResourcesMS += static_cast<size_t>(sample);
captures->initResourcesMS += static_cast<size_t>(sample);
}
}
......@@ -78,12 +65,13 @@ class EGLInitializePerfTest : public ANGLEPerfTest,
~EGLInitializePerfTest();
void step() override;
void SetUp() override;
void TearDown() override;
private:
OSWindow *mOSWindow;
EGLDisplay mDisplay;
CapturePlatform mCapturePlatform;
Captures mCaptures;
};
EGLInitializePerfTest::EGLInitializePerfTest()
......@@ -123,8 +111,18 @@ EGLInitializePerfTest::EGLInitializePerfTest()
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
reinterpret_cast<void *>(mOSWindow->getNativeDisplay()),
&displayAttributes[0]);
}
void EGLInitializePerfTest::SetUp()
{
ANGLEPerfTest::SetUp();
angle::PlatformMethods *platformMethods = nullptr;
ASSERT_TRUE(ANGLEGetDisplayPlatform(mDisplay, angle::g_PlatformMethodNames,
angle::g_NumPlatformMethods, &mCaptures, &platformMethods));
ANGLEPlatformInitialize(&mCapturePlatform);
platformMethods->currentTime = CapturePlatform_currentTime;
platformMethods->histogramCustomCounts = CapturePlatform_histogramCustomCounts;
}
EGLInitializePerfTest::~EGLInitializePerfTest()
......@@ -144,11 +142,11 @@ void EGLInitializePerfTest::step()
void EGLInitializePerfTest::TearDown()
{
ANGLEPerfTest::TearDown();
printResult("LoadDLLs", normalizedTime(mCapturePlatform.getLoadDLLsMS()), "ms", true);
printResult("D3D11CreateDevice", normalizedTime(mCapturePlatform.getCreateDeviceMS()), "ms", true);
printResult("InitResources", normalizedTime(mCapturePlatform.getInitResourcesMS()), "ms", true);
printResult("LoadDLLs", normalizedTime(mCaptures.loadDLLsMS), "ms", true);
printResult("D3D11CreateDevice", normalizedTime(mCaptures.createDeviceMS), "ms", true);
printResult("InitResources", normalizedTime(mCaptures.initResourcesMS), "ms", true);
ANGLEPlatformShutdown();
ANGLEResetDisplayPlatform(mDisplay);
}
TEST_P(EGLInitializePerfTest, Run)
......
......@@ -42,73 +42,43 @@ GLubyte ColorDenorm(float colorValue)
return static_cast<GLubyte>(colorValue * 255.0f);
}
// Use a custom ANGLE platform class to capture and report internal errors.
class TestPlatform : public angle::Platform
void TestPlatform_logError(angle::PlatformMethods *platform, const char *errorMessage)
{
public:
void logError(const char *errorMessage) override;
void logWarning(const char *warningMessage) override;
void logInfo(const char *infoMessage) override;
void overrideWorkaroundsD3D(WorkaroundsD3D *workaroundsD3D) override;
void ignoreMessages();
void enableMessages();
void setCurrentTest(ANGLETest *currentTest);
private:
bool mIgnoreMessages = false;
ANGLETest *mCurrentTest = nullptr;
};
void TestPlatform::logError(const char *errorMessage)
{
if (mIgnoreMessages)
auto *testPlatformContext = static_cast<TestPlatformContext *>(platform->context);
if (testPlatformContext->ignoreMessages)
return;
FAIL() << errorMessage;
}
void TestPlatform::logWarning(const char *warningMessage)
void TestPlatform_logWarning(angle::PlatformMethods *platform, const char *warningMessage)
{
if (mIgnoreMessages)
auto *testPlatformContext = static_cast<TestPlatformContext *>(platform->context);
if (testPlatformContext->ignoreMessages)
return;
std::cerr << "Warning: " << warningMessage << std::endl;
}
void TestPlatform::logInfo(const char *infoMessage)
void TestPlatform_logInfo(angle::PlatformMethods *platform, const char *infoMessage)
{
if (mIgnoreMessages)
auto *testPlatformContext = static_cast<TestPlatformContext *>(platform->context);
if (testPlatformContext->ignoreMessages)
return;
angle::WriteDebugMessage("%s\n", infoMessage);
}
void TestPlatform::overrideWorkaroundsD3D(WorkaroundsD3D *workaroundsD3D)
void TestPlatform_overrideWorkaroundsD3D(angle::PlatformMethods *platform,
WorkaroundsD3D *workaroundsD3D)
{
if (mCurrentTest)
auto *testPlatformContext = static_cast<TestPlatformContext *>(platform->context);
if (testPlatformContext->currentTest)
{
mCurrentTest->overrideWorkaroundsD3D(workaroundsD3D);
testPlatformContext->currentTest->overrideWorkaroundsD3D(workaroundsD3D);
}
}
void TestPlatform::ignoreMessages()
{
mIgnoreMessages = true;
}
void TestPlatform::enableMessages()
{
mIgnoreMessages = false;
}
void TestPlatform::setCurrentTest(ANGLETest *currentTest)
{
mCurrentTest = currentTest;
}
TestPlatform g_testPlatformInstance;
std::array<angle::Vector3, 4> GetIndexedQuadVertices()
{
std::array<angle::Vector3, 4> vertices;
......@@ -267,8 +237,8 @@ ANGLETest::~ANGLETest()
void ANGLETest::SetUp()
{
EnableANGLEPlatformMessages();
angle::g_testPlatformInstance.setCurrentTest(this);
mPlatformContext.ignoreMessages = false;
mPlatformContext.currentTest = this;
// Resize the window before creating the context so that the first make current
// sets the viewport and scissor box to the right size.
......@@ -287,6 +257,22 @@ void ANGLETest::SetUp()
FAIL() << "egl context creation 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
......@@ -306,7 +292,7 @@ void ANGLETest::SetUp()
void ANGLETest::TearDown()
{
angle::g_testPlatformInstance.setCurrentTest(nullptr);
mPlatformContext.currentTest = nullptr;
checkD3D11SDKLayersMessages();
const auto &info = testing::UnitTest::GetInstance()->current_test_info();
......@@ -756,6 +742,7 @@ bool ANGLETest::destroyEGLContext()
return true;
}
// static
bool ANGLETest::InitTestWindow()
{
mOSWindow = CreateOSWindow();
......@@ -766,9 +753,12 @@ bool ANGLETest::InitTestWindow()
mOSWindow->setVisible(true);
mGLESLibrary.reset(angle::loadLibrary("libGLESv2"));
return true;
}
// static
bool ANGLETest::DestroyTestWindow()
{
if (mOSWindow)
......@@ -778,6 +768,8 @@ bool ANGLETest::DestroyTestWindow()
mOSWindow = NULL;
}
mGLESLibrary.reset(nullptr);
return true;
}
......@@ -927,20 +919,10 @@ void ANGLETest::ignoreD3D11SDKLayersWarnings()
OSWindow *ANGLETest::mOSWindow = nullptr;
Optional<EGLint> ANGLETest::mLastRendererType;
std::unique_ptr<angle::Library> ANGLETest::mGLESLibrary;
void ANGLETestEnvironment::SetUp()
{
mGLESLibrary.reset(angle::loadLibrary("libGLESv2"));
if (mGLESLibrary)
{
auto initFunc = reinterpret_cast<ANGLEPlatformInitializeFunc>(
mGLESLibrary->getSymbol("ANGLEPlatformInitialize"));
if (initFunc)
{
initFunc(&angle::g_testPlatformInstance);
}
}
if (!ANGLETest::InitTestWindow())
{
FAIL() << "Failed to create ANGLE test window.";
......@@ -950,25 +932,4 @@ void ANGLETestEnvironment::SetUp()
void ANGLETestEnvironment::TearDown()
{
ANGLETest::DestroyTestWindow();
if (mGLESLibrary)
{
auto shutdownFunc = reinterpret_cast<ANGLEPlatformShutdownFunc>(
mGLESLibrary->getSymbol("ANGLEPlatformShutdown"));
if (shutdownFunc)
{
shutdownFunc();
}
}
}
void IgnoreANGLEPlatformMessages()
{
// Negative tests may trigger expected errors/warnings in the ANGLE Platform.
angle::g_testPlatformInstance.ignoreMessages();
}
void EnableANGLEPlatformMessages()
{
angle::g_testPlatformInstance.enableMessages();
}
......@@ -166,6 +166,13 @@ GLColor32F ReadColor32F(GLint x, GLint y);
class EGLWindow;
class OSWindow;
class ANGLETest;
struct TestPlatformContext final : angle::NonCopyable
{
bool ignoreMessages = false;
ANGLETest *currentTest = nullptr;
};
class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
{
......@@ -260,10 +267,15 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
// Used for indexed quad rendering
GLuint mQuadVertexBuffer;
TestPlatformContext mPlatformContext;
static OSWindow *mOSWindow;
// Workaround for NVIDIA not being able to share a window with OpenGL and Vulkan.
static Optional<EGLint> mLastRendererType;
// For loading and freeing platform
static std::unique_ptr<angle::Library> mGLESLibrary;
};
class ANGLETestEnvironment : public testing::Environment
......@@ -271,10 +283,6 @@ class ANGLETestEnvironment : public testing::Environment
public:
void SetUp() override;
void TearDown() override;
private:
// For loading and freeing platform
std::unique_ptr<angle::Library> mGLESLibrary;
};
// Driver vendors
......@@ -307,10 +315,6 @@ bool IsVulkan();
bool IsDebug();
bool IsRelease();
// Negative tests may trigger expected errors/warnings in the ANGLE Platform.
void IgnoreANGLEPlatformMessages();
void EnableANGLEPlatformMessages();
// Note: git cl format messes up this formatting.
#define ANGLE_SKIP_TEST_IF(COND) \
\
......
......@@ -690,27 +690,27 @@ static inline void setTraceValue(const std::string& arg,
// store pointers to the internal c_str and pass through to the tracing API, the
// arg values must live throughout these procedures.
static inline angle::Platform::TraceEventHandle addTraceEvent(
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags) {
static inline angle::TraceEventHandle addTraceEvent(char phase,
const unsigned char *categoryEnabled,
const char *name,
unsigned long long id,
unsigned char flags)
{
return TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, categoryEnabled, name, id,
zeroNumArgs, 0, 0, 0,
flags);
}
template<class ARG1_TYPE>
static inline angle::Platform::TraceEventHandle addTraceEvent(
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
const char* arg1Name,
const ARG1_TYPE& arg1Val) {
template <class ARG1_TYPE>
static inline angle::TraceEventHandle addTraceEvent(char phase,
const unsigned char *categoryEnabled,
const char *name,
unsigned long long id,
unsigned char flags,
const char *arg1Name,
const ARG1_TYPE &arg1Val)
{
const int numArgs = 1;
unsigned char argTypes[1];
unsigned long long argValues[1];
......@@ -721,17 +721,17 @@ static inline angle::Platform::TraceEventHandle addTraceEvent(
flags);
}
template<class ARG1_TYPE, class ARG2_TYPE>
static inline angle::Platform::TraceEventHandle addTraceEvent(
char phase,
const unsigned char* categoryEnabled,
const char* name,
unsigned long long id,
unsigned char flags,
const char* arg1Name,
const ARG1_TYPE& arg1Val,
const char* arg2Name,
const ARG2_TYPE& arg2Val) {
template <class ARG1_TYPE, class ARG2_TYPE>
static inline angle::TraceEventHandle addTraceEvent(char phase,
const unsigned char *categoryEnabled,
const char *name,
unsigned long long id,
unsigned char flags,
const char *arg1Name,
const ARG1_TYPE &arg1Val,
const char *arg2Name,
const ARG2_TYPE &arg2Val)
{
const int numArgs = 2;
const char* argNames[2] = { arg1Name, arg2Name };
unsigned char argTypes[2];
......
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