Refactor instance creation #1455
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a suggestion on how the instance creation could be simplified.
The main goal was to move all the application specific logic out of
vkb::core::Instanceintovkb::VulkanSampleand the sample specific code.This means that the
vkb::core::Instanceconstructor now only receives the data that is to be used for the actual instantiation and checks its validity. As the structures chained into thevk::InstanceCreateInfoviapNextmight depend on the actually enabled layers or extensions, it also takes a function to determine those structures.In
vkb::VulkanSample::create_instance, a couple of virtual functions are called (get_name,get_api_version,request_layers,request_instance_extension) or provided (get_instance_create_info_extensions) to actually get the data needed to instantiate thatvkb::core::Instance. The default implementations invkb::VulkanSamplefit to the needs of most samples, and some samples override some of them for special needs. Those virtual functions replace some calls previously done in the samples constructor or prepare function.To summarize, this MR makes more clear when and where data needed for vkb::core::Instance creation is provided by the samples.
Build tested on Win11 with VS2022. Run tested on Win10 with NVidia GPU.
General Checklist:
Please ensure the following points are checked:
Note: The Samples CI runs a number of checks including:
If this PR contains framework changes:
batchcommand line argument to make sure all samples still work properlySample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: