blob: 1ef994aa3f348f6fb33bc6f3eff9eb8c8aaa6071 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "VulkanWindowContext_android.h"
#include "vk/GrVkInterface.h"
#include "vk/GrVkUtil.h"
namespace sk_app {
VkSurfaceKHR VulkanWindowContext::createVkSurface(VkInstance instance, void* platformData) {
static PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR = nullptr;
if (!createAndroidSurfaceKHR) {
createAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(instance,
"vkCreateAndroidSurfaceKHR");
}
if (!platformData) {
return VK_NULL_HANDLE;
}
ContextPlatformData_android* androidPlatformData =
reinterpret_cast<ContextPlatformData_android*>(platformData);
VkSurfaceKHR surface;
VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
surfaceCreateInfo.pNext = nullptr;
surfaceCreateInfo.flags = 0;
surfaceCreateInfo.window = androidPlatformData->fNativeWindow;
VkResult res = createAndroidSurfaceKHR(instance, &surfaceCreateInfo,
nullptr, &surface);
return (VK_SUCCESS == res) ? surface : VK_NULL_HANDLE;
}
bool VulkanWindowContext::canPresent(VkInstance instance, VkPhysicalDevice physDev,
uint32_t queueFamilyIndex) {
return true;
}
} // namespace sk_app
|