diff options
author | Ryan Neph <ryanneph@google.com> | 2023-01-13 16:54:02 -0800 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-01-18 20:02:06 +0000 |
commit | 2b61218a23b5a7da533e8183611af98214bf70ab (patch) | |
tree | 0341ef51d400c8164b7e64f0c3e5210b1abdefa5 /server | |
parent | 96b2b6828d2741e6b43ad415b3401d8ac73aed00 (diff) |
server: expand known context names for native driver config
Guest Linux kernel's virtgpu driver only gets 15 chars of the guest
application name via get_task_comm(). While a better method is devised
to send the full name, do host-side substring expansion for known apps
that must have app-specific native driver configuration applied.
Signed-off-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1021>
Diffstat (limited to 'server')
-rw-r--r-- | server/render_context.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/server/render_context.c b/server/render_context.c index 5f9336a..b2e2e83 100644 --- a/server/render_context.c +++ b/server/render_context.c @@ -295,19 +295,40 @@ render_context_set_thread_name(uint32_t ctx_id, UNUSED const char *ctx_name) u_thread_setname(thread_name); } +static const char *ctx_name_expansions[] = { + "DOOMEternalx64vk.exe", +}; + static bool render_context_init_name(struct render_context *ctx, uint32_t ctx_id, const char *ctx_name) { - ctx->name_len = strlen(ctx_name); - ctx->name = malloc(ctx->name_len + 1); + /* Linux guests may only pass the first 15 chars of a guest application name, + * plus a null terminator. In that case, attempt substring matching and + * expansion to enable proper dri-conf lookup in native mesa drivers. + */ + static const size_t truncated_name_len = 15; + size_t name_len = strlen(ctx_name); + if (name_len == truncated_name_len) { + for (uint32_t i = 0; i < ARRAY_SIZE(ctx_name_expansions); i++) { + const char *full = ctx_name_expansions[i]; + if (!strncmp(ctx_name, full, truncated_name_len)) { + ctx_name = full; + name_len = strlen(full); + break; + } + } + } + + ctx->name_len = name_len; + ctx->name = malloc(name_len + 1); if (!ctx->name) return false; strcpy(ctx->name, ctx_name); - render_context_set_thread_name(ctx_id, ctx_name); + render_context_set_thread_name(ctx_id, ctx->name); #ifdef _GNU_SOURCE /* Sets the guest app executable name used by mesa to load app-specific driver |