-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionally enabling device features #269
Comments
As far as implementation goes, I'm not sure a callback is necessary or even desired. In my mind I would just want to pass in the features struct with the features I optionally want set to true, and get back a bool telling me if they are enabled. That said, being able to directly modify the user's features struct would be nice. What I worry about is making Yes, we probably should move mem_fn inside the implementation since templates are easy to misuse. Implementation for my 'basic bool check' bool enable_all_features_if_available(VkPhysicalDeviceFeatures feats) {
bool can_enable = true;
can_enable = feats.f1 ? can_enable && physical_device.available_feats.f1 : can_enable;
// Early exit if false
if (!can_enable) return false;
physical_device.feats_to_enable.f1 = physical_device.feats_to_enable.f1 && feats.f1;
// repeat for all features
return true;
} I guess the issues I would like to see solved is being able to specify several optional features at the same time, and handling all of the VkPhysDevFeats2 structs. |
In my local implementation, the
Actually, for me I'd prefer if I could specify a few features I'd like optionally and then see if they were enabled through
How would this even work, when you'd need to dynamically know what
As for the several optional features, using a parameter pack could work but I kinda don't like specifying them in bulk, seeing as there might be other conditions for individual features. |
I've gone ahead and implemented what I thought was a reasonable interface for 1.0 features as well as 1.1+/extension features. I probably should document that this wont enable the extensions along side it, cause that's a different can of worms. |
My main issue with your proposal and the implementation found in #273 is that I cannot do this: VkPhysicalDeviceFeatures textureCompressionFeatures {
.textureCompressionETC2 = VK_TRUE,
.textureCompressionASTC_LDR = VK_TRUE,
.textureCompressionBC = VK_TRUE,
};
physicalDevice.enable_features_if_present(textureCompressionFeatures); and instead, need to do this, because the VkPhysicalDeviceFeatures textureCompressionETCFeatures {
.textureCompressionETC2 = VK_TRUE,
};
physicalDevice.enable_features_if_present(textureCompressionETCFeatures);
VkPhysicalDeviceFeatures textureCompressionASTCFeatures {
.textureCompressionASTC_LDR = VK_TRUE,
};
physicalDevice.enable_features_if_present(textureCompressionASTCFeatures);
VkPhysicalDeviceFeatures textureCompressionBCFeatures {
.textureCompressionBC = VK_TRUE,
};
physicalDevice.enable_features_if_present(textureCompressionBCFeatures); That seems overly complicated to me, quite frankly. However, it is still possible to add my proposal with Also, the current PR modifies the |
My main holdup with mem_fn is that it appears to only work with the 1.0 features struct, and there are way more features than just 1.0. Yes, combine only works when “all” features are present - this allows setting groups of settings all at once and know if they all are supported. Allowing ”any” feature to be enabled would be difficult to know which features are actually supported, unless the struct was taken as non const and I assumed users will check the structs contents - which is not as good. Of course both could be supported with a function for all and another for “any”. Also really appreciate the review and feedback, seems you are finding bugs in the implementation as well as design issues with it. Being able to enable a single feature with mem_fn is nice, I just wish it supported multiple structs gracefully (or maybe it can and i just don’t know how yet). |
That was definitely an oversight. No reason to have a |
@charles-lunarg Just tested the PR locally with the new changes, and it works great. Thank you very much. |
Some physical device features can be useful for an application, but not necessary. For example, in my application, I'd like to enable the BC, ASTC, or the ECS texture compression features if they are available. If I would do
add_required_extensions
the physical device selection would fail as often not all three features are available. Therefore, I'd like to see some functionality on the physical device selector or the device builder to specify optional features or features to be enabled, if they are available.I would propose a function on the device builder that enables a feature if it is available, using
std::mem_fn
. This would look something like this:@charles-lunarg Does this look like a good idea to you? I would implement a PR for this right now I have your blessing.
Also, another question, but is it intended that
physical_device.features
only represents the enabled features?The text was updated successfully, but these errors were encountered: