aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gpu')
-rw-r--r--tools/gpu/vk/VkTestContext.cpp10
-rw-r--r--tools/gpu/vk/VkTestUtils.cpp40
-rw-r--r--tools/gpu/vk/VkTestUtils.h21
3 files changed, 68 insertions, 3 deletions
diff --git a/tools/gpu/vk/VkTestContext.cpp b/tools/gpu/vk/VkTestContext.cpp
index e329583a03..daaa55bfa0 100644
--- a/tools/gpu/vk/VkTestContext.cpp
+++ b/tools/gpu/vk/VkTestContext.cpp
@@ -10,9 +10,9 @@
#ifdef SK_VULKAN
#include "GrContext.h"
+#include "VkTestUtils.h"
#include "vk/GrVkInterface.h"
#include "vk/GrVkUtil.h"
-#include <vulkan/vulkan.h>
namespace {
/**
@@ -114,8 +114,12 @@ public:
if (sharedContext) {
backendContext = sharedContext->getVkBackendContext();
} else {
- backendContext.reset(GrVkBackendContext::Create(vkGetInstanceProcAddr,
- vkGetDeviceProcAddr));
+ PFN_vkGetInstanceProcAddr instProc;
+ PFN_vkGetDeviceProcAddr devProc;
+ if (!sk_gpu_test::LoadVkLibraryAndGetProcAddrFuncs(&instProc, &devProc)) {
+ return nullptr;
+ }
+ backendContext.reset(GrVkBackendContext::Create(instProc, devProc));
}
if (!backendContext) {
return nullptr;
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;
+}
+}
diff --git a/tools/gpu/vk/VkTestUtils.h b/tools/gpu/vk/VkTestUtils.h
new file mode 100644
index 0000000000..43e9dfdbdc
--- /dev/null
+++ b/tools/gpu/vk/VkTestUtils.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef VkTestUtils_DEFINED
+#define VkTestUtils_DEFINED
+
+#ifdef SK_VULKAN
+
+#include "vk/GrVkDefines.h"
+
+namespace sk_gpu_test {
+ bool LoadVkLibraryAndGetProcAddrFuncs(PFN_vkGetInstanceProcAddr*, PFN_vkGetDeviceProcAddr*);
+}
+
+#endif
+#endif
+