mesa: make ARB_debug_output functions an alias of

KHR_debug

Also update dispatch sanity removing ARB_debug_output checks and
removing KHR_debug placeholders as the checks have already been added

V2: Make sure we exit case statements with conditional breaks rather than
just dropping through.

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Timothy Arceri 2014-03-08 15:35:54 +11:00
parent 0608d346aa
commit fb78fa58d2
5 changed files with 92 additions and 254 deletions

View File

@ -52,7 +52,7 @@
<enum name="DEBUG_SEVERITY_LOW_ARB" value="0x9148"/>
<function name="DebugMessageControlARB" offset="assign">
<function name="DebugMessageControlARB" alias="DebugMessageControl">
<param name="source" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="severity" type="GLenum"/>
@ -61,7 +61,7 @@
<param name="enabled" type="GLboolean"/>
</function>
<function name="DebugMessageInsertARB" offset="assign">
<function name="DebugMessageInsertARB" alias="DebugMessageInsert">
<param name="source" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="id" type="GLuint"/>
@ -70,12 +70,12 @@
<param name="buf" type="const GLcharARB *"/>
</function>
<function name="DebugMessageCallbackARB" offset="assign">
<function name="DebugMessageCallbackARB" alias="DebugMessageCallback">
<param name="callback" type="GLDEBUGPROCARB"/>
<param name="userParam" type="const GLvoid *"/>
</function>
<function name="GetDebugMessageLogARB" offset="assign">
<function name="GetDebugMessageLogARB" alias="GetDebugMessageLog">
<return type="GLuint"/>
<param name="count" type="GLuint"/>
<param name="bufsize" type="GLsizei"/>

View File

@ -38,9 +38,6 @@
#include "version.h"
#include "hash_table.h"
#define MESSAGE_LOG 1
#define MESSAGE_LOG_ARB 2
static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
static GLuint NextDynamicID = 1;
@ -372,40 +369,6 @@ store_message_details(struct gl_debug_msg *emptySlot,
}
/**
* Remap any type exclusive to KHR_debug to something suitable
* for ARB_debug_output
*/
inline static int
remap_type(GLenum type) {
switch(type) {
case GL_DEBUG_TYPE_MARKER:
case GL_DEBUG_TYPE_PUSH_GROUP:
case GL_DEBUG_TYPE_POP_GROUP:
type = GL_DEBUG_TYPE_OTHER;
default:
;
}
return type;
}
/**
* Remap severity exclusive to KHR_debug to something suitable
* for ARB_debug_output
*/
inline static int
remap_severity(GLenum severity) {
if (GL_DEBUG_SEVERITY_NOTIFICATION == severity)
severity = GL_DEBUG_SEVERITY_LOW;
return severity;
}
/**
* 'buf' is not necessarily a null-terminated string. When logging, copy
* 'len' characters from it, store them in a new, null-terminated string,
@ -433,10 +396,6 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
GLenum gl_type = debug_type_enums[type];
GLenum gl_severity = debug_severity_enums[severity];
if (debug->ARBCallback) {
gl_severity = remap_severity(gl_severity);
gl_type = remap_type(gl_type);
}
debug->Callback(debug_source_enums[source], gl_type, id, gl_severity,
len, buf, debug->CallbackData);
return;
@ -470,8 +429,7 @@ log_msg(struct gl_context *ctx, enum mesa_debug_source source,
*/
static GLsizei
get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
GLuint *id, GLenum *severity, GLsizei bufSize, char *buf,
unsigned caller)
GLuint *id, GLenum *severity, GLsizei bufSize, char *buf)
{
struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
struct gl_debug_msg *msg;
@ -490,8 +448,6 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
if (severity) {
*severity = debug_severity_enums[msg->severity];
if (caller == MESSAGE_LOG_ARB)
*severity = remap_severity(*severity);
}
if (source) {
@ -500,8 +456,6 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
if (type) {
*type = debug_type_enums[msg->type];
if (caller == MESSAGE_LOG_ARB)
*type = remap_type(*type);
}
if (id) {
@ -529,12 +483,9 @@ get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
/**
* Verify that source, type, and severity are valid enums.
* glDebugMessageInsertARB only accepts two values for 'source',
* and glDebugMessageControlARB will additionally accept GL_DONT_CARE
* in any parameter, so handle those cases specially.
*
* There is also special cases for handling values available in
* GL_KHR_debug that are not avaliable in GL_ARB_debug_output
* The 'caller' param is used for handling values available
* only in glDebugMessageInsert or glDebugMessageControl
*/
static GLboolean
validate_params(struct gl_context *ctx, unsigned caller,
@ -543,8 +494,6 @@ validate_params(struct gl_context *ctx, unsigned caller,
{
#define INSERT 1
#define CONTROL 2
#define INSERT_ARB 3
#define CONTROL_ARB 4
switch(source) {
case GL_DEBUG_SOURCE_APPLICATION_ARB:
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
@ -553,11 +502,15 @@ validate_params(struct gl_context *ctx, unsigned caller,
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
case GL_DEBUG_SOURCE_OTHER_ARB:
if (caller != INSERT || caller == INSERT_ARB)
if (caller != INSERT)
break;
else
goto error;
case GL_DONT_CARE:
if (caller == CONTROL || caller == CONTROL_ARB)
if (caller == CONTROL)
break;
else
goto error;
default:
goto error;
}
@ -569,14 +522,13 @@ validate_params(struct gl_context *ctx, unsigned caller,
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
case GL_DEBUG_TYPE_PORTABILITY_ARB:
case GL_DEBUG_TYPE_OTHER_ARB:
break;
case GL_DEBUG_TYPE_MARKER:
/* this value is only valid for GL_KHR_debug functions */
if (caller == CONTROL || caller == INSERT)
break;
break;
case GL_DONT_CARE:
if (caller == CONTROL || caller == CONTROL_ARB)
if (caller == CONTROL)
break;
else
goto error;
default:
goto error;
}
@ -585,14 +537,13 @@ validate_params(struct gl_context *ctx, unsigned caller,
case GL_DEBUG_SEVERITY_HIGH_ARB:
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
case GL_DEBUG_SEVERITY_LOW_ARB:
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
/* this value is only valid for GL_KHR_debug functions */
if (caller == CONTROL || caller == INSERT)
break;
break;
case GL_DONT_CARE:
if (caller == CONTROL || caller == CONTROL_ARB)
if (caller == CONTROL)
break;
else
goto error;
default:
goto error;
}
@ -705,44 +656,6 @@ control_app_messages(struct gl_context *ctx, GLenum esource, GLenum etype,
}
/**
* This is a generic message control function for use by both
* glDebugMessageControlARB and glDebugMessageControl.
*/
static void
message_control(GLenum gl_source, GLenum gl_type,
GLenum gl_severity,
GLsizei count, const GLuint *ids,
GLboolean enabled,
unsigned caller, const char *callerstr)
{
GET_CURRENT_CONTEXT(ctx);
if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(count=%d : count must not be negative)", callerstr,
count);
return;
}
if (!validate_params(ctx, caller, callerstr, gl_source, gl_type,
gl_severity))
return; /* GL_INVALID_ENUM */
if (count && (gl_severity != GL_DONT_CARE || gl_type == GL_DONT_CARE
|| gl_source == GL_DONT_CARE)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(When passing an array of ids, severity must be"
" GL_DONT_CARE, and source and type must not be GL_DONT_CARE.",
callerstr);
return;
}
control_app_messages(ctx, gl_source, gl_type, gl_severity,
count, ids, enabled);
}
/**
* This is a generic message insert function.
* Validation of source, type and severity parameters should be done
@ -773,58 +686,6 @@ message_insert(GLenum source, GLenum type, GLuint id,
}
/**
* This is a generic message insert function for use by both
* glGetDebugMessageLogARB and glGetDebugMessageLog.
*/
static GLuint
get_message_log(GLuint count, GLsizei logSize, GLenum *sources,
GLenum *types, GLenum *ids, GLenum *severities,
GLsizei *lengths, GLchar *messageLog,
unsigned caller, const char *callerstr)
{
GET_CURRENT_CONTEXT(ctx);
GLuint ret;
if (!messageLog)
logSize = 0;
if (logSize < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(logSize=%d : logSize must not be negative)", callerstr,
logSize);
return 0;
}
for (ret = 0; ret < count; ret++) {
GLsizei written = get_msg(ctx, sources, types, ids, severities,
logSize, messageLog, caller);
if (!written)
break;
if (messageLog) {
messageLog += written;
logSize -= written;
}
if (lengths) {
*lengths = written;
lengths++;
}
if (severities)
severities++;
if (sources)
sources++;
if (types)
types++;
if (ids)
ids++;
}
return ret;
}
static void
do_nothing(GLuint key, void *data, void *userData)
{
@ -887,22 +748,79 @@ _mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum *sources,
GLenum *types, GLenum *ids, GLenum *severities,
GLsizei *lengths, GLchar *messageLog)
{
const char *callerstr = "glGetDebugMessageLog";
GET_CURRENT_CONTEXT(ctx);
GLuint ret;
return get_message_log(count, logSize, sources, types, ids, severities,
lengths, messageLog, MESSAGE_LOG, callerstr);
if (!messageLog)
logSize = 0;
if (logSize < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetDebugMessageLog(logSize=%d : logSize must not be"
" negative)", logSize);
return 0;
}
for (ret = 0; ret < count; ret++) {
GLsizei written = get_msg(ctx, sources, types, ids, severities,
logSize, messageLog);
if (!written)
break;
if (messageLog) {
messageLog += written;
logSize -= written;
}
if (lengths) {
*lengths = written;
lengths++;
}
if (severities)
severities++;
if (sources)
sources++;
if (types)
types++;
if (ids)
ids++;
}
return ret;
}
void GLAPIENTRY
_mesa_DebugMessageControl(GLenum source, GLenum type, GLenum severity,
GLsizei count, const GLuint *ids,
GLboolean enabled)
_mesa_DebugMessageControl(GLenum gl_source, GLenum gl_type,
GLenum gl_severity, GLsizei count,
const GLuint *ids, GLboolean enabled)
{
const char *callerstr = "glDebugMessageControl";
message_control(source, type, severity, count, ids,
enabled, CONTROL, callerstr);
GET_CURRENT_CONTEXT(ctx);
if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(count=%d : count must not be negative)", callerstr,
count);
return;
}
if (!validate_params(ctx, CONTROL, callerstr, gl_source, gl_type,
gl_severity))
return; /* GL_INVALID_ENUM */
if (count && (gl_severity != GL_DONT_CARE || gl_type == GL_DONT_CARE
|| gl_source == GL_DONT_CARE)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(When passing an array of ids, severity must be"
" GL_DONT_CARE, and source and type must not be GL_DONT_CARE.",
callerstr);
return;
}
control_app_messages(ctx, gl_source, gl_type, gl_severity,
count, ids, enabled);
}
@ -914,7 +832,6 @@ _mesa_DebugMessageCallback(GLDEBUGPROC callback, const void *userParam)
if (debug) {
debug->Callback = callback;
debug->CallbackData = userParam;
debug->ARBCallback = GL_FALSE;
}
}
@ -1041,60 +958,6 @@ _mesa_PopDebugGroup(void)
}
void GLAPIENTRY
_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id,
GLenum severity, GLint length,
const GLcharARB *buf)
{
const char *callerstr = "glDebugMessageInsertARB";
GET_CURRENT_CONTEXT(ctx);
if (!validate_params(ctx, INSERT_ARB, callerstr, source, type, severity))
return; /* GL_INVALID_ENUM */
message_insert(source, type, id, severity, length, buf, callerstr);
}
GLuint GLAPIENTRY
_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum *sources,
GLenum *types, GLenum *ids, GLenum *severities,
GLsizei *lengths, GLcharARB *messageLog)
{
const char *callerstr = "glGetDebugMessageLogARB";
return get_message_log(count, logSize, sources, types, ids, severities,
lengths, messageLog, MESSAGE_LOG_ARB, callerstr);
}
void GLAPIENTRY
_mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type,
GLenum gl_severity,
GLsizei count, const GLuint *ids,
GLboolean enabled)
{
const char *callerstr = "glDebugMessageControlARB";
message_control(gl_source, gl_type, gl_severity, count, ids,
enabled, CONTROL_ARB, callerstr);
}
void GLAPIENTRY
_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_debug_state *debug = _mesa_get_debug_state(ctx);
if (debug) {
debug->Callback = callback;
debug->CallbackData = userParam;
debug->ARBCallback = GL_TRUE;
}
}
void
_mesa_init_errors(struct gl_context *ctx)
{

View File

@ -91,21 +91,6 @@ _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
const char *msg, int len);
void GLAPIENTRY
_mesa_DebugMessageInsertARB(GLenum source, GLenum type, GLuint id,
GLenum severity, GLint length,
const GLcharARB* buf);
GLuint GLAPIENTRY
_mesa_GetDebugMessageLogARB(GLuint count, GLsizei logSize, GLenum* sources,
GLenum* types, GLenum* ids, GLenum* severities,
GLsizei* lengths, GLcharARB* messageLog);
void GLAPIENTRY
_mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity,
GLsizei count, const GLuint *ids,
GLboolean enabled);
void GLAPIENTRY
_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback,
const void *userParam);
void GLAPIENTRY
_mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
GLenum severity, GLint length,
const GLchar* buf);

View File

@ -3845,7 +3845,6 @@ struct gl_debug_state
const void *CallbackData;
GLboolean SyncOutput;
GLboolean DebugOutput;
GLboolean ARBCallback; /* Used to track if current callback is of type ARB_debug_output or KHR_debug */
GLboolean Defaults[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
struct gl_debug_namespace Namespaces[MAX_DEBUG_GROUP_STACK_DEPTH][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT];
struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES];

View File

@ -797,10 +797,6 @@ const struct function gl_core_functions_possible[] = {
{ "glGetFloati_v", 43, -1 },
{ "glGetDoublei_v", 43, -1 },
// { "glCreateSyncFromCLeventARB", 43, -1 }, // XXX: Add to xml
{ "glDebugMessageControlARB", 43, -1 },
{ "glDebugMessageInsertARB", 43, -1 },
{ "glDebugMessageCallbackARB", 43, -1 },
{ "glGetDebugMessageLogARB", 43, -1 },
{ "glGetGraphicsResetStatusARB", 43, -1 },
{ "glGetnMapdvARB", 43, -1 },
{ "glGetnMapfvARB", 43, -1 },
@ -836,16 +832,6 @@ const struct function gl_core_functions_possible[] = {
{ "glTextureStorage1DEXT", 43, -1 },
{ "glTextureStorage2DEXT", 43, -1 },
{ "glTextureStorage3DEXT", 43, -1 },
// { "glDebugMessageControl", 43, -1 }, // XXX: Add to xml
// { "glDebugMessageInsert", 43, -1 }, // XXX: Add to xml
// { "glDebugMessageCallback", 43, -1 }, // XXX: Add to xml
// { "glGetDebugMessageLog", 43, -1 }, // XXX: Add to xml
// { "glPushDebugGroup", 43, -1 }, // XXX: Add to xml
// { "glPopDebugGroup", 43, -1 }, // XXX: Add to xml
// { "glObjectLabel", 43, -1 }, // XXX: Add to xml
// { "glGetObjectLabel", 43, -1 }, // XXX: Add to xml
// { "glObjectPtrLabel", 43, -1 }, // XXX: Add to xml
// { "glGetObjectPtrLabel", 43, -1 }, // XXX: Add to xml
{ "glClearBufferData", 43, -1 },
{ "glClearBufferSubData", 43, -1 },
// { "glClearNamedBufferDataEXT", 43, -1 }, // XXX: Add to xml
@ -896,7 +882,7 @@ const struct function gl_core_functions_possible[] = {
/* GL_ARB_internalformat_query */
{ "glGetInternalformativ", 30, -1 },
/* GL_KHR_debug */
/* GL_KHR_debug/GL_ARB_debug_output */
{ "glPushDebugGroup", 11, -1 },
{ "glPopDebugGroup", 11, -1 },
{ "glDebugMessageCallback", 11, -1 },
@ -907,6 +893,11 @@ const struct function gl_core_functions_possible[] = {
{ "glGetObjectPtrLabel", 11, -1 },
{ "glObjectLabel", 11, -1 },
{ "glObjectPtrLabel", 11, -1 },
/* aliased versions checked above */
//{ "glDebugMessageControlARB", 11, -1 },
//{ "glDebugMessageInsertARB", 11, -1 },
//{ "glDebugMessageCallbackARB", 11, -1 },
//{ "glGetDebugMessageLogARB", 11, -1 },
/* GL_AMD_performance_monitor */
{ "glGetPerfMonitorGroupsAMD", 11, -1 },