diff options
author | 2017-11-09 15:20:26 -0500 | |
---|---|---|
committer | 2017-11-09 21:04:37 +0000 | |
commit | 77d6feaa69d95c42f4e77195e92de33917995544 (patch) | |
tree | 105d7145e53d14cc2ead22f2e5807cb34b5fb481 /tools/gpu/vk/VkTestUtils.cpp | |
parent | 0f3c73220a25eba9bf11583db3d0f76a2c4f6331 (diff) |
Dynamically load the vulkan library in our test tools
Bug: skia:
Change-Id: I7c1f6cbb2b50ca284f40cf4b9ef49a76083b38c6
Reviewed-on: https://skia-review.googlesource.com/68643
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tools/gpu/vk/VkTestUtils.cpp')
-rw-r--r-- | tools/gpu/vk/VkTestUtils.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/gpu/vk/VkTestUtils.cpp b/tools/gpu/vk/VkTestUtils.cpp new file mode 100644 index 0000000000..62fd312ecf --- /dev/null +++ b/tools/gpu/vk/VkTestUtils.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2017 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "VkTestUtils.h" + +#include "../ports/SkOSLibrary.h" + +namespace sk_gpu_test { + +bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr* instProc, + PFN_vkGetDeviceProcAddr* devProc) { + static void* vkLib = nullptr; + static PFN_vkGetInstanceProcAddr localInstProc = nullptr; + static PFN_vkGetDeviceProcAddr localDevProc = nullptr; + if (!vkLib) { +#if defined _WIN32 + vkLib = DynamicLoadLibrary("vulkan-1.dll"); +#else + vkLib = DynamicLoadLibrary("libvulkan.so"); +#endif + if (!vkLib) { + return false; + } + localInstProc = (PFN_vkGetInstanceProcAddr) GetProcedureAddress(vkLib, + "vkGetInstanceProcAddr"); + localDevProc = (PFN_vkGetDeviceProcAddr) GetProcedureAddress(vkLib, + "vkGetDeviceProcAddr"); + } + if (!localInstProc || !localDevProc) { + return false; + } + *instProc = localInstProc; + *devProc = localDevProc; + return true; +} +} |