mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-22 07:24:34 +00:00
Small cleanup.
- Replaced GenericFeaturesPNextNode's set function with a template constructor. - Moved validation asserts for extension feature structs into source. - Dispatch table now generates in UTF-8.
This commit is contained in:
parent
867376d01e
commit
c66158e87c
@ -39,6 +39,7 @@ import sys
|
||||
import subprocess
|
||||
import pkg_resources
|
||||
import copy
|
||||
import codecs
|
||||
from string import Template
|
||||
|
||||
installed = {pkg.key for pkg in pkg_resources.working_set}
|
||||
@ -287,7 +288,7 @@ body += '} // namespace vkb'
|
||||
|
||||
header = license + info + body
|
||||
|
||||
header_file = open("../src/VkBootstrapDispatch.h", "w")
|
||||
header_file = codecs.open("../src/VkBootstrapDispatch.h", "w", "utf-8")
|
||||
header_file.write(header)
|
||||
header_file.close();
|
||||
|
||||
|
@ -1137,6 +1137,17 @@ PhysicalDeviceSelector::PhysicalDeviceSelector(Instance const& instance) {
|
||||
}
|
||||
|
||||
detail::Result<PhysicalDevice> PhysicalDeviceSelector::select() const {
|
||||
|
||||
// Validation
|
||||
for(const auto& node : criteria.extended_features_chain) {
|
||||
assert(node.sType != 0 && "Features struct sType must be filled with the struct's "
|
||||
"corresponding VkStructureType enum");
|
||||
assert(
|
||||
node.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
|
||||
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An "
|
||||
"instance of this is managed internally for selection criteria and device creation.");
|
||||
}
|
||||
|
||||
if (!instance_info.headless && !criteria.defer_surface_initialization) {
|
||||
if (instance_info.surface == VK_NULL_HANDLE)
|
||||
return detail::Result<PhysicalDevice>{ PhysicalDeviceError::no_surface_provided };
|
||||
|
@ -121,7 +121,10 @@ struct GenericFeaturesPNextNode {
|
||||
|
||||
GenericFeaturesPNextNode();
|
||||
|
||||
template <typename T> void set(T const& features) { *reinterpret_cast<T*>(this) = features; }
|
||||
template <typename T>
|
||||
GenericFeaturesPNextNode(T const& features) {
|
||||
*reinterpret_cast<T*>(this) = features;
|
||||
}
|
||||
|
||||
static bool match(GenericFeaturesPNextNode const& requested, GenericFeaturesPNextNode const& supported);
|
||||
|
||||
@ -459,15 +462,7 @@ class PhysicalDeviceSelector {
|
||||
#if defined(VK_API_VERSION_1_1)
|
||||
template <typename T>
|
||||
PhysicalDeviceSelector& add_required_extension_features(T const& features) {
|
||||
assert(features.sType != 0 && "Features struct sType must be filled with the struct's "
|
||||
"corresponding VkStructureType enum");
|
||||
assert(
|
||||
features.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
|
||||
"Do not pass VkPhysicalDeviceFeatures2 as a required extension feature structure. An "
|
||||
"instance of this is managed internally for selection criteria and device creation.");
|
||||
detail::GenericFeaturesPNextNode node;
|
||||
node.set(features);
|
||||
criteria.extended_features_chain.push_back(node);
|
||||
criteria.extended_features_chain.push_back(features);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright © 2021 Cody Goodson (contact@vibimanx.com)
|
||||
* Copyright © 2021 Cody Goodson (contact@vibimanx.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the “Software”), to deal in the Software without restriction, including without
|
||||
* documentation files (the “Software”), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
Loading…
Reference in New Issue
Block a user