17ec681f3Smrg/*
27ec681f3Smrg * Copyright 2019 Google LLC
37ec681f3Smrg * SPDX-License-Identifier: MIT
47ec681f3Smrg *
57ec681f3Smrg * based in part on anv and radv which are:
67ec681f3Smrg * Copyright © 2015 Intel Corporation
77ec681f3Smrg * Copyright © 2016 Red Hat.
87ec681f3Smrg * Copyright © 2016 Bas Nieuwenhuizen
97ec681f3Smrg */
107ec681f3Smrg
117ec681f3Smrg#include "vn_icd.h"
127ec681f3Smrg
137ec681f3Smrg#include "vn_instance.h"
147ec681f3Smrg
157ec681f3Smrg/* we support all versions from version 1 up to version 5 */
167ec681f3Smrgstatic uint32_t vn_icd_version = 5;
177ec681f3Smrg
187ec681f3SmrgVkResult
197ec681f3Smrgvk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
207ec681f3Smrg{
217ec681f3Smrg   vn_debug_init();
227ec681f3Smrg   vn_trace_init();
237ec681f3Smrg
247ec681f3Smrg   vn_icd_version = MIN2(vn_icd_version, *pSupportedVersion);
257ec681f3Smrg   if (VN_DEBUG(INIT))
267ec681f3Smrg      vn_log(NULL, "using ICD interface version %d", vn_icd_version);
277ec681f3Smrg
287ec681f3Smrg   *pSupportedVersion = vn_icd_version;
297ec681f3Smrg   return VK_SUCCESS;
307ec681f3Smrg}
317ec681f3Smrg
327ec681f3SmrgPFN_vkVoidFunction
337ec681f3Smrgvk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
347ec681f3Smrg{
357ec681f3Smrg   return vn_GetInstanceProcAddr(instance, pName);
367ec681f3Smrg}
377ec681f3Smrg
387ec681f3SmrgPFN_vkVoidFunction
397ec681f3Smrgvk_icdGetPhysicalDeviceProcAddr(VkInstance _instance, const char *pName)
407ec681f3Smrg{
417ec681f3Smrg   struct vn_instance *instance = vn_instance_from_handle(_instance);
427ec681f3Smrg   return vk_instance_get_physical_device_proc_addr(&instance->base.base,
437ec681f3Smrg                                                    pName);
447ec681f3Smrg}
457ec681f3Smrg
467ec681f3Smrgbool
477ec681f3Smrgvn_icd_supports_api_version(uint32_t api_version)
487ec681f3Smrg{
497ec681f3Smrg   return vn_icd_version >= 5 || api_version < VK_API_VERSION_1_1;
507ec681f3Smrg}
51