diff options
author | Timothy Arceri <tarceri@itsqueeze.com> | 2022-10-06 10:44:39 +1100 |
---|---|---|
committer | Timothy Arceri <tarceri@itsqueeze.com> | 2022-10-17 08:53:20 +1100 |
commit | 675bcbb7a1c0111dc907f189b4a2de18397e6f23 (patch) | |
tree | a918b07fae3bbf00ba3c2b15e5e50f3d6d298792 /src | |
parent | 70fef476334297c51ed237aa3044e3003ffd5a5e (diff) |
mesa: add EXT_debug_label support
KHR_debug provides the same functionality but this extension is
still in use and adding support for it seems fairly harmless.
For example its used by Unity and without it we keep
getting given apitraces from Unity games that just spew out
unsupported function errors due to the missing support.
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19029>
Diffstat (limited to 'src')
-rw-r--r-- | src/mapi/glapi/gen/gl_API.xml | 17 | ||||
-rw-r--r-- | src/mapi/glapi/gen/static_data.py | 4 | ||||
-rw-r--r-- | src/mesa/main/extensions_table.h | 1 | ||||
-rw-r--r-- | src/mesa/main/objectlabel.c | 68 |
4 files changed, 82 insertions, 8 deletions
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 0d2c9aaf690..7eb25f87a9b 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -12595,6 +12595,23 @@ <enum name="GPU_MEMORY_INFO_EVICTED_MEMORY_NVX" value="0x904B" /> </category> +<category name="GL_EXT_debug_label" number="439"> + <function name="LabelObjectEXT" es1="1.1" es2="2.0"> + <param name="type" type="GLenum"/> + <param name="object" type="GLuint"/> + <param name="length" type="GLsizei"/> + <param name="label" type="const GLchar *"/> + </function> + + <function name="GetObjectLabelEXT" es1="1.1" es2="2.0"> + <param name="type" type="GLenum"/> + <param name="object" type="GLuint"/> + <param name="bufSize" type="GLsizei"/> + <param name="length" type="GLsizei *"/> + <param name="label" type="GLchar *"/> + </function> +</category> + <xi:include href="AMD_gpu_shader_int64.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <category name="GL_NV_fill_rectangle" number="466"> diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 95b6541a07c..0a147b2fe09 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1695,6 +1695,8 @@ offsets = { "ImportSemaphoreWin32HandleEXT": 1659, "ImportMemoryWin32NameEXT": 1660, "ImportSemaphoreWin32NameEXT": 1661, + "GetObjectLabelEXT": 1662, + "LabelObjectEXT": 1663, } functions = [ @@ -2139,6 +2141,7 @@ functions = [ "GetnUniformuiv", "GetnUniformuivARB", "GetObjectLabel", + "GetObjectLabelEXT" "GetObjectParameterfvARB", "GetObjectParameterivARB", "GetObjectPtrLabel", @@ -2270,6 +2273,7 @@ functions = [ "IsTextureEXT", "IsTransformFeedback", "IsVertexArray", + "LabelObjectEXT", "Lightf", "Lightfv", "Lighti", diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 0d2851e0a5a..307b5d3bc1d 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -232,6 +232,7 @@ EXT(EXT_compiled_vertex_array , dummy_true EXT(EXT_compressed_ETC1_RGB8_sub_texture , OES_compressed_ETC1_RGB8_texture , x , x , ES1, ES2, 2014) EXT(EXT_copy_image , OES_copy_image , x , x , x , 30, 2014) EXT(EXT_copy_texture , dummy_true , GLL, x , x , x , 1995) +EXT(EXT_debug_label , dummy_true , GLL, GLC, 11, ES2, 2013) EXT(EXT_demote_to_helper_invocation , EXT_demote_to_helper_invocation , GLL, GLC, ES1, ES2, 2019) EXT(EXT_depth_bounds_test , EXT_depth_bounds_test , GLL, GLC, x , x , 2002) EXT(EXT_depth_clamp , ARB_depth_clamp , x , x , x , ES2, 2019) diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index ed9dfd40d35..02e950b10bd 100644 --- a/src/mesa/main/objectlabel.c +++ b/src/mesa/main/objectlabel.c @@ -44,14 +44,15 @@ */ static void set_label(struct gl_context *ctx, char **labelPtr, const char *label, - int length, const char *caller) + int length, const char *caller, bool ext_length) { free(*labelPtr); *labelPtr = NULL; /* set new label string */ if (label) { - if (length >= 0) { + if ((!ext_length && length >= 0) || + (ext_length && length > 0)) { if (length >= MAX_LABEL_LENGTH) _mesa_error(ctx, GL_INVALID_VALUE, "%s(length=%d, which is not less than " @@ -69,6 +70,13 @@ set_label(struct gl_context *ctx, char **labelPtr, const char *label, } } else { + if (ext_length && length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(label length=%d, is less than zero)", caller, + length); + return; + } + int len = strlen(label); if (len >= MAX_LABEL_LENGTH) _mesa_error(ctx, GL_INVALID_VALUE, @@ -133,12 +141,15 @@ copy_label(const GLchar *src, GLchar *dst, GLsizei *length, GLsizei bufSize) */ static char ** get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, - const char *caller) + const char *caller, bool ext_errors) { char **labelPtr = NULL; + GLenum no_match_error = + ext_errors ? GL_INVALID_OPERATION : GL_INVALID_VALUE; switch (identifier) { case GL_BUFFER: + case GL_BUFFER_OBJECT_EXT: { struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, name); if (bufObj) @@ -146,6 +157,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } break; case GL_SHADER: + case GL_SHADER_OBJECT_EXT: { struct gl_shader *shader = _mesa_lookup_shader(ctx, name); if (shader) @@ -153,6 +165,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } break; case GL_PROGRAM: + case GL_PROGRAM_OBJECT_EXT: { struct gl_shader_program *program = _mesa_lookup_shader_program(ctx, name); @@ -161,6 +174,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } break; case GL_VERTEX_ARRAY: + case GL_VERTEX_ARRAY_OBJECT_EXT: { struct gl_vertex_array_object *obj = _mesa_lookup_vao(ctx, name); if (obj) @@ -168,6 +182,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } break; case GL_QUERY: + case GL_QUERY_OBJECT_EXT: { struct gl_query_object *query = _mesa_lookup_query_object(ctx, name); if (query) @@ -225,6 +240,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } break; case GL_PROGRAM_PIPELINE: + case GL_PROGRAM_PIPELINE_OBJECT_EXT: { struct gl_pipeline_object *pipe = _mesa_lookup_pipeline_object(ctx, name); @@ -237,7 +253,7 @@ get_label_pointer(struct gl_context *ctx, GLenum identifier, GLuint name, } if (NULL == labelPtr) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s(name = %u)", caller, name); + _mesa_error(ctx, no_match_error, "%s(name = %u)", caller, name); } return labelPtr; @@ -249,6 +265,42 @@ invalid_enum: } void GLAPIENTRY +_mesa_LabelObjectEXT(GLenum identifier, GLuint name, GLsizei length, + const GLchar *label) +{ + GET_CURRENT_CONTEXT(ctx); + const char *callerstr = "glLabelObjectEXT"; + char **labelPtr; + + labelPtr = get_label_pointer(ctx, identifier, name, callerstr, true); + if (!labelPtr) + return; + + set_label(ctx, labelPtr, label, length, callerstr, true); +} + +void GLAPIENTRY +_mesa_GetObjectLabelEXT(GLenum identifier, GLuint name, GLsizei bufSize, + GLsizei *length, GLchar *label) +{ + GET_CURRENT_CONTEXT(ctx); + const char *callerstr = "glGetObjectLabelEXT"; + char **labelPtr; + + if (bufSize < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(bufSize = %d)", callerstr, + bufSize); + return; + } + + labelPtr = get_label_pointer(ctx, identifier, name, callerstr, true); + if (!labelPtr) + return; + + copy_label(*labelPtr, label, length, bufSize); +} + +void GLAPIENTRY _mesa_ObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label) { @@ -261,11 +313,11 @@ _mesa_ObjectLabel(GLenum identifier, GLuint name, GLsizei length, else callerstr = "glObjectLabelKHR"; - labelPtr = get_label_pointer(ctx, identifier, name, callerstr); + labelPtr = get_label_pointer(ctx, identifier, name, callerstr, false); if (!labelPtr) return; - set_label(ctx, labelPtr, label, length, callerstr); + set_label(ctx, labelPtr, label, length, callerstr, false); } void GLAPIENTRY @@ -287,7 +339,7 @@ _mesa_GetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, return; } - labelPtr = get_label_pointer(ctx, identifier, name, callerstr); + labelPtr = get_label_pointer(ctx, identifier, name, callerstr, false); if (!labelPtr) return; @@ -317,7 +369,7 @@ _mesa_ObjectPtrLabel(const void *ptr, GLsizei length, const GLchar *label) labelPtr = &syncObj->Label; - set_label(ctx, labelPtr, label, length, callerstr); + set_label(ctx, labelPtr, label, length, callerstr, false); _mesa_unref_sync_object(ctx, syncObj, 1); } |