| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "vk/GrVkBackendContext.h" | 8 #include "vk/GrVkBackendContext.h" |
| 9 #include "vk/GrVkExtensions.h" | 9 #include "vk/GrVkExtensions.h" |
| 10 #include "vk/GrVkInterface.h" | 10 #include "vk/GrVkInterface.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #ifdef ENABLE_VK_LAYERS | 61 #ifdef ENABLE_VK_LAYERS |
| 62 for (int i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { | 62 for (int i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { |
| 63 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) { | 63 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) { |
| 64 instanceLayerNames.push_back(kDebugLayerNames[i]); | 64 instanceLayerNames.push_back(kDebugLayerNames[i]); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { | 67 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { |
| 68 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); | 68 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
| 69 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag; | 69 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag; |
| 70 } | 70 } |
| 71 if (extensions.hasInstanceExtension(VK_KHR_SURFACE_EXTENSION_NAME)) { |
| 72 instanceExtensionNames.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 73 extensionFlags |= kKHR_surface_GrVkExtensionFlag; |
| 74 } |
| 75 if (extensions.hasInstanceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) { |
| 76 instanceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 77 extensionFlags |= kKHR_swapchain_GrVkExtensionFlag; |
| 78 } |
| 79 #ifdef SK_BUILD_FOR_WIN |
| 80 if (extensions.hasInstanceExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) { |
| 81 instanceExtensionNames.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 82 extensionFlags |= kKHR_win32_surface_GrVkExtensionFlag; |
| 83 } |
| 84 #elif SK_BUILD_FOR_ANDROID |
| 85 if (extensions.hasInstanceExtension(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME))
{ |
| 86 instanceExtensionNames.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 87 extensionFlags |= kKHR_android_surface_GrVkExtensionFlag; |
| 88 } |
| 89 #elif SK_BUILD_FOR_UNIX |
| 90 if (extensions.hasInstanceExtension(VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) { |
| 91 instanceExtensionNames.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 92 extensionFlags |= kKHR_xlib_surface_GrVkExtensionFlag; |
| 93 } |
| 94 #endif |
| 71 #endif | 95 #endif |
| 72 | 96 |
| 73 const VkInstanceCreateInfo instance_create = { | 97 const VkInstanceCreateInfo instance_create = { |
| 74 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType | 98 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType |
| 75 nullptr, // pNext | 99 nullptr, // pNext |
| 76 0, // flags | 100 0, // flags |
| 77 &app_info, // pApplicationInfo | 101 &app_info, // pApplicationInfo |
| 78 instanceLayerNames.count(), // enabledLayerNameCount | 102 instanceLayerNames.count(), // enabledLayerNameCount |
| 79 instanceLayerNames.begin(), // ppEnabledLayerNames | 103 instanceLayerNames.begin(), // ppEnabledLayerNames |
| 80 instanceExtensionNames.count(), // enabledExtensionNameCount | 104 instanceExtensionNames.count(), // enabledExtensionNameCount |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 228 |
| 205 return ctx; | 229 return ctx; |
| 206 } | 230 } |
| 207 | 231 |
| 208 GrVkBackendContext::~GrVkBackendContext() { | 232 GrVkBackendContext::~GrVkBackendContext() { |
| 209 vkDestroyDevice(fDevice, nullptr); | 233 vkDestroyDevice(fDevice, nullptr); |
| 210 fDevice = VK_NULL_HANDLE; | 234 fDevice = VK_NULL_HANDLE; |
| 211 vkDestroyInstance(fInstance, nullptr); | 235 vkDestroyInstance(fInstance, nullptr); |
| 212 fInstance = VK_NULL_HANDLE; | 236 fInstance = VK_NULL_HANDLE; |
| 213 } | 237 } |
| OLD | NEW |