From a68c584d70be5254c68beeb2e54ba2e9113196fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Date: Thu, 23 Oct 2025 13:08:37 +0100 Subject: [PATCH] mesa: gallium: make GL object maximum label length a pipescreen cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit a4ffd2395f70 ("mesa: Implement label sharing from GL objects with UM drivers") enabled GL clients to tag objects at a UM driver level. In the case of Panfrost, and for both KMDs, maximum label size is set to 4096, but the Mesa limit is much lower. Since glObjectLabel() allocates object labels dynamically, there's no need to have this value chiseled in stone, so allow Gallium driver implementers to set their own limit through a pipe screen capability. Keep the same default maximum label length as before. Signed-off-by: Adrián Larumbe Reviewed-by: Erik Faye-Lund Reviewed-by: Eric R. Smith Part-of: --- src/gallium/auxiliary/util/u_screen.c | 2 ++ src/gallium/include/pipe/p_defines.h | 1 + src/mesa/main/config.h | 1 - src/mesa/main/get_hash_params.py | 2 +- src/mesa/main/objectlabel.c | 13 +++++++------ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 19e7bcdbf98..3a7730f9701 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -187,6 +187,8 @@ u_init_pipe_screen_caps(struct pipe_screen *pscreen, int accel) caps->min_vma = caps->max_vma = 0; + + caps->max_label_length = 256; } uint64_t u_default_get_timestamp(UNUSED struct pipe_screen *screen) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index ae0fdba1a9c..80ebf2872d2 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -1126,6 +1126,7 @@ struct pipe_caps { unsigned shader_subgroup_supported_stages; unsigned shader_subgroup_supported_features; unsigned multiview; + unsigned max_label_length; uint64_t max_timeline_semaphore_difference; /** for CL SVM */ diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index ba2b6da1c69..cb7b444fcfb 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -242,7 +242,6 @@ /** For GL_KHR_debug */ /*@{*/ -#define MAX_LABEL_LENGTH 256 #define MAX_DEBUG_GROUP_STACK_DEPTH 64 /*@}*/ diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index 9af400986f3..e009038f1c1 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -127,7 +127,7 @@ descriptor=[ [ "DEBUG_NEXT_LOGGED_MESSAGE_LENGTH", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ], [ "MAX_DEBUG_LOGGED_MESSAGES", "CONST(MAX_DEBUG_LOGGED_MESSAGES), NO_EXTRA" ], [ "MAX_DEBUG_MESSAGE_LENGTH", "CONST(MAX_DEBUG_MESSAGE_LENGTH), NO_EXTRA" ], - [ "MAX_LABEL_LENGTH", "CONST(MAX_LABEL_LENGTH), NO_EXTRA" ], + [ "MAX_LABEL_LENGTH", "CAPS_UINT(max_label_length), NO_EXTRA" ], [ "MAX_DEBUG_GROUP_STACK_DEPTH", "CONST(MAX_DEBUG_GROUP_STACK_DEPTH), NO_EXTRA" ], [ "DEBUG_GROUP_STACK_DEPTH", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ], diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c index 69c0aa992e5..c224be281a6 100644 --- a/src/mesa/main/objectlabel.c +++ b/src/mesa/main/objectlabel.c @@ -125,6 +125,7 @@ static void set_label(struct gl_context *ctx, GLenum identifier, GLuint name, char **labelPtr, const char *label, int length, const char *caller, bool ext_length) { + unsigned max_label_len = ctx->screen->caps.max_label_length; char *old_label = *labelPtr; *labelPtr = NULL; @@ -132,11 +133,11 @@ set_label(struct gl_context *ctx, GLenum identifier, GLuint name, char **labelPt if (label) { if ((!ext_length && length >= 0) || (ext_length && length > 0)) { - if (length >= MAX_LABEL_LENGTH) + if (length >= max_label_len) _mesa_error(ctx, GL_INVALID_VALUE, "%s(length=%d, which is not less than " - "GL_MAX_LABEL_LENGTH=%d)", caller, length, - MAX_LABEL_LENGTH); + "GL_MAX_LABEL_LENGTH=%u)", caller, length, + max_label_len); /* explicit length */ *labelPtr = malloc(length+1); @@ -157,11 +158,11 @@ set_label(struct gl_context *ctx, GLenum identifier, GLuint name, char **labelPt } int len = strlen(label); - if (len >= MAX_LABEL_LENGTH) + if (len >= max_label_len) _mesa_error(ctx, GL_INVALID_VALUE, "%s(label length=%d, which is not less than " - "GL_MAX_LABEL_LENGTH=%d)", caller, len, - MAX_LABEL_LENGTH); + "GL_MAX_LABEL_LENGTH=%u)", caller, len, + max_label_len); /* null-terminated string */ *labelPtr = strdup(label);