| 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" |
| 11 #include "vk/GrVkUtil.h" | 11 #include "vk/GrVkUtil.h" |
| 12 | 12 |
| 13 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
| 14 // Helper code to set up Vulkan context objects | 14 // Helper code to set up Vulkan context objects |
| 15 | 15 |
| 16 #ifdef ENABLE_VK_LAYERS | 16 #ifdef ENABLE_VK_LAYERS |
| 17 const char* kDebugLayerNames[] = { | 17 const char* kDebugLayerNames[] = { |
| 18 // elements of VK_LAYER_LUNARG_standard_validation | 18 // elements of VK_LAYER_LUNARG_standard_validation |
| 19 "VK_LAYER_LUNARG_threading", | 19 "VK_LAYER_LUNARG_threading", |
| 20 "VK_LAYER_LUNARG_param_checker", | 20 "VK_LAYER_LUNARG_param_checker", |
| 21 "VK_LAYER_LUNARG_device_limits", | 21 "VK_LAYER_LUNARG_device_limits", |
| 22 "VK_LAYER_LUNARG_object_tracker", | 22 "VK_LAYER_LUNARG_object_tracker", |
| 23 "VK_LAYER_LUNARG_image", | 23 "VK_LAYER_LUNARG_image", |
| 24 "VK_LAYER_LUNARG_mem_tracker", | 24 "VK_LAYER_LUNARG_mem_tracker", |
| 25 "VK_LAYER_LUNARG_draw_state", | 25 "VK_LAYER_LUNARG_draw_state", |
| 26 "VK_LAYER_LUNARG_swapchain", | 26 "VK_LAYER_LUNARG_swapchain", |
| 27 "VK_LAYER_GOOGLE_unique_objects", | 27 //"VK_LAYER_GOOGLE_unique_objects", |
| 28 // not included in standard_validation | 28 // not included in standard_validation |
| 29 //"VK_LAYER_LUNARG_api_dump", | 29 //"VK_LAYER_LUNARG_api_dump", |
| 30 //"VK_LAYER_LUNARG_vktrace", | 30 //"VK_LAYER_LUNARG_vktrace", |
| 31 //"VK_LAYER_LUNARG_screenshot", | 31 //"VK_LAYER_LUNARG_screenshot", |
| 32 }; | 32 }; |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 // the minimum version of Vulkan supported | 35 // the minimum version of Vulkan supported |
| 36 const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 3); | 36 const uint32_t kGrVkMinimumVersion = VK_MAKE_VERSION(1, 0, 3); |
| 37 | 37 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 SkTArray<const char*> deviceLayerNames; | 153 SkTArray<const char*> deviceLayerNames; |
| 154 SkTArray<const char*> deviceExtensionNames; | 154 SkTArray<const char*> deviceExtensionNames; |
| 155 #ifdef ENABLE_VK_LAYERS | 155 #ifdef ENABLE_VK_LAYERS |
| 156 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { | 156 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { |
| 157 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) { | 157 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) { |
| 158 deviceLayerNames.push_back(kDebugLayerNames[i]); | 158 deviceLayerNames.push_back(kDebugLayerNames[i]); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 #endif | 161 #endif |
| 162 if (extensions.hasDeviceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) { |
| 163 deviceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 164 extensionFlags |= kKHR_swapchain_GrVkExtensionFlag; |
| 165 } |
| 162 if (extensions.hasDeviceExtension("VK_NV_glsl_shader")) { | 166 if (extensions.hasDeviceExtension("VK_NV_glsl_shader")) { |
| 163 deviceExtensionNames.push_back("VK_NV_glsl_shader"); | 167 deviceExtensionNames.push_back("VK_NV_glsl_shader"); |
| 164 extensionFlags |= kNV_glsl_shader_GrVkExtensionFlag; | 168 extensionFlags |= kNV_glsl_shader_GrVkExtensionFlag; |
| 165 } | 169 } |
| 166 | 170 |
| 167 // query to get the physical device properties | 171 // query to get the physical device properties |
| 168 VkPhysicalDeviceFeatures deviceFeatures; | 172 VkPhysicalDeviceFeatures deviceFeatures; |
| 169 vkGetPhysicalDeviceFeatures(physDev, &deviceFeatures); | 173 vkGetPhysicalDeviceFeatures(physDev, &deviceFeatures); |
| 170 // this looks like it would slow things down, | 174 // this looks like it would slow things down, |
| 171 // and we can't depend on it on all platforms | 175 // and we can't depend on it on all platforms |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 232 |
| 229 return ctx; | 233 return ctx; |
| 230 } | 234 } |
| 231 | 235 |
| 232 GrVkBackendContext::~GrVkBackendContext() { | 236 GrVkBackendContext::~GrVkBackendContext() { |
| 233 vkDestroyDevice(fDevice, nullptr); | 237 vkDestroyDevice(fDevice, nullptr); |
| 234 fDevice = VK_NULL_HANDLE; | 238 fDevice = VK_NULL_HANDLE; |
| 235 vkDestroyInstance(fInstance, nullptr); | 239 vkDestroyInstance(fInstance, nullptr); |
| 236 fInstance = VK_NULL_HANDLE; | 240 fInstance = VK_NULL_HANDLE; |
| 237 } | 241 } |
| OLD | NEW |