Home | History | Annotate | Line # | Download | only in util
      1 /*
      2  * Copyright  2021 Intel Corporation
      3  *
      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:
     10  *
     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
     13  * Software.
     14  *
     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
     21  * IN THE SOFTWARE.
     22  */
     23 #ifndef VK_INSTANCE_H
     24 #define VK_INSTANCE_H
     25 
     26 #include "vk_dispatch_table.h"
     27 #include "vk_extensions.h"
     28 #include "vk_object.h"
     29 
     30 #include "c11/threads.h"
     31 #include "util/list.h"
     32 
     33 #ifdef __cplusplus
     34 extern "C" {
     35 #endif
     36 
     37 struct vk_app_info {
     38    const char*        app_name;
     39    uint32_t           app_version;
     40    const char*        engine_name;
     41    uint32_t           engine_version;
     42    uint32_t           api_version;
     43 };
     44 
     45 struct vk_instance {
     46    struct vk_object_base base;
     47    VkAllocationCallbacks alloc;
     48 
     49    struct vk_app_info app_info;
     50    struct vk_instance_extension_table enabled_extensions;
     51 
     52    struct vk_instance_dispatch_table dispatch_table;
     53 
     54    /* VK_EXT_debug_report debug callbacks */
     55    struct {
     56       mtx_t callbacks_mutex;
     57       struct list_head callbacks;
     58    } debug_report;
     59 
     60    /* VK_EXT_debug_utils */
     61    struct {
     62       /* These callbacks are only used while creating or destroying an
     63        * instance
     64        */
     65       struct list_head instance_callbacks;
     66       mtx_t callbacks_mutex;
     67       /* Persistent callbacks */
     68       struct list_head callbacks;
     69    } debug_utils;
     70 };
     71 
     72 VK_DEFINE_HANDLE_CASTS(vk_instance, base, VkInstance,
     73                        VK_OBJECT_TYPE_INSTANCE)
     74 
     75 VkResult MUST_CHECK
     76 vk_instance_init(struct vk_instance *instance,
     77                  const struct vk_instance_extension_table *supported_extensions,
     78                  const struct vk_instance_dispatch_table *dispatch_table,
     79                  const VkInstanceCreateInfo *pCreateInfo,
     80                  const VkAllocationCallbacks *alloc);
     81 
     82 void
     83 vk_instance_finish(struct vk_instance *instance);
     84 
     85 VkResult
     86 vk_enumerate_instance_extension_properties(
     87     const struct vk_instance_extension_table *supported_extensions,
     88     uint32_t *pPropertyCount,
     89     VkExtensionProperties *pProperties);
     90 
     91 PFN_vkVoidFunction
     92 vk_instance_get_proc_addr(const struct vk_instance *instance,
     93                           const struct vk_instance_entrypoint_table *entrypoints,
     94                           const char *name);
     95 
     96 PFN_vkVoidFunction
     97 vk_instance_get_proc_addr_unchecked(const struct vk_instance *instance,
     98                                     const char *name);
     99 
    100 PFN_vkVoidFunction
    101 vk_instance_get_physical_device_proc_addr(const struct vk_instance *instance,
    102                                           const char *name);
    103 
    104 #ifdef __cplusplus
    105 }
    106 #endif
    107 
    108 #endif /* VK_INSTANCE_H */
    109