vkd3d: Introduce vkd3d_application_info.

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-05-10 14:15:21 +02:00 committed by Alexandre Julliard
parent 58e0a89d76
commit 08e2e583b5
3 changed files with 94 additions and 3 deletions

View File

@ -43,6 +43,7 @@ enum vkd3d_structure_type
VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO,
VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO,
VKD3D_STRUCTURE_TYPE_APPLICATION_INFO,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_STRUCTURE_TYPE),
};
@ -83,6 +84,19 @@ struct vkd3d_optional_instance_extensions_info
uint32_t extension_count;
};
/* Extends vkd3d_instance_create_info. */
struct vkd3d_application_info
{
enum vkd3d_structure_type type;
const void *next;
const char *application_name;
uint32_t application_version;
const char *engine_name; /* "vkd3d" if NULL */
uint32_t engine_version; /* vkd3d version if engine_name is NULL */
};
struct vkd3d_device_create_info
{
enum vkd3d_structure_type type;

View File

@ -18,6 +18,8 @@
#include "vkd3d_private.h"
#include <ctype.h>
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
@ -104,6 +106,25 @@ static void *vk_find_struct_(struct vk_struct *chain, VkStructureType sType)
return NULL;
}
static uint32_t vkd3d_get_vk_version(void)
{
const char *ptr = PACKAGE_VERSION;
int major, minor;
major = atoi(ptr);
while (isdigit(*ptr))
++ptr;
if (*ptr == '.')
++ptr;
minor = atoi(ptr);
TRACE("Version %d.%d.\n", major, minor);
return VK_MAKE_VERSION(major, minor, 0);
}
struct vkd3d_optional_extension_info
{
const char *extension_name;
@ -459,6 +480,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
{
const struct vkd3d_vk_global_procs *vk_global_procs = &instance->vk_global_procs;
const struct vkd3d_optional_instance_extensions_info *optional_extensions;
const struct vkd3d_application_info *vkd3d_application_info;
bool *user_extension_supported = NULL;
VkApplicationInfo application_info;
VkInstanceCreateInfo instance_info;
@ -509,12 +531,23 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
application_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
application_info.pNext = NULL;
application_info.pApplicationName = PACKAGE_NAME;
application_info.pApplicationName = NULL;
application_info.applicationVersion = 0;
application_info.pEngineName = NULL;
application_info.engineVersion = 0;
application_info.pEngineName = PACKAGE_NAME;
application_info.engineVersion = vkd3d_get_vk_version();
application_info.apiVersion = VK_API_VERSION_1_0;
if ((vkd3d_application_info = vkd3d_find_struct(create_info->next, APPLICATION_INFO)))
{
application_info.pApplicationName = vkd3d_application_info->application_name;
application_info.applicationVersion = vkd3d_application_info->application_version;
if (vkd3d_application_info->engine_name)
{
application_info.pEngineName = vkd3d_application_info->engine_name;
application_info.engineVersion = vkd3d_application_info->engine_version;
}
}
if (!(extensions = vkd3d_calloc(extension_count, sizeof(*extensions))))
{
if (instance->libvulkan)

View File

@ -1052,6 +1052,49 @@ static void test_formats(void)
}
}
static void test_application_info(void)
{
struct vkd3d_instance_create_info create_info;
struct vkd3d_application_info app_info;
struct vkd3d_instance *instance;
ULONG refcount;
HRESULT hr;
app_info.type = VKD3D_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.next = NULL;
app_info.engine_name = NULL;
app_info.engine_version = 0;
app_info.application_name = NULL;
app_info.application_version = 0;
create_info = instance_default_create_info;
create_info.next = &app_info;
hr = vkd3d_create_instance(&create_info, &instance);
ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr);
refcount = vkd3d_instance_decref(instance);
ok(!refcount, "Instance has %u references left.\n", refcount);
app_info.application_name = "vkd3d_api_tests";
app_info.application_version = 0xdeadbeef;
hr = vkd3d_create_instance(&create_info, &instance);
ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr);
refcount = vkd3d_instance_decref(instance);
ok(!refcount, "Instance has %u references left.\n", refcount);
app_info.engine_name = "engine_name";
hr = vkd3d_create_instance(&create_info, &instance);
ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr);
refcount = vkd3d_instance_decref(instance);
ok(!refcount, "Instance has %u references left.\n", refcount);
app_info.engine_name = "engine_name";
app_info.engine_version = 2;
hr = vkd3d_create_instance(&create_info, &instance);
ok(hr == S_OK, "Failed to create instance, hr %#x.\n", hr);
refcount = vkd3d_instance_decref(instance);
ok(!refcount, "Instance has %u references left.\n", refcount);
}
static bool have_d3d12_device(void)
{
ID3D12Device *device;
@ -1083,4 +1126,5 @@ START_TEST(vkd3d_api)
run_test(test_external_resource_map);
run_test(test_external_resource_present_state);
run_test(test_formats);
run_test(test_application_info);
}