OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2016 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "VulkanTestContext_win.h" | 9 #include "VulkanTestContext_win.h" |
10 | 10 |
11 #include "vk/GrVkInterface.h" | 11 #include "vk/GrVkInterface.h" |
12 #include "../../src/gpu/vk/GrVkUtil.h" | 12 #include "vk/GrVkUtil.h" |
13 | 13 |
14 // Platform dependant call | 14 // Platform dependant call |
15 VkSurfaceKHR VulkanTestContext::createVkSurface(void* platformData) { | 15 VkSurfaceKHR VulkanTestContext::createVkSurface(VkInstance instance, void* platf
ormData) { |
16 // need better error handling here | 16 static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr; |
17 SkASSERT(platformData); | 17 if (!createWin32SurfaceKHR) { |
| 18 createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAd
dr(instance, |
| 19 "vkCrea
teWin32SurfaceKHR"); |
| 20 } |
| 21 |
| 22 if (!platformData) { |
| 23 return VK_NULL_HANDLE; |
| 24 } |
18 ContextPlatformData_win* winPlatformData = | 25 ContextPlatformData_win* winPlatformData = |
19 reinterpret_cast<ContextPlatformData_
win*>(platformData); | 26 reinterpret_cast<ContextPlatformData_
win*>(platformData); |
20 VkSurfaceKHR surface; | 27 VkSurfaceKHR surface; |
21 | 28 |
22 VkWin32SurfaceCreateInfoKHR surfaceCreateInfo; | 29 VkWin32SurfaceCreateInfoKHR surfaceCreateInfo; |
23 memset(&surfaceCreateInfo, 0, sizeof(VkWin32SurfaceCreateInfoKHR)); | 30 memset(&surfaceCreateInfo, 0, sizeof(VkWin32SurfaceCreateInfoKHR)); |
24 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; | 31 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; |
25 surfaceCreateInfo.pNext = nullptr; | 32 surfaceCreateInfo.pNext = nullptr; |
26 surfaceCreateInfo.flags = 0; | 33 surfaceCreateInfo.flags = 0; |
27 surfaceCreateInfo.hinstance = winPlatformData->fHInstance; | 34 surfaceCreateInfo.hinstance = winPlatformData->fHInstance; |
28 surfaceCreateInfo.hwnd = winPlatformData->fHWnd; | 35 surfaceCreateInfo.hwnd = winPlatformData->fHWnd; |
29 | 36 |
30 VkResult res = GR_VK_CALL(fBackendContext->fInterface, | 37 VkResult res = createWin32SurfaceKHR(instance, &surfaceCreateInfo, nullptr,
&surface); |
31 CreateWin32SurfaceKHR(fBackendContext->fInstance,
&surfaceCreateInfo, | |
32 nullptr, &surface)); | |
33 if (VK_SUCCESS != res) { | 38 if (VK_SUCCESS != res) { |
34 return VK_NULL_HANDLE; | 39 return VK_NULL_HANDLE; |
35 } | 40 } |
36 | 41 |
37 return surface; | 42 return surface; |
38 } | 43 } |
39 | 44 |
40 // Platform dependant call | 45 // Platform dependant call |
41 bool VulkanTestContext::canPresent(uint32_t queueFamilyIndex) { | 46 bool VulkanTestContext::canPresent(VkInstance instance, VkPhysicalDevice physDev
, |
42 VkBool32 check = GR_VK_CALL(fBackendContext->fInterface, | 47 uint32_t queueFamilyIndex) { |
43 GetPhysicalDeviceWin32PresentationSupportKHR( | 48 static PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR |
44 fBackendConte
xt->fPhysicalDevice, | 49 getPhysicalDeviceWin32PresentationS
upportKHR = nullptr; |
45 queueFamilyIn
dex)); | 50 if (!getPhysicalDeviceWin32PresentationSupportKHR) { |
| 51 getPhysicalDeviceWin32PresentationSupportKHR = |
| 52 (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) vkGetInstancePr
ocAddr(instance, |
| 53 "vkGetPhysicalDeviceWin32Prese
ntationSupportKHR"); |
| 54 } |
| 55 |
| 56 VkBool32 check = getPhysicalDeviceWin32PresentationSupportKHR(physDev, queue
FamilyIndex); |
46 return (VK_FALSE != check); | 57 return (VK_FALSE != check); |
47 } | 58 } |
OLD | NEW |