Commit 70d0f499 by Geoff Lang

Implement GL_KHR_debug.

BUG=angleproject:520 Change-Id: I9ced3e7ab1515feddf2ec103c26b2610a45b1784 Reviewed-on: https://chromium-review.googlesource.com/319830 Tryjob-Request: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 74b92323
...@@ -17,6 +17,7 @@ namespace gl ...@@ -17,6 +17,7 @@ namespace gl
Buffer::Buffer(rx::BufferImpl *impl, GLuint id) Buffer::Buffer(rx::BufferImpl *impl, GLuint id)
: RefCountObject(id), : RefCountObject(id),
mLabel(),
mBuffer(impl), mBuffer(impl),
mUsage(GL_STATIC_DRAW), mUsage(GL_STATIC_DRAW),
mSize(0), mSize(0),
...@@ -34,6 +35,16 @@ Buffer::~Buffer() ...@@ -34,6 +35,16 @@ Buffer::~Buffer()
SafeDelete(mBuffer); SafeDelete(mBuffer);
} }
void Buffer::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Buffer::getLabel() const
{
return mLabel;
}
Error Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage) Error Buffer::bufferData(const void *data, GLsizeiptr size, GLenum usage)
{ {
gl::Error error = mBuffer->setData(data, size, usage); gl::Error error = mBuffer->setData(data, size, usage);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define LIBANGLE_BUFFER_H_ #define LIBANGLE_BUFFER_H_
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/IndexRangeCache.h" #include "libANGLE/IndexRangeCache.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
...@@ -24,13 +25,15 @@ class BufferImpl; ...@@ -24,13 +25,15 @@ class BufferImpl;
namespace gl namespace gl
{ {
class Buffer : public RefCountObject class Buffer final : public RefCountObject, public LabeledObject
{ {
public: public:
Buffer(rx::BufferImpl *impl, GLuint id); Buffer(rx::BufferImpl *impl, GLuint id);
virtual ~Buffer(); virtual ~Buffer();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
Error bufferData(const void *data, GLsizeiptr size, GLenum usage); Error bufferData(const void *data, GLsizeiptr size, GLenum usage);
Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset); Error bufferSubData(const void *data, GLsizeiptr size, GLintptr offset);
Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); Error copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
...@@ -61,6 +64,8 @@ class Buffer : public RefCountObject ...@@ -61,6 +64,8 @@ class Buffer : public RefCountObject
private: private:
rx::BufferImpl *mBuffer; rx::BufferImpl *mBuffer;
std::string mLabel;
GLenum mUsage; GLenum mUsage;
GLint64 mSize; GLint64 mSize;
GLbitfield mAccessFlags; GLbitfield mAccessFlags;
......
...@@ -148,6 +148,10 @@ Extensions::Extensions() ...@@ -148,6 +148,10 @@ Extensions::Extensions()
packSubimage(false), packSubimage(false),
vertexArrayObject(false), vertexArrayObject(false),
debug(false), debug(false),
maxDebugMessageLength(0),
maxDebugLoggedMessages(0),
maxDebugGroupStackDepth(0),
maxLabelLength(0),
colorBufferFloat(false) colorBufferFloat(false)
{ {
} }
......
...@@ -262,6 +262,10 @@ struct Extensions ...@@ -262,6 +262,10 @@ struct Extensions
// GL_KHR_debug // GL_KHR_debug
bool debug; bool debug;
GLuint maxDebugMessageLength;
GLuint maxDebugLoggedMessages;
GLuint maxDebugGroupStackDepth;
GLuint maxLabelLength;
// ES3 Extension support // ES3 Extension support
......
...@@ -62,7 +62,8 @@ Context::Context(const egl::Config *config, ...@@ -62,7 +62,8 @@ Context::Context(const egl::Config *config,
const Context *shareContext, const Context *shareContext,
rx::Renderer *renderer, rx::Renderer *renderer,
bool notifyResets, bool notifyResets,
bool robustAccess) bool robustAccess,
bool debug)
: ValidationContext(clientVersion, : ValidationContext(clientVersion,
mState, mState,
mCaps, mCaps,
...@@ -77,7 +78,7 @@ Context::Context(const egl::Config *config, ...@@ -77,7 +78,7 @@ Context::Context(const egl::Config *config,
ASSERT(robustAccess == false); // Unimplemented ASSERT(robustAccess == false); // Unimplemented
initCaps(clientVersion); initCaps(clientVersion);
mState.initialize(mCaps, clientVersion); mState.initialize(mCaps, mExtensions, clientVersion, debug);
mClientVersion = clientVersion; mClientVersion = clientVersion;
...@@ -503,7 +504,7 @@ void Context::deleteQuery(GLuint query) ...@@ -503,7 +504,7 @@ void Context::deleteQuery(GLuint query)
} }
} }
Buffer *Context::getBuffer(GLuint handle) Buffer *Context::getBuffer(GLuint handle) const
{ {
return mResourceManager->getBuffer(handle); return mResourceManager->getBuffer(handle);
} }
...@@ -523,7 +524,7 @@ Texture *Context::getTexture(GLuint handle) const ...@@ -523,7 +524,7 @@ Texture *Context::getTexture(GLuint handle) const
return mResourceManager->getTexture(handle); return mResourceManager->getTexture(handle);
} }
Renderbuffer *Context::getRenderbuffer(GLuint handle) Renderbuffer *Context::getRenderbuffer(GLuint handle) const
{ {
return mResourceManager->getRenderbuffer(handle); return mResourceManager->getRenderbuffer(handle);
} }
...@@ -550,6 +551,41 @@ TransformFeedback *Context::getTransformFeedback(GLuint handle) const ...@@ -550,6 +551,41 @@ TransformFeedback *Context::getTransformFeedback(GLuint handle) const
return (iter != mTransformFeedbackMap.end()) ? iter->second : nullptr; return (iter != mTransformFeedbackMap.end()) ? iter->second : nullptr;
} }
LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const
{
switch (identifier)
{
case GL_BUFFER:
return getBuffer(name);
case GL_SHADER:
return getShader(name);
case GL_PROGRAM:
return getProgram(name);
case GL_VERTEX_ARRAY:
return getVertexArray(name);
case GL_QUERY:
return getQuery(name);
case GL_TRANSFORM_FEEDBACK:
return getTransformFeedback(name);
case GL_SAMPLER:
return getSampler(name);
case GL_TEXTURE:
return getTexture(name);
case GL_RENDERBUFFER:
return getRenderbuffer(name);
case GL_FRAMEBUFFER:
return getFramebuffer(name);
default:
UNREACHABLE();
return nullptr;
}
}
LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const
{
return getFenceSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr)));
}
bool Context::isSampler(GLuint samplerName) const bool Context::isSampler(GLuint samplerName) const
{ {
return mResourceManager->isSampler(samplerName); return mResourceManager->isSampler(samplerName);
...@@ -776,6 +812,12 @@ Query *Context::getQuery(unsigned int handle, bool create, GLenum type) ...@@ -776,6 +812,12 @@ Query *Context::getQuery(unsigned int handle, bool create, GLenum type)
} }
} }
Query *Context::getQuery(GLuint handle) const
{
auto iter = mQueryMap.find(handle);
return (iter != mQueryMap.end()) ? iter->second : nullptr;
}
Texture *Context::getTargetTexture(GLenum target) const Texture *Context::getTargetTexture(GLenum target) const
{ {
ASSERT(ValidTextureTarget(this, target)); ASSERT(ValidTextureTarget(this, target));
...@@ -905,6 +947,21 @@ void Context::getIntegerv(GLenum pname, GLint *params) ...@@ -905,6 +947,21 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_NUM_EXTENSIONS: case GL_NUM_EXTENSIONS:
*params = static_cast<GLint>(mExtensionStrings.size()); *params = static_cast<GLint>(mExtensionStrings.size());
break; break;
// GL_KHR_debug
case GL_MAX_DEBUG_MESSAGE_LENGTH:
*params = mExtensions.maxDebugMessageLength;
break;
case GL_MAX_DEBUG_LOGGED_MESSAGES:
*params = mExtensions.maxDebugLoggedMessages;
break;
case GL_MAX_DEBUG_GROUP_STACK_DEPTH:
*params = mExtensions.maxDebugGroupStackDepth;
break;
case GL_MAX_LABEL_LENGTH:
*params = mExtensions.maxLabelLength;
break;
default: default:
mState.getIntegerv(getData(), pname, params); mState.getIntegerv(getData(), pname, params);
break; break;
...@@ -938,6 +995,11 @@ void Context::getInteger64v(GLenum pname, GLint64 *params) ...@@ -938,6 +995,11 @@ void Context::getInteger64v(GLenum pname, GLint64 *params)
} }
} }
void Context::getPointerv(GLenum pname, void **params) const
{
mState.getPointerv(pname, params);
}
bool Context::getIndexedIntegerv(GLenum target, GLuint index, GLint *data) bool Context::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
{ {
// Queries about context capabilities and maximums are answered by Context. // Queries about context capabilities and maximums are answered by Context.
...@@ -1149,6 +1211,29 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -1149,6 +1211,29 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
return true; return true;
} }
if (mExtensions.debug)
{
switch (pname)
{
case GL_DEBUG_LOGGED_MESSAGES:
case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
case GL_DEBUG_GROUP_STACK_DEPTH:
case GL_MAX_DEBUG_MESSAGE_LENGTH:
case GL_MAX_DEBUG_LOGGED_MESSAGES:
case GL_MAX_DEBUG_GROUP_STACK_DEPTH:
case GL_MAX_LABEL_LENGTH:
*type = GL_INT;
*numParams = 1;
return true;
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
case GL_DEBUG_OUTPUT:
*type = GL_BOOL;
*numParams = 1;
return true;
}
}
// Check for ES3.0+ parameter names which are also exposed as ES2 extensions // Check for ES3.0+ parameter names which are also exposed as ES2 extensions
switch (pname) switch (pname)
{ {
...@@ -1393,6 +1478,13 @@ void Context::recordError(const Error &error) ...@@ -1393,6 +1478,13 @@ void Context::recordError(const Error &error)
if (error.isError()) if (error.isError())
{ {
mErrors.insert(error.getCode()); mErrors.insert(error.getCode());
if (!error.getMessage().empty())
{
auto &debug = mState.getDebug();
debug.insertMessage(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_ERROR, error.getID(),
GL_DEBUG_SEVERITY_HIGH, error.getMessage());
}
} }
} }
...@@ -1740,6 +1832,13 @@ void Context::initCaps(GLuint clientVersion) ...@@ -1740,6 +1832,13 @@ void Context::initCaps(GLuint clientVersion)
//mExtensions.sRGB = false; //mExtensions.sRGB = false;
} }
// Explicitly enable GL_KHR_debug
mExtensions.debug = true;
mExtensions.maxDebugMessageLength = 1024;
mExtensions.maxDebugLoggedMessages = 1024;
mExtensions.maxDebugGroupStackDepth = 1024;
mExtensions.maxLabelLength = 1024;
// Apply implementation limits // Apply implementation limits
mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS); mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS);
mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS); mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS);
......
...@@ -58,7 +58,13 @@ class TransformFeedback; ...@@ -58,7 +58,13 @@ class TransformFeedback;
class Context final : public ValidationContext class Context final : public ValidationContext
{ {
public: public:
Context(const egl::Config *config, int clientVersion, const Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess); Context(const egl::Config *config,
int clientVersion,
const Context *shareContext,
rx::Renderer *renderer,
bool notifyResets,
bool robustAccess,
bool debug);
virtual ~Context(); virtual ~Context();
...@@ -133,18 +139,21 @@ class Context final : public ValidationContext ...@@ -133,18 +139,21 @@ class Context final : public ValidationContext
GLint getSamplerParameteri(GLuint sampler, GLenum pname); GLint getSamplerParameteri(GLuint sampler, GLenum pname);
GLfloat getSamplerParameterf(GLuint sampler, GLenum pname); GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
Buffer *getBuffer(GLuint handle); Buffer *getBuffer(GLuint handle) const;
FenceNV *getFenceNV(GLuint handle); FenceNV *getFenceNV(GLuint handle);
FenceSync *getFenceSync(GLsync handle) const; FenceSync *getFenceSync(GLsync handle) const;
Shader *getShader(GLuint handle) const; Shader *getShader(GLuint handle) const;
Program *getProgram(GLuint handle) const; Program *getProgram(GLuint handle) const;
Texture *getTexture(GLuint handle) const; Texture *getTexture(GLuint handle) const;
Framebuffer *getFramebuffer(GLuint handle) const; Framebuffer *getFramebuffer(GLuint handle) const;
Renderbuffer *getRenderbuffer(GLuint handle); Renderbuffer *getRenderbuffer(GLuint handle) const;
VertexArray *getVertexArray(GLuint handle) const; VertexArray *getVertexArray(GLuint handle) const;
Sampler *getSampler(GLuint handle) const; Sampler *getSampler(GLuint handle) const;
Query *getQuery(GLuint handle, bool create, GLenum type); Query *getQuery(GLuint handle, bool create, GLenum type);
Query *getQuery(GLuint handle) const;
TransformFeedback *getTransformFeedback(GLuint handle) const; TransformFeedback *getTransformFeedback(GLuint handle) const;
LabeledObject *getLabeledObject(GLenum identifier, GLuint name) const;
LabeledObject *getLabeledObjectFromPtr(const void *ptr) const;
Texture *getTargetTexture(GLenum target) const; Texture *getTargetTexture(GLenum target) const;
Texture *getSamplerTexture(unsigned int sampler, GLenum type) const; Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
...@@ -160,6 +169,7 @@ class Context final : public ValidationContext ...@@ -160,6 +169,7 @@ class Context final : public ValidationContext
void getFloatv(GLenum pname, GLfloat *params); void getFloatv(GLenum pname, GLfloat *params);
void getIntegerv(GLenum pname, GLint *params); void getIntegerv(GLenum pname, GLint *params);
void getInteger64v(GLenum pname, GLint64 *params); void getInteger64v(GLenum pname, GLint64 *params);
void getPointerv(GLenum pname, void **params) const;
bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data); bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data); bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
......
//
// Copyright (c) 2015 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.
//
// Debug.cpp: Defines debug state used for GL_KHR_debug
#include "libANGLE/Debug.h"
#include "common/debug.h"
#include <algorithm>
#include <tuple>
namespace gl
{
Debug::Debug()
: mOutputEnabled(false),
mCallbackFunction(nullptr),
mCallbackUserParam(nullptr),
mMessages(),
mMaxLoggedMessages(0),
mOutputSynchronous(false),
mGroups()
{
pushDefaultGroup();
}
void Debug::setMaxLoggedMessages(GLuint maxLoggedMessages)
{
mMaxLoggedMessages = maxLoggedMessages;
}
void Debug::setOutputEnabled(bool enabled)
{
mOutputEnabled = enabled;
}
bool Debug::isOutputEnabled() const
{
return mOutputEnabled;
}
void Debug::setOutputSynchronous(bool synchronous)
{
mOutputSynchronous = synchronous;
}
bool Debug::isOutputSynchronous() const
{
return mOutputSynchronous;
}
void Debug::setCallback(GLDEBUGPROCKHR callback, const void *userParam)
{
mCallbackFunction = callback;
mCallbackUserParam = userParam;
}
GLDEBUGPROCKHR Debug::getCallback() const
{
return mCallbackFunction;
}
const void *Debug::getUserParam() const
{
return mCallbackUserParam;
}
void Debug::insertMessage(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
const std::string &message)
{
std::string messageCopy(message);
insertMessage(source, type, id, severity, std::move(messageCopy));
}
void Debug::insertMessage(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
std::string &&message)
{
if (!isMessageEnabled(source, type, id, severity))
{
return;
}
if (mCallbackFunction != nullptr)
{
// TODO(geofflang) Check the synchronous flag and potentially flush messages from another
// thread.
mCallbackFunction(source, type, id, severity, static_cast<GLsizei>(message.length()),
message.c_str(), mCallbackUserParam);
}
else
{
if (mMessages.size() >= mMaxLoggedMessages)
{
// Drop messages over the limit
return;
}
Message m;
m.source = source;
m.type = type;
m.id = id;
m.severity = severity;
m.message = std::move(message);
mMessages.push_back(std::move(m));
}
}
size_t Debug::getMessages(GLuint count,
GLsizei bufSize,
GLenum *sources,
GLenum *types,
GLuint *ids,
GLenum *severities,
GLsizei *lengths,
GLchar *messageLog)
{
size_t messageCount = 0;
size_t messageStringIndex = 0;
while (messageCount <= count && !mMessages.empty())
{
const Message &m = mMessages.front();
if (messageLog != nullptr)
{
// Check that this message can fit in the message buffer
if (messageStringIndex + m.message.length() + 1 > static_cast<size_t>(bufSize))
{
break;
}
std::copy(m.message.begin(), m.message.end(), messageLog + messageStringIndex);
messageStringIndex += m.message.length();
messageLog[messageStringIndex] = '\0';
messageStringIndex += 1;
}
if (sources != nullptr)
{
sources[messageCount] = m.source;
}
if (types != nullptr)
{
types[messageCount] = m.type;
}
if (ids != nullptr)
{
ids[messageCount] = m.id;
}
if (severities != nullptr)
{
severities[messageCount] = m.severity;
}
if (lengths != nullptr)
{
lengths[messageCount] = static_cast<GLsizei>(m.message.length());
}
mMessages.pop_front();
messageCount++;
}
return messageCount;
}
size_t Debug::getNextMessageLength() const
{
return mMessages.empty() ? 0 : mMessages.front().message.length();
}
size_t Debug::getMessageCount() const
{
return mMessages.size();
}
void Debug::setMessageControl(GLenum source,
GLenum type,
GLenum severity,
std::vector<GLuint> &&ids,
bool enabled)
{
Control c;
c.source = source;
c.type = type;
c.severity = severity;
c.ids = std::move(ids);
c.enabled = enabled;
auto &controls = mGroups.back().controls;
controls.push_back(std::move(c));
}
void Debug::pushGroup(GLenum source, GLuint id, std::string &&message)
{
insertMessage(source, GL_DEBUG_TYPE_PUSH_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION,
std::string(message));
Group g;
g.source = source;
g.id = id;
g.message = std::move(message);
mGroups.push_back(std::move(g));
}
void Debug::popGroup()
{
// Make sure the default group is not about to be popped
ASSERT(mGroups.size() > 1);
Group g = mGroups.back();
mGroups.pop_back();
insertMessage(g.source, GL_DEBUG_TYPE_POP_GROUP, g.id, GL_DEBUG_SEVERITY_NOTIFICATION,
g.message);
}
size_t Debug::getGroupStackDepth() const
{
return mGroups.size();
}
bool Debug::isMessageEnabled(GLenum source, GLenum type, GLuint id, GLenum severity) const
{
if (!mOutputEnabled)
{
return false;
}
for (auto groupIter = mGroups.rbegin(); groupIter != mGroups.rend(); groupIter++)
{
const auto &controls = groupIter->controls;
for (auto controlIter = controls.rbegin(); controlIter != controls.rend(); controlIter++)
{
const auto &control = *controlIter;
if (control.source != GL_DONT_CARE && control.source != source)
{
continue;
}
if (control.type != GL_DONT_CARE && control.type != type)
{
continue;
}
if (control.severity != GL_DONT_CARE && control.severity != severity)
{
continue;
}
if (!control.ids.empty() &&
std::find(control.ids.begin(), control.ids.end(), id) == control.ids.end())
{
continue;
}
return control.enabled;
}
}
return true;
}
void Debug::pushDefaultGroup()
{
Group g;
g.source = GL_NONE;
g.id = 0;
g.message = "";
Control c0;
c0.source = GL_DONT_CARE;
c0.type = GL_DONT_CARE;
c0.severity = GL_DONT_CARE;
c0.enabled = true;
g.controls.push_back(std::move(c0));
Control c1;
c1.source = GL_DONT_CARE;
c1.type = GL_DONT_CARE;
c1.severity = GL_DEBUG_SEVERITY_LOW;
c1.enabled = false;
g.controls.push_back(std::move(c1));
mGroups.push_back(std::move(g));
}
} // namespace gl
//
// Copyright (c) 2015 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.
//
// Debug.h: Defines debug state used for GL_KHR_debug
#ifndef LIBANGLE_DEBUG_H_
#define LIBANGLE_DEBUG_H_
#include "angle_gl.h"
#include "common/angleutils.h"
#include <deque>
#include <string>
#include <vector>
namespace gl
{
class LabeledObject
{
public:
virtual void setLabel(const std::string &label) = 0;
virtual const std::string &getLabel() const = 0;
};
class Debug : angle::NonCopyable
{
public:
Debug();
void setMaxLoggedMessages(GLuint maxLoggedMessages);
void setOutputEnabled(bool enabled);
bool isOutputEnabled() const;
void setOutputSynchronous(bool synchronous);
bool isOutputSynchronous() const;
void setCallback(GLDEBUGPROCKHR callback, const void *userParam);
GLDEBUGPROCKHR getCallback() const;
const void *getUserParam() const;
void insertMessage(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
const std::string &message);
void insertMessage(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
std::string &&message);
void setMessageControl(GLenum source,
GLenum type,
GLenum severity,
std::vector<GLuint> &&ids,
bool enabled);
size_t getMessages(GLuint count,
GLsizei bufSize,
GLenum *sources,
GLenum *types,
GLuint *ids,
GLenum *severities,
GLsizei *lengths,
GLchar *messageLog);
size_t getNextMessageLength() const;
size_t getMessageCount() const;
void pushGroup(GLenum source, GLuint id, std::string &&message);
void popGroup();
size_t getGroupStackDepth() const;
private:
bool isMessageEnabled(GLenum source, GLenum type, GLuint id, GLenum severity) const;
void pushDefaultGroup();
struct Message
{
GLenum source;
GLenum type;
GLuint id;
GLenum severity;
std::string message;
};
struct Control
{
GLenum source;
GLenum type;
GLenum severity;
std::vector<GLuint> ids;
bool enabled;
};
struct Group
{
GLenum source;
GLuint id;
std::string message;
std::vector<Control> controls;
};
bool mOutputEnabled;
GLDEBUGPROCKHR mCallbackFunction;
const void *mCallbackUserParam;
std::deque<Message> mMessages;
GLuint mMaxLoggedMessages;
bool mOutputSynchronous;
std::vector<Group> mGroups;
};
} // namespace gl
#endif // LIBANGLE_DEBUG_H_
...@@ -17,8 +17,17 @@ namespace gl ...@@ -17,8 +17,17 @@ namespace gl
{ {
Error::Error(GLenum errorCode, const char *msg, ...) Error::Error(GLenum errorCode, const char *msg, ...)
: mCode(errorCode), : mCode(errorCode), mID(errorCode), mMessage(nullptr)
mMessage(nullptr) {
va_list vararg;
va_start(vararg, msg);
createMessageString();
*mMessage = FormatString(msg, vararg);
va_end(vararg);
}
Error::Error(GLenum errorCode, GLuint id, const char *msg, ...)
: mCode(errorCode), mID(id), mMessage(nullptr)
{ {
va_list vararg; va_list vararg;
va_start(vararg, msg); va_start(vararg, msg);
......
...@@ -22,6 +22,7 @@ class Error final ...@@ -22,6 +22,7 @@ class Error final
public: public:
explicit inline Error(GLenum errorCode); explicit inline Error(GLenum errorCode);
Error(GLenum errorCode, const char *msg, ...); Error(GLenum errorCode, const char *msg, ...);
Error(GLenum errorCode, GLuint id, const char *msg, ...);
inline Error(const Error &other); inline Error(const Error &other);
inline Error(Error &&other); inline Error(Error &&other);
...@@ -31,6 +32,7 @@ class Error final ...@@ -31,6 +32,7 @@ class Error final
inline Error &operator=(Error &&other); inline Error &operator=(Error &&other);
inline GLenum getCode() const; inline GLenum getCode() const;
inline GLuint getID() const;
inline bool isError() const; inline bool isError() const;
const std::string &getMessage() const; const std::string &getMessage() const;
...@@ -43,6 +45,7 @@ class Error final ...@@ -43,6 +45,7 @@ class Error final
void createMessageString() const; void createMessageString() const;
GLenum mCode; GLenum mCode;
GLuint mID;
mutable std::string *mMessage; mutable std::string *mMessage;
}; };
......
...@@ -15,12 +15,14 @@ namespace gl ...@@ -15,12 +15,14 @@ namespace gl
Error::Error(GLenum errorCode) Error::Error(GLenum errorCode)
: mCode(errorCode), : mCode(errorCode),
mID(errorCode),
mMessage(nullptr) mMessage(nullptr)
{ {
} }
Error::Error(const Error &other) Error::Error(const Error &other)
: mCode(other.mCode), : mCode(other.mCode),
mID(other.mID),
mMessage(nullptr) mMessage(nullptr)
{ {
if (other.mMessage != nullptr) if (other.mMessage != nullptr)
...@@ -32,6 +34,7 @@ Error::Error(const Error &other) ...@@ -32,6 +34,7 @@ Error::Error(const Error &other)
Error::Error(Error &&other) Error::Error(Error &&other)
: mCode(other.mCode), : mCode(other.mCode),
mID(other.mID),
mMessage(other.mMessage) mMessage(other.mMessage)
{ {
other.mMessage = nullptr; other.mMessage = nullptr;
...@@ -45,6 +48,7 @@ Error::~Error() ...@@ -45,6 +48,7 @@ Error::~Error()
Error &Error::operator=(const Error &other) Error &Error::operator=(const Error &other)
{ {
mCode = other.mCode; mCode = other.mCode;
mID = other.mID;
if (other.mMessage != nullptr) if (other.mMessage != nullptr)
{ {
...@@ -62,6 +66,7 @@ Error &Error::operator=(const Error &other) ...@@ -62,6 +66,7 @@ Error &Error::operator=(const Error &other)
Error &Error::operator=(Error &&other) Error &Error::operator=(Error &&other)
{ {
mCode = other.mCode; mCode = other.mCode;
mID = other.mID;
mMessage = other.mMessage; mMessage = other.mMessage;
other.mMessage = nullptr; other.mMessage = nullptr;
...@@ -74,6 +79,11 @@ GLenum Error::getCode() const ...@@ -74,6 +79,11 @@ GLenum Error::getCode() const
return mCode; return mCode;
} }
GLuint Error::getID() const
{
return mID;
}
bool Error::isError() const bool Error::isError() const
{ {
return (mCode != GL_NO_ERROR); return (mCode != GL_NO_ERROR);
......
...@@ -76,10 +76,7 @@ Error FenceNV::finish() ...@@ -76,10 +76,7 @@ Error FenceNV::finish()
} }
FenceSync::FenceSync(rx::FenceSyncImpl *impl, GLuint id) FenceSync::FenceSync(rx::FenceSyncImpl *impl, GLuint id)
: RefCountObject(id), : RefCountObject(id), mFence(impl), mLabel(), mCondition(GL_NONE), mFlags(0)
mFence(impl),
mCondition(GL_NONE),
mFlags(0)
{ {
} }
...@@ -88,6 +85,16 @@ FenceSync::~FenceSync() ...@@ -88,6 +85,16 @@ FenceSync::~FenceSync()
SafeDelete(mFence); SafeDelete(mFence);
} }
void FenceSync::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &FenceSync::getLabel() const
{
return mLabel;
}
Error FenceSync::set(GLenum condition, GLbitfield flags) Error FenceSync::set(GLenum condition, GLbitfield flags)
{ {
Error error = mFence->set(condition, flags); Error error = mFence->set(condition, flags);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#ifndef LIBANGLE_FENCE_H_ #ifndef LIBANGLE_FENCE_H_
#define LIBANGLE_FENCE_H_ #define LIBANGLE_FENCE_H_
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
...@@ -47,12 +48,15 @@ class FenceNV final : angle::NonCopyable ...@@ -47,12 +48,15 @@ class FenceNV final : angle::NonCopyable
GLenum mCondition; GLenum mCondition;
}; };
class FenceSync final : public RefCountObject class FenceSync final : public RefCountObject, public LabeledObject
{ {
public: public:
explicit FenceSync(rx::FenceSyncImpl *impl, GLuint id); FenceSync(rx::FenceSyncImpl *impl, GLuint id);
virtual ~FenceSync(); virtual ~FenceSync();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
Error set(GLenum condition, GLbitfield flags); Error set(GLenum condition, GLbitfield flags);
Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult); Error clientWait(GLbitfield flags, GLuint64 timeout, GLenum *outResult);
Error serverWait(GLbitfield flags, GLuint64 timeout); Error serverWait(GLbitfield flags, GLuint64 timeout);
...@@ -64,6 +68,8 @@ class FenceSync final : public RefCountObject ...@@ -64,6 +68,8 @@ class FenceSync final : public RefCountObject
private: private:
rx::FenceSyncImpl *mFence; rx::FenceSyncImpl *mFence;
std::string mLabel;
GLenum mCondition; GLenum mCondition;
GLbitfield mFlags; GLbitfield mFlags;
}; };
......
...@@ -40,7 +40,8 @@ void DetachMatchingAttachment(FramebufferAttachment *attachment, GLenum matchTyp ...@@ -40,7 +40,8 @@ void DetachMatchingAttachment(FramebufferAttachment *attachment, GLenum matchTyp
} }
Framebuffer::Data::Data() Framebuffer::Data::Data()
: mColorAttachments(1), : mLabel(),
mColorAttachments(1),
mDrawBufferStates(1, GL_NONE), mDrawBufferStates(1, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT) mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
{ {
...@@ -48,7 +49,8 @@ Framebuffer::Data::Data() ...@@ -48,7 +49,8 @@ Framebuffer::Data::Data()
} }
Framebuffer::Data::Data(const Caps &caps) Framebuffer::Data::Data(const Caps &caps)
: mColorAttachments(caps.maxColorAttachments), : mLabel(),
mColorAttachments(caps.maxColorAttachments),
mDrawBufferStates(caps.maxDrawBuffers, GL_NONE), mDrawBufferStates(caps.maxDrawBuffers, GL_NONE),
mReadBufferState(GL_COLOR_ATTACHMENT0_EXT) mReadBufferState(GL_COLOR_ATTACHMENT0_EXT)
{ {
...@@ -59,6 +61,11 @@ Framebuffer::Data::~Data() ...@@ -59,6 +61,11 @@ Framebuffer::Data::~Data()
{ {
} }
const std::string &Framebuffer::Data::getLabel()
{
return mLabel;
}
const FramebufferAttachment *Framebuffer::Data::getReadAttachment() const const FramebufferAttachment *Framebuffer::Data::getReadAttachment() const
{ {
ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15)); ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15));
...@@ -179,6 +186,16 @@ Framebuffer::~Framebuffer() ...@@ -179,6 +186,16 @@ Framebuffer::~Framebuffer()
SafeDelete(mImpl); SafeDelete(mImpl);
} }
void Framebuffer::setLabel(const std::string &label)
{
mData.mLabel = label;
}
const std::string &Framebuffer::getLabel() const
{
return mData.mLabel;
}
void Framebuffer::detachTexture(GLuint textureId) void Framebuffer::detachTexture(GLuint textureId)
{ {
detachResourceById(GL_TEXTURE, textureId); detachResourceById(GL_TEXTURE, textureId);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Constants.h" #include "libANGLE/Constants.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
...@@ -44,7 +45,7 @@ struct Extensions; ...@@ -44,7 +45,7 @@ struct Extensions;
struct ImageIndex; struct ImageIndex;
struct Rectangle; struct Rectangle;
class Framebuffer class Framebuffer final : public LabeledObject
{ {
public: public:
...@@ -55,6 +56,8 @@ class Framebuffer ...@@ -55,6 +56,8 @@ class Framebuffer
explicit Data(const Caps &caps); explicit Data(const Caps &caps);
~Data(); ~Data();
const std::string &getLabel();
const FramebufferAttachment *getReadAttachment() const; const FramebufferAttachment *getReadAttachment() const;
const FramebufferAttachment *getFirstColorAttachment() const; const FramebufferAttachment *getFirstColorAttachment() const;
const FramebufferAttachment *getDepthOrStencilAttachment() const; const FramebufferAttachment *getDepthOrStencilAttachment() const;
...@@ -71,6 +74,8 @@ class Framebuffer ...@@ -71,6 +74,8 @@ class Framebuffer
private: private:
friend class Framebuffer; friend class Framebuffer;
std::string mLabel;
std::vector<FramebufferAttachment> mColorAttachments; std::vector<FramebufferAttachment> mColorAttachments;
FramebufferAttachment mDepthAttachment; FramebufferAttachment mDepthAttachment;
FramebufferAttachment mStencilAttachment; FramebufferAttachment mStencilAttachment;
...@@ -83,6 +88,9 @@ class Framebuffer ...@@ -83,6 +88,9 @@ class Framebuffer
Framebuffer(rx::SurfaceImpl *surface); Framebuffer(rx::SurfaceImpl *surface);
virtual ~Framebuffer(); virtual ~Framebuffer();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
const rx::FramebufferImpl *getImplementation() const { return mImpl; } const rx::FramebufferImpl *getImplementation() const { return mImpl; }
rx::FramebufferImpl *getImplementation() { return mImpl; } rx::FramebufferImpl *getImplementation() { return mImpl; }
......
...@@ -223,7 +223,8 @@ VariableLocation::VariableLocation(const std::string &name, unsigned int element ...@@ -223,7 +223,8 @@ VariableLocation::VariableLocation(const std::string &name, unsigned int element
} }
Program::Data::Data() Program::Data::Data()
: mAttachedFragmentShader(nullptr), : mLabel(),
mAttachedFragmentShader(nullptr),
mAttachedVertexShader(nullptr), mAttachedVertexShader(nullptr),
mTransformFeedbackBufferMode(GL_INTERLEAVED_ATTRIBS), mTransformFeedbackBufferMode(GL_INTERLEAVED_ATTRIBS),
mBinaryRetrieveableHint(false) mBinaryRetrieveableHint(false)
...@@ -243,6 +244,11 @@ Program::Data::~Data() ...@@ -243,6 +244,11 @@ Program::Data::~Data()
} }
} }
const std::string &Program::Data::getLabel()
{
return mLabel;
}
const LinkedUniform *Program::Data::getUniformByName(const std::string &name) const const LinkedUniform *Program::Data::getUniformByName(const std::string &name) const
{ {
for (const LinkedUniform &linkedUniform : mUniforms) for (const LinkedUniform &linkedUniform : mUniforms)
...@@ -328,6 +334,16 @@ Program::~Program() ...@@ -328,6 +334,16 @@ Program::~Program()
SafeDelete(mProgram); SafeDelete(mProgram);
} }
void Program::setLabel(const std::string &label)
{
mData.mLabel = label;
}
const std::string &Program::getLabel() const
{
return mData.mLabel;
}
bool Program::attachShader(Shader *shader) bool Program::attachShader(Shader *shader)
{ {
if (shader->getType() == GL_VERTEX_SHADER) if (shader->getType() == GL_VERTEX_SHADER)
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/Constants.h" #include "libANGLE/Constants.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
...@@ -143,7 +144,7 @@ struct VariableLocation ...@@ -143,7 +144,7 @@ struct VariableLocation
unsigned int index; unsigned int index;
}; };
class Program : angle::NonCopyable class Program final : angle::NonCopyable, public LabeledObject
{ {
public: public:
class Data final : angle::NonCopyable class Data final : angle::NonCopyable
...@@ -152,6 +153,8 @@ class Program : angle::NonCopyable ...@@ -152,6 +153,8 @@ class Program : angle::NonCopyable
Data(); Data();
~Data(); ~Data();
const std::string &getLabel();
const Shader *getAttachedVertexShader() const { return mAttachedVertexShader; } const Shader *getAttachedVertexShader() const { return mAttachedVertexShader; }
const Shader *getAttachedFragmentShader() const { return mAttachedFragmentShader; } const Shader *getAttachedFragmentShader() const { return mAttachedFragmentShader; }
const std::vector<std::string> &getTransformFeedbackVaryingNames() const const std::vector<std::string> &getTransformFeedbackVaryingNames() const
...@@ -191,6 +194,8 @@ class Program : angle::NonCopyable ...@@ -191,6 +194,8 @@ class Program : angle::NonCopyable
private: private:
friend class Program; friend class Program;
std::string mLabel;
Shader *mAttachedFragmentShader; Shader *mAttachedFragmentShader;
Shader *mAttachedVertexShader; Shader *mAttachedVertexShader;
...@@ -224,6 +229,9 @@ class Program : angle::NonCopyable ...@@ -224,6 +229,9 @@ class Program : angle::NonCopyable
GLuint id() const { return mHandle; } GLuint id() const { return mHandle; }
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
rx::ProgramImpl *getImplementation() { return mProgram; } rx::ProgramImpl *getImplementation() { return mProgram; }
const rx::ProgramImpl *getImplementation() const { return mProgram; } const rx::ProgramImpl *getImplementation() const { return mProgram; }
......
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
namespace gl namespace gl
{ {
Query::Query(rx::QueryImpl *impl, GLuint id) Query::Query(rx::QueryImpl *impl, GLuint id) : RefCountObject(id), mQuery(impl), mLabel()
: RefCountObject(id),
mQuery(impl)
{ {
} }
...@@ -22,6 +20,16 @@ Query::~Query() ...@@ -22,6 +20,16 @@ Query::~Query()
SafeDelete(mQuery); SafeDelete(mQuery);
} }
void Query::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Query::getLabel() const
{
return mLabel;
}
Error Query::begin() Error Query::begin()
{ {
return mQuery->begin(); return mQuery->begin();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef LIBANGLE_QUERY_H_ #ifndef LIBANGLE_QUERY_H_
#define LIBANGLE_QUERY_H_ #define LIBANGLE_QUERY_H_
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
...@@ -24,12 +25,15 @@ class QueryImpl; ...@@ -24,12 +25,15 @@ class QueryImpl;
namespace gl namespace gl
{ {
class Query : public RefCountObject class Query final : public RefCountObject, public LabeledObject
{ {
public: public:
Query(rx::QueryImpl *impl, GLuint id); Query(rx::QueryImpl *impl, GLuint id);
virtual ~Query(); virtual ~Query();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
Error begin(); Error begin();
Error end(); Error end();
...@@ -43,6 +47,8 @@ class Query : public RefCountObject ...@@ -43,6 +47,8 @@ class Query : public RefCountObject
private: private:
rx::QueryImpl *mQuery; rx::QueryImpl *mQuery;
std::string mLabel;
}; };
} }
......
...@@ -22,6 +22,7 @@ namespace gl ...@@ -22,6 +22,7 @@ namespace gl
Renderbuffer::Renderbuffer(rx::RenderbufferImpl *impl, GLuint id) Renderbuffer::Renderbuffer(rx::RenderbufferImpl *impl, GLuint id)
: egl::ImageSibling(id), : egl::ImageSibling(id),
mRenderbuffer(impl), mRenderbuffer(impl),
mLabel(),
mWidth(0), mWidth(0),
mHeight(0), mHeight(0),
mInternalFormat(GL_RGBA4), mInternalFormat(GL_RGBA4),
...@@ -34,6 +35,16 @@ Renderbuffer::~Renderbuffer() ...@@ -34,6 +35,16 @@ Renderbuffer::~Renderbuffer()
SafeDelete(mRenderbuffer); SafeDelete(mRenderbuffer);
} }
void Renderbuffer::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Renderbuffer::getLabel() const
{
return mLabel;
}
Error Renderbuffer::setStorage(GLenum internalformat, size_t width, size_t height) Error Renderbuffer::setStorage(GLenum internalformat, size_t width, size_t height)
{ {
orphanImages(); orphanImages();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Image.h" #include "libANGLE/Image.h"
...@@ -25,12 +26,17 @@ namespace gl ...@@ -25,12 +26,17 @@ namespace gl
// FramebufferAttachment and Framebuffer for how they are applied to an FBO via an // FramebufferAttachment and Framebuffer for how they are applied to an FBO via an
// attachment point. // attachment point.
class Renderbuffer : public egl::ImageSibling, public gl::FramebufferAttachmentObject class Renderbuffer final : public egl::ImageSibling,
public gl::FramebufferAttachmentObject,
public LabeledObject
{ {
public: public:
Renderbuffer(rx::RenderbufferImpl *impl, GLuint id); Renderbuffer(rx::RenderbufferImpl *impl, GLuint id);
virtual ~Renderbuffer(); virtual ~Renderbuffer();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
Error setStorage(GLenum internalformat, size_t width, size_t height); Error setStorage(GLenum internalformat, size_t width, size_t height);
Error setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height); Error setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height);
Error setStorageEGLImageTarget(egl::Image *imageTarget); Error setStorageEGLImageTarget(egl::Image *imageTarget);
...@@ -63,6 +69,8 @@ class Renderbuffer : public egl::ImageSibling, public gl::FramebufferAttachmentO ...@@ -63,6 +69,8 @@ class Renderbuffer : public egl::ImageSibling, public gl::FramebufferAttachmentO
rx::RenderbufferImpl *mRenderbuffer; rx::RenderbufferImpl *mRenderbuffer;
std::string mLabel;
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLenum mInternalFormat; GLenum mInternalFormat;
......
...@@ -16,7 +16,7 @@ namespace gl ...@@ -16,7 +16,7 @@ namespace gl
{ {
Sampler::Sampler(rx::ImplFactory *factory, GLuint id) Sampler::Sampler(rx::ImplFactory *factory, GLuint id)
: RefCountObject(id), mImpl(factory->createSampler()), mSamplerState() : RefCountObject(id), mImpl(factory->createSampler()), mLabel(), mSamplerState()
{ {
} }
...@@ -25,6 +25,16 @@ Sampler::~Sampler() ...@@ -25,6 +25,16 @@ Sampler::~Sampler()
SafeDelete(mImpl); SafeDelete(mImpl);
} }
void Sampler::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Sampler::getLabel() const
{
return mLabel;
}
void Sampler::setMinFilter(GLenum minFilter) void Sampler::setMinFilter(GLenum minFilter)
{ {
mSamplerState.minFilter = minFilter; mSamplerState.minFilter = minFilter;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define LIBANGLE_SAMPLER_H_ #define LIBANGLE_SAMPLER_H_
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/Debug.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
namespace rx namespace rx
...@@ -22,12 +23,15 @@ class SamplerImpl; ...@@ -22,12 +23,15 @@ class SamplerImpl;
namespace gl namespace gl
{ {
class Sampler final : public RefCountObject class Sampler final : public RefCountObject, public LabeledObject
{ {
public: public:
Sampler(rx::ImplFactory *factory, GLuint id); Sampler(rx::ImplFactory *factory, GLuint id);
~Sampler() override; ~Sampler() override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
void setMinFilter(GLenum minFilter); void setMinFilter(GLenum minFilter);
GLenum getMinFilter() const; GLenum getMinFilter() const;
...@@ -66,6 +70,8 @@ class Sampler final : public RefCountObject ...@@ -66,6 +70,8 @@ class Sampler final : public RefCountObject
private: private:
rx::SamplerImpl *mImpl; rx::SamplerImpl *mImpl;
std::string mLabel;
SamplerState mSamplerState; SamplerState mSamplerState;
}; };
......
...@@ -72,7 +72,7 @@ bool CompareShaderVar(const sh::ShaderVariable &x, const sh::ShaderVariable &y) ...@@ -72,7 +72,7 @@ bool CompareShaderVar(const sh::ShaderVariable &x, const sh::ShaderVariable &y)
return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type); return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type);
} }
Shader::Data::Data(GLenum shaderType) : mShaderType(shaderType), mShaderVersion(100) Shader::Data::Data(GLenum shaderType) : mLabel(), mShaderType(shaderType), mShaderVersion(100)
{ {
} }
...@@ -103,6 +103,16 @@ Shader::~Shader() ...@@ -103,6 +103,16 @@ Shader::~Shader()
SafeDelete(mImplementation); SafeDelete(mImplementation);
} }
void Shader::setLabel(const std::string &label)
{
mData.mLabel = label;
}
const std::string &Shader::getLabel() const
{
return mData.mLabel;
}
GLuint Shader::getHandle() const GLuint Shader::getHandle() const
{ {
return mHandle; return mHandle;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/Debug.h"
namespace rx namespace rx
{ {
...@@ -36,7 +37,7 @@ struct Limitations; ...@@ -36,7 +37,7 @@ struct Limitations;
class ResourceManager; class ResourceManager;
struct Data; struct Data;
class Shader : angle::NonCopyable class Shader final : angle::NonCopyable, public LabeledObject
{ {
public: public:
class Data final : angle::NonCopyable class Data final : angle::NonCopyable
...@@ -45,6 +46,8 @@ class Shader : angle::NonCopyable ...@@ -45,6 +46,8 @@ class Shader : angle::NonCopyable
Data(GLenum shaderType); Data(GLenum shaderType);
~Data(); ~Data();
const std::string &getLabel() const { return mLabel; }
const std::string &getSource() const { return mSource; } const std::string &getSource() const { return mSource; }
const std::string &getTranslatedSource() const { return mTranslatedSource; } const std::string &getTranslatedSource() const { return mTranslatedSource; }
...@@ -66,6 +69,8 @@ class Shader : angle::NonCopyable ...@@ -66,6 +69,8 @@ class Shader : angle::NonCopyable
private: private:
friend class Shader; friend class Shader;
std::string mLabel;
GLenum mShaderType; GLenum mShaderType;
int mShaderVersion; int mShaderVersion;
std::string mTranslatedSource; std::string mTranslatedSource;
...@@ -86,6 +91,9 @@ class Shader : angle::NonCopyable ...@@ -86,6 +91,9 @@ class Shader : angle::NonCopyable
virtual ~Shader(); virtual ~Shader();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
GLenum getType() const { return mType; } GLenum getType() const { return mType; }
GLuint getHandle() const; GLuint getHandle() const;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Query.h" #include "libANGLE/Query.h"
...@@ -78,7 +79,10 @@ State::~State() ...@@ -78,7 +79,10 @@ State::~State()
reset(); reset();
} }
void State::initialize(const Caps &caps, GLuint clientVersion) void State::initialize(const Caps &caps,
const Extensions &extensions,
GLuint clientVersion,
bool debug)
{ {
mMaxDrawBuffers = caps.maxDrawBuffers; mMaxDrawBuffers = caps.maxDrawBuffers;
mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits; mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;
...@@ -185,6 +189,9 @@ void State::initialize(const Caps &caps, GLuint clientVersion) ...@@ -185,6 +189,9 @@ void State::initialize(const Caps &caps, GLuint clientVersion)
mDrawFramebuffer = NULL; mDrawFramebuffer = NULL;
mPrimitiveRestart = false; mPrimitiveRestart = false;
mDebug.setOutputEnabled(debug);
mDebug.setMaxLoggedMessages(extensions.maxDebugLoggedMessages);
} }
void State::reset() void State::reset()
...@@ -581,6 +588,12 @@ void State::setEnableFeature(GLenum feature, bool enabled) ...@@ -581,6 +588,12 @@ void State::setEnableFeature(GLenum feature, bool enabled)
case GL_DITHER: setDither(enabled); break; case GL_DITHER: setDither(enabled); break;
case GL_PRIMITIVE_RESTART_FIXED_INDEX: setPrimitiveRestart(enabled); break; case GL_PRIMITIVE_RESTART_FIXED_INDEX: setPrimitiveRestart(enabled); break;
case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break; case GL_RASTERIZER_DISCARD: setRasterizerDiscard(enabled); break;
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
mDebug.setOutputSynchronous(enabled);
break;
case GL_DEBUG_OUTPUT:
mDebug.setOutputEnabled(enabled);
break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
} }
...@@ -600,6 +613,10 @@ bool State::getEnableFeature(GLenum feature) ...@@ -600,6 +613,10 @@ bool State::getEnableFeature(GLenum feature)
case GL_DITHER: return isDitherEnabled(); case GL_DITHER: return isDitherEnabled();
case GL_PRIMITIVE_RESTART_FIXED_INDEX: return isPrimitiveRestartEnabled(); case GL_PRIMITIVE_RESTART_FIXED_INDEX: return isPrimitiveRestartEnabled();
case GL_RASTERIZER_DISCARD: return isRasterizerDiscardEnabled(); case GL_RASTERIZER_DISCARD: return isRasterizerDiscardEnabled();
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
return mDebug.isOutputSynchronous();
case GL_DEBUG_OUTPUT:
return mDebug.isOutputEnabled();
default: UNREACHABLE(); return false; default: UNREACHABLE(); return false;
} }
} }
...@@ -1271,6 +1288,16 @@ PixelUnpackState &State::getUnpackState() ...@@ -1271,6 +1288,16 @@ PixelUnpackState &State::getUnpackState()
return mUnpack; return mUnpack;
} }
const Debug &State::getDebug() const
{
return mDebug;
}
Debug &State::getDebug()
{
return mDebug;
}
void State::getBooleanv(GLenum pname, GLboolean *params) void State::getBooleanv(GLenum pname, GLboolean *params)
{ {
switch (pname) switch (pname)
...@@ -1300,6 +1327,12 @@ void State::getBooleanv(GLenum pname, GLboolean *params) ...@@ -1300,6 +1327,12 @@ void State::getBooleanv(GLenum pname, GLboolean *params)
case GL_RASTERIZER_DISCARD: case GL_RASTERIZER_DISCARD:
*params = isRasterizerDiscardEnabled() ? GL_TRUE : GL_FALSE; *params = isRasterizerDiscardEnabled() ? GL_TRUE : GL_FALSE;
break; break;
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
*params = mDebug.isOutputSynchronous() ? GL_TRUE : GL_FALSE;
break;
case GL_DEBUG_OUTPUT:
*params = mDebug.isOutputEnabled() ? GL_TRUE : GL_FALSE;
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
...@@ -1557,12 +1590,37 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) ...@@ -1557,12 +1590,37 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
case GL_PIXEL_UNPACK_BUFFER_BINDING: case GL_PIXEL_UNPACK_BUFFER_BINDING:
*params = mUnpack.pixelBuffer.id(); *params = mUnpack.pixelBuffer.id();
break; break;
case GL_DEBUG_LOGGED_MESSAGES:
*params = static_cast<GLint>(mDebug.getMessageCount());
break;
case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
*params = static_cast<GLint>(mDebug.getNextMessageLength());
break;
case GL_DEBUG_GROUP_STACK_DEPTH:
*params = static_cast<GLint>(mDebug.getGroupStackDepth());
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
} }
void State::getPointerv(GLenum pname, void **params) const
{
switch (pname)
{
case GL_DEBUG_CALLBACK_FUNCTION:
*params = reinterpret_cast<void *>(mDebug.getCallback());
break;
case GL_DEBUG_CALLBACK_USER_PARAM:
*params = const_cast<void *>(mDebug.getUserParam());
break;
default:
UNREACHABLE();
break;
}
}
bool State::getIndexedIntegerv(GLenum target, GLuint index, GLint *data) bool State::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
{ {
switch (target) switch (target)
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#define LIBANGLE_STATE_H_ #define LIBANGLE_STATE_H_
#include <bitset> #include <bitset>
#include <memory>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
...@@ -37,7 +39,10 @@ class State : angle::NonCopyable ...@@ -37,7 +39,10 @@ class State : angle::NonCopyable
State(); State();
~State(); ~State();
void initialize(const Caps& caps, GLuint clientVersion); void initialize(const Caps &caps,
const Extensions &extensions,
GLuint clientVersion,
bool debug);
void reset(); void reset();
// State chunk getters // State chunk getters
...@@ -258,10 +263,15 @@ class State : angle::NonCopyable ...@@ -258,10 +263,15 @@ class State : angle::NonCopyable
const PixelUnpackState &getUnpackState() const; const PixelUnpackState &getUnpackState() const;
PixelUnpackState &getUnpackState(); PixelUnpackState &getUnpackState();
// Debug state
const Debug &getDebug() const;
Debug &getDebug();
// State query functions // State query functions
void getBooleanv(GLenum pname, GLboolean *params); void getBooleanv(GLenum pname, GLboolean *params);
void getFloatv(GLenum pname, GLfloat *params); void getFloatv(GLenum pname, GLfloat *params);
void getIntegerv(const gl::Data &data, GLenum pname, GLint *params); void getIntegerv(const gl::Data &data, GLenum pname, GLint *params);
void getPointerv(GLenum pname, void **params) const;
bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data); bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data); bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
...@@ -412,6 +422,8 @@ class State : angle::NonCopyable ...@@ -412,6 +422,8 @@ class State : angle::NonCopyable
bool mPrimitiveRestart; bool mPrimitiveRestart;
Debug mDebug;
DirtyBits mDirtyBits; DirtyBits mDirtyBits;
DirtyBits mUnpackStateBitMask; DirtyBits mUnpackStateBitMask;
DirtyBits mPackStateBitMask; DirtyBits mPackStateBitMask;
......
...@@ -50,6 +50,7 @@ static size_t GetImageDescIndex(GLenum target, size_t level) ...@@ -50,6 +50,7 @@ static size_t GetImageDescIndex(GLenum target, size_t level)
Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target) Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target)
: egl::ImageSibling(id), : egl::ImageSibling(id),
mTexture(impl), mTexture(impl),
mLabel(),
mTextureState(), mTextureState(),
mTarget(target), mTarget(target),
mImageDescs(IMPLEMENTATION_MAX_TEXTURE_LEVELS * (target == GL_TEXTURE_CUBE_MAP ? 6 : 1)), mImageDescs(IMPLEMENTATION_MAX_TEXTURE_LEVELS * (target == GL_TEXTURE_CUBE_MAP ? 6 : 1)),
...@@ -68,6 +69,16 @@ Texture::~Texture() ...@@ -68,6 +69,16 @@ Texture::~Texture()
SafeDelete(mTexture); SafeDelete(mTexture);
} }
void Texture::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &Texture::getLabel() const
{
return mLabel;
}
GLenum Texture::getTarget() const GLenum Texture::getTarget() const
{ {
return mTarget; return mTarget;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "angle_gl.h" #include "angle_gl.h"
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Constants.h" #include "libANGLE/Constants.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
...@@ -33,14 +34,19 @@ class Context; ...@@ -33,14 +34,19 @@ class Context;
class Framebuffer; class Framebuffer;
struct Data; struct Data;
bool IsMipmapFiltered(const gl::SamplerState &samplerState); bool IsMipmapFiltered(const SamplerState &samplerState);
class Texture final : public egl::ImageSibling, public gl::FramebufferAttachmentObject class Texture final : public egl::ImageSibling,
public FramebufferAttachmentObject,
public LabeledObject
{ {
public: public:
Texture(rx::TextureImpl *impl, GLuint id, GLenum target); Texture(rx::TextureImpl *impl, GLuint id, GLenum target);
~Texture() override; ~Texture() override;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
GLenum getTarget() const; GLenum getTarget() const;
void setSwizzleRed(GLenum swizzleRed); void setSwizzleRed(GLenum swizzleRed);
...@@ -184,6 +190,8 @@ class Texture final : public egl::ImageSibling, public gl::FramebufferAttachment ...@@ -184,6 +190,8 @@ class Texture final : public egl::ImageSibling, public gl::FramebufferAttachment
rx::TextureImpl *mTexture; rx::TextureImpl *mTexture;
std::string mLabel;
TextureState mTextureState; TextureState mTextureState;
GLenum mTarget; GLenum mTarget;
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
namespace gl namespace gl
{ {
TransformFeedback::TransformFeedback(rx::TransformFeedbackImpl* impl, GLuint id, const Caps &caps) TransformFeedback::TransformFeedback(rx::TransformFeedbackImpl *impl, GLuint id, const Caps &caps)
: RefCountObject(id), : RefCountObject(id),
mImplementation(impl), mImplementation(impl),
mLabel(),
mActive(false), mActive(false),
mPrimitiveMode(GL_NONE), mPrimitiveMode(GL_NONE),
mPaused(false), mPaused(false),
...@@ -36,6 +37,16 @@ TransformFeedback::~TransformFeedback() ...@@ -36,6 +37,16 @@ TransformFeedback::~TransformFeedback()
SafeDelete(mImplementation); SafeDelete(mImplementation);
} }
void TransformFeedback::setLabel(const std::string &label)
{
mLabel = label;
}
const std::string &TransformFeedback::getLabel() const
{
return mLabel;
}
void TransformFeedback::begin(GLenum primitiveMode) void TransformFeedback::begin(GLenum primitiveMode)
{ {
mActive = true; mActive = true;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Debug.h"
#include "angle_gl.h" #include "angle_gl.h"
...@@ -23,12 +24,15 @@ namespace gl ...@@ -23,12 +24,15 @@ namespace gl
class Buffer; class Buffer;
struct Caps; struct Caps;
class TransformFeedback : public RefCountObject class TransformFeedback final : public RefCountObject, public LabeledObject
{ {
public: public:
TransformFeedback(rx::TransformFeedbackImpl* impl, GLuint id, const Caps &caps); TransformFeedback(rx::TransformFeedbackImpl* impl, GLuint id, const Caps &caps);
virtual ~TransformFeedback(); virtual ~TransformFeedback();
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
void begin(GLenum primitiveMode); void begin(GLenum primitiveMode);
void end(); void end();
void pause(); void pause();
...@@ -53,6 +57,8 @@ class TransformFeedback : public RefCountObject ...@@ -53,6 +57,8 @@ class TransformFeedback : public RefCountObject
private: private:
rx::TransformFeedbackImpl* mImplementation; rx::TransformFeedbackImpl* mImplementation;
std::string mLabel;
bool mActive; bool mActive;
GLenum mPrimitiveMode; GLenum mPrimitiveMode;
bool mPaused; bool mPaused;
......
...@@ -15,8 +15,7 @@ namespace gl ...@@ -15,8 +15,7 @@ namespace gl
{ {
VertexArray::Data::Data(size_t maxAttribs) VertexArray::Data::Data(size_t maxAttribs)
: mVertexAttributes(maxAttribs), : mLabel(), mVertexAttributes(maxAttribs), mMaxEnabledAttribute(0)
mMaxEnabledAttribute(0)
{ {
} }
...@@ -46,6 +45,16 @@ GLuint VertexArray::id() const ...@@ -46,6 +45,16 @@ GLuint VertexArray::id() const
return mId; return mId;
} }
void VertexArray::setLabel(const std::string &label)
{
mData.mLabel = label;
}
const std::string &VertexArray::getLabel() const
{
return mData.mLabel;
}
void VertexArray::detachBuffer(GLuint bufferName) void VertexArray::detachBuffer(GLuint bufferName)
{ {
for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++) for (size_t attribute = 0; attribute < getMaxAttribs(); attribute++)
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
#include "libANGLE/Constants.h" #include "libANGLE/Constants.h"
#include "libANGLE/Debug.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
...@@ -30,7 +31,7 @@ namespace gl ...@@ -30,7 +31,7 @@ namespace gl
{ {
class Buffer; class Buffer;
class VertexArray class VertexArray final : public LabeledObject
{ {
public: public:
VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs); VertexArray(rx::ImplFactory *factory, GLuint id, size_t maxAttribs);
...@@ -38,6 +39,9 @@ class VertexArray ...@@ -38,6 +39,9 @@ class VertexArray
GLuint id() const; GLuint id() const;
void setLabel(const std::string &label) override;
const std::string &getLabel() const override;
const VertexAttribute &getVertexAttribute(size_t attributeIndex) const; const VertexAttribute &getVertexAttribute(size_t attributeIndex) const;
void detachBuffer(GLuint bufferName); void detachBuffer(GLuint bufferName);
...@@ -63,6 +67,8 @@ class VertexArray ...@@ -63,6 +67,8 @@ class VertexArray
explicit Data(size_t maxAttribs); explicit Data(size_t maxAttribs);
~Data(); ~Data();
const std::string &getLabel() const { return mLabel; }
const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; } const BindingPointer<Buffer> &getElementArrayBuffer() const { return mElementArrayBuffer; }
size_t getMaxAttribs() const { return mVertexAttributes.size(); } size_t getMaxAttribs() const { return mVertexAttributes.size(); }
size_t getMaxEnabledAttribute() const { return mMaxEnabledAttribute; } size_t getMaxEnabledAttribute() const { return mMaxEnabledAttribute; }
...@@ -74,6 +80,7 @@ class VertexArray ...@@ -74,6 +80,7 @@ class VertexArray
private: private:
friend class VertexArray; friend class VertexArray;
std::string mLabel;
std::vector<VertexAttribute> mVertexAttributes; std::vector<VertexAttribute> mVertexAttributes;
BindingPointer<Buffer> mElementArrayBuffer; BindingPointer<Buffer> mElementArrayBuffer;
size_t mMaxEnabledAttribute; size_t mMaxEnabledAttribute;
......
...@@ -235,8 +235,10 @@ egl::Error DisplayD3D::createContext(const egl::Config *config, const gl::Contex ...@@ -235,8 +235,10 @@ egl::Error DisplayD3D::createContext(const egl::Config *config, const gl::Contex
EGLint clientVersion = attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1); EGLint clientVersion = attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1);
bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT); bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT);
bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE); bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE);
bool debug = (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE);
*outContext = new gl::Context(config, clientVersion, shareContext, mRenderer, notifyResets, robustAccess); *outContext = new gl::Context(config, clientVersion, shareContext, mRenderer, notifyResets,
robustAccess, debug);
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
......
...@@ -62,8 +62,10 @@ egl::Error DisplayGL::createContext(const egl::Config *config, const gl::Context ...@@ -62,8 +62,10 @@ egl::Error DisplayGL::createContext(const egl::Config *config, const gl::Context
EGLint clientVersion = attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1); EGLint clientVersion = attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1);
bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT); bool notifyResets = (attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION_EXT) == EGL_LOSE_CONTEXT_ON_RESET_EXT);
bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE); bool robustAccess = (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE);
bool debug = (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE);
*outContext = new gl::Context(config, clientVersion, shareContext, mRenderer, notifyResets, robustAccess); *outContext = new gl::Context(config, clientVersion, shareContext, mRenderer, notifyResets,
robustAccess, debug);
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
......
...@@ -210,6 +210,9 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context ...@@ -210,6 +210,9 @@ Error ValidateCreateContext(Display *display, Config *configuration, gl::Context
contextFlags = value; contextFlags = value;
break; break;
case EGL_CONTEXT_OPENGL_DEBUG:
break;
case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR: case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
// Only valid for OpenGL (non-ES) contexts // Only valid for OpenGL (non-ES) contexts
return Error(EGL_BAD_ATTRIBUTE); return Error(EGL_BAD_ATTRIBUTE);
......
...@@ -109,9 +109,15 @@ bool ValidCap(const Context *context, GLenum cap) ...@@ -109,9 +109,15 @@ bool ValidCap(const Context *context, GLenum cap)
case GL_BLEND: case GL_BLEND:
case GL_DITHER: case GL_DITHER:
return true; return true;
case GL_PRIMITIVE_RESTART_FIXED_INDEX: case GL_PRIMITIVE_RESTART_FIXED_INDEX:
case GL_RASTERIZER_DISCARD: case GL_RASTERIZER_DISCARD:
return (context->getClientVersion() >= 3); return (context->getClientVersion() >= 3);
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
case GL_DEBUG_OUTPUT:
return context->getExtensions().debug;
default: default:
return false; return false;
} }
......
...@@ -96,7 +96,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError) ...@@ -96,7 +96,7 @@ TEST(ValidationESTest, DrawElementsWithMaxIndexGivesError)
caps.maxElementIndex = 100; caps.maxElementIndex = 100;
caps.maxDrawBuffers = 1; caps.maxDrawBuffers = 1;
caps.maxColorAttachments = 1; caps.maxColorAttachments = 1;
state.initialize(caps, 3); state.initialize(caps, extensions, 3, false);
MockTextureImpl *textureImpl = new MockTextureImpl(); MockTextureImpl *textureImpl = new MockTextureImpl();
EXPECT_CALL(*textureImpl, setStorage(_, _, _, _)).WillOnce(Return(Error(GL_NO_ERROR))); EXPECT_CALL(*textureImpl, setStorage(_, _, _, _)).WillOnce(Return(Error(GL_NO_ERROR)));
......
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
'libANGLE/Context.h', 'libANGLE/Context.h',
'libANGLE/Data.cpp', 'libANGLE/Data.cpp',
'libANGLE/Data.h', 'libANGLE/Data.h',
'libANGLE/Debug.cpp',
'libANGLE/Debug.h',
'libANGLE/Device.cpp', 'libANGLE/Device.cpp',
'libANGLE/Device.h', 'libANGLE/Device.h',
'libANGLE/Display.cpp', 'libANGLE/Display.cpp',
......
...@@ -1298,7 +1298,9 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source, ...@@ -1298,7 +1298,9 @@ void GL_APIENTRY DebugMessageControlKHR(GLenum source,
return; return;
} }
UNIMPLEMENTED(); std::vector<GLuint> idVector(ids, ids + count);
context->getState().getDebug().setMessageControl(
source, type, severity, std::move(idVector), (enabled != GL_FALSE));
} }
} }
...@@ -1322,7 +1324,8 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source, ...@@ -1322,7 +1324,8 @@ void GL_APIENTRY DebugMessageInsertKHR(GLenum source,
return; return;
} }
UNIMPLEMENTED(); std::string msg(buf, (length > 0) ? static_cast<size_t>(length) : strlen(buf));
context->getState().getDebug().insertMessage(source, type, id, severity, std::move(msg));
} }
} }
...@@ -1339,7 +1342,7 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us ...@@ -1339,7 +1342,7 @@ void GL_APIENTRY DebugMessageCallbackKHR(GLDEBUGPROCKHR callback, const void *us
return; return;
} }
UNIMPLEMENTED(); context->getState().getDebug().setCallback(callback, userParam);
} }
} }
...@@ -1367,7 +1370,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count, ...@@ -1367,7 +1370,8 @@ GLuint GL_APIENTRY GetDebugMessageLogKHR(GLuint count,
return 0; return 0;
} }
UNIMPLEMENTED(); return static_cast<GLuint>(context->getState().getDebug().getMessages(
count, bufSize, sources, types, ids, severities, lengths, messageLog));
} }
return 0; return 0;
...@@ -1388,7 +1392,8 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con ...@@ -1388,7 +1392,8 @@ void GL_APIENTRY PushDebugGroupKHR(GLenum source, GLuint id, GLsizei length, con
return; return;
} }
UNIMPLEMENTED(); std::string msg(message, (length > 0) ? static_cast<size_t>(length) : strlen(message));
context->getState().getDebug().pushGroup(source, id, std::move(msg));
} }
} }
...@@ -1404,7 +1409,7 @@ void GL_APIENTRY PopDebugGroupKHR(void) ...@@ -1404,7 +1409,7 @@ void GL_APIENTRY PopDebugGroupKHR(void)
return; return;
} }
UNIMPLEMENTED(); context->getState().getDebug().popGroup();
} }
} }
...@@ -1423,7 +1428,11 @@ void GL_APIENTRY ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length, ...@@ -1423,7 +1428,11 @@ void GL_APIENTRY ObjectLabelKHR(GLenum identifier, GLuint name, GLsizei length,
return; return;
} }
UNIMPLEMENTED(); LabeledObject *object = context->getLabeledObject(identifier, name);
ASSERT(object != nullptr);
std::string lbl(label, (length > 0) ? static_cast<size_t>(length) : strlen(label));
object->setLabel(lbl);
} }
} }
...@@ -1443,7 +1452,14 @@ GetObjectLabelKHR(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *leng ...@@ -1443,7 +1452,14 @@ GetObjectLabelKHR(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *leng
return; return;
} }
UNIMPLEMENTED(); LabeledObject *object = context->getLabeledObject(identifier, name);
ASSERT(object != nullptr);
const std::string &objectLabel = object->getLabel();
size_t writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length());
std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label);
label[writeLength] = '\0';
*length = static_cast<GLsizei>(writeLength);
} }
} }
...@@ -1460,7 +1476,11 @@ void GL_APIENTRY ObjectPtrLabelKHR(const void *ptr, GLsizei length, const GLchar ...@@ -1460,7 +1476,11 @@ void GL_APIENTRY ObjectPtrLabelKHR(const void *ptr, GLsizei length, const GLchar
return; return;
} }
UNIMPLEMENTED(); LabeledObject *object = context->getLabeledObjectFromPtr(ptr);
ASSERT(object != nullptr);
std::string lbl(label, (length > 0) ? static_cast<size_t>(length) : strlen(label));
object->setLabel(lbl);
} }
} }
...@@ -1482,7 +1502,14 @@ void GL_APIENTRY GetObjectPtrLabelKHR(const void *ptr, ...@@ -1482,7 +1502,14 @@ void GL_APIENTRY GetObjectPtrLabelKHR(const void *ptr,
return; return;
} }
UNIMPLEMENTED(); LabeledObject *object = context->getLabeledObjectFromPtr(ptr);
ASSERT(object != nullptr);
const std::string &objectLabel = object->getLabel();
size_t writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length());
std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label);
label[writeLength] = '\0';
*length = static_cast<GLsizei>(writeLength);
} }
} }
...@@ -1498,7 +1525,7 @@ void GL_APIENTRY GetPointervKHR(GLenum pname, void **params) ...@@ -1498,7 +1525,7 @@ void GL_APIENTRY GetPointervKHR(GLenum pname, void **params)
return; return;
} }
UNIMPLEMENTED(); context->getPointerv(pname, params);
} }
} }
} }
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
'<(angle_path)/src/tests/gl_tests/CopyTexImageTest.cpp', '<(angle_path)/src/tests/gl_tests/CopyTexImageTest.cpp',
'<(angle_path)/src/tests/gl_tests/CubeMapTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/CubeMapTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/DebugMarkerTest.cpp', '<(angle_path)/src/tests/gl_tests/DebugMarkerTest.cpp',
'<(angle_path)/src/tests/gl_tests/DebugTest.cpp',
'<(angle_path)/src/tests/gl_tests/DepthStencilFormatsTest.cpp', '<(angle_path)/src/tests/gl_tests/DepthStencilFormatsTest.cpp',
'<(angle_path)/src/tests/gl_tests/DiscardFramebufferEXTTest.cpp', '<(angle_path)/src/tests/gl_tests/DiscardFramebufferEXTTest.cpp',
'<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp', '<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp',
......
...@@ -223,6 +223,11 @@ void ANGLETest::setMultisampleEnabled(bool enabled) ...@@ -223,6 +223,11 @@ void ANGLETest::setMultisampleEnabled(bool enabled)
mEGLWindow->setMultisample(enabled); mEGLWindow->setMultisample(enabled);
} }
void ANGLETest::setDebugEnabled(bool enabled)
{
mEGLWindow->setDebugEnabled(enabled);
}
int ANGLETest::getClientVersion() const int ANGLETest::getClientVersion() const
{ {
return mEGLWindow->getClientMajorVersion(); return mEGLWindow->getClientMajorVersion();
......
...@@ -96,6 +96,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -96,6 +96,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
void setConfigDepthBits(int bits); void setConfigDepthBits(int bits);
void setConfigStencilBits(int bits); void setConfigStencilBits(int bits);
void setMultisampleEnabled(bool enabled); void setMultisampleEnabled(bool enabled);
void setDebugEnabled(bool enabled);
int getClientVersion() const; int getClientVersion() const;
......
...@@ -85,6 +85,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion, ...@@ -85,6 +85,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion,
mDepthBits(-1), mDepthBits(-1),
mStencilBits(-1), mStencilBits(-1),
mMultisample(false), mMultisample(false),
mDebug(false),
mSwapInterval(-1) mSwapInterval(-1)
{ {
} }
...@@ -224,6 +225,9 @@ bool EGLWindow::initializeGL(OSWindow *osWindow) ...@@ -224,6 +225,9 @@ bool EGLWindow::initializeGL(OSWindow *osWindow)
contextAttributes.push_back(EGL_CONTEXT_MINOR_VERSION_KHR); contextAttributes.push_back(EGL_CONTEXT_MINOR_VERSION_KHR);
contextAttributes.push_back(mClientMinorVersion); contextAttributes.push_back(mClientMinorVersion);
contextAttributes.push_back(EGL_CONTEXT_OPENGL_DEBUG);
contextAttributes.push_back(mDebug ? EGL_TRUE : EGL_FALSE);
} }
contextAttributes.push_back(EGL_NONE); contextAttributes.push_back(EGL_NONE);
......
...@@ -59,6 +59,7 @@ class EGLWindow : angle::NonCopyable ...@@ -59,6 +59,7 @@ class EGLWindow : angle::NonCopyable
void setConfigDepthBits(int bits) { mDepthBits = bits; } void setConfigDepthBits(int bits) { mDepthBits = bits; }
void setConfigStencilBits(int bits) { mStencilBits = bits; } void setConfigStencilBits(int bits) { mStencilBits = bits; }
void setMultisample(bool multisample) { mMultisample = multisample; } void setMultisample(bool multisample) { mMultisample = multisample; }
void setDebugEnabled(bool debug) { mDebug = debug; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
...@@ -79,6 +80,7 @@ class EGLWindow : angle::NonCopyable ...@@ -79,6 +80,7 @@ class EGLWindow : angle::NonCopyable
int getConfigDepthBits() const { return mDepthBits; } int getConfigDepthBits() const { return mDepthBits; }
int getConfigStencilBits() const { return mStencilBits; } int getConfigStencilBits() const { return mStencilBits; }
bool isMultisample() const { return mMultisample; } bool isMultisample() const { return mMultisample; }
bool isDebugEnabled() const { return mDebug; }
EGLint getSwapInterval() const { return mSwapInterval; } EGLint getSwapInterval() const { return mSwapInterval; }
bool initializeGL(OSWindow *osWindow); bool initializeGL(OSWindow *osWindow);
...@@ -101,6 +103,7 @@ class EGLWindow : angle::NonCopyable ...@@ -101,6 +103,7 @@ class EGLWindow : angle::NonCopyable
int mDepthBits; int mDepthBits;
int mStencilBits; int mStencilBits;
bool mMultisample; bool mMultisample;
bool mDebug;
EGLint mSwapInterval; EGLint mSwapInterval;
}; };
......
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