|
29 | 29 | * implemented as library code which can be swapped for alternative |
30 | 30 | * implementations on a per-layer basis if needed. |
31 | 31 | */ |
32 | | -#include <vulkan/utility/vk_safe_struct.hpp> |
33 | 32 | #include <vulkan/utility/vk_struct_helper.hpp> |
34 | 33 |
|
35 | 34 | #include "framework/manual_functions.hpp" |
@@ -370,22 +369,15 @@ static void enableInstanceVkExtDebugUtils(vku::safe_VkInstanceCreateInfo& create |
370 | 369 | } |
371 | 370 | } |
372 | 371 |
|
373 | | -/** |
374 | | - * Enable VK_KHR_timeline_semaphore if not enabled. |
375 | | - * |
376 | | - * Enabling this requires passing the extension string to vkCreateDevice(), |
377 | | - * and passing either VkPhysicalDeviceTimelineSemaphoreFeatures or |
378 | | - * VkPhysicalDeviceVulkan12Features with the feature enabled. |
379 | | - * |
380 | | - * If the user has the extension enabled but the feature disabled we patch |
381 | | - * their existing structures to enable it. |
382 | | - * |
383 | | - * @param createInfo The createInfo we can search to find user config. |
384 | | - * @param supported The list of supported extensions. |
385 | | - */ |
386 | | -static void enableDeviceVkKhrTimelineSemaphore(vku::safe_VkDeviceCreateInfo& createInfo, |
387 | | - const std::vector<std::string>& supported) |
| 372 | +/* See header for documentation. */ |
| 373 | +void enableDeviceVkKhrTimelineSemaphore(Instance& instance, |
| 374 | + VkPhysicalDevice physicalDevice, |
| 375 | + vku::safe_VkDeviceCreateInfo& createInfo, |
| 376 | + std::vector<std::string>& supported) |
388 | 377 | { |
| 378 | + UNUSED(instance); |
| 379 | + UNUSED(physicalDevice); |
| 380 | + |
389 | 381 | static const std::string target {VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME}; |
390 | 382 |
|
391 | 383 | // We know we can const-cast here because createInfo is a safe-struct clone |
@@ -445,21 +437,15 @@ static void enableDeviceVkKhrTimelineSemaphore(vku::safe_VkDeviceCreateInfo& cre |
445 | 437 | } |
446 | 438 | } |
447 | 439 |
|
448 | | -/** |
449 | | - * Enable VK_EXT_image_compression_control if not enabled. |
450 | | - * |
451 | | - * Enabling this requires passing the extension string to vkCreateDevice(), |
452 | | - * and passing VkPhysicalDeviceImageCompressionControlFeaturesEXT. |
453 | | - * |
454 | | - * If the user has the extension enabled but the feature disabled we patch |
455 | | - * their existing structures to enable it. |
456 | | - * |
457 | | - * @param createInfo The createInfo we can search to find user config. |
458 | | - * @param supported The list of supported extensions. |
459 | | - */ |
460 | | -static void enableDeviceVkExtImageCompressionControl(vku::safe_VkDeviceCreateInfo& createInfo, |
461 | | - std::vector<std::string>& supported) |
| 440 | +/* See header for documentation. */ |
| 441 | +void enableDeviceVkExtImageCompressionControl(Instance& instance, |
| 442 | + VkPhysicalDevice physicalDevice, |
| 443 | + vku::safe_VkDeviceCreateInfo& createInfo, |
| 444 | + std::vector<std::string>& supported) |
462 | 445 | { |
| 446 | + UNUSED(instance); |
| 447 | + UNUSED(physicalDevice); |
| 448 | + |
463 | 449 | static const std::string target {VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME}; |
464 | 450 |
|
465 | 451 | // We know we can const-cast here because createInfo is a safe-struct clone |
@@ -792,32 +778,19 @@ VKAPI_ATTR VkResult VKAPI_CALL layer_vkCreateDevice_default(VkPhysicalDevice phy |
792 | 778 | vku::safe_VkDeviceCreateInfo newCreateInfoSafe(pCreateInfo); |
793 | 779 | auto* newCreateInfo = reinterpret_cast<VkDeviceCreateInfo*>(&newCreateInfoSafe); |
794 | 780 |
|
795 | | - // Enable extra extensions |
796 | | - for (const auto& newExt : Device::extraExtensions) |
| 781 | + // Apply all required patches to the VkDeviceCreateInfo |
| 782 | + for (const auto patch : Device::createInfoPatches) |
797 | 783 | { |
798 | | - if (newExt == VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME) |
799 | | - { |
800 | | - |
801 | | - enableDeviceVkKhrTimelineSemaphore(newCreateInfoSafe, |
802 | | - supportedExtensions); |
803 | | - } |
804 | | - else if (newExt == VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME) |
805 | | - { |
806 | | - enableDeviceVkExtImageCompressionControl(newCreateInfoSafe, |
807 | | - supportedExtensions); |
808 | | - } |
809 | | - else |
810 | | - { |
811 | | - LAYER_ERR("Unknown instance extension: %s", newExt.c_str()); |
812 | | - } |
| 784 | + patch(*layer, physicalDevice, newCreateInfoSafe, supportedExtensions); |
813 | 785 | } |
814 | 786 |
|
815 | | - // Log extensions for debug purposes |
| 787 | + // Log extensions after patching for debug purposes |
816 | 788 | for (uint32_t i = 0; i < newCreateInfo->enabledExtensionCount; i++) |
817 | 789 | { |
818 | 790 | LAYER_LOG("Requested device extension list: [%u] = %s", i, newCreateInfo->ppEnabledExtensionNames[i]); |
819 | 791 | } |
820 | 792 |
|
| 793 | + // TODO: Issue #123: Why can't we just use layer.driver.vkGetInstanceProcAddr? |
821 | 794 | auto fpCreateDeviceRaw = fpGetInstanceProcAddr(layer->instance, "vkCreateDevice"); |
822 | 795 | auto fpCreateDevice = reinterpret_cast<PFN_vkCreateDevice>(fpCreateDeviceRaw); |
823 | 796 | if (!fpCreateDevice) |
|
0 commit comments