Commit 42b115f8 authored by Robert Menzel's avatar Robert Menzel

push and pop debug groups are working

parent 56a352f3
......@@ -18,7 +18,7 @@ int KHR_DEBUG_EMULATOR_isSynchronous = 0;
// implementation dependent limits:
int KHR_DEBUG_EMULATOR_MAX_DEBUG_MESSAGE_LENGTH = 256;
int KHR_DEBUG_EMULATOR_MAX_DEBUG_LOGGED_MESSAGES = 1;
int KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH = 64;
#define KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH 64
int KHR_DEBUG_EMULATOR_MAX_LABEL_LENGTH = 256;
......@@ -72,7 +72,6 @@ void KHR_DEBUG_EMULATOR_DebugMessageInsert(GLenum source, GLenum type, GLuint id
if ((source != GL_DEBUG_SOURCE_APPLICATION) && (source != GL_DEBUG_SOURCE_THIRD_PARTY)) {
INSERT_API_ERROR( GL_INVALID_ENUM, "invalid enum in glDebugMessageInsert: source has to be GL_DEBUG_SOURCE_APPLICATION or GL_DEBUG_SOURCE_THIRD_PARTY" );
return;
}
KHR_DEBUG_EMULATOR_DebugMessageInsert_internal( source, type, id, severity, length, buf );
}
......@@ -139,6 +138,8 @@ typedef struct DebugMessageControlRule
GLboolean allIDs; // if set, ignore id
GLboolean enabled;
GLuint debugGroup;
DebugMessageControlRule *previousRule;
DebugMessageControlRule *nextRule;
} DebugMessageControlRule;
......@@ -146,6 +147,8 @@ typedef struct DebugMessageControlRule
// yes, I'm aware that this will never get cleaned up :-(
DebugMessageControlRule *g_FirstDebugMessageControlRule = NULL;
DebugMessageControlRule *g_LastDebugMessageControlRule = NULL;
GLuint g_DebugGroupNumber = 0; // 0 == default group
GLboolean ruleApplies( DebugMessageControlRule *rule, GLenum source, GLenum type, GLuint id, GLenum severity )
{
......@@ -196,7 +199,7 @@ void addRule( DebugMessageControlRule *newRule )
}
//
// glDebugMessageControl TODO
// glDebugMessageControl
//
void KHR_DEBUG_EMULATOR_DebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled)
{
......@@ -205,6 +208,7 @@ void KHR_DEBUG_EMULATOR_DebugMessageControl(GLenum source, GLenum type, GLenum s
rule->type = type;
rule->severity = severity;
rule->enabled = enabled;
rule->debugGroup = g_DebugGroupNumber;
if (count == 0) {
// ID-agnostic rule
......@@ -216,6 +220,11 @@ void KHR_DEBUG_EMULATOR_DebugMessageControl(GLenum source, GLenum type, GLenum s
// rules for specific IDs
rule->allIDs = false;
if (source == GL_DONT_CARE || type == GL_DONT_CARE || severity != GL_DONT_CARE) {
// see KHR_debug 5.5.4
INSERT_API_ERROR( GL_INVALID_OPERATION , "invalid operation in glDebugMessageControl: if an ID is specified, source and type have to be specified as well but severity has to be GL_DONT_CARE" );
}
for (int i = 0; i < count; ++i) {
rule->id = ids[i];
addRule( rule );
......@@ -275,14 +284,86 @@ void KHR_DEBUG_EMULATOR_ObjectPtrLabel(const void * ptr, GLsizei length, const G
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
}
struct DebugGroupDescription {
GLenum source;
GLuint id;
GLsizei length;
GLchar * message;
};
DebugGroupDescription g_DebugGroupDescriptions[ KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH ];
//
// glPopDebugGroup
//
void KHR_DEBUG_EMULATOR_PopDebugGroup()
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
if (g_DebugGroupNumber == 0) {
INSERT_API_ERROR( GL_STACK_UNDERFLOW, "stack underflow in glPushDebugGroup: can't pop default group" );
return;
}
//
// delete all rules from the poped group:
while (g_LastDebugMessageControlRule && g_LastDebugMessageControlRule->debugGroup >= g_DebugGroupNumber) {
DebugMessageControlRule *ruleToDelete = g_LastDebugMessageControlRule;
// set new last rule:
g_LastDebugMessageControlRule = g_LastDebugMessageControlRule->previousRule;
if (g_LastDebugMessageControlRule != NULL) {
g_LastDebugMessageControlRule->nextRule = NULL;
} else {
g_FirstDebugMessageControlRule = NULL;
}
// now delete the rule:
free( (void*) ruleToDelete );
}
GLenum source = g_DebugGroupDescriptions[g_DebugGroupNumber].source;
GLuint id = g_DebugGroupDescriptions[g_DebugGroupNumber].id;
GLsizei length = g_DebugGroupDescriptions[g_DebugGroupNumber].length;
GLchar * message = g_DebugGroupDescriptions[g_DebugGroupNumber].message;
// goodby message:
KHR_DEBUG_EMULATOR_DebugMessageInsert_internal( source, GL_DEBUG_TYPE_POP_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION, length, message );
// clean up:
free( (void*) g_DebugGroupDescriptions[g_DebugGroupNumber].message );
g_DebugGroupDescriptions[g_DebugGroupNumber].message = NULL;
g_DebugGroupNumber--;
}
//
// glPushDebugGroup
//
void KHR_DEBUG_EMULATOR_PushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar * message)
{
KHR_DEBUG_EMULATOR_insertMissingFeatureError( "function not simulated yet - ignored" );
if ((source != GL_DEBUG_SOURCE_APPLICATION) && (source != GL_DEBUG_SOURCE_THIRD_PARTY)) {
INSERT_API_ERROR( GL_INVALID_ENUM, "invalid enum in glPushDebugGroup: source has to be GL_DEBUG_SOURCE_APPLICATION or GL_DEBUG_SOURCE_THIRD_PARTY" );
return;
}
if (g_DebugGroupNumber >= KHR_DEBUG_EMULATOR_MAX_DEBUG_GROUP_STACK_DEPTH-1) {
INSERT_API_ERROR( GL_STACK_OVERFLOW, "stack overflow in glPushDebugGroup: already too many groups pushed" );
return;
}
KHR_DEBUG_EMULATOR_DebugMessageInsert_internal( source, GL_DEBUG_TYPE_PUSH_GROUP, id, GL_DEBUG_SEVERITY_NOTIFICATION, length, message );
g_DebugGroupNumber++;
if (length < 0) {
length = strlen( message );
}
g_DebugGroupDescriptions[g_DebugGroupNumber].id = id;
g_DebugGroupDescriptions[g_DebugGroupNumber].source = source;
g_DebugGroupDescriptions[g_DebugGroupNumber].length = length;
g_DebugGroupDescriptions[g_DebugGroupNumber].message = (GLchar *) malloc( length+1 );
strncpy( g_DebugGroupDescriptions[g_DebugGroupNumber].message, message, length );
g_DebugGroupDescriptions[g_DebugGroupNumber].message[ length ] = 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
......
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