Commit bcb3f9ba by Yuly Novikov Committed by Commit Bot

Direct logging to Platform when available

All logging should be done via ERR() and WARN(), which call angle::Platform's logError and logWarning, if there is current Platform which supports logging. Otherwise, ERR() is directed to std::cerr. Misc fixes to keep tests passing. BUG=angleproject:1660, angleproject:1644 Change-Id: I2bca33a021537185d0c236a3083789af3236b5f3 Reviewed-on: https://chromium-review.googlesource.com/434188 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a2936aaf
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <vector> #include <vector>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/platform.h"
#include "common/Optional.h" #include "common/Optional.h"
namespace gl namespace gl
...@@ -37,8 +36,33 @@ constexpr const char *LogSeverityName(int severity) ...@@ -37,8 +36,33 @@ constexpr const char *LogSeverityName(int severity)
: "UNKNOWN"; : "UNKNOWN";
} }
bool ShouldCreateLogMessage(LogSeverity severity)
{
#if defined(ANGLE_TRACE_ENABLED)
return true;
#elif defined(ANGLE_ENABLE_ASSERTS)
return severity == LOG_ERR;
#else
return false;
#endif
}
} // namespace } // namespace
namespace priv
{
bool ShouldCreatePlatformLogMessage(LogSeverity severity)
{
#if defined(ANGLE_TRACE_ENABLED)
return true;
#else
return severity != LOG_EVENT;
#endif
}
} // namespace priv
bool DebugAnnotationsActive() bool DebugAnnotationsActive()
{ {
#if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS) #if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS)
...@@ -48,6 +72,11 @@ bool DebugAnnotationsActive() ...@@ -48,6 +72,11 @@ bool DebugAnnotationsActive()
#endif #endif
} }
bool DebugAnnotationsInitialized()
{
return g_debugAnnotator != nullptr;
}
void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator) void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator)
{ {
UninitializeDebugAnnotations(); UninitializeDebugAnnotations();
...@@ -85,30 +114,39 @@ ScopedPerfEventHelper::~ScopedPerfEventHelper() ...@@ -85,30 +114,39 @@ ScopedPerfEventHelper::~ScopedPerfEventHelper()
} }
} }
namespace priv LogMessage::LogMessage(const char *function, int line, LogSeverity severity)
{ : mFunction(function), mLine(line), mSeverity(severity)
bool ShouldCreateLogMessage(LogSeverity severity)
{ {
#if defined(ANGLE_TRACE_ENABLED)
return true;
#elif defined(ANGLE_ENABLE_ASSERTS)
return severity == LOG_ERR;
#else
return false;
#endif
} }
LogMessage::LogMessage(const char *function, int line, LogSeverity severity) LogMessage::~LogMessage()
: mSeverity(severity), mFunction(function), mLine(line)
{ {
init(function, line); if (DebugAnnotationsInitialized() && (mSeverity == LOG_ERR || mSeverity == LOG_WARN))
{
g_debugAnnotator->logMessage(*this);
}
else
{
trace();
}
} }
LogMessage::~LogMessage() void LogMessage::trace() const
{ {
mStream << std::endl; if (!ShouldCreateLogMessage(mSeverity))
std::string str(mStream.str()); {
return;
}
std::ostringstream stream;
stream << LogSeverityName(mSeverity) << ": ";
// EVENT() don't require additional function(line) info
if (mSeverity != LOG_EVENT)
{
stream << mFunction << "(" << mLine << "): ";
}
stream << mStream.str() << std::endl;
std::string str(stream.str());
if (DebugAnnotationsActive()) if (DebugAnnotationsActive())
{ {
...@@ -125,11 +163,7 @@ LogMessage::~LogMessage() ...@@ -125,11 +163,7 @@ LogMessage::~LogMessage()
} }
} }
// Give any log message handler first dibs on the message. if (mSeverity == LOG_ERR)
bool handled = g_debugAnnotator != nullptr &&
g_debugAnnotator->logMessage(mSeverity, mFunction, mLine, mMessageStart, str);
if (!handled && mSeverity == LOG_ERR)
{ {
std::cerr << str; std::cerr << str;
#if !defined(NDEBUG) && defined(_MSC_VER) #if !defined(NDEBUG) && defined(_MSC_VER)
...@@ -158,20 +192,17 @@ LogMessage::~LogMessage() ...@@ -158,20 +192,17 @@ LogMessage::~LogMessage()
#endif // ANGLE_ENABLE_DEBUG_TRACE #endif // ANGLE_ENABLE_DEBUG_TRACE
} }
// writes the common header info to the stream LogSeverity LogMessage::getSeverity() const
void LogMessage::init(const char *function, int line)
{ {
if (mSeverity >= 0) return mSeverity;
mStream << LogSeverityName(mSeverity);
else
mStream << "VERBOSE" << -mSeverity;
mStream << ": " << function << "(" << line << "): ";
mMessageStart = mStream.str().length();
} }
} // namespace priv std::string LogMessage::getMessage() const
{
std::ostringstream stream;
stream << mFunction << "(" << mLine << "): " << mStream.str() << std::endl;
return stream.str();
}
#if defined(ANGLE_PLATFORM_WINDOWS) #if defined(ANGLE_PLATFORM_WINDOWS)
std::ostream &operator<<(std::ostream &os, const FmtHR &fmt) std::ostream &operator<<(std::ostream &os, const FmtHR &fmt)
......
...@@ -42,33 +42,54 @@ constexpr LogSeverity LOG_WARN = 1; ...@@ -42,33 +42,54 @@ constexpr LogSeverity LOG_WARN = 1;
constexpr LogSeverity LOG_ERR = 2; constexpr LogSeverity LOG_ERR = 2;
constexpr LogSeverity LOG_NUM_SEVERITIES = 3; constexpr LogSeverity LOG_NUM_SEVERITIES = 3;
// This class more or less represents a particular log message. You
// create an instance of LogMessage and then stream stuff to it.
// When you finish streaming to it, ~LogMessage is called and the
// full message gets streamed to the appropriate destination.
//
// You shouldn't actually use LogMessage's constructor to log things,
// though. You should use the ERR() and WARN() macros.
class LogMessage : angle::NonCopyable
{
public:
// Used for ANGLE_LOG(severity).
LogMessage(const char *function, int line, LogSeverity severity);
~LogMessage();
std::ostream &stream() { return mStream; }
void trace() const;
LogSeverity getSeverity() const;
std::string getMessage() const;
private:
const char *mFunction;
const int mLine;
const LogSeverity mSeverity;
std::ostringstream mStream;
};
// Wraps the D3D9/D3D11 debug annotation functions. // Wraps the D3D9/D3D11 debug annotation functions.
// Also handles redirecting logging destination.
class DebugAnnotator : angle::NonCopyable class DebugAnnotator : angle::NonCopyable
{ {
public: public:
DebugAnnotator() { }; DebugAnnotator(){};
virtual ~DebugAnnotator() { }; virtual ~DebugAnnotator() { };
virtual void beginEvent(const wchar_t *eventName) = 0; virtual void beginEvent(const wchar_t *eventName) = 0;
virtual void endEvent() = 0; virtual void endEvent() = 0;
virtual void setMarker(const wchar_t *markerName) = 0; virtual void setMarker(const wchar_t *markerName) = 0;
virtual bool getStatus() = 0; virtual bool getStatus() = 0;
// Log Message Handler that gets passed every log message before // Log Message Handler that gets passed every log message,
// it's sent to other log destinations (if any). // when debug annotations are initialized,
// Returns true to signal that it handled the message and the message // replacing default handling by LogMessage.
// should not be sent to other log destinations. virtual void logMessage(const LogMessage &msg) const = 0;
virtual bool logMessage(LogSeverity severity,
const char *function,
int line,
size_t message_start,
const std::string &str)
{
return false;
}
}; };
void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator); void InitializeDebugAnnotations(DebugAnnotator *debugAnnotator);
void UninitializeDebugAnnotations(); void UninitializeDebugAnnotations();
bool DebugAnnotationsActive(); bool DebugAnnotationsActive();
bool DebugAnnotationsInitialized();
namespace priv namespace priv
{ {
...@@ -83,33 +104,7 @@ class LogMessageVoidify ...@@ -83,33 +104,7 @@ class LogMessageVoidify
}; };
// Used by ANGLE_LOG_IS_ON to lazy-evaluate stream arguments. // Used by ANGLE_LOG_IS_ON to lazy-evaluate stream arguments.
bool ShouldCreateLogMessage(LogSeverity severity); bool ShouldCreatePlatformLogMessage(LogSeverity severity);
// This class more or less represents a particular log message. You
// create an instance of LogMessage and then stream stuff to it.
// When you finish streaming to it, ~LogMessage is called and the
// full message gets streamed to the appropriate destination.
//
// You shouldn't actually use LogMessage's constructor to log things,
// though. You should use the ERR() and WARN() macros.
class LogMessage : angle::NonCopyable
{
public:
// Used for ANGLE_LOG(severity).
LogMessage(const char *function, int line, LogSeverity severity);
~LogMessage();
std::ostream &stream() { return mStream; }
private:
void init(const char *function, int line);
LogSeverity mSeverity;
std::ostringstream mStream;
size_t mMessageStart; // Offset of the start of the message (past prefix info).
// The function and line information passed in to the constructor.
const char *mFunction;
const int mLine;
};
template <int N, typename T> template <int N, typename T>
std::ostream &FmtHex(std::ostream &os, T value) std::ostream &FmtHex(std::ostream &os, T value)
...@@ -157,17 +152,17 @@ std::ostream &FmtHexInt(std::ostream &os, T value) ...@@ -157,17 +152,17 @@ std::ostream &FmtHexInt(std::ostream &os, T value)
// by ANGLE_LOG(). Since these are used all over our code, it's // by ANGLE_LOG(). Since these are used all over our code, it's
// better to have compact code for these operations. // better to have compact code for these operations.
#define COMPACT_ANGLE_LOG_EX_EVENT(ClassName, ...) \ #define COMPACT_ANGLE_LOG_EX_EVENT(ClassName, ...) \
::gl::priv::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_EVENT, ##__VA_ARGS__) ::gl::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_EVENT, ##__VA_ARGS__)
#define COMPACT_ANGLE_LOG_EX_WARN(ClassName, ...) \ #define COMPACT_ANGLE_LOG_EX_WARN(ClassName, ...) \
::gl::priv::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_WARN, ##__VA_ARGS__) ::gl::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_WARN, ##__VA_ARGS__)
#define COMPACT_ANGLE_LOG_EX_ERR(ClassName, ...) \ #define COMPACT_ANGLE_LOG_EX_ERR(ClassName, ...) \
::gl::priv::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_ERR, ##__VA_ARGS__) ::gl::ClassName(__FUNCTION__, __LINE__, ::gl::LOG_ERR, ##__VA_ARGS__)
#define COMPACT_ANGLE_LOG_EVENT COMPACT_ANGLE_LOG_EX_EVENT(LogMessage) #define COMPACT_ANGLE_LOG_EVENT COMPACT_ANGLE_LOG_EX_EVENT(LogMessage)
#define COMPACT_ANGLE_LOG_WARN COMPACT_ANGLE_LOG_EX_WARN(LogMessage) #define COMPACT_ANGLE_LOG_WARN COMPACT_ANGLE_LOG_EX_WARN(LogMessage)
#define COMPACT_ANGLE_LOG_ERR COMPACT_ANGLE_LOG_EX_ERR(LogMessage) #define COMPACT_ANGLE_LOG_ERR COMPACT_ANGLE_LOG_EX_ERR(LogMessage)
#define ANGLE_LOG_IS_ON(severity) (::gl::priv::ShouldCreateLogMessage(::gl::LOG_##severity)) #define ANGLE_LOG_IS_ON(severity) (::gl::priv::ShouldCreatePlatformLogMessage(::gl::LOG_##severity))
// Helper macro which avoids evaluating the arguments to a stream if the condition doesn't hold. // Helper macro which avoids evaluating the arguments to a stream if the condition doesn't hold.
// Condition is evaluated once and only once. // Condition is evaluated once and only once.
......
...@@ -70,30 +70,10 @@ class DefaultPlatform : public angle::Platform ...@@ -70,30 +70,10 @@ class DefaultPlatform : public angle::Platform
public: public:
DefaultPlatform() {} DefaultPlatform() {}
~DefaultPlatform() override {} ~DefaultPlatform() override {}
void logError(const char *errorMessage) override;
void logWarning(const char *warningMessage) override;
void logInfo(const char *infoMessage) override;
}; };
std::unique_ptr<DefaultPlatform> g_defaultPlatform = nullptr; std::unique_ptr<DefaultPlatform> g_defaultPlatform = nullptr;
void DefaultPlatform::logError(const char *errorMessage)
{
ERR() << errorMessage;
}
void DefaultPlatform::logWarning(const char *warningMessage)
{
WARN() << warningMessage;
}
void DefaultPlatform::logInfo(const char *infoMessage)
{
// Uncomment this if you want Vulkan spam.
// WARN() << infoMessage;
}
} // namespace angle } // namespace angle
namespace egl namespace egl
...@@ -429,6 +409,8 @@ Error Display::initialize() ...@@ -429,6 +409,8 @@ Error Display::initialize()
// Re-initialize default platform if it's needed // Re-initialize default platform if it's needed
InitDefaultPlatformImpl(); InitDefaultPlatformImpl();
gl::InitializeDebugAnnotations(&mAnnotator);
SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.DisplayInitializeMS"); SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.DisplayInitializeMS");
TRACE_EVENT0("gpu.angle", "egl::Display::initialize"); TRACE_EVENT0("gpu.angle", "egl::Display::initialize");
...@@ -443,10 +425,7 @@ Error Display::initialize() ...@@ -443,10 +425,7 @@ Error Display::initialize()
if (error.isError()) if (error.isError())
{ {
// Log extended error message here // Log extended error message here
std::stringstream errorStream; ERR() << "ANGLE Display::initialize error " << error.getID() << ": " << error.getMessage();
errorStream << "ANGLE Display::initialize error " << error.getID() << ": "
<< error.getMessage();
ANGLEPlatformCurrent()->logError(errorStream.str().c_str());
return error; return error;
} }
...@@ -527,6 +506,8 @@ void Display::terminate() ...@@ -527,6 +506,8 @@ void Display::terminate()
mInitialized = false; mInitialized = false;
gl::UninitializeDebugAnnotations();
// Never de-init default platform.. terminate is not that final. // Never de-init default platform.. terminate is not that final.
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/LoggingAnnotator.h"
#include "libANGLE/Version.h" #include "libANGLE/Version.h"
namespace gl namespace gl
...@@ -170,6 +171,7 @@ class Display final : angle::NonCopyable ...@@ -170,6 +171,7 @@ class Display final : angle::NonCopyable
Device *mDevice; Device *mDevice;
EGLenum mPlatform; EGLenum mPlatform;
angle::LoggingAnnotator mAnnotator;
}; };
} }
......
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// LoggingAnnotator.cpp: DebugAnnotator implementing logging
//
#include "libANGLE/LoggingAnnotator.h"
#include <platform/Platform.h>
namespace angle
{
void LoggingAnnotator::logMessage(const gl::LogMessage &msg) const
{
angle::Platform *plat = ANGLEPlatformCurrent();
if (plat != nullptr)
{
switch (msg.getSeverity())
{
case gl::LOG_ERR:
plat->logError(msg.getMessage().c_str());
break;
case gl::LOG_WARN:
plat->logWarning(msg.getMessage().c_str());
break;
default:
UNREACHABLE();
}
}
else
{
msg.trace();
}
}
} // namespace angle
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// LoggingAnnotator.h: DebugAnnotator implementing logging
//
#ifndef LIBANGLE_LOGGINGANNOTATOR_H_
#define LIBANGLE_LOGGINGANNOTATOR_H_
#include "common/debug.h"
namespace angle
{
class LoggingAnnotator : public gl::DebugAnnotator
{
public:
LoggingAnnotator(){};
~LoggingAnnotator() override{};
void beginEvent(const wchar_t *eventName) override {}
void endEvent() override {}
void setMarker(const wchar_t *markerName) override {}
bool getStatus() override { return false; }
void logMessage(const gl::LogMessage &msg) const override;
};
} // namespace angle
#endif // LIBANGLE_LOGGINGANNOTATOR_H_
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_DEBUGANNOTATOR11_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D11_DEBUGANNOTATOR11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_DEBUGANNOTATOR11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_DEBUGANNOTATOR11_H_
#include "common/debug.h" #include "libANGLE/LoggingAnnotator.h"
namespace rx namespace rx
{ {
class DebugAnnotator11 : public gl::DebugAnnotator class DebugAnnotator11 : public angle::LoggingAnnotator
{ {
public: public:
DebugAnnotator11(); DebugAnnotator11();
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D9_DEBUGANNOTATOR9_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D9_DEBUGANNOTATOR9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_DEBUGANNOTATOR9_H_ #define LIBANGLE_RENDERER_D3D_D3D9_DEBUGANNOTATOR9_H_
#include "common/debug.h" #include "libANGLE/LoggingAnnotator.h"
namespace rx namespace rx
{ {
class DebugAnnotator9 : public gl::DebugAnnotator class DebugAnnotator9 : public angle::LoggingAnnotator
{ {
public: public:
DebugAnnotator9() {} DebugAnnotator9() {}
......
...@@ -382,7 +382,7 @@ bool FramebufferGL::checkStatus() const ...@@ -382,7 +382,7 @@ bool FramebufferGL::checkStatus() const
GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER); GLenum status = mFunctions->checkFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) if (status != GL_FRAMEBUFFER_COMPLETE)
{ {
ANGLEPlatformCurrent()->logWarning("GL framebuffer returned incomplete."); WARN() << "GL framebuffer returned incomplete.";
} }
return (status == GL_FRAMEBUFFER_COMPLETE); return (status == GL_FRAMEBUFFER_COMPLETE);
} }
......
...@@ -591,8 +591,6 @@ bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog) ...@@ -591,8 +591,6 @@ bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog)
GLint infoLogLength = 0; GLint infoLogLength = 0;
mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
std::string warning;
// Info log length includes the null terminator, so 1 means that the info log is an empty // Info log length includes the null terminator, so 1 means that the info log is an empty
// string. // string.
if (infoLogLength > 1) if (infoLogLength > 1)
...@@ -605,14 +603,12 @@ bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog) ...@@ -605,14 +603,12 @@ bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog)
infoLog << buf.data(); infoLog << buf.data();
warning = FormatString("Program link failed unexpectedly: %s", buf.data()); WARN() << "Program link failed unexpectedly: " << buf.data();
} }
else else
{ {
warning = "Program link failed unexpectedly with no info log."; WARN() << "Program link failed unexpectedly with no info log.";
} }
ANGLEPlatformCurrent()->logWarning(warning.c_str());
WARN() << std::endl << warning;
// TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case
return false; return false;
......
...@@ -93,12 +93,25 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, GLenum type, G ...@@ -93,12 +93,25 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, GLenum type, G
default: severityText = "UNKNOWN"; break; default: severityText = "UNKNOWN"; break;
} }
ERR() << std::endl if (type == GL_DEBUG_TYPE_ERROR)
<< "\tSource: " << sourceText << std::endl {
<< "\tType: " << typeText << std::endl ERR() << std::endl
<< "\tID: " << id << std::endl << "\tSource: " << sourceText << std::endl
<< "\tSeverity: " << severityText << std::endl << "\tType: " << typeText << std::endl
<< "\tMessage: " << message; << "\tID: " << gl::Error(id) << std::endl
<< "\tSeverity: " << severityText << std::endl
<< "\tMessage: " << message;
}
else
{
// TODO(ynovikov): filter into WARN and INFO if INFO is ever implemented
WARN() << std::endl
<< "\tSource: " << sourceText << std::endl
<< "\tType: " << typeText << std::endl
<< "\tID: " << gl::Error(id) << std::endl
<< "\tSeverity: " << severityText << std::endl
<< "\tMessage: " << message;
}
} }
#endif #endif
......
...@@ -584,8 +584,10 @@ GLuint DisplayOzone::makeShader(GLuint type, const char *src) ...@@ -584,8 +584,10 @@ GLuint DisplayOzone::makeShader(GLuint type, const char *src)
gl->getShaderiv(shader, GL_COMPILE_STATUS, &compiled); gl->getShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if (compiled != GL_TRUE) if (compiled != GL_TRUE)
{ {
ANGLEPlatformCurrent()->logError("DisplayOzone shader compilation error:"); // This code is solely for internal debugging of shaders in drawWithTexture(),
ANGLEPlatformCurrent()->logError(buf); // used when putting pixels on screen when running tests on ChromeOS device.
// Error will not propagate beyond ASSERT(linked) there.
ERR() << "DisplayOzone shader compilation error: " << buf;
} }
return shader; return shader;
......
...@@ -346,9 +346,8 @@ egl::Error DisplayWGL::initialize(egl::Display *display) ...@@ -346,9 +346,8 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
mHasRobustness = mFunctionsGL->getGraphicsResetStatus != nullptr; mHasRobustness = mFunctionsGL->getGraphicsResetStatus != nullptr;
if (hasWGLCreateContextRobustness != mHasRobustness) if (hasWGLCreateContextRobustness != mHasRobustness)
{ {
ANGLEPlatformCurrent()->logWarning( WARN() << "WGL_ARB_create_context_robustness exists but unable to OpenGL context with "
"WGL_ARB_create_context_robustness exists but unable to OpenGL context with " "robustness.";
"robustness.");
} }
// Intel OpenGL ES drivers are not currently supported due to bugs in the driver and ANGLE // Intel OpenGL ES drivers are not currently supported due to bugs in the driver and ANGLE
......
...@@ -63,7 +63,7 @@ VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags, ...@@ -63,7 +63,7 @@ VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags,
{ {
if ((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) != 0) if ((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) != 0)
{ {
ANGLEPlatformCurrent()->logError(message); ERR() << message;
#if !defined(NDEBUG) #if !defined(NDEBUG)
// Abort the call in Debug builds. // Abort the call in Debug builds.
return VK_TRUE; return VK_TRUE;
...@@ -71,11 +71,12 @@ VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags, ...@@ -71,11 +71,12 @@ VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags,
} }
else if ((flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) != 0) else if ((flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) != 0)
{ {
ANGLEPlatformCurrent()->logWarning(message); WARN() << message;
} }
else else
{ {
ANGLEPlatformCurrent()->logInfo(message); // Uncomment this if you want Vulkan spam.
// WARN() << message;
} }
return VK_FALSE; return VK_FALSE;
...@@ -162,7 +163,7 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs) ...@@ -162,7 +163,7 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs)
const auto &cwd = angle::GetCWD(); const auto &cwd = angle::GetCWD();
if (!cwd.valid()) if (!cwd.valid())
{ {
ANGLEPlatformCurrent()->logError("Error getting CWD for Vulkan layers init."); ERR() << "Error getting CWD for Vulkan layers init.";
mEnableValidationLayers = false; mEnableValidationLayers = false;
} }
else else
...@@ -202,12 +203,11 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs) ...@@ -202,12 +203,11 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs)
// Generate an error if the attribute was requested, warning otherwise. // Generate an error if the attribute was requested, warning otherwise.
if (attribs.contains(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE)) if (attribs.contains(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE))
{ {
ANGLEPlatformCurrent()->logError("Vulkan standard validation layers are missing."); ERR() << "Vulkan standard validation layers are missing.";
} }
else else
{ {
ANGLEPlatformCurrent()->logWarning( WARN() << "Vulkan standard validation layers are missing.";
"Vulkan standard validation layers are missing.");
} }
mEnableValidationLayers = false; mEnableValidationLayers = false;
} }
...@@ -372,7 +372,7 @@ vk::Error RendererVk::initializeDevice(uint32_t queueFamilyIndex) ...@@ -372,7 +372,7 @@ vk::Error RendererVk::initializeDevice(uint32_t queueFamilyIndex)
{ {
if (!HasStandardValidationLayer(deviceLayerProps)) if (!HasStandardValidationLayer(deviceLayerProps))
{ {
ANGLEPlatformCurrent()->logWarning("Vulkan standard validation layer is missing."); WARN() << "Vulkan standard validation layer is missing.";
mEnableValidationLayers = false; mEnableValidationLayers = false;
} }
} }
......
...@@ -128,6 +128,8 @@ ...@@ -128,6 +128,8 @@
'libANGLE/ImageIndex.cpp', 'libANGLE/ImageIndex.cpp',
'libANGLE/IndexRangeCache.cpp', 'libANGLE/IndexRangeCache.cpp',
'libANGLE/IndexRangeCache.h', 'libANGLE/IndexRangeCache.h',
'libANGLE/LoggingAnnotator.cpp',
'libANGLE/LoggingAnnotator.h',
'libANGLE/Path.h', 'libANGLE/Path.h',
'libANGLE/Path.cpp', 'libANGLE/Path.cpp',
'libANGLE/Platform.cpp', 'libANGLE/Platform.cpp',
......
...@@ -317,6 +317,9 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery) ...@@ -317,6 +317,9 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery)
// eglSwapBuffers, so we must call eglSwapBuffers before we lose the device. // eglSwapBuffers, so we must call eglSwapBuffers before we lose the device.
ASSERT_EGL_TRUE(eglSwapBuffers(mDisplay, mSurface)); ASSERT_EGL_TRUE(eglSwapBuffers(mDisplay, mSurface));
// Ignore expected error messages
IgnoreANGLEPlatformMessages();
// Trigger a lost device // Trigger a lost device
trigger9_3DeviceLost(); trigger9_3DeviceLost();
...@@ -334,6 +337,9 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery) ...@@ -334,6 +337,9 @@ TEST_F(EGLDeviceCreationTest, D3D11DeviceRecovery)
ASSERT_EQ(EGL_NO_SURFACE, mSurface); ASSERT_EQ(EGL_NO_SURFACE, mSurface);
ASSERT_EGL_ERROR(EGL_BAD_ALLOC); 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. // Get the D3D11 device out of the EGLDisplay again. It should be the same one as above.
EGLAttrib device = 0; EGLAttrib device = 0;
EGLAttrib newEglDevice = 0; EGLAttrib newEglDevice = 0;
......
...@@ -267,7 +267,7 @@ ANGLETest::~ANGLETest() ...@@ -267,7 +267,7 @@ ANGLETest::~ANGLETest()
void ANGLETest::SetUp() void ANGLETest::SetUp()
{ {
angle::g_testPlatformInstance.enableMessages(); EnableANGLEPlatformMessages();
angle::g_testPlatformInstance.setCurrentTest(this); angle::g_testPlatformInstance.setCurrentTest(this);
// Resize the window before creating the context so that the first make current // Resize the window before creating the context so that the first make current
...@@ -967,3 +967,8 @@ void IgnoreANGLEPlatformMessages() ...@@ -967,3 +967,8 @@ void IgnoreANGLEPlatformMessages()
// Negative tests may trigger expected errors/warnings in the ANGLE Platform. // Negative tests may trigger expected errors/warnings in the ANGLE Platform.
angle::g_testPlatformInstance.ignoreMessages(); angle::g_testPlatformInstance.ignoreMessages();
} }
void EnableANGLEPlatformMessages()
{
angle::g_testPlatformInstance.enableMessages();
}
...@@ -304,6 +304,7 @@ bool IsRelease(); ...@@ -304,6 +304,7 @@ bool IsRelease();
// Negative tests may trigger expected errors/warnings in the ANGLE Platform. // Negative tests may trigger expected errors/warnings in the ANGLE Platform.
void IgnoreANGLEPlatformMessages(); void IgnoreANGLEPlatformMessages();
void EnableANGLEPlatformMessages();
// Note: git cl format messes up this formatting. // Note: git cl format messes up this formatting.
#define ANGLE_SKIP_TEST_IF(COND) \ #define ANGLE_SKIP_TEST_IF(COND) \
......
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