| 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 SK_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_GOOGLE_threading", | 19 "VK_LAYER_GOOGLE_threading", |
| 20 "VK_LAYER_LUNARG_parameter_validation", | 20 "VK_LAYER_LUNARG_parameter_validation", |
| 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_core_validation", | 24 "VK_LAYER_LUNARG_core_validation", |
| 25 "VK_LAYER_LUNARG_swapchain", | 25 "VK_LAYER_LUNARG_swapchain", |
| 26 "VK_LAYER_GOOGLE_unique_objects", | 26 "VK_LAYER_GOOGLE_unique_objects", |
| (...skipping 28 matching lines...) Expand all Loading... |
| 55 0, // engineVerison | 55 0, // engineVerison |
| 56 kGrVkMinimumVersion, // apiVersion | 56 kGrVkMinimumVersion, // apiVersion |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 GrVkExtensions extensions; | 59 GrVkExtensions extensions; |
| 60 extensions.initInstance(kGrVkMinimumVersion); | 60 extensions.initInstance(kGrVkMinimumVersion); |
| 61 | 61 |
| 62 SkTArray<const char*> instanceLayerNames; | 62 SkTArray<const char*> instanceLayerNames; |
| 63 SkTArray<const char*> instanceExtensionNames; | 63 SkTArray<const char*> instanceExtensionNames; |
| 64 uint32_t extensionFlags = 0; | 64 uint32_t extensionFlags = 0; |
| 65 #ifdef ENABLE_VK_LAYERS | 65 #ifdef SK_ENABLE_VK_LAYERS |
| 66 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { | 66 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { |
| 67 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) { | 67 if (extensions.hasInstanceLayer(kDebugLayerNames[i])) { |
| 68 instanceLayerNames.push_back(kDebugLayerNames[i]); | 68 instanceLayerNames.push_back(kDebugLayerNames[i]); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { | 71 if (extensions.hasInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { |
| 72 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); | 72 instanceExtensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
| 73 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag; | 73 extensionFlags |= kEXT_debug_report_GrVkExtensionFlag; |
| 74 } | 74 } |
| 75 #endif | 75 #endif |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 SkASSERT(presentQueueIndex < queueCount); | 167 SkASSERT(presentQueueIndex < queueCount); |
| 168 *presentQueueIndexPtr = presentQueueIndex; | 168 *presentQueueIndexPtr = presentQueueIndex; |
| 169 } | 169 } |
| 170 | 170 |
| 171 extensions.initDevice(kGrVkMinimumVersion, inst, physDev); | 171 extensions.initDevice(kGrVkMinimumVersion, inst, physDev); |
| 172 | 172 |
| 173 SkTArray<const char*> deviceLayerNames; | 173 SkTArray<const char*> deviceLayerNames; |
| 174 SkTArray<const char*> deviceExtensionNames; | 174 SkTArray<const char*> deviceExtensionNames; |
| 175 #ifdef ENABLE_VK_LAYERS | 175 #ifdef SK_ENABLE_VK_LAYERS |
| 176 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { | 176 for (size_t i = 0; i < SK_ARRAY_COUNT(kDebugLayerNames); ++i) { |
| 177 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) { | 177 if (extensions.hasDeviceLayer(kDebugLayerNames[i])) { |
| 178 deviceLayerNames.push_back(kDebugLayerNames[i]); | 178 deviceLayerNames.push_back(kDebugLayerNames[i]); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 #endif | 181 #endif |
| 182 if (extensions.hasDeviceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) { | 182 if (extensions.hasDeviceExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)) { |
| 183 deviceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); | 183 deviceExtensionNames.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 184 extensionFlags |= kKHR_swapchain_GrVkExtensionFlag; | 184 extensionFlags |= kKHR_swapchain_GrVkExtensionFlag; |
| 185 } | 185 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 return ctx; | 266 return ctx; |
| 267 } | 267 } |
| 268 | 268 |
| 269 GrVkBackendContext::~GrVkBackendContext() { | 269 GrVkBackendContext::~GrVkBackendContext() { |
| 270 vkDeviceWaitIdle(fDevice); | 270 vkDeviceWaitIdle(fDevice); |
| 271 vkDestroyDevice(fDevice, nullptr); | 271 vkDestroyDevice(fDevice, nullptr); |
| 272 fDevice = VK_NULL_HANDLE; | 272 fDevice = VK_NULL_HANDLE; |
| 273 vkDestroyInstance(fInstance, nullptr); | 273 vkDestroyInstance(fInstance, nullptr); |
| 274 fInstance = VK_NULL_HANDLE; | 274 fInstance = VK_NULL_HANDLE; |
| 275 } | 275 } |
| OLD | NEW |