Fix vsg::DeviceFeatures.cpp to return a VkPhysicalDeviceFeatures2 to pass into VkDeviceCreateInfo.pNext. - #1744
St0fF-NPL-ToM wants to merge 4 commits into
Conversation
…pass into VkDeviceCreateInfo.pNext. Problem: Map-internal comparison does not assure VkPhysicalDeviceFeatures2 being "first", as e.g. VkPhysicalDeviceMultiviewFeatures gets sorted up front ( 1000059000 vs. 1000053001 → see vulkan_core.h)
|
I have done a first pass review and it looks a bit convoluted. Engineers coming after us and perhaps ourselves in a few months will look at the code and be perplexed why it's doing what it's doing. Could you provide a code snippet that illustrates the problem usage that you came across, I can't have a think about this and the public API and implementation of vsg::DeviceFeatures to avoid issues. |
|
The problem itself: original assumption simply does not hold anymore due to Vulkan additions. Which means: the original intention behind using a map for AUTOMATIC ORDERING BY VK_STRUCTURE_TYPE doesn't work anymore. My intent - no change upon the public API - lead to fixing the output function and adding a safety-net (that "get();" call in the CTor). I strongly agree this is far from perfect and it should be at least "outstandingly documented in code" - or completely rewritten. This only fixes the symptoms … … just had a quick review myself and found a bug:
QuestionWhat would you choose, now that |
|
About "problem usage" - i guess you mean a real world use case - that is why I do not understand the question. The whole interface is made for customization of yet unknown upcoming vulkan features. You did not need a use case for creating it in the first place. Now a central assumption was flipped by such "an upcoming update". Why do you need a motivation, now? |
- change storage container type to simple std::list - rewritten get() template function to: - directly return already created structs - behaviour as before - insert and return the struct get<>() was called for - insert the required PhysicalDeviceFeatures2-Struct at the beginning in case there is none as soon as any other struct is added - rewritten data() function to: - short-circuit undeclared features (as before) - use the list to forward-chain all structs together and return the first.
|
I need bit of example code that illustrates the problem you are seeing. I could guess at what is causing the problem on your system and then see if the suggested changes, or my own changes fixes this, but I may well have not recreated the problem you are seeing, so my testing might well be completely off. So, it's best to have a concrete bit of code that fails on your system, that I can test with myself and use for investigating the issue and then confirming that the issue is resolved by what ever changes are finally checked in. |
|
Please understand the problem at hand instead. Something happened (even some time ago) that you:
→ Vulkan/Khronos added VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES with a smaller value
Therefore using a map to assume the first entry being the VkPhysicalDeviceFeatures2 is not possible anymore, because I'm sorry if I am not able to translate something very clearly logically that is said in 1.5 sentences in German into understandable English. |
|
And for testing code:
expected outcome (my results within NSight on Windows): validation layers will report violations upon using the extra features: feature is not enabled. At first, I did not understand the meaning of the specs. It seems the VkPhysicalDeviceFeatures2 structure inside the pNext chain starts a feature-enabling mechanism during device creation. Any other Feature-Structs seem to get ignored. Furthermore, they seem to get handled as if "nullptr", ignoring VkPhysicalDeviceFeatures2 further down the chain. So my final conclusion on how to read the specs:
Which - at the end - leaves only "VkPhysicalDeviceFeatures2 needs to exist at the top of the chain". |
Pull Request Template
Description
Problem: Map-internal comparison does not assure VkPhysicalDeviceFeatures2 being "first", as e.g. VkPhysicalDeviceMultiviewFeatures gets sorted up front ( 1000059000 vs. 1000053001 → see vulkan_core.h)
But: specs state "For all features, including the Core 1.0 Features, use VkPhysicalDeviceFeatures2 to pass into VkDeviceCreateInfo.pNext"
Type of change
How Has This Been Tested?
tr, e.g. from command line parameters,Checklist:
Trivia
I just stumbled over this. Didn't actually need Multiview, but enabled it and ASAP NSight went into Validation Violation mode ;)