2
* Copyright © 2021 Intel Corporation
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
#include "vk_dispatch_table.h"
27
#include "vk_extensions.h"
28
#include "vk_object.h"
30
#include "c11/threads.h"
31
#include "util/list.h"
38
/** VkApplicationInfo::pApplicationName */
41
/** VkApplicationInfo::applicationVersion */
44
/** VkApplicationInfo::pEngineName */
45
const char* engine_name;
47
/** VkApplicationInfo::engineVersion */
48
uint32_t engine_version;
50
/** VkApplicationInfo::apiVersion or `VK_API_VERSION_1_0`
52
* If the application does not provide a `pApplicationInfo` or the
53
* `apiVersion` field is 0, this is set to `VK_API_VERSION_1_0`.
58
/** Base struct for all `VkInstance` implementations
60
* This contains data structures necessary for detecting enabled extensions,
61
* handling entrypoint dispatch, and implementing `vkGetInstanceProcAddr()`.
62
* It also contains data copied from the `VkInstanceCreateInfo` such as the
63
* application information.
66
struct vk_object_base base;
68
/** Allocator used when creating this instance
70
* This is used as a fall-back for when a NULL pAllocator is passed into a
71
* device-level create function such as vkCreateImage().
73
VkAllocationCallbacks alloc;
75
/** VkInstanceCreateInfo::pApplicationInfo */
76
struct vk_app_info app_info;
78
/** Table of all enabled instance extensions
80
* This is generated automatically as part of `vk_instance_init()` from
81
* VkInstanceCreateInfo::ppEnabledExtensionNames.
83
struct vk_instance_extension_table enabled_extensions;
85
/** Instance-level dispatch table */
86
struct vk_instance_dispatch_table dispatch_table;
88
/* VK_EXT_debug_report debug callbacks */
90
mtx_t callbacks_mutex;
91
struct list_head callbacks;
94
/* VK_EXT_debug_utils */
96
/* These callbacks are only used while creating or destroying an
99
struct list_head instance_callbacks;
100
mtx_t callbacks_mutex;
101
/* Persistent callbacks */
102
struct list_head callbacks;
106
VK_DEFINE_HANDLE_CASTS(vk_instance, base, VkInstance,
107
VK_OBJECT_TYPE_INSTANCE);
109
/** Initialize a vk_instance
111
* Along with initializing the data structures in `vk_instance`, this function
112
* validates the Vulkan version number provided by the client and checks that
113
* every extension specified by
114
* `VkInstanceCreateInfo::ppEnabledExtensionNames` is actually supported by
115
* the implementation and returns `VK_ERROR_EXTENSION_NOT_PRESENT` if an
116
* unsupported extension is requested.
118
* @param[out] instance The instance to initialize
119
* @param[in] supported_extensions Table of all instance extensions supported
121
* @param[in] dispatch_table Instance-level dispatch table
122
* @param[in] pCreateInfo VkInstanceCreateInfo pointer passed to
123
* `vkCreateInstance()`
124
* @param[in] alloc Allocation callbacks used to create this
125
* instance; must not be `NULL`
128
vk_instance_init(struct vk_instance *instance,
129
const struct vk_instance_extension_table *supported_extensions,
130
const struct vk_instance_dispatch_table *dispatch_table,
131
const VkInstanceCreateInfo *pCreateInfo,
132
const VkAllocationCallbacks *alloc);
134
/** Tears down a vk_instance
136
* @param[out] instance The instance to tear down
139
vk_instance_finish(struct vk_instance *instance);
141
/** Implementaiton of vkEnumerateInstanceExtensionProperties() */
143
vk_enumerate_instance_extension_properties(
144
const struct vk_instance_extension_table *supported_extensions,
145
uint32_t *pPropertyCount,
146
VkExtensionProperties *pProperties);
148
/** Implementaiton of vkGetInstanceProcAddr() */
150
vk_instance_get_proc_addr(const struct vk_instance *instance,
151
const struct vk_instance_entrypoint_table *entrypoints,
154
/** Unchecked version of vk_instance_get_proc_addr
156
* This is identical to `vk_instance_get_proc_addr()` except that it doesn't
157
* check whether extensions are enabled before returning function pointers.
158
* This is useful in window-system code where we may use extensions without
159
* the client explicitly enabling them.
162
vk_instance_get_proc_addr_unchecked(const struct vk_instance *instance,
165
/** Implementaiton of vk_icdGetPhysicalDeviceProcAddr() */
167
vk_instance_get_physical_device_proc_addr(const struct vk_instance *instance,
174
#endif /* VK_INSTANCE_H */