diff --git a/script/generate_dispatch.py b/script/generate_dispatch.py index 688b874..c30016e 100644 --- a/script/generate_dispatch.py +++ b/script/generate_dispatch.py @@ -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(); diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 52db701..8f6b21b 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -1137,6 +1137,17 @@ PhysicalDeviceSelector::PhysicalDeviceSelector(Instance const& instance) { } detail::Result 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{ PhysicalDeviceError::no_surface_provided }; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 8506709..fecbc60 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -121,7 +121,10 @@ struct GenericFeaturesPNextNode { GenericFeaturesPNextNode(); - template void set(T const& features) { *reinterpret_cast(this) = features; } + template + GenericFeaturesPNextNode(T const& features) { + *reinterpret_cast(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 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 diff --git a/src/VkBootstrapDispatch.h b/src/VkBootstrapDispatch.h index d60b592..c5e5924 100644 --- a/src/VkBootstrapDispatch.h +++ b/src/VkBootstrapDispatch.h @@ -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.