Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and/or associated documentation files (the "Materials"), to |
| 8 | * deal in the Materials without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice(s) and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Materials. |
| 15 | * |
| 16 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 19 | * |
| 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 23 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 | * |
| 25 | * Author: Jeremy Hayes <jeremy@lunarG.com> |
| 26 | */ |
| 27 | |
Jeremy Hayes | d8726c2 | 2016-04-21 13:19:41 -0600 | [diff] [blame] | 28 | #include <memory> |
| 29 | |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 30 | #include <vulkan/vulkan.h> |
| 31 | #include "test_common.h" |
| 32 | |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 33 | namespace VK |
| 34 | { |
| 35 | |
| 36 | struct InstanceCreateInfo |
| 37 | { |
| 38 | InstanceCreateInfo() : |
| 39 | info // MSVC can't handle list initialization, thus explicit construction herein. |
| 40 | ( |
| 41 | VkInstanceCreateInfo |
| 42 | { |
| 43 | VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType |
| 44 | nullptr, // pNext |
| 45 | 0, // flags |
| 46 | nullptr, // pApplicationInfo |
| 47 | 0, // enabledLayerCount |
| 48 | nullptr, // ppEnabledLayerNames |
| 49 | 0, //enabledExtensionCount |
| 50 | nullptr // ppEnabledExtensionNames |
| 51 | } |
| 52 | ) |
| 53 | { |
| 54 | } |
| 55 | |
| 56 | InstanceCreateInfo& sType(VkStructureType const& sType) |
| 57 | { |
| 58 | info.sType = sType; |
| 59 | |
| 60 | return *this; |
| 61 | } |
| 62 | |
| 63 | InstanceCreateInfo& pNext(void const*const pNext) |
| 64 | { |
| 65 | info.pNext = pNext; |
| 66 | |
| 67 | return *this; |
| 68 | } |
| 69 | |
| 70 | InstanceCreateInfo& flags(VkInstanceCreateFlags const& flags) |
| 71 | { |
| 72 | info.flags = flags; |
| 73 | |
| 74 | return *this; |
| 75 | } |
| 76 | |
| 77 | InstanceCreateInfo& pApplicationInfo(VkApplicationInfo const*const pApplicationInfo) |
| 78 | { |
| 79 | info.pApplicationInfo = pApplicationInfo; |
| 80 | |
| 81 | return *this; |
| 82 | } |
| 83 | |
| 84 | InstanceCreateInfo& enabledLayerCount(uint32_t const& enabledLayerCount) |
| 85 | { |
| 86 | info.enabledLayerCount = enabledLayerCount; |
| 87 | |
| 88 | return *this; |
| 89 | } |
| 90 | |
| 91 | InstanceCreateInfo& ppEnabledLayerNames(char const*const*const ppEnabledLayerNames) |
| 92 | { |
| 93 | info.ppEnabledLayerNames = ppEnabledLayerNames; |
| 94 | |
| 95 | return *this; |
| 96 | } |
| 97 | |
| 98 | InstanceCreateInfo& enabledExtensionCount(uint32_t const& enabledExtensionCount) |
| 99 | { |
| 100 | info.enabledExtensionCount = enabledExtensionCount; |
| 101 | |
| 102 | return *this; |
| 103 | } |
| 104 | |
| 105 | InstanceCreateInfo& ppEnabledExtensionNames(char const*const*const ppEnabledExtensionNames) |
| 106 | { |
| 107 | info.ppEnabledExtensionNames = ppEnabledExtensionNames; |
| 108 | |
| 109 | return *this; |
| 110 | } |
| 111 | |
| 112 | operator VkInstanceCreateInfo const*() const |
| 113 | { |
| 114 | return &info; |
| 115 | } |
| 116 | |
| 117 | operator VkInstanceCreateInfo*() |
| 118 | { |
| 119 | return &info; |
| 120 | } |
| 121 | |
| 122 | VkInstanceCreateInfo info; |
| 123 | }; |
| 124 | |
| 125 | struct DeviceQueueCreateInfo |
| 126 | { |
| 127 | DeviceQueueCreateInfo() : |
| 128 | info // MSVC can't handle list initialization, thus explicit construction herein. |
| 129 | ( |
| 130 | VkDeviceQueueCreateInfo |
| 131 | { |
| 132 | VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType |
| 133 | nullptr, // pNext |
| 134 | 0, // flags |
| 135 | 0, // queueFamilyIndex |
| 136 | 0, // queueCount |
| 137 | nullptr // pQueuePriorities |
| 138 | } |
| 139 | ) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | DeviceQueueCreateInfo& sType(VkStructureType const& sType) |
| 144 | { |
| 145 | info.sType = sType; |
| 146 | |
| 147 | return *this; |
| 148 | } |
| 149 | |
| 150 | DeviceQueueCreateInfo& pNext(void const*const pNext) |
| 151 | { |
| 152 | info.pNext = pNext; |
| 153 | |
| 154 | return *this; |
| 155 | } |
| 156 | |
| 157 | DeviceQueueCreateInfo& flags(VkDeviceQueueCreateFlags const& flags) |
| 158 | { |
| 159 | info.flags = flags; |
| 160 | |
| 161 | return *this; |
| 162 | } |
| 163 | |
| 164 | DeviceQueueCreateInfo& queueFamilyIndex(uint32_t const& queueFamilyIndex) |
| 165 | { |
| 166 | info.queueFamilyIndex = queueFamilyIndex; |
| 167 | |
| 168 | return *this; |
| 169 | } |
| 170 | |
| 171 | DeviceQueueCreateInfo& queueCount(uint32_t const& queueCount) |
| 172 | { |
| 173 | info.queueCount = queueCount; |
| 174 | |
| 175 | return *this; |
| 176 | } |
| 177 | |
| 178 | DeviceQueueCreateInfo& pQueuePriorities(float const*const pQueuePriorities) |
| 179 | { |
| 180 | info.pQueuePriorities = pQueuePriorities; |
| 181 | |
| 182 | return *this; |
| 183 | } |
| 184 | |
| 185 | operator VkDeviceQueueCreateInfo() |
| 186 | { |
| 187 | return info; |
| 188 | } |
| 189 | |
| 190 | VkDeviceQueueCreateInfo info; |
| 191 | }; |
| 192 | |
| 193 | struct DeviceCreateInfo |
| 194 | { |
| 195 | DeviceCreateInfo() : |
| 196 | info // MSVC can't handle list initialization, thus explicit construction herein. |
| 197 | ( |
| 198 | VkDeviceCreateInfo |
| 199 | { |
| 200 | VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType |
| 201 | nullptr, // pNext |
| 202 | 0, // flags |
| 203 | 0, // queueCreateInfoCount |
| 204 | nullptr, // pQueueCreateInfos |
| 205 | 0, // enabledLayerCount |
| 206 | nullptr, // ppEnabledLayerNames |
| 207 | 0, // enabledExtensionCount |
| 208 | nullptr, // ppEnabledExtensionNames |
| 209 | nullptr // pEnabledFeatures |
| 210 | } |
| 211 | ) |
| 212 | { |
| 213 | } |
| 214 | |
| 215 | DeviceCreateInfo& sType(VkStructureType const& sType) |
| 216 | { |
| 217 | info.sType = sType; |
| 218 | |
| 219 | return *this; |
| 220 | } |
| 221 | |
| 222 | DeviceCreateInfo& pNext(void const*const pNext) |
| 223 | { |
| 224 | info.pNext = pNext; |
| 225 | |
| 226 | return *this; |
| 227 | } |
| 228 | |
| 229 | DeviceCreateInfo& flags(VkDeviceQueueCreateFlags const& flags) |
| 230 | { |
| 231 | info.flags = flags; |
| 232 | |
| 233 | return *this; |
| 234 | } |
| 235 | |
| 236 | DeviceCreateInfo& queueCreateInfoCount(uint32_t const& queueCreateInfoCount) |
| 237 | { |
| 238 | info.queueCreateInfoCount = queueCreateInfoCount; |
| 239 | |
| 240 | return *this; |
| 241 | } |
| 242 | |
| 243 | DeviceCreateInfo& pQueueCreateInfos(VkDeviceQueueCreateInfo const*const pQueueCreateInfos) |
| 244 | { |
| 245 | info.pQueueCreateInfos = pQueueCreateInfos; |
| 246 | |
| 247 | return *this; |
| 248 | } |
| 249 | |
| 250 | DeviceCreateInfo& enabledLayerCount(uint32_t const& enabledLayerCount) |
| 251 | { |
| 252 | info.enabledLayerCount = enabledLayerCount; |
| 253 | |
| 254 | return *this; |
| 255 | } |
| 256 | |
| 257 | DeviceCreateInfo& ppEnabledLayerNames(char const*const*const ppEnabledLayerNames) |
| 258 | { |
| 259 | info.ppEnabledLayerNames = ppEnabledLayerNames; |
| 260 | |
| 261 | return *this; |
| 262 | } |
| 263 | |
| 264 | DeviceCreateInfo& enabledExtensionCount(uint32_t const& enabledExtensionCount) |
| 265 | { |
| 266 | info.enabledExtensionCount = enabledExtensionCount; |
| 267 | |
| 268 | return *this; |
| 269 | } |
| 270 | |
| 271 | DeviceCreateInfo& ppEnabledExtensionNames(char const*const*const ppEnabledExtensionNames) |
| 272 | { |
| 273 | info.ppEnabledExtensionNames = ppEnabledExtensionNames; |
| 274 | |
| 275 | return *this; |
| 276 | } |
| 277 | |
| 278 | DeviceCreateInfo& pEnabledFeatures(VkPhysicalDeviceFeatures const*const pEnabledFeatures) |
| 279 | { |
| 280 | info.pEnabledFeatures = pEnabledFeatures; |
| 281 | |
| 282 | return *this; |
| 283 | } |
| 284 | |
| 285 | operator VkDeviceCreateInfo const*() const |
| 286 | { |
| 287 | return &info; |
| 288 | } |
| 289 | |
| 290 | operator VkDeviceCreateInfo*() |
| 291 | { |
| 292 | return &info; |
| 293 | } |
| 294 | |
| 295 | VkDeviceCreateInfo info; |
| 296 | }; |
| 297 | |
| 298 | } |
| 299 | |
Jeremy Hayes | d8726c2 | 2016-04-21 13:19:41 -0600 | [diff] [blame] | 300 | // Test groups: |
| 301 | // LX = lunar exchange |
| 302 | // LVLGH = loader and validation github |
| 303 | // LVLGL = lodaer and validation gitlab |
| 304 | |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 305 | TEST(LX435, InstanceCreateInfoConst) |
| 306 | { |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 307 | VkInstanceCreateInfo const info = |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 308 | { |
| 309 | VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
| 310 | nullptr, |
| 311 | 0, |
| 312 | nullptr, |
| 313 | 0, |
| 314 | nullptr, |
| 315 | 0, |
| 316 | nullptr |
| 317 | }; |
| 318 | |
| 319 | VkInstance instance = VK_NULL_HANDLE; |
| 320 | VkResult result = vkCreateInstance(&info, VK_NULL_HANDLE, &instance); |
| 321 | EXPECT_EQ(result, VK_SUCCESS); |
| 322 | } |
| 323 | |
Jeremy Hayes | d8726c2 | 2016-04-21 13:19:41 -0600 | [diff] [blame] | 324 | TEST(LX475, DestroyInstanceNullHandle) |
| 325 | { |
| 326 | vkDestroyInstance(VK_NULL_HANDLE, nullptr); |
| 327 | } |
| 328 | |
| 329 | TEST(LX475, DestroyDeviceNullHandle) |
| 330 | { |
| 331 | vkDestroyDevice(VK_NULL_HANDLE, nullptr); |
| 332 | } |
| 333 | |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 334 | TEST(CreateInstance, ExtensionNotPresent) |
| 335 | { |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 336 | char const*const names[] = {"NotPresent"}; // Temporary required due to MSVC bug. |
| 337 | auto const info = VK::InstanceCreateInfo(). |
| 338 | enabledExtensionCount(1). |
| 339 | ppEnabledExtensionNames(names); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 340 | |
| 341 | VkInstance instance = VK_NULL_HANDLE; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 342 | VkResult result = vkCreateInstance(info, VK_NULL_HANDLE, &instance); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 343 | ASSERT_EQ(result, VK_ERROR_EXTENSION_NOT_PRESENT); |
| 344 | } |
| 345 | |
| 346 | TEST(CreateInstance, LayerNotPresent) |
| 347 | { |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 348 | char const*const names[] = {"NotPresent"}; // Temporary required due to MSVC bug. |
| 349 | auto const info = VK::InstanceCreateInfo(). |
| 350 | enabledLayerCount(1). |
| 351 | ppEnabledLayerNames(names); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 352 | |
| 353 | VkInstance instance = VK_NULL_HANDLE; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 354 | VkResult result = vkCreateInstance(info, VK_NULL_HANDLE, &instance); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 355 | ASSERT_EQ(result, VK_ERROR_LAYER_NOT_PRESENT); |
| 356 | } |
| 357 | |
| 358 | TEST(CreateDevice, ExtensionNotPresent) |
| 359 | { |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 360 | VkInstance instance = VK_NULL_HANDLE; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 361 | VkResult result = vkCreateInstance(VK::InstanceCreateInfo(), VK_NULL_HANDLE, &instance); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 362 | ASSERT_EQ(result, VK_SUCCESS); |
| 363 | |
| 364 | uint32_t physicalCount = 0; |
| 365 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, nullptr); |
| 366 | ASSERT_EQ(result, VK_SUCCESS); |
Jeremy Hayes | a6fb5b4 | 2016-06-21 10:54:01 -0600 | [diff] [blame] | 367 | ASSERT_GT(physicalCount, 0u); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 368 | |
| 369 | std::unique_ptr<VkPhysicalDevice[]> physical(new VkPhysicalDevice[physicalCount]); |
| 370 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, physical.get()); |
| 371 | ASSERT_EQ(result, VK_SUCCESS); |
Jeremy Hayes | a6fb5b4 | 2016-06-21 10:54:01 -0600 | [diff] [blame] | 372 | ASSERT_GT(physicalCount, 0u); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 373 | |
| 374 | for(uint32_t p = 0; p < physicalCount; ++p) |
| 375 | { |
| 376 | uint32_t familyCount = 0; |
| 377 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, nullptr); |
| 378 | ASSERT_EQ(result, VK_SUCCESS); |
Jeremy Hayes | a6fb5b4 | 2016-06-21 10:54:01 -0600 | [diff] [blame] | 379 | ASSERT_GT(familyCount, 0u); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 380 | |
| 381 | std::unique_ptr<VkQueueFamilyProperties[]> family(new VkQueueFamilyProperties[familyCount]); |
| 382 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, family.get()); |
| 383 | ASSERT_EQ(result, VK_SUCCESS); |
Jeremy Hayes | a6fb5b4 | 2016-06-21 10:54:01 -0600 | [diff] [blame] | 384 | ASSERT_GT(familyCount, 0u); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 385 | |
| 386 | for(uint32_t q = 0; q < familyCount; ++q) |
| 387 | { |
| 388 | if(~family[q].queueFlags & VK_QUEUE_GRAPHICS_BIT) |
| 389 | { |
| 390 | continue; |
| 391 | } |
| 392 | |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 393 | float const priorities[] = {0.0f}; // Temporary required due to MSVC bug. |
| 394 | VkDeviceQueueCreateInfo const queueInfo[1] |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 395 | { |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 396 | VK::DeviceQueueCreateInfo(). |
| 397 | queueFamilyIndex(q). |
| 398 | queueCount(1). |
| 399 | pQueuePriorities(priorities) |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 400 | }; |
| 401 | |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 402 | char const*const names[] = {"NotPresent"}; // Temporary required due to MSVC bug. |
| 403 | auto const deviceInfo = VK::DeviceCreateInfo(). |
| 404 | queueCreateInfoCount(1). |
| 405 | pQueueCreateInfos(queueInfo). |
| 406 | enabledExtensionCount(1). |
| 407 | ppEnabledExtensionNames(names); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 408 | |
| 409 | VkDevice device; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 410 | result = vkCreateDevice(physical[p], deviceInfo, nullptr, &device); |
Jeremy Hayes | 097188a | 2016-06-15 16:37:17 -0600 | [diff] [blame] | 411 | ASSERT_EQ(result, VK_ERROR_EXTENSION_NOT_PRESENT); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 416 | // LX535 / MI-76: Device layers are deprecated. |
| 417 | // For backwards compatibility, they are allowed, but must be ignored. |
| 418 | // Ensure that no errors occur if a bogus device layer list is passed to vkCreateDevice. |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 419 | TEST(CreateDevice, LayersNotPresent) |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 420 | { |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 421 | VkInstance instance = VK_NULL_HANDLE; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 422 | VkResult result = vkCreateInstance(VK::InstanceCreateInfo(), VK_NULL_HANDLE, &instance); |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 423 | ASSERT_EQ(result, VK_SUCCESS); |
| 424 | |
| 425 | uint32_t physicalCount = 0; |
| 426 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, nullptr); |
| 427 | ASSERT_EQ(result, VK_SUCCESS); |
| 428 | ASSERT_GT(physicalCount, 0u); |
| 429 | |
| 430 | std::unique_ptr<VkPhysicalDevice[]> physical(new VkPhysicalDevice[physicalCount]); |
| 431 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, physical.get()); |
| 432 | ASSERT_EQ(result, VK_SUCCESS); |
| 433 | ASSERT_GT(physicalCount, 0u); |
| 434 | |
| 435 | for(uint32_t p = 0; p < physicalCount; ++p) |
| 436 | { |
| 437 | uint32_t familyCount = 0; |
| 438 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, nullptr); |
| 439 | ASSERT_EQ(result, VK_SUCCESS); |
| 440 | ASSERT_GT(familyCount, 0u); |
| 441 | |
| 442 | std::unique_ptr<VkQueueFamilyProperties[]> family(new VkQueueFamilyProperties[familyCount]); |
| 443 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, family.get()); |
| 444 | ASSERT_EQ(result, VK_SUCCESS); |
| 445 | ASSERT_GT(familyCount, 0u); |
| 446 | |
| 447 | for(uint32_t q = 0; q < familyCount; ++q) |
| 448 | { |
| 449 | if(~family[q].queueFlags & VK_QUEUE_GRAPHICS_BIT) |
| 450 | { |
| 451 | continue; |
| 452 | } |
| 453 | |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 454 | float const priorities[] = {0.0f}; // Temporary required due to MSVC bug. |
| 455 | VkDeviceQueueCreateInfo const queueInfo[1] |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 456 | { |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 457 | VK::DeviceQueueCreateInfo(). |
| 458 | queueFamilyIndex(q). |
| 459 | queueCount(1). |
| 460 | pQueuePriorities(priorities) |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 461 | }; |
| 462 | |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 463 | char const*const names[] = {"NotPresent"}; // Temporary required due to MSVC bug. |
| 464 | auto const deviceInfo = VK::DeviceCreateInfo(). |
| 465 | queueCreateInfoCount(1). |
| 466 | pQueueCreateInfos(queueInfo). |
| 467 | enabledLayerCount(1). |
| 468 | ppEnabledLayerNames(names); |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 469 | |
| 470 | VkDevice device; |
Jeremy Hayes | c558718 | 2016-06-28 11:29:05 -0600 | [diff] [blame^] | 471 | result = vkCreateDevice(physical[p], deviceInfo, nullptr, &device); |
| 472 | ASSERT_EQ(result, VK_SUCCESS); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | TEST(WrapObjects, Insert) |
| 478 | { |
| 479 | VkInstance instance = VK_NULL_HANDLE; |
| 480 | VkResult result = vkCreateInstance(VK::InstanceCreateInfo(), VK_NULL_HANDLE, &instance); |
| 481 | ASSERT_EQ(result, VK_SUCCESS); |
| 482 | |
| 483 | uint32_t physicalCount = 0; |
| 484 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, nullptr); |
| 485 | ASSERT_EQ(result, VK_SUCCESS); |
| 486 | ASSERT_GT(physicalCount, 0u); |
| 487 | |
| 488 | std::unique_ptr<VkPhysicalDevice[]> physical(new VkPhysicalDevice[physicalCount]); |
| 489 | result = vkEnumeratePhysicalDevices(instance, &physicalCount, physical.get()); |
| 490 | ASSERT_EQ(result, VK_SUCCESS); |
| 491 | ASSERT_GT(physicalCount, 0u); |
| 492 | |
| 493 | for(uint32_t p = 0; p < physicalCount; ++p) |
| 494 | { |
| 495 | uint32_t familyCount = 0; |
| 496 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, nullptr); |
| 497 | ASSERT_EQ(result, VK_SUCCESS); |
| 498 | ASSERT_GT(familyCount, 0u); |
| 499 | |
| 500 | std::unique_ptr<VkQueueFamilyProperties[]> family(new VkQueueFamilyProperties[familyCount]); |
| 501 | vkGetPhysicalDeviceQueueFamilyProperties(physical[p], &familyCount, family.get()); |
| 502 | ASSERT_EQ(result, VK_SUCCESS); |
| 503 | ASSERT_GT(familyCount, 0u); |
| 504 | |
| 505 | for(uint32_t q = 0; q < familyCount; ++q) |
| 506 | { |
| 507 | if(~family[q].queueFlags & VK_QUEUE_GRAPHICS_BIT) |
| 508 | { |
| 509 | continue; |
| 510 | } |
| 511 | |
| 512 | float const priorities[] = {0.0f}; // Temporary required due to MSVC bug. |
| 513 | VkDeviceQueueCreateInfo const queueInfo[1] |
| 514 | { |
| 515 | VK::DeviceQueueCreateInfo(). |
| 516 | queueFamilyIndex(q). |
| 517 | queueCount(1). |
| 518 | pQueuePriorities(priorities) |
| 519 | }; |
| 520 | |
| 521 | auto const deviceInfo = VK::DeviceCreateInfo(). |
| 522 | queueCreateInfoCount(1). |
| 523 | pQueueCreateInfos(queueInfo); |
| 524 | |
| 525 | VkDevice device; |
| 526 | result = vkCreateDevice(physical[p], deviceInfo, nullptr, &device); |
Rene Lindsay | e7ec3de | 2016-06-28 10:36:01 -0600 | [diff] [blame] | 527 | ASSERT_EQ(result, VK_SUCCESS); |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
Jeremy Hayes | 6650d1f | 2016-04-20 09:00:39 -0600 | [diff] [blame] | 532 | int main(int argc, char **argv) |
| 533 | { |
| 534 | int result; |
| 535 | |
| 536 | ::testing::InitGoogleTest(&argc, argv); |
| 537 | |
| 538 | result = RUN_ALL_TESTS(); |
| 539 | |
| 540 | return result; |
| 541 | } |