[PATCH vkd3d 5/6] vkd3d: Try to guess application name.
Józef Kucia
joseph.kucia at gmail.com
Tue May 7 08:37:05 CDT 2019
From: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
libs/vkd3d/device.c | 7 +++++--
libs/vkd3d/utils.c | 31 +++++++++++++++++++++++++++++++
libs/vkd3d/vkd3d_private.h | 2 ++
3 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 3476fdead708..4b5e4492ac3f 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -527,8 +527,6 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
application_info.pNext = NULL;
- application_info.pApplicationName = NULL;
- application_info.applicationVersion = 0;
application_info.pEngineName = PACKAGE_NAME;
application_info.engineVersion = vkd3d_get_vk_version();
application_info.apiVersion = VK_API_VERSION_1_0;
@@ -543,6 +541,11 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
application_info.engineVersion = vkd3d_application_info->engine_version;
}
}
+ else
+ {
+ application_info.pApplicationName = vkd3d_get_program_name();
+ application_info.applicationVersion = 0;
+ }
if (!(extensions = vkd3d_calloc(extension_count, sizeof(*extensions))))
{
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index ea468b37d37d..21919815537a 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -602,6 +602,37 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
return S_OK;
}
+const char *vkd3d_get_program_name(void)
+{
+#ifdef _GNU_SOURCE
+ char *name;
+
+ if ((name = strrchr(program_invocation_name, '/')))
+ {
+ const char *path = realpath("/proc/self/exe", NULL);
+
+ /* Try to strip command line arguments. */
+ if (path && !strncmp(path, program_invocation_name, strlen(path)))
+ {
+ const char *p = strrchr(path, '/');
+
+ if (p)
+ return p + 1;
+ }
+
+ return name + 1;
+ }
+
+ if ((name = strrchr(program_invocation_name, '\\')))
+ return name + 1;
+
+ return program_invocation_name;
+
+#else
+ return NULL;
+#endif
+}
+
static struct vkd3d_private_data *vkd3d_private_store_get_private_data(
const struct vkd3d_private_store *store, const GUID *tag)
{
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 057a0a7c0dea..da177d346ec9 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1126,6 +1126,8 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
extern const char vkd3d_build[];
+const char *vkd3d_get_program_name(void) DECLSPEC_HIDDEN;
+
static inline void vkd3d_set_thread_name(const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP_2)
--
2.21.0
More information about the wine-devel
mailing list