Skip to content

Commit 8d76b5e

Browse files
authored
Used StructureChain for feature quering in createLogicalDevice function
1 parent 109a4f4 commit 8d76b5e

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

en/03_Drawing_a_triangle/01_Presentation/00_Window_surface.adoc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,17 @@ void createLogicalDevice() {
254254
throw std::runtime_error( "Could not find a queue for graphics or present -> terminating" );
255255
}
256256
257-
// query for Vulkan 1.3 features
258-
auto features = physicalDevice.getFeatures2();
259-
vk::PhysicalDeviceVulkan13Features vulkan13Features;
260-
vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures;
261-
vulkan13Features.dynamicRendering = vk::True;
262-
extendedDynamicStateFeatures.extendedDynamicState = vk::True;
263-
vulkan13Features.pNext = &extendedDynamicStateFeatures;
264-
features.pNext = &vulkan13Features;
257+
// Create a chain of feature structures
258+
vk::StructureChain<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan13Features, vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT> featureChain = {
259+
{}, // vk::PhysicalDeviceFeatures2 (empty for now)
260+
{.dynamicRendering = true }, // Enable dynamic rendering from Vulkan 1.3
261+
{.extendedDynamicState = true } // Enable extended dynamic state from the extension
262+
};
263+
265264
// create a Device
266265
float queuePriority = 0.5f;
267266
vk::DeviceQueueCreateInfo deviceQueueCreateInfo { .queueFamilyIndex = graphicsIndex, .queueCount = 1, .pQueuePriorities = &queuePriority };
268-
vk::DeviceCreateInfo deviceCreateInfo{ .pNext = &features, .queueCreateInfoCount = 1, .pQueueCreateInfos = &deviceQueueCreateInfo };
267+
vk::DeviceCreateInfo deviceCreateInfo{ .pNext = featureChain.get<vk::PhysicalDeviceFeatures2>(), .queueCreateInfoCount = 1, .pQueueCreateInfos = &deviceQueueCreateInfo };
269268
deviceCreateInfo.enabledExtensionCount = deviceExtensions.size();
270269
deviceCreateInfo.ppEnabledExtensionNames = deviceExtensions.data();
271270

0 commit comments

Comments
 (0)