vkd3d: Try to guess application name.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-06-17 15:43:28 +02:00 committed by Alexandre Julliard
parent 0bde4c7dca
commit 3d681737c9
3 changed files with 53 additions and 0 deletions

View File

@ -467,6 +467,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
bool *user_extension_supported = NULL;
VkApplicationInfo application_info;
VkInstanceCreateInfo instance_info;
char application_name[PATH_MAX];
uint32_t extension_count;
const char **extensions;
VkInstance vk_instance;
@ -530,6 +531,12 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
application_info.engineVersion = vkd3d_application_info->engine_version;
}
}
else if (vkd3d_get_program_name(application_name))
{
application_info.pApplicationName = application_name;
}
TRACE("Application: %s.\n", debugstr_a(application_info.pApplicationName));
if (!(extensions = vkd3d_calloc(extension_count, sizeof(*extensions))))
{

View File

@ -602,6 +602,50 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
return S_OK;
}
#ifdef _GNU_SOURCE
bool vkd3d_get_program_name(char program_name[PATH_MAX])
{
char *name, *p, *real_path = NULL;
if ((name = strrchr(program_invocation_name, '/')))
{
real_path = realpath("/proc/self/exe", NULL);
/* Try to strip command line arguments. */
if (real_path && (p = strrchr(real_path, '/'))
&& !strncmp(real_path, program_invocation_name, strlen(real_path)))
{
name = p;
}
++name;
}
else if ((name = strrchr(program_invocation_name, '\\')))
{
++name;
}
else
{
name = program_invocation_name;
}
strncpy(program_name, name, PATH_MAX);
program_name[PATH_MAX - 1] = '\0';
free(real_path);
return true;
}
#else
bool vkd3d_get_program_name(char program_name[PATH_MAX])
{
*program_name = '\0';
return false;
}
#endif /* _GNU_SOURCE */
static struct vkd3d_private_data *vkd3d_private_store_get_private_data(
const struct vkd3d_private_store *store, const GUID *tag)
{

View File

@ -1203,6 +1203,8 @@ HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
extern const char vkd3d_build[];
bool vkd3d_get_program_name(char program_name[PATH_MAX]) DECLSPEC_HIDDEN;
static inline void vkd3d_set_thread_name(const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP_2)