OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/vulkan/vulkan_implementation.h" | 5 #include "gpu/vulkan/vulkan_implementation.h" |
6 | 6 |
7 #include <unordered_set> | 7 #include <unordered_set> |
8 #include <vector> | 8 #include <vector> |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 instance_create_info.ppEnabledLayerNames = enabled_layer_names.data(); | 124 instance_create_info.ppEnabledLayerNames = enabled_layer_names.data(); |
125 instance_create_info.enabledExtensionCount = enabled_ext_names.size(); | 125 instance_create_info.enabledExtensionCount = enabled_ext_names.size(); |
126 instance_create_info.ppEnabledExtensionNames = enabled_ext_names.data(); | 126 instance_create_info.ppEnabledExtensionNames = enabled_ext_names.data(); |
127 | 127 |
128 result = vkCreateInstance(&instance_create_info, nullptr, &vk_instance); | 128 result = vkCreateInstance(&instance_create_info, nullptr, &vk_instance); |
129 if (VK_SUCCESS != result) { | 129 if (VK_SUCCESS != result) { |
130 DLOG(ERROR) << "vkCreateInstance() failed: " << result; | 130 DLOG(ERROR) << "vkCreateInstance() failed: " << result; |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
| 134 #if DCHECK_IS_ON() |
134 // Register our error logging function. | 135 // Register our error logging function. |
135 if (debug_report_enabled) { | 136 if (debug_report_enabled) { |
136 PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = | 137 PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT = |
137 reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT> | 138 reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT> |
138 (vkGetInstanceProcAddr(vk_instance, | 139 (vkGetInstanceProcAddr(vk_instance, |
139 "vkCreateDebugReportCallbackEXT")); | 140 "vkCreateDebugReportCallbackEXT")); |
140 DCHECK(vkCreateDebugReportCallbackEXT); | 141 DCHECK(vkCreateDebugReportCallbackEXT); |
141 | 142 |
142 VkDebugReportCallbackCreateInfoEXT cb_create_info = {}; | 143 VkDebugReportCallbackCreateInfoEXT cb_create_info = {}; |
143 cb_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; | 144 cb_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
(...skipping 12 matching lines...) Expand all Loading... |
156 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; | 157 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; |
157 cb_create_info.pfnCallback = &VulkanWarningCallback; | 158 cb_create_info.pfnCallback = &VulkanWarningCallback; |
158 result = vkCreateDebugReportCallbackEXT(vk_instance, &cb_create_info, | 159 result = vkCreateDebugReportCallbackEXT(vk_instance, &cb_create_info, |
159 nullptr, &warning_callback); | 160 nullptr, &warning_callback); |
160 if (VK_SUCCESS != result) { | 161 if (VK_SUCCESS != result) { |
161 DLOG(ERROR) << "vkCreateDebugReportCallbackEXT(WARN) failed: " | 162 DLOG(ERROR) << "vkCreateDebugReportCallbackEXT(WARN) failed: " |
162 << result; | 163 << result; |
163 return false; | 164 return false; |
164 } | 165 } |
165 } | 166 } |
| 167 #endif |
166 | 168 |
167 return true; | 169 return true; |
168 } | 170 } |
169 | 171 |
170 bool valid = false; | 172 bool valid = false; |
171 VkInstance vk_instance = VK_NULL_HANDLE; | 173 VkInstance vk_instance = VK_NULL_HANDLE; |
172 #if DCHECK_IS_ON() | 174 #if DCHECK_IS_ON() |
173 VkDebugReportCallbackEXT error_callback = VK_NULL_HANDLE; | 175 VkDebugReportCallbackEXT error_callback = VK_NULL_HANDLE; |
174 VkDebugReportCallbackEXT warning_callback = VK_NULL_HANDLE; | 176 VkDebugReportCallbackEXT warning_callback = VK_NULL_HANDLE; |
175 #endif | 177 #endif |
176 }; | 178 }; |
177 | 179 |
178 static VulkanInstance* vulkan_instance = nullptr; | 180 static VulkanInstance* vulkan_instance = nullptr; |
179 | 181 |
180 bool InitializeVulkan() { | 182 bool InitializeVulkan() { |
181 DCHECK(!vulkan_instance); | 183 DCHECK(!vulkan_instance); |
182 vulkan_instance = new VulkanInstance; | 184 vulkan_instance = new VulkanInstance; |
183 vulkan_instance->Initialize(); | 185 vulkan_instance->Initialize(); |
184 return vulkan_instance->valid; | 186 return vulkan_instance->valid; |
185 } | 187 } |
186 | 188 |
187 VkInstance GetVulkanInstance() { | 189 VkInstance GetVulkanInstance() { |
188 DCHECK(vulkan_instance); | 190 DCHECK(vulkan_instance); |
189 DCHECK(vulkan_instance->valid); | 191 DCHECK(vulkan_instance->valid); |
190 return vulkan_instance->vk_instance; | 192 return vulkan_instance->vk_instance; |
191 } | 193 } |
192 | 194 |
193 } // namespace gpu | 195 } // namespace gpu |
OLD | NEW |