1 /* 2 * Copyright 2017 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "VkTestUtils.h" 9 10 #ifdef SK_VULKAN 11 12 #include "../ports/SkOSLibrary.h" 13 14 namespace sk_gpu_test { 15 LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr * instProc,PFN_vkGetDeviceProcAddr * devProc)16bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc, 17 PFN_vkGetDeviceProcAddr* devProc) { 18 static void* vkLib = nullptr; 19 static PFN_vkGetInstanceProcAddr localInstProc = nullptr; 20 static PFN_vkGetDeviceProcAddr localDevProc = nullptr; 21 if (!vkLib) { 22 #if defined _WIN32 23 vkLib = DynamicLoadLibrary("vulkan-1.dll"); 24 #else 25 vkLib = DynamicLoadLibrary("libvulkan.so"); 26 #endif 27 if (!vkLib) { 28 return false; 29 } 30 localInstProc = (PFN_vkGetInstanceProcAddr) GetProcedureAddress(vkLib, 31 "vkGetInstanceProcAddr"); 32 localDevProc = (PFN_vkGetDeviceProcAddr) GetProcedureAddress(vkLib, 33 "vkGetDeviceProcAddr"); 34 } 35 if (!localInstProc || !localDevProc) { 36 return false; 37 } 38 *instProc = localInstProc; 39 *devProc = localDevProc; 40 return true; 41 } 42 } 43 44 #endif 45