1 /*
2  * Copyright 2019 Google LLC
3  * SPDX-License-Identifier: MIT
4  *
5  * based in part on anv and radv which are:
6  * Copyright © 2015 Intel Corporation
7  * Copyright © 2016 Red Hat.
8  * Copyright © 2016 Bas Nieuwenhuizen
9  */
10 
11 #include "vn_icd.h"
12 
13 #include "vn_instance.h"
14 
15 /* we support all versions from version 1 up to version 5 */
16 static uint32_t vn_icd_version = 5;
17 
18 VkResult
vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t * pSupportedVersion)19 vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
20 {
21    vn_debug_init();
22    vn_trace_init();
23 
24    vn_icd_version = MIN2(vn_icd_version, *pSupportedVersion);
25    if (VN_DEBUG(INIT))
26       vn_log(NULL, "using ICD interface version %d", vn_icd_version);
27 
28    *pSupportedVersion = vn_icd_version;
29    return VK_SUCCESS;
30 }
31 
32 PFN_vkVoidFunction
vk_icdGetInstanceProcAddr(VkInstance instance,const char * pName)33 vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
34 {
35    return vn_GetInstanceProcAddr(instance, pName);
36 }
37 
38 PFN_vkVoidFunction
vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance,const char * pName)39 vk_icdGetPhysicalDeviceProcAddr(VkInstance _instance, const char *pName)
40 {
41    struct vn_instance *instance = vn_instance_from_handle(_instance);
42    return vk_instance_get_physical_device_proc_addr(&instance->base.base,
43                                                     pName);
44 }
45 
46 bool
vn_icd_supports_api_version(uint32_t api_version)47 vn_icd_supports_api_version(uint32_t api_version)
48 {
49    return vn_icd_version >= 5 || api_version < VK_API_VERSION_1_1;
50 }
51