| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 &app_info, // pApplicationInfo | 102 &app_info, // pApplicationInfo |
| 103 (uint32_t) instanceLayerNames.count(), // enabledLayerNameCount | 103 (uint32_t) instanceLayerNames.count(), // enabledLayerNameCount |
| 104 instanceLayerNames.begin(), // ppEnabledLayerNames | 104 instanceLayerNames.begin(), // ppEnabledLayerNames |
| 105 (uint32_t) instanceExtensionNames.count(), // enabledExtensionNameCount | 105 (uint32_t) instanceExtensionNames.count(), // enabledExtensionNameCount |
| 106 instanceExtensionNames.begin(), // ppEnabledExtensionNames | 106 instanceExtensionNames.begin(), // ppEnabledExtensionNames |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 err = vkCreateInstance(&instance_create, nullptr, &inst); | 109 err = vkCreateInstance(&instance_create, nullptr, &inst); |
| 110 if (err < 0) { | 110 if (err < 0) { |
| 111 SkDebugf("vkCreateInstance failed: %d\n", err); | 111 SkDebugf("vkCreateInstance failed: %d\n", err); |
| 112 SkFAIL("failing"); | 112 return nullptr; |
| 113 } | 113 } |
| 114 | 114 |
| 115 uint32_t gpuCount; | 115 uint32_t gpuCount; |
| 116 err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr); | 116 err = vkEnumeratePhysicalDevices(inst, &gpuCount, nullptr); |
| 117 if (err) { | 117 if (err) { |
| 118 SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err); | 118 SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err); |
| 119 vkDestroyInstance(inst, nullptr); | 119 vkDestroyInstance(inst, nullptr); |
| 120 SkFAIL("failing"); | 120 return nullptr; |
| 121 } | 121 } |
| 122 SkASSERT(gpuCount > 0); | 122 SkASSERT(gpuCount > 0); |
| 123 // Just returning the first physical device instead of getting the whole arr
ay. | 123 // Just returning the first physical device instead of getting the whole arr
ay. |
| 124 // TODO: find best match for our needs | 124 // TODO: find best match for our needs |
| 125 gpuCount = 1; | 125 gpuCount = 1; |
| 126 err = vkEnumeratePhysicalDevices(inst, &gpuCount, &physDev); | 126 err = vkEnumeratePhysicalDevices(inst, &gpuCount, &physDev); |
| 127 if (err) { | 127 if (err) { |
| 128 SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err); | 128 SkDebugf("vkEnumeratePhysicalDevices failed: %d\n", err); |
| 129 vkDestroyInstance(inst, nullptr); | 129 vkDestroyInstance(inst, nullptr); |
| 130 SkFAIL("failing"); | 130 return nullptr; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // query to get the initial queue props size | 133 // query to get the initial queue props size |
| 134 uint32_t queueCount; | 134 uint32_t queueCount; |
| 135 vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr); | 135 vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueCount, nullptr); |
| 136 SkASSERT(queueCount >= 1); | 136 SkASSERT(queueCount >= 1); |
| 137 | 137 |
| 138 SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties)); | 138 SkAutoMalloc queuePropsAlloc(queueCount * sizeof(VkQueueFamilyProperties)); |
| 139 // now get the actual queue props | 139 // now get the actual queue props |
| 140 VkQueueFamilyProperties* queueProps = (VkQueueFamilyProperties*)queuePropsAl
loc.get(); | 140 VkQueueFamilyProperties* queueProps = (VkQueueFamilyProperties*)queuePropsAl
loc.get(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 return ctx; | 237 return ctx; |
| 238 } | 238 } |
| 239 | 239 |
| 240 GrVkBackendContext::~GrVkBackendContext() { | 240 GrVkBackendContext::~GrVkBackendContext() { |
| 241 vkDestroyDevice(fDevice, nullptr); | 241 vkDestroyDevice(fDevice, nullptr); |
| 242 fDevice = VK_NULL_HANDLE; | 242 fDevice = VK_NULL_HANDLE; |
| 243 vkDestroyInstance(fInstance, nullptr); | 243 vkDestroyInstance(fInstance, nullptr); |
| 244 fInstance = VK_NULL_HANDLE; | 244 fInstance = VK_NULL_HANDLE; |
| 245 } | 245 } |
| OLD | NEW |