The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/vk: Add timeline semaphore to the list of optional features.

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
0b11ce3a 2af3798e

+64 -9
+60 -9
src/xrt/auxiliary/vk/vk_helpers.c
··· 1349 1349 return true; 1350 1350 } 1351 1351 1352 + static inline void 1353 + append_to_pnext_chain(VkBaseInStructure *head, VkBaseInStructure *new_struct) 1354 + { 1355 + assert(new_struct->pNext == NULL); 1356 + // Insert ourselves between head and its previous pNext 1357 + new_struct->pNext = head->pNext; 1358 + head->pNext = (void *)new_struct; 1359 + } 1360 + 1361 + /** 1362 + * @brief Sets fields in @p device_features to true if and only if they are available and they are true in @p 1363 + * optional_device_features (indicating a desire for that feature) 1364 + * 1365 + * @param vk self 1366 + * @param physical_device The physical device to query 1367 + * @param[in] optional_device_features The features to request if available 1368 + * @param[out] device_features Populated with the subset of @p optional_device_features that are actually available. 1369 + */ 1352 1370 static void 1353 1371 filter_device_features(struct vk_bundle *vk, 1354 1372 VkPhysicalDevice physical_device, ··· 1371 1389 }; 1372 1390 #endif 1373 1391 1392 + #ifdef VK_KHR_timeline_semaphore 1393 + VkPhysicalDeviceTimelineSemaphoreFeaturesKHR timeline_semaphore_info = { 1394 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR, 1395 + .pNext = NULL, 1396 + }; 1397 + #endif 1398 + 1374 1399 VkPhysicalDeviceFeatures2 physical_device_features = { 1375 1400 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, 1376 1401 .pNext = NULL, ··· 1378 1403 1379 1404 #ifdef VK_EXT_robustness2 1380 1405 if (vk->has_EXT_robustness2) { 1381 - // Insert ourselves between physical_device_features and its previous pNext 1382 - robust_info.pNext = physical_device_features.pNext; 1383 - physical_device_features.pNext = (void *)&robust_info; 1406 + append_to_pnext_chain((VkBaseInStructure *)&physical_device_features, 1407 + (VkBaseInStructure *)&robust_info); 1408 + } 1409 + #endif 1410 + 1411 + #ifdef VK_KHR_timeline_semaphore 1412 + if (vk->has_KHR_timeline_semaphore) { 1413 + append_to_pnext_chain((VkBaseInStructure *)&physical_device_features, 1414 + (VkBaseInStructure *)&timeline_semaphore_info); 1384 1415 } 1385 1416 #endif 1386 1417 ··· 1398 1429 #ifdef VK_EXT_robustness2 1399 1430 CHECK(null_descriptor, robust_info.nullDescriptor); 1400 1431 #endif 1432 + 1433 + #ifdef VK_KHR_timeline_semaphore 1434 + CHECK(timeline_semaphore, timeline_semaphore_info.timelineSemaphore); 1435 + #endif 1401 1436 CHECK(shader_storage_image_write_without_format, 1402 1437 physical_device_features.features.shaderStorageImageWriteWithoutFormat); 1403 1438 ··· 1407 1442 VK_DEBUG(vk, 1408 1443 "Features:" 1409 1444 "\n\tnull_descriptor: %i" 1410 - "\n\tshader_storage_image_write_without_format: %i", 1411 - device_features->null_descriptor, device_features->shader_storage_image_write_without_format); 1445 + "\n\tshader_storage_image_write_without_format: %i" 1446 + "\n\ttimeline_semaphore: %i", // 1447 + device_features->null_descriptor, // 1448 + device_features->shader_storage_image_write_without_format, // 1449 + device_features->timeline_semaphore); 1412 1450 } 1413 1451 1414 1452 VkResult ··· 1444 1482 1445 1483 struct vk_device_features device_features = {0}; 1446 1484 filter_device_features(vk, vk->physical_device, optional_device_features, &device_features); 1447 - 1485 + vk->timeline_semaphores = device_features.timeline_semaphore; 1448 1486 1449 1487 /* 1450 1488 * Queue ··· 1493 1531 }; 1494 1532 #endif 1495 1533 1534 + #ifdef VK_KHR_timeline_semaphore 1535 + VkPhysicalDeviceTimelineSemaphoreFeaturesKHR timeline_semaphore_info = { 1536 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR, 1537 + .pNext = NULL, 1538 + .timelineSemaphore = device_features.timeline_semaphore, 1539 + }; 1540 + #endif 1541 + 1496 1542 VkPhysicalDeviceFeatures enabled_features = { 1497 1543 .shaderStorageImageWriteWithoutFormat = device_features.shader_storage_image_write_without_format, 1498 1544 }; ··· 1508 1554 1509 1555 #ifdef VK_EXT_robustness2 1510 1556 if (vk->has_EXT_robustness2) { 1511 - // This struct is a in/out struct, while device_create_info has a const pNext. 1512 - robust_info.pNext = (void *)device_create_info.pNext; 1513 - device_create_info.pNext = (void *)&robust_info; 1557 + append_to_pnext_chain((VkBaseInStructure *)&device_create_info, (VkBaseInStructure *)&robust_info); 1558 + } 1559 + #endif 1560 + 1561 + #ifdef VK_KHR_timeline_semaphore 1562 + if (vk->has_KHR_timeline_semaphore) { 1563 + append_to_pnext_chain((VkBaseInStructure *)&device_create_info, 1564 + (VkBaseInStructure *)&timeline_semaphore_info); 1514 1565 } 1515 1566 #endif 1516 1567
+4
src/xrt/auxiliary/vk/vk_helpers.h
··· 65 65 66 66 bool is_tegra; 67 67 68 + //! Were timeline semaphores requested, available, and enabled? 69 + bool timeline_semaphores; 70 + 68 71 VkDebugReportCallbackEXT debug_report_cb; 69 72 70 73 VkPhysicalDeviceMemoryProperties device_memory_props; ··· 418 421 { 419 422 bool shader_storage_image_write_without_format; 420 423 bool null_descriptor; 424 + bool timeline_semaphore; 421 425 }; 422 426 423 427 /*!