KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 648 forks source link

Requesting extension features also enables all available features #938

Closed SaschaWillems closed 1 month ago

SaschaWillems commented 8 months ago

In a lot of samples we do something like this:

auto &requested_extension_features = gpu.request_extension_features<VkPhysicalDeviceSomeExtensionFeaturesKHR>(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SOME_EXTENSION_FEATURES_KHR);
requested_extension_features.someFeature = VK_TRUE;

But the call to gpu.request_extension_features already sets all supported features to true by calling vkGetPhysicalDeviceFeatures2KHR, which makes the second line (enabling a feature) superfluous.

This doesn't do any harm, but it might confuse people trying to write or debug samples.

asuessenbach commented 8 months ago

One could introduce a new function vkb::PhysicalDevice::get_extension_features<ExtensionFeatureStruct> that could be used like this:

    if (gpu.get_extension_features<VkPhysicalDeviceHostQueryResetFeaturesEXT>().hostQueryReset)
    {
        gpu.request_extension_features<VkPhysicalDeviceHostQueryResetFeaturesEXT>().hostQueryReset= VK_TRUE;
    }

... and would need to adjust all usages of request_extension_features accordingly! ... and modify request_extension_features such that it returns either an empty features struct, or the one already requested before.