зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1004702 - Use KHR_debug in DebugMode(). - r=bjacob
This commit is contained in:
Родитель
a67499c469
Коммит
db332a112a
|
@ -303,6 +303,19 @@ GLContext::~GLContext() {
|
|||
#endif
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
GLContext::StaticDebugCallback(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const GLvoid* userParam)
|
||||
{
|
||||
GLContext* gl = (GLContext*)userParam;
|
||||
gl->DebugCallback(source, type, id, severity, length, message);
|
||||
}
|
||||
|
||||
bool
|
||||
GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
||||
{
|
||||
|
@ -1159,6 +1172,17 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
mTexGarbageBin = new TextureGarbageBin(this);
|
||||
|
||||
MOZ_ASSERT(IsCurrent());
|
||||
|
||||
if (DebugMode() && IsExtensionSupported(KHR_debug)) {
|
||||
fEnable(LOCAL_GL_DEBUG_OUTPUT);
|
||||
fDisable(LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
fDebugMessageCallback(&StaticDebugCallback, (void*)this);
|
||||
fDebugMessageControl(LOCAL_GL_DONT_CARE,
|
||||
LOCAL_GL_DONT_CARE,
|
||||
LOCAL_GL_DONT_CARE,
|
||||
0, nullptr,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
if (mInitialized)
|
||||
|
@ -1174,6 +1198,95 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||
return mInitialized;
|
||||
}
|
||||
|
||||
void
|
||||
GLContext::DebugCallback(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message)
|
||||
{
|
||||
nsAutoCString sourceStr;
|
||||
switch (source) {
|
||||
case LOCAL_GL_DEBUG_SOURCE_API:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_API");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_WINDOW_SYSTEM");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SOURCE_SHADER_COMPILER:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_SHADER_COMPILER");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SOURCE_THIRD_PARTY:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_THIRD_PARTY");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SOURCE_APPLICATION:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_APPLICATION");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SOURCE_OTHER:
|
||||
sourceStr = NS_LITERAL_CSTRING("SOURCE_OTHER");
|
||||
break;
|
||||
default:
|
||||
sourceStr = nsPrintfCString("<source 0x%04x>", source);
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoCString typeStr;
|
||||
switch (type) {
|
||||
case LOCAL_GL_DEBUG_TYPE_ERROR:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_ERROR");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_DEPRECATED_BEHAVIOR");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_UNDEFINED_BEHAVIOR");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_PORTABILITY:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_PORTABILITY");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_PERFORMANCE:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_PERFORMANCE");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_OTHER:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_OTHER");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_TYPE_MARKER:
|
||||
typeStr = NS_LITERAL_CSTRING("TYPE_MARKER");
|
||||
break;
|
||||
default:
|
||||
typeStr = nsPrintfCString("<type 0x%04x>", type);
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoCString sevStr;
|
||||
switch (severity) {
|
||||
case LOCAL_GL_DEBUG_SEVERITY_HIGH:
|
||||
sevStr = NS_LITERAL_CSTRING("SEVERITY_HIGH");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SEVERITY_MEDIUM:
|
||||
sevStr = NS_LITERAL_CSTRING("SEVERITY_MEDIUM");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SEVERITY_LOW:
|
||||
sevStr = NS_LITERAL_CSTRING("SEVERITY_LOW");
|
||||
break;
|
||||
case LOCAL_GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
sevStr = NS_LITERAL_CSTRING("SEVERITY_NOTIFICATION");
|
||||
break;
|
||||
default:
|
||||
sevStr = nsPrintfCString("<severity 0x%04x>", severity);
|
||||
break;
|
||||
}
|
||||
|
||||
printf_stderr("[KHR_debug: 0x%x] ID %u: %s %s %s:\n %s",
|
||||
(uintptr_t)this,
|
||||
id,
|
||||
sourceStr.BeginReading(),
|
||||
typeStr.BeginReading(),
|
||||
sevStr.BeginReading(),
|
||||
message);
|
||||
}
|
||||
|
||||
void
|
||||
GLContext::InitExtensions()
|
||||
{
|
||||
|
|
|
@ -582,6 +582,20 @@ private:
|
|||
GLenum mGLError;
|
||||
#endif // DEBUG
|
||||
|
||||
static void GLAPIENTRY StaticDebugCallback(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const GLvoid* userParam);
|
||||
void DebugCallback(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message);
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// MOZ_GL_DEBUG implementation
|
||||
|
|
Загрузка…
Ссылка в новой задаче