diff --git a/attachments/03_physical_device_selection.cpp b/attachments/03_physical_device_selection.cpp index 5e1d8b66..2fa96044 100644 --- a/attachments/03_physical_device_selection.cpp +++ b/attachments/03_physical_device_selection.cpp @@ -141,7 +141,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -167,10 +167,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria diff --git a/attachments/04_logical_device.cpp b/attachments/04_logical_device.cpp index 1d3748ed..a8c285a3 100644 --- a/attachments/04_logical_device.cpp +++ b/attachments/04_logical_device.cpp @@ -146,7 +146,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -172,10 +172,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria @@ -205,11 +207,16 @@ class HelloTriangleApplication auto graphicsIndex = static_cast(std::distance(queueFamilyProperties.begin(), graphicsQueueFamilyProperty)); // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f; diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index a7bfb80b..bb7b4bee 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -144,7 +144,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -180,10 +180,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria @@ -223,11 +225,16 @@ class HelloTriangleApplication } // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f; diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index af229c3e..d6bb7724 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -152,7 +152,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -188,10 +188,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria @@ -231,11 +233,16 @@ class HelloTriangleApplication } // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f; diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index bbdfd11b..a6cb5c23 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -153,7 +153,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -189,10 +189,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria @@ -232,11 +234,16 @@ class HelloTriangleApplication } // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f; diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index c18d2189..8705c201 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -154,7 +154,7 @@ class HelloTriangleApplication vk::DebugUtilsMessageSeverityFlagsEXT severityFlags(vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError); vk::DebugUtilsMessageTypeFlagsEXT messageTypeFlags( - vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); + vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation); vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoEXT{.messageSeverity = severityFlags, .messageType = messageTypeFlags, .pfnUserCallback = &debugCallback}; @@ -190,10 +190,12 @@ class HelloTriangleApplication }); // Check if the physicalDevice supports the required features - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria @@ -233,11 +235,16 @@ class HelloTriangleApplication } // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f; diff --git a/en/03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.adoc b/en/03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.adoc index cdf164c7..feb643bf 100644 --- a/en/03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/03_Physical_devices_and_queue_families.adoc @@ -232,8 +232,12 @@ Finally, we need to check that all optionally supported required features are ac [,c++] ---- -auto features = physicalDevice.template getFeatures2(); -bool supportsRequiredFeatures = features.template get().dynamicRendering && +auto features = physicalDevice.template getFeatures2(); +bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; ---- @@ -265,11 +269,13 @@ bool isDeviceSuitable( vk::raii::PhysicalDevice const & physicalDevice ) { return strcmp( availableDeviceExtension.extensionName, requiredDeviceExtension ) == 0; } ); } ); - // Check if the physicalDevice supports the required features (dynamic rendering and extended dynamic state) - auto features = - physicalDevice - .template getFeatures2(); - bool supportsRequiredFeatures = features.template get().dynamicRendering && + // Check if the physicalDevice supports the required features (shader draw parameters, dynamic rendering and extended dynamic state) + auto features = physicalDevice.template getFeatures2(); + bool supportsRequiredFeatures = features.template get().shaderDrawParameters && + features.template get().dynamicRendering && features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria diff --git a/en/03_Drawing_a_triangle/00_Setup/04_Logical_device_and_queues.adoc b/en/03_Drawing_a_triangle/00_Setup/04_Logical_device_and_queues.adoc index c713d1d3..16c0a50d 100644 --- a/en/03_Drawing_a_triangle/00_Setup/04_Logical_device_and_queues.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/04_Logical_device_and_queues.adoc @@ -94,11 +94,16 @@ The C++ Vulkan API provides a helper template called `vk::StructureChain` that m [,c++] ---- // Create a chain of feature structures -vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 (empty for now) - {.dynamicRendering = true }, // Enable dynamic rendering from Vulkan 1.3 - {.extendedDynamicState = true } // Enable extended dynamic state from the extension -}; +vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 (empty for now) + {.shaderDrawParameters = true}, // Enable shader draw parameters from Vulkan 1.1 + {.dynamicRendering = true}, // Enable dynamic rendering from Vulkan 1.3 + {.extendedDynamicState = true} // Enable extended dynamic state from the extension + }; ---- Here's what's happening in this code: @@ -106,8 +111,9 @@ Here's what's happening in this code: 1. We create a `vk::StructureChain` with three different feature structures. 2. For each structure in the chain, we provide an initializer: - The first structure (`vk::PhysicalDeviceFeatures2`) is left empty with `{}` - - In the second structure, we enable the `dynamicRendering` feature from Vulkan 1.3 - - In the third structure, we enable the `extendedDynamicState` feature from an extension + - In the second structure, we enable the `shaderDrawParameters` feature from Vulkan 1.1 + - In the third structure, we enable the `dynamicRendering` feature from Vulkan 1.3 + - In the fourth structure, we enable the `extendedDynamicState` feature from an extension The `vk::StructureChain` template automatically connects these structures together by setting up the `pNext` pointers between them. This saves us from having to manually link each structure to the next one. diff --git a/en/03_Drawing_a_triangle/01_Presentation/00_Window_surface.adoc b/en/03_Drawing_a_triangle/01_Presentation/00_Window_surface.adoc index 4ad0c375..9f8fea10 100644 --- a/en/03_Drawing_a_triangle/01_Presentation/00_Window_surface.adoc +++ b/en/03_Drawing_a_triangle/01_Presentation/00_Window_surface.adoc @@ -209,11 +209,16 @@ void createLogicalDevice() { } // query for Vulkan 1.3 features - vk::StructureChain featureChain = { - {}, // vk::PhysicalDeviceFeatures2 - {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features - {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT - }; + vk::StructureChain + featureChain = { + {}, // vk::PhysicalDeviceFeatures2 + {.shaderDrawParameters = true}, // vk::PhysicalDeviceVulkan11Features + {.dynamicRendering = true}, // vk::PhysicalDeviceVulkan13Features + {.extendedDynamicState = true} // vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT + }; // create a Device float queuePriority = 0.5f;