[PATCH v2 vkd3d 5/6] vkd3d: Try to guess application name.
Józef Kucia
joseph.kucia at gmail.com
Fri May 10 07:15:22 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 ae8893de11a4..d2e7bc735845 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -531,8 +531,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;
@@ -547,6 +545,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 402ac0aaa791..62562f8f3b03 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1130,6 +1130,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